The write
function does print the parameters with a lot of spaces between columms, this is giving me a very huge file in the end. so How do I trim the output, to li
You need to take control of the output formatting using Fortran's edit descriptors. If you just want to write 3 integers on a line then you could use
write(1,fmt='(3i2)',err=1001) 1, 2, 3
which will write the integers into 2-character wide fields in the output file. There are many variations of the edit descriptors you should become familiar with. A couple of examples:
fmt='(i4.2)' ! 1 integer is written into a 4-character wide field, with at least 2 digits so a leading 0 is written if necessary
fmt='(6f9.4)' ! 6 reals are written into 9-character fields, with 4 digits after the decimal point
There's a lot more besides this, your compiler documentation will explain everything.
This is just an explanatory comment in addition to what High Performance Mark has written. If you do not provide an explicit format specifier in the WRITE
statement, the so-called list directed output is being used. Each Fortran processor (the Fortran word for compiler) is free to choose an output format that will guarantee that every element in the list will be printed in its entirety. This often leads to very wide (and compiler dependent) fields being used.