Skip to content

Commit 681a2c6

Browse files
anton-seaiceblimlimSIobhan O'Farrell
authored
Update to CMIP7 diagnostics (#35)
* port CICE6 history features for CMIP variables: avg_ice_present, mask_ice_free_points * add some error handling for variables not available in the ACCESS coupling * add comment metadata for area and time weighting of variables * use variable descriptions from data request, and set cell_methods * add variables which are high priority, available and not previously included * for snow variables, add an _intensive version, see https://airtable.com/appGoMZhCpkGESoVk/tblpo5L8maBIGlM1B/viwNNzrqK5oPL7zk2?blocks=hide This change is based on the CMIP7 data request v1.2.2.2 - https://airtable.com/appGoMZhCpkGESoVk/tblpo5L8maBIGlM1B/viwNNzrqK5oPL7zk2?blocks=hide Co-authored-by: Spencer Wong <88933912+blimlim@users.noreply.github.com> Co-authored-by: SIobhan O'Farrell <spo599@gadi-login-05.gadi.nci.org.au>
1 parent 16e26c8 commit 681a2c6

12 files changed

Lines changed: 1374 additions & 1622 deletions

drivers/access/CICE_RunMod.F90

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@ subroutine CICE_Run
6262
use ice_timers, only: ice_timer_start, &
6363
ice_timer_stop, timer_couple, timer_step, &
6464
timer_from_atm, timer_into_atm, timer_from_ocn, timer_into_ocn
65-
use ice_grid, only: t2ugrid_vector, u2tgrid_vector
65+
use ice_grid, only: t2ugrid_vector
6666
integer (kind=int_kind) :: time_sec, itap, icpl_ai, tmp_time
6767
integer (kind=int_kind) :: rtimestamp_ai, stimestamp_ai
6868
integer (kind=int_kind) :: rtimestamp_io, stimestamp_io
6969
!receive and send timestamps (seconds)
7070
integer (kind=int_kind) :: imon
7171

72-
logical :: write_tmp_dump = .true.
7372
#endif
7473

7574
!--------------------------------------------------------------------
@@ -83,9 +82,12 @@ subroutine CICE_Run
8382
!--------------------------------------------------------------------
8483

8584
#ifdef ACCESS
86-
write(il_out,*)'A <==> I coupling num_cpl_ai = ',num_cpl_ai
87-
write(il_out,*)' ice steps per ai interval num_ice_ai = ',num_ice_ai
88-
write(il_out,*)' runtime, runtime0 = ',runtime, runtime0
85+
86+
if (my_task == master_task) then
87+
write(il_out,*)'A <==> I coupling num_cpl_ai = ',num_cpl_ai
88+
write(il_out,*)' ice steps per ai interval num_ice_ai = ',num_ice_ai
89+
write(il_out,*)' runtime, runtime0 = ',runtime, runtime0
90+
endif
8991

9092
time_sec = 0
9193

@@ -94,7 +96,7 @@ subroutine CICE_Run
9496
!receive a2i fields
9597
rtimestamp_ai = time_sec
9698
!call ice_timer_start(timer_from_atm) ! atm/ice coupling
97-
write(il_out,*)' calling from_atm at icpl_ai, time_sec = ', icpl_ai, time_sec
99+
! write(il_out,*)' calling from_atm at icpl_ai, time_sec = ', icpl_ai, time_sec
98100
!===========================
99101
call from_atm(rtimestamp_ai)
100102
!===========================
@@ -116,8 +118,8 @@ subroutine CICE_Run
116118
call t2ugrid_vector(io_strsu)
117119
call t2ugrid_vector(io_strsv)
118120

119-
write(il_out,'(a,3i10)') &
120-
' calling into_ocn at icpl_ai, itap, time_sec = ', icpl_ai, itap, time_sec
121+
! write(il_out,'(a,3i10)') &
122+
! ' calling into_ocn at icpl_ai, itap, time_sec = ', icpl_ai, itap, time_sec
121123
!call ice_timer_start(timer_into_ocn) ! atm/ocn coupling
122124
!===========================
123125
!call check_iceberg_fields('chk_iceberg_i2o.nc')
@@ -161,8 +163,8 @@ subroutine CICE_Run
161163

162164
stimestamp_ai = time_sec
163165

164-
write(il_out,'(a,3i10)') &
165-
' calling into_atm at icpl_ai, itap, time_sec = ',icpl_ai, itap, time_sec
166+
! write(il_out,'(a,3i10)') &
167+
! ' calling into_atm at icpl_ai, itap, time_sec = ',icpl_ai, itap, time_sec
166168
!===========================
167169
call into_atm(stimestamp_ai)
168170
!===========================
@@ -292,6 +294,10 @@ subroutine ice_step
292294
use ice_algae, only: bgc_diags, write_restart_bgc
293295
use ice_zbgc, only: init_history_bgc, biogeochemistry
294296
use ice_zbgc_shared, only: skl_bgc
297+
#ifdef ACCESS
298+
use ice_state, only: vsno, aice, tr_pond
299+
use ice_flux, only: snowfrac
300+
#endif
295301

296302
integer (kind=int_kind) :: &
297303
iblk , & ! block index
@@ -428,20 +434,12 @@ subroutine coupling_prep (iblk)
428434
use ice_constants, only: c0, c1, puny, rhofresh
429435
use ice_coupling, only: top_layer_Tandk_run, sfcflux_to_ocn
430436
use ice_domain_size, only: ncat
431-
use ice_flux, only: alvdf, alidf, alvdr, alidr, albice, albsno, &
432-
albpnd, albcnt, apeff_ai, coszen, fpond, fresh, &
433-
alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, &
434-
fresh_ai, fsalt_ai, fsalt, &
435-
fswthru_ai, fhocn, fswthru, scale_factor, &
436-
swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyt, &
437-
fsens, flat, fswabs, flwout, evap, Tref, Qref, faero_ocn, &
438-
fsurfn_f, flatn_f, scale_fluxes, frzmlt_init, frzmlt, &
439-
snowfrac, snowfracn, evap_ice, evap_snow
437+
use ice_flux
440438
use ice_grid, only: tmask
441439
use ice_ocean, only: oceanmixed_ice, ocean_mixed_layer
442440
use ice_shortwave, only: alvdfn, alidfn, alvdrn, alidrn, &
443441
albicen, albsnon, albpndn, apeffn
444-
use ice_state, only: aicen, aice, aice_init, nbtrcr
442+
use ice_state, only: aicen, aice, aice_init, nbtrcr, tr_pond, vsno
445443
use ice_therm_shared, only: calc_Tsfc, heat_capacity
446444
use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop
447445
use ice_zbgc_shared, only: flux_bio, flux_bio_ai
@@ -527,8 +525,19 @@ subroutine coupling_prep (iblk)
527525

528526
apeff_ai(i,j,iblk) = apeff_ai(i,j,iblk) & ! for history
529527
+ apeffn(i,j,n,iblk)*aicen(i,j,n,iblk)
530-
snowfrac(i,j,iblk) = snowfrac(i,j,iblk) & ! for history
531-
+ snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk)
528+
529+
if ( .not. tr_pond .and. .not. calc_Tsfc ) then
530+
! calculate a snowfrac diagnostic in the same way the UM does
531+
! set snow fraction using JULES empirical formula based
532+
! on snow volume
533+
! ref: https://github.com/ACCESS-NRI/UM7/blob/6602dadd15c190ee37c6644190f52d428bc66917/umbase_hg3/src/atmosphere/short_wave_radiation/ftsa.F90#L201-L202
534+
if (aice(i,j,iblk) > 2e-4) &
535+
snowfrac(i,j,iblk) = c1 - exp(-p2*rhos*(vsno(i,j,iblk) / aice(i,j,iblk)))
536+
else
537+
snowfrac(i,j,iblk) = snowfrac(i,j,iblk) & ! for history
538+
+ snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk)
539+
endif
540+
532541
enddo
533542
enddo
534543
enddo
@@ -555,6 +564,15 @@ subroutine coupling_prep (iblk)
555564
fsalt_ai (i,j,iblk) = fsalt (i,j,iblk)
556565
fhocn_ai (i,j,iblk) = fhocn (i,j,iblk)
557566
fswthru_ai(i,j,iblk) = fswthru(i,j,iblk)
567+
fsens_ai (i,j,iblk) = fsens(i,j,iblk)
568+
flat_ai (i,j,iblk) = flat(i,j,iblk)
569+
fswabs_ai (i,j,iblk) = fswabs(i,j,iblk)
570+
flwout_ai (i,j,iblk) = flwout(i,j,iblk)
571+
evap_ai (i,j,iblk) = evap(i,j,iblk)
572+
evap_ice_ai(i,j,iblk) = evap_ice(i,j,iblk)
573+
evap_snow_ai(i,j,iblk) = evap_snow(i,j,iblk)
574+
fcondtop_ai(i,j,iblk) = fcondtop(i,j,iblk)
575+
fsurf_ai(i,j,iblk) = fsurf(i,j,iblk)
558576

