Changeset 137


Ignore:
Timestamp:
11/17/10 14:40:14 (14 years ago)
Author:
hozdoba
Message:

mise à jour

Location:
XMLIO_V2/dev/dev_rv/src/XMLIO
Files:
1 added
19 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/NetCDF4_data_output.hpp

    r131 r137  
    2222         void writeVarData(const string& id, const Array<float, 1>& vdata) 
    2323         { 
    24             //if (!latVar->put(lats, NLAT)) 
    25             //   return NC_ERR; 
    26          } 
    27  
    28          virtual ~NetCDF4DataOutput() 
     24 
     25         } 
     26 
     27         virtual ~NetCDF4DataOutput( void) 
    2928         { if (dataFile != NULL) delete dataFile; } 
    3029 
     
    192191               hm["long_name"]     = "Latitude" ; 
    193192               hm["nav_model"]     = domid ; 
    194                if ((*itt)->yvalue.hasValue()) 
    195                { 
    196                   hmf["valid_min"] = ((Array<double, 1>)(*itt)->yvalue)(0); 
    197                   hmf["valid_max"] = ((Array<double, 1>)(*itt)->yvalue)(((Array<double, 1>)(*itt)->yvalue).size()-1); 
     193               if ((*itt)->latvalue.hasValue()) 
     194               { 
     195                  hmf["valid_min"] = ((Array<double, 1>)(*itt)->latvalue)(0); 
     196                  hmf["valid_max"] = ((Array<double, 1>)(*itt)->latvalue)(((Array<double, 1>)(*itt)->latvalue).size()-1); 
    198197                  this->addStringAttributesToVar(latVar, hmf); 
    199198                  hmf.clear(); 
     
    208207               hm["long_name"]     = "Longitude" ; 
    209208               hm["nav_model"]     = domid ; 
    210                if ((*itt)->xvalue.hasValue()) 
    211                { 
    212                   hmf["valid_min"] = ((Array<double, 1>)(*itt)->xvalue)(0); 
    213                   hmf["valid_max"] = ((Array<double, 1>)(*itt)->xvalue)(((Array<double, 1>)(*itt)->xvalue).size()-1); 
     209               if ((*itt)->lonvalue.hasValue()) 
     210               { 
     211                  hmf["valid_min"] = ((Array<double, 1>)(*itt)->lonvalue)(0); 
     212                  hmf["valid_max"] = ((Array<double, 1>)(*itt)->lonvalue)(((Array<double, 1>)(*itt)->lonvalue).size()-1); 
    214213                  this->addStringAttributesToVar(lonVar, hmf); 
    215214                  hmf.clear(); 
     
    218217               hm.clear(); 
    219218 
    220                if ((*itt)->yvalue.hasValue()) 
    221                   this->writeCoords(lonid, (*itt)->xvalue); 
     219               if ((*itt)->lonvalue.hasValue()) 
     220                  this->writeCoords(lonid, (*itt)->lonvalue); 
    222221               else throw XMLIOUndefinedValueException 
    223222                  ("Les coordonnées de longitude (xvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 
    224223 
    225                if ((*itt)->xvalue.hasValue()) 
    226                   this->writeCoords(latid, (*itt)->yvalue); 
     224               if ((*itt)->latvalue.hasValue()) 
     225                  this->writeCoords(latid, (*itt)->latvalue); 
    227226               else throw XMLIOUndefinedValueException 
    228227                  ("Les coordonnées de latitude (yvalue) ne sont pas définies pour le domaine \""+domid+"\"."); 
     
    244243               if ((*it)->long_name.hasValue())    hm["long_name"]     = (*it)->long_name ; 
    245244               if ((*it)->unit.hasValue())         hm["units"]         = (*it)->unit; 
    246                if ((*it)->value.hasValue()) 
    247                { 
    248                   hmf["valid_min"] = ((Array<double, 1>)(*it)->value)(0); 
    249                   hmf["valid_max"] = ((Array<double, 1>)(*it)->value)(((Array<double, 1>)(*it)->value).size()-1); 
     245               if ((*it)->zvalue.hasValue()) 
     246               { 
     247                  hmf["valid_min"] = ((Array<double, 1>)(*it)->zvalue)(0); 
     248                  hmf["valid_max"] = ((Array<double, 1>)(*it)->zvalue)(((Array<double, 1>)(*it)->zvalue).size()-1); 
    250249                  this->addStringAttributesToVar(othvar, hmf); 
    251250                  hmf.clear(); 
     
    254253               hm.clear(); 
    255254 
    256                if ((*it)->value.hasValue()) 
    257                   this->writeCoords(axisid, (*it)->value); 
     255               if ((*it)->zvalue.hasValue()) 
     256                  this->writeCoords(axisid, (*it)->zvalue); 
    258257               else throw XMLIOUndefinedValueException 
    259258                  ("Les coordonnées de l'axe \""+axisid+"\" (value) ne sont pas définies."); 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_output.hpp

    r126 r137  
    44namespace XMLIOSERVER 
    55{ 
    6  
    76   class CFile; 
    87 
     
    2524         } 
    2625 
    27          virtual ~AbstractDataOutput() 
     26         virtual ~AbstractDataOutput(void) 
    2827         { /* Ne rien faire de plus */ } 
    2928 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/attribut.hpp

    r128 r137  
    1717 
    1818         Attribut(void) 
    19             : BaseAttribut(), _hasValue(false) 
     19            : BaseAttribut(), _hasValue(false), value() 
    2020         { /* Ne rien faire de plus */ } 
    2121 
     
    3737         operator Ctype() const 
    3838         { 
    39             if (!_hasValue) throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !"); 
     39            if (!_hasValue) 
     40               throw XMLIOUndefinedValueException("L'attribut \"" + this->getName() + "\" est invalide !"); 
    4041            return (value) ; 
     42         } 
     43 
     44         Ctype* getValue(void) 
     45         { 
     46            //if (!_hasValue) return(NULL); // REVOIR: 4 h de debug à cause de ça !!! 
     47            return (&value); 
    4148         } 
    4249 
     
    6067 
    6168         virtual ostream& print(std::ostream & _out) const 
    62          { if (_hasValue) _out << " " << getName() << "=\"" << boolalpha << value << "\"" ; return (_out) ; } 
     69         { 
     70            if (_hasValue) 
     71            { 
     72               _out << " " << getName() 
     73                    << "=\"" << boolalpha << value << "\"" ; 
     74            } 
     75            return (_out) ; 
     76         } 
    6377 
    6478         virtual void setValue(const Ctype & value_) 
    6579         { _hasValue = true ; value = value_ ;} 
    6680 
    67          Ctype* getValue(void) 
    68          { if (!_hasValue) return(NULL); return (&value); } 
    69  
    7081         virtual void getValue(Ctype & value_) const 
    7182         { 
     
    7485         } 
    7586 
    76          virtual ~Attribut() 
     87         virtual ~Attribut(void) 
    7788         { /* Ne rien faire de plus */ } 
    7889 
     
    89100   { _hasValue = true ; value.resize(val.shape()); value = val ; } 
    90101 
    91 #define PRINT_ARRAY(type)                                             \ 
     102#define PRINT_ARRAY1(type)                                            \ 
    92103   template <>                                                        \ 
    93104      ostream& Attribut<Array<type, 1> >::print(ostream & _out) const \ 
    94105   {                                                                  \ 
    95       if (_hasValue) _out << " " << getName() << "=\"" << value(0);   \ 
    96       _out << "..." << value(value.size()-1); _out << "\"" ;          \ 
     106      if (_hasValue)                                                  \ 
     107      _out << " " << getName() << "=\"" << value(0)                   \ 
     108           << "(" << value.extent(0) << ")"                           \ 
     109           << value(value.size()-1); _out << "\"" ;                   \ 
    97110      return (_out) ;                                                 \ 
    98111   } 
    99112 
     113#define PRINT_ARRAY2(type)                                            \ 
     114   template <>                                                        \ 
     115      ostream& Attribut<Array<type, 2> >::print(ostream & _out) const \ 
     116   {                                                                  \ 
     117      if (_hasValue)                                                  \ 
     118      _out << " " << getName() << "=\"" << value(0, 0)                \ 
     119           << "(" << value.extent(0) << "," << value.extent(1) << ")" \ 
     120           << value(value.extent(0)-1, value.extent(1)-1)             \ 
     121           << "\"" ;                                                  \ 
     122      return (_out) ;                                                 \ 
     123   } 
     124 
    100125#define SET_ARRAY_TYPE(type) \ 
    101    PRINT_ARRAY(type)         \ 
     126   PRINT_ARRAY1(type)        \ 
     127   PRINT_ARRAY2(type)        \ 
    102128   SET_ARRAY_DIM(type, 1)    \ 
    103129   SET_ARRAY_DIM(type, 2)    \ 
     
    167193      void Attribut<bool>::setFromString(const std::string& str) 
    168194   { 
    169       istringstream iss(str) ; 
    170       const bool val = (! iss.str().compare(string(".TRUE."))) ? true : false; 
     195      const bool val = 
     196          (str.compare(string(".TRUE.")) == 0) ? true : false; 
    171197      this->setValue(val); 
    172198   } 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/axis_attribut.hpp

    r126 r137  
    1616         DECLARE_ATTR(unit          , string) ; 
    1717         DECLARE_ATTR(size          , int) ; 
    18          DECLARE_ATTR(value         , Array(double, 1)) ; 
     18         DECLARE_ATTR(zvalue        , Array(double, 1)) ; 
    1919 
    2020         AxisAttribut(void) : AttributRegistrar() 
     
    3030            RegisterAttribut(&unit) ; 
    3131            RegisterAttribut(&size) ; 
    32             RegisterAttribut(&value) ; 
     32            RegisterAttribut(&zvalue) ; 
    3333         } 
    3434 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp

    r134 r137  
    22 
    33/* ********************************************************** */ 
    4 /*                      CONVERSION FUNCTION                   */ 
    5 /* ********************************************************** */ 
    6  
    7 static inline std::string stringXtoStd(const XString _str) 
    8 { 
    9    char * const temp = new char[_str.len+1](); 
    10    memset(temp, '\0', _str.len+1); 
    11    memcpy(temp, _str.str, _str.len); 
    12    std::string _retstr(temp); 
    13    size_t d = _retstr.find_first_not_of(' '); 
    14    size_t f = _retstr.find_last_not_of (' '); 
    15  
    16    delete[] temp; 
    17    return (_retstr.substr(d, f-d+1)); 
    18 } 
    19  
    20 static inline XString stringXtoStd(const std::string& _str) // Non testée 
    21 { 
    22    XString _retstr = {new char[_str.size()](), _str.size()}; 
    23    memcpy(_retstr.str, _str.c_str(), _str.size()); 
    24    return (_retstr); 
    25 } 
    26  
    27 static inline Duration durationXtoXMLIO(const XDuration * const _xdur) // Non testée 
    28 { 
    29    Duration __dur= { _xdur->year, _xdur->month , _xdur->day, 
    30                      _xdur->hour, _xdur->minute, _xdur->second }; 
    31    return (__dur); 
    32 } 
    33  
    34 /* ********************************************************** */ 
    354/*                      HANDLE INTERFACE                      */ 
    365/* ********************************************************** */ 
    376 
    38 void xios_handle_create_(XHandle * const _ret, const XDType * const _dtype, const XString _id) 
    39 { 
    40    // Si le handle n'est pas initialisé à 0, on ne fait aucun traitement. 
    41    if (!isNullHandle(*_ret)) return; 
    42    std::string __id = stringXtoStd(_id); 
    43    switch(*_dtype) 
    44    { 
    45       /* EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ 
     7#define CASE_ELEM(elem_enum, elem_class)                    \ 
     8         case (E##elem_enum):                               \ 
     9            *_ret = (!C##elem_class::HasObject(__id)) ?     \ 
     10               0 : C##elem_class::GetObject(__id);          \ 
     11            return;                                         \ 
     12         case (G##elem_enum):                               \ 
     13            *_ret = (!elem_class##Group::HasObject(__id)) ? \ 
     14               0 : elem_class##Group::GetObject(__id);      \ 
     15            return; 
     16 
     17void xios_handle_create (XPtr * const _ret, XDType _dtype, 
     18                         const XString _id, XSize _id_len) 
     19{ 
     20   MAKE_STRING(__id, _id, _id_len); 
     21   switch(_dtype) 
     22   { 
    4623      case (ECONTEXT): 
    4724         // Si le context n'existe pas, on retourne un handle vide/nul. 
    48          if (!Context::HasContext(__id)) { *_ret = NULLHANDLE; return ; } 
    49          _ret->data_type = *_dtype; 
    50          _ret->data_ptr  = Context::GetContext(__id); 
     25         *_ret = (!Context::HasContext(__id)) ? 0 : Context::GetContext(__id) ; 
    5126         return ; 
    52  
     27      CASE_ELEM(AXIS   , Axis); 
     28      CASE_ELEM(DOMAIN , Domain); 
     29      CASE_ELEM(FIELD  , Field); 
     30      CASE_ELEM(FILE   , File); 
     31      CASE_ELEM(GRID   , Grid); 
    5332      default : 
    54          *_ret = NULLHANDLE; 
     33         *_ret = 0; 
    5534         return ; 
    5635   }; 
    5736} 
    5837 
     38#undef CASE_ELEM 
     39 
    5940/* ********************************************************** */ 
    6041/*                      XML INTERFACE                         */ 
    6142/* ********************************************************** */ 
    6243 
    63 void xios_xml_parse_file_(const XString _filename) 
    64 { 
    65    std::string   __filename = stringXtoStd(_filename); 
     44void xios_xml_parse_file(const XString _filename, XSize _filename_len) 
     45{ 
     46   MAKE_STRING(__filename, _filename, _filename_len); 
    6647   std::ifstream __istr( __filename.c_str() , std::ifstream::in ); 
    6748 
    6849   // On commence la lecture du flux de donnée xml. 
    6950   XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 
    70  
    7151   // On parse le fichier xml noeud par noeud 
    7252   // (ie on construit dynamiquement notre arbre d'objets). 
    7353   XMLParser::Parse(node); 
    74 } 
    75  
    76 void xios_xml_parse_string_(const XString _xmlcontent) 
    77 { 
    78    std::string        __xmlcontent = stringXtoStd(_xmlcontent); 
     54 
     55} 
     56 
     57void xios_xml_parse_string(const XString _xmlcontent, XSize _xmlcontent_len) 
     58{ 
     59   MAKE_STRING(__xmlcontent, _xmlcontent, _xmlcontent_len); 
    7960   std::istringstream __istr(__xmlcontent); 
    8061 
    8162   // On commence la lecture du flux de donnée xml. 
    8263   XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); 
    83  
    84    // On parse le fichier xml noeud par noeud 
    85    // (ie on construit dynamiquement notre arbre d'objets). 
     64   // On parse le document xml noeud par noeud 
    8665   XMLParser::Parse(node); 
    8766} 
    88  
    89 /* ********************************************************** */ 
    90 /*                      DATA TREATMENT INTERFACE              */ 
    91 /* ********************************************************** */ 
    92  
     67/* ********************************************************** */ 
     68/*                      CONTEXT INTERFACE                     */ 
     69/* ********************************************************** */ 
     70 
     71void xios_context_set_current (XPtr _ctx, bool _wswap) 
     72{ 
     73   Context* const __ctxt = (Context*) _ctx; 
     74   Context::SetCurrentContext(__ctxt->getId(), _wswap) ; 
     75} 
     76 
     77void xios_context_create (XPtr * _ctx, const XString _ctx_id, 
     78                          XSize _ctx_id_len, XCalendarType _calType) 
     79{ 
     80   MAKE_STRING(__ctx_id, _ctx_id, _ctx_id_len); 
     81   // si le contexte existe déjà, on arrête le traitement. 
     82   if (Context::HasContext(__ctx_id)) { _ctx = NULL; return ; } 
     83 
     84   Context::SetCurrentContext(__ctx_id, false, false); 
     85   Context * context = Context::CreateObject(__ctx_id); 
     86   context->createDefinitions(); *_ctx = context; 
     87 
     88   if (!Context::HasContext(__ctx_id)) // Au cas où ... 
     89      std::cerr << "La création du contexte a échoué ???" << std::endl; 
     90 
     91   switch(_calType) 
     92   { 
     93      case (D360) : 
     94         context->setCalendar(new D360Calendar());      return; 
     95      case (ALLLEAP) : 
     96         context->setCalendar(new AllLeapCalendar());   return; 
     97      case (NOLEAP) : 
     98         context->setCalendar(new NoLeapCalendar());    return; 
     99      case (JULIAN) : 
     100         context->setCalendar(new JulianCalendar());    return; 
     101      case (GREGORIAN) : 
     102         context->setCalendar(new GregorianCalendar()); return; 
     103      default: 
     104         std::cerr << "[context_create] Type de calendrier invalide [0-5]" << std::endl; 
     105         return; 
     106   } 
     107} 
     108 
     109/* ********************************************************** */ 
     110/*                    XML TREE INTERFACE                      */ 
     111/* ********************************************************** */ 
     112 
     113#define CASE_ELEM0(elem_enum, elem_class, group_enum, group_class)              \ 
     114      case (group_enum) : {                                                     \ 
     115         group_class * _group = (group_class *) _parent;                        \ 
     116         switch(_child_type) {                                                  \ 
     117            case (group_enum) :                                                 \ 
     118               if ((_child_id_len != -1) &&                                     \ 
     119                   (group_class::HasObject(___child_id))) return;               \ 
     120               *_child = (_child_id_len != -1)                                  \ 
     121                       ? (group_class *)(&_group->createGroup(___child_id))     \ 
     122                       : (group_class *)(&_group->createGroup());               \ 
     123               break;                                                           \ 
     124            case (elem_enum) :                                                  \ 
     125               if ((_child_id_len != -1) &&                                     \ 
     126                   (elem_class::HasObject(___child_id))) return;                \ 
     127               *_child = (_child_id_len != -1)                                  \ 
     128                       ? (elem_class *)(&_group->createChild(___child_id))      \ 
     129                       : (elem_class *)(&_group->createChild());                \ 
     130               break;                                                           \ 
     131            default :                                                           \ 
     132               std::cerr << "[xml_tree_add] Type enfant invalide" << std::endl; \ 
     133         }; return; } 
     134 
     135void xios_xml_tree_add (const XPtr _parent, XDType _parent_type, XPtr * _child, 
     136                        XDType _child_type, const XString _child_id, XSize _child_id_len) 
     137{ 
     138   string ___child_id; 
     139   if (_child_id_len != -1) 
     140   { 
     141      MAKE_STRING(__child_id, _child_id, _child_id_len); 
     142      ___child_id = __child_id; 
     143   } 
     144 
     145   switch (_parent_type) 
     146   { 
     147      case (EFILE) : 
     148      { 
     149         CFile * _file = (CFile *) _parent; 
     150         FieldGroup * _field_group = _file->createVirtualFieldGroup(_file->getId()); 
     151         xios_xml_tree_add (_field_group, GFIELD, _child, _child_type, _child_id, _child_id_len); 
     152         return; 
     153      } 
     154      CASE_ELEM0(EAXIS, CAxis, GAXIS, AxisGroup); 
     155      CASE_ELEM0(EGRID, CGrid, GGRID, GridGroup); 
     156      CASE_ELEM0(EDOMAIN, CDomain, GDOMAIN, DomainGroup); 
     157      CASE_ELEM0(EFIELD, CField, GFIELD, FieldGroup); 
     158      CASE_ELEM0(EFILE, CFile, GFILE, FileGroup); 
     159      default : 
     160         std::cerr << "[xml_tree_add] Type parent invalide" << std::endl; 
     161         return; 
     162   } 
     163} 
     164 
     165#undef CASE_ELEM0 
     166 
     167void xios_xml_tree_show(const XString _filename, XSize _filename_len) 
     168{ 
     169   string ___filename; 
     170   if (_filename_len != -1) 
     171   { 
     172      MAKE_STRING(__filename, _filename, _filename_len); 
     173      ___filename = __filename; 
     174   } 
     175   if (_filename_len == -1) 
     176      // On écrit l'arborescence résultante du traitement sur la sortie de log. 
     177      Context::ShowTree(std::clog); 
     178   else 
     179   { 
     180      std::ofstream __outfile (___filename.c_str()); 
     181      // On écrit l'arborescence résultante du traitement dans le fichier. 
     182      Context::ShowTree(__outfile); 
     183      __outfile.close(); 
     184   } 
     185} 
     186 
     187#undef XML_SET 
     188#undef XML_SET_STRING 
     189 
     190#define XML_SET(ttype, type, type_var, var, long_var)                 \ 
     191   void xios_xml_set_##type##_##var                                   \ 
     192                  (XPtr const _##type, XDType _dtype, type_var var){  \ 
     193      if (_dtype >= 10 && _dtype <= 14) {                             \ 
     194         ttype##Group * __##type = (ttype##Group *) _##type;          \ 
     195         __##type->set_##long_var(var);                               \ 
     196      } else {                                                        \ 
     197         C##ttype * __##type = (C##ttype *) _##type;                  \ 
     198         __##type->set_##long_var(var);                               \ 
     199   }} 
     200 
     201 
     202#define XML_SET_STRING(ttype, type, var, long_var)              \ 
     203   void xios_xml_set_##type##_##var(XPtr const _##type,         \ 
     204      XDType _dtype, const XString _##var, XSize _##var##_len) {\ 
     205      MAKE_STRING(___##var, _##var, _##var##_len);              \ 
     206      if (_dtype >= 10 && _dtype <= 14) {                       \ 
     207         ttype##Group * __##type = (ttype##Group *) _##type;    \ 
     208         __##type->set_##long_var(___##var);                    \ 
     209      } else {                                                  \ 
     210         C##ttype * __##type = (C##ttype *) _##type;            \ 
     211         __##type->set_##long_var(___##var);                    \ 
     212   }} 
     213 
     214// Attributs de field ou field_group // 
     215XML_SET_STRING(Field, field, name, name) 
     216XML_SET_STRING(Field, field, sname, standard_name) 
     217XML_SET_STRING(Field, field, lname, long_name) 
     218XML_SET_STRING(Field, field, unit, unit) 
     219XML_SET_STRING(Field, field, operation, operation) 
     220 
     221void xios_xml_set_field_freq_op(XPtr const _field, XDType _dtype, 
     222                                double year, double month, double day, 
     223                                double hour, double minute, double second) 
     224{ 
     225   const Duration _dur   = {year, month, day, hour, minute, second}; 
     226   if (_dtype >= 10 && _dtype <= 14) 
     227   { 
     228      FieldGroup * __field = (FieldGroup *) _field; 
     229      __field->set_freq_op(_dur); 
     230   } else { 
     231      CField * __field = (CField *) _field; 
     232      __field->set_freq_op(_dur); 
     233   } 
     234} 
     235 
     236XML_SET(Field, field, int, level, level) 
     237XML_SET(Field, field, int, prec, prec) 
     238XML_SET(Field, field, bool, enabled, enabled) 
     239 
     240XML_SET_STRING(Field, field, dref, domain_ref) 
     241XML_SET_STRING(Field, field, aref, axis_ref) 
     242XML_SET_STRING(Field, field, gref, grid_ref) 
     243XML_SET_STRING(Field, field, zref, zoom_ref) 
     244XML_SET_STRING(Field, field, fref, field_ref) 
     245 
     246// Attributs de file ou file_group 
     247XML_SET_STRING(File, file, name, name) 
     248XML_SET_STRING(File, file, description, description) 
     249 
     250void xios_xml_set_file_output_freq(XPtr const _file, XDType _dtype, 
     251                                   double year, double month, double day, 
     252                                   double hour, double minute, double second) 
     253{ 
     254   const Duration _dur   = {year, month, day, hour, minute, second}; 
     255   if (_dtype >= 10 && _dtype <= 14) 
     256   { 
     257      FileGroup * __file = (FileGroup *) _file; 
     258      __file->set_output_freq(_dur); 
     259   } else { 
     260      CFile * __file= (CFile *) _file; 
     261      __file->set_output_freq(_dur); 
     262   } 
     263} 
     264 
     265XML_SET(File, file, int, olevel, output_level) 
     266XML_SET(File, file, bool, enabled, enabled) 
     267 
     268// Attributs de grid ou grid_group 
     269XML_SET_STRING(Grid, grid, name, name) 
     270XML_SET_STRING(Grid, grid, description, description) 
     271XML_SET_STRING(Grid, grid, dref, domain_ref) 
     272XML_SET_STRING(Grid, grid, aref, axis_ref) 
     273 
     274// Attribut de axis ou axis group 
     275XML_SET_STRING(Axis, axis, name, name) 
     276XML_SET_STRING(Axis, axis, sname, standard_name) 
     277XML_SET_STRING(Axis, axis, lname, long_name) 
     278 
     279XML_SET_STRING(Axis, axis, unit, unit) 
     280 
     281void xios_xml_set_axis_value(XPtr const _axis, XDType _dtype, double value[], XSize value_size) 
     282{ 
     283   Array<double, 1> __arr(value, shape(value_size), neverDeleteData, FortranArray<1>()); 
     284   if (_dtype >= 10 && _dtype <= 14) 
     285   { 
     286      AxisGroup * __axis = (AxisGroup *) _axis; 
     287      __axis->set_size(value_size); 
     288      __axis->zvalue.getValue()->resize(value_size); 
     289      __axis->set_zvalue(__arr); 
     290   } else { 
     291      CAxis * __axis = (CAxis *) _axis; 
     292      __axis->set_size(value_size); 
     293      __axis->zvalue.getValue()->resize(value_size); 
     294      __axis->set_zvalue(__arr); 
     295   } 
     296} 
     297 
     298// Attribut de domain ou domain_group 
     299XML_SET_STRING(Domain, domain, name, name) 
     300XML_SET_STRING(Domain, domain, sname, standard_name) 
     301XML_SET_STRING(Domain, domain, lname, long_name) 
     302 
     303XML_SET(Domain, domain, int, niglo, ni_glo) 
     304XML_SET(Domain, domain, int, njglo, nj_glo) 
     305 
     306XML_SET(Domain, domain, int, ibegin, ibegin) 
     307XML_SET(Domain, domain, int, iend, iend) 
     308XML_SET(Domain, domain, int, ni, ni) 
     309 
     310XML_SET(Domain, domain, int, jbegin, jbegin) 
     311XML_SET(Domain, domain, int, jend, jend) 
     312XML_SET(Domain, domain, int, nj, nj) 
     313 
     314void xios_xml_set_domain_mask(XPtr const _domain, XDType _dtype, bool * _mask , XSize _maskXsize, XSize _maskYsize) 
     315{ 
     316   Array<bool, 2> __arr(_mask, shape(_maskXsize, _maskYsize), neverDeleteData, FortranArray<2>()); 
     317   if (_dtype >= 10 && _dtype <= 14) 
     318   { 
     319      DomainGroup * __domain = (DomainGroup *) _domain; 
     320      __domain->mask.getValue()->resize(shape(_maskXsize, _maskYsize)); 
     321      __domain->set_mask(__arr); 
     322   } else { 
     323      CDomain * __domain = (CDomain *) _domain; 
     324      __domain->mask.getValue()->resize(shape(_maskXsize, _maskYsize)); 
     325      __domain->set_mask(__arr); 
     326   } 
     327 
     328} 
     329 
     330XML_SET(Domain, domain, int, ddim, data_dim) 
     331XML_SET(Domain, domain, int, dni, data_ni) 
     332XML_SET(Domain, domain, int, dnj, data_nj) 
     333XML_SET(Domain, domain, int, dibegin, data_ibegin) 
     334XML_SET(Domain, domain, int, djbegin, data_jbegin) 
     335 
     336XML_SET(Domain, domain, int, dnindex, data_n_index) 
     337 
     338void xios_xml_set_domain_diindex(XPtr const _domain, XDType _dtype, int _diindex[], XSize _diindex_size) 
     339{ 
     340   Array<int, 1> __arr(_diindex, shape(_diindex_size), neverDeleteData, FortranArray<1>()); 
     341   if (_dtype >= 10 && _dtype <= 14) 
     342   { 
     343      DomainGroup * __domain = (DomainGroup *) _domain; 
     344      __domain->data_i_index.getValue()->resize(_diindex_size); 
     345      __domain->set_data_i_index(__arr); 
     346   } else { 
     347      CDomain * __domain = (CDomain *) _domain; 
     348      __domain->data_i_index.getValue()->resize(_diindex_size); 
     349      __domain->set_data_i_index(__arr); 
     350   } 
     351} 
     352 
     353void xios_xml_set_domain_djindex(XPtr const _domain, XDType _dtype, int _djindex[], XSize _djindex_size) 
     354{ 
     355   Array<int, 1> __arr(_djindex, shape(_djindex_size), neverDeleteData, FortranArray<1>()); 
     356   if (_dtype >= 10 && _dtype <= 14) 
     357   { 
     358      DomainGroup * __domain = (DomainGroup *) _domain; 
     359      __domain->data_j_index.getValue()->resize(_djindex_size); 
     360      __domain->set_data_j_index(__arr); 
     361   } else { 
     362      CDomain * __domain = (CDomain *) _domain; 
     363      __domain->data_j_index.getValue()->resize(_djindex_size); 
     364      __domain->set_data_j_index(__arr); 
     365   } 
     366} 
     367 
     368void xios_xml_set_domain_lonvalue(XPtr const _domain, XDType _dtype, double _lonvalue[], XSize _lonvalue_Xsize, XSize _lonvalue_Ysize) 
     369{ 
     370   XSize __size = (_lonvalue_Ysize == -1) 
     371                  ? _lonvalue_Xsize : (_lonvalue_Ysize*_lonvalue_Xsize); 
     372   Array<double, 1> __arr(_lonvalue, shape(__size), neverDeleteData, FortranArray<1>()); 
     373   if (_dtype >= 10 && _dtype <= 14) 
     374   { 
     375      DomainGroup * __domain = (DomainGroup *) _domain; 
     376      __domain->lonvalue.getValue()->resize(__size); 
     377      __domain->set_lonvalue(__arr); 
     378   } else { 
     379      CDomain * __domain = (CDomain *) _domain; 
     380      __domain->lonvalue.getValue()->resize(__size); 
     381      __domain->set_lonvalue(__arr); 
     382   } 
     383} 
     384 
     385void xios_xml_set_domain_latvalue(XPtr const _domain, XDType _dtype, double _latvalue[], XSize _latvalue_Xsize, XSize _latvalue_Ysize) 
     386{ 
     387   XSize __size = (_latvalue_Ysize == -1) 
     388                  ? _latvalue_Xsize : (_latvalue_Ysize*_latvalue_Xsize); 
     389   Array<double, 1> __arr(_latvalue, shape(__size), neverDeleteData, FortranArray<1>()); 
     390   if (_dtype >= 10 && _dtype <= 14) 
     391   { 
     392      DomainGroup * __domain = (DomainGroup *) _domain; 
     393      __domain->latvalue.getValue()->resize(__size); 
     394      __domain->set_latvalue(__arr); 
     395   } else { 
     396      CDomain * __domain = (CDomain *) _domain; 
     397      __domain->latvalue.getValue()->resize(__size); 
     398      __domain->set_latvalue(__arr); 
     399   } 
     400} 
     401 
     402XML_SET_STRING(Domain, domain, domtype, domtype) 
     403 
     404/* ********************************************************** */ 
     405/*                   DATA TREATMENT INTERFACE                 */ 
     406/* ********************************************************** */ 
    93407static std::vector<DataTreatment *> AllDataTreatment; 
    94408 
     
    101415} 
    102416 
    103 void xios_dtreatment_new_(XHandle * const _dt, const XHandle * const _hd) 
     417void xios_dtreatment_start(XPtr const _context, XFileType filetype) 
    104418{ 
    105419   static bool called = false; 
    106  
    107    // Si le handle de traitement n'est pas initialisé à 0, on ne fait aucun traitement. 
    108    if (!isNullHandle(*_dt) || (_hd->data_type != ECONTEXT)) return; 
    109    Context       * const __ctxt = (Context*) _hd->data_ptr; 
     420   Context       * const __ctxt = (Context *) _context; 
    110421   DataTreatment * const __dtrt =__ctxt->setDataTreatment<DataTreatment>(); 
    111  
    112422   if (__dtrt != NULL) 
    113423   { 
    114424      AllDataTreatment.push_back(__dtrt); 
    115       _dt->data_type = DTREATMENT; 
    116       _dt->data_ptr  = __dtrt; 
    117425      if (!called) 
    118426      { 
     
    123431} 
    124432 
    125 void xios_dtreatment_create_files_and_headers_(const XHandle * const _hd, const XFileType * const _ft) 
    126 { 
    127    if (isNullHandle(*_hd) || (_hd->data_type != DTREATMENT)) return; 
    128    DataTreatment * const __dt = (DataTreatment*)_hd->data_ptr; 
    129    switch(*_ft) 
    130    { 
    131       case (NETCDF4): 
    132          __dt->createDataOutput<NetCDF4DataOutput>(); 
    133          return; 
    134       // Autres formats de fichiers si disponibles... 
    135       default: 
    136          return; 
    137    } 
    138 } 
    139  
    140 /* ********************************************************** */ 
    141 /*                      CONTEXT INTERFACE                     */ 
    142 /* ********************************************************** */ 
    143  
    144 void xios_context_set_current_(const XHandle * const _ctxt, const bool * const _wswap) 
    145 { 
    146    bool __wswap = (_wswap == NULL) ? false : *_wswap; 
    147    if (isNullHandle(*_ctxt) || (_ctxt->data_type != ECONTEXT)) return; 
    148    Context* const __ctxt = (Context*) _ctxt->data_ptr; 
    149    Context::SetCurrentContext(__ctxt->getId(), __wswap) ; 
    150 } 
    151  
    152 void xios_context_get_current_ (XHandle * _ctxt) 
    153 { 
    154    // Si le handle de traitement n'est pas initialisé à 0, on ne fait aucun traitement. 
    155    if ((Context::GetAllListObject().size() == 0) || 
    156          !isNullHandle(*_ctxt)) return; 
    157    _ctxt->data_type = ECONTEXT; 
    158    _ctxt->data_ptr  = Context::GetCurrentContext(); 
    159 } 
    160  
    161 void xios_context_get_calendar_(const XHandle * const _ctxt, XHandle * _cal) 
    162 { 
    163    if (!isNullHandle(*_cal)  || isNullHandle(*_ctxt) || 
    164       (_ctxt->data_type != ECONTEXT)) return; 
    165    Context* const __ctxt = (Context*) _ctxt->data_ptr; 
    166    AbstractCalendar * const __cal  = __ctxt->getCalendar(); 
    167    if (__cal != NULL) 
    168    { 
    169       _cal->data_type = CALENDAR; 
    170       _cal->data_ptr  = __cal; 
    171    } 
    172 } 
    173  
    174 /* ********************************************************** */ 
    175 /*                      CALENDAR INTERFACE                    */ 
    176 /* ********************************************************** */ 
    177  
    178 void xios_calendar_set_timestep_(const XHandle * const _cal, const XDuration * const _dur) 
    179 { 
    180    if (isNullHandle(*_cal) || (_cal->data_type != CALENDAR)) return; 
    181    const Duration __dur = durationXtoXMLIO(_dur); 
    182    AbstractCalendar * const __cal = (AbstractCalendar*) _cal->data_ptr; 
    183    __cal->setTimeStep(__dur); 
    184 } 
    185  
     433#undef XML_SET 
     434#undef XML_SET_STRING 
    186435#undef isNullHandle 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.hpp

    r134 r137  
    77using namespace XMLIOSERVER::XML; 
    88 
     9typedef long int XInt, XSize; // Integer 
     10typedef bool     XBool;       // Logical 
     11typedef void   * XPtr;        // Pointeur C non typé 
     12typedef char   * XString;     // Pointeur C non typé 
     13 
     14typedef enum 
     15{ 
     16   NOTYPE = 0, 
     17   DTREATMENT/* UNUSED */, DATE, CALENDAR, ECONTEXT, 
     18   EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, 
     19   GAXIS, GDOMAIN, GFIELD, GFILE, GGRID 
     20} XDType; 
     21 
     22typedef enum 
     23{ 
     24   NETCDF4 = 0 
     25} XFileType; 
     26 
     27typedef enum 
     28 { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ; 
     29 
     30typedef struct // Référence C à une objet de la bibliothÚque. 
     31{ XDType data_type; XPtr data_ptr; } XHandle; 
     32 
     33#define MAKE_STRING(var_name, str_arg, int_arg)             \ 
     34      std::string var_name##temp;                           \ 
     35      var_name##temp.append (str_arg, int_arg);             \ 
     36      size_t d = var_name##temp.find_first_not_of(' ');     \ 
     37      size_t f = var_name##temp.find_last_not_of (' ');     \ 
     38      std::string var_name = var_name##temp.substr(d, f-d+1) 
     39 
     40#define XML_SET(type, type_var, var, long_var) \ 
     41   void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, type_var var) 
     42 
     43#define XML_SET_STRING(type, var, long_var) \ 
     44   void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, const XString _##var, XSize _##var##_len) 
     45 
    946#ifdef __cplusplus 
    1047extern"C" 
     
    1249#endif //__cplusplus 
    1350 
    14    typedef long int XInt; // Integer 
    15    typedef bool     XBool;// Logical 
    16    typedef void    *XPtr; // Pointeur C non typé 
     51/* ******************** HANDLE INTERFACE ******************** */ 
     52void xios_handle_create (XPtr * const _ret, XDType _dtype, const XString _id, XSize _id_len); 
    1753 
    18    typedef enum _datatype 
    19    { 
    20       NOTYPE = 0, 
    21       DTREATMENT, DATE, CALENDAR, ECONTEXT, 
    22       EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, 
    23       GAXIS, GDOMAIN, GFIELD, GFILE, GGRID 
    24    } XDType; 
     54/* ******************** XML INTERFACE *********************** */ 
     55void xios_xml_parse_file  (const XString _filename, XSize _filename_len); 
     56void xios_xml_parse_string(const XString _xmlcontent, XSize _xmlcontent_len); 
    2557 
    26    typedef enum _filetype 
    27    { 
    28       NETCDF4 = 0 
    29    } XFileType; 
     58/* ******************** CONTEXT INTERFACE ******************* */ 
     59void xios_context_set_current (XPtr const _ctx, bool _wswap); 
     60void xios_context_create (XPtr * _ctx, const XString _ctx_id, XSize _ctx_id_len, XCalendarType _calType); 
    3061 
    31    typedef struct _handle // Référence C à une objet de la bibliothÚque. 
    32    { XDType data_type; XPtr data_ptr; } XHandle; 
     62/* ******************  XML TREE INTERFACE ******************* */ 
     63void xios_xml_tree_add(const XPtr _parent, XDType _parent_type, XPtr * _child, 
     64                       XDType _child_type, const XString _child_id, XSize _child_id_len); 
     65void xios_xml_tree_show(const XString _filename, XSize _filename_len); 
    3366 
    34    typedef struct _string // Chaîne de caractÚres. 
    35    { char * str; int len;  } XString; 
     67// Attributs de field ou field_group 
     68XML_SET_STRING(field, name, name); 
     69XML_SET_STRING(field, sname, standard_name); 
     70XML_SET_STRING(field, lname, long_name); 
     71XML_SET_STRING(field, unit, unit); 
     72XML_SET_STRING(field, operation, operation); 
    3673 
    37    typedef struct _ymdhms_int 
    38    { int year, month, day, hour, minute, second; } XDate; 
     74void xios_xml_set_field_freq_op(XPtr const _field, XDType _dtype, 
     75                                 double year, double month, double day, 
     76                                 double hour, double minute, double second); 
    3977 
    40     typedef struct _ymdhms_double 
    41    { double year, month, day, hour, minute, second; } XDuration; 
     78XML_SET(field, int, level, level); 
     79XML_SET(field, int, prec, prec); 
     80XML_SET(field, bool, enabled, enabled); 
    4281 
    43    const XHandle NULLHANDLE = { NOTYPE, NULL }; 
     82XML_SET_STRING(field, dref, domain_ref); 
     83XML_SET_STRING(field, aref, axis_ref); 
     84XML_SET_STRING(field, gref, grid_ref); 
     85XML_SET_STRING(field, zref, zoom_ref); 
     86XML_SET_STRING(field, fref, field_ref); 
    4487 
    45 #define isNullHandle(hdl) \ 
    46    ((hdl).data_type == NOTYPE && (hdl).data_ptr == NULL) 
     88// Attributs de file ou file_group 
     89XML_SET_STRING(file, name, name) ; 
     90XML_SET_STRING(file, description, description); 
     91void xios_xml_set_file_output_freq(XPtr const _file, XDType _dtype, 
     92                                   double year, double month, double day, 
     93                                   double hour, double minute, double second); 
    4794 
    48    /* ******************** HANDLE INTERFACE ******************** */ 
    49    void xios_handle_create_ (XHandle * const _ret, const XDType * const _dtype, const XString _id); 
     95XML_SET(file, int, olevel, output_level); 
     96XML_SET(file, bool, enabled, enabled); 
    5097 
    51    /* ******************** XML INTERFACE *********************** */ 
    52    void xios_xml_parse_file_  (const XString _filename); 
    53    void xios_xml_parse_string_(const XString _xmlcontent); 
     98// Attributs de grid ou grid_group 
     99XML_SET_STRING(grid, name, name) ; 
     100XML_SET_STRING(grid, description, description) ; 
     101XML_SET_STRING(grid, dref, domain_ref) ; 
     102XML_SET_STRING(grid, aref, axis_ref) ; 
    54103 
    55    /* ******************** DATA TREATMENT INTERFACE ************ */ 
    56    void xios_dtreatment_new_(XHandle * const _dt, const XHandle * const _hd); 
    57    void xios_dtreatment_create_files_and_headers_(const XHandle * const _hd, const XFileType * const _ft); 
     104// Attribut de axis ou axis_group 
     105XML_SET_STRING(axis, name, name) ; 
     106XML_SET_STRING(axis, sname, standard_name) ; 
     107XML_SET_STRING(axis, lname, long_name) ; 
    58108 
    59    /* ******************** CONTEXT INTERFACE ******************* */ 
    60    void xios_context_set_current_ (const XHandle * const _ctxt, const bool * const _wswap); 
    61    void xios_context_get_current_ (XHandle * _ctxt); 
    62    void xios_context_get_calendar_(const XHandle * const _ctxt, XHandle * _cal); 
    63    ///  void xios_context_ShowTree_  (void); 
     109XML_SET_STRING(axis, unit, unit) ; 
    64110 
    65    /* ******************** CALENDAR INTERFACE ****************** */ 
    66    void xios_calendar_set_timestep_(const XHandle * const _cal, const XDuration * const _dur); 
     111void xios_xml_set_axis_value(XPtr const _file, XDType _dtype, double value[], XSize value_size); 
     112 
     113 
     114// Attribut de domain ou domain_group 
     115XML_SET_STRING(domain, name, name) ; 
     116XML_SET_STRING(domain, sname, standard_name) ; 
     117XML_SET_STRING(domain, lname, long_name) ; 
     118 
     119XML_SET(domain, int, niglo, ni_glo); 
     120XML_SET(domain, int, njglo, nj_glo); 
     121 
     122XML_SET(domain, int, ibegin, ibegin); 
     123XML_SET(domain, int, iend, iend); 
     124XML_SET(domain, int, ni, ni); 
     125 
     126XML_SET(domain, int, jbegin, jbegin); 
     127XML_SET(domain, int, jend, jend); 
     128XML_SET(domain, int, nj, nj); 
     129 
     130void xios_xml_set_domain_mask(XPtr const _domain, XDType _dtype, bool * _mask , XSize _maskXsize, XSize _maskYsize); 
     131 
     132XML_SET(domain, int, ddim, data_dim); 
     133XML_SET(domain, int, dni, data_ni); 
     134XML_SET(domain, int, dnj, data_nj); 
     135XML_SET(domain, int, dibegin, data_ibegin); 
     136XML_SET(domain, int, djbegin, data_jbegin); 
     137 
     138XML_SET(domain, int, dnindex, data_n_index); 
     139 
     140void xios_xml_set_domain_diindex(XPtr const _domain, XDType _dtype, int _diindex[], XSize _diindex_size); 
     141void xios_xml_set_domain_djindex(XPtr const _domain, XDType _dtype, int _djindex[], XSize _djindex_size); 
     142 
     143void xios_xml_set_domain_lonvalue(XPtr const _domain, XDType _dtype, double _lonvalue[], XSize _lonvalue_Xsize, XSize _lonvalue_Ysize); 
     144void xios_xml_set_domain_latvalue(XPtr const _domain, XDType _dtype, double _latvalue[], XSize _latvalue_Xsize, XSize _latvalue_Ysize); 
     145 
     146XML_SET_STRING(domain, domtype, domtype) ; 
     147 
     148/* ******************  DATA TREATMENT INTERFACE ******************* */ 
     149void xios_dtreatment_start(XPtr const _context, XFileType filetype); 
    67150 
    68151#ifdef __cplusplus 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp

    r134 r137  
    2323         { /* Ne rien faire de plus */ } 
    2424 
     25         bool createDefinitions(void) 
     26         { 
     27            if (hasChild()) return false; 
     28            this->fieldDef  = 
     29               (FieldDefinition*) FieldDefinition ::CreateObject(FieldDefinition ::GetDefName()); 
     30            this->fileDef   = 
     31               (FileDefinition*)  FileDefinition  ::CreateObject(FileDefinition  ::GetDefName()); 
     32            this->axisDef   = 
     33               (AxisDefinition*)  AxisDefinition  ::CreateObject(AxisDefinition  ::GetDefName()); 
     34            this->gridDef   = 
     35               (GridDefinition*)  GridDefinition  ::CreateObject(GridDefinition  ::GetDefName()); 
     36            this->domainDef = 
     37               (DomainDefinition*)DomainDefinition::CreateObject(DomainDefinition::GetDefName()); 
     38            return (true); 
     39         } 
     40 
    2541          FieldDefinition * getFieldDefinition (void) const { return (this->fieldDef ); } 
    2642           FileDefinition * getFileDefinition  (void) const { return (this->fileDef  ); } 
     
    3147         AbstractCalendar * getCalendar     (void) const { return (ccalendar ); } 
    3248         DataTreatment    * getDataTreatment(void) const { return (dtreatment); } 
     49 
     50         AbstractCalendar * setCalendar(AbstractCalendar * const _cal) { return (ccalendar = _cal);} 
    3351 
    3452         AbstractCalendar * setCalendar(const string& _calName, const string& _dateStr) 
     
    82100            else 
    83101            { 
    84               do { // Parcours des contexts pour traitement. 
     102              do { // Parcours des contextes pour traitement. 
    85103 
    86104                  string name = _node.getElementName(); 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/declare_attribut.hpp

    r131 r137  
    2626                                                                                    \ 
    2727   const Attr_##att_name& getAttr_##att_name(void) const { return (att_name); }     \ 
    28    const Attr_##att_name& get_##att_name(void)     const { return (att_name); }     \ 
    29                                                                                     \ 
    30    void setAttr##att_name(const Attr_##att_name& _newattr) { att_name = _newattr; } \ 
    31    void set_##att_name   (const Attr_##att_name& _newattr) { att_name = _newattr; }\ 
    32                                                                                     \ 
    33    void setAttr##att_name(const att_type& _newattr) { att_name.setValue(_newattr); }\ 
    34    void set_##att_name   (const att_type& _newattr) { att_name.setValue(_newattr); }\ 
     28   void set_##att_name (const Attr_##att_name& _newattr) { att_name = _newattr; }   \ 
     29   void set_##att_name (const att_type& _newattr) { att_name.setValue(_newattr); }  \ 
    3530                                                                                    \ 
    3631   Attr_##att_name att_name 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/declare_group.hpp

    r127 r137  
    2727      typedef child_type##Group child_type##Definition;                    \ 
    2828   } 
    29  
    3029#endif // __DECLARE_GROUP__ 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/domain.hpp

    r125 r137  
    1111      public: 
    1212 
    13          CDomain(void) : ObjectTemplate<CDomain>(), DomainAttribut() 
    14          { /* Ne rien faire de plus */ } 
    15          CDomain(const string& _id) : ObjectTemplate<CDomain>(_id), DomainAttribut() 
     13         CDomain(void) 
     14            : ObjectTemplate<CDomain>(), DomainAttribut() 
    1615         { /* Ne rien faire de plus */ } 
    1716 
    18          static string GetName(void) {return ("domain"); } 
     17         CDomain(const string& _id) 
     18            : ObjectTemplate<CDomain>(_id), DomainAttribut() 
     19         { /* Ne rien faire de plus */ } 
     20 
     21         static string GetName(void)    { return ("domain"); } 
    1922         static string GetDefName(void) { return (CDomain::GetName()); } 
    2023 
    2124         inline void check(void) ; 
    2225 
    23          ~CDomain(void) { /* Ne rien faire de plus */ } 
     26         ~CDomain(void) 
     27         { /* Ne rien faire de plus */ } 
    2428 
    2529   }; // class Domain 
    2630 
    2731   void CDomain::check(void) 
    28    { 
    29       //static bool isChecked = false ; 
     32   { // Recodée en partie le 17/11/10 
    3033 
    31       //if (isChecked) return; // Si la vérification a été faite, on arrête tout. 
     34      // Domaine global // 
     35      if ((!ni_glo.hasValue() || ni_glo <= 0 ) || 
     36          (!nj_glo.hasValue() || nj_glo <= 0 )) 
     37        ERROR("Le domaine global est mal défini, vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") ; 
    3238 
    33       // domaine global 
    34       if (!ni_glo.hasValue() || ni_glo<=0 ) throw XMLIOSERVER::XMLIOUndefinedValueException("domaine global mal defini") ; 
    35       if (!nj_glo.hasValue() || nj_glo<=0 ) throw XMLIOSERVER::XMLIOUndefinedValueException("domaine global mal defini") ; 
     39      // Domaine local en i // 
     40      if (ni.hasValue() && ibegin.hasValue() && !iend.hasValue()) 
     41         iend = ibegin + ni - 1 ; 
     42      else if (ni.hasValue() && iend.hasValue() && !ibegin.hasValue()) 
     43         ibegin = ni - iend + 1 ; 
     44      else if (ibegin.hasValue() && iend.hasValue() && !ni.hasValue()) 
     45         ni = iend - ibegin - 1 ; 
     46      else if (ibegin.hasValue() && iend.hasValue() && 
     47               ni.hasValue() && (iend != ibegin + ni - 1)) 
     48         ERROR("Le domaine est mal défini, iend est différent de (ibegin + ni - 1) !") ; 
     49      else 
     50         ERROR("Le domaine est mal défini, deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ; 
    3651 
    37       //domaine local en i 
    38       if ( ni.hasValue() && ibegin.hasValue()) 
     52      if (ni < 0 || ibegin > iend || 
     53          ibegin < 1 || iend > ni_glo) 
     54         ERROR("Domaine local mal défini, vérifiez les valeurs ni, ni_glo, ibegin, iend") ; 
     55 
     56      // Domaine local en j // 
     57      if (nj.hasValue() && jbegin.hasValue() && !jend.hasValue()) 
     58         jend = jbegin + nj - 1 ; 
     59      else if (nj.hasValue() && jend.hasValue() && !jbegin.hasValue()) 
     60         jbegin = nj - jend + 1 ; 
     61      else if (jbegin.hasValue() && jend.hasValue() && !nj.hasValue()) 
     62         nj = jend - jbegin - 1 ; 
     63      else if (jbegin.hasValue() && jend.hasValue() && 
     64               nj.hasValue() && (jend != jbegin + nj - 1)) 
     65         ERROR("Le domaine est mal défini, jend est différent de (jbegin + nj - 1) !") ; 
     66      else 
     67         ERROR("Le domaine est mal défini, deux valeurs au moins parmis jend, jbegin, nj doivent être définjes !") ; 
     68 
     69      if (nj < 0 || jbegin > jend || 
     70          jbegin < 1 || jend > nj_glo) 
     71         ERROR("Domaine local mal défini, vérifiez les valeurs nj, nj_glo, jbegin, jend") ; 
     72 
     73      // Masque de domaine // 
     74      if (mask.hasValue()) 
    3975      { 
    40          if (iend.hasValue() && iend!=ibegin+ni-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 1") ; 
    41          iend = ibegin + ni - 1 ; 
     76         if ((mask->extent(0) != ni) || 
     77             (mask->extent(1) != nj)) 
     78            ERROR("Le masque n'a pas la même taille que le domaine local") ; 
    4279      } 
    43       else if (ni.hasValue() && iend.hasValue()) 
    44       { 
    45          if (ibegin != ni-iend+1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 2") ; 
    46          ibegin = ni - iend + 1 ; 
    47       } 
    48       else if (ibegin.hasValue() && iend.hasValue()) 
    49       { 
    50          if (ni!=iend-ibegin-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 3") ; 
    51          ni = iend - ibegin - 1 ; 
    52       } 
    53       else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 4") ; 
    54  
    55       if (ni<0 || ibegin>iend || ibegin<1 || iend>ni_glo) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 5") ; 
    56  
    57       //domaine local en j 
    58       if ( nj.hasValue() && jbegin.hasValue()) 
    59       { 
    60          if (jend.hasValue() && jend!=jbegin+nj-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 6") ; 
    61          jend = jbegin + nj - 1 ; 
    62       } 
    63       else if (nj.hasValue() && jend.hasValue()) 
    64       { 
    65          if (jbegin!=nj-jend+1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 7") ; 
    66          jbegin = nj - jend + 1 ; 
    67       } 
    68       else if (jbegin.hasValue() && jend.hasValue()) 
    69       { 
    70          if (nj!=jend-jbegin-1) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 8") ; 
    71          nj = jend - jbegin - 1 ; 
    72       } 
    73       else throw XMLIOSERVER::XMLIOUndefinedValueException("domain local non défini 9") ; 
    74  
    75       if (nj<0 || jbegin>jend || jbegin<1 || jend>nj_glo) throw XMLIOSERVER::XMLIOUndefinedValueException("domain local mal défini 10") ; 
    76  
    77       //cout<<"mask ni "<<mask->extent(0)<<" nj "<<mask->extent(1)<<"  "<<mask<<endl ; 
    78       if (mask.hasValue()) 
    79          if (mask->extent(0) != ni || mask->extent(1) != nj) 
    80             throw XMLIOSERVER::XMLIOUndefinedValueException("le champ mask n'a pas la même taille que le domaine local") ; 
    81  
    82       if (data_dim.hasValue()) 
    83       { 
    84          if (!(data_dim==1 || data_dim==2)) throw XMLIOSERVER::XMLIOUndefinedValueException("dimension non comptatible (doit être 1 ou 2)") ; 
    85       } 
    86       else throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des donnée non définie") ; 
    87  
    88       if (data_ni.hasValue()) 
    89       { 
    90          if (data_ni<=0) throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des données négative") ; 
    91       } 
    92       else 
    93       { 
    94          if (data_dim==1) data_ni=ni*nj ; 
    95          else data_ni=(int) ni ; 
     80      else // (!mask.hasValue()) 
     81      { // Si aucun masque n'est défini, on en crée un nouveau qui valide l'intégralité du domaine. 
     82         Array<bool, 2> __arr(shape(ni, nj)); 
     83         __arr = true ; 
     84         mask->resize(shape(ni,nj)) ; 
     85         this->set_mask(__arr); 
    9686      } 
    9787 
    98       if (!data_ibegin.hasValue()) data_ibegin=0 ; 
     88      // Données du domaine // 
     89      if (!data_jbegin.hasValue()) data_jbegin = 0 ; 
     90      if (!data_ibegin.hasValue()) data_ibegin = 0 ; 
    9991 
    100       if (data_nj.hasValue()) 
    101       { 
    102          if (data_nj<=0) throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension des données négative") ; 
    103       } 
    104       else data_nj=(int) nj ; 
     92      if (data_dim.hasValue() && 
     93        !(data_dim==1 || data_dim==2)) 
     94         ERROR("Dimension des données non comptatible (doit être 1 ou 2) !") ; 
     95      else if (! data_dim.hasValue()) 
     96         ERROR("Dimension des données non définie !") ; 
    10597 
    106       if (!data_jbegin.hasValue()) data_jbegin=0 ; 
     98      if (data_ni.hasValue() && (data_ni <= 0)) 
     99         ERROR("Dimension des données négative (data_ni).") ; 
     100      else if (!data_ni.hasValue()) 
     101         data_ni = (data_dim == 1) ? (ni * nj) : (int) ni; 
    107102 
    108       if (!mask.hasValue()) 
    109       { // Si aucun masque n'est défini, on en crée un nouveau qui valide l'intégralité du domaine. 
    110          mask->resize(shape(ni,nj)) ; 
    111          *mask=true ; 
    112       } 
     103      if (data_nj.hasValue() && (data_nj <= 0)) 
     104         ERROR("Dimension des données négative (data_nj).") ; 
     105      else if (!data_nj.hasValue()) 
     106         data_nj = (int) nj ; 
    113107 
    114       // Gestion de la compression 
    115  
     108      // Gestion de la compression // 
    116109      if (data_i_index.hasValue()) 
    117110      { 
    118          if (data_n_index.hasValue()) 
     111         if (data_n_index.hasValue() && 
     112            (data_n_index != data_i_index->extent(0))) 
     113            ERROR("Dimension data_i_index incompatible avec data_n_index.") ; 
     114         else if (!data_n_index.hasValue()) 
     115            data_n_index = data_i_index->extent(0) ; 
     116 
     117         if (data_dim == 2) 
    119118         { 
    120             if (data_n_index!=data_i_index->extent(0)) 
    121                throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension data_i_index incompatible avec data_n_index") ; 
    122          } 
    123          else data_n_index=data_i_index->extent(0) ; 
    124  
    125          if (data_dim==2) 
    126          { 
    127             if (data_j_index.hasValue()) 
    128             { 
    129                if (data_j_index->extent(0)!=data_i_index->extent(0)) 
    130                   throw XMLIOSERVER::XMLIOUndefinedValueException("Dimension data_j_index incompatible avec data_i_index") ; 
    131             } 
    132             else throw XMLIOSERVER::XMLIOUndefinedValueException("data_j_index non défini") ; 
     119            if (data_j_index.hasValue() && 
     120               (data_j_index->extent(0) != data_i_index->extent(0))) 
     121               ERROR("Dimension data_j_index incompatible avec data_i_index.") ; 
     122            else if (!data_j_index.hasValue()) 
     123               ERROR("La donnée data_j_index doit être renseignée !") ; 
    133124         } 
    134125      } 
    135126      else 
    136127      { 
    137          if (data_n_index.hasValue() || (data_dim==2 && data_j_index.hasValue())) 
    138             throw XMLIOSERVER::XMLIOUndefinedValueException("data_i_index non défini") ; 
     128         if (data_n_index.hasValue() || 
     129            ((data_dim == 2) && (data_j_index.hasValue()))) 
     130            ERROR("data_i_index non défini") ; 
    139131      } 
    140       //cout<<"data_n_index.hasValue() "<<data_n_index.hasValue()<<endl ; 
     132 
    141133      if (!data_n_index.hasValue()) 
    142       { 
    143          if (data_dim==1) 
     134      { // -> bloc re-vérfié OK 
     135         if (data_dim == 1) 
    144136         { 
    145             int i ; 
    146             data_n_index=*data_ni ; 
    147             //cout <<"data_n_index "<<data_n_index<<"  "<<data_ni<<" "<<data_nj<<endl ; 
    148  
    149             data_i_index->resize(data_n_index) ; 
    150  
    151             for (i=0;i<data_ni;i++) (*data_i_index)(i)=i ; 
    152             //cout <<"data_i_index "<<*data_i_index<<endl ; 
     137            const int dni = data_ni; 
     138            Array<int, 1> __arri(shape(dni)); 
     139            this->set_data_n_index(dni) ; 
     140            for (int i = 0; i < dni; i++) 
     141               __arri(i) = i+1 ; 
     142            data_i_index->resize(dni) ; 
     143            this->set_data_i_index(__arri) ; 
    153144         } 
    154          else   // data_dim=2 
     145         else   // (data_dim == 2) 
    155146         { 
    156             int i ; 
    157             int j ; 
    158             int count ; 
    159  
    160             data_n_index = data_ni * data_nj ; 
    161             data_i_index -> resize(data_n_index) ; 
    162             data_j_index -> resize(data_n_index) ; 
    163             for(count=0,i=0; i<data_ni;i++) 
    164                for(j=0; j<data_nj;j++) 
    165                { 
    166                   (*data_i_index)(count)=i ; 
    167                  // cout<<count<<"  "<<(*data_i_index)(count)<<endl ; 
    168                   (*data_j_index)(count)=j ; 
    169                   //cout<<count<<"  "<<(*data_j_index)(count)<<endl ; 
    170                   count++ ; 
    171                } 
    172                //cout<<data_ni<<" "<<data_nj<<" "<<data_n_index<<" "<<*data_i_index<<" "<<*data_j_index<<endl ; 
     147            const int dni = data_ni * data_nj; 
     148            Array<int, 1> __arri(shape(dni)), __arrj(shape(dni)); 
     149            this->set_data_n_index(dni) ; 
     150            for(int count = 0, i = 0; i  <data_ni; i++) 
     151               for(int j = 0; j < data_nj; j++, count++) 
     152               { __arri(count) = i+1 ;  __arrj(count) = j+1 ; } 
     153            data_i_index -> resize(dni) ; 
     154            data_j_index -> resize(dni) ; 
     155            this->set_data_i_index(__arri) ; 
     156            this->set_data_j_index(__arrj) ; 
    173157         } 
    174158      } 
    175  
    176       //isChecked = true ; 
    177159   } 
    178160 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/domain_attribut.hpp

    r127 r137  
    3737         DECLARE_ATTR(data_j_index  , Array(int, 1)) ; 
    3838 
    39          DECLARE_ATTR(xvalue        , Array(double, 1)) ; 
    40          DECLARE_ATTR(yvalue        , Array(double, 1)) ; 
     39         DECLARE_ATTR(lonvalue      , Array(double, 1)) ; 
     40         DECLARE_ATTR(latvalue      , Array(double, 1)) ; 
     41         DECLARE_ATTR(domtype       , string); 
    4142 
    4243         DomainAttribut(void) : AttributRegistrar() 
     
    6970            RegisterAttribut(&data_j_index) ; 
    7071 
    71             RegisterAttribut(&xvalue) ; 
    72             RegisterAttribut(&yvalue) ; 
     72            RegisterAttribut(&lonvalue) ; 
     73            RegisterAttribut(&latvalue) ; 
     74            RegisterAttribut(&domtype) ; 
    7375         } 
    7476 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/duration.hpp

    r131 r137  
    2828            if(d.hour   != 0.0) { testValue = false; out << d.hour   << "h " ; } 
    2929            if(d.minute != 0.0) { testValue = false; out << d.minute << "mi "; } 
    30             if(d.second != 0.0 || testValue) { out << d.second << "s " ; } 
     30            if(d.second != 0.0 || testValue)       { out << d.second << "s " ; } 
    3131 
    3232            _out << (out.str().substr(0, out.str().size()-1)); // << suppression de l'espace en fin de chaîne. 
     
    7676         } 
    7777 
    78          struct _duration& resolve(const AbstractCalendar&); 
     78         inline struct _duration& resolve(const AbstractCalendar&); 
    7979 
    8080         std::string toString(void) const 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/exception.hpp

    r131 r137  
    3434         { /* Ne rien faire de plus */ } 
    3535 
    36          ~XMLIOException() throw() 
    37          { /* Ne rien faire de plus */ } 
     36         ~XMLIOException(void) throw() 
     37         { std::cerr << displayText() << std::endl; } 
    3838 
    3939         XMLIOException& operator = (const XMLIOException& _exc) 
     
    4343         virtual const char* className(void) const throw() { return (typeid(*this).name()); } 
    4444 
    45          virtual Exception* clone(void) const {   return new XMLIOException(*this); } 
     45         virtual Exception* clone(void) const { return new XMLIOException(*this); } 
    4646         virtual void rethrow(void) const { throw *this; } 
    4747 
     
    5757         const char* name(void) const throw() 
    5858         { return ("XMLIO>UndefinedValueException"); } 
     59 
     60         ~XMLIOUndefinedValueException(void) throw() 
     61         { std::cerr << displayText() << std::endl; } 
    5962 
    6063   }; //class XMLIOUndefinedException 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp

    r130 r137  
    2525         const std::vector<CField*>& getEnabledFields    (void) const { return (enabledFields); } 
    2626 
     27         FieldGroup * createVirtualFieldGroup(const std::string _id) 
     28         { 
     29            return (vfieldGroup == NULL) 
     30               ? vfieldGroup = (FieldGroup*) FieldGroup::CreateObject(_id) 
     31               : vfieldGroup; 
     32         } 
     33 
    2734         void initializeDataOutput(AbstractDataOutput* _output) 
    2835         { 
     
    94101               int default_outputlevel = 5, int default_level = 1, bool default_enabled = true ) 
    95102         { 
    96             const int _outputlevel = (output_level.hasValue()) ? (int)output_level : default_outputlevel; 
     103            const int _outputlevel = 
     104               (output_level.hasValue()) ? (int)output_level : default_outputlevel; 
    97105            std::vector<CField*>::iterator it; 
    98106 
     
    163171         } 
    164172 
    165          virtual bool hasChild(void) const { return (vfieldGroup != NULL); } 
    166          virtual void printChild(ostream& out) const { out << *vfieldGroup << std::endl; } 
     173         virtual bool hasChild(void) const 
     174         { return (vfieldGroup != NULL); } 
     175 
     176         virtual void printChild(ostream& out) const 
     177         { out << *vfieldGroup << std::endl; } 
    167178 
    168179         virtual void solveDescInheritance(const AttributRegistrar* const _parent = 0) 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/group_template.hpp

    r128 r137  
    168168                  attributes.clear(); _node.getAttributes(attributes); 
    169169 
    170                   if (name.compare(W::GetName()) == 0) { createGroupAndParse<W>(attributes, _node); continue; } 
    171                   if (name.compare(T::GetName()) == 0) { createChildAndParse<T>(attributes, _node); continue; } 
     170                  if (name.compare(W::GetName()) == 0) 
     171                  { createGroupAndParse<W>(attributes, _node); continue; } 
     172 
     173                  if (name.compare(T::GetName()) == 0) 
     174                  { createChildAndParse<T>(attributes, _node); continue; } 
    172175 
    173176                  WARNING("Un objet de type \""+W::GetName()+"\" ne peut contenir qu'un object de type \""+T::GetName()+"\" ou \""+W::GetName()+"\" !"); 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/logger.hpp

    r128 r137  
    22#define __XMLIO_LOGGER__ 
    33 
    4 // Entête Poco logging 
    54#include <csignal> 
    65 
     
    9291   } 
    9392 
    94    std::ostream& IncIndent(std::ostream& out) { Indent++; return (NIndent(out)); } 
    95    std::ostream& DecEndl  (std::ostream& out) { Indent--; return (out); } 
     93   std::ostream& IncIndent(std::ostream& out) 
     94   { Indent++; return (NIndent(out)); } 
     95 
     96   std::ostream& DecEndl  (std::ostream& out) 
     97   { Indent--; return (out); } 
    9698   ///////////////////////////////////////////////////////////////////// 
    9799 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/main.f90

    r134 r137  
    11! --------------------------------------------------- ! 
    2 ! ------------- XMLIO SERVER MAIN TEST  ------------- ! 
     2!               XMLIO SERVER MAIN TEST                ! 
    33! --------------------------------------------------- ! 
    44 
    5 MODULE XTYPE 
    6    IMPLICIT NONE 
    7  
    8    ! Ne jamais modifier les valeurs internes de ce type dans le code fortran. 
    9    TYPE XHandle 
    10       INTEGER :: dtype 
    11       INTEGER :: daddr 
    12    END TYPE XHandle 
    13  
    14    TYPE XDate 
    15       INTEGER :: year, month, day, hour, minute, second 
    16    END TYPE XDate 
    17  
    18    TYPE XDuration 
    19       REAL(kind = 8) :: year, month, day, hour, minute, second 
    20    END TYPE XDuration 
    21  
    22    ! enum XDType 
    23    INTEGER, PARAMETER  :: NOTYPE = 0 
    24    INTEGER, PARAMETER  :: DTREATMENT = 1, DDATE = 2, CALENDAR = 3, ECONTEXT = 4 
    25    INTEGER, PARAMETER  :: EAXIS = 5 , EDOMAIN = 6 , EFIELD = 7 , EFILE = 8 , EGRID = 9 
    26    INTEGER, PARAMETER  :: GAXIS = 10, GDOMAIN = 11, GFIELD = 12, GFILE = 13, GGRID = 14 
    27  
    28    ! enum XFileType 
    29    INTEGER, PARAMETER  :: NETCDF4 = 0 
    30  
    31    ! Autres constantes 
    32    TYPE(XHandle)  , PARAMETER :: NULLHANDLE = XHandle(0, 0) 
    33    TYPE(XDuration), PARAMETER :: NONEDUR    = XDuration(0., 0., 0., 0., 0., 0.) 
    34  
    35 END MODULE XTYPE 
    36  
    37 MODULE IXHANDLE 
    38  
    39    INTERFACE 
    40  
    41       SUBROUTINE xios_handle_create(ret, dtype, idt) 
    42          USE XTYPE 
    43          TYPE(XHandle), INTENT(OUT) :: ret 
    44          INTEGER      , INTENT(IN)  :: dtype 
    45          CHARACTER*(*), INTENT(IN)  :: idt 
    46       END SUBROUTINE xios_handle_create 
    47  
    48    END INTERFACE 
    49  
    50 END MODULE IXHANDLE 
    51  
    52 MODULE IXML 
    53    IMPLICIT NONE 
    54    INTERFACE 
    55  
    56       SUBROUTINE xios_xml_Parse_File(filename) 
    57          CHARACTER*(*), INTENT(IN) :: filename 
    58       END SUBROUTINE xios_xml_Parse_File 
    59  
    60       SUBROUTINE xios_xml_Parse_String(xmlcontent) 
    61          CHARACTER*(*), INTENT(IN) :: xmlcontent 
    62       END SUBROUTINE xios_xml_Parse_String 
    63  
    64    END INTERFACE 
    65 END MODULE IXML 
    66  
    67 MODULE ICONTEXT 
    68    IMPLICIT NONE 
    69    INTERFACE 
    70  
    71       SUBROUTINE xios_context_set_current(context, withswap) 
    72          USE XTYPE 
    73          TYPE(XHandle),     INTENT(IN) :: context 
    74          LOGICAL, OPTIONAL, INTENT(IN) :: withswap 
    75       END SUBROUTINE xios_context_set_current 
    76  
    77       SUBROUTINE xios_context_get_current(context) 
    78          USE XTYPE 
    79          TYPE(XHandle), INTENT(IN) :: context 
    80       END SUBROUTINE xios_context_get_current 
    81  
    82       SUBROUTINE xios_context_get_calendar(context, calend) 
    83          USE XTYPE 
    84          TYPE(XHandle), INTENT(IN)  :: context 
    85          TYPE(XHandle), INTENT(OUT) :: calend 
    86       END SUBROUTINE xios_context_get_calendar 
    87  
    88    END INTERFACE 
    89  
    90 END MODULE ICONTEXT 
    91  
    92 MODULE ICALENDAR 
    93    IMPLICIT NONE 
    94    INTERFACE 
    95  
    96       SUBROUTINE xios_calendar_set_timestep(calend, dur) 
    97          USE XTYPE 
    98          TYPE(XHandle)  , INTENT(IN) :: calend 
    99          TYPE(XDuration), INTENT(IN) :: dur 
    100       END SUBROUTINE xios_calendar_set_timestep 
    101  
    102    END INTERFACE 
    103  
    104 END MODULE ICALENDAR 
    105  
    106 MODULE IDATATREATMENT 
    107    IMPLICIT NONE 
    108    INTERFACE 
    109  
    110       SUBROUTINE xios_dtreatment_new(dt, context) 
    111          USE XTYPE 
    112          TYPE(XHandle), INTENT(OUT) :: dt 
    113          TYPE(XHandle), INTENT(IN)  :: context 
    114       END SUBROUTINE xios_dtreatment_new 
    115  
    116       SUBROUTINE xios_dtreatment_create_files_and_headers(dt, ftype) 
    117          USE XTYPE 
    118          TYPE(XHandle), INTENT(IN) :: dt 
    119          INTEGER      , INTENT(IN) :: ftype 
    120       END SUBROUTINE xios_dtreatment_create_files_and_headers 
    121  
    122    END INTERFACE 
    123 END MODULE IDATATREATMENT 
    124  
    1255PROGRAM MAIN 
    126    USE XTYPE 
    1276   USE IXHANDLE 
    1287   USE IXML 
     8   USE IXMLTREE 
    1299   USE ICONTEXT 
     10   USE ICALENDAR 
     11   USE IEXTENDED 
    13012   USE IDATATREATMENT 
    131    USE ICALENDAR 
    13213 
    133    IMPLICIT NONE 
     14   INTEGER       :: compt = 0 
    13415 
    135    INTEGER         :: compt 
    136    TYPE(XHandle)   :: context1    = NULLHANDLE 
    137    TYPE(XHandle)   :: dtreat      = NULLHANDLE 
    138    TYPE(XHandle)   :: calend      = NULLHANDLE 
     16   TYPE(XHandle) :: nemo_style_ctxt     = NULLHANDLE, & 
     17                    orchidee_style_ctxt = NULLHANDLE, & 
     18                    lmdz_style_ctxt     = NULLHANDLE 
     19 
     20   TYPE(XHandle) :: temp_mod  = NULLHANDLE, & 
     21                    temp_mod_ = NULLHANDLE 
     22 
     23   ! Axes verticaux 
     24   REAL(kind = 8), DIMENSION(10) :: vaxis  = (/(i, i=1, 10)/) 
     25                                    !vvaxis = (/(i, i=1, 5)/) 
     26 
     27   ! Domaines horizontaux 
     28   REAL(kind = 8), DIMENSION(20) :: lonrect_orch0  = (/(i, i=11, 30)/),& 
     29                                    latrect_orch0  = (/(i, i=11, 30)/) 
     30 
     31   REAL(kind = 8), DIMENSION(10,10) :: loncurv_nemo0  = 1, & 
     32                                       latcurv_nemo0  = 1 
     33 
     34   ! Les durées 
    13935   TYPE(XDuration) :: timestep_1h = XDuration(0., 0., 0., 1., 0., 0.) 
     36                      !timestep_2h = XDuration(0., 0., 0., 2., 0., 0.) 
     37 
     38   ! Les masques 
     39   LOGICAL(kind = 1), DIMENSION(20, 20) :: mask0  = .TRUE._1 
     40 
     41   CHARACTER(len = *), PARAMETER :: filename = & 
     42            "/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml" 
     43 
     44   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    14045 
    14146   ! Parsing du document xml depuis un fichier situé sur le disque. 
    142    CALL xios_xml_Parse_File("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_simple_test.xml") 
     47   CALL xml_Parse_File(filename) 
    14348 
    144    ! Le calendrier doit être initialisé ici s'il ne l'a pas déjà été depuis le document xml. 
     49   ! Création de handle sur les contextes exstants dans lequels on souhaite travailler. 
     50   CALL handle_create(nemo_style_ctxt, ECONTEXT, "nemo_style") 
     51   CALL context_set_current(nemo_style_ctxt) 
    14552 
    146    ! Création d'un handle sur le contexte dans lequel on souhaite travailler, càd 'context1' ici. 
    147    CALL xios_handle_create(context1, ECONTEXT, "context1") 
    148    iF ((context1%dtype == 0) .AND. (context1%daddr == 0)) THEN 
    149       PRINT *, "Impossible de créer un handle sur l'élément context1 !" 
    150       STOP 
    151    END IF 
     53   CALL handle_create(temp_mod, EDOMAIN,  "domaine0") 
     54      CALL xml_domain_addAttribut(domain_hdl    = temp_mod,      & 
     55                                  lonvalue_curv = loncurv_nemo0, & 
     56                                  latvalue_curv = latcurv_nemo0, & 
     57                                  domtype       = "curvilinear") 
     58 
     59   CALL handle_create(lmdz_style_ctxt, ECONTEXT, "lmdz_style") 
     60   CALL context_set_current(lmdz_style_ctxt) 
     61 
     62   !!!!!!!!!!!!!!!!!!!! EXEMPLE RECONSTRUCTION !!!!!!!!!!!!!!!!!!!!! 
     63   ! On crée un nouveau context et on lui associe un handle. 
     64   CALL context_create(context_hdl   = orchidee_style_ctxt, & 
     65                       context_id    = "orchidee_style",    & 
     66                       calendar_type = GREGORIAN) 
     67 
     68   ! ---------> field_définition 
     69   CALL handle_create(temp_mod, GFIELD,  "field_definition") 
     70      CALL xml_tree_add(parent_hdl = temp_mod,        & 
     71                        child_hdl  = temp_mod_,       & 
     72                        child_type = GFIELD,          & 
     73                        child_id   = "ss_fieldgroup") 
     74      CALL xml_group_field_addAttribut(gfield_hdl = temp_mod_, & 
     75                                       flevel     = 1,         & 
     76                                       fprec      = 4,         & 
     77                                       fenabled   = .TRUE._1) 
     78         CALL xml_tree_add(parent_hdl = temp_mod_,    & 
     79                           child_hdl  = temp_mod ,    & 
     80                           child_type = EFIELD,       & 
     81                           child_id   = "field0") 
     82         CALL xml_field_addAttribut(field_hdl      = temp_mod,       & 
     83                                    fname          = "field0_name",  & 
     84                                    fstandard_name = "field0_sname", & 
     85                                    flong_name     = "field0_lname", & 
     86                                    funit          = "Pa",           & 
     87                                    foperation     = "inst",         & 
     88                                    ffreq_op       = timestep_1h,    & 
     89                                    fgrid_ref      = "grid0") 
     90   ! ---------> axis_définition 
     91   CALL handle_create(temp_mod, GAXIS,   "axis_definition") 
     92      CALL xml_tree_add(parent_hdl = temp_mod,        & 
     93                        child_hdl  = temp_mod_,       & 
     94                        child_type = GAXIS,           & 
     95                        child_id   = "ss_axisgroup") 
     96      CALL xml_group_axis_addAttribut(gaxis_hdl = temp_mod_, & 
     97                                      aunit     = "SI") 
     98         CALL xml_tree_add(parent_hdl = temp_mod_,    & 
     99                           child_hdl  = temp_mod ,    & 
     100                           child_type = EAXIS,        & 
     101                           child_id   = "axis0") 
     102         CALL xml_axis_addAttribut(axis_hdl       = temp_mod,             & 
     103                                   aname          = "saxev",              & 
     104                                   astandard_name = "saxev",              & 
     105                                   along_name     = "Simple axe vertical",& 
     106                                   avalue         = vaxis) 
     107 
     108   ! ---------> domain_définition 
     109   CALL handle_create(temp_mod, GDOMAIN, "domain_definition") 
     110      CALL xml_tree_add(parent_hdl = temp_mod,        & 
     111                        child_hdl  = temp_mod_,       & 
     112                        child_type = GDOMAIN,         & 
     113                        child_id   = "ss_domaingroup") 
     114      CALL xml_group_domain_addAttribut(gdomain_hdl = temp_mod_, & 
     115                                        ni_glo      = 40,        & 
     116                                        nj_glo      = 40) 
     117         CALL xml_tree_add(parent_hdl = temp_mod_,    & 
     118                           child_hdl  = temp_mod ,    & 
     119                           child_type = EDOMAIN,      & 
     120                           child_id   = "domain0") 
     121         CALL xml_domain_addAttribut(domain_hdl     = temp_mod,             & 
     122                                     dname          = "Compressee",         & 
     123                                     dstandard_name = "DomOrchTest",        & 
     124                                     dlong_name     = "Test type orchidee", & 
     125                                     ibegin         = 10,                   & 
     126                                     iend           = 31,                   & 
     127                                     jbegin         = 10,                   & 
     128                                     jend           = 31,                   & 
     129                                     mask           = mask0,                & 
     130                                     data_dim       = 1,                    & 
     131                                     data_ni        = 400,                  & 
     132                                     data_ibegin    = 1,                    & 
     133                                     lonvalue_rect  = lonrect_orch0,        & 
     134                                     latvalue_rect  = latrect_orch0,        & 
     135                                     domtype        = "rectilinear") 
     136 
     137   ! ---------> file_définition 
     138   CALL handle_create(temp_mod, GFILE,   "file_definition") 
     139      CALL xml_tree_add(parent_hdl = temp_mod,        & 
     140                        child_hdl  = temp_mod_,       & 
     141                        child_type = GFILE) 
     142      CALL xml_group_file_addAttribut(gfile_hdl = temp_mod_,   & 
     143                                      fofreq   = timestep_1h,  & 
     144                                      folevel   = 2,           & 
     145                                      fenabled  = .TRUE._1) 
     146         CALL xml_tree_add(parent_hdl = temp_mod_,    & 
     147                           child_hdl  = temp_mod ,    & 
     148                           child_type = EFILE,        & 
     149                           child_id   = "file0") 
     150         CALL xml_file_addAttribut(file_hdl     = temp_mod,                      & 
     151                                   fname        = "data/orchidee_test.nc",       & 
     152                                   fdescription = "Test sur grille type orchidee") 
     153            CALL xml_tree_add(parent_hdl = temp_mod , & 
     154                              child_hdl  = temp_mod_, & 
     155                              child_type = EFIELD) 
     156            CALL xml_field_addAttribut(field_hdl  = temp_mod_, & 
     157                                       ffield_ref = "field0") 
     158 
     159   ! ---------> grid_définition 
     160   CALL handle_create(temp_mod, GGRID,   "grid_definition") 
     161      CALL xml_tree_add(parent_hdl = temp_mod,        & 
     162                        child_hdl  = temp_mod_,       & 
     163                        child_type = GGRID,           & 
     164                        child_id   = "ss_gridgroup") 
     165      CALL xml_group_grid_addAttribut(ggrid_hdl    = temp_mod_, & 
     166                                      gdomain_ref  = "domain0", & 
     167                                      gaxis_ref    = "axis0"); 
     168         CALL xml_tree_add(parent_hdl = temp_mod_,    & 
     169                           child_hdl  = temp_mod ,    & 
     170                           child_type = EGRID,        & 
     171                           child_id   = "grid0") 
     172         CALL xml_grid_addAttribut(grid_hdl     = temp_mod,           & 
     173                                   gname        = "GRectiCompressee", & 
     174                                   gdescription = "Grille orchidee"); 
     175 
     176   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     177 
     178   ! Affichage de l'arbre xml au niveau de la sortie. 
     179   CALL xml_tree_show("xmlio_tree_prev.log") 
     180   ! CALL xml_tree_show() 
    152181 
    153182   ! ----------- Début du traitement ----------- ! 
    154  
    155    CALL xios_context_set_current(context1, .TRUE.) 
    156  
    157    ! Création et initialisation d'une instance de traitement des données dans 'context1'. 
    158    CALL xios_dtreatment_new(dtreat, context1) 
    159    iF ((dtreat%dtype == 0) .AND. (dtreat%daddr == 0)) THEN 
    160       PRINT *, "Impossible d'initialiser l'instance de traitement !" 
    161       STOP 
    162    END IF 
    163  
    164    ! Création des fichiers et des entêtes dans le contexte. 
    165    CALL xios_dtreatment_create_files_and_headers(dtreat, NETCDF4) 
    166  
    167    ! On récupére le calendrier associé au contexte en cours de traitement. 
    168    CALL xios_context_get_calendar(context1, calend) 
    169    iF ((calend%dtype == 0) .AND. (calend%daddr == 0)) THEN 
    170       PRINT *, "Impossible de récupérer le calendrier !" 
    171       STOP 
    172    END IF 
    173  
    174    ! On change la durée du timestep. 
    175    CALL xios_calendar_set_timestep(calend, timestep_1h) 
     183   ! On choisit le context dans lequel on va travailler et on commence le traitement des données. 
     184   CALL dtreatment_start(orchidee_style_ctxt, NETCDF4) 
    176185 
    177186   ! Exécution de la boucle de calcul-écriture. 
     
    180189   END DO 
    181190 
     191   ! Affichage de l'arbre xml au niveau de la sortie. 
     192   CALL xml_tree_show("xmlio_tree_next.log") 
     193 
    182194END PROGRAM MAIN 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp

    r128 r137  
    147147         } 
    148148 
    149          static const StrHashMap<T>& GetCurrentListObject(void) { return (AllListObj[CurrContext]); } 
    150          static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) { return (AllListObj); } 
    151  
    152          static void SetContext(const string& id) { ObjectTemplate<T>::CurrContext = id; } 
    153  
    154          static string& GetCurrentContextId(void) { return (ObjectTemplate<T>::CurrContext); } 
     149         static const StrHashMap<T>& GetCurrentListObject(void) 
     150         { return (AllListObj[CurrContext]); } 
     151 
     152         static Poco::HashMap<string, StrHashMap<T> >& GetAllListObject(void) 
     153         { return (AllListObj); } 
     154 
     155         static void SetContext(const string& id) 
     156         { ObjectTemplate<T>::CurrContext = id; } 
     157 
     158         static string& GetCurrentContextId(void) 
     159         { return (ObjectTemplate<T>::CurrContext); } 
    155160 
    156161      protected : 
     
    179184         } 
    180185 
    181          template <class V> static V* CreateInstanceAndParse(XMLNode& _node, const char* defaultId, bool parseAttr = true ) 
     186         template <class V> 
     187            static V* CreateInstanceAndParse(XMLNode& _node, const char* defaultId, bool parseAttr = true ) 
    182188         { 
    183189            V* instance_ptr = NULL; string did(defaultId); 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xml_node.hpp

    r132 r137  
    3636            bool goToChildElement(void) 
    3737            { 
    38                Poco::XML::Node* nextElement = this->getCNode()->firstChild(); 
     38               Poco::XML::Node * nextElement = this->getCNode()->firstChild(); 
    3939 
    4040               // On parcourt la liste des enfants jusqu'à trouver un élément quelconque. 
Note: See TracChangeset for help on using the changeset viewer.