Contact: | Jeff Anderson |
Reviewers: | |
Revision: | $Revision: 1.2 $ |
Release Name: | $Name: post_iceland $ |
Change Date: | $Date: 2004/12/22 20:48:13 $ |
Change history: | see CVS log |
Every model that is DART compliant must provide an interface that looks like this. The file template/model_mod.f90 under models provides the fortran interfaces for a minimal implementation of this interface. This description is generic in that no details of the underlying model impact the interface.
types_mod time_manager_mod location_mod POSSIBLY MANY OTHERS DEPENDING ON MODEL DETAILS
Optional namelist interface &model_mod_nml may be read from file input.nml The details of the namelist are always model specific (there are no generic namelist values).
fill in text here
integer :: get_model_size
Returns the size of the model as an integer. Required for all applications.
get_model_size | The size of the model state vector. |
real(r8), dimension(:), intent(inout) :: x type(time_type), intent(in) :: time
Does a single timestep advance of the model. The input value of the vector x is the starting condition and x is updated to reflect the changed state after a timestep. The time argument is intent in and is used for models that need to know the date/time to compute a timestep, for instance for radiation computations. This interface is only called if the namelist parameter async is set to 0 in perfect_model_obs of filter or if the program integrate_model is to be used to advance the model state as a separate executable. If one of these options is not going to be used (the model will only be advanced as a separate model-specific executable), this can be a NULL INTERFACE.
x | Input state vector that is returned at the next timestep. |
time | Initial time of the model state that is returned at the advanced time. |
integer, intent(in) :: index_in type(location_type), intent(out) :: location integer, optional, intent(out) :: var_type
Given an integer index into the state vector structure, returns the associated location. A second intent(out) optional argument kind can be returned if the model has more than one type of field (for instance temperature and zonal wind component). This interface is required for all filter applications as it is required for computing the distance between observations and state variables.
index_in | Index of state vector element about which information is requested. |
location | The location of state variable element. |
var_type | The type of the state variable element. |
real(r8), dimension(:), intent(in) :: x type(location_type), intent(in) :: location integer, intent(in) :: itype real(r8), intent(out) :: obs_val integer, intent(out) :: istatus
Given a state vector, a location, and a model state variable type, interpolates the state variable field to that location and returns the value in obs_val. The istatus variable should be returned as 0 unless there is some problem in computing the interpolation in which case an alternate value should be returned. The itype variable is a model specific integer that specifies the type of field (for instance temperature, zonal wind component, etc.). In low order models that have no notion of types of variables, this argument can be ignored. For applications in which only perfect model experiments with identity observations (i.e. only the value of a particular state variable is observerd), this can be a NULL INTERFACE.
x | A model state vector. |
location | Location to which to interpolate. |
itype | Type of state field to be interpolated. |
obs_val | The returned interpolated value. |
istatus | Integer value returning 0 for successful, other values can be defined for various failures. |
type(time_type) :: get_model_time_step
Returns the the time step of the model; the smallest increment in time that the model is capable of advancing the state in a given implementation. This interface is required for all applications.
get_model_time_step | Time step of model. |
Does any shutdown and clean-up needed for model. Can be a NULL INTERFACE if the model has no need to clean up storage, etc.
Called to do one time initialization of the model. As examples, might define information about the model size or model timestep. In models that require pre-computed static data, for instance spherical harmonic weights, these would also be computed here. Can be a NULL INTERFACE for the simplest models.
type(time_type), intent(out) :: time
Companion interface to init_conditions. Returns a time that is somehow appropriate for starting up a long integration of the model. At present, this is only used if the namelist parameter start_from_restart is set to .false. in the program perfect_model_obs. If this option is not to be used in perfect_model_obs, or if no synthetic data experiments using perfect_model_obs are planned, this can be a NULL INTERFACE.
time | Initial model time. |
real(r8), dimension(:), intent(out) :: x
Returns a model state vector, x, that is some sort of appropriate initial condition for starting up a long integration of the model. At present, this is only used if the namelist parameter start_from_restart is set to .false. in the program perfect_model_obs. If this option is not to be used in perfect_model_obs, or if no synthetic data experiments using perfect_model_obs are planned, this can be a NULL INTERFACE.
x | Initial conditions for state vector. |
type(location_type), intent(in) :: o_loc real(r8), intent(in) :: radius integer, intent(out) :: inum integer, dimension(:), intent(out) :: indices real(r8), dimension(:), intent(out) :: dist real(r8), dimension(:), intent(in) :: x
Computes a list of model state variable indices that are within distance radius of a given location, o_loc. The units of the radius and the metric for computing distances is defined by the location module that is in use. The number of state variables that are within radius of o_loc is returned in inum. The indices of each of these is returned in indices and the corresponding distance in dist. The model state is available in x because it is sometimes required to determine the distance (for instance, the current model surface pressure field is required to compute the location of state variables in a sigma vertical coordinate model). A model can choose to do no computation here and return a value of -1 in inum. If this happens, the filter will do a naive search through ALL state variables for close states. This can work fine in low-order models, but can be far too expensive in large models.
o_loc | Location around which close states are to be found. |
radius | Anything closer than this is close. |
inum | Number of close states found. |
indices | Indices in state vector of close state elements. |
dist | Distance to corresponding state elements. |
x | The state vector, needed for computing distance in some models. |
integer :: nc_write_model_atts integer, intent(in) :: ncFileID
Writes the model-specific attributes to a netCDF file
TJH Jan 24 2003
TJH 29 July 2003 -- for the moment, all errors are fatal, so the
return code is always '0 == normal', since the fatal errors stop execution.
For the lorenz_96 model, each state variable is at a separate location.
that's all the model-specific attributes I can think of ...
assim_model_mod:init_diag_output uses information from the location_mod
to define the location dimension and variable ID. All we need to do
is query, verify, and fill ...
Typical sequence for adding new dimensions,variables,attributes:
NF90_OPEN ! open existing netCDF dataset
NF90_redef ! put into define mode
NF90_def_dim ! define additional dimensions (if any)
NF90_def_var ! define variables: from name, type, and dims
NF90_put_att ! assign attribute values
NF90_ENDDEF ! end definitions: leave define mode
NF90_put_var ! provide values for variable
NF90_CLOSE ! close: save updated netCDF dataset
nc_write_model_atts | Returns a 0 for successful completion. |
ncFileID | netCDF file identifier. |
integer :: nc_write_model_vars integer, intent(in) :: ncFileID real(r8), dimension(:), intent(in) :: statevec integer, intent(in) :: copyindex integer, intent(in) :: timeindex
Writes the model variables to a netCDF file
TJH 23 May 2003
TJH 29 July 2003 -- for the moment, all errors are fatal, so the
return code is always '0 == normal', since the fatal errors stop execution.
For the lorenz_96 model, each state variable is at a separate location.
that's all the model-specific attributes I can think of ...
assim_model_mod:init_diag_output uses information from the location_mod
to define the location dimension and variable ID. All we need to do
is query, verify, and fill ...
Typical sequence for adding new dimensions,variables,attributes:
NF90_OPEN ! open existing netCDF dataset
NF90_redef ! put into define mode
NF90_def_dim ! define additional dimensions (if any)
NF90_def_var ! define variables: from name, type, and dims
NF90_put_att ! assign attribute values
NF90_ENDDEF ! end definitions: leave define mode
NF90_put_var ! provide values for variable
NF90_CLOSE ! close: save updated netCDF dataset
nc_write_model_vars | Returns 0 for normal completion. |
ncFileID | NetCDF file id. |
statevec | A model state vector. |
copyindex | Which copy of state in output file is being written |
timeindex | What time level of output is this. |
real(r8), dimension(:), intent(in) :: state real(r8), dimension(:), intent(out) :: pert_state logical, intent(out) :: interf_provided
Given a model state vector, perturbs this vector. Used to generate initial conditions for spinning up ensembles. If the model_mod does not want to do this, instead allowing the default algorithms in filter to take effect, interf_provided should be returned as false. Otherwise, it should be returned as true.
state | State vector to be perturbed. |
pert_state | Perturbed state vector |
interf_provided | Returned false if model_mod doesn't know how to do this, else true. |
We adhere to the F90 standard of starting a namelist with an ampersand '&338;' and terminating with a slash '/'.
namelist / model_mod_nml /
Models are free to include a model_mod namelist which can be read when static_init_model is called. A good example can be found in the lorenz_96 model_mod.
This namelist is read in a file called input.nml
It is likely that a number of additional optional interfaces will be added to the model_mod structure. For instance, hints about how to divide the state vector into regions for parallel assimilation will need to be obtained from the model. It is planned that the interf_provided mechanism used in pert_model_state will allow those who do not wish to support enhanced interfaces to add NULL interfaces by simply pasting in an interface block.