modbuild_sp_model_template.h

Go to the documentation of this file.
00001 /*
00002 COSTA: Problem solving environment for data assimilation
00003 Copyright (C) 2007  Nils van Velzen
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 /**
00021 \file  cta_modbuild_sp_model_template.h
00022 
00023 \brief Interfaces of the user-routines that can be provided in order to create a model using the SP-modelbuilder
00024 
00025 Copy this file to your_model.c and fill in the routines.
00026 
00027 
00028 */
00029 #include "cta.h"
00030 #include "f_cta_utils.h"
00031 
00032 #define CREATEFUNC_F77  CF77_CALL(usr_createfunc)
00033 
00034 
00035 
00036 
00037 /** \brief Creates a new model instance
00038  *  This routine creates and initialises a new model instance.
00039  *
00040  *  \param hinput    I   Model configuration CTA_Tree of CTA_String
00041  *  \param state     O   Model state (initialized to initial value. Note this statevector must be created
00042  *  \param sbound    O   State-vector for the offset on the forcings. Set CTA_NULL if not used. Note this statevector must be created
00043  *  \param nnoise    O   The number of noise parameters in model state. Set 0 in case of a deterministic model
00044  *  \param time0     O   Time instance of the initial state state. The time object is already created
00045  *  \param snamnoise O   Name of the substate containing the noise parameters. The string is already created
00046  *  \param husrdata  O   Handle that can be used for storing instance specific data
00047  *  \param ierr      O   Return flag CTA_OK if successful
00048 */
00049 void usr_create(CTA_Handle *hinput,  CTA_TreeVector *state, CTA_TreeVector *sbound, 
00050                 CTA_TreeVector *sparam, int *nnoise, CTA_Time *time0, 
00051                 CTA_String *snamnoise, CTA_Handle *husrdata, int *ierr);
00052 
00053 /** \brief Compute timestep(s)
00054  *  This routine is computes several timesteps over a giving timespan.
00055  *
00056  *  \param timespan  I  Timespan to simulate
00057  *  \param state     IO State vector
00058  *  \param saxpyforc I  Offset on models forcings
00059  *  \param baddnoise I  flag (CTA_TRUE/CTA_FALSE) whether to add noise
00060  *  \param sparam    I  Model parameters
00061  *  \param husrdata  IO Instance specific data
00062  *  \param ierr      O  Return flag CTA_OK if successful
00063 */
00064 void usr_compute(CTA_Time *timespan, CTA_TreeVector *state, CTA_TreeVector *saxpyforc,
00065                      int *baddnoise, CTA_TreeVector *sparam, CTA_Handle *husrdata,
00066                      int *ierr);
00067 
00068 /** \brief Return the root of noise covariance matrix
00069  *  This routine is responsible for returning the covariance matrix of the noise parameters.
00070  *
00071  *  \param colsvar         O   Covariance of noise parameters array of noise. 
00072  *                             Represented als an array (nnoise) of tree-vectors.
00073  *                             Note the sub-tree-vectors are already allocated.
00074  *  \param nnoise          I   Number of noise parameters
00075  *  \param husrdata        IO  Instance specific data
00076  *  \param ierr            O   Return flag CTA_OK if successful
00077 */
00078 void usr_covar(CTA_TreeVector *colsvar, int *nnoise, CTA_Handle *husrdata, int *ierr);
00079 
00080 /** \brief Return values that correspond to observed values
00081  *  This routine is responsible for the transformation of the state-vector to the observations. 
00082  *
00083  *  \param state    I  state vector
00084  *  \param hdescr   I  Observation description of observations
00085  *  \param vval     O  Model (state) values corresponding to observations in hdescr
00086  *  \param husrdata IO Instance specific data
00087  *  \param ierr     O  Return flag CTA_OK if successful
00088 */
00089 void usr_obs(CTA_TreeVector *state, CTA_ObsDescr *hdescr, CTA_Vector *vval,
00090                 CTA_Handle *husrdata, int *ierr);
00091 
00092 
00093 /** \brief Select criterion for observations that can be used for the model.
00094  *  This routine is responsible for producing a selection criterion that will filter out all invalid observations.
00095  *  Invalid observations are observations for which the model cannot produce a corresponding value. For example
00096  *  observations that are outside the computational domain.
00097  *
00098  *  \param state    I  state vector
00099  *  \param ttime    I  timespan for selection
00100  *  \param hdescr   I  observation description of all available observations
00101  *  \param sselect  O  The select criterion to filter out all invalid observations
00102  *  \param husrdata IO Instance specific data
00103  *  \param ierr     O  Return flag CTA_OK if successful
00104 */
00105 void usr_obssel(CTA_TreeVector *state, CTA_Time *ttime, CTA_ObsDescr *hdescr,
00106                 CTA_String *sselect, CTA_Handle *husrdata, int* ierr);
00107 
00108 
00109 void usr_SP_Model_CreateFunc(){
00110 CTA_Intf hintf;
00111 CTA_Func func;
00112 
00113    CTA_Func_Create("usr_create",  usr_create,  hintf, &func);
00114    CTA_Func_Create("usr_compute", usr_compute, hintf, &func);
00115    CTA_Func_Create("usr_covar",   usr_covar,   hintf, &func);
00116    CTA_Func_Create("usr_obs",     usr_obs,     hintf, &func);
00117    CTA_Func_Create("usr_obssel",  usr_obssel,  hintf, &func);
00118 }
00119 
00120 void CREATEFUNC_F77(){
00121    usr_CreateFunc();
00122 }
00123 

Generated on Mon Apr 6 14:05:58 2009 for COSTA by  doxygen 1.5.2