Skip to content

Commit

Permalink
Fix QC test, fix bug in history time axis, fix history output averagi…
Browse files Browse the repository at this point in the history
…ng for timestep output (CICE-Consortium#624)

* Fix history features

- Fix bug in history time axis when sec_init is not zero.
- Fix issue with time_beg and time_end uninitialized values.
- Add support for averaging with histfreq='1' by allowing histfreq_n to be any value
  in that case.  Extend and clean up construct_filename for history files.  More could
  be done, but wanted to preserve backwards compatibility.
- Add new calendar_sec2hms to converts daily seconds to hh:mm:ss.  Update the
  calchk calendar unit tester to check this method
- Remove abort test in bcstchk, this was just causing problems in regression testing
- Remove known problems documentation about problems writing when istep=1.  This issue
  does not exist anymore with the updated time manager.
- Add new tests with hist_avg = false.  Add set_nml.histinst.

* revert set_nml.histall

* fix implementation error

* update model log output in ice_init

* Fix QC issues

- Add netcdf ststus checks and aborts in ice_read_write.F90
- Check for end of file when reading records in ice_read_write.F90 for
  ice_read_nc methods
- Update set_nml.qc to better specify the test, turn off leap years since we're cycling
  2005 data
- Add check in c ice.t-test.py to make sure there is at least 1825 files, 5 years of data
- Add QC run to base_suite.ts to verify qc runs to completion and possibility to use
  those results directly for QC validation
- Clean up error messages and some indentation in ice_read_write.F90

* Update testing

- Add prod suite including 10 year gx1prod and qc test
- Update unit test compare scripts

* update documentation

* reset calchk to 100000 years

* update evp1d test
  • Loading branch information
apcraig authored Aug 19, 2021
1 parent 2a692af commit 26d917a
Show file tree
Hide file tree
Showing 21 changed files with 556 additions and 283 deletions.
16 changes: 8 additions & 8 deletions cicecore/cicedynB/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,7 @@ subroutine accum_hist (dt)
nstrm ! nstreams (1 if writing initial condition)

real (kind=dbl_kind) :: &
timedbl , & ! temporary dbl for time bounds
ravgct , & ! 1/avgct
ravgctz ! 1/avgct

Expand Down Expand Up @@ -1824,7 +1825,7 @@ subroutine accum_hist (dt)
n4Dfcum = n4Dscum + num_avail_hist_fields_4Df ! should equal num_avail_hist_fields_tot

do ns = 1,nstreams
if (.not. hist_avg .or. histfreq(ns) == '1') then ! write snapshots
if (.not. hist_avg) then ! write snapshots
do n = 1,n2D
if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) &
a2D(:,:,n,:) = c0
Expand Down Expand Up @@ -1872,11 +1873,10 @@ subroutine accum_hist (dt)
avgct(ns) = c1
else ! write averages over time histfreq
avgct(ns) = avgct(ns) + c1
! if (avgct(ns) == c1) time_beg(ns) = (time-dt)/int(secday)
if (avgct(ns) == c1) then
time_beg(ns) = (timesecs-dt)/int(secday)
time_beg(ns) = real(time_beg(ns),kind=real_kind)
endif
endif
if (avgct(ns) == c1) then
timedbl = (timesecs-dt)/(secday)
time_beg(ns) = real(timedbl,kind=real_kind)
endif
enddo

Expand Down Expand Up @@ -4010,8 +4010,8 @@ subroutine accum_hist (dt)
enddo ! iblk
!$OMP END PARALLEL DO

time_end(ns) = timesecs/int(secday)
time_end(ns) = real(time_end(ns),kind=real_kind)
timedbl = timesecs/secday
time_end(ns) = real(timedbl,kind=real_kind)

!---------------------------------------------------------------
! write file
Expand Down
97 changes: 50 additions & 47 deletions cicecore/cicedynB/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -672,64 +672,67 @@ subroutine construct_filename(ncfile,suffix,ns)
iday = mday
isec = msec - dt

if (write_ic) isec = msec
! construct filename
if (write_ic) then
isec = msec
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
incond_file(1:lenstr(incond_file)),'.',iyear,'-', &
imonth,'-',iday,'-',isec,'.',suffix
imonth,'-',iday,'-',isec,'.',trim(suffix)
else

