cta_bb_modbuild.h

Go to the documentation of this file.
00001 /*
00002 COSTA: Problem solving environment for data assimilation
00003 Copyright (C) 2005  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_b3.h
00022 \brief Description of the COSTA blackbox component
00023 */
00024 
00025 #ifndef CTA_MODBUILD_BB_H
00026 #define CTA_MODBUILD_BB_H
00027 
00028 #include <string.h>
00029 #ifdef WIN32
00030 #include <direct.h>
00031 #endif
00032 #include "cta.h"
00033 #include "cta_system.h"
00034 #include "f_cta_utils.h"
00035 #include "cta_datatypes.h"
00036 #include "cta_model_utilities.h" 
00037 #include "cta_handles.h"
00038 #include "cta_datetime.h"
00039 
00040 #define STRING_MAX              1024                 /* maximum length of string */
00041 
00042 #define BB_ENCODING  ("utf-8")              /* XML encodiing */
00043 
00044 
00045 typedef struct BB_Variable BB_Variable;
00046 typedef BB_Variable * BB_VariablePntr;
00047 
00048 struct BB_Variable {
00049    char    *name;                            /* variable name */
00050    double   value;                           /* variable value */
00051 };
00052 
00053 typedef struct BB_Station BB_Station;
00054 typedef BB_Station * BB_StationPntr;
00055 
00056 struct BB_Station {
00057    char             *name;                   /* station name */
00058    char             *location;               /* station location */
00059    char             *filename;               /* station filename */
00060    int               nvariables;             /* station number of variables */
00061    BB_VariablePntr *variables;              /* station variables */
00062 };
00063 
00064 typedef struct BB_Forcing BB_Forcing;
00065 typedef BB_Forcing * BB_ForcingPntr;
00066 
00067 struct BB_Forcing {
00068    char    *name;                            /* forcing name */
00069    char    *file;                            /* forcing file */
00070    char    *element;                         /* forcing element */
00071    char    *property;                        /* forcing property */
00072    char    *item;                            /* forcing item */
00073    double   value;                           /* forcing value */
00074 };
00075 
00076 typedef struct BB_Parameter BB_Parameter;
00077 typedef BB_Parameter * BB_ParameterPntr;
00078 
00079 struct BB_Parameter {
00080    char    *name;                            /* parameter name */
00081    char    *file;                            /* parameter file */
00082    char    *element;                         /* parameter element */
00083    char    *property;                        /* parameter property */
00084    char    *item;                            /* parameter item */
00085    double   value;                           /* parameter value */
00086 };
00087 
00088 typedef struct BB_StateExchange BB_StateExchange;
00089 typedef BB_StateExchange * BB_StateExchangePntr;
00090 
00091 struct BB_StateExchange {
00092    char    *executable;                      /* name of blackbox executable */
00093    char    *state2model;                     /* name of input file */
00094    char    *model2state;                     /* name of output file */
00095    char    *outputSteps;                     /* output steps 'last' or 'all' */
00096    char    *state2model_file;                /* filename to write state */
00097    char    *model2state_file;                /* filename to read state */
00098    char    *initial_state_file;              /* filename containing initial state */
00099    CTA_Func state2model_func;                /* Handle to user function for writing state 2 model */
00100    CTA_Func model2state_func;                /* Handle to user function for writing model 2 state */
00101    CTA_Func initial_state_func;                /* Handle to user function for reading initial state */
00102   int      nofquantities;                    /* number of quantities == number of substates */
00103   int     quantsize;                          /* length of quantityvector */
00104   int nofdimensions;                         /* number of co-ordinate dimensions */
00105   CTA_String     *hquantid;                 /* id of each quantity */ 
00106   CTA_String     *hdimid;                 /* id of each dimension */ 
00107   int *dimlength;                        /* length of each dimension */
00108 };
00109 
00110 typedef struct BB_Model BB_Model;
00111 typedef BB_Model * BB_ModelPntr;
00112 
00113 struct BB_Model{
00114    char                   *type;             /* model type */
00115    char                   *description;      /* model description */
00116    double                  timestep;         /* simulation timestep in seconds */
00117    int                     simulationNumber; /* simulation number */
00118    char                   *workingdir;       /* working map of simulation */
00119    char                   *templatedir;      /* map with simulation template */
00120    char                   *simulationMap;    /* map with simulation results */
00121    int                     stateLength;      /* length of the state vector */
00122    int                     nstations;        /* number of stations */
00123    BB_StateExchangePntr   stateexchange;    /* pointer to the state exchange variables */
00124    BB_StationPntr        *stations;         /* pointer to the list of stations */
00125    int                     nparameters;      /* number of parameters */
00126    BB_ParameterPntr      *parameters;       /* pointer to the list of parameters */
00127    int                     nforcings;        /* number of forcings */
00128    BB_ForcingPntr        *forcings;         /* pointer to the list of forcings */
00129 };
00130 
00131 static int BB_simulationNumber=0;             // Number of the simulation         
00132 
00133 #define BB_INDEX_THIS              ( 0) /* Handle of instance               */
00134 #define BB_INDEX_TIME              ( 1) /* Time instance of model (state)   */
00135 #define BB_INDEX_STATE             ( 2) /* State vector of model            */
00136 #define BB_INDEX_FORCINGS          ( 3) /* Tree vector containing the forcings of the model */
00137 #define BB_INDEX_PARAMETERS        ( 4) /* Tree vector of model parameters */
00138 #define BB_INDEX_USERDATA          ( 5) /* Userdata */
00139 
00140 #define BB_SIZE_DATABLK            ( 6)
00141 
00142 
00143 /** \brief Create the model class of the BB Black-box builder
00144  *
00145  * \note This is not a user function. It is called at initialization of the
00146  *       COSTA environment.
00147  *
00148  *  \param modelcls  O  receives handle of the BB-modelbuilder class
00149  */
00150 
00151 void CTA_Modbuild_b3b_CreateClass(CTA_ModelClass *modelcls);
00152 
00153 #endif
00154 

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