Work in progress!!!
Global physics fields
As you hopefully already know, GEM can run in parallel, using MPI and/or OpenMP. In the physics, when using MPI, the model domain gets horizontally divided into tiles, or rather cubes. Each MPI process is taking care of one of these cubes.
However, the physics do not see the whole "cube" at once but they are called for one "slab" (ni*nk) at the time. With ni being the number of points in x-direction of the particular tile and nk being the number of vertical levels, which can be atmospheric model levels, soil or ice levels or even "levels" for the different surface fractions.
Busses
Physics fields, that are used in different routines and also available for output, are organized in so called "busses". These busses are very veeeeery long 2-D arrays, filled with one field after the other. For each field there is one row per level, followed by the next field. The starting location of each field in a bus is defined in a variable.
There are 5 of these busses in the physics:
- entry bus (contains initial conditions - almost not used anymore in GEM5)
- dynamic bus (contains fields which get passed from and to the dynamics)
- volatile bus (contains physics fields of which the content is not needed to calculate the next timestep)
- permanent bus (contains physics fields of which the content is needed to calculate the next timestep)
- surface bus (contains only physics fields used by the surface schemes)
All fields that are in a bus need to get declared with the command "PHYVARnCx".
The syntax is:
PHYVARnD1 (name, description)
respectively
PHYVARnDC (name, description, condition)
Where :
'n' is the "real" dimension of the field which can be: 2 (ni*nj), 3 (ni*nj*nk), or 4.
'name' is the "name" by which the field can get addressed in the physics. This variable is actually an integer which contains the starting position of the field in the bus.
'description' is a string containing a set of key words followed by a name, description or value. The different keys are separated by a semicolon ';'. These are the accepted keys:
ON= ; ===> output name (4 letters only) - mandatory
IN= ; ===> input name (4 letters only) - defaults to 'ON'
SN= ; ===> series name (4 letters only) - defaults to 'ON'
VD= ; ===> formal description - mandatory, will appear in model listing
VS= ; ===> variable shape (accepted shapes are M, T, E and A with +, - or * followed by an integer)
VB= ; ===> bus identification (e1, d1, p0, p1, v0) - mandatory
'0' means the field does not need to get read at timestep 0
'1' means the field is an input field which needs to get read at timestep 0,
either from the analysis, geophys or climatology file
MIN= ; ===> minimum value of the field (useful to keep i.e. humidity fields above zero)
MAX= ; ===> maximum value of the field
WLOAD= ; ===> water load flag (default=0)
HZD= ; ===> Horizontal diffusion (default=0)
MASSC= ; ===> mass conserv (default=0)
MONOT= ; ===> monotone interpolation (default=1)
'condition' is the condition under which the field should get declared. For example, certain fields are only needed when certain schemes are used. So they only need to get declared when the respective scheme is used. Otherwise they should not get declared so they do not use memory space unnecessarily and do not get written in the restart files.
Fields that get only(!) used by the surface schemes need to get declared in rpnphy/surface/sfc_businit.F90.
All other fields need to get declared in rpnphy/base/phyvar.hf.
Entry, dynamic, volatile and permanent bus
As mentioned above, the entry bus is almost not used anymore. It was used for fields which got read by the entry (which does not exist anymore) and then passed to the model.
Fields from the entry bus need to get declared as "VB=e1" - see above.
The dynamic bus contains fields which get passed from and to the dynamics. If possible, do not add fields to the dynamic bus as this gets quite complicated.
Fields from the dynamic bus need to get declared as "VB=d1" - see above.
All pure physics fields that are NOT needed to calculate the next timestep should go in the volatile bus. These are, for example, precipitation rates or instantaneous radiation.
Fields from the volatile bus need to get declared as "VB=v1" - see above.
All fields of which the content is needed in the next timestep need to be in the permanent bus. For example, accumulators need to be in the permanent bus, since they usually get accumulated over several timesteps. The same goes for averages, minimum and maximum fields. But there are also instantaneous fields that need to be in the permanent like snow depth or temperature fields, because they are needed for the next timestep.
Fields from the permanent bus need to get declared as "VB=p0" resp. as "VB=p1" (mandatory to get read at timestep 0) - see above.
Surface bus
If variable is in the rest of the physics
base/phyvar.hf : variable declaration in physics bus
surface/sfcbus_mod.F90 : copy variable from physics bus to surface bus
SFCVAR(name_in_surface_bus, 'name_in_physics_bus')
Explain what a bus is: slab with just land points etc.
in class_main:
declare variable as pointer with the correct dimension (1-D)
all usually 2-D fields are 1-D because we only get one row
all usually 3-D fields are 2-D because we only get one slab