I'm converting some code from fortran90 to python 2.7 and am having trouble understanding the arguments the in Open, Write, and Read functions in the fortran code, as well as knowing what elements are necessary to add to the code when I write it in python.
Here are some blocks of the fortran code that I want to understand and convert to python:
OPEN(1,FILE=TRIM(filenameOut),RECL=2000)
WRITE(1,*) "tAge/yr (u-r) (u-z) fGas Mstars/MstarsOld"
CLOSE(1)
I'm guessing that the "1" is just assigning a label to the file name, the TRIM is removing any white space before or after the variable to which the python equivalent would be filenameOut.strip() or something. I'm unsure of what the RECL is doing and what the python equivalents for the other functions would be for this block.
Another example:
OPEN(1,FILE=TRIM(filenameOut),RECL=2000)
WRITE(1,*) "(u-r) prob(u-r)"
DO countInside=1,nColourBins
WRITE(1,*) uMinusrMidpointsArray(countInside),probuMinusrArray(countInside)
CLOSE(1)
From this I would guess that the asterisk is meaning to write to the next line in the file. Again, I'm not sure how to do this in python yet.
An example of reading in the fortran code:
OPEN(1,FILE=TRIM(filenameBC),RECL=2000)
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
IOEnd=0
DO WHILE(IOEnd>-1)
READ(1,*,IOSTAT=IOEnd) logTime,Mbol,g,uMg,gMr,gMi,gMz
END DO
CLOSE(1)
I understand that the repeated READ(1,*) are simply reading off the first 7 lines of the file, but I'm unsure of any python equivalent shortcuts for this, i.e. a way to start at the 8th line or something.