uvic_fabm Module

Copyright (C) 2024 Bolding & Bruggeman

Warning

This module is still under development. API and functioning might change without notice.

History

A list of important UVic (MOM2) variables used by FABM:

  • - all tracers [source/mom/mw.h] - [T,S] = [1,2]
  • : tracers with sources [source/mom/tracer.f]
  • surface boundary conditions [source/common/csbc.h]
  • : density [source/mom/mw.h]

with

  • [commom/size.h]
  • number of tracers [commom/size.h]
  • [commom/size.h]
  • : number of tracers with source terms [common/size.h]
  • : total number of surface boundary conditions - list in [common/csbc.h] set in [common/UVic_ESCM.F].

Updating FABM is done in the tracer() subroutine called like:

  • with

The arguments to tracer() are passed directly to fabm_update(). Note that potentially jstrac:jetrac does not cover the entire domain. Focus - initially - will be on getting it to work with !O_min_window i.e. the entire domain calculated in one go.

Note

The FABM calculation domain in UVic reference is

Is it best to allocate arrays correspondingly or do the mapping in the do-loops?

Note

Dimension of z, dz and pressure in a z-coordinate model? Option to be 1D?

Note

What are the proper links to FABM modules?

Note

Is there a way to check if a FABM pelagic variable has source terms?

With UVic model all tracer variables - except T, S and CFC gases. All respecting #ifdefs.

Some native UVic_ESCM variables will have to be converted to be compatible with FABM. This can either be because of different dimensionality or different units. This is done by creating module level private variables that will be calculated/updated based on the original UVic_ECSM variables. Some will only need to be calculated once - like layer heights - and some will have to be updated every time step - like density.


Uses

  • module~~uvic_fabm~~UsesGraph module~uvic_fabm uvic_fabm fabm fabm module~uvic_fabm->fabm fabm_debug fabm_debug module~uvic_fabm->fabm_debug fabm_types fabm_types module~uvic_fabm->fabm_types uvic_common_blocks uvic_common_blocks module~uvic_fabm->uvic_common_blocks

Variables

Type Visibility Attributes Name Initial
class(type_fabm_model), private, pointer :: model

This variable will contain all FABM configuration and give access to FABM routines

real(kind=rke), private, allocatable, target :: dz(:,:,:)
type(type_fabm_interior_variable_id), private :: id_density
real(kind=rke), private, allocatable, target :: rho_fabm(:,:,:)
real(kind=rke), private, allocatable, target :: depth(:,:,:)
type(type_fabm_interior_variable_id), private :: id_downwelling_photosynthetic_radiative_flux
real(kind=rke), private, allocatable, target :: downwelling_photosynthetic_radiative_flux(:,:,:)
type(type_fabm_interior_variable_id), private :: id_practical_salinity
real(kind=rke), private, allocatable, target :: salt(:,:,:)
type(type_fabm_interior_variable_id), private :: id_pressure
real(kind=rke), private, allocatable, target :: pressure(:,:,:)
type(type_fabm_horizontal_variable_id), private :: id_mole_fraction_of_carbon_dioxide_in_air
real(kind=rke), private, allocatable, target :: mole_fraction_of_carbon_dioxide_in_air(:,:)
type(type_fabm_horizontal_variable_id), private :: id_surface_downwelling_photosynthetic_radiative_flux
real(kind=rke), private, allocatable, target :: surface_downwelling_photosynthetic_radiative_flux(:,:)
type(type_fabm_horizontal_variable_id), private :: id_surface_swr_flux
real(kind=rke), private, allocatable, target :: surface_swr_flux(:,:)
type(type_fabm_horizontal_variable_id), private :: id_windspeed
real(kind=rke), private, allocatable, target :: windspeed(:,:)
type(type_fabm_horizontal_variable_id), private :: id_bottom_stress
real(kind=rke), private, allocatable, target :: bottom_stress(:,:)
integer, private, parameter :: offset = nsrc-nfabm+1
real(kind=rke), private :: pelagic_sms(imt,km,1,nfabm)

