CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   CD-adapco (http://www.cfd-online.com/Forums/cd-adapco/)
-   -   COMMON blocks for passing arrays -- Please help (http://www.cfd-online.com/Forums/cd-adapco/55347-common-blocks-passing-arrays-please-help.html)

marcus May 5, 2006 11:11

COMMON blocks for passing arrays -- Please help
 
Hello experts,

I am using Star-CD 3.26.

I want to pass an array from subroutine POSDAT to subroutine POROS1.

In older posts i have read that i should use COMMON block statement in both routines, to pass the array.However it doesn't works....

Can anybody write a working example, if possible with pointers (in Star 3.26 for adjustable arrays you have to use pointers)???

I am looking forward for your answers and if possible any working examples, marcus


Ben May 5, 2006 12:04

Re: COMMON blocks for passing arrays -- Please hel
 
Have a look in the back of the user guide, this shows the new coding practices for memory allocation and common blocks for 3.2x so should be usefull as a guide.What you need depends on what you are using, for variable size you need a common statement (declaring name and shape of the array), a pointer (pointing to where it is) and also a memory allocation statement which must be issued in the first subroutine you use (otherwise you will be trying to use a common block that hasnt got memory allocation and the code will crash)


marcus May 5, 2006 16:12

Re: COMMON blocks for passing arrays -- Please hel
 
Dear Ben, thanks for your answer.

According to the user guide i declare the pointer in POSDAT, by the following lines:

---------POSDAT------------------------

DIMENSION UARRAY(NCMAX)

POINTER(P_UARRAY,UARRAY)

COMMON/UCOMM1/P_UARRAY

CALL CDMALLOC(P_UARRAY,IFLSIZ*NCMAX)

do i=1,NCTMAX

UARRAY(i) = 50.0

enddo

and afterwards i add a COMMON statement in POROS1 like that:

COMMON/UCOMM1/P_UARRAY

but with no result....

Can you tell my where am i wrong and if it is possible please send me an example of passing variables between subroutines in STAR-CD to my email address: gonnafon@yahoo.gr


Question May 5, 2006 16:41

Re: COMMON blocks for passing arrays -- Please hel
 
Do you know how to pass common block between two subroutines in fortran?

Well...it is the same in star-cd user-coding

I am not sure it is worth programming user-coding without knowing fortran ?


Ben May 6, 2006 06:06

Re: COMMON blocks for passing arrays -- Please hel
 
I have to agree, I would be quite happy to provide you with a example of common block usage but without the underlying knowledge you arent going to get much further and when it goes wrong you will just be stuck staring at code again. Other than that I recomend that you speak to your support office for a start and/or attend the subroutines training course as well, if you do want the coding still let me know but I cant see you getting much further.

marcus May 6, 2006 07:50

Re: COMMON blocks for passing arrays -- Please hel
 
I am afraid that you are biased towards me.

I have an adequate knowledge of Fortran and i have been able to pass arrays in Fortran code from a subroutine to the main program.

However the exactly same technique doesn't work on Star-CD code...

If you could send me an example of passing the array UARRAY(NCMAX) from posdat.f to poros1.f i would appreciate it.

I just want an example that works on Star.

Thank you for your concerning, my email is gonnafon@yahoo.gr

That will be my final post, sorry for bothering you.

marcus

Ben May 6, 2006 09:46

Re: COMMON blocks for passing arrays -- Please hel
 
lol well you're not bothering me not sure about other people, I was just concerned that you may have trouble expanding the code to other applications. The uarray is just an arbitrary name by the way, you can call it whatever you want. Anyways when I am back at work on monday I will see what I can sort out.


All times are GMT -4. The time now is 18:12.