MODULE model_mod (Lorenz_96, forced)

DART project logo

Jump to DART Documentation Main Index
version information for this file:
$Id: model_mod.html 7986 2015-05-15 20:34:58Z nancy $


DART interface module for the forced_lorenz_96 model. The 16 public interfaces are standardized for all DART compliant models. These interfaces allow DART to advance the model, get the model state and metadata describing this state, find state variables that are close to a given location, and do spatial interpolation for model state variables.


The forced_lorenz_96 model implements the standard L96 equations except that the forcing term, F, is added to the state vector and is assigned an independent value at each gridpoint. The result is a model that is twice as big as the standard L96 model. The forcing can be allowed to vary in time or can be held fixed so that the model looks like the standard L96 but with a state vector that includes the constant forcing term. An option is also included to add random noise to the forcing terms as part of the time tendency computation which can help in assimilation performance. If the random noise option is turned off (see namelist) the time tendency of the forcing terms is 0.

DART state vector composition
state variables
indices 1 - 40
forcing terms
indices 41 - 80
traditional Lorenz_96 state "extended" state

The DART tutorial Section 20 [pdf] explores parameter estimation using the forced_lorenz_96 model.

Quick Example

To become familiar with the model, try this quick experiment.

  1. compile everything in the model/forced_lorenz_96/work directory.

    cd models/forced_lorenz_96/work

  2. make sure the input.nml looks like the following (there is a lot that has been left out for clarity, these are the settings of interest for this example):

       start_from_restart    = .true.,
       output_restart        = .true.,
       async                 = 0,
       restart_in_file_name  = "perfect_ics",
       obs_seq_in_file_name  = "",
       obs_seq_out_file_name = "obs_seq.out",
       async                    = 0,
       ens_size                 = 80,
       start_from_restart       = .true.,
       output_restart           = .true.,
       obs_sequence_in_name     = "obs_seq.out",
       obs_sequence_out_name    = "",
       restart_in_file_name     = "filter_ics",
       restart_out_file_name    = "filter_restart",
       num_output_state_members = 80,
       num_output_obs_members   = 80,
       num_state_vars    = 40,
       forcing           = 8.00,
       delta_t           = 0.05,
       time_step_days    = 0,
       time_step_seconds = 3600,
       reset_forcing     = .false.,
       random_forcing_amplitude = 0.10

  3. Run perfect_model_obs to generate and obs_seq.out. The default will cause the model to advance for 1000 time steps.


  4. If you have ncview, explore the Notice that the State Variable indices from 1-40 are the dynamical part of the model and 41-80 are the Forcing variables.


  5. Run filter to generate, and


  6. Launch Matlab and run plot_ens_time_series.

    >> plot_ens_time_series
    Input name of prior or posterior diagnostics file:

    OPTIONAL: if you have the true state and want it superimposed, provide
    : the name of the input file. If not, enter a dummy filename.
    : Input name of True State file:

    Using state state variable IDs 1 13 27
    If these are OK, ;
    If not, please enter array of state variable ID's
    To choose from entire state enter A 25 50 75 (between 1 and 80)
    To choose traditional model state enter S 1 23 40 (between 1 and 40)
    To choose forcing estimates enter F 2 12 22 (between 1 and 40)
    (no intervening syntax required)
    A 20 30 40 60 70 80

    Indices 20, 30, and 40 will be from the dynamical part of the lorenz_96 attractor, indices 60, 70, and 80 will be the corresponding Forcing values. Here are some images for just indices 20 and 60. Click on each image for a high-res version.

  7. forced_lorenz_96evolution forced_lorenz_96evolution

Repeat the experiment with reset_forcing = .true. when creating the true state and reset_forcing = .false. when assimilating. What happens?





use model_mod, only : get_model_size

A note about documentation style. Optional arguments are enclosed in brackets [like this].

model_size = get_model_size( )
integer :: get_model_size

Returns the length of the model state vector. Required.

model_size The length of the model state vector.

call adv_1step(x, time)
real(r8), dimension(:), intent(inout) :: x
type(time_type),        intent(in)    :: time

Advances this model for a single time step using a four-step Runga-Kutta. The time argument is not used.

x State vector of length model_size.
time    Specifies time of the initial model state.

call get_state_meta_data (index_in, location, [, var_type] )
integer,             intent(in)  :: index_in
type(location_type), intent(out) :: location
integer, optional,   intent(out) ::  var_type 

Returns metadata about a given element, indexed by index_in, in the model state vector. Returns location of the state variable at the given index. If present, var_type is set to 1 for the default variable type, and set to 2 if the forcing parameter is being assimilated.

index_in    Index of state vector element about which information is requested.
location The location of state variable element.
var_type Returns the type of the indexed state variable as an optional argument. Valid types are 1 and 2.

call model_interpolate(x, location, itype, obs_val, istatus)
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 model state, returns the value of variable itype interpolated to a given location by a method of the model's choosing. At present, this is the only support for forward operators that is required from the model_mod.

x A model state vector.
location    Location to which to interpolate.
itype Integer indexing which type of state variable is to be interpolated. Can be ignored for low order models with a single type of variable.
obs_val The interpolated value from the model.
istatus Quality control information about the observation of the model state.

var = get_model_time_step()
type(time_type) :: get_model_time_step

Returns the time step (forecast length) of the model; The time step defaults to 1 hour but is settable by namelist.

var    Smallest time step of model.

call static_init_model()