pelagic source-sink terms in one j-stride

real(kind=rke), private :: surface_flux(imt,jmt,nfabm)

surface fluxes

real(kind=rke), private :: surface_sms(imt,jmt,nfabm)

surface source-sink terms

real(kind=rke), private :: bottom_flux(imt,jmt,nfabm)

bottom fluxes

real(kind=rke), private :: bottom_sms(imt,jmt,nfabm)

bottom source-sink terms

real(kind=rke), private :: w(imt,km,nt-2)

vertical velocity in m/s

real(kind=rke), private :: tai_fabm(nt-2)

time averaged variables

integer, private :: nsurface
integer, private :: npelagic
integer, private :: nbottom
logical, private, parameter :: repair = .true.
logical, private :: valid_pel

Note

The variables to hold surface, pelagic and bottom state variabl !es comes from mw.h - included in a 1 compilation clause

logical, private :: valid_surf

Note

The variables to hold surface, pelagic and bottom state variabl !es comes from mw.h - included in a 1 compilation clause

logical, private :: valid_bott

Note

The variables to hold surface, pelagic and bottom state variabl !es comes from mw.h - included in a 1 compilation clause


Subroutines

public subroutine fabm_configure(dt, yaml_file)

read fabm.yaml and call FABM configuration subroutines

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rke), intent(in) :: dt

bio-geochemical time step as set by MOM2 [s]

character(len=*), intent(in), optional :: yaml_file

name of alternativ FABM configuration file

public subroutine fabm_sbc_init(m)

surface boundary data are handled via sbc(imt,jmt,numsbc) in setmom.F, tracer.F, gosbc.F, embmio.F

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: m

number of handled variables handled so far

public subroutine fabm_tracer_init(m)

surface boundary data are handled via sbc(imt,jmt,numsbc) in setmom.F, tracer.F, gosbc.F, embmio.F

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: m

number of handled variables handled so far

private subroutine rowi_fabm()

this is done in fabm_initialize_state() - but check !!KB setmom.F - if (.not. init) then - around line 299

Arguments

None

public subroutine fabm_rest_in(iou, ln, ib, ic, tmpik, ils, ile, kls, kle, tau)

reading FABM restart variables from NetCDF

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: ln

data length

integer, intent(in) :: ib(:)

array of start indices

integer, intent(in) :: ic(:)

array of counts

real, intent(inout) :: tmpik(ils:ile,kls:kle)

array for present data slice

integer, intent(in) :: ils

start index - i

integer, intent(in) :: ile

end index - i

integer, intent(in) :: kls

start index - k

integer, intent(in) :: kle

end index - k

integer, intent(in) :: tau

time index - -1:1

public subroutine fabm_rest_def(iou, it)

define FABM restart variables in NetCDF context

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: it(:)

time dimension

public subroutine fabm_rest_out(iou, ln, ib, ic, tmpik, ils, ile, kls, kle, tau)

save 4D data to the NetCDF file given by iou

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: ln

data length

integer, intent(in) :: ib(:)

array of start indices

integer, intent(in) :: ic(:)

array of counts

real, intent(inout) :: tmpik(ils:ile,kls:kle)

mask array for present data slice

integer, intent(in) :: ils

start index - i

integer, intent(in) :: ile

end index - i

integer, intent(in) :: kls

start index - k

integer, intent(in) :: kle

end index - k

integer, intent(in) :: tau

time index - -1:1

public subroutine ta_fabm_tsi(m, ntatio, tbar)

define FABM variables in NetCDF context

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: m

switch operations

integer, intent(in), optional :: ntatio

switch operations

real, intent(in), optional :: tbar(:)

slice of UVic maintained temporary variable

public subroutine fabm_tsi_def(iou, id)