if (hist_avg .and. histfreq(ns) /= '1') then
if (histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then
! do nothing
elseif (new_year) then
iyear = iyear - 1
imonth = 12
iday = daymo(imonth)
elseif (new_month) then
imonth = mmonth - 1
iday = daymo(imonth)
elseif (new_day) then
iday = iday - 1
endif
endif

cstream = ''
if (hist_avg) then
if (histfreq(ns) == '1' .or. histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then
! do nothing
elseif (new_year) then
iyear = iyear - 1
imonth = 12
iday = daymo(imonth)
elseif (new_month) then
imonth = mmonth - 1
iday = daymo(imonth)
elseif (new_day) then
iday = iday - 1
endif
endif

cstream = ''
!echmod ! this was implemented for CESM but it breaks post-processing software
!echmod ! of other groups (including RASM which uses CESMCOUPLED)
!echmod if (ns > 1) write(cstream,'(i1.1)') ns-1

if (histfreq(ns) == '1') then ! instantaneous, write every dt
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',suffix

elseif (hist_avg) then ! write averaged data

if (histfreq(ns) == 'd'.or.histfreq(ns) == 'D') then ! daily
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream), &
'.',iyear,'-',imonth,'-',iday,'.',suffix
elseif (histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then ! hourly
write(ncfile,'(a,a,i2.2,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_', &
histfreq_n(ns),'h.',iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
elseif (histfreq(ns) == 'm'.or.histfreq(ns) == 'M') then ! monthly
write(ncfile,'(a,a,i4.4,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'-',imonth,'.',suffix
elseif (histfreq(ns) == 'y'.or.histfreq(ns) == 'Y') then ! yearly
write(ncfile,'(a,a,i4.4,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'.',suffix
endif
if (hist_avg) then ! write averaged data
if (histfreq(ns) == '1' .and. histfreq_n(ns) == 1) then ! timestep
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',trim(suffix)
elseif (histfreq(ns) == '1' .and. histfreq_n(ns) > 1) then ! timestep
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',trim(suffix)
elseif (histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then ! hourly
write(ncfile,'(a,a,i2.2,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_', &
histfreq_n(ns),'h.',iyear,'-',imonth,'-',iday,'-',msec,'.',trim(suffix)
elseif (histfreq(ns) == 'd'.or.histfreq(ns) == 'D') then ! daily
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'-',imonth,'-',iday,'.',trim(suffix)
elseif (histfreq(ns) == 'm'.or.histfreq(ns) == 'M') then ! monthly
write(ncfile,'(a,a,i4.4,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'-',imonth,'.',trim(suffix)
elseif (histfreq(ns) == 'y'.or.histfreq(ns) == 'Y') then ! yearly
write(ncfile,'(a,a,i4.4,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'.',trim(suffix)
endif

else ! instantaneous
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',trim(suffix)
endif

else ! instantaneous with histfreq > dt
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file)),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
endif
endif

end subroutine construct_filename
Expand Down
5 changes: 3 additions & 2 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1897,13 +1897,13 @@ subroutine input_data
write(nu_diag,1023) ' histfreq_n = ', histfreq_n(:)
write(nu_diag,1031) ' histfreq_base = ', trim(histfreq_base)
write(nu_diag,1011) ' hist_avg = ', hist_avg
if (.not. hist_avg) write(nu_diag,1031) ' History data will be snapshots'
if (.not. hist_avg) write(nu_diag,1039) ' History data will be snapshots'
write(nu_diag,1031) ' history_dir = ', trim(history_dir)
write(nu_diag,1031) ' history_file = ', trim(history_file)
write(nu_diag,1021) ' history_precision= ', history_precision
write(nu_diag,1031) ' history_format = ', trim(history_format)
if (write_ic) then
write(nu_diag,1031) ' Initial condition will be written in ', &
write(nu_diag,1039) ' Initial condition will be written in ', &
trim(incond_dir)
endif
write(nu_diag,1031) ' dumpfreq = ', trim(dumpfreq)
Expand Down Expand Up @@ -2075,6 +2075,7 @@ subroutine input_data
1030 format (a20,a14,1x,a) ! character
1031 format (a20,1x,a,a)
1033 format (a20,1x,6a6)
1039 format (a,1x,a,1x,a,1x,a)

end subroutine input_data

Expand Down
Loading

0 comments on commit 26d917a

Please sign in to comment.