CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens

Passing data/variables between subroutines

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 16, 2007, 12:42
Default Passing data/variables between subroutines
  #1
Emmanuel Resch
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.
  Reply With Quote

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

Reply


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 Off
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 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


All times are GMT -4. The time now is 01:30.