From c2ecca505e988d6312cd88bd67ecf4a2d3f5504d Mon Sep 17 00:00:00 2001 From: Kate Hedstrom Date: Tue, 19 Sep 2017 16:07:45 -0800 Subject: [PATCH 1/8] Turning off the OBC tracer advection for now. - It will come back with tracers on segments. --- src/tracer/MOM_tracer_advect.F90 | 68 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/tracer/MOM_tracer_advect.F90 b/src/tracer/MOM_tracer_advect.F90 index 37b3e70a34..42c3ac6bbb 100644 --- a/src/tracer/MOM_tracer_advect.F90 +++ b/src/tracer/MOM_tracer_advect.F90 @@ -523,22 +523,23 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & endif endif enddo - endif - if (OBC%open_u_BCs_exist_globally) then - do n=1,OBC%number_of_segments - if (OBC%segment(n)%specified) cycle - if (OBC%segment(n)%is_E_or_W) then - I = OBC%segment(n)%HI%IsdB - if (j >= OBC%segment(n)%HI%jsd .and. j<= OBC%segment(n)%HI%jed) then - do m=1,ntr - if (associated(Tr(m)%OBC_in_u)) then - uhh(I) = uhr(I,j,k) - flux_x(I,m) = uhh(I)*Tr(m)%OBC_in_u(I,j,k) - else ; flux_x(I,m) = uhh(I)*Tr(m)%OBC_inflow_conc ; endif - enddo - endif - endif - enddo +! endif + ! Not yet... +! if (OBC%open_u_BCs_exist_globally) then +! do n=1,OBC%number_of_segments +! if (OBC%segment(n)%specified) cycle +! if (OBC%segment(n)%is_E_or_W) then +! I = OBC%segment(n)%HI%IsdB +! if (j >= OBC%segment(n)%HI%jsd .and. j<= OBC%segment(n)%HI%jed) then +! do m=1,ntr +! if (associated(Tr(m)%OBC_in_u)) then +! uhh(I) = uhr(I,j,k) +! flux_x(I,m) = uhh(I)*Tr(m)%OBC_in_u(I,j,k) +! else ; flux_x(I,m) = uhh(I)*Tr(m)%OBC_inflow_conc ; endif +! enddo +! endif +! endif +! enddo endif ; endif ; endif ! Calculate new tracer concentration in each cell after accounting @@ -816,23 +817,24 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & endif endif enddo - endif - if (OBC%open_v_BCs_exist_globally) then - do n=1,OBC%number_of_segments - if (OBC%segment(n)%specified) cycle - if (OBC%segment(n)%is_N_or_S) then - if (J >= OBC%segment(n)%HI%JsdB .and. J<= OBC%segment(n)%HI%JedB) then - do i = OBC%segment(n)%HI%isd,OBC%segment(n)%HI%ied - do m=1,ntr - if (associated(Tr(m)%OBC_in_v)) then - vhh(i,J) = vhr(i,J,k) - flux_y(i,m,J) = vhh(i,J)*Tr(m)%OBC_in_v(i,J,k) - else ; flux_y(i,m,J) = vhh(i,J)*Tr(m)%OBC_inflow_conc ; endif - enddo - enddo - endif - endif - enddo +! endif +! Coming soon... +! if (OBC%open_v_BCs_exist_globally) then +! do n=1,OBC%number_of_segments +! if (OBC%segment(n)%specified) cycle +! if (OBC%segment(n)%is_N_or_S) then +! if (J >= OBC%segment(n)%HI%JsdB .and. J<= OBC%segment(n)%HI%JedB) then +! do i = OBC%segment(n)%HI%isd,OBC%segment(n)%HI%ied +! do m=1,ntr +! if (associated(Tr(m)%OBC_in_v)) then +! vhh(i,J) = vhr(i,J,k) +! flux_y(i,m,J) = vhh(i,J)*Tr(m)%OBC_in_v(i,J,k) +! else ; flux_y(i,m,J) = vhh(i,J)*Tr(m)%OBC_inflow_conc ; endif +! enddo +! enddo +! endif +! endif +! enddo endif ; endif ; endif else ! not domore_v. do i=is,ie ; vhh(i,J) = 0.0 ; enddo From a02220e247f5416610c91c32588a4fd43fc95a49 Mon Sep 17 00:00:00 2001 From: Kate Hedstrom Date: Tue, 19 Sep 2017 17:00:06 -0800 Subject: [PATCH 2/8] Setting h outside is needed for ALE regridding... --- src/core/MOM_open_boundary.F90 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/core/MOM_open_boundary.F90 b/src/core/MOM_open_boundary.F90 index 9b2c5d0739..31c9f2d582 100644 --- a/src/core/MOM_open_boundary.F90 +++ b/src/core/MOM_open_boundary.F90 @@ -1647,6 +1647,33 @@ 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 + end subroutine set_tracer_data function lookup_seg_field(OBC_seg,field) From e8edc15ea3a5c6dce62c5d42cd73e61708fac722 Mon Sep 17 00:00:00 2001 From: Kate Hedstrom Date: Mon, 25 Sep 2017 16:28:05 -0800 Subject: [PATCH 3/8] *Mask out the land outside of open boundaries. - Changes some answers of problems with OBCs. --- src/core/MOM_open_boundary.F90 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/MOM_open_boundary.F90 b/src/core/MOM_open_boundary.F90 index 9f06838d4d..7463f75161 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 From 6c05467d24f1eaf9595e76fe3871d7e8785680c2 Mon Sep 17 00:00:00 2001 From: Kate Hedstrom Date: Mon, 25 Sep 2017 16:54:00 -0800 Subject: [PATCH 4/8] Mask out those outside h points again. --- src/core/MOM_open_boundary.F90 | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/core/MOM_open_boundary.F90 b/src/core/MOM_open_boundary.F90 index 7463f75161..153b901a42 100644 --- a/src/core/MOM_open_boundary.F90 +++ b/src/core/MOM_open_boundary.F90 @@ -1643,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 From 8d33a65330ec8b679b83ae3761f9731bc6e02733 Mon Sep 17 00:00:00 2001 From: Kate Hedstrom Date: Tue, 26 Sep 2017 08:59:14 -0800 Subject: [PATCH 5/8] *Fix tracer upstream OBC -Changes answers for ESMG seamount cases. --- src/tracer/MOM_tracer_advect.F90 | 40 +++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) 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 From c6d5a6e4df1cdda493a7bbf29fff307bb0915018 Mon Sep 17 00:00:00 2001 From: Kate Hedstrom Date: Wed, 27 Sep 2017 09:20:35 -0800 Subject: [PATCH 6/8] Doxygen of generic tracer --- .../MOM_state_initialization.F90 | 7 +- src/tracer/MOM_generic_tracer.F90 | 369 ++++++------------ 2 files changed, 124 insertions(+), 252 deletions(-) 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 - ! - ! - ! - + !> 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. - ! - !