define FABM time series variables in NetCDF context

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: id(1)

time dimension

public subroutine fabm_tsi_out(iou, ntrec)

define FABM variables in NetCDF context

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: ntrec

time record

public subroutine fabm_tavg_def_4d(iou, it)

define FABM variables in NetCDF context

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: it(:)

array of dimension ids

public subroutine fabm_tavg_out_4d(iou, ln, ib, ic, tmpijkm, ils, ile, jls, jle, kls, kle, t, ids, ide, jds, jde, km, nt)

save 4D data to the NetCDF file given by iou

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: iou

NetCDF file id

integer, intent(in) :: ln

data length

integer, intent(in) :: ib(:)

array of start indices

integer, intent(in) :: ic(:)

array of counts

real, intent(in) :: tmpijkm(ils:ile,jls:jle,kls:kle)

mask array for present data slice

integer, intent(in) :: ils

start index - i

integer, intent(in) :: ile

end index - i

integer, intent(in) :: jls

start index - j

integer, intent(in) :: jle

end index - j

integer, intent(in) :: kls

start index - k

integer, intent(in) :: kle

end index - k

real, intent(in) :: t(ids:ide,jds:jde,km,nt)

UVic maintained data array slice

integer, intent(in) :: ids

start index - i

integer, intent(in) :: ide

end index - i

integer, intent(in) :: jds

start index - j

integer, intent(in) :: jde

end index - j

integer, intent(in) :: km

index - k

integer, intent(in) :: nt

number of tracers

public subroutine fabm_link_data()

link all FABM configured external dependencies - and call model%start() to assure proper configuration

Arguments

None

public subroutine fabm_initialize_state()

the initialization must be split form the linking as the masks are not yet calculated

Arguments

None

public subroutine fabm_list()

lists all FABM configured variables

Arguments

None

public subroutine fabm_update(joff, js, je, is, ie)

update the environment and calculate the source/sink terms - is called with the same argument list as mom() calls tracer( !) i.e. the specification of the active UVic window - typically the full domain on modern hardware

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: joff

offset row in global window

integer, intent(in) :: js

start row

integer, intent(in) :: je

end row

integer, intent(in) :: is

start column

integer, intent(in) :: ie

end column

public subroutine fabm_clean()

de-allocate all allocated arrays

Arguments

None

private subroutine update_data(joff)

update all time varying FABM configured external dependencie !s by calling individual update routines - tests done in routin !es

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: joff

offset row in global window

private subroutine link_grid()

Allocate and link grid related FABM standard variables that are being transformed from UVic native variables [cm -> m].

Arguments

None

private subroutine link_wind()

get wind speed FABM standard variable and if needed by FABM allocate memory

Arguments

None

private subroutine update_wind()

calculate wind speed in m/s according to

Arguments

None

Arguments

None

calculate the ?????? in W/m^2

Arguments

None

private subroutine link_surface_swr_flux()

Arguments

None

private subroutine update_surface_swr_flux()

This calculation of the surface swr uses the flux directly from the atmospheric model - must be corrected for ice at some point.

Read more…

Arguments

None

private subroutine link_bottom_stress()

get bottom stress FABM standard variable and if needed by FABM allocate memory

Arguments

None

private subroutine update_bottom_stress(joff)

calculate the bottom stress in Pa

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: joff

offset row in global window

get salinity FABM standard variable and if needed by FABM allocate memory

Arguments

None

calculate salinity in PSU according to

Arguments

None

private subroutine link_salinity()

get salinity FABM standard variable and if needed by FABM allocate memory

Arguments

None

private subroutine update_salinity()

calculate salinity in PSU according to

Arguments

None

private subroutine link_density()

get density FABM standard variable and if needed by FABM allocate memory

Arguments

None

private subroutine update_density()

calculate density in kg/m³ according to with . MUST match rho0 from UVic_ESCM.F90

Read more…

Arguments

None