CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

fscanf to read scientific notation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 22, 2020, 13:30
Default fscanf to read scientific notation
  #1
Member
 
j
Join Date: Apr 2020
Posts: 34
Rep Power: 0
buckngnr11 is on a distinguished road
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!
buckngnr11 is offline   Reply With Quote

Old   April 22, 2020, 14:09
Default Specifiers
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
vinerm is offline   Reply With Quote

Reply

Tags
fscanf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 10:45.