These days I'm trying to run my climate model with new meteorology data (which is given in netcdf format instead of the old cray format). The model is compiled smoothly, however when it's time for the simulation the model runs well the first day but it stops in the second day of simulation, always at same time step, no matter what start date I use. The error is:
forrtl: severe (408): fort: (2): Subscript #1 of the array TIMEVALS has value 141 which is greater than the upper bound of 140.
So I did some research and went through my source code to see what kind of array timevals refers to and I found out that it refers to this new meteorology data which has a time dimension, and such time array is made of 140 elements. Each element is a specific date and time of the meteo data that the model is supposed to use for the simulation...so I started to believe that it's a problem of my code, but my collegue has been able to run the model with no issues, which was strange to me. He compiled the model with some different settings in the Makefile, I don't know if this matters, I'm still not very familiar with fortran etc. However here below is the part of the code that uses this TIMEVALS array:
CASE(2) ! nudging data is in netcdf-format
cfile = str_filter(ndg_file_nc,yr,mo,dy,hr,mi,se,ndgblock)
CALL message(' Adjust date using file: ',TRIM(cfile))
IF (p_parallel_io) THEN
INQUIRE(file=cfile,exist=found)
IF (.NOT.found) &
CALL finish('NudgingInit','Nudging data file not found.')
ndgfile%format = NETCDF
CALL IO_open (cfile, ndgfile, IO_READ)
CALL IO_INQ_DIMID(ndgfile%file_id, 'time', ndimid)
CALL IO_INQ_DIMLEN(ndgfile%file_id, ndimid, nts)
CALL IO_INQ_VARID(ndgfile%file_id, 'time', nvarid)
ALLOCATE (timevals(nts))
CALL IO_GET_VAR_DOUBLE (ndgfile%file_id, nvarid, timevals)
ihead_nc(1) = FLOOR(timevals(1)) ! ihead_nc(1) is YYYYMMDD
ihead_nc(2) = INT((timevals(1)-ihead_nc(1))*24._dp) ! ihead_nc(2) is HH
DEALLOCATE (timevals)
ENDIF
IF (p_parallel) CALL p_bcast(ihead_nc, p_io)
CALL inp_convert_date(ihead_nc(1),ihead_nc(2)*10000, ndg_date0)
IF (p_parallel_io) THEN
! skip first record and read second header
ALLOCATE (timevals(nts))
CALL IO_GET_VAR_DOUBLE (ndgfile%file_id, nvarid, timevals)
ihead_nc(1) = FLOOR(timevals(2)) ! ihead_nc(1) is YYYYMMDD
ihead_nc(2) = INT((timevals(2)-ihead_nc(1))*24._dp) ! ihead_nc(2) is HH
DEALLOCATE (timevals)
CALL IO_close(ndgfile)
ENDIF
IF (p_parallel) CALL p_bcast(ihead_nc, p_io)
CALL inp_convert_date(ihead_nc(1),ihead_nc(2)*10000, ndg_date1)
ndg_file and ndg_date refer to nudging (meteo data)
Do you guys have any idea of what might cause this error?
timevals(141), althoughtimevalsonly has 140 elements. That is what the compiler is telling you. This cannot happen in the code snippet you provided, though. Here, you only accesstimevals(1)andtimevals(2). Please post the corresponding (line of) code, i.e. the line the compiler complains about! - Alexander Vogtntscorrespods to the amount of data thatIO_GET_VAR_DOUBLEreads from your files. - Vladimir F