ROMS history file has suddenly included restart record

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
d.kobashi
Posts: 66
Joined: Tue Sep 28, 2010 11:59 pm
Location: Texas A&M University

ROMS history file has suddenly included restart record

#1 Unread post by d.kobashi »

Hi,

I am working on operational forecast/nowcast and use restart file to run forecast/nowcast daily. Now I am in a strange situation that ROMS history file created daily has suddenly started including restart record in history file :? .

When we run ROMS with restart file (assuming restart time is 2018-05-01 00:00:00) with 1 hour output frequency, the history file should start from 2018-05-01 01:00:00. However, my history file includes restart record (2018-05-01 00:00:00) as the first record. Has anyone had this situation? Could anyone tell me how not to include restart record in history file?

Nowcast (1-day run) is aggregated and when I do, nowcast data have duplicated record at 00:00 every day, which is annoying.

I use a recent version of COAWST (ver 3.3). ROMS rev 885.

Thanks in advance.

-DJ

User avatar
wilkin
Posts: 875
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: ROMS history file has suddenly included restart record

#2 Unread post by wilkin »

There have been some changes to the time handling that might have altered the model behavior, e.g.:
https://www.myroms.org/projects/src/ticket/778

But the changes were to make ROMS behave more according to how it is supposed to. Read the GLOSSARY at the end of ocean.in for a description of how NRREC is supposed to work.

If you have NRREC = 0 you are asking for a new solution, which should write the initial conditions as the first record of the history file (in your case duplicating the last record from the previous run).

If you don't want that, point NRREC to the record you want it to read from ININAME (instead of 0). If you are starting from a multi-record history file from your last run you can use NRREC = -1 to read the latest time. Provided NTIMES is a multiple of NDEFHIS this should not cause the previous file to be over-written.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

d.kobashi
Posts: 66
Joined: Tue Sep 28, 2010 11:59 pm
Location: Texas A&M University

Re: ROMS history file has suddenly included restart record

#3 Unread post by d.kobashi »

Thanks, John.

Attached below are some parameters in ocean.in I use for nowcast. As for NRREC, I use NRREC=-1 and I specify restart file of the previous run as ININAME. I use NDEFHIS=0 as I don't want to split the file, but I don't think that's the problem.

When I used an old version of ROMS (COAWST), I did not have such problem. Still looking into the matter. Maybe I should try the old version again to see if I can replicate the problem. Thanks, -DJ

Code: Select all

      NTIMES == 4320   
          DT == 20.0
     NDTFAST == 40

       NRREC == -1
   LcycleRST == T
        NRST == 4320  
        NSTA == 180  
        NFLT == 15
       NINFO == 60

     LDEFOUT == T
        NHIS == 180  
     NDEFHIS == 0
      NTSAVG == 1
        NAVG == 4320  
    NDEFAVG == 0
      NTSDIA == 1
        NDIA == 4320
     NDEFDIA == 0

d.kobashi
Posts: 66
Joined: Tue Sep 28, 2010 11:59 pm
Location: Texas A&M University

Re: ROMS history file has suddenly included restart record

#4 Unread post by d.kobashi »

This is an update to my previous post.

The version of ROMS does not seem to be anything do with whether history file includes restart record or not. However, I just found out that if I specify a non-zero value of NDEFHIS (I tested with NDEFHIS = 4320 (that is the same as NTIMES)), the history file does not have restart record at the beginning(i.e. history file starts at 1:00 hour instead of 0:00). :shock:
That reminds me why I did not have restart record in the past, because mostly I was working on long-term hincast simulation, which almost always uses a non-zero value of NDEFHIS.

