Opened 8 years ago

Closed 8 years ago

#510 closed bug (Fixed)

Unable to create new history NetCDF in restart mode (NRREC ≠ 0)

Reported by: colucix Owned by: arango
Priority: major Milestone: Release ROMS/TOMS 3.5
Component: Nonlinear Version: 3.5
Keywords: Cc:

Description (last modified by arango)

If I run the model using a NRREC value different than 0, the subroutine def_his() always expects an existing NetCDF history and it results in:

DEF_HIS   - inquiring history file: ''/path/to/''

 NETCDF_OPEN - unable to open existing NetCDF file:
               call from:  def_his.F

The problem seems due to the missing initialization of the parameter idefHIS in Modules/mod_ncparam.F. Please, note that in releases prior to 553 this parameter was initialized to -1.

Looking at Nonlinear/output.F the following lines of code are never executed due to the limiting condition over idefHIS (which is never assigned, hence it's always 0):

    76            IF (idefHIS(ng).lt.0) THEN
    77              idefHIS(ng)=((ntstart(ng)-1)/ndefHIS(ng))*ndefHIS(ng)
    78              IF (idefHIS(ng).lt.iic(ng)-1) THEN
    79                idefHIS(ng)=idefHIS(ng)+ndefHIS(ng)
    80              END IF
    81            END IF

In the same subroutine the following if/then construct results in the assignment of NewFile which will be always .FALSE. whenever NRREC is not equal to 0:

    82            IF ((nrrec(ng).ne.0).and.(iic(ng).eq.ntstart(ng))) THEN
    83              IF ((iic(ng)-1).eq.idefHIS(ng)) THEN
    84                Ldefine=.FALSE.                 ! finished file, delay
    85              ELSE                              ! creation of next file
    86                Ldefine=.TRUE.
    87                NewFile=.FALSE.                 ! unfinished file, inquire
    88              END IF                            ! content for appending
    89              idefHIS(ng)=idefHIS(ng)+nHIS(ng)  ! restart offset
    90            ELSE IF ((iic(ng)-1).eq.idefHIS(ng)) THEN
    91              idefHIS(ng)=idefHIS(ng)+ndefHIS(ng)
    92              IF (nHIS(ng).ne.ndefHIS(ng).and.iic(ng).eq.ntstart(ng)) THEN
    93                idefHIS(ng)=idefHIS(ng)+nHIS(ng)  ! multiple record offset
    94              END IF
    95              Ldefine=.TRUE.
    96              NewFile=.TRUE.
    97            ELSE
    98              Ldefine=.FALSE.
    99            END IF

As a workaround I re-introduced the initialization of at least the following two parameters inside Modules/mod_ncparam.F:

      DO ng=1,Ngrids
      END DO

This lets the first aforementioned block of code (output.F: line 77) to correctly set the idefHIS(ng) parameter and in the subsequent if/then construct the NewFile parameter is permitted to be .TRUE.

Thank you, Alex

Change History (2)

comment:1 Changed 8 years ago by kate

Hmm, this could be related to my suddenly getting the file with not much in it, before it writes the first record to

comment:2 Changed 8 years ago by arango

  • Description modified (diff)
  • Resolution set to Fixed
  • Status changed from new to closed

Yes, great catch. I missed this one. Thank you.

Note: See TracTickets for help on using tickets.