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:
with
Updating FABM is done in the tracer() subroutine called like:
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.
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 |
read fabm.yaml and call FABM configuration subroutines
Type | Intent | Optional | 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 |
surface boundary data are handled via sbc(imt,jmt,numsbc) in setmom.F, tracer.F, gosbc.F, embmio.F
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | m |
number of handled variables handled so far |
surface boundary data are handled via sbc(imt,jmt,numsbc) in setmom.F, tracer.F, gosbc.F, embmio.F
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | m |
number of handled variables handled so far |
this is done in fabm_initialize_state() - but check !!KB setmom.F - if (.not. init) then - around line 299
reading FABM restart variables from NetCDF
Type | Intent | Optional | 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 |
define FABM restart variables in NetCDF context
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | iou |
NetCDF file id |
||
integer, | intent(in) | :: | it(:) |
time dimension |
save 4D data to the NetCDF file given by iou
Type | Intent | Optional | 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 |
define FABM variables in NetCDF context
Type | Intent | Optional | 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 |
define FABM time series variables in NetCDF context
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | iou |
NetCDF file id |
||
integer, | intent(in) | :: | id(1) |
time dimension |
define FABM variables in NetCDF context
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | iou |
NetCDF file id |
||
integer, | intent(in) | :: | ntrec |
time record |
define FABM variables in NetCDF context
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | iou |
NetCDF file id |
||
integer, | intent(in) | :: | it(:) |
array of dimension ids |
save 4D data to the NetCDF file given by iou
Type | Intent | Optional | 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 |
link all FABM configured external dependencies - and call model%start() to assure proper configuration
the initialization must be split form the linking as the masks are not yet calculated
lists all FABM configured variables
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
Type | Intent | Optional | 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 |
de-allocate all allocated arrays
update all time varying FABM configured external dependencie !s by calling individual update routines - tests done in routin !es
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | joff |
offset row in global window |
Allocate and link grid related FABM standard variables that are being transformed from UVic native variables [cm -> m].
get wind speed FABM standard variable and if needed by FABM allocate memory
calculate wind speed in m/s according to
calculate the ?????? in W/m^2
This calculation of the surface swr uses the flux directly from the atmospheric model - must be corrected for ice at some point.
get bottom stress FABM standard variable and if needed by FABM allocate memory
calculate the bottom stress in Pa
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | joff |
offset row in global window |
get salinity FABM standard variable and if needed by FABM allocate memory
calculate salinity in PSU according to
get salinity FABM standard variable and if needed by FABM allocate memory
calculate salinity in PSU according to
get density FABM standard variable and if needed by FABM allocate memory
calculate density in kg/m³ according to with . MUST match rho0 from UVic_ESCM.F90