Silverfrost Forums

Welcome to our forums

error 57: attempt to read past end-of-file

11 May 2010 9:56 #6363

Hello, I encounter the error: ERROR 57: attempt to read past end-of-file. It occures during the call: CALL RDDUMP(.... [see the first part of the program here under] The file DUMP is created in the first run of the program and runs well. As somebody a solution? Regards Reinoud

C****************************************************************************** PROGRAM EXMPLR C C******************************************************************************* C Restart of EXMPL, default values, Jacobian derivatives exact *** C******************************************************************************* INTEGER MXLEV, NPD, NPTS, LENIWK, LENRWK, LENLWK PARAMETER (MXLEV=2, NPD=2, NPTS=2500) PARAMETER (LENIWK=NPTS*(5MXLEV+14), + LENRWK=NPTSNPD*(5MXLEV + 9+18NPD), + LENLWK=2NPTS) C INTEGER LUNDMP PARAMETER (LUNDMP = 89) C INTEGER NPDE, INFO(1), IWK(LENIWK), MNTR LOGICAL LWK(LENLWK) DOUBLE PRECISION T, TOUT, DT, XL, YL, XR, YU, DX, DY, + TOLS, TOLT, RINFO(1), RWK(LENRWK) C***************************************************************************** C*** Continuation call of VLUGR2 *** C****************************************************************************** MNTR = 1 TOUT = 3.0 TOLS = 0.1 TOLT = 0.05 C****************************************************************************** C*** OPEN FILE FOR OUTPUT *** C OPEN(UNIT=7,STATUS='old',FILE='C:/documents/exmplr.tbl') C C****************************************************************************** C Default choices INFO(1)=0 C******************************************************************************* C READ VALUES DUMP from first run **** C******************************************************************************* OPEN(UNIT=LUNDMP,FILE='DUMP',FORM='UNFORMATTED') CALL RDDUMP (LUNDMP, RWK, LENRWK, IWK, LENIWK) CLOSE(LUNDMP) C*********************************************************** C*********************************************************** C call main routine CALL VLUGR2 (NPDE, T, TOUT, DT, XL, YL, XR, YU, DX, DY, + TOLS, TOLT, INFO, RINFO, RWK, LENRWK, IWK, LENIWK, LWK, LENLWK, + MNTR) PRINT , 'VLUGR2 returned with MNTR=', MNTR C OPEN(UNIT=LUNDMP,FILE='DUMP2',FORM='UNFORMATTED') CALL DUMP (LUNDMP, RWK, IWK) CLOSE(LUNDMP) END C***************************************************************************** C*** *** C*** SUBR DERIVF *** C*** *** C****************************************************************************** c

12 May 2010 6:07 #6364

It seems like you try to perform some read action in your subroutine RDDUMP (which you did not provide). You could try the following: Errors corresponding to input statements (like read) can be trapped using ERR= and/or IOSTAT= in the file OPEN command. This might help you to find the line in your RDDUMP subroutine which causes the problem.

IOSTAT=<variable> <variable> is an integer numeric variable into which the input/output status will be written. The variable will be positive if an error occurred, otherwise it will be zero.

ERR=<label> <label> is a label to jump to in the event of an error.

12 May 2010 11:08 #6366

Or even

END=<label>
12 May 2010 7:51 #6370

Hello jjgermis, Thanks for your reply. I send you the DUMP and RGDUMP files They are part of the huge main file VLUGR2. It has to to with the lenght of the file.: SUBROUTINE DUMP (LUNDMP, RWK, IWK) C C----------------------------------------------------------------------- C Ccc PARAMETER SPECIFICATION: INTEGER LUNDMP, IWK() DOUBLE PRECISION RWK() C Ccc PURPOSE: C Dump all information necessary for a restart of VLUGR2 on file C Ccc PARAMETER DESCRIPTION: C LUNDMP : IN. Logical unit number of dumpfile. Should be opened as an C unformatted file. C RWK : IN. Real workstorage as returned from VLUGR2 C IWK : IN. Integer workstorage as returned from VLUGR2 C Ccc EXTERNALS USED: NONE C C Ccc INCLUDE 'CMNSTATS' C C CMNSTATS C C COMMON with integration statistics INTEGER MXCLEV, MXCNIT PARAMETER (MXCLEV = 10, MXCNIT = 20) INTEGER LUNPDS, LUNNLS, LUNLSS, LEVEL, NSTEPS, NREJS, + NJACS(MXCLEV), NRESID(MXCLEV), NNIT(MXCLEV), + NLSIT(MXCLEV,MXCNIT) COMMON /STATS/ LUNPDS, LUNNLS, LUNLSS, LEVEL, NSTEPS, NREJS, + NJACS, NRESID, NNIT, NLSIT SAVE /STATS/ C C end INCLUDE 'CMNSTATS' C C Ccc INCLUDE 'CMNWRITEF' C C CMNWRITEF C C COMMON needed for continuation calls INTEGER MAXLVW, NPDEW, LRWKPS, LIWKPS, LRWKB, LIWKB LOGICAL FIRST, SECOND DOUBLE PRECISION T0, TW, TEW, DTW, XLW, YLW, XRW, YUW, DXB, DYB, + DTO COMMON /WRITIF/ MAXLVW, NPDEW, LRWKPS, LIWKPS, LRWKB, LIWKB COMMON /WRITLF/ FIRST, SECOND COMMON /WRITRF/ T0, TW, TEW, DTW, XLW,YLW, XRW,YUW, DXB, DYB, DTO SAVE /WRITIF/, /WRITLF/, /WRITRF/ C C end INCLUDE 'CMNWRITEF' C C C----------------------------------------------------------------------- C INTEGER I, J

  WRITE(LUNDMP) MAXLVW, NPDEW, LRWKPS, LIWKPS, LRWKB, LIWKB,
 +   FIRST, SECOND,
 +   T0, TW, TEW, DTW, XLW, YLW, XRW, YUW, DXB, DYB, DTO
  WRITE(LUNDMP) LUNPDS, LUNNLS, LUNLSS, LEVEL, NSTEPS, NREJS,
 +   (NJACS(I), I=1,MXCLEV), (NRESID(I), I=1,MXCLEV),
 +   (NNIT(I), I=1,MXCLEV), ((NLSIT(I,J), I=1,MXCLEV), J=1,MXCNIT)
  WRITE(LUNDMP) (RWK(I), I=1,LRWKPS+LRWKB)
  WRITE(LUNDMP) (IWK(I), I=1,LIWKPS+LIWKB)

  RETURN
  END
  SUBROUTINE RDDUMP (LUNDMP, RWK, LENRWK, IWK, LENIWK)

C C----------------------------------------------------------------------- C Ccc PARAMETER SPECIFICATION: INTEGER LENIWK INTEGER LUNDMP, LENRWK, IWK(LENIWK) DOUBLE PRECISION RWK(LENRWK) C Ccc PURPOSE: C Read all information necessary for a restart of VLUGR2 from file C Ccc PARAMETER DESCRIPTION: C LUNDMP : IN. Logical unit number of dumpfile. Should be opened as an C unformatted file. C RWK : OUT. Real workstorage intended to pass to VLUGR2 C LENRWK : IN. Dimension of RWK. C IWK : OUT. Integer workstorage intended to pass to VLUGR2 C LENIWK : IN. Dimension of IWK. C Ccc EXTERNALS USED: NONE C C Ccc INCLUDE 'CMNSTATS' C C CMNSTATS C C COMMON with integration statistics INTEGER MXCLEV, MXCNIT PARAMETER (MXCLEV = 10, MXCNIT = 20) INTEGER LUNPDS, LUNNLS, LUNLSS, LEVEL, NSTEPS, NREJS, + NJACS(MXCLEV), NRESID(MXCLEV), NNIT(MXCLEV), + NLSIT(MXCLEV,MXCNIT) COMMON /STATS/ LUNPDS, LUNNLS, LUNLSS, LEVEL, NSTEPS, NREJS, + NJACS, NRESID, NNIT, NLSIT SAVE /STATS/ C C end INCLUDE 'CMNSTATS' C C Ccc INCLUDE 'CMNWRITEF' C C CMNWRITEF C C COMMON needed for continuation calls INTEGER MAXLVW, NPDEW, LRWKPS, LIWKPS, LRWKB, LIWKB LOGICAL FIRST, SECOND DOUBLE PRECISION T0, TW, TEW, DTW, XLW, YLW, XRW, YUW, DXB, DYB, + DTO COMMON /WRITIF/ MAXLVW, NPDEW, LRWKPS, LIWKPS, LRWKB, LIWKB COMMON /WRITLF/ FIRST, SECOND COMMON /WRITRF/ T0, TW, TEW, DTW, XLW,YLW, XRW,YUW, DXB, DYB, DTO SAVE /WRITIF/, /WRITLF/, /WRITRF/ C C end INCLUDE 'CMNWRITEF' C C C----------------------------------------------------------------------- C INTEGER I, J

  READ(LUNDMP) MAXLVW, NPDEW, LRWKPS, LIWKPS, LRWKB, LIWKB,
 +   FIRST, SECOND,
 +   T0, TW, TEW, DTW, XLW, YLW, XRW, YUW, DXB, DYB, DTO
  IF (LENRWK .LT. LRWKPS+LRWKB .OR. LENIWK .LT. LIWKPS+LIWKB) THEN
     PRINT *, LENRWK, LRWKPS+LRWKB, LENIWK, LIWKPS+LIWKB
     STOP 'work space too small'
  ENDIF
  READ(LUNDMP) LUNPDS, LUNNLS, LUNLSS, LEVEL, NSTEPS, NREJS,
 +   (NJACS(I), I=1,MXCLEV), (NRESID(I), I=1,MXCLEV),
 +   (NNIT(I), I=1,MXCLEV), ((NLSIT(I,J), I=1,MXCLEV), J=1,MXCNIT)
  READ(LUNDMP) (RWK(I), I=1,LRWKPS+LRWKB)
  READ(LUNDMP) (IWK(I), I=1,LIWKPS+LIWKB)

C RETURN END LOGICAL FUNCTION CHKWRK (LRWKN, LENRWK, LIWKN, LENIWK, + LLWKN, LENLWK) C----------------------------------------------------------------------- INTEGER LRWKN, LENRWK, LIWKN, LENIWK, LLWKN, LENLWK C C Ccc INCLUDE 'CMNCMMACH' C C CMNCMMACH C C COMMON with `machine numbers' C LUNOUT : Logical unit # standard output -I C LUNERR : Logical unit # standard error I Set in the routine C UROUND : Smallest machine number such that I MACNUM C 1.0+UROUND > 1.0 and 1.0-UROUND < 1.0 I C XMIN : Smallest floating-point number -I INTEGER LUNOUT, LUNERR DOUBLE PRECISION UROUND, XMIN COMMON /IMACH/ LUNOUT, LUNERR COMMON /RMACH/ UROUND, XMIN SAVE /IMACH/, /RMACH/ C C end INCLUDE 'CMNCMMACH' C C----------------------------------------------------------------------- CHKWRK = .TRUE. IF (LRWKN .GT. LENRWK) THEN WRITE(LUNERR, + '(''Real workspace too small, required at least:'',I10)') + LRWKN CHKWRK = .FALSE. ENDIF IF (LIWKN .GT. LENIWK) THEN WRITE(LUNERR, + '(''Integer workspace too small, required at least:'',I10)') + LIWKN CHKWRK = .FALSE. ENDIF IF (LLWKN .GT. LENLWK) THEN WRITE(LUNERR, + '(''Logical workspace too small, required at least:'',I10)') + LLWKN CHKWRK = .FALSE. ENDIF

  RETURN
  END

The error is and the first read(lundmp) .... lundmp is the file number 89 regards reinoud

14 May 2010 1:05 #6371

Your error message ' encounter the error: ERROR 57: attempt to read past end-of-file.' would give a line number if you compiled including /debug.

As Ian has suggested, at the offending line, use an END= or IOSTAT= and interogate the offending file unit 'IF (IOSTAT /= 0) ...', such as INQUIRE (UNIT=LUNDMP, NAME=<char_variable>, ...) Look at the 'INQUIRE - file or unit' in help for ideas Print out the file unit number and the file name, then check the file size, using windows explorer or dos DIR.

The answer could be that you are looking for too much information, or more likely, that the file is empy; due to wrong file name or the file has been overwritten (check OPEN statement).

John

14 May 2010 7:54 #6372

Try incrementing a variable such as 'no_of_lines' just before or after the read statement. At the labels that the end= or err= sends you to, print out the number of the line you were trying to read or the last one successfully read. At least you will know which line you were reading. Ian

17 May 2010 7:57 #6376

Hi Reinoud,

unfortunately you cannot post large portions of your code in the forum. My suggestion to you is to make a very simple (and small) working example of your code. If you look at your RDDUMP code in the forum you will notice that the READ intruction (where you have problems) does not appear. Ian and John gave a good summary of what could go wrong as well as some good advice to trap the error message.

Good luck!

Please login to reply.