559577
if (nbtrcr > 0) then
560578
do k = 1, nbtrcr

drivers/access/cpl_forcing_handler.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ subroutine get_lice_discharge(fname)
424424
case (4); myvar = 'FICEBERG_GC3_AVE'
425425
end select
426426
write(il_out,*)'(get_lice_discharge), iceberg = ', iceberg
427-
write(il_out,'(a,a)') '(get_lice_discharge) reading in iceberg data, myvar= ',trim(myvar)
427+
! write(il_out,'(a,a)') '(get_lice_discharge) reading in iceberg data, myvar= ',trim(myvar)
428428
do im = 1, 12
429-
write(il_out,*) '(get_lice_discharge) reading in data, month= ',im
429+
! write(il_out,*) '(get_lice_discharge) reading in data, month= ',im
430430
call ice_read_nc(ncid_i2o, im, trim(myvar), vwork, dbug)
431431

432432
! Restrict iceberg fluxes to ocean points

drivers/access/cpl_interface.F90

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,23 @@ subroutine prism_init
9292
! Initialise MPI
9393
mpiflag = .FALSE.
9494
call MPI_Initialized (mpiflag, ierror)
95-
print *,'CICE: (prism_init) BF MPI_INIT, mpiflag = ',mpiflag
95+
! print *,'CICE: (prism_init) BF MPI_INIT, mpiflag = ',mpiflag
9696

