|
[Sponsors] |
August 16, 2007, 12:42 |
Passing data/variables between subroutines
|
#1 |
Guest
Posts: n/a
|
Hello,
I'm having a bit of trouble passing variables and data between subroutines. Using v3.26, I understand that the procedure for declaring/passing an array "UARRAY" of variable size is the following: First, a common block statement (req'd for every subroutine): COMMON/UCOMM1/P_UARRAY Then, in the first subroutine called, the array and its pointer need to be defined: DIMENSION UARRAY(NCMAX) POINTER(P_UARRAY,UARRAY) With space in memory allocated by: CALL CDMALLOC(P_UARRAY,IFLSIZ*NCMAX) I am having difficulties with this... I am using the following subroutines which employ these arrays: sorsca.f, sorent.f, posdat.f QUESTION: Which of these subroutines is called first, i.e. in which subroutine should I have the variable definition/memory allocation statements? If anyone had some example files that would be a great help! Thanks. |
|
August 16, 2007, 13:44 |
Re: Passing data/variables between subroutines
|
#2 |
Guest
Posts: n/a
|
You could do the memory allocation in your own subroutine, called from all three user subroutines. In that subroutine, have a logical with SAVE attribute, say INIT. Initialize INIT to false in a DATA statement. Just return if it is true, but allocate the memory and set INIT to true otherwise. Then you don't need to know the call sequence and you can guarantee that the memory will be allocated when needed, and just once. The subroutine could also initialize the memory as well as allocating it.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Passing fortran variables to C in mixed programmin | Quarkz | Main CFD Forum | 1 | January 9, 2008 07:17 |
VARIABLES FOR SUBROUTINES | Mika Nuutinen | Siemens | 2 | October 24, 2007 09:06 |
Passing of gas thru sand | Sans | CFX | 1 | October 15, 2007 05:44 |
Parallel UDF data passing causes Fluent to hang | Tom | FLUENT | 2 | June 9, 2006 14:17 |
Passing point data to UDF using C_UDMI | Sam Bennett | FLUENT | 6 | December 1, 2005 09:46 |