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 a bunch of C-grid infrastructure #1

Merged
merged 17 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions cicecore/cicedynB/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ subroutine init_hist (dt)
use ice_domain_size, only: max_blocks, max_nstrm, nilyr, nslyr, nblyr, ncat, nfsd
use ice_dyn_shared, only: kdyn
use ice_flux, only: mlt_onset, frz_onset, albcnt, snwcnt
use ice_grid, only: grid_system
use ice_history_shared ! everything
use ice_history_mechred, only: init_hist_mechred_2D, init_hist_mechred_3Dc
use ice_history_pond, only: init_hist_pond_2D, init_hist_pond_3Dc
Expand Down Expand Up @@ -277,6 +278,13 @@ subroutine init_hist (dt)
f_sispeed = f_CMIP
endif

if (grid_system == 'CD') then
f_uvele = f_uvel
f_vvele = f_vvel
f_uveln = f_uvel
f_vveln = f_vvel
endif

#ifndef ncdf
f_bounds = .false.
#endif
Expand All @@ -290,13 +298,22 @@ subroutine init_hist (dt)
if (tr_fsd) f_NFSD = .true.

call broadcast_scalar (f_tmask, master_task)
call broadcast_scalar (f_umask, master_task)
call broadcast_scalar (f_nmask, master_task)
call broadcast_scalar (f_emask, master_task)
call broadcast_scalar (f_blkmask, master_task)
call broadcast_scalar (f_tarea, master_task)
call broadcast_scalar (f_uarea, master_task)
call broadcast_scalar (f_narea, master_task)
call broadcast_scalar (f_earea, master_task)
call broadcast_scalar (f_dxt, master_task)
call broadcast_scalar (f_dyt, master_task)
call broadcast_scalar (f_dxu, master_task)
call broadcast_scalar (f_dyu, master_task)
call broadcast_scalar (f_dxn, master_task)
call broadcast_scalar (f_dyn, master_task)
call broadcast_scalar (f_dxe, master_task)
call broadcast_scalar (f_dye, master_task)
call broadcast_scalar (f_HTN, master_task)
call broadcast_scalar (f_HTE, master_task)
call broadcast_scalar (f_ANGLE, master_task)
Expand All @@ -318,6 +335,10 @@ subroutine init_hist (dt)
call broadcast_scalar (f_aice, master_task)
call broadcast_scalar (f_uvel, master_task)
call broadcast_scalar (f_vvel, master_task)
call broadcast_scalar (f_uvele, master_task)
call broadcast_scalar (f_uveln, master_task)
call broadcast_scalar (f_vvele, master_task)
call broadcast_scalar (f_vveln, master_task)
call broadcast_scalar (f_uatm, master_task)
call broadcast_scalar (f_vatm, master_task)
call broadcast_scalar (f_atmspd, master_task)
Expand Down Expand Up @@ -538,21 +559,39 @@ subroutine init_hist (dt)
"snow/ice surface temperature", &
"averaged with Tf if no ice is present", c1, c0, &
ns1, f_Tsfc)

call define_hist_field(n_aice,"aice","1",tstr2D, tcstr, &
"ice area (aggregate)", &
"none", c1, c0, &
ns1, f_aice)

call define_hist_field(n_uvel,"uvel","m/s",ustr2D, ucstr, &

if (grid_system == 'CD') then
call define_hist_field(n_uvele,"uvele","m/s",estr2D, ecstr, &
"ice velocity (x)", &
"positive is x direction on E grid", c1, c0, &
ns1, f_uvel)
call define_hist_field(n_vvele,"vvele","m/s",estr2D, ecstr, &
"ice velocity (y)", &
"positive is y direction on E grid", c1, c0, &
ns1, f_uvel)
call define_hist_field(n_uveln,"uveln","m/s",nstr2D, ncstr, &
"ice velocity (x)", &
"positive is x direction on N grid", c1, c0, &
ns1, f_vvel)
call define_hist_field(n_vveln,"vveln","m/s",nstr2D, ncstr, &
"ice velocity (y)", &
"positive is y direction on N grid", c1, c0, &
ns1, f_vvel)
else
call define_hist_field(n_uvel,"uvel","m/s",ustr2D, ucstr, &
"ice velocity (x)", &
"positive is x direction on U grid", c1, c0, &
ns1, f_uvel)

call define_hist_field(n_vvel,"vvel","m/s",ustr2D, ucstr, &
call define_hist_field(n_vvel,"vvel","m/s",ustr2D, ucstr, &
"ice velocity (y)", &
"positive is y direction on U grid", c1, c0, &
ns1, f_vvel)
endif

call define_hist_field(n_uatm,"uatm","m/s",ustr2D, ucstr, &
"atm velocity (x)", &
Expand Down Expand Up @@ -1592,13 +1631,22 @@ subroutine init_hist (dt)
igrd=.true.

igrd(n_tmask ) = f_tmask
igrd(n_umask ) = f_umask
igrd(n_nmask ) = f_nmask
igrd(n_emask ) = f_emask
igrd(n_blkmask ) = f_blkmask
igrd(n_tarea ) = f_tarea
igrd(n_uarea ) = f_uarea
igrd(n_narea ) = f_narea
igrd(n_earea ) = f_earea
igrd(n_dxt ) = f_dxt
igrd(n_dyt ) = f_dyt
igrd(n_dxu ) = f_dxu
igrd(n_dyu ) = f_dyu
igrd(n_dxn ) = f_dxn
igrd(n_dyn ) = f_dyn
igrd(n_dxe ) = f_dxe
igrd(n_dye ) = f_dye
igrd(n_HTN ) = f_HTN
igrd(n_HTE ) = f_HTE
igrd(n_ANGLE ) = f_ANGLE
Expand Down Expand Up @@ -1918,6 +1966,10 @@ subroutine accum_hist (dt)
call accum_hist_field(n_uvel, iblk, uvel(:,:,iblk), a2D)
if (f_vvel (1:1) /= 'x') &
call accum_hist_field(n_vvel, iblk, vvel(:,:,iblk), a2D)
if (f_uveln (1:1) /= 'x') &
call accum_hist_field(n_uveln, iblk, uveln(:,:,iblk), a2D)
if (f_vvele (1:1) /= 'x') &
call accum_hist_field(n_vvele, iblk, vvele(:,:,iblk), a2D)
if (f_uatm (1:1) /= 'x') &
call accum_hist_field(n_uatm, iblk, uatm(:,:,iblk), a2D)
if (f_vatm (1:1) /= 'x') &
Expand Down
87 changes: 68 additions & 19 deletions cicecore/cicedynB/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ module ice_history_shared
avail_hist_fields(max_avail_hist_fields)

integer (kind=int_kind), parameter, public :: &
nvar = 12 , & ! number of grid fields that can be written
nvar_grd = 21 , & ! number of grid fields that can be written
! excluding grid vertices
nvarz = 6 ! number of category/vertical grid fields written
nvar_grdz = 6 ! number of category/vertical grid fields written

integer (kind=int_kind), public :: &
ncat_hist , & ! number of thickness categories written <= ncat
Expand Down Expand Up @@ -152,32 +152,52 @@ module ice_history_shared
avgct(max_nstrm) ! average sample counter

logical (kind=log_kind), public :: &
igrd (nvar), & ! true if grid field is written to output file
igrdz(nvarz) ! true if category/vertical grid field is written
igrd (nvar_grd), & ! true if grid field is written to output file
igrdz(nvar_grdz) ! true if category/vertical grid field is written

character (len=25), public, parameter :: &
tcstr = 'area: tarea' , & ! vcellmeas for T cell quantities
ucstr = 'area: uarea' , & ! vcellmeas for U cell quantities
ncstr = 'area: narea' , & ! vcellmeas for N cell quantities
ecstr = 'area: earea' , & ! vcellmeas for E cell quantities
tstr2D = 'TLON TLAT time' , & ! vcoord for T cell quantities, 2D
ustr2D = 'ULON ULAT time' , & ! vcoord for U cell quantities, 2D
nstr2D = 'NLON NLAT time' , & ! vcoord for N cell quantities, 2D
estr2D = 'ELON ELAT time' , & ! vcoord for E cell quantities, 2D
tstr3Dz = 'TLON TLAT VGRDi time',& ! vcoord for T cell quantities, 3D
ustr3Dz = 'ULON ULAT VGRDi time',& ! vcoord for U cell quantities, 3D
nstr3Dz = 'NLON NLAT VGRDi time',& ! vcoord for N cell quantities, 3D
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we will need some of these options on the N and E grids, but it's okay to have them available for future use. The B- vs C-grid choice should only impact the dynamics variables, which do not have vertical, ITD (ncat) or FSD dimensions.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 4d options already exists for the ULON ULAT, so that's why I added them for the N and E grids. It could be that we can get rid of some of them at some point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a "clean up history" checkbox in the project board, to remind us to look back at this. I'd suggest commenting out whatever is not immediately needed.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a tick box to the project page.

estr3Dz = 'ELON ELAT VGRDi time',& ! vcoord for E cell quantities, 3D
tstr3Dc = 'TLON TLAT NCAT time',& ! vcoord for T cell quantities, 3D
ustr3Dc = 'ULON ULAT NCAT time',& ! vcoord for U cell quantities, 3D
nstr3Dc = 'NLON NLAT NCAT time',& ! vcoord for N cell quantities, 3D
estr3Dc = 'ELON ELAT NCAT time',& ! vcoord for E cell quantities, 3D
tstr3Db = 'TLON TLAT VGRDb time',& ! vcoord for T cell quantities, 3D
ustr3Db = 'ULON ULAT VGRDb time',& ! vcoord for U cell quantities, 3D
nstr3Db = 'NLON NLAT VGRDb time',& ! vcoord for N cell quantities, 3D
estr3Db = 'ELON ELAT VGRDb time',& ! vcoord for E cell quantities, 3D
tstr3Da = 'TLON TLAT VGRDa time',& ! vcoord for T cell quantities, 3D
ustr3Da = 'ULON ULAT VGRDa time',& ! vcoord for U cell quantities, 3D
nstr3Da = 'NLON NLAT VGRDa time',& ! vcoord for N cell quantities, 3D
estr3Da = 'ELON ELAT VGRDa time',& ! vcoord for E cell quantities, 3D
tstr3Df = 'TLON TLAT NFSD time',& ! vcoord for T cell quantities, 3D
ustr3Df = 'ULON ULAT NFSD time',& ! vcoord for U cell quantities, 3D
nstr3Df = 'NLON NLAT NFSD time',& ! vcoord for N cell quantities, 3D
estr3Df = 'ELON ELAT NFSD time',& ! vcoord for E cell quantities, 3D

!ferret
tstr4Di = 'TLON TLAT VGRDi NCAT', & ! vcoord for T cell, 4D, ice
ustr4Di = 'ULON ULAT VGRDi NCAT', & ! vcoord for U cell, 4D, ice
nstr4Di = 'NLON NLAT VGRDi NCAT', & ! vcoord for N cell, 4D, ice
estr4Di = 'ELON ELAT VGRDi NCAT', & ! vcoord for E cell, 4D, ice
tstr4Ds = 'TLON TLAT VGRDs NCAT', & ! vcoord for T cell, 4D, snow
ustr4Ds = 'ULON ULAT VGRDs NCAT', & ! vcoord for U cell, 4D, snow
nstr4Ds = 'NLON NLAT VGRDs NCAT', & ! vcoord for N cell, 4D, snow
estr4Ds = 'ELON ELAT VGRDs NCAT', & ! vcoord for E cell, 4D, snow
tstr4Df = 'TLON TLAT NFSD NCAT', & ! vcoord for T cell, 4D, fsd
ustr4Df = 'ULON ULAT NFSD NCAT' ! vcoord for U cell, 4D, fsd
ustr4Df = 'ULON ULAT NFSD NCAT', & ! vcoord for U cell, 4D, fsd
nstr4Df = 'NLON NLAT NFSD NCAT', & ! vcoord for N cell, 4D, fsd
estr4Df = 'ELON ELAT NFSD NCAT' ! vcoord for E cell, 4D, fsd
!ferret
! tstr4Di = 'TLON TLAT VGRDi NCAT time', & ! ferret can not handle time
! ustr4Di = 'ULON ULAT VGRDi NCAT time', & ! index on 4D variables.
Expand All @@ -193,10 +213,15 @@ module ice_history_shared
!---------------------------------------------------------------

logical (kind=log_kind), public :: &
f_tmask = .true., f_blkmask = .true., &
f_tmask = .true., f_umask = .true., &
f_nmask = .true., f_emask = .true., &
f_blkmask = .true., &
f_tarea = .true., f_uarea = .true., &
f_narea = .true., f_earea = .true., &
f_dxt = .true., f_dyt = .true., &
f_dxu = .true., f_dyu = .true., &
f_dxn = .true., f_dyn = .true., &
f_dxe = .true., f_dye = .true., &
f_HTN = .true., f_HTE = .true., &
f_ANGLE = .true., f_ANGLET = .true., &
f_bounds = .true., f_NCAT = .true., &
Expand All @@ -210,6 +235,8 @@ module ice_history_shared
f_snowfrac = 'x', f_snowfracn = 'x', &
f_Tsfc = 'm', f_aice = 'm', &
f_uvel = 'm', f_vvel = 'm', &
f_uvele = 'x', f_vvele = 'x', &
f_uveln = 'x', f_vveln = 'x', &
f_uatm = 'm', f_vatm = 'm', &
f_atmspd = 'm', f_atmdir = 'm', &
f_fswup = 'm', &
Expand Down Expand Up @@ -339,10 +366,15 @@ module ice_history_shared
!---------------------------------------------------------------

namelist / icefields_nml / &
f_tmask , f_blkmask , &
f_tmask , f_umask , &
f_nmask , f_emask , &
f_blkmask , &
f_tarea , f_uarea , &
f_narea , f_earea , &
f_dxt , f_dyt , &
f_dxu , f_dyu , &
f_dxn , f_dyn , &
f_dxe , f_dye , &
f_HTN , f_HTE , &
f_ANGLE , f_ANGLET , &
f_bounds , f_NCAT , &
Expand All @@ -354,6 +386,8 @@ module ice_history_shared
f_snowfrac, f_snowfracn, &
f_Tsfc, f_aice , &
f_uvel, f_vvel , &
! f_uvele, f_vvele , & ! for now, have this set from f_uvel, f_vvel
! f_uveln, f_vveln , & ! for now, have this set from f_uvel, f_vvel
f_uatm, f_vatm , &
f_atmspd, f_atmdir , &
f_fswup, &
Expand Down Expand Up @@ -484,17 +518,26 @@ module ice_history_shared

integer (kind=int_kind), parameter, public :: &
n_tmask = 1, &
n_blkmask = 2, &
n_tarea = 3, &
n_uarea = 4, &
n_dxt = 5, &
n_dyt = 6, &
n_dxu = 7, &
n_dyu = 8, &
n_HTN = 9, &
n_HTE = 10, &
n_ANGLE = 11, &
n_ANGLET = 12, &
n_umask = 2, &
n_nmask = 3, &
n_emask = 4, &
n_blkmask = 5, &
n_tarea = 6, &
n_uarea = 7, &
n_narea = 8, &
n_earea = 9, &
n_dxt = 10, &
n_dyt = 11, &
n_dxu = 12, &
n_dyu = 13, &
n_dxn = 14, &
n_dyn = 15, &
n_dxe = 16, &
n_dye = 17, &
n_HTN = 18, &
n_HTE = 19, &
n_ANGLE = 20, &
n_ANGLET = 21, &

n_NCAT = 1, &
n_VGRDi = 2, &
Expand All @@ -506,14 +549,20 @@ module ice_history_shared
n_lont_bnds = 1, &
n_latt_bnds = 2, &
n_lonu_bnds = 3, &
n_latu_bnds = 4
n_latu_bnds = 4, &
n_lonn_bnds = 5, &
n_latn_bnds = 6, &
n_lone_bnds = 7, &
n_late_bnds = 8

integer (kind=int_kind), dimension(max_nstrm), public :: &
! n_example , &
n_hi , n_hs , &
n_snowfrac , n_snowfracn , &
n_Tsfc , n_aice , &
n_uvel , n_vvel , &
n_uvele , n_vvele , &
n_uveln , n_vveln , &
n_uatm , n_vatm , &
n_atmspd , n_atmdir , &
n_sice , &
Expand Down
22 changes: 15 additions & 7 deletions cicecore/cicedynB/dynamics/ice_dyn_eap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ subroutine eap (dt)
stressm_1, stressm_2, stressm_3, stressm_4, &
stress12_1, stress12_2, stress12_3, stress12_4
use ice_grid, only: tmask, umask, dxt, dyt, dxhy, dyhx, cxp, cyp, cxm, cym, &
tarear, uarear, to_ugrid, t2ugrid_vector, u2tgrid_vector
tarear, uarear, grid_average_X2Y
use ice_state, only: aice, vice, vsno, uvel, vvel, divu, shear, &
aice_init, aice0, aicen, vicen, strength
! use ice_timers, only: timer_dynamics, timer_bound, &
Expand Down Expand Up @@ -254,8 +254,8 @@ subroutine eap (dt)
! convert fields from T to U grid
!-----------------------------------------------------------------

call to_ugrid(tmass,umass)
call to_ugrid(aice_init, aiu)
call grid_average_X2Y('T2UF',tmass,umass)
call grid_average_X2Y('T2UF',aice_init, aiu)

!----------------------------------------------------------------
! Set wind stress to values supplied via NEMO or other forcing
Expand All @@ -270,8 +270,12 @@ subroutine eap (dt)
strairx(:,:,:) = strax(:,:,:)
strairy(:,:,:) = stray(:,:,:)
else
call t2ugrid_vector(strairx)
call t2ugrid_vector(strairy)
call ice_HaloUpdate (strairx, halo_info, &
field_loc_center, field_type_vector)
call ice_HaloUpdate (strairy, halo_info, &
field_loc_center, field_type_vector)
call grid_average_X2Y('T2UF',strairx)
call grid_average_X2Y('T2UF',strairy)
endif

! tcraig, tcx, turned off this threaded region, in evp, this block and
Expand Down Expand Up @@ -548,8 +552,12 @@ subroutine eap (dt)
enddo
!$OMP END PARALLEL DO

call u2tgrid_vector(strocnxT) ! shift
call u2tgrid_vector(strocnyT)
call ice_HaloUpdate (strocnxT, halo_info, &
field_loc_NEcorner, field_type_vector)
call ice_HaloUpdate (strocnyT, halo_info, &
field_loc_NEcorner, field_type_vector)
call grid_average_X2Y('U2TF',strocnxT) ! shift
call grid_average_X2Y('U2TF',strocnyT)

call ice_timer_stop(timer_dynamics) ! dynamics

Expand Down
Loading