9797
if ( .not. mpiflag ) then
9898
call MPI_INIT(ierror)
9999
endif
100100

101101
call MPI_Initialized (mpiflag, ierror)
102-
print *, 'CICE: (prism_init) AF MPI_INIT, mpiflag = ',mpiflag
102+
! print *, 'CICE: (prism_init) AF MPI_INIT, mpiflag = ',mpiflag
103103

104-
print *
105-
print *, 'CICE: (prism_init) calling prism_init_comp_proto...'
104+
! print *, 'CICE: (prism_init) calling prism_init_comp_proto...'
106105

107106
call prism_init_comp_proto (il_comp_id, cp_modnam, ierror)
108107

109108
if (ierror /= PRISM_Ok) then
110109
call prism_abort_proto(il_comp_id, 'cice prism_init','STOP 1')
111-
else
112-
print *, 'CICE: (prism_init) called prism_init_comp_proto !'
110+
! else
111+
! if ( my_task == master_task ) print *, 'CICE: (prism_init) called prism_init_comp_proto !'
113112
endif
114113

115114
!B: the following part may not be really needed(?)
@@ -132,8 +131,8 @@ subroutine prism_init
132131
if (ierror /= PRISM_Ok) then
133132
print *, 'CICE: (prism_init) Error in MPI_Buffer_Attach.'
134133
call prism_abort_proto(il_comp_id, 'cice prism_init','STOP 2')
135-
else
136-
print *, 'CICE: (prism_init) MPI_Buffer_Attach ok!'
134+
! else
135+
! print *, 'CICE: (prism_init) MPI_Buffer_Attach ok!'
137136
endif
138137
!
139138
! PSMILe attribution of local communicator.
@@ -147,21 +146,21 @@ subroutine prism_init
147146
print *, 'CICE: Error in prism_get_localcomm_proto'
148147
call prism_abort_proto(il_comp_id, 'cice prism_init','STOP 3')
149148
else
150-
print *, 'CICE: _get_localcomm_ OK! il_commlocal= ',il_commlocal
149+
if ( my_task == master_task ) print *, 'CICE: _get_localcomm_ OK! il_commlocal= ',il_commlocal
151150
endif
152151

