diff --git a/src/core/MOM_CoriolisAdv.F90 b/src/core/MOM_CoriolisAdv.F90
index fd015b3262..c32352acb1 100644
--- a/src/core/MOM_CoriolisAdv.F90
+++ b/src/core/MOM_CoriolisAdv.F90
@@ -224,6 +224,27 @@ subroutine CorAdCalc(u, v, h, uh, vh, CAu, CAv, OBC, AD, G, GV, CS)
do j=Jsq-1,Jeq+2 ; do I=Isq-1,Ieq+2
Area_h(i,j) = G%mask2dT(i,j) * G%areaT(i,j)
enddo ; enddo
+ if (associated(OBC)) then ; do n=1,OBC%number_of_segments
+ if (.not. OBC%segment(n)%on_pe) cycle
+ I = OBC%segment(n)%HI%IsdB ; J = OBC%segment(n)%HI%JsdB
+ if (OBC%segment(n)%is_N_or_S .and. (J >= Jsq-1) .and. (J <= Jeq+1)) then
+ do i = max(Isq-1,OBC%segment(n)%HI%isd), min(Ieq+2,OBC%segment(n)%HI%ied)
+ if (OBC%segment(n)%direction == OBC_DIRECTION_N) then
+ Area_h(i,j+1) = Area_h(i,j)
+ else ! (OBC%segment(n)%direction == OBC_DIRECTION_S)
+ Area_h(i,j) = Area_h(i,j+1)
+ endif
+ enddo
+ elseif (OBC%segment(n)%is_E_or_W .and. (I >= Isq-1) .and. (I <= Ieq+1)) then
+ do j = max(Jsq-1,OBC%segment(n)%HI%jsd), min(Jeq+2,OBC%segment(n)%HI%jed)
+ if (OBC%segment(n)%direction == OBC_DIRECTION_E) then
+ Area_h(i+1,j) = Area_h(i,j)
+ else ! (OBC%segment(n)%direction == OBC_DIRECTION_W)
+ Area_h(i,j) = Area_h(i+1,j)
+ endif
+ enddo
+ endif
+ enddo ; endif
!$OMP parallel do default(private) shared(Isq,Ieq,Jsq,Jeq,G,Area_h,Area_q)
do J=Jsq-1,Jeq+1 ; do I=Isq-1,Ieq+1
Area_q(i,j) = (Area_h(i,j) + Area_h(i+1,j+1)) + &
diff --git a/src/core/MOM_open_boundary.F90 b/src/core/MOM_open_boundary.F90
index 9f06838d4d..153b901a42 100644
--- a/src/core/MOM_open_boundary.F90
+++ b/src/core/MOM_open_boundary.F90
@@ -1116,7 +1116,7 @@ end subroutine open_boundary_impose_normal_slope
!! Also adjust u- and v-point cell area on specified open boundaries.
subroutine open_boundary_impose_land_mask(OBC, G, areaCu, areaCv)
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
- type(dyn_horgrid_type), intent(in) :: G !< Ocean grid structure
+ type(dyn_horgrid_type), intent(inout) :: G !< Ocean grid structure
real, dimension(SZIB_(G),SZJ_(G)), intent(inout) :: areaCu !< Area of a u-cell (m2)
real, dimension(SZI_(G),SZJB_(G)), intent(inout) :: areaCv !< Area of a u-cell (m2)
! Local variables
@@ -1134,12 +1134,22 @@ subroutine open_boundary_impose_land_mask(OBC, G, areaCu, areaCv)
I=segment%HI%IsdB
do j=segment%HI%jsd,segment%HI%jed
if (G%mask2dCu(I,j) == 0) OBC%segnum_u(I,j) = OBC_NONE
+ if (segment%direction == OBC_DIRECTION_W) then
+ G%mask2dT(i,j) = 0
+ else
+ G%mask2dT(i+1,j) = 0
+ endif
enddo
else
! Sweep along v-segments and delete the OBC for blocked points.
J=segment%HI%JsdB
do i=segment%HI%isd,segment%HI%ied
if (G%mask2dCv(i,J) == 0) OBC%segnum_v(i,J) = OBC_NONE
+ if (segment%direction == OBC_DIRECTION_S) then
+ G%mask2dT(i,j) = 0
+ else
+ G%mask2dT(i,j+1) = 0
+ endif
enddo
endif
enddo
@@ -1633,32 +1643,32 @@ subroutine set_tracer_data(OBC, tv, h, G, PF, tracer_Reg)
enddo
endif
- do n=1,OBC%number_of_segments
- segment => OBC%segment(n)
- if (.not. segment%on_pe) cycle
-
- if (segment%direction == OBC_DIRECTION_E) then
- I=segment%HI%IsdB
- do k=1,G%ke ; do j=segment%HI%jsd,segment%HI%jed
- h(i+1,j,k) = h(i,j,k)
- enddo; enddo
- elseif (segment%direction == OBC_DIRECTION_W) then
- I=segment%HI%IsdB
- do k=1,G%ke ; do j=segment%HI%jsd,segment%HI%jed
- h(i,j,k) = h(i+1,j,k)
- enddo; enddo
- elseif (segment%direction == OBC_DIRECTION_N) then
- J=segment%HI%JsdB
- do k=1,G%ke ; do i=segment%HI%isd,segment%HI%ied
- h(i,j+1,k) = h(i,j,k)
- enddo; enddo
- elseif (segment%direction == OBC_DIRECTION_S) then
- J=segment%HI%JsdB
- do k=1,G%ke ; do i=segment%HI%isd,segment%HI%ied
- h(i,j,k) = h(i,j+1,k)
- enddo; enddo
- endif
- enddo
+! do n=1,OBC%number_of_segments
+! segment => OBC%segment(n)
+! if (.not. segment%on_pe) cycle
+
+! if (segment%direction == OBC_DIRECTION_E) then
+! I=segment%HI%IsdB
+! do k=1,G%ke ; do j=segment%HI%jsd,segment%HI%jed
+! h(i+1,j,k) = h(i,j,k)
+! enddo; enddo
+! elseif (segment%direction == OBC_DIRECTION_W) then
+! I=segment%HI%IsdB
+! do k=1,G%ke ; do j=segment%HI%jsd,segment%HI%jed
+! h(i,j,k) = h(i+1,j,k)
+! enddo; enddo
+! elseif (segment%direction == OBC_DIRECTION_N) then
+! J=segment%HI%JsdB
+! do k=1,G%ke ; do i=segment%HI%isd,segment%HI%ied
+! h(i,j+1,k) = h(i,j,k)
+! enddo; enddo
+! elseif (segment%direction == OBC_DIRECTION_S) then
+! J=segment%HI%JsdB
+! do k=1,G%ke ; do i=segment%HI%isd,segment%HI%ied
+! h(i,j,k) = h(i,j+1,k)
+! enddo; enddo
+! endif
+! enddo
end subroutine set_tracer_data
diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90
index 3d77e1a0c4..696f612e28 100644
--- a/src/initialization/MOM_state_initialization.F90
+++ b/src/initialization/MOM_state_initialization.F90
@@ -1629,9 +1629,10 @@ subroutine initialize_sponges_file(G, GV, use_temperature, tv, param_file, CSp,
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters.
type(sponge_CS), pointer :: CSp !< A pointer that is set to point to the control
!! structure for this module (in layered mode).
- type(ALE_sponge_CS), pointer :: ALE_CSp !< A pointer that is set to point to the control
- !! structure for this module (in ALE mode).
- type(time_type), intent(in) :: Time
+ type(ALE_sponge_CS), pointer :: ALE_CSp !< A pointer that is set to point to the control
+ !! structure for this module (in ALE mode).
+ type(time_type), intent(in) :: Time !< Time at the start of the run segment. Time_in
+ !! overrides any value set for Time.
! Local variables
real, allocatable, dimension(:,:,:) :: eta ! The target interface heights, in m.
diff --git a/src/tracer/MOM_generic_tracer.F90 b/src/tracer/MOM_generic_tracer.F90
index 891f29dbbd..d905f3f307 100644
--- a/src/tracer/MOM_generic_tracer.F90
+++ b/src/tracer/MOM_generic_tracer.F90
@@ -2,18 +2,6 @@ module MOM_generic_tracer
! This file is part of MOM6. See LICENSE.md for the license.
-!----------------------------------------------------------------
-! Niki Zadeh
-!
-!
-! William Cooke
-!
-!
-!
-! This module drives the generic version of tracers TOPAZ and CFC
-!
-!----------------------------------------------------------------
-
#include
#ifdef _USE_GENERIC_TRACER
@@ -99,41 +87,20 @@ module MOM_generic_tracer
contains
- !
- !
- ! Initialize phase I: Add the generic tracers
- !
- !
- ! This subroutine:
- ! Initializes the generic tracer packages and adds their tracers to the list
- ! Adds the tracers in the list of generic tracers to the set of MOM tracers (i.e., MOM-register them)
- ! Register these tracers for restart
- !
- !
- ! call register_MOM_generic_tracer(G, param_file, CS, diag, tr_Reg, restart_CS)
- !
- !
-
+ !> Initializes the generic tracer packages and adds their tracers to the list
+ !! Adds the tracers in the list of generic tracers to the set of MOM tracers (i.e., MOM-register them)
+ !! Register these tracers for restart
function register_MOM_generic_tracer(HI, GV, param_file, CS, tr_Reg, restart_CS)
- type(hor_index_type), intent(in) :: HI
- type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
+ type(hor_index_type), intent(in) :: HI !< Horizontal index ranges
+ type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters
- type(MOM_generic_tracer_CS), pointer :: CS
- type(tracer_registry_type), pointer :: tr_Reg
- type(MOM_restart_CS), pointer :: restart_CS
- ! This subroutine is used to register tracer fields and subroutines
- ! to be used with MOM.
- ! Arguments: G - The ocean's grid structure.
- ! (in) param_file - A structure indicating the open file to parse for
- ! model parameter values.
- ! (in/out) CS - A pointer that is set to point to the control structure
- ! for this module
- ! (in) diag - A structure that is used to regulate diagnostic output.
- ! (in/out) tr_Reg - A pointer that is set to point to the control structure
- ! for the tracer advection and diffusion module.
- ! (in) restart_CS - A pointer to the restart control structure.
- logical :: register_MOM_generic_tracer
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module
+ type(tracer_registry_type), pointer :: tr_Reg !< Pointer to the control structure for the tracer
+ !! advection and diffusion module.
+ type(MOM_restart_CS), pointer :: restart_CS !< Pointer to the restart control structure.
+! Local variables
+ logical :: register_MOM_generic_tracer
character(len=fm_string_len), parameter :: sub_name = 'register_MOM_generic_tracer'
character(len=200) :: inputdir ! The directory where NetCDF input files are.
@@ -254,53 +221,33 @@ function register_MOM_generic_tracer(HI, GV, param_file, CS, tr_Reg, restart_CS)
register_MOM_generic_tracer = .true.
end function register_MOM_generic_tracer
- !
- !
- ! Initialize phase II: Initialize required variables for generic tracers
- !
- !
- ! There are some steps of initialization that cannot be done in register_MOM_generic_tracer
- ! This is the place and time to do them:
- ! Set the grid mask and initial time for all generic tracers.
- ! Diag_register them.
- ! Z_diag_register them.
- !
- !
- ! call initialize_MOM_generic_tracer(restart, day, G, h, OBC, CS, sponge_CSp,ALE_sponge_CSp, diag_to_Z_CSp)
- !
+ !> Initialize phase II: Initialize required variables for generic tracers
+ !! There are some steps of initialization that cannot be done in register_MOM_generic_tracer
+ !! This is the place and time to do them:
+ !! Set the grid mask and initial time for all generic tracers.
+ !! Diag_register them.
+ !! Z_diag_register them.
+ !!
+ !! This subroutine initializes the NTR tracer fields in tr(:,:,:,:)
+ !! and it sets up the tracer output.
subroutine initialize_MOM_generic_tracer(restart, day, G, GV, h, param_file, diag, OBC, CS, &
sponge_CSp, ALE_sponge_CSp,diag_to_Z_CSp)
- logical, intent(in) :: restart
- type(time_type), target, intent(in) :: day
+ logical, intent(in) :: restart !< .true. if the fields have already been
+ !! read from a restart file.
+ type(time_type), target, intent(in) :: day !< Time of the start of the run.
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thicknesses, in H (usually m or kg m-2)
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters
- type(diag_ctrl), target, intent(in) :: diag
- type(ocean_OBC_type), pointer :: OBC
- type(MOM_generic_tracer_CS), pointer :: CS
- type(sponge_CS), pointer :: sponge_CSp
- type(ALE_sponge_CS), pointer :: ALE_sponge_CSp
- type(diag_to_Z_CS), pointer :: diag_to_Z_CSp
- ! This subroutine initializes the NTR tracer fields in tr(:,:,:,:)
- ! and it sets up the tracer output.
-
- ! Arguments: restart - .true. if the fields have already been read from
- ! a restart file.
- ! (in) day - Time of the start of the run.
- ! (in) G - The ocean's grid structure.
- ! (in) GV - The ocean's vertical grid structure.
- ! (in) h - Layer thickness, in m or kg m-2.
- ! (in) OBC - This open boundary condition type specifies whether, where,
- ! and what open boundary conditions are used.
- ! (in/out) CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
- ! (in/out) sponge_CSp - A pointer to the control structure for the sponges, if
- ! they are in use. Otherwise this may be unassociated.
- ! (in/out) ALE_sponge_CSp - A pointer to the control structure for the ALE
- ! sponges, if they are in use. Otherwise this may be unassociated
- ! (in/out) diag_to_Z_Csp - A pointer to the control structure for diagnostics
- ! in depth space.
+ type(diag_ctrl), target, intent(in) :: diag !< Regulates diagnostic output.
+ type(ocean_OBC_type), pointer :: OBC !< This open boundary condition type specifies whether,
+ !! where, and what open boundary conditions are used.
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
+ type(sponge_CS), pointer :: sponge_CSp !< Pointer to the control structure for the sponges.
+ type(ALE_sponge_CS), pointer :: ALE_sponge_CSp !< Pointer to the control structure for the
+ !! ALE sponges.
+ type(diag_to_Z_CS), pointer :: diag_to_Z_CSp !< A pointer to the control structure for diagnostics
+ !! in depth space.
character(len=fm_string_len), parameter :: sub_name = 'initialize_MOM_generic_tracer'
logical :: OK
@@ -480,62 +427,44 @@ subroutine initialize_MOM_generic_tracer(restart, day, G, GV, h, param_file, dia
end subroutine initialize_MOM_generic_tracer
- !
- !
- ! Column physics for generic tracers.
- !
- !
- ! This subroutine does:
- ! Get the coupler values for generic tracers that exchange with atmosphere
- ! Update generic tracer concentration fields from sources and sinks.
- ! Vertically diffuse generic tracer concentration fields.
- ! Update generic tracers from bottom and their bottom reservoir.
- !
- !
- ! call MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, CS, tv, optics)
- !
- !
-
+ !> Column physics for generic tracers.
+ !! Get the coupler values for generic tracers that exchange with atmosphere
+ !! Update generic tracer concentration fields from sources and sinks.
+ !! Vertically diffuse generic tracer concentration fields.
+ !! Update generic tracers from bottom and their bottom reservoir.
+ !!
+ !! This subroutine applies diapycnal diffusion and any other column
+ !! tracer physics or chemistry to the tracers from this file.
+ !! CFCs are relatively simple, as they are passive tracers. with only a surface
+ !! flux as a source.
subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV, CS, tv, optics, &
evap_CFL_limit, minimum_forcing_depth)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
- real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h_old, h_new, ea, eb
+ real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h_old !< Layer thickness before entrainment,
+ !! in m or kg !m-2.
+ real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h_new !< Layer thickness after entrainment,
+ !! in m or kg !m-2.
+ real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: ea !< an array to which the amount of
+ !! fluid entrained from the layer !above during this
+ !! call will be added, in m or kg !m-2.
+ real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: eb !< an array to which the amount of
+ !! fluid entrained from the layer !below during this
+ !! call will be added, in m or kg !m-2.
type(forcing), intent(in) :: fluxes
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: Hml !< Mixed layer depth
real, intent(in) :: dt !< The amount of time covered by this call, in s
- type(MOM_generic_tracer_CS), pointer :: CS
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
type(optics_type), intent(in) :: optics
- real, optional,intent(in) :: evap_CFL_limit
- real, optional,intent(in) :: minimum_forcing_depth
- ! This subroutine applies diapycnal diffusion and any other column
- ! tracer physics or chemistry to the tracers from this file.
- ! CFCs are relatively simple, as they are passive tracers. with only a surface
- ! flux as a source.
-
- ! Arguments: h_old - Layer thickness before entrainment, in m or kg m-2.
- ! (in) h_new - Layer thickness after entrainment, in m or kg m-2.
- ! (in) ea - an array to which the amount of fluid entrained
- ! from the layer above during this call will be
- ! added, in m or kg m-2.
- ! (in) eb - an array to which the amount of fluid entrained
- ! from the layer below during this call will be
- ! added, in m or kg m-2.
- ! (in) fluxes - A structure containing pointers to any possible
- ! forcing fields. Unused fields have NULL ptrs.
- ! (in) dt - The amount of time covered by this call, in s.
- ! (in) G - The ocean's grid structure.
- ! (in) GV - The ocean's vertical grid structure.
- ! (in) CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
- ! (in) evap_CFL_limit - Limits how much water can be fluxed out of the top layer
- ! Stored previously in diabatic CS.
- ! (in) minimum_forcing_depth - The smallest depth over which fluxes can be applied
- ! Stored previously in diabatic CS.
- !
+ real, optional,intent(in) :: evap_CFL_limit !< Limits how much water can be fluxed out of
+ !! the top layer Stored previously in diabatic CS.
+ real, optional,intent(in) :: minimum_forcing_depth !< The smallest depth over which fluxes
+ !! can be applied Stored previously in diabatic CS.
! The arguments to this subroutine are redundant in that
! h_new[k] = h_old[k] + ea[k] - eb[k-1] + eb[k] - ea[k+1]
+
+! Local variables
character(len=fm_string_len), parameter :: sub_name = 'MOM_generic_tracer_column_physics'
type(g_tracer_type), pointer :: g_tracer, g_tracer_next
@@ -660,46 +589,26 @@ subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml,
end subroutine MOM_generic_tracer_column_physics
- !
- !
- ! Calculate the mass-weighted integral of tracer concentrations.
- !
- !
- ! This subroutine calculates mass-weighted integral on the PE either
- ! of all available tracer concentrations, or of a tracer that is
- ! being requested specifically, returning the number of stocks it has
- ! calculated.
- !
- !
- ! ns = MOM_generic_tracer_stock(h, stocks, G, CS, names, units, stock_index)
- !
- !
-
+ !> This subroutine calculates mass-weighted integral on the PE either
+ !! of all available tracer concentrations, or of a tracer that is
+ !! being requested specifically, returning the number of stocks it has
+ !! calculated. If the stock_index is present, only the stock corresponding
+ !! to that coded index is returned.
function MOM_generic_tracer_stock(h, stocks, G, GV, CS, names, units, stock_index)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
- real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thicknesses, in H (usually m or kg m-2)
- real, dimension(:), intent(out) :: stocks
- type(MOM_generic_tracer_CS), pointer :: CS
- character(len=*), dimension(:), intent(out) :: names
- character(len=*), dimension(:), intent(out) :: units
- integer, optional, intent(in) :: stock_index
- integer :: MOM_generic_tracer_stock
- ! This function calculates the mass-weighted integral of all tracer stocks,
- ! returning the number of stocks it has calculated. If the stock_index
- ! is present, only the stock corresponding to that coded index is returned.
-
- ! Arguments: h - Layer thickness, in m or kg m-2.
- ! (out) stocks - the mass-weighted integrated amount of each tracer,
- ! in kg times concentration units.
- ! (in) G - The ocean's grid structure.
- ! (in) GV - The ocean's vertical grid structure.
- ! (in) CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
- ! (out) names - the names of the stocks calculated.
- ! (out) units - the units of the stocks calculated.
- ! (in,opt) stock_index - the coded index of a specific stock being sought.
- ! Return value: the number of stocks calculated here.
+ real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thicknesses, in H (usually m or kg m-2)
+ real, dimension(:), intent(out) :: stocks !< The mass-weighted integrated amount of each
+ !! tracer, in kg times concentration units.
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
+ character(len=*), dimension(:), intent(out) :: names !< The names of the stocks calculated.
+ character(len=*), dimension(:), intent(out) :: units !< The units of the stocks calculated.
+ integer, optional, intent(in) :: stock_index !< The coded index of a specific stock
+ !! being sought.
+ integer :: MOM_generic_tracer_stock !< Return value, the
+ !! number of stocks calculated here.
+
+! Local variables
type(g_tracer_type), pointer :: g_tracer, g_tracer_next
real, dimension(:,:,:,:), pointer :: tr_field
real, dimension(:,:,:), pointer :: tr_ptr
@@ -746,46 +655,26 @@ function MOM_generic_tracer_stock(h, stocks, G, GV, CS, names, units, stock_inde
end function MOM_generic_tracer_stock
- !
- !
- ! Find the min and max of tracer concentrations.
- !
- !
- ! This subroutine find the global min and max of either
- ! of all available tracer concentrations, or of a tracer that is
- ! being requested specifically, returning the number of tracers it has gone through.
- !
- !
- ! ns = MOM_generic_tracer_min_max(do_minmax, gmin, gmax, igmin, jgmin, kgmin, igmax, jgmax, kgmax , G, CS, names, units)
- !
- !
-
+ !> This subroutine find the global min and max of either of all
+ !! available tracer concentrations, or of a tracer that is being
+ !! requested specifically, returning the number of tracers it has gone through.
function MOM_generic_tracer_min_max(ind_start, got_minmax, gmin, gmax, xgmin, ygmin, zgmin, xgmax, ygmax, zgmax , G, CS, names, units)
use mpp_utilities_mod, only: mpp_array_global_min_max
integer, intent(in) :: ind_start
logical, dimension(:), intent(out) :: got_minmax
- real, dimension(:), intent(out) :: gmin,gmax
+ real, dimension(:), intent(out) :: gmin !< Global minimum of each tracer, in kg
+ !! times concentration units.
+ real, dimension(:), intent(out) :: gmax !< Global maximum of each tracer, in kg
+ !! times concentration units.
real, dimension(:), intent(out) :: xgmin, ygmin, zgmin, xgmax, ygmax, zgmax
- type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
- type(MOM_generic_tracer_CS), pointer :: CS
- character(len=*), dimension(:), intent(out) :: names
- character(len=*), dimension(:), intent(out) :: units
- integer :: MOM_generic_tracer_min_max
- ! This function calculates the mass-weighted integral of all tracer stocks,
- ! returning the number of stocks it has calculated. If the stock_index
- ! is present, only the stock corresponding to that coded index is returned.
-
- ! Arguments: h - Layer thickness, in m or kg m-2.
- ! (out) gmin , gmax - the global minimum and maximum of each tracer,
- ! in kg times concentration units.
- ! (in) G - The ocean's grid structure.
- ! (in) CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
- ! (out) names - the names of the stocks calculated.
- ! (out) units - the units of the stocks calculated.
- ! (in,opt) trace_index - the coded index of a specific tracer being sought.
- ! Return value: the number of tracers done here.
-
+ type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
+ character(len=*), dimension(:), intent(out) :: names !< The names of the stocks calculated.
+ character(len=*), dimension(:), intent(out) :: units !< The units of the stocks calculated.
+ integer :: MOM_generic_tracer_min_max !< Return value, the
+ !! number of tracers done here.
+
+! Local variables
type(g_tracer_type), pointer :: g_tracer, g_tracer_next
real, dimension(:,:,:,:), pointer :: tr_field
real, dimension(:,:,:), pointer :: tr_ptr
@@ -844,33 +733,19 @@ function MOM_generic_tracer_min_max(ind_start, got_minmax, gmin, gmax, xgmin, yg
end function MOM_generic_tracer_min_max
- !
- !
- ! Calculate the surface state and set coupler values
- !
- !
- ! This subroutine calculates the surface state and set coupler values for
- ! those generic tracers that havd flux exchange with atmosphere.
- !
- !
- ! call MOM_generic_tracer_surface_state(state, h, G, CS)
- !
- !
-
+ !> This subroutine calculates the surface state and sets coupler values for
+ !! those generic tracers that have flux exchange with atmosphere.
+ !!
+ !! This subroutine sets up the fields that the coupler needs to calculate the
+ !! CFC fluxes between the ocean and atmosphere.
subroutine MOM_generic_tracer_surface_state(state, h, G, CS)
- type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
- type(surface), intent(inout) :: state
+ type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
+ type(surface), intent(inout) :: state !< A structure containing fields that
+ !! describe the surface state of the ocean.
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h !< Layer thicknesses, in H (usually m or kg m-2)
- type(MOM_generic_tracer_CS), pointer :: CS
- ! This subroutine sets up the fields that the coupler needs to calculate the
- ! CFC fluxes between the ocean and atmosphere.
- ! Arguments: state - A structure containing fields that describe the
- ! surface state of the ocean.
- ! (in) h - Layer thickness, in m.
- ! (in) G - The ocean's grid structure.
- ! (in) CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
+! Local variables
real :: sosga
character(len=fm_string_len), parameter :: sub_name = 'MOM_generic_tracer_surface_state'
@@ -948,13 +823,12 @@ subroutine MOM_generic_tracer_fluxes_accumulate(flux_tmp, weight)
end subroutine MOM_generic_tracer_fluxes_accumulate
+ !> Copy the requested tracer into an array.
subroutine MOM_generic_tracer_get(name,member,array, CS)
- character(len=*), intent(in) :: name
- character(len=*), intent(in) :: member
- real, dimension(:,:,:), intent(out) :: array
- type(MOM_generic_tracer_CS), pointer :: CS
- ! (in) CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
+ character(len=*), intent(in) :: name !< Name of requested tracer.
+ character(len=*), intent(in) :: member !< ??
+ real, dimension(:,:,:), intent(out) :: array !< Array filled by this routine.
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
real, dimension(:,:,:), pointer :: array_ptr
character(len=fm_string_len), parameter :: sub_name = 'MOM_generic_tracer_get'
@@ -964,24 +838,9 @@ subroutine MOM_generic_tracer_get(name,member,array, CS)
end subroutine MOM_generic_tracer_get
- !
- !
- ! Ends the generic tracer module
- !
- !
- ! Call the end for generic tracer module and deallocate all temp arrays
- !
- !
- ! call end_MOM_generic_tracer(CS)
- !
- !
-
+ !> This subroutine deallocates the memory owned by this module.
subroutine end_MOM_generic_tracer(CS)
- type(MOM_generic_tracer_CS), pointer :: CS
- ! This subroutine deallocates the memory owned by this module.
- ! Argument: CS - The control structure returned by a previous call to
- ! register_MOM_generic_tracer.
- integer :: m
+ type(MOM_generic_tracer_CS), pointer :: CS !< Pointer to the control structure for this module.
call generic_tracer_end
@@ -991,4 +850,16 @@ subroutine end_MOM_generic_tracer(CS)
end subroutine end_MOM_generic_tracer
#endif /* _USE_GENERIC_TRACER */
+!----------------------------------------------------------------
+! Niki Zadeh
+!
+!
+! William Cooke
+!
+!
+!
+! This module drives the generic version of tracers TOPAZ and CFC
+!
+!----------------------------------------------------------------
+
end module MOM_generic_tracer
diff --git a/src/tracer/MOM_tracer_advect.F90 b/src/tracer/MOM_tracer_advect.F90
index 728d838182..9293940109 100644
--- a/src/tracer/MOM_tracer_advect.F90
+++ b/src/tracer/MOM_tracer_advect.F90
@@ -532,9 +532,23 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, &
if (j >= OBC%segment(n)%HI%jsd .and. j<= OBC%segment(n)%HI%jed) then
uhh(I) = uhr(I,j,k)
do m=1,ntr
- if (associated(OBC%segment(n)%tr_Reg%Tr(m)%t)) then
- flux_x(I,m) = uhh(I)*OBC%segment(n)%tr_Reg%Tr(m)%t(I,j,k)
- else ; flux_x(I,m) = uhh(I)*OBC%segment(n)%tr_Reg%Tr(m)%OBC_inflow_conc ; endif
+ if (OBC%segment(n)%direction == OBC_DIRECTION_E) then
+ if (uhh(I) > 0.0) then
+ flux_x(I,m) = uhh(I)*Tr(m)%t(i,j,k)
+ else
+ if (associated(OBC%segment(n)%tr_Reg%Tr(m)%t)) then
+ flux_x(I,m) = uhh(I)*OBC%segment(n)%tr_Reg%Tr(m)%t(I,j,k)
+ else ; flux_x(I,m) = uhh(I)*OBC%segment(n)%tr_Reg%Tr(m)%OBC_inflow_conc ; endif
+ endif
+ else ! West
+ if (uhh(I) < 0.0) then
+ flux_x(I,m) = uhh(I)*Tr(m)%t(i+1,j,k)
+ else
+ if (associated(OBC%segment(n)%tr_Reg%Tr(m)%t)) then
+ flux_x(I,m) = uhh(I)*OBC%segment(n)%tr_Reg%Tr(m)%t(I,j,k)
+ else ; flux_x(I,m) = uhh(I)*OBC%segment(n)%tr_Reg%Tr(m)%OBC_inflow_conc ; endif
+ endif
+ endif
enddo
endif
endif
@@ -827,9 +841,23 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, &
do i = OBC%segment(n)%HI%isd,OBC%segment(n)%HI%ied
vhh(i,J) = vhr(i,J,k)
do m=1,ntr
- if (associated(OBC%segment(n)%tr_Reg%Tr(m)%t)) then
- flux_y(i,m,J) = vhh(i,J)*OBC%segment(n)%tr_Reg%Tr(m)%t(i,J,k)
- else ; flux_y(i,m,J) = vhh(i,J)*OBC%segment(n)%tr_Reg%Tr(m)%OBC_inflow_conc ; endif
+ if (OBC%segment(n)%direction == OBC_DIRECTION_N) then
+ if (vhh(i,J) > 0.0) then
+ flux_y(i,m,J) = vhh(i,J)*Tr(m)%t(i,j,k)
+ else
+ if (associated(OBC%segment(n)%tr_Reg%Tr(m)%t)) then
+ flux_y(i,m,J) = vhh(i,J)*OBC%segment(n)%tr_Reg%Tr(m)%t(i,J,k)
+ else ; flux_y(i,m,J) = vhh(i,J)*OBC%segment(n)%tr_Reg%Tr(m)%OBC_inflow_conc ; endif
+ endif
+ else ! South
+ if (vhh(i,J) < 0.0) then
+ flux_y(i,m,J) = vhh(i,J)*Tr(m)%t(i,j,k)
+ else
+ if (associated(OBC%segment(n)%tr_Reg%Tr(m)%t)) then
+ flux_y(i,m,J) = vhh(i,J)*OBC%segment(n)%tr_Reg%Tr(m)%t(i,J,k)
+ else ; flux_y(i,m,J) = vhh(i,J)*OBC%segment(n)%tr_Reg%Tr(m)%OBC_inflow_conc ; endif
+ endif
+ endif
enddo
enddo
endif