Problem regarding restart when activate SED_MOR

Sediment modeling collaborators: issues, applications, information exchange

Moderators: arango, robertson, rsignell

Post Reply
Message
Author
Johnny.Zang
Posts: 4
Joined: Tue Dec 20, 2016 3:12 pm
Location: LSU

Problem regarding restart when activate SED_MOR

#1 Unread post by Johnny.Zang »

Dear ROMS users,

Now I meet a problem regarding restart my sediment model when I activate SED_MOR. In wrt_rst.F

#if defined SEDIMENT && defined SED_MORPH
!
! Write out time-dependent bathymetry (m)
!
IF (Hout(idbath,ng)) THEN
scale=1.0_r8
gtype=gfactor*r2dvar
status=nf_fwrite2d(ng, iNLM, RST(ng)%ncid, RST(ng)%Vid(idbath), &
& RST(ng)%Rindex, gtype, &
& LBi, UBi, LBj, UBj, scale, &
# ifdef MASKING
& GRID(ng) % rmask, &
# endif
& GRID(ng) % h, &
& SetFillVal = .FALSE.)
IF (status.ne.nf90_noerr) THEN
IF (Master) THEN
WRITE (stdout,10) TRIM(Vname(1,idbath)), RST(ng)%Rindex
END IF
exit_flag=3
ioerror=status
RETURN
END IF
END IF
#endif


It seems like "bath" will not be written in restart file until you activate writing "bath" in history output. When I deactivate writing "bath" in history, "bath" in restart is alway empty, which cannot be used to restart model. If I activate writing "bath" in history, however, ROMS will report an error" WRT_RST - error while writing variable: bath into restart NetCDF file for time record: 4". The error always happens when the model begin to write the fourth frame of restart file. I just guess it is because of the size mismatch between variable defined in restart nc file and variable "bath" in cache. If you check out the restart file you will find variable "bath" has one dimension called "three".

Does someone ever meet this kind of problem before? Please share your experience on that if you have.

Best,

Johnny Zang

c.drinkorn
Posts: 110
Joined: Thu Mar 08, 2018 2:47 am
Location: German Research Centre for Geosciences

Re: Problem regarding restart when activate SED_MOR

#2 Unread post by c.drinkorn »

Hi,

I found this old issue while I am having had the same. I realized it is connected to the usage of PERFECT RESTART. In wrt_rst.F, when choosing PERFECT_RESTART, t2dgrd is becoming an extra value, i.e. DimIDs(31). Later in def_var.F this causes an inconsistency while nvd3 has the value 3 and Vdim(1:nvd3) is not consistent with Vdim = t2dgrd having four entries.

In wrt_rst.F, starting from line 291:

Code: Select all

!  Set number of dimensions for output variables.
!
#if !defined PERFECT_RESTART && \
    (defined WRITE_WATER && defined MASKING)
        nvd3=2
        nvd4=2
        nvd5=2
#else
        nvd3=3
        nvd4=4
        nvd5=5
#endif
!
!  Define dimension vectors for staggered tracer type variables.
!
#if !defined PERFECT_RESTART && \
    (defined WRITE_WATER && defined MASKING)
        t2dgrd(1)=DimIDs(17)
        t2dgrd(2)=DimIDs(12)
        sr2dgrd(1)=DimIDs(17)
        sr2dgrd(2)=DimIDs(12)
# ifdef SOLVE3D
        t3dgrd(1)=DimIDs(20)
        t3dgrd(2)=DimIDs(12)
        r3dgrd(1)=DimIDs(20)
        r3dgrd(2)=DimIDs(12)
# endif
#else
        t2dgrd(1)=DimIDs( 1)
        t2dgrd(2)=DimIDs( 5)
        sr2dgrd(1)=DimIDs( 1)
        sr2dgrd(2)=DimIDs( 5)
        sr2dgrd(3)=DimIDs(12)
# ifdef PERFECT_RESTART
        t2dgrd(3)=DimIDs(31)
        t2dgrd(4)=DimIDs(12)
# else
        t2dgrd(3)=DimIDs(12)
# endif
# ifdef SOLVE3D
        t3dgrd(1)=DimIDs( 1)
        t3dgrd(2)=DimIDs( 5)
        t3dgrd(3)=DimIDs( 9)
        r3dgrd(1)=DimIDs( 1)
        r3dgrd(2)=DimIDs( 5)
        r3dgrd(3)=DimIDs( 9)
#  ifdef PERFECT_RESTART
        t3dgrd(4)=DimIDs(30)
        t3dgrd(5)=DimIDs(12)
#  else
        t3dgrd(4)=DimIDs(12)
#  endif
        r3dgrd(4)=DimIDs(12)
# endif
#endif
-> With PERFECT_RESTART option this causes t2dgrd to have four entries, t2dgrd(1)=DimIDs(1) i.e., Xi rho, t2dgrd(2)=DimIDs(5) i.e., ETA rho, t2dgrd(3)=DimIDs(31) i.e. 3 (number of 2d variables time levels), and t2dgrd(4)=DimIDs(12) i.e. an unlimited time record dimension.

Then later in line 711 of the same routine def_var.F is being called with t2dgrd as Vdim:

Code: Select all

#if defined SEDIMENT && defined SED_MORPH
!
!  Define time-varying bathymetry.
!
        Vinfo( 1)=Vname(1,idbath)
        Vinfo( 2)=Vname(2,idbath)
        Vinfo( 3)=Vname(3,idbath)
        Vinfo(14)=Vname(4,idbath)
        Vinfo(16)=Vname(1,idtime)
        Vinfo(22)='coordinates'
        Aval(5)=REAL(Iinfo(1,idbath,ng),r8)
        status=def_var(ng, iNLM, RST(ng)%ncid, RST(ng)%Vid(idbath),     &
     &                 NF_FRST, nvd3, t2dgrd, Aval, Vinfo, ncname,      &
     &                 SetFillVal = .FALSE.)
        IF (FoundError(exit_flag, NoError, __LINE__,                    &
     &                 __FILE__)) RETURN
#endif
In def_var.F, from line 122, nf90_def_var is being called:

Code: Select all

!
!-----------------------------------------------------------------------
!  Define requested variable and its attributes.
!-----------------------------------------------------------------------
!
      IF (OutThread) THEN
!
!  Define variable.
!
        IF (exit_flag.eq.NoError) THEN
          IF (LEN_TRIM(Vinfo(1)).gt.0) THEN
            IF ((nVdim.eq.1).and.(Vdim(1).eq.0)) THEN
              status=nf90_def_var(ncid, TRIM(Vinfo(1)), Vtype,          &
     &                            varid = Vid)
            ELSE
              status=nf90_def_var(ncid, TRIM(Vinfo(1)), Vtype,          &
     &                            Vdim(1:nVdim), Vid)
            END IF
            IF (FoundError(status, nf90_noerr, __LINE__,                &
     &                     __FILE__)) THEN
              IF (Master) WRITE (stdout,10) ng, TRIM(Vinfo(1)),         &
     &                                      TRIM(ncname)
              exit_flag=3
              ioerror=status
            END IF
          END IF
        END IF
-> The Fortran function will only read in the first three entries of Vdim, which are Xi rho, ETA rho and the number 3.

Maybe switch t2dgrd(3) and t2dgrd(4) in this case?

This may also be connected to my other issue:
viewtopic.php?f=17&t=5211
Where I am having troubles with the restart timesteps. I realized that temp and salt are NaNs but bath and bed thickness aren't. Maybe the SEDIMENT option is causing some inconsistencies in the RESTART routines?

Post Reply