153152
!
154153
! Inquire if model is parallel or not and open the process log file
155154
!
156155
! print *, '* CICE: Entering init_cpl.....'
157156

158-
print *, '* CICE (prism_init) calling MPI_Comm_Size ...'
157+
!print *, '* CICE (prism_init) calling MPI_Comm_Size ...'
159158
call MPI_Comm_Size(il_commlocal, il_nbtotproc, ierror)
160-
print *, '* CICE (prism_init) calling MPI_Comm_Rank ...'
159+
!print *, '* CICE (prism_init) calling MPI_Comm_Rank ...'
161160
call MPI_Comm_Rank(il_commlocal, my_task, ierror)
162161

163-
print *, '* CICE (prism_init) il_commlocal, il_nbtotproc, my_task = '
164-
print *, '* CICE (prism_init) ', il_commlocal, il_nbtotproc, my_task
162+
if ( my_task == master_task ) print *, '* CICE (prism_init) il_commlocal, il_nbtotproc, my_task = '
163+
if ( my_task == master_task ) print *, '* CICE (prism_init) ', il_commlocal, il_nbtotproc, my_task
165164
!
166165
il_nbcplproc = il_nbtotproc !multi-process coupling (real parallel cpl)!
167166
!il_nbcplproc = 1 !mono process coupling
@@ -258,18 +257,18 @@ subroutine init_cpl
258257
! end do
259258

260259
!!debug
261-
if (my_task == 0) then
262-
write(il_out,*) "all block info:"
263-
do iblk=1,nblocks_tot
264-
this_block = get_block(iblk,iblk)
265-
ilo = this_block%ilo
266-
ihi = this_block%ihi
267-
jlo = this_block%jlo
268-
jhi = this_block%jhi
269-
write(il_out,*) ' this block: cpu, iblock, jblock=', distrb_info%blockLocation(iblk)-1, this_block%iblock, this_block%jblock
270-
write(il_out,*) ' block:', iblk, "gilo, gjlo, gihi, gjhi=", this_block%i_glob(ilo), this_block%j_glob(jlo), this_block%i_glob(ihi), this_block%j_glob(jhi)
271-
end do
272-
end if
260+
! if (my_task == 0) then
261+
! write(il_out,*) "all block info:"
262+
! do iblk=1,nblocks_tot
263+
! this_block = get_block(iblk,iblk)
264+
! ilo = this_block%ilo
265+
! ihi = this_block%ihi
266+
! jlo = this_block%jlo
267+
! jhi = this_block%jhi
268+
! write(il_out,*) ' this block: cpu, iblock, jblock=', distrb_info%blockLocation(iblk)-1, this_block%iblock, this_block%jblock
269+
! write(il_out,*) ' block:', iblk, "gilo, gjlo, gihi, gjhi=", this_block%i_glob(ilo), this_block%j_glob(jlo), this_block%i_glob(ihi), this_block%j_glob(jhi)
270+
! end do
271+
! end if
273272

274273
do iblk=1,nblocks_tot
275274

