Page 1 of 1
How to add a new subroutine ?
Posted: Thu May 23, 2013 2:49 pm
by zeph67
Hello,
I'm wondering about a proper way to add an own subroutine, using just a few variables. It is a very simple routine, just performing a change in coordinates.
I tried adding a file containing it, I tried adding it in a cs_user_*.f90 file. None works.
So my question is just ; what is the proper way to perform it ?
Thanks a lot in advance.
PS : I'm talking about version 3.0.0
Re: How to add a new subroutine ?
Posted: Sun May 26, 2013 12:44 pm
by Yvan Fournier
Hello,
Normally, you should be able to add as many user subroutines as you want, but be careful where you call them from. For example, modifying coordinates after other geometric values have been computed and not updating them is a very bad idea.
What existing subroutine did you try to call your subroutine from ?
Regards,
Yvan
Re: How to add a new subroutine ?
Posted: Tue Jun 11, 2013 3:31 pm
by zeph67
I called the "new" routines from cs_user_initialization. But in fact I just encountered a stupid calling bug ; everything is fine now.
My routines don't modify coordinates (my first message, above, was clumsy) ; they just perform some frame-transformation for vectors and tensors. For instance, in cs_user_initialization, some of my starting data are expressed in a cylindrical frame, and I simply needed to "translate" them to the cartesian frame where Code_Saturne works.
I also intend to use these routines in cs_user_postprocess_var, in order to post-process e.g. velocities in the cylindrical frame, even though I could do this outside Code_Saturne, of course.
Thanks.
Re: How to add a new subroutine ?
Posted: Tue Jun 11, 2013 4:02 pm
by Yvan Fournier
Hello,
OK, great.
I forgot to mention that if you (or anyone else following this forum) ever need to define your own Fortran 95 modules, it is recommended to put them in a file named cs_user_modules.f90, because a file with that name will be compiled first, so that other files using those modules can be compiled correctly.
Regards,
Yvan
Re: How to add a new subroutine ?
Posted: Tue Jun 11, 2013 5:08 pm
by zeph67
Thanks for the suggestion.
I already use cs_user_modules.f90 but rather for common variable declarations and (de)allocations, which is its first purpose. Let's reckon that it is far more user-friendly (and readable) than the old RTUSER and ITUSER arrays.