- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I know this is basic, yet I would like to know the reason why this happens.
I'm playing with fortran doing the standard, suppose I have a initial condition between [0:2pi]
with a chaoticity parameter K=1.0. If I want to repeat the experiment numerically I read from
a file the initial condition that I use in the first experiment. I check the results by looking at it
and I notice that although I read and start with the same number (e.g. 0.475265000237136 2.58735041435918)
after 3 or 5 steps of applying the map over this initial conditions I see differences in the numerical results.
This obviously says that there's something different between the data read from a file and the data that one
creates to to calculations on the fly. Why is that?
Thanks,
Adrian
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you read the data from a file, are the values stored as formatted text in the file, or are you using UNFORMATTED files? Does the precision of the variables in memory match the precision of the values written into the file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I write the data on a file in this way:
Write(names,*) theta_init(control), I_init(control)
And I read it in similar fashion:
Read(names,*) theta_init(control), I_init(control)
If I look both results on screen they give me the same numerical value, for instance,
0.475265000237136 2.58735041435918
-Adrian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What are the declared types of variables control, theta_init and I_init? The binary representations of the values of REAL variables may become altered in the least significant bit after writing and reading back. WIth a chaotic map, such a change can quickly lead to noticeable differences with fewer applications of the map than if the variables had been DOUBLE PRECISION type..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Open the files with FORT='UNFORMATTED' or FORM='BINARY' to write and read the full binary format of the internal variable values (this file will not be readable using an editor).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
my arrays are declared as follows
Real(r8), Allocatable :: I_init(:), theta_init(:)
so they're double precision variables. I will try the binary or unformatted options.
This is interesting, which is the philosophycal reason that the actual values are modify
if one write and read in a certain format?
-Adrian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
jimdempseyatthecove wrote:
Open the files with FORT='UNFORMATTED' or FORM='BINARY' to write and read the full binary format of the internal variable values (this file will not be readable using an editor).
Jim Dempsey
access='stream' (supported by most currently maintained Fortran compilers) is the standard version of the legacy 'binary' options available in several compilers. The literature seems to indicate this was adopted more to afford inte-language compatibility than for performance. form="UNFORMATTED" goes back to F77 ahd beyond but the file formats may not work among compilers.
"most" current compilers (and their run-time libraries) adhere to the (somewhat complicated) IEEE rules for formatted data. By writing a sufficient number of decimal significant figures (9 for 32-bit single precision, 17 for 64-bit double), loss-less reversible conversions may be maintained to the extent they are feasible. Needless to say, following such prescriptions implies a penalty in performance and file size.
The standards don't require list-directed formatting to use enough decimals to accomplish such goals. In the likely case where it's important to you, specific formatting is indicated.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page