Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow virtual flux correction based on ocean salt restoring/correction #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions generic_tracers/generic_tracer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module generic_tracer
public generic_tracer_source
public generic_tracer_diag
public generic_tracer_update_from_bottom
public generic_tracer_update_from_coupler
public generic_tracer_coupler_get
public generic_tracer_coupler_set
public generic_tracer_coupler_zero
Expand Down Expand Up @@ -612,6 +613,52 @@ subroutine generic_tracer_update_from_bottom(dt, tau, model_time)

end subroutine generic_tracer_update_from_bottom

! <SUBROUTINE NAME="generic_tracer_update_from_coupler">
! <OVERVIEW>
! Modify the values obtained from the coupler
! </OVERVIEW>
! <DESCRIPTION>
! Calls the corresponding generic_X_update_from_coupler routine for each package X.
! </DESCRIPTION>
! <TEMPLATE>
! call generic_tracer_update_from_coupler(ilb, jlb, salt_flux_added)
! </TEMPLATE>
! <IN NAME="ilb,jlb" TYPE="integer">
! Lower bounds of x and y extents of input arrays on data domain
! </IN>
! <IN NAME="salt_flux_added" TYPE="real, dimension(ilb:,jlb:)">
! Surface salt flux into ocean from restoring or flux adjustment [g/m^2/sec]
! </IN>
! </SUBROUTINE>

subroutine generic_tracer_update_from_coupler(ilb, jlb, salt_flux_added)
integer, intent(in) :: ilb, jlb
real, dimension(ilb:,jlb:), intent(in) :: salt_flux_added

character(len=fm_string_len), parameter :: sub_name = 'generic_tracer_update_from_coupler'

!Specific tracers
! if(do_generic_blres) call generic_age_update_from_coupler(tracer_list) !Nothing to do for mixed layer tracer

! if(do_generic_age) call generic_blres_update_from_coupler(tracer_list) !Nothing to do for age

! if(do_generic_argon) call generic_argon_update_from_coupler(tracer_list) !Nothing to do for argon

! if(do_generic_CFC) call generic_CFC_update_from_coupler(tracer_list) !Nothing to do for CFC

! if(do_generic_SF6) call generic_SF6_update_from_coupler(tracer_list) !Nothing to do for SF6

if(do_generic_TOPAZ) call generic_TOPAZ_update_from_coupler(tracer_list)

if(do_generic_BLING) call generic_BLING_update_from_coupler(tracer_list)

if(do_generic_miniBLING) call generic_miniBLING_update_from_coupler(tracer_list)

if(do_generic_COBALT) call generic_COBALT_update_from_coupler(tracer_list)

return

end subroutine generic_tracer_update_from_coupler

! <SUBROUTINE NAME="generic_tracer_vertdiff_G">
! <OVERVIEW>
Expand Down
17 changes: 14 additions & 3 deletions generic_tracers/generic_tracer_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ module g_tracer_utils
! logical :: flux_wetdep = .false. !Is there a wet deposition?
! logical :: flux_drydep = .false. !Is there a dry deposition?
! logical :: flux_bottom = .false. !Is there a flux through bottom?
! logical :: flux_virtual = .false. !Is there a virtual flux to be applid to the surface flux?
!
! ! Flux identifiers to be set by aof_set_coupler_flux()
! integer :: flux_gas_ind = -1
Expand Down Expand Up @@ -256,6 +257,7 @@ module g_tracer_utils
logical :: flux_wetdep = .false. !Is there a wet deposition?
logical :: flux_drydep = .false. !Is there a dry deposition?
logical :: flux_bottom = .false. !Is there a flux through bottom?
logical :: flux_virtual = .false. !Is there a virtual flux to be applid to the surface flux?
logical :: has_btm_reservoir = .false. !Is there a flux bottom reservoir?
logical :: runoff_added_to_stf = .false. ! Has flux in from runoff been added to stf?

Expand Down Expand Up @@ -724,6 +726,9 @@ end subroutine g_tracer_add_param_string
! <IN NAME="flux_bottom" TYPE="logical">
! .true. if there is bottom flux.
! </IN>
! <IN NAME="flux_virtual" TYPE="logical">
! .true. to ensure that stf is allocated so that a surface virtual flux can be applied
! </IN>
! <IN NAME="btm_reservoir" TYPE="logical">
! .true. if there is bottom reservoir.
! </IN>
Expand Down Expand Up @@ -757,7 +762,8 @@ end subroutine g_tracer_add_param_string
subroutine g_tracer_add(node_ptr, package, name, longname, units, prog, const_init_value,init_value,&
flux_gas, flux_gas_name, flux_runoff, flux_wetdep, flux_drydep, flux_gas_molwt, flux_gas_param, &
flux_param, flux_bottom, btm_reservoir, move_vertical, diff_vertical, sink_rate, flux_gas_restart_file, &
flux_gas_type,requires_src_info,standard_name,diag_name,diag_field_units,diag_field_scaling_factor,implementation)
flux_gas_type,requires_src_info,standard_name,diag_name,diag_field_units,diag_field_scaling_factor, &
implementation, flux_virtual)

type(g_tracer_type), pointer :: node_ptr
character(len=*), intent(in) :: package,name,longname,units
Expand All @@ -770,6 +776,7 @@ subroutine g_tracer_add(node_ptr, package, name, longname, units, prog, const_i
logical, intent(in), optional :: flux_wetdep
logical, intent(in), optional :: flux_drydep
logical, intent(in), optional :: flux_bottom
logical, intent(in), optional :: flux_virtual
logical, intent(in), optional :: btm_reservoir
logical, intent(in), optional :: move_vertical
logical, intent(in), optional :: diff_vertical
Expand Down Expand Up @@ -918,6 +925,8 @@ subroutine g_tracer_add(node_ptr, package, name, longname, units, prog, const_i

if(present(flux_bottom)) g_tracer%flux_bottom = flux_bottom

if(present(flux_virtual)) g_tracer%flux_virtual = flux_virtual

if(present(btm_reservoir)) g_tracer%has_btm_reservoir = btm_reservoir

if(present(move_vertical)) g_tracer%move_vertical = move_vertical
Expand Down Expand Up @@ -1035,7 +1044,8 @@ subroutine g_tracer_init(g_tracer)
endif
!Surface flux %stf exists if one of the following fluxes were requested:

if(g_tracer%flux_gas .or. g_tracer%flux_runoff .or. g_tracer%flux_wetdep .or. g_tracer%flux_drydep) then
if(g_tracer%flux_gas .or. g_tracer%flux_runoff .or. g_tracer%flux_wetdep .or. g_tracer%flux_drydep &
.or. g_tracer%flux_virtual) then
allocate(g_tracer%stf(isd:ied,jsd:jed)); g_tracer%stf(:,:) = 0.0
endif

Expand Down Expand Up @@ -1536,7 +1546,8 @@ subroutine g_tracer_coupler_get(g_tracer_list,IOB_struc, weight, model_time)
!runoff contributes to %stf in GOLD but not in MOM,
!so it will be added later in the model-dependent driver code (GOLD_generic_tracer.F90)

if(g_tracer%flux_gas .or. g_tracer%flux_drydep .or. g_tracer%flux_wetdep .or. g_tracer%flux_runoff ) then
if(g_tracer%flux_gas .or. g_tracer%flux_drydep .or. g_tracer%flux_wetdep .or. g_tracer%flux_runoff &
.or. g_tracer%flux_virtual) then
call g_tracer_set_values(g_tracer,g_tracer%name,'stf',stf_array,&
g_tracer_com%isd,g_tracer_com%jsd, weight)
endif
Expand Down