The problem is when I specify NDEFHIS as a non-zero value, the name of history file includes "_0001.nc" at the end (i.e. if I specify HISNAME as ocean_his.nc, it will be ocean_his_0001.nc'). When we split the history files, that's fine. If we don't (e.g. continuous monthly hindcast runs), the addition is unnecessary. I am not sure if there is some way not to include _0001" at the end easily. I may need to tweak the source code to remove the inclusion of restart record. If anyone has done that, I would appreciate your instruction.

Thanks,

-DJ

jcwarner
Posts: 1172
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ROMS history file has suddenly included restart record

#5 Unread post by jcwarner »

i am glad you found this out. I was looking around at all the recent updates and could not see any reason for that change in behavior. if you want to stop the addition of _0001, you could look in Nonlinear/output.F for the code:

ifile=(iic(ng)-1)/ndefHIS(ng)+1
IF (Master) THEN
WRITE (HIS(ng)%name,10) TRIM(HIS(ng)%base), ifile

-j

d.kobashi
Posts: 66
Joined: Tue Sep 28, 2010 11:59 pm
Location: Texas A&M University

Re: ROMS history file has suddenly included restart record

#6 Unread post by d.kobashi »

John,

Thanks for checking the code on your side. I appreciate your help (always).

As for your comments, I still want to run long-simulation (1+ year) and for the purpose, keeping the file splitting function is necessary as without it, the history file created would be huge.... (FYI. the total size of one-year run is close to 1 TB).

So I ended up with modifying the source code to fulfill my need.
A good thing is that now I can change if I want to include initial fields or not only by changing a parameter I created (NHISSTR) in ocean.in.

Details of what I did are below.

Three files needed to be modified.
Nonlinear/output.F
Utility/read_phypar.F
Modules/mod_scalars.F


In Utility/read_phypar.F, I added the following lines

Code: Select all

 685             CASE ('NHISSTR')
 686               Npts=load_i(Nval, Rval, Ngrids, nHISstr)
In Modules/mod_scalars.F, I added two lines as follow

Code: Select all

1008         integer, allocatable :: nHISstr(:)       ! select to add initial
1009                                                  ! fields to history
1010                                                  ! file. 0:include,
1011                                                  ! 1:exclude
and

Code: Select all

2226       allocate ( nHISstr(Ngrids) )
In Nonlinear/output.F
I changed the follwoing lines

Code: Select all

144           IF (iic(ng).eq.ntstart(ng)) THEN
145             CALL def_his (ng, ldefout(ng))
146             IF (FoundError(exit_flag, NoError, __LINE__,                &
147      &                     __FILE__)) RETURN
148             LwrtHIS(ng)=.TRUE.
149             LdefHIS(ng)=.FALSE.
150           END IF

to the following lines

Code: Select all

145 ! ---- added by DJ@TAMU
146            IF (nHISstr(ng).eq.0) THEN
147               ! include initial fields to history file(Original version)
148               IF (iic(ng).eq.ntstart(ng)) THEN
149                  CALL def_his (ng, ldefout(ng))
150                  IF (FoundError(exit_flag, NoError, __LINE__,           &
151      &                     __FILE__)) RETURN
152                  LwrtHIS(ng)=.TRUE.
153                  LdefHIS(ng)=.FALSE.
154               END IF
155 
156            ELSE IF (nHISstr(ng).eq.1) THEN
157               ! exclude initail fields to history file (modified version)
158               IF (iic(ng).eq.ntstart(ng).and.(nrrec(ng).ne.0)) THEN
159 !              IF (iic(ng).eq.ntstart(ng)) THEN
160                  LwrtHIS(ng)=.False.
161                  LdefHIS(ng)=.True.
162               ELSE
163                  LwrtHIS(ng)=.True.
164                  LdefHIS(ng)=.FALSE.
165                  CALL def_his (ng, ldefout(ng))
166                  IF (FoundError(exit_flag, NoError, __LINE__,           &
167      &                __FILE__)) RETURN
168               END IF
169            END IF
170 ! --------------------------

Lastly, in ocean.in, I added the following line below NDEFHIS == 0

Code: Select all

248      NHISSTR == 0  ! 0 to include inital fields, 1 to exclude

That's it. With this modification, if you want to use a non-zero value of NDEFHIS, the modification won't do anything, but if you set NDEFHIS == 0, depending on NHISSTR, initial fields are included or excluded depending on user choice. Hope I did not do anything (terribly) wrong.

I added two ncview snapshots and see the 1st on includes initial fields (NHISSTR==0), and the other doesn't (NHISSTR==1). It seems to be working. It's a subtle thing and possibly nobody cares, but it is kind of important to me as I need to aggregate nowcast and hindcast with NCO/CDO and on THREDDS. And Python Xarray hates duplications...

Cheers,

-DJ
Attachments
a snapshot with initial fields
a snapshot with initial fields
00.png (83.09 KiB) Viewed 5948 times
a snapshot without initial fields
a snapshot without initial fields
01.png (85.77 KiB) Viewed 5948 times

User avatar
arango
Site Admin
Posts: 1347
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: ROMS history file has suddenly included restart record

#7 Unread post by arango »

Hmmm, I haven't had the time to examine the issue that you are having. I haven't modified this part of the code in years. I use the split of history files frequently and I have never observed the behavior that you are reporting. I wonder if it is a matter of configuration. Are you changing DSTART every time that you restart the solution?

d.kobashi
Posts: 66
Joined: Tue Sep 28, 2010 11:59 pm
Location: Texas A&M University

Re: ROMS history file has suddenly included restart record

#8 Unread post by d.kobashi »

Yes. I update forecast/nowcast daily and for that, DSTART changes for every run. When I use file splitting function, the initial fields are not included (e.g. 1-year hindcast run), but for short-term runs, file splitting is not necessary for my purpose.

Post Reply