Post Reply 
Any tips for FORTRAN I/O?
07-03-2016, 06:59 PM (This post was last modified: 07-03-2016 10:32 PM by StephenG1CMZ.)
Post: #1
Any tips for FORTRAN I/O?
Many datasets still use Fortran-formatted IO files.

For those unfamaliar with Fortran, there is a heavy emphasis on data being in a fixed column on the line.

I have tried generating such output, mainly so that I can verify my input routines before letting them loose on real data.

I am finding that the built-in procedures are not giving me what I had hoped for in this context.

As an example, suppose you want a fixed-format with d digits after the decimal point - not just useful for FORTRAN files, it could also be useful in printing out log tables.

But STRING does not seem to deliver the requested number of digits.

Code:

 
 MR()
 BEGIN
  // WE CAN HAVE UP TO 12 DIGITS OF PRECISION
  STRING(0.1234567891123456789,6,12);
  //BUT MAY SEE LESS
   //HAD HOPED TO SEE DECIMAL POINT IN SAME PLACE
   //FOLLOWED BY SPACES OR ZEROS
  STRING(0.123,5,12);//SEE 0.123=NOT THE REQUESTED PRECISION
 END;
 EXPORT RD()
 BEGIN
  MR();
 END;

I had hoped for a string with 12 positions after the decimal (not accurately, but simply for laying out a formatted column of numbers). Instead STRING sometimes seems to reduce the requested precision - confusing 1.000 with 1.0, in effect.

Am I using precision correctly? Is their a better built-in I have overlooked?
Are there any useful libraries for such formatting?

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-03-2016, 10:27 PM (This post was last modified: 07-03-2016 10:28 PM by StephenG1CMZ.)
Post: #2
RE: Any tips for FORTRAN I/O? The built-in procedures do not help?
Actually
STRING(0.133,2,12)
fixes that particular problem.
I hadn't tried Fixed format earlier, thinking it would give whatever fixed length the system was configured for - but it actually uses the "12" parameter to specify the number of fixed places to show.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)