1

Running Fortran 90 on AIX. I've asked a similar question that was answered, however this is a different error. On compiling, getting this error:

The unformatted I/O statement on the file /filepath/TB_20160610005713bufr_v620.dat cannot be completed because the end of the record was reached. 

I believe it has something to do with the record length, but I don't fully understand the error. What exactly is the I/O statement?

TYPE :: NR_record
 INTEGER ( Short ) :: row
 INTEGER ( Short ) :: col
 REAL ( Single )   :: time
 REAL ( Single )   :: tbh425
END TYPE NR_record   

TYPE (NR_record) :: TB_RECORD

INTEGER,PARAMETER :: GRID_TB_UNIT = 200
INTEGER ( Short ), PARAMETER :: TB_REC_LEN = 22
tbhmap=0

OPEN(UNIT=GRID_TB_UNIT,file=TRIM(TB_binary_filename),STATUS='REPLACE',ACCESS='DIRECT',FORM='UNFORMATTED',RECL=TB_REC_LEN)                        

nrecg = 0
DO rr=1,720

  IF(countgrid(cc,rr) < 1)CYCLE
  nrecg = nrecg+1

  tbhmap(cc,rr) = tbhgrid(cc,rr)/countgrid(cc,rr)
  timemap(cc,rr) = timegrid(cc,rr)/countgrid(cc,rr)

GRID_TB_record%row = rr
GRID_TB_record%col = cc
GRID_TB_record%time = timemap(cc,rr)
GRID_TB_record%tbh425 = tbhmap(cc,rr)

WRITE(GRID_TB_UNIT,REC=nrecg)GRID_TB_record 

END DO

CLOSE(GRID_TB_UNIT)
klex52s
  • 437
  • 1
  • 7
  • 19
  • 2
    The definition of `GRID_TB_record` is missing, so it's hard to answer. Try to define the record length `TB_REC_LEN` dynamically, by `inquire(iolength=TB_REC_LEN) GRID_TB_record` instead of statically by `INTEGER ( Short ), PARAMETER :: TB_REC_LEN = 22`. The idea is to ask how big the record for a given variable has to be, instead of "knowing" that it's `22`. – StefanS Jun 13 '16 at 15:14
  • @francescalus Added that definition to the original code above. – klex52s Jun 13 '16 at 15:25
  • 1
    What are the named constants `Short` and `Single`? Perhaps you can create a [mcve]? – francescalus Jun 13 '16 at 15:31
  • 1
    As StefanS says, use `inquire` to get reclen http://stackoverflow.com/a/37784431/721644 – Vladimir F Героям слава Jun 13 '16 at 15:32
  • @francescalus Short is a 2 byte INTEGER and Single is 4 byte REAL. – klex52s Jun 13 '16 at 15:40

0 Answers0