|
[Sponsors] |
April 22, 2020, 13:30 |
fscanf to read scientific notation
|
#1 |
Member
j
Join Date: Apr 2020
Posts: 34
Rep Power: 0 |
My udf writes (fprintf) some small numbers to .txt files in scientific notation. When I try to use fscanf later to read the file, I get nonsense values. As shown, the numbers in the file are on order of e-8 to e-15 or so. What is read into and shown in the console is nonsense of order e-314. I tried different char values, %f, %g, %e. These all work when writing the data to the file, but don't work when reading it. I have another variable that is an integer list and that one writes and reads in just fine. Any ideas how to fix this?
Thanks! |
|
April 22, 2020, 14:09 |
Specifiers
|
#2 |
Senior Member
|
If you are running simulation in double precision, you need to use %le and not %e. You may also be able to read using %lf. Usually, %e or %le are not meant for reading, only for writing. But l is certainly required in your case if it is double precision.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
Tags |
fscanf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 19:57 |
Parallel Error in ANSYS FLUENT 12 | zeusxx | FLUENT | 25 | July 17, 2015 05:40 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 | UDS_rambler | FLUENT | 2 | November 22, 2011 10:46 |
Problem in running ICEM grid in Openfoam | Tarak | OpenFOAM | 6 | September 9, 2011 18:51 |