Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add time_period_freq #816

Merged
merged 10 commits into from
Mar 2, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ subroutine ice_write_hist (ns)
use ice_blocks, only: nx_block, ny_block
use ice_broadcast, only: broadcast_scalar
use ice_calendar, only: msec, timesecs, idate, idate0, write_ic, &
histfreq, days_per_year, use_leap_years, dayyr, &
histfreq, histfreq_n, days_per_year, use_leap_years, dayyr, &
hh_init, mm_init, ss_init
use ice_communicate, only: my_task, master_task
use ice_domain, only: distrb_info
Expand Down Expand Up @@ -86,6 +86,7 @@ subroutine ice_write_hist (ns)
integer (kind=int_kind), dimension(6) :: dimidex
real (kind=dbl_kind) :: ltime2
character (char_len) :: title
character (char_len) :: time_period_freq = 'none'
character (char_len_long) :: ncfile(max_nstrm)
real (kind=dbl_kind) :: secday, rad_to_deg

Expand Down Expand Up @@ -682,6 +683,25 @@ subroutine ice_write_hist (ns)
if (status /= nf90_noerr) call abort_ice(subname// &
'ERROR: global attribute date2')

select case (histfreq(ns))
case ("y", "Y")
write(time_period_freq,'(a,i0)') 'year_',histfreq_n(ns)
case ("m", "M")
write(time_period_freq,'(a,i0)') 'month_',histfreq_n(ns)
case ("d", "D")
write(time_period_freq,'(a,i0)') 'day_',histfreq_n(ns)
case ("h", "H")
write(time_period_freq,'(a,i0)') 'hour_',histfreq_n(ns)
case ("1")
write(time_period_freq,'(a,i0)') 'step_',histfreq_n(ns)
end select

if (.not.write_ic .and. trim(time_period_freq) /= 'none') then
status = nf90_put_att(ncid,nf90_global,'time_period_freq',trim(time_period_freq))
if (status /= nf90_noerr) call abort_ice(subname// &
'ERROR: global attribute time_period_freq')
endif

title = 'CF-1.0'
status = &
nf90_put_att(ncid,nf90_global,'conventions',title)
Expand Down
18 changes: 18 additions & 0 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_history_write.F90
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ subroutine ice_write_hist (ns)
integer (kind=int_kind), dimension(6) :: dimidex
real (kind= dbl_kind) :: ltime2
character (char_len) :: title
character (char_len) :: time_period_freq = 'none'
character (char_len_long) :: ncfile(max_nstrm)
integer (kind=int_kind) :: iotype

Expand Down Expand Up @@ -649,6 +650,23 @@ subroutine ice_write_hist (ns)
write(title,'(a,i6)') 'seconds elapsed into model date: ',msec
status = pio_put_att(File,pio_global,'comment3',trim(title))

select case (histfreq(ns))
case ("y", "Y")
write(time_period_freq,'(a,i0)') 'year_',histfreq_n(ns)
case ("m", "M")
write(time_period_freq,'(a,i0)') 'month_',histfreq_n(ns)
case ("d", "D")
write(time_period_freq,'(a,i0)') 'day_',histfreq_n(ns)
case ("h", "H")
write(time_period_freq,'(a,i0)') 'hour_',histfreq_n(ns)
case ("1")
write(time_period_freq,'(a,i0)') 'step_',histfreq_n(ns)
end select

if (.not.write_ic .and. trim(time_period_freq) /= 'none') then
status = pio_put_att(File,pio_global,'time_period_freq',trim(time_period_freq))
endif

title = 'CF-1.0'
status = &
pio_put_att(File,pio_global,'conventions',trim(title))
Expand Down