Hello,
I am performing expansive computations with code_saturne v3.0.0 and I wish to save memory. So I set up code_saturne to write the results files in binary format.
After computation, I usually use a Fortran program to read and post-process the datas in the results files and obtain statistics. And there is a problem to read the binary files with the Fortran program. I found that the problem comes from the different manners to write/read binary files between C and Fortran but I didn't find a way to set a kind of "translator binary C / binary Fortran" (if you see what I mean) when Fortran is reading.
So my question isn't really about code_saturne usage actually. But taking acount that code_saturne is coded in both language, you probably already faced this situation and could help me or give me some tips or related links.
Regards.
Alexis
C / Fortran
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: C / Fortran
Hello,
What binary format are you using ? MED and CGNS both allow for Fortran bindings, which can save you some work. MED saves floating-point data as doubles, while EnSight Gold uses floats, so MED files will be bigger. CGNS allows for both, but we use mainly doubles (to map to the internal representation; floats would save space and be sufficient in most cases).
If you use the EnSight gold format, you can find details on the format on the ensight.com website. To read binary files from Fortran as you would from C (i.e. without record markers), you need to open the file with the access="stream" option. This option is part of the Fortran 2003 standard, so some older compilers, or new ones in f95 mode might not accept it.
Regards,
Yvan
What binary format are you using ? MED and CGNS both allow for Fortran bindings, which can save you some work. MED saves floating-point data as doubles, while EnSight Gold uses floats, so MED files will be bigger. CGNS allows for both, but we use mainly doubles (to map to the internal representation; floats would save space and be sufficient in most cases).
If you use the EnSight gold format, you can find details on the format on the ensight.com website. To read binary files from Fortran as you would from C (i.e. without record markers), you need to open the file with the access="stream" option. This option is part of the Fortran 2003 standard, so some older compilers, or new ones in f95 mode might not accept it.
Regards,
Yvan
Re: C / Fortran
Hi,
I did set up with Access='stream' and after some readings and tests, I finally obtained what I wanted !
Thanks for your help.
Regards
Alexis
I did set up with Access='stream' and after some readings and tests, I finally obtained what I wanted !
Thanks for your help.
Regards
Alexis