Hi guys,
Could anyone help with a problem I am having with a Fortran code? I have written a code to open a file(with binary extension) and want to change this file into an integer format. Using a gfortran compiler on MAC OS, the program compiled well but on trying to execute it, I get this error message:
At line 11 of file convert2integer.f90
Fortran runtime error: End of file
Please, could anyone let me know what is wrong with this program? Here is the code:
PROGRAM convertToInteger
IMPLICIT NONE
REAL(KIND=4), DIMENSION(15,9,1) :: precipitation_real
INTEGER(KIND=4), DIMENSION(15,9) :: precipitation_int
OPEN(UNIT=10, FILE='upas_test.bin', FORM="unformatted", ACCESS="sequential")
OPEN(UNIT=11, FILE='upas_test_int.bin', FORM="unformatted", ACCESS="direct", RECL=15*9*4))
READ(UNIT=10) precipitation_real
precipitation_int = NINT((precipitation_real,:,1)-273.16)*10.)
WRITE(*,'(15I5)') precipitation_int
WRITE(UNIT=11, REC=1) precipitation_int
CLOSE(UNIT=10)
CLOSE(UNIT=11)
END PROGRAM convertToInteger
Could anyone help with a problem I am having with a Fortran code? I have written a code to open a file(with binary extension) and want to change this file into an integer format. Using a gfortran compiler on MAC OS, the program compiled well but on trying to execute it, I get this error message:
At line 11 of file convert2integer.f90
Fortran runtime error: End of file
Please, could anyone let me know what is wrong with this program? Here is the code:
PROGRAM convertToInteger
IMPLICIT NONE
REAL(KIND=4), DIMENSION(15,9,1) :: precipitation_real
INTEGER(KIND=4), DIMENSION(15,9) :: precipitation_int
OPEN(UNIT=10, FILE='upas_test.bin', FORM="unformatted", ACCESS="sequential")
OPEN(UNIT=11, FILE='upas_test_int.bin', FORM="unformatted", ACCESS="direct", RECL=15*9*4))
READ(UNIT=10) precipitation_real
precipitation_int = NINT((precipitation_real,:,1)-273.16)*10.)
WRITE(*,'(15I5)') precipitation_int
WRITE(UNIT=11, REC=1) precipitation_int
CLOSE(UNIT=10)
CLOSE(UNIT=11)
END PROGRAM convertToInteger