CS ignores Fortran user coding files on macOS

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
panos
Posts: 3
Joined: Sat Jun 18, 2022 12:59 pm

CS ignores Fortran user coding files on macOS

Post by panos »

I compiled code_saturne 7.1 on MacOS (Monterey, M1, gcc 11 from MacPorts) without any compilation errors. However, when I try to run a case which contains user coding files in Fortran I found out that they are ignored and the resulting code_saturne executable contains the empty user functions.

However, this is not the case for C user coding files which appear to be working properly! The compiler.log contains no error messages to indicate some compilation issue and both C and Fortran user coding files are compiled.

I realised that this is the case because C user coding produces messages on the screen when running a case but not the Fortran user coding when I insert "write" statements. So, I assume that the standard empty functions are used and the linked object files after the compilation are ignored.

Has anyone experienced a similar problem and are there any suggestions for a way to handle this problem?
panos
Posts: 3
Joined: Sat Jun 18, 2022 12:59 pm

Re: CS ignores Fortran user coding files on macOS

Post by panos »

There is an interesting article in

http://www.goldsborough.me/c/low-level/ ... ad-_trick/

which describes a method to override functions for any UNIX and macOS system reliably.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: CS ignores Fortran user coding files on macOS

Post by Yvan Fournier »

Hello Panos,

Do C user functions work normally here0 ? For C, we use #pragma weak for reference files which should work with gcc or clang and give priority to actual user functions.

In Fortran, I did not find a similar option...

Best regards,

Yvan
panos
Posts: 3
Joined: Sat Jun 18, 2022 12:59 pm

Re: CS ignores Fortran user coding files on macOS

Post by panos »

Hello Yvan,

I think that it is the presence of this pragma directive that does the trick for C user routines. A test with some small code I wrote showed that this is the way for functions to be replaced reliably. I also had a look for something similar for Fortran but all I found was a feature request for gfortran to support weak symbols with a compiler directive many years ago. Until today there is no way for Fortran symbols to be marked as weak. Hopefully, one day soon, all Fortran code will be removed from code_saturne and user coding will be in C only.
Post Reply