@@ -781,8 +780,8 @@ subroutine from_atm(isteps)
781780
call ncheck( nf_open('fields_a2i_in_ice.nc',nf_write,ncid) )
782781
call write_nc_1Dtime(real(isteps),currstep,'time',ncid)
783782
endif
784-
write(il_out,*)
785-
write(il_out,*) '(from_atm) Total number of fields to be rcvd: ', nrecv_a2i
783+
! write(il_out,*)
784+
! write(il_out,*) '(from_atm) Total number of fields to be rcvd: ', nrecv_a2i
786785
endif
787786

788787
if (debug) write(il_out,*) "prism_get from_atm at sec: ", isteps

io_netcdf/ice_history_write.F90

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
668668
call check(nf90_put_att(ncid,varid,'cell_measures', &
669669
avail_hist_fields(n)%vcellmeas), &
670670
'put att cell_measures '//avail_hist_fields(n)%vname)
671+
if (avail_hist_fields(n)%vcomment /= "none") then
672+
call check(nf90_put_att(ncid,varid,'comment', &
673+
avail_hist_fields(n)%vcomment), &
674+
'put att comment '//avail_hist_fields(n)%vname)
675+
endif
671676
call check(nf90_put_att(ncid,varid,'missing_value',spval), &
672677
'put att missing_value '//avail_hist_fields(n)%vname)
673678
call check(nf90_put_att(ncid,varid,'_FillValue',spval), &
@@ -679,9 +684,20 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
679684
if (hist_avg) then
680685
if (TRIM(avail_hist_fields(n)%vname)/='sig1' .or. &
681686
TRIM(avail_hist_fields(n)%vname)/='sig2') then
682-
683-
call check(nf90_put_att(ncid,varid,'cell_methods','time: mean'), &
687+
if (avail_hist_fields(n)%avg_ice_present) then
688+
call check(nf90_put_att(ncid,varid,'cell_methods',&
689+
'area: time: mean where sea_ice (mask=siconc)'), &
690+
'put att cell methods time mean '//avail_hist_fields(n)%vname)
691+
else
692+
if (TRIM(avail_hist_fields(n)%vname(1:2))/='si') then !native diags
693+
call check(nf90_put_att(ncid,varid,'cell_methods','time: mean'), &
694+
'put att cell methods time mean '//avail_hist_fields(n)%vname)
695+
else !cmip diags
696+
call check(nf90_put_att(ncid,varid,'cell_methods', &
697+
'area: mean where sea time: mean'), &
684698
'put att cell methods time mean '//avail_hist_fields(n)%vname)
699+
endif
700+
endif
685701
endif
686702
endif
687703

@@ -739,6 +755,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
739755
avail_hist_fields(n)%vcellmeas)
740756
if (status /= nf90_noerr) call abort_ice( &
741757
'Error defining cell measures for '//avail_hist_fields(n)%vname)
758+
if (avail_hist_fields(n)%vcomment /= "none") then
759+
call check(nf90_put_att(ncid,varid,'comment', &
760+
avail_hist_fields(n)%vcomment), &
761+
'put att comment '//avail_hist_fields(n)%vname)
762+
endif
742763
status = nf90_put_att(ncid,varid,'missing_value',spval)
743764
if (status /= nf90_noerr) call abort_ice( &
744765
'Error defining missing_value for '//avail_hist_fields(n)%vname)
@@ -802,6 +823,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
802823
avail_hist_fields(n)%vcellmeas)
803824
if (status /= nf90_noerr) call abort_ice( &
804825
'Error defining cell measures for '//avail_hist_fields(n)%vname)
826+
if (avail_hist_fields(n)%vcomment /= "none") then
827+
call check(nf90_put_att(ncid,varid,'comment', &
828+
avail_hist_fields(n)%vcomment), &
829+
'put att comment '//avail_hist_fields(n)%vname)
830+
endif
805831
status = nf90_put_att(ncid,varid,'missing_value',spval)
806832
if (status /= nf90_noerr) call abort_ice( &
807833
'Error defining missing_value for '//avail_hist_fields(n)%vname)
@@ -851,6 +877,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
851877
avail_hist_fields(n)%vcellmeas)
852878
if (status /= nf90_noerr) call abort_ice( &
853879
'Error defining cell measures for '//avail_hist_fields(n)%vname)
880+
if (avail_hist_fields(n)%vcomment /= "none") then
881+
call check(nf90_put_att(ncid,varid,'comment', &
882+
avail_hist_fields(n)%vcomment), &
883+
'put att comment '//avail_hist_fields(n)%vname)
884+
endif
854885
status = nf90_put_att(ncid,varid,'missing_value',spval)
855886
if (status /= nf90_noerr) call abort_ice( &
856887
'Error defining missing_value for '//avail_hist_fields(n)%vname)
@@ -901,6 +932,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
901932
avail_hist_fields(n)%vcellmeas)
902933
if (status /= nf90_noerr) call abort_ice( &
903934
'Error defining cell measures for '//avail_hist_fields(n)%vname)
935+
if (avail_hist_fields(n)%vcomment /= "none") then
936+
call check(nf90_put_att(ncid,varid,'comment', &
937+
avail_hist_fields(n)%vcomment), &
938+
'put att comment '//avail_hist_fields(n)%vname)
939+
endif
904940
status = nf90_put_att(ncid,varid,'missing_value',spval)
905941
if (status /= nf90_noerr) call abort_ice( &
906942
'Error defining missing_value for '//avail_hist_fields(n)%vname)
@@ -966,6 +1002,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
9661002
avail_hist_fields(n)%vcellmeas)
9671003
if (status /= nf90_noerr) call abort_ice( &
9681004
'Error defining cell measures for '//avail_hist_fields(n)%vname)
1005+
if (avail_hist_fields(n)%vcomment /= "none") then
1006+
call check(nf90_put_att(ncid,varid,'comment', &
1007+
avail_hist_fields(n)%vcomment), &
1008+
'put att comment '//avail_hist_fields(n)%vname)
1009+
endif
9691010
status = nf90_put_att(ncid,varid,'missing_value',spval)
9701011
if (status /= nf90_noerr) call abort_ice( &
9711012
'Error defining missing_value for '//avail_hist_fields(n)%vname)
@@ -1031,6 +1072,11 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
10311072
avail_hist_fields(n)%vcellmeas)
10321073
if (status /= nf90_noerr) call abort_ice( &
10331074
'Error defining cell measures for '//avail_hist_fields(n)%vname)
1075+
if (avail_hist_fields(n)%vcomment /= "none") then
1076+
call check(nf90_put_att(ncid,varid,'comment', &
1077+
avail_hist_fields(n)%vcomment), &
1078+
'put att comment '//avail_hist_fields(n)%vname)
1079+
endif
10341080
status = nf90_put_att(ncid,varid,'missing_value',spval)
10351081
if (status /= nf90_noerr) call abort_ice( &
10361082
'Error defining missing_value for '//avail_hist_fields(n)%vname)
@@ -1094,9 +1140,10 @@ subroutine ice_hist_create(ns, ncfile, ncid, var, coord_var, var_nverts, var_nz)
10941140
call check(nf90_put_att(ncid,nf90_global,'comment2',title), &
10951141
'global attribute comment2')
10961142

1097-
title = 'CF-1.0'
1098-
call check(nf90_put_att(ncid,nf90_global,'conventions',title), &
1099-
'global attribute conventions')
1143+
! TO-DO: Update output for CF compliance !
1144+
! title = 'CF-1.0'
1145+
! call check(nf90_put_att(ncid,nf90_global,'conventions',title), &
1146+
! 'global attribute conventions')
11001147

11011148
call date_and_time(date=current_date, time=current_time)
11021149
write(start_time,1000) current_date(1:4), current_date(5:6), &

0 commit comments

Comments
 (0)