Used for runtime initialization of model; reads namelist, initializes model parameters, etc. This is the first call made to the model by any DART-compliant assimilation routine.

call end_model()

A stub routine in this model.

call init_time(time)
type(time_type), intent(out) :: time

Returns the time at which the model will start if no input initial conditions are to be used. This is used to spin-up the model from rest. Sets time to 0 in this model.

time    Initial model time.

call init_conditions(x)
real(r8), dimension(:), intent(out) :: x

Returns default initial conditions for model; generally used for spinning up initial model states. Sets the entire state variable to the value of the forcing and then slightly perturbs the first element.

x    Initial conditions for state vector.

ierr = nc_write_model_atts(ncFileID)
integer             :: nc_write_model_atts
integer, intent(in) :: ncFileID

Function to write model specific attributes to a netCDF file. At present, DART is using the NetCDF format to output diagnostic information. This is not a requirement, and models could choose to provide output in other formats. This function writes the metadata associated with the model to a NetCDF file opened to a file identified by ncFileID.

ncFileID    Integer file descriptor to previously-opened netCDF file.
ierr Returns a 0 for successful completion.

ierr = nc_write_model_vars(ncFileID, statevec, copyindex, timeindex)
integer                            :: nc_write_model_vars
integer,                intent(in) :: ncFileID
real(r8), dimension(:), intent(in) :: statevec
integer,                intent(in) :: copyindex
integer,                intent(in) :: timeindex

Writes a copy of the state variables to a netCDF file. Multiple copies of the state for a given time are supported, allowing, for instance, a single file to include multiple ensemble estimates of the state.

ncFileID file descriptor to previously-opened netCDF file.
statevec A model state vector.
copyindex    Integer index of copy to be written.
timeindex The timestep counter for the given state.
ierr Returns 0 for normal completion.

call pert_model_state(state, pert_state, interf_provided)
real(r8), dimension(:), intent(in)  :: state
real(r8), dimension(:), intent(out) :: pert_state
logical,                intent(out) :: interf_provided

Given a model state, produces a perturbed model state. This particular model does not implement an interface for this and so returns .false. for interf_provided.

state State vector to be perturbed.
pert_state Perturbed state vector: NOT returned.
interf_provided    Returned false; interface is not implemented.

call get_close_maxdist_init(gc, maxdist)
type(get_close_type), intent(inout) :: gc
real(r8),             intent(in)    :: maxdist

Pass-through to the 1-D locations module. See get_close_maxdist_init() for the documentation of this subroutine.

call get_close_obs_init(gc, num, obs)
type(get_close_type), intent(inout) :: gc
integer,              intent(in)    :: num
type(location_type),  intent(in)    :: obs(num)

Pass-through to the 1-D locations module. See get_close_obs_init() for the documentation of this subroutine.

call get_close_obs(gc, base_obs_loc, base_obs_kind, obs, obs_kind, num_close, close_ind [, dist])
type(get_close_type), intent(in)  :: gc
type(location_type),  intent(in)  :: base_obs_loc
integer,              intent(in)  :: base_obs_kind
type(location_type),  intent(in)  :: obs(:)
integer,              intent(in)  :: obs_kind(:)
integer,              intent(out) :: num_close
integer,              intent(out) :: close_ind(:)
real(r8), optional,   intent(out) :: dist(:)

Pass-through to the 1-D locations module. See get_close_obs() for the documentation of this subroutine.

call ens_mean_for_model(ens_mean)
real(r8), dimension(:), intent(in) :: ens_mean

A NULL INTERFACE in this model.

ens_mean    State vector containing the ensemble mean.



This namelist is read from the file input.nml. Namelists start with an ampersand '&' and terminate with a slash '/'. Character strings that contain a '/' must be enclosed in quotes to prevent them from prematurely terminating the namelist. The values shown here are the default values.

   num_state_vars    = 40,
   forcing           = 8.00,
   delta_t           = 0.05,
   time_step_days    = 0,
   time_step_seconds = 3600,
   reset_forcing     = .false.,
   random_forcing_amplitude = 0.10  

Item Type Description
num_state_vars integer Number of variables in model.
forcing real(r8) Forcing, F, for model.
delta_t real(r8) Non-dimensional timestep.
time_step_days real(r8) Base model time step maps to this much real time.
time_step_seconds real(r8) Base model time step maps to this.
reset_forcing logical If true, all forcing values are held fixed at the value specified for the forcing namelist.
random_forcing_amplitude real(r8) Standard deviation of the gaussian noise with zero mean that is added to each forcing value's time step.



filename purpose
input.nml to read the model_mod namelist the time-history of the single model state used to generate the synthetic observations the time-history of the model state before assimilation   the time-history of the model state after assimilation
advance_model.csh shell script to advance the model as a standalone executable. Each advance will then read the model's namelist.
dart_log.out the run-time diagnostic output
dart_log.nml the record of all the namelists actually USED - contains the default values





Routine Message Comment
Various netCDF-f90 interface error messages From one of the netCDF calls in the named routine


none at this time



none at this time





Terms of Use

DART software - Copyright 2004 - 2013 UCAR.
This open source software is provided by UCAR, "as is",
without charge, subject to all terms of use at

Contact: DART core group
Revision: $Revision: 7986 $
Source: $URL: $
Change Date: $Date: 2015-05-15 14:34:58 -0600 (Fri, 15 May 2015) $
Change history:  try "svn log" or "svn diff"