07-03-2016, 06:59 PM
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.
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?
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?