- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I have created the following TYPE variables:
TYPE tPARAM INTEGER :: ncl REAL, ALLOCATABLE,DIMENSION(:) :: SET END TYPE tPARAM
then I allocate the following variables:
TYPE(tPARAM), DIMENSION(0:nParam) :: PAR2HY
and
DO iParam=0,nParam ncl = PARAM(iParam)%ncl ALLOCATE(PAR2HY(iParam)%SET(ncl)) ENDDO
I would like to pass it to a subroutine as:
SUBROUTINE PRINT_PARAMETRS(fileunit,fname,nParam,PARAM,eff) USE VARS_TYPE IMPLICIT NONE !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INTEGER, INTENT(IN) :: fileunit CHARACTER(100), INTENT(IN) :: fname INTEGER, INTENT(IN) :: nParam TYPE(tPARAM), INTENT(IN) :: PARAM REAL, INTENT(IN) :: eff
Now the question:
The fact that I have also
PAR2HY(iParam)%SET(ncl)
where also SET is allocate will give me some problems? If yes, how can I avoid it?
Thank a lot
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@diedro,
Given your original post, you shouldn't have a problem but you don't show much and nor is your code snippet a complete reproducer so one can't be sure. However you are asking a basic question, so a few suggestions:
- You may want to review references in this blog https://software.intel.com/en-us/blogs/2013/12/30/doctor-fortran-in-its-a-modern-fortran-world, the books in there can best guide you in terms of Fortran language.
- You can review examples at the Fortran Wiki Tutorials page http://fortranwiki.org/fortran/show/Tutorials ;and try them with your compiler e.g., Intel Fortran and that can help you design your code,
- Also look at various Fortran projects at GitHub https://github.com/trending/fortran, there's a lot you can pick up from all the open source codes made available there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear FortranFan, Dear all,
if you want, I could send a fortran example code. This could really help me.
What do
I will also look the links that you send me.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your subroutine declarations appear incorrect. You are declaring nParam and PARAM which seem to imply PARAM is to be an array (with nParam things). Yet PARAM is declared as a single "thing" of type tPARAM. Did you intend for your code to read as:
SUBROUTINE PRINT_PARAMETRS(fileunit,fname,nParam,PARAM,eff) USE VARS_TYPE IMPLICIT NONE !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INTEGER, INTENT(IN) :: fileunit CHARACTER(100), INTENT(IN) :: fname INTEGER, INTENT(IN) :: nParam TYPE(tPARAM), INTENT(IN) :: PARAM(nParam) REAL, INTENT(IN) :: eff
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Deal all, Dear Jim,
really really thanks. I get it.
I have also to put nParam.
Now, my concerns even more then before are about PARAM it self. Indeed PARAM is a "Type" with allocated arguments:
ALLOCATE(PARAM(iParam)%SET(ncl))
outside the subroutine call.
What do you think?
Thank again,
Diego

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page