Any tips for FORTRAN I/O? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Any tips for FORTRAN I/O? (/thread-6499.html) |
Any tips for FORTRAN I/O? - StephenG1CMZ - 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. Code:
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? RE: Any tips for FORTRAN I/O? The built-in procedures do not help? - StephenG1CMZ - 07-03-2016 10:27 PM 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. |