CFD Online Logo CFD Online URL
Home > Forums > Siemens

Passing data/variables between subroutines

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   August 16, 2007, 11:42
Default Passing data/variables between subroutines
Emmanuel Resch
Posts: n/a

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):


Then, in the first subroutine called, the array and its pointer need to be defined:



With space in memory allocated by:


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!

  Reply With Quote

Old   August 16, 2007, 12:44
Default Re: Passing data/variables between subroutines
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.
  Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 08:06
Passing of gas thru sand Sans CFX 1 October 15, 2007 04:44
Parallel UDF data passing causes Fluent to hang Tom FLUENT 2 June 9, 2006 13:17
Passing point data to UDF using C_UDMI Sam Bennett FLUENT 6 December 1, 2005 09:46

All times are GMT -4. The time now is 03:33.