MOM6
mom_tracer_registry Module Reference

Detailed Description

This module contains the tracer_registry_type and the subroutines that handle registration of tracers and related subroutines. The primary subroutine, register_tracer, is called to indicate the tracers advected and diffused.

Data Types

type  tracer_registry_type
 Type to carry basic tracer information. More...
 
type  tracer_type
 The tracer type. More...
 

Functions/Subroutines

subroutine, public register_tracer (tr_ptr, Reg, param_file, HI, GV, name, longname, units, cmor_name, cmor_units, cmor_longname, tr_desc, OBC_inflow, OBC_in_u, OBC_in_v, ad_x, ad_y, df_x, df_y, ad_2d_x, ad_2d_y, df_2d_x, df_2d_y, advection_xy, registry_diags, flux_nameroot, flux_longname, flux_units, flux_scale, convergence_units, convergence_scale, cmor_tendprefix, diag_form, restart_CS, mandatory)
 This subroutine registers a tracer to be advected and laterally diffused. More...
 
subroutine, public lock_tracer_registry (Reg)
 This subroutine locks the tracer registry to prevent the addition of more tracers. After locked=.true., can then register common diagnostics. More...
 
subroutine, public register_tracer_diagnostics (Reg, h, Time, diag, G, GV, US, use_ALE)
 register_tracer_diagnostics does a set of register_diag_field calls for any previously registered in a tracer registry with a value of registry_diags set to .true. More...
 
subroutine, public preale_tracer_diagnostics (Reg, G, GV)
 
subroutine, public postale_tracer_diagnostics (Reg, G, GV, diag, dt)
 
subroutine, public post_tracer_diagnostics_at_sync (Reg, h, diag_prev, diag, G, GV, dt)
 Post tracer diganostics when that should only be posted when MOM's state is self-consistent (also referred to as 'synchronized') More...
 
subroutine, public post_tracer_transport_diagnostics (G, GV, Reg, h_diag, diag)
 Post the advective and diffusive tendencies. More...
 
subroutine, public mom_tracer_chksum (mesg, Tr, ntr, G)
 This subroutine writes out chksums for tracers. More...
 
subroutine, public mom_tracer_chkinv (mesg, G, h, Tr, ntr)
 Calculates and prints the global inventory of all tracers in the registry. More...
 
subroutine, public tracer_name_lookup (Reg, tr_ptr, name)
 Find a tracer in the tracer registry by name. More...
 
subroutine, public tracer_registry_init (param_file, Reg)
 Initialize the tracer registry. More...
 
subroutine, public tracer_registry_end (Reg)
 This routine closes the tracer registry module. More...
 

Function/Subroutine Documentation

◆ lock_tracer_registry()

subroutine, public mom_tracer_registry::lock_tracer_registry ( type(tracer_registry_type), pointer  Reg)

This subroutine locks the tracer registry to prevent the addition of more tracers. After locked=.true., can then register common diagnostics.

Parameters
regpointer to the tracer registry

Definition at line 331 of file MOM_tracer_registry.F90.

332  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
333 
334  if (.not. associated(reg)) call mom_error(warning, &
335  "lock_tracer_registry called with an unassociated registry.")
336 
337  reg%locked = .true.
338 

◆ mom_tracer_chkinv()

subroutine, public mom_tracer_registry::mom_tracer_chkinv ( character(len=*), intent(in)  mesg,
type(ocean_grid_type), intent(in)  G,
real, dimension(szi_(g),szj_(g),szk_(g)), intent(in)  h,
type(tracer_type), dimension(:), intent(in)  Tr,
integer, intent(in)  ntr 
)

Calculates and prints the global inventory of all tracers in the registry.

Parameters
[in]mesgmessage that appears on the chksum lines
[in]gocean grid structure
[in]trarray of all of registered tracers
[in]hLayer thicknesses
[in]ntrnumber of registered tracers

Definition at line 825 of file MOM_tracer_registry.F90.

826  character(len=*), intent(in) :: mesg !< message that appears on the chksum lines
827  type(ocean_grid_type), intent(in) :: G !< ocean grid structure
828  type(tracer_type), dimension(:), intent(in) :: Tr !< array of all of registered tracers
829  real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thicknesses
830  integer, intent(in) :: ntr !< number of registered tracers
831 
832  real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: tr_inv !< Tracer inventory
833  real :: total_inv
834  integer :: is, ie, js, je, nz
835  integer :: i, j, k, m
836 
837  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
838  do m=1,ntr
839  do k=1,nz ; do j=js,je ; do i=is,ie
840  tr_inv(i,j,k) = tr(m)%t(i,j,k)*h(i,j,k)*g%US%L_to_m**2*g%areaT(i,j)*g%mask2dT(i,j)
841  enddo ; enddo ; enddo
842  total_inv = reproducing_sum(tr_inv, is+(1-g%isd), ie+(1-g%isd), js+(1-g%jsd), je+(1-g%jsd))
843  if (is_root_pe()) write(0,'(A,1X,A5,1X,ES25.16,1X,A)') "h-point: inventory", tr(m)%name, total_inv, mesg
844  enddo
845 

◆ mom_tracer_chksum()

subroutine, public mom_tracer_registry::mom_tracer_chksum ( character(len=*), intent(in)  mesg,
type(tracer_type), dimension(:), intent(in)  Tr,
integer, intent(in)  ntr,
type(ocean_grid_type), intent(in)  G 
)

This subroutine writes out chksums for tracers.

Parameters
[in]mesgmessage that appears on the chksum lines
[in]trarray of all of registered tracers
[in]ntrnumber of registered tracers
[in]gocean grid structure

Definition at line 808 of file MOM_tracer_registry.F90.

809  character(len=*), intent(in) :: mesg !< message that appears on the chksum lines
810  type(tracer_type), intent(in) :: Tr(:) !< array of all of registered tracers
811  integer, intent(in) :: ntr !< number of registered tracers
812  type(ocean_grid_type), intent(in) :: G !< ocean grid structure
813 
814  integer :: is, ie, js, je, nz
815  integer :: i, j, k, m
816 
817  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
818  do m=1,ntr
819  call hchksum(tr(m)%t, mesg//trim(tr(m)%name), g%HI)
820  enddo
821 

◆ post_tracer_diagnostics_at_sync()

subroutine, public mom_tracer_registry::post_tracer_diagnostics_at_sync ( type(tracer_registry_type), pointer  Reg,
real, dimension(szi_(g),szj_(g),szk_(gv)), intent(in)  h,
type(diag_grid_storage), intent(in)  diag_prev,
type(diag_ctrl), intent(inout)  diag,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, intent(in)  dt 
)

Post tracer diganostics when that should only be posted when MOM's state is self-consistent (also referred to as 'synchronized')

Parameters
[in]gThe ocean's grid structure
[in]gvThe ocean's vertical grid structure
regpointer to the tracer registry
[in]hLayer thicknesses
[in]diag_prevContains diagnostic grids from previous timestep
[in,out]diagstructure to regulate diagnostic output
[in]dttotal time step for tracer updates [T ~> s]

Definition at line 717 of file MOM_tracer_registry.F90.

718  type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
719  type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
720  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
721  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
722  intent(in) :: h !< Layer thicknesses
723  type(diag_grid_storage), intent(in) :: diag_prev !< Contains diagnostic grids from previous timestep
724  type(diag_ctrl), intent(inout) :: diag !< structure to regulate diagnostic output
725  real, intent(in) :: dt !< total time step for tracer updates [T ~> s]
726 
727  real :: work3d(SZI_(G),SZJ_(G),SZK_(GV))
728  real :: work2d(SZI_(G),SZJ_(G))
729  real :: Idt ! The inverse of the time step [T-1 ~> s-1]
730  type(tracer_type), pointer :: Tr=>null()
731  integer :: i, j, k, is, ie, js, je, nz, m
732  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
733 
734  idt = 0.; if (dt/=0.) idt = 1.0 / dt ! The "if" is in case the diagnostic is called for a zero length interval
735 
736  ! Tendency diagnostics need to be posted on the grid from the last call to this routine
737  call diag_save_grids(diag)
738  call diag_copy_storage_to_diag(diag, diag_prev)
739  do m=1,reg%ntr ; if (reg%Tr(m)%registry_diags) then
740  tr => reg%Tr(m)
741  if (tr%id_tr > 0) call post_data(tr%id_tr, tr%t, diag)
742  if (tr%id_tendency > 0) then
743  work3d(:,:,:) = 0.0
744  do k=1,nz ; do j=js,je ; do i=is,ie
745  work3d(i,j,k) = (tr%t(i,j,k) - tr%t_prev(i,j,k))*idt
746  tr%t_prev(i,j,k) = tr%t(i,j,k)
747  enddo ; enddo ; enddo
748  call post_data(tr%id_tendency, work3d, diag, alt_h=diag_prev%h_state)
749  endif
750  if ((tr%id_trxh_tendency > 0) .or. (tr%id_trxh_tendency_2d > 0)) then
751  do k=1,nz ; do j=js,je ; do i=is,ie
752  work3d(i,j,k) = (tr%t(i,j,k)*h(i,j,k) - tr%Trxh_prev(i,j,k)) * idt
753  tr%Trxh_prev(i,j,k) = tr%t(i,j,k) * h(i,j,k)
754  enddo ; enddo ; enddo
755  if (tr%id_trxh_tendency > 0) call post_data(tr%id_trxh_tendency, work3d, diag, alt_h=diag_prev%h_state)
756  if (tr%id_trxh_tendency_2d > 0) then
757  work2d(:,:) = 0.0
758  do k=1,nz ; do j=js,je ; do i=is,ie
759  work2d(i,j) = work2d(i,j) + work3d(i,j,k)
760  enddo ; enddo ; enddo
761  call post_data(tr%id_trxh_tendency_2d, work2d, diag)
762  endif
763  endif
764  endif ; enddo
765  call diag_restore_grids(diag)
766 

◆ post_tracer_transport_diagnostics()

subroutine, public mom_tracer_registry::post_tracer_transport_diagnostics ( type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
type(tracer_registry_type), pointer  Reg,
real, dimension(szi_(g),szj_(g),szk_(gv)), intent(in)  h_diag,
type(diag_ctrl), intent(in)  diag 
)

Post the advective and diffusive tendencies.

Parameters
[in]gThe ocean's grid structure
[in]gvThe ocean's vertical grid structure
regpointer to the tracer registry
[in]h_diagLayer thicknesses on which to post fields
[in]diagstructure to regulate diagnostic output

Definition at line 770 of file MOM_tracer_registry.F90.

771  type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
772  type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
773  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
774  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
775  intent(in) :: h_diag !< Layer thicknesses on which to post fields
776  type(diag_ctrl), intent(in) :: diag !< structure to regulate diagnostic output
777 
778  integer :: i, j, k, is, ie, js, je, nz, m
779  real :: work2d(SZI_(G),SZJ_(G))
780  type(tracer_type), pointer :: Tr=>null()
781 
782  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
783 
784  do m=1,reg%ntr ; if (reg%Tr(m)%registry_diags) then
785  tr => reg%Tr(m)
786  if (tr%id_tr_post_horzn> 0) call post_data(tr%id_tr_post_horzn, tr%t, diag)
787  if (tr%id_adx > 0) call post_data(tr%id_adx, tr%ad_x, diag, alt_h=h_diag)
788  if (tr%id_ady > 0) call post_data(tr%id_ady, tr%ad_y, diag, alt_h=h_diag)
789  if (tr%id_dfx > 0) call post_data(tr%id_dfx, tr%df_x, diag, alt_h=h_diag)
790  if (tr%id_dfy > 0) call post_data(tr%id_dfy, tr%df_y, diag, alt_h=h_diag)
791  if (tr%id_adx_2d > 0) call post_data(tr%id_adx_2d, tr%ad2d_x, diag)
792  if (tr%id_ady_2d > 0) call post_data(tr%id_ady_2d, tr%ad2d_y, diag)
793  if (tr%id_dfx_2d > 0) call post_data(tr%id_dfx_2d, tr%df2d_x, diag)
794  if (tr%id_dfy_2d > 0) call post_data(tr%id_dfy_2d, tr%df2d_y, diag)
795  if (tr%id_adv_xy > 0) call post_data(tr%id_adv_xy, tr%advection_xy, diag, alt_h=h_diag)
796  if (tr%id_adv_xy_2d > 0) then
797  work2d(:,:) = 0.0
798  do k=1,nz ; do j=js,je ; do i=is,ie
799  work2d(i,j) = work2d(i,j) + tr%advection_xy(i,j,k)
800  enddo ; enddo ; enddo
801  call post_data(tr%id_adv_xy_2d, work2d, diag)
802  endif
803  endif ; enddo
804 

◆ postale_tracer_diagnostics()

subroutine, public mom_tracer_registry::postale_tracer_diagnostics ( type(tracer_registry_type), pointer  Reg,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
type(diag_ctrl), intent(in)  diag,
real, intent(in)  dt 
)
Parameters
regpointer to the tracer registry
[in]gThe ocean's grid structure
[in]gvocean vertical grid structure
[in]diagregulates diagnostic output
[in]dttotal time interval for these diagnostics [T ~> s]

Definition at line 688 of file MOM_tracer_registry.F90.

689  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
690  type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
691  type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
692  type(diag_ctrl), intent(in) :: diag !< regulates diagnostic output
693  real, intent(in) :: dt !< total time interval for these diagnostics [T ~> s]
694 
695  real :: work(SZI_(G),SZJ_(G),SZK_(G))
696  real :: Idt ! The inverse of the time step [T-1 ~> s-1]
697  integer :: i, j, k, is, ie, js, je, nz, m, m2
698  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
699 
700  ! The "if" is to avoid NaNs if the diagnostic is called for a zero length interval
701  idt = 0.0 ; if (dt /= 0.0) idt = 1.0 / dt
702 
703  do m=1,reg%ntr ; if (reg%Tr(m)%id_tr_vardec > 0) then
704  m2 = reg%Tr(m)%ind_tr_squared
705  if (m2 < 1) call mom_error(fatal, "Bad value of Tr%ind_tr_squared for "//trim(reg%Tr(m)%name))
706  ! Update squared quantities
707  do k=1,nz ; do j=js,je ; do i=is,ie
708  work(i,j,k) = (reg%Tr(m2)%T(i,j,k) - reg%Tr(m)%T(i,j,k)**2) * idt
709  enddo ; enddo ; enddo
710  call post_data(reg%Tr(m)%id_tr_vardec, work, diag)
711  endif ; enddo
712 

◆ preale_tracer_diagnostics()

subroutine, public mom_tracer_registry::preale_tracer_diagnostics ( type(tracer_registry_type), pointer  Reg,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV 
)
Parameters
regpointer to the tracer registry
[in]gThe ocean's grid structure
[in]gvocean vertical grid structure

Definition at line 670 of file MOM_tracer_registry.F90.

671  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
672  type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
673  type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
674 
675  integer :: i, j, k, is, ie, js, je, nz, m, m2
676  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
677 
678  do m=1,reg%ntr ; if (reg%Tr(m)%ind_tr_squared > 0) then
679  m2 = reg%Tr(m)%ind_tr_squared
680  ! Update squared quantities
681  do k=1,nz ; do j=js,je ; do i=is,ie
682  reg%Tr(m2)%T(i,j,k) = reg%Tr(m)%T(i,j,k)**2
683  enddo ; enddo ; enddo
684  endif ; enddo
685 

◆ register_tracer()

subroutine, public mom_tracer_registry::register_tracer ( real, dimension( hi %isd: hi %ied, hi %jsd: hi %jed, gv %ke), target  tr_ptr,
type(tracer_registry_type), pointer  Reg,
type(param_file_type), intent(in)  param_file,
type(hor_index_type), intent(in)  HI,
type(verticalgrid_type), intent(in)  GV,
character(len=*), intent(in), optional  name,
character(len=*), intent(in), optional  longname,
character(len=*), intent(in), optional  units,
character(len=*), intent(in), optional  cmor_name,
character(len=*), intent(in), optional  cmor_units,
character(len=*), intent(in), optional  cmor_longname,
type(vardesc), intent(in), optional  tr_desc,
real, intent(in), optional  OBC_inflow,
real, dimension(:,:,:), optional, pointer  OBC_in_u,
real, dimension(:,:,:), optional, pointer  OBC_in_v,
real, dimension(:,:,:), optional, pointer  ad_x,
real, dimension(:,:,:), optional, pointer  ad_y,
real, dimension(:,:,:), optional, pointer  df_x,
real, dimension(:,:,:), optional, pointer  df_y,
real, dimension(:,:), optional, pointer  ad_2d_x,
real, dimension(:,:), optional, pointer  ad_2d_y,
real, dimension(:,:), optional, pointer  df_2d_x,
real, dimension(:,:), optional, pointer  df_2d_y,
real, dimension(:,:,:), optional, pointer  advection_xy,
logical, intent(in), optional  registry_diags,
character(len=*), intent(in), optional  flux_nameroot,
character(len=*), intent(in), optional  flux_longname,
character(len=*), intent(in), optional  flux_units,
real, intent(in), optional  flux_scale,
character(len=*), intent(in), optional  convergence_units,
real, intent(in), optional  convergence_scale,
character(len=*), intent(in), optional  cmor_tendprefix,
integer, intent(in), optional  diag_form,
type(mom_restart_cs), optional, pointer  restart_CS,
logical, intent(in), optional  mandatory 
)

This subroutine registers a tracer to be advected and laterally diffused.

Parameters
[in]hihorizontal index type
[in]gvocean vertical grid structure
regpointer to the tracer registry
tr_ptrtarget or pointer to the tracer array
[in]param_filefile to parse for model parameter values
[in]nameShort tracer name
[in]longnameThe long tracer name
[in]unitsThe units of this tracer
[in]cmor_nameCMOR name
[in]cmor_unitsCMOR physical dimensions of variable
[in]cmor_longnameCMOR long name
[in]tr_descA structure with metadata about the tracer
[in]obc_inflowthe tracer for all inflows via OBC for which OBC_in_u or OBC_in_v are not specified (units of tracer CONC)
obc_in_utracer at inflows through u-faces of tracer cells (units of tracer CONC)
obc_in_vtracer at inflows through v-faces of tracer cells (units of tracer CONC)
ad_xdiagnostic x-advective flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
ad_ydiagnostic y-advective flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
df_xdiagnostic x-diffusive flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
df_ydiagnostic y-diffusive flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
ad_2d_xvert sum of diagnostic x-advect flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
ad_2d_yvert sum of diagnostic y-advect flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
df_2d_xvert sum of diagnostic x-diffuse flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
df_2d_yvert sum of diagnostic y-diffuse flux [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
advection_xyconvergence of lateral advective tracer fluxes
[in]registry_diagsIf present and true, use the registry for the diagnostics of this tracer.
[in]flux_namerootShort tracer name snippet used construct the names of flux diagnostics.
[in]flux_longnameA word or phrase used construct the long names of flux diagnostics.
[in]flux_unitsThe units for the fluxes of this tracer.
[in]flux_scaleA scaling factor used to convert the fluxes of this tracer to its desired units.
[in]convergence_unitsThe units for the flux convergence of this tracer.
[in]convergence_scaleA scaling factor used to convert the flux convergence of this tracer to its desired units.
[in]cmor_tendprefixThe CMOR name for the layer-integrated tendencies of this tracer.
[in]diag_formAn integer (1 or 2, 1 by default) indicating the character string template to use in labeling diagnostics
restart_csA pointer to the restart control structure this tracer will be registered for restarts if this argument is present
[in]mandatoryIf true, this tracer must be read from a restart file.

Definition at line 151 of file MOM_tracer_registry.F90.

158  type(hor_index_type), intent(in) :: HI !< horizontal index type
159  type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
160  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
161  real, dimension(SZI_(HI),SZJ_(HI),SZK_(GV)), &
162  target :: tr_ptr !< target or pointer to the tracer array
163  type(param_file_type), intent(in) :: param_file !< file to parse for model parameter values
164  character(len=*), optional, intent(in) :: name !< Short tracer name
165  character(len=*), optional, intent(in) :: longname !< The long tracer name
166  character(len=*), optional, intent(in) :: units !< The units of this tracer
167  character(len=*), optional, intent(in) :: cmor_name !< CMOR name
168  character(len=*), optional, intent(in) :: cmor_units !< CMOR physical dimensions of variable
169  character(len=*), optional, intent(in) :: cmor_longname !< CMOR long name
170  type(vardesc), optional, intent(in) :: tr_desc !< A structure with metadata about the tracer
171 
172  real, optional, intent(in) :: OBC_inflow !< the tracer for all inflows via OBC for which OBC_in_u
173  !! or OBC_in_v are not specified (units of tracer CONC)
174  real, dimension(:,:,:), optional, pointer :: OBC_in_u !< tracer at inflows through u-faces of
175  !! tracer cells (units of tracer CONC)
176  real, dimension(:,:,:), optional, pointer :: OBC_in_v !< tracer at inflows through v-faces of
177  !! tracer cells (units of tracer CONC)
178 
179  ! The following are probably not necessary if registry_diags is present and true.
180  real, dimension(:,:,:), optional, pointer :: ad_x !< diagnostic x-advective flux
181  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
182  real, dimension(:,:,:), optional, pointer :: ad_y !< diagnostic y-advective flux
183  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
184  real, dimension(:,:,:), optional, pointer :: df_x !< diagnostic x-diffusive flux
185  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
186  real, dimension(:,:,:), optional, pointer :: df_y !< diagnostic y-diffusive flux
187  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
188  real, dimension(:,:), optional, pointer :: ad_2d_x !< vert sum of diagnostic x-advect flux
189  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
190  real, dimension(:,:), optional, pointer :: ad_2d_y !< vert sum of diagnostic y-advect flux
191  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
192  real, dimension(:,:), optional, pointer :: df_2d_x !< vert sum of diagnostic x-diffuse flux
193  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
194  real, dimension(:,:), optional, pointer :: df_2d_y !< vert sum of diagnostic y-diffuse flux
195  !! [conc H L2 T-1 ~> CONC m3 s-1 or CONC kg s-1]
196 
197  real, dimension(:,:,:), optional, pointer :: advection_xy !< convergence of lateral advective tracer fluxes
198  logical, optional, intent(in) :: registry_diags !< If present and true, use the registry for
199  !! the diagnostics of this tracer.
200  character(len=*), optional, intent(in) :: flux_nameroot !< Short tracer name snippet used construct the
201  !! names of flux diagnostics.
202  character(len=*), optional, intent(in) :: flux_longname !< A word or phrase used construct the long
203  !! names of flux diagnostics.
204  character(len=*), optional, intent(in) :: flux_units !< The units for the fluxes of this tracer.
205  real, optional, intent(in) :: flux_scale !< A scaling factor used to convert the fluxes
206  !! of this tracer to its desired units.
207  character(len=*), optional, intent(in) :: convergence_units !< The units for the flux convergence of
208  !! this tracer.
209  real, optional, intent(in) :: convergence_scale !< A scaling factor used to convert the flux
210  !! convergence of this tracer to its desired units.
211  character(len=*), optional, intent(in) :: cmor_tendprefix !< The CMOR name for the layer-integrated
212  !! tendencies of this tracer.
213  integer, optional, intent(in) :: diag_form !< An integer (1 or 2, 1 by default) indicating the
214  !! character string template to use in
215  !! labeling diagnostics
216  type(MOM_restart_CS), optional, pointer :: restart_CS !< A pointer to the restart control structure
217  !! this tracer will be registered for
218  !! restarts if this argument is present
219  logical, optional, intent(in) :: mandatory !< If true, this tracer must be read
220  !! from a restart file.
221 
222  logical :: mand
223  type(tracer_type), pointer :: Tr=>null()
224  character(len=256) :: mesg ! Message for error messages.
225 
226  if (.not. associated(reg)) call tracer_registry_init(param_file, reg)
227 
228  if (reg%ntr>=max_fields_) then
229  write(mesg,'("Increase MAX_FIELDS_ in MOM_memory.h to at least ",I3," to allow for &
230  &all the tracers being registered via register_tracer.")') reg%ntr+1
231  call mom_error(fatal,"MOM register_tracer: "//mesg)
232  endif
233  reg%ntr = reg%ntr + 1
234 
235  tr => reg%Tr(reg%ntr)
236 
237  if (present(name)) then
238  tr%name = name
239  tr%longname = name ; if (present(longname)) tr%longname = longname
240  tr%units = "Conc" ; if (present(units)) tr%units = units
241 
242  tr%cmor_name = ""
243  if (present(cmor_name)) tr%cmor_name = cmor_name
244 
245  tr%cmor_units = tr%units
246  if (present(cmor_units)) tr%cmor_units = cmor_units
247 
248  tr%cmor_longname = ""
249  if (present(cmor_longname)) tr%cmor_longname = cmor_longname
250 
251  if (present(tr_desc)) call mom_error(warning, "MOM register_tracer: "//&
252  "It is a bad idea to use both name and tr_desc when registring "//trim(name))
253  elseif (present(tr_desc)) then
254  call query_vardesc(tr_desc, name=tr%name, units=tr%units, &
255  longname=tr%longname, cmor_field_name=tr%cmor_name, &
256  cmor_longname=tr%cmor_longname, caller="register_tracer")
257  tr%cmor_units = tr%units
258  else
259  call mom_error(fatal,"MOM register_tracer: Either name or "//&
260  "tr_desc must be present when registering a tracer.")
261  endif
262 
263  if (reg%locked) call mom_error(fatal, &
264  "MOM register_tracer was called for variable "//trim(tr%name)//&
265  " with a locked tracer registry.")
266 
267  tr%flux_nameroot = tr%name
268  if (present(flux_nameroot)) then
269  if (len_trim(flux_nameroot) > 0) tr%flux_nameroot = flux_nameroot
270  endif
271 
272  tr%flux_longname = tr%longname
273  if (present(flux_longname)) then
274  if (len_trim(flux_longname) > 0) tr%flux_longname = flux_longname
275  endif
276 
277  tr%flux_units = ""
278  if (present(flux_units)) tr%flux_units = flux_units
279 
280  tr%flux_scale = 1.0
281  if (present(flux_scale)) tr%flux_scale = flux_scale
282 
283  tr%conv_units = ""
284  if (present(convergence_units)) tr%conv_units = convergence_units
285 
286  tr%cmor_tendprefix = ""
287  if (present(cmor_tendprefix)) tr%cmor_tendprefix = cmor_tendprefix
288 
289  tr%conv_scale = 1.0
290  if (present(convergence_scale)) then
291  tr%conv_scale = convergence_scale
292  elseif (present(flux_scale)) then
293  tr%conv_scale = flux_scale
294  endif
295 
296  tr%diag_form = 1
297  if (present(diag_form)) tr%diag_form = diag_form
298 
299  tr%t => tr_ptr
300 
301  if (present(registry_diags)) tr%registry_diags = registry_diags
302 
303  if (present(ad_x)) then ; if (associated(ad_x)) tr%ad_x => ad_x ; endif
304  if (present(ad_y)) then ; if (associated(ad_y)) tr%ad_y => ad_y ; endif
305  if (present(df_x)) then ; if (associated(df_x)) tr%df_x => df_x ; endif
306  if (present(df_y)) then ; if (associated(df_y)) tr%df_y => df_y ; endif
307 ! if (present(OBC_inflow)) Tr%OBC_inflow_conc = OBC_inflow
308 ! if (present(OBC_in_u)) then ; if (associated(OBC_in_u)) &
309 ! Tr%OBC_in_u => OBC_in_u ; endif
310 ! if (present(OBC_in_v)) then ; if (associated(OBC_in_v)) &
311 ! Tr%OBC_in_v => OBC_in_v ; endif
312  if (present(ad_2d_x)) then ; if (associated(ad_2d_x)) tr%ad2d_x => ad_2d_x ; endif
313  if (present(ad_2d_y)) then ; if (associated(ad_2d_y)) tr%ad2d_y => ad_2d_y ; endif
314  if (present(df_2d_x)) then ; if (associated(df_2d_x)) tr%df2d_x => df_2d_x ; endif
315 
316  if (present(advection_xy)) then ; if (associated(advection_xy)) tr%advection_xy => advection_xy ; endif
317 
318  if (present(restart_cs)) then ; if (associated(restart_cs)) then
319  ! Register this tracer to be read from and written to restart files.
320  mand = .true. ; if (present(mandatory)) mand = mandatory
321 
322  call register_restart_field(tr_ptr, tr%name, mand, restart_cs, &
323  longname=tr%longname, units=tr%units)
324  endif ; endif
325 

◆ register_tracer_diagnostics()

subroutine, public mom_tracer_registry::register_tracer_diagnostics ( type(tracer_registry_type), pointer  Reg,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h,
type(time_type), intent(in)  Time,
type(diag_ctrl), intent(in)  diag,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
type(unit_scale_type), intent(in)  US,
logical, intent(in)  use_ALE 
)

register_tracer_diagnostics does a set of register_diag_field calls for any previously registered in a tracer registry with a value of registry_diags set to .true.

Parameters
[in]gThe ocean's grid structure
[in]gvThe ocean's vertical grid structure
[in]usA dimensional unit scaling type
regpointer to the tracer registry
[in]hLayer thicknesses
[in]timecurrent model time
[in]diagstructure to regulate diagnostic output
[in]use_aleIf true active diagnostics that only apply to ALE configurations

Definition at line 343 of file MOM_tracer_registry.F90.

344  type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
345  type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
346  type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
347  type(tracer_registry_type), pointer :: Reg !< pointer to the tracer registry
348  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
349  intent(in) :: h !< Layer thicknesses
350  type(time_type), intent(in) :: Time !< current model time
351  type(diag_ctrl), intent(in) :: diag !< structure to regulate diagnostic output
352  logical, intent(in) :: use_ALE !< If true active diagnostics that only
353  !! apply to ALE configurations
354 
355  character(len=24) :: name ! A variable's name in a NetCDF file.
356  character(len=24) :: shortnm ! A shortened version of a variable's name for
357  ! creating additional diagnostics.
358  character(len=72) :: longname ! The long name of that tracer variable.
359  character(len=72) :: flux_longname ! The tracer name in the long names of fluxes.
360  character(len=48) :: units ! The dimensions of the tracer.
361  character(len=48) :: flux_units ! The units for fluxes, either
362  ! [units] m3 s-1 or [units] kg s-1.
363  character(len=48) :: conv_units ! The units for flux convergences, either
364  ! [units] m2 s-1 or [units] kg s-1.
365  character(len=48) :: unit2 ! The dimensions of the tracer squared
366  character(len=72) :: cmorname ! The CMOR name of this tracer.
367  character(len=120) :: cmor_longname ! The CMOR long name of that variable.
368  character(len=120) :: var_lname ! A temporary longname for a diagnostic.
369  character(len=120) :: cmor_var_lname ! The temporary CMOR long name for a diagnostic
370  character(len=72) :: cmor_varname ! The temporary CMOR name for a diagnostic
371  type(tracer_type), pointer :: Tr=>null()
372  integer :: i, j, k, is, ie, js, je, nz, m, m2, nTr_in
373  integer :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
374  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
375  isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
376  isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
377 
378  if (.not. associated(reg)) call mom_error(fatal, "register_tracer_diagnostics: "//&
379  "register_tracer must be called before register_tracer_diagnostics")
380 
381  ntr_in = reg%ntr
382 
383  do m=1,ntr_in ; if (reg%Tr(m)%registry_diags) then
384  tr => reg%Tr(m)
385 ! call query_vardesc(Tr%vd, name, units=units, longname=longname, &
386 ! cmor_field_name=cmorname, cmor_longname=cmor_longname, &
387 ! caller="register_tracer_diagnostics")
388  name = tr%name ; units=adjustl(tr%units) ; longname = tr%longname
389  cmorname = tr%cmor_name ; cmor_longname = tr%cmor_longname
390  shortnm = tr%flux_nameroot
391  flux_longname = tr%flux_longname
392  if (len_trim(cmor_longname) == 0) cmor_longname = longname
393 
394  if (len_trim(tr%flux_units) > 0) then ; flux_units = tr%flux_units
395  elseif (gv%Boussinesq) then ; flux_units = trim(units)//" m3 s-1"
396  else ; flux_units = trim(units)//" kg s-1" ; endif
397 
398  if (len_trim(tr%conv_units) > 0) then ; conv_units = tr%conv_units
399  elseif (gv%Boussinesq) then ; conv_units = trim(units)//" m s-1"
400  else ; conv_units = trim(units)//" kg m-2 s-1" ; endif
401 
402  if (len_trim(cmorname) == 0) then
403  tr%id_tr = register_diag_field("ocean_model", trim(name), diag%axesTL, &
404  time, trim(longname), trim(units))
405  else
406  tr%id_tr = register_diag_field("ocean_model", trim(name), diag%axesTL, &
407  time, trim(longname), trim(units), cmor_field_name=cmorname, &
408  cmor_long_name=cmor_longname, cmor_units=tr%cmor_units, &
409  cmor_standard_name=cmor_long_std(cmor_longname))
410  endif
411  tr%id_tr_post_horzn = register_diag_field("ocean_model", &
412  trim(name)//"_post_horzn", diag%axesTL, time, &
413  trim(longname)//" after horizontal transport (advection/diffusion) "//&
414  "has occurred", trim(units))
415  if (tr%diag_form == 1) then
416  tr%id_adx = register_diag_field("ocean_model", trim(shortnm)//"_adx", &
417  diag%axesCuL, time, trim(flux_longname)//" advective zonal flux" , &
418  trim(flux_units), v_extensive = .true., y_cell_method = 'sum', &
419  conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T)
420  tr%id_ady = register_diag_field("ocean_model", trim(shortnm)//"_ady", &
421  diag%axesCvL, time, trim(flux_longname)//" advective meridional flux" , &
422  trim(flux_units), v_extensive = .true., x_cell_method = 'sum', &
423  conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T)
424  tr%id_dfx = register_diag_field("ocean_model", trim(shortnm)//"_dfx", &
425  diag%axesCuL, time, trim(flux_longname)//" diffusive zonal flux" , &
426  trim(flux_units), v_extensive = .true., y_cell_method = 'sum', &
427  conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
428  tr%id_dfy = register_diag_field("ocean_model", trim(shortnm)//"_dfy", &
429  diag%axesCvL, time, trim(flux_longname)//" diffusive zonal flux" , &
430  trim(flux_units), v_extensive = .true., x_cell_method = 'sum', &
431  conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
432  tr%id_lbd_dfx = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffx", &
433  diag%axesCuL, time, trim(flux_longname)//" diffusive zonal flux from the lateral boundary diffusion "//&
434  "scheme", trim(flux_units), v_extensive = .true., y_cell_method = 'sum', &
435  conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
436  tr%id_lbd_dfy = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffy", &
437  diag%axesCvL, time, trim(flux_longname)//" diffusive meridional flux from the lateral boundary diffusion "//&
438  "scheme", trim(flux_units), v_extensive = .true., x_cell_method = 'sum', &
439  conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T)
440  else
441  tr%id_adx = register_diag_field("ocean_model", trim(shortnm)//"_adx", &
442  diag%axesCuL, time, "Advective (by residual mean) Zonal Flux of "//trim(flux_longname), &
443  flux_units, v_extensive=.true., conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, y_cell_method = 'sum')
444  tr%id_ady = register_diag_field("ocean_model", trim(shortnm)//"_ady", &
445  diag%axesCvL, time, "Advective (by residual mean) Meridional Flux of "//trim(flux_longname), &
446  flux_units, v_extensive=.true., conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, x_cell_method = 'sum')
447  tr%id_dfx = register_diag_field("ocean_model", trim(shortnm)//"_diffx", &
448  diag%axesCuL, time, "Diffusive Zonal Flux of "//trim(flux_longname), &
449  flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
450  y_cell_method='sum')
451  tr%id_dfy = register_diag_field("ocean_model", trim(shortnm)//"_diffy", &
452  diag%axesCvL, time, "Diffusive Meridional Flux of "//trim(flux_longname), &
453  flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
454  x_cell_method='sum')
455  tr%id_lbd_dfx = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffx", &
456  diag%axesCuL, time, "Lateral Boundary Diffusive Zonal Flux of "//trim(flux_longname), &
457  flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
458  y_cell_method='sum')
459  tr%id_lbd_dfy = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffy", &
460  diag%axesCvL, time, "Lateral Boundary Diffusive Meridional Flux of "//trim(flux_longname), &
461  flux_units, v_extensive=.true., conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
462  x_cell_method='sum')
463  endif
464  if (tr%id_adx > 0) call safe_alloc_ptr(tr%ad_x,isdb,iedb,jsd,jed,nz)
465  if (tr%id_ady > 0) call safe_alloc_ptr(tr%ad_y,isd,ied,jsdb,jedb,nz)
466  if (tr%id_dfx > 0) call safe_alloc_ptr(tr%df_x,isdb,iedb,jsd,jed,nz)
467  if (tr%id_dfy > 0) call safe_alloc_ptr(tr%df_y,isd,ied,jsdb,jedb,nz)
468  if (tr%id_lbd_dfx > 0) call safe_alloc_ptr(tr%lbd_dfx,isdb,iedb,jsd,jed,nz)
469  if (tr%id_lbd_dfy > 0) call safe_alloc_ptr(tr%lbd_dfy,isd,ied,jsdb,jedb,nz)
470 
471  tr%id_adx_2d = register_diag_field("ocean_model", trim(shortnm)//"_adx_2d", &
472  diag%axesCu1, time, &
473  "Vertically Integrated Advective Zonal Flux of "//trim(flux_longname), &
474  flux_units, conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, y_cell_method = 'sum')
475  tr%id_ady_2d = register_diag_field("ocean_model", trim(shortnm)//"_ady_2d", &
476  diag%axesCv1, time, &
477  "Vertically Integrated Advective Meridional Flux of "//trim(flux_longname), &
478  flux_units, conversion=tr%flux_scale*(us%L_to_m**2)*us%s_to_T, x_cell_method = 'sum')
479  tr%id_dfx_2d = register_diag_field("ocean_model", trim(shortnm)//"_diffx_2d", &
480  diag%axesCu1, time, &
481  "Vertically Integrated Diffusive Zonal Flux of "//trim(flux_longname), &
482  flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
483  y_cell_method='sum')
484  tr%id_dfy_2d = register_diag_field("ocean_model", trim(shortnm)//"_diffy_2d", &
485  diag%axesCv1, time, &
486  "Vertically Integrated Diffusive Meridional Flux of "//trim(flux_longname), &
487  flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
488  x_cell_method='sum')
489  tr%id_lbd_bulk_dfx = register_diag_field("ocean_model", trim(shortnm)//"_lbd_bulk_diffx", &
490  diag%axesCu1, time, &
491  "Total Bulk Diffusive Zonal Flux of "//trim(flux_longname), &
492  flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
493  y_cell_method='sum')
494  tr%id_lbd_bulk_dfy = register_diag_field("ocean_model", trim(shortnm)//"_lbd_bulk_diffy", &
495  diag%axesCv1, time, &
496  "Total Bulk Diffusive Meridional Flux of "//trim(flux_longname), &
497  flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
498  x_cell_method='sum')
499  tr%id_lbd_dfx_2d = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffx_2d", &
500  diag%axesCu1, time, "Vertically-integrated zonal diffusive flux from the lateral boundary diffusion "//&
501  "scheme for "//trim(flux_longname), flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
502  y_cell_method = 'sum')
503  tr%id_lbd_dfy_2d = register_diag_field("ocean_model", trim(shortnm)//"_lbd_diffy_2d", &
504  diag%axesCv1, time, "Vertically-integrated meridional diffusive flux from the lateral boundary diffusion "//&
505  "scheme for "//trim(flux_longname), flux_units, conversion=(us%L_to_m**2)*tr%flux_scale*us%s_to_T, &
506  x_cell_method = 'sum')
507 
508  if (tr%id_adx_2d > 0) call safe_alloc_ptr(tr%ad2d_x,isdb,iedb,jsd,jed)
509  if (tr%id_ady_2d > 0) call safe_alloc_ptr(tr%ad2d_y,isd,ied,jsdb,jedb)
510  if (tr%id_dfx_2d > 0) call safe_alloc_ptr(tr%df2d_x,isdb,iedb,jsd,jed)
511  if (tr%id_dfy_2d > 0) call safe_alloc_ptr(tr%df2d_y,isd,ied,jsdb,jedb)
512  if (tr%id_lbd_bulk_dfx > 0) call safe_alloc_ptr(tr%lbd_bulk_df_x,isdb,iedb,jsd,jed)
513  if (tr%id_lbd_bulk_dfy > 0) call safe_alloc_ptr(tr%lbd_bulk_df_y,isd,ied,jsdb,jedb)
514  if (tr%id_lbd_dfx_2d > 0) call safe_alloc_ptr(tr%lbd_dfx_2d,isdb,iedb,jsd,jed)
515  if (tr%id_lbd_dfy_2d > 0) call safe_alloc_ptr(tr%lbd_dfy_2d,isd,ied,jsdb,jedb)
516 
517  tr%id_adv_xy = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy", &
518  diag%axesTL, time, &
519  'Horizontal convergence of residual mean advective fluxes of '//&
520  trim(lowercase(flux_longname)), conv_units, v_extensive=.true., &
521  conversion=tr%conv_scale*us%s_to_T)
522  tr%id_adv_xy_2d = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy_2d", &
523  diag%axesT1, time, &
524  'Vertical sum of horizontal convergence of residual mean advective fluxes of '//&
525  trim(lowercase(flux_longname)), conv_units, conversion=tr%conv_scale*us%s_to_T)
526  if ((tr%id_adv_xy > 0) .or. (tr%id_adv_xy_2d > 0)) &
527  call safe_alloc_ptr(tr%advection_xy,isd,ied,jsd,jed,nz)
528 
529  tr%id_tendency = register_diag_field('ocean_model', trim(shortnm)//'_tendency', &
530  diag%axesTL, time, &
531  'Net time tendency for '//trim(lowercase(longname)), trim(units)//' s-1', conversion=us%s_to_T)
532 
533  if (tr%id_tendency > 0) then
534  call safe_alloc_ptr(tr%t_prev,isd,ied,jsd,jed,nz)
535  do k=1,nz ; do j=js,je ; do i=is,ie
536  tr%t_prev(i,j,k) = tr%t(i,j,k)
537  enddo ; enddo ; enddo
538  endif
539 
540  ! Neutral/Lateral diffusion convergence tendencies
541  if (tr%diag_form == 1) then
542  tr%id_dfxy_cont = register_diag_field("ocean_model", trim(shortnm)//'_dfxy_cont_tendency', &
543  diag%axesTL, time, "Neutral diffusion tracer content tendency for "//trim(shortnm), &
544  conv_units, conversion=tr%conv_scale*us%s_to_T, x_cell_method='sum', y_cell_method='sum', v_extensive=.true.)
545 
546  tr%id_dfxy_cont_2d = register_diag_field("ocean_model", trim(shortnm)//'_dfxy_cont_tendency_2d', &
547  diag%axesT1, time, "Depth integrated neutral diffusion tracer content "//&
548  "tendency for "//trim(shortnm), conv_units, conversion=tr%conv_scale*us%s_to_T, &
549  x_cell_method='sum', y_cell_method= 'sum')
550 
551  tr%id_lbdxy_cont = register_diag_field("ocean_model", trim(shortnm)//'_lbdxy_cont_tendency', &
552  diag%axesTL, time, "Lateral diffusion tracer content tendency for "//trim(shortnm), &
553  conv_units, conversion=tr%conv_scale*us%s_to_T, x_cell_method='sum', y_cell_method='sum', v_extensive=.true.)
554 
555  tr%id_lbdxy_cont_2d = register_diag_field("ocean_model", trim(shortnm)//'_lbdxy_cont_tendency_2d', &
556  diag%axesT1, time, "Depth integrated lateral diffusion tracer content "//&
557  "tendency for "//trim(shortnm), conv_units, conversion=tr%conv_scale*us%s_to_T, &
558  x_cell_method='sum', y_cell_method= 'sum')
559  else
560  cmor_var_lname = 'Tendency of '//trim(lowercase(cmor_longname))//&
561  ' expressed as '//trim(lowercase(flux_longname))//&
562  ' content due to parameterized mesoscale neutral diffusion'
563  tr%id_dfxy_cont = register_diag_field("ocean_model", trim(shortnm)//'_dfxy_cont_tendency', &
564  diag%axesTL, time, "Neutral diffusion tracer content tendency for "//trim(shortnm), &
565  conv_units, conversion=tr%conv_scale*us%s_to_T, cmor_field_name = trim(tr%cmor_tendprefix)//'pmdiff', &
566  cmor_long_name = trim(cmor_var_lname), cmor_standard_name = trim(cmor_long_std(cmor_var_lname)), &
567  x_cell_method = 'sum', y_cell_method = 'sum', v_extensive = .true.)
568 
569  cmor_var_lname = 'Tendency of '//trim(lowercase(cmor_longname))//' expressed as '//&
570  trim(lowercase(flux_longname))//' content due to parameterized mesoscale neutral diffusion'
571  tr%id_dfxy_cont_2d = register_diag_field("ocean_model", trim(shortnm)//'_dfxy_cont_tendency_2d', &
572  diag%axesT1, time, "Depth integrated neutral diffusion tracer "//&
573  "content tendency for "//trim(shortnm), conv_units, &
574  conversion=tr%conv_scale*us%s_to_T, cmor_field_name=trim(tr%cmor_tendprefix)//'pmdiff_2d', &
575  cmor_long_name=trim(cmor_var_lname), cmor_standard_name=trim(cmor_long_std(cmor_var_lname)), &
576  x_cell_method='sum', y_cell_method='sum')
577 
578  tr%id_lbdxy_cont = register_diag_field("ocean_model", trim(shortnm)//'_lbdxy_cont_tendency', &
579  diag%axesTL, time, "Lateral diffusion tracer content tendency for "//trim(shortnm), &
580  conv_units, conversion=tr%conv_scale*us%s_to_T, &
581  x_cell_method = 'sum', y_cell_method = 'sum', v_extensive = .true.)
582 
583  tr%id_lbdxy_cont_2d = register_diag_field("ocean_model", trim(shortnm)//'_lbdxy_cont_tendency_2d', &
584  diag%axesT1, time, "Depth integrated lateral diffusion tracer "//&
585  "content tendency for "//trim(shortnm), conv_units, &
586  conversion=tr%conv_scale*us%s_to_T, x_cell_method='sum', y_cell_method='sum')
587  endif
588  tr%id_dfxy_conc = register_diag_field("ocean_model", trim(shortnm)//'_dfxy_conc_tendency', &
589  diag%axesTL, time, "Neutral diffusion tracer concentration tendency for "//trim(shortnm), &
590  trim(units)//' s-1', conversion=us%s_to_T)
591 
592  tr%id_lbdxy_conc = register_diag_field("ocean_model", trim(shortnm)//'_lbdxy_conc_tendency', &
593  diag%axesTL, time, "Lateral diffusion tracer concentration tendency for "//trim(shortnm), &
594  trim(units)//' s-1', conversion=us%s_to_T)
595 
596  var_lname = "Net time tendency for "//lowercase(flux_longname)
597  if (len_trim(tr%cmor_tendprefix) == 0) then
598  tr%id_trxh_tendency = register_diag_field('ocean_model', trim(shortnm)//'h_tendency', &
599  diag%axesTL, time, var_lname, conv_units, v_extensive=.true., &
600  conversion=tr%conv_scale*us%s_to_T)
601  tr%id_trxh_tendency_2d = register_diag_field('ocean_model', trim(shortnm)//'h_tendency_2d', &
602  diag%axesT1, time, "Vertical sum of "//trim(lowercase(var_lname)), conv_units, &
603  conversion=tr%conv_scale*us%s_to_T)
604  else
605  cmor_var_lname = "Tendency of "//trim(cmor_longname)//" Expressed as "//&
606  trim(flux_longname)//" Content"
607  tr%id_trxh_tendency = register_diag_field('ocean_model', trim(shortnm)//'h_tendency', &
608  diag%axesTL, time, var_lname, conv_units, &
609  cmor_field_name=trim(tr%cmor_tendprefix)//"tend", &
610  cmor_standard_name=cmor_long_std(cmor_var_lname), cmor_long_name=cmor_var_lname, &
611  v_extensive=.true., conversion=tr%conv_scale*us%s_to_T)
612  cmor_var_lname = trim(cmor_var_lname)//" Vertical Sum"
613  tr%id_trxh_tendency_2d = register_diag_field('ocean_model', trim(shortnm)//'h_tendency_2d', &
614  diag%axesT1, time, "Vertical sum of "//trim(lowercase(var_lname)), conv_units, &
615  cmor_field_name=trim(tr%cmor_tendprefix)//"tend_2d", &
616  cmor_standard_name=cmor_long_std(cmor_var_lname), cmor_long_name=cmor_var_lname, &
617  conversion=tr%conv_scale*us%s_to_T)
618  endif
619  if ((tr%id_trxh_tendency > 0) .or. (tr%id_trxh_tendency_2d > 0)) then
620  call safe_alloc_ptr(tr%Trxh_prev,isd,ied,jsd,jed,nz)
621  do k=1,nz ; do j=js,je ; do i=is,ie
622  tr%Trxh_prev(i,j,k) = tr%t(i,j,k) * h(i,j,k)
623  enddo ; enddo ; enddo
624  endif
625 
626  ! Vertical regridding/remapping tendencies
627  if (use_ale .and. tr%remap_tr) then
628  var_lname = "Vertical remapping tracer concentration tendency for "//trim(reg%Tr(m)%name)
629  tr%id_remap_conc= register_diag_field('ocean_model', &
630  trim(tr%flux_nameroot)//'_tendency_vert_remap', diag%axesTL, time, var_lname, &
631  trim(units)//' s-1', conversion=us%s_to_T)
632 
633  var_lname = "Vertical remapping tracer content tendency for "//trim(reg%Tr(m)%flux_longname)
634  tr%id_remap_cont = register_diag_field('ocean_model', &
635  trim(tr%flux_nameroot)//'h_tendency_vert_remap', &
636  diag%axesTL, time, var_lname, flux_units, v_extensive=.true., conversion=tr%conv_scale*us%s_to_T)
637 
638  var_lname = "Vertical sum of vertical remapping tracer content tendency for "//&
639  trim(reg%Tr(m)%flux_longname)
640  tr%id_remap_cont_2d = register_diag_field('ocean_model', &
641  trim(tr%flux_nameroot)//'h_tendency_vert_remap_2d', &
642  diag%axesT1, time, var_lname, flux_units, conversion=tr%conv_scale*us%s_to_T)
643 
644  endif
645 
646  if (use_ale .and. (reg%ntr<max_fields_) .and. tr%remap_tr) then
647  unit2 = trim(units)//"2"
648  if (index(units(1:len_trim(units))," ") > 0) unit2 = "("//trim(units)//")2"
649  tr%id_tr_vardec = register_diag_field('ocean_model', trim(shortnm)//"_vardec", diag%axesTL, &
650  time, "ALE variance decay for "//lowercase(longname), trim(unit2)//" s-1", conversion=us%s_to_T)
651  if (tr%id_tr_vardec > 0) then
652  ! Set up a new tracer for this tracer squared
653  m2 = reg%ntr+1
654  tr%ind_tr_squared = m2
655  call safe_alloc_ptr(reg%Tr(m2)%t,isd,ied,jsd,jed,nz) ; reg%Tr(m2)%t(:,:,:) = 0.0
656  reg%Tr(m2)%name = trim(shortnm)//"2"
657  reg%Tr(m2)%longname = "Squared "//trim(longname)
658  reg%Tr(m2)%units = unit2
659  reg%Tr(m2)%registry_diags = .false.
660  reg%Tr(m2)%ind_tr_squared = -1
661  ! Augment the total number of tracers, including the squared tracers.
662  reg%ntr = reg%ntr + 1
663  endif
664  endif
665 
666  endif ; enddo
667 

◆ tracer_name_lookup()

subroutine, public mom_tracer_registry::tracer_name_lookup ( type(tracer_registry_type), pointer  Reg,
type(tracer_type), pointer  tr_ptr,
character(len=32), intent(in)  name 
)

Find a tracer in the tracer registry by name.

Parameters
regpointer to tracer registry
tr_ptrtarget or pointer to the tracer array
[in]nametracer name

Definition at line 849 of file MOM_tracer_registry.F90.

850  type(tracer_registry_type), pointer :: Reg !< pointer to tracer registry
851  type(tracer_type), pointer :: tr_ptr !< target or pointer to the tracer array
852  character(len=32), intent(in) :: name !< tracer name
853 
854  integer n
855  do n=1,reg%ntr
856  if (lowercase(reg%Tr(n)%name) == lowercase(name)) tr_ptr => reg%Tr(n)
857  enddo
858 

◆ tracer_registry_end()

subroutine, public mom_tracer_registry::tracer_registry_end ( type(tracer_registry_type), pointer  Reg)

This routine closes the tracer registry module.

Parameters
regThe tracer registry that will be deallocated

Definition at line 890 of file MOM_tracer_registry.F90.

891  type(tracer_registry_type), pointer :: Reg !< The tracer registry that will be deallocated
892  if (associated(reg)) deallocate(reg)

◆ tracer_registry_init()

subroutine, public mom_tracer_registry::tracer_registry_init ( type(param_file_type), intent(in)  param_file,
type(tracer_registry_type), pointer  Reg 
)

Initialize the tracer registry.

Parameters
[in]param_fileopen file to parse for model parameters
regpointer to tracer registry

Definition at line 862 of file MOM_tracer_registry.F90.

863  type(param_file_type), intent(in) :: param_file !< open file to parse for model parameters
864  type(tracer_registry_type), pointer :: Reg !< pointer to tracer registry
865 
866  integer, save :: init_calls = 0
867 
868 ! This include declares and sets the variable "version".
869 #include "version_variable.h"
870  character(len=40) :: mdl = "MOM_tracer_registry" ! This module's name.
871  character(len=256) :: mesg ! Message for error messages.
872 
873  if (.not.associated(reg)) then ; allocate(reg)
874  else ; return ; endif
875 
876  ! Read all relevant parameters and write them to the model log.
877  call log_version(param_file, mdl, version, "", all_default=.true.)
878 
879  init_calls = init_calls + 1
880  if (init_calls > 1) then
881  write(mesg,'("tracer_registry_init called ",I3, &
882  &" times with different registry pointers.")') init_calls
883  if (is_root_pe()) call mom_error(warning,"MOM_tracer"//mesg)
884  endif
885 
mom_coms::reproducing_sum
Find an accurate and order-invariant sum of a distributed 2d or 3d field.
Definition: MOM_coms.F90:53