Changeset 125


Ignore:
Timestamp:
10/05/10 09:47:10 (14 years ago)
Author:
hozdoba
Message:
 
Location:
XMLIO_V2/dev/dev_rv/src/XMLIO
Files:
13 edited

Legend:

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

    r124 r125  
    2020      protected : 
    2121 
    22          Poco::HashMap<string, int> getAllLimitedDim(void) 
     22         Poco::HashMap<string, int> getAllLimitedDim(void) const 
    2323         { 
    2424            Poco::HashMap<string, int> dims; 
    25             const std::set<const CDomain*> sdom = getRelFile()->getEnabledDomains(); 
    26             const std::set<const CAxis*> saxis = getRelFile()->getEnabledAxis(); 
    27  
    28             const CDomain* pdom = *sdom.begin(); 
    29  
    30             // TODO Améliorer ci-dessous -> un seul domaine pris en compte pour le moment 
    31             dims["lon"] = pdom->nj; 
    32             dims["lat"] = pdom->ni; 
     25            const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 
     26            const std::set<const CAxis*>  saxis = this->getRelFile()->getEnabledAxis(); 
     27 
     28            // std::cout << "Nombre de domaines disponibles pour le fichier : " << sdom.size() << std::endl; 
     29            // std::cout << "Nombre d'axes disponibles pour le fichier : " << saxis.size() << std::endl; 
     30 
     31            std::set<const CDomain*>::const_iterator itt; 
     32            for ( itt = sdom.begin() ; itt != sdom.end(); itt++ ) 
     33            { 
     34               string domid = ((*itt)->name.hasValue()) ? (string)(*itt)->name : (*itt)->getId(); 
     35               string lonid = string("lon_").append(domid); 
     36               string latid = string("lat_").append(domid); 
     37               dims[lonid]  = (*itt)->ni; 
     38               dims[latid]  = (*itt)->nj; 
     39            } 
    3340 
    3441            std::set<const CAxis*>::const_iterator it; 
    3542            for ( it = saxis.begin() ; it != saxis.end(); it++ ) 
    36                dims[(*it)->getId()] = (*it)->size; 
     43            { 
     44               string axisid = ((*it)->name.hasValue()) ? (string)(*it)->name : (*it)->getId(); 
     45               dims[axisid]  = (*it)->size; 
     46            } 
    3747 
    3848            return (dims); 
     
    4555         { 
    4656              time_t rawtime; 
    47               struct tm * timeinfo; 
     57              struct tm * timeinfo = NULL; 
    4858              char buffer [100]; 
    4959 
     
    7787         { 
    7888            bool withTime = true; 
    79             const Poco::HashMap<string, int>& allDim = getAllLimitedDim(); 
     89            const Poco::HashMap<string, int>& allDim = this->getAllLimitedDim(); 
    8090            Poco::HashMap<string, int>::ConstIterator it; 
    8191 
     
    99109            Poco::HashMap<string, string> hm; 
    100110 
    101             const std::set<const CDomain*> sdom = getRelFile()->getEnabledDomains(); 
    102             const std::set<const CAxis*> saxis = getRelFile()->getEnabledAxis(); 
    103  
    104             if (!(latVar = dataFile->add_var("lat", ncFloat, dataFile->get_dim("lat")))) 
    105                throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de latitude !"); 
    106             if (!(lonVar = dataFile->add_var("lon", ncFloat, dataFile->get_dim("lon")))) 
    107                throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de longitude !"); 
    108  
    109             // Attribut de latitude. 
    110             hm["axis"]          = "Y" ; 
    111             hm["standard_name"] = "latitude" ; 
    112             hm["units"]         = "degrees_north"; 
    113             hm["long_name"]     = "Latitude" ; 
    114             addStringAttributesToVar(latVar, hm); 
    115             hm.clear(); 
    116  
    117             // Attribut de longitude. 
    118             hm["axis"]           = "X" ; 
    119             hm["standard_name"]  = "longitude" ; 
    120             hm["units"]          = "degrees_east"; 
    121             hm["long_name"]      = "Longitude" ; 
    122             addStringAttributesToVar(lonVar, hm); 
    123             hm.clear(); 
     111            const std::set<const CDomain*> sdom = this->getRelFile()->getEnabledDomains(); 
     112            const std::set<const CAxis*>  saxis = this->getRelFile()->getEnabledAxis(); 
     113 
     114            std::set<const CDomain*>::const_iterator itt; 
     115            for ( itt = sdom.begin() ; itt != sdom.end(); itt++ ) 
     116            { 
     117               string domid = ((*itt)->name.hasValue()) ? (string)(*itt)->name : (*itt)->getId(); 
     118               string lonid = string("lon_").append(domid); 
     119               string latid = string("lat_").append(domid); 
     120 
     121               if (!(latVar = dataFile->add_var(latid.c_str(), ncFloat, dataFile->get_dim(latid.c_str())))) 
     122                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de latitude !"); 
     123               if (!(lonVar = dataFile->add_var(lonid.c_str(), ncFloat, dataFile->get_dim(lonid.c_str())))) 
     124                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable de longitude !"); 
     125 
     126               // Attribut de latitude. 
     127               hm["axis"]          = "Y" ; 
     128               hm["standard_name"] = "latitude" ; 
     129               hm["units"]         = "degrees_north"; 
     130               hm["long_name"]     = "Latitude" ; 
     131               addStringAttributesToVar(latVar, hm); 
     132               hm.clear(); 
     133 
     134               // Attribut de longitude. 
     135               hm["axis"]           = "X" ; 
     136               hm["standard_name"]  = "longitude" ; 
     137               hm["units"]          = "degrees_east"; 
     138               hm["long_name"]      = "Longitude" ; 
     139               addStringAttributesToVar(lonVar, hm); 
     140               hm.clear(); 
     141            } 
    124142 
    125143            // Attribut des autres coordonnées. 
     
    127145            for ( it = saxis.begin() ; it != saxis.end(); it++ ) 
    128146            { 
    129                if (!(othvar = dataFile->add_var((*it)->getId().c_str(), ncFloat, dataFile->get_dim((*it)->getId().c_str())))) 
     147               string axisid = ((*it)->name.hasValue()) ? (string)(*it)->name : (*it)->getId(); 
     148               if (!(othvar = dataFile->add_var(axisid.c_str(), ncFloat, dataFile->get_dim(axisid.c_str())))) 
    130149                  throw XMLIOUndefinedValueException("Impossible d'ajouter la variable "+ (*it)->getId() +" !"); 
    131150 
     
    150169            for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 
    151170            { 
    152                CField* field = (*it); 
     171                     CField* field = (*it); 
    153172               const CField* bfield = (*it)->getBaseObject(); 
     173               const CDomain*  rdom = field->getGrid()->getRelDomain(); 
     174               const CAxis*   raxis = field->getGrid()->getRelAxis(); 
     175 
     176               string fieldid = (field->name.hasValue()) ? (string)field->name : bfield->getId(); 
     177               string domid   = (rdom ->name.hasValue()) ? (string)rdom ->name : rdom  ->getId(); 
     178               string axisid  = (raxis->name.hasValue()) ? (string)raxis->name : raxis ->getId(); 
     179 
     180               string lonid = string("lon_").append(domid); // Nom de la coordonnée longitudinale associée. 
     181               string latid = string("lat_").append(domid); // Nom de la coordonnée latitudinale  associée. 
    154182 
    155183               lonlat = !field->getGrid()->_hasAxis(); 
     
    158186               { // Si une opération sur le champ est définie ... 
    159187                  if (field->operation.getId().compare("once") == 0) 
    160                   { 
    161                      wtime = false; 
    162                      field->freq_op.setValue(NoneDu); 
    163                   } 
     188                  { wtime = false; field->freq_op.setValue(NoneDu); } 
    164189               } 
    165190               else 
     
    175200               ((FieldOperation)field->operation).setFreqOp(Duration(field->freq_op)); 
    176201 
    177  
    178202               tvar = ncFloat; 
    179203               if (field->prec.hasValue()) 
     
    184208                  if (lonlat) // 2D spatio + temps 
    185209                  { 
    186                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    187                         dataFile->get_dim("time"), dataFile->get_dim("lon"), dataFile->get_dim("lat")))) 
     210                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     211                        dataFile->get_dim("time"), dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str())))) 
    188212                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    189213                  } 
    190214                  else // 3D spatio + temps 
    191215                  { 
    192                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    193                         dataFile->get_dim("time"), dataFile->get_dim("lon"), dataFile->get_dim("lat"), 
    194                         dataFile->get_dim(field->getGrid()->getRelAxis()->getId().c_str())))) 
     216                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     217                        dataFile->get_dim("time"), dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str()), 
     218                        dataFile->get_dim(axisid.c_str())))) 
    195219                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    196220                  } 
     
    200224                  if (lonlat) // 2D spatio sans temps 
    201225                  { 
    202                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    203                         dataFile->get_dim("lon"), dataFile->get_dim("lat")))) 
     226                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     227                        dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str())))) 
    204228                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    205229                  } 
    206230                  else // 3D spatio sans temps 
    207231                  { 
    208                      if (!(var = dataFile->add_var(bfield->getId().c_str(), tvar, 
    209                         dataFile->get_dim("lon"), dataFile->get_dim("lat"), 
    210                         dataFile->get_dim(field->getGrid()->getRelAxis()->getId().c_str())))) 
     232                     if (!(var = dataFile->add_var(fieldid.c_str(), tvar, 
     233                        dataFile->get_dim(lonid.c_str()), dataFile->get_dim(latid.c_str()), 
     234                        dataFile->get_dim(axisid.c_str())))) 
    211235                        throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 
    212236                  } 
     
    221245         } 
    222246 
     247         virtual void writeCoords(const string& id, const Array<float, 1>& cdata) 
     248         { 
     249            //if (!latVar->put(lats, NLAT)) 
     250            //   return NC_ERR; 
     251         } 
     252 
     253         virtual void writeVarData(const string& id, const Array<float, 1>& vdata) 
     254         { 
     255            //if (!latVar->put(lats, NLAT)) 
     256            //   return NC_ERR; 
     257         } 
     258 
    223259      private : 
    224260 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_output.hpp

    r122 r125  
    3434 
    3535 
    36          virtual void initFile(void) = 0; 
    37          virtual void setDims(void) = 0; 
     36         virtual void initFile (void) = 0; 
     37         virtual void setDims  (void) = 0; 
    3838         virtual void setCoords(void) = 0; 
    39          virtual void setVars(void) = 0; 
     39         virtual void setVars  (void) = 0; 
    4040 
    4141      private : 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_treatment.hpp

    r124 r125  
    4040 
    4141            std::vector<CField*>::const_iterator it; 
     42 
    4243            for (it = vectRef.begin(); it != vectRef.end(); it++ ) 
    4344            { 
     
    4748                  (*it)->getGrid()->storeField(arr, data_uni); 
    4849                  (*it)->storeData(data_uni, currentContext->getCalendar()->getCurrentDate()); 
     50               } 
     51 
     52               if (true) 
     53               { // Ecriture des données si nécessaire. 
     54 
    4955               } 
    5056            } 
     
    6167         AbstractDataTreatment(Context* const _ctxt, const AbstractCalendar& cal) : enabledFiles(), currentContext(_ctxt) 
    6268         { 
     69            // Résolution des héritages pour le context actuel (Context::ResolveInheritance() résoud les héritages pour tous les contextes). 
    6370            //std::cout << "(Message temporaire) Résolution des héritages ..." << std::endl; 
    64             // Résolution des héritages pour le context actuel (Context::ResolveInheritance() résoud les héritages pour tous les contextes). 
    6571            solveAllInheritance(); 
    6672 
    67             // Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
     73            //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    6874            //std::cout << "(Message temporaire) Initialisation du vecteur enabledFiles ..." << std::endl; 
    6975            findEnabledFiles(); 
    7076 
    71             // Recherche des champs à sortir (enable à true + niveau de sortie correct) pour chaque fichier précédemment listé. 
     77            //Recherche des champs à sortir (enable à true + niveau de sortie correct) pour chaque fichier précédemment listé. 
    7278            //std::cout << "(Message temporaire) Recherche des champs à sortir ..." << std::endl; 
    7379            findAllEnabledFields(cal.getInitDate()); 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/axis.hpp

    r114 r125  
    1717 
    1818         static string GetName(void) {return ("axis"); } 
     19         static string GetDefName(void)  { return (CAxis::GetName()); } 
    1920 
    2021         virtual ~CAxis(void) 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp

    r124 r125  
    5656            calendar->update(); 
    5757 
    58             std::cout << "> Itération de calcul " << tcourant << ",  " << *calendar << std::endl; 
     58            std::cout << "> Itération de calcul " << tcourant << ", " << *calendar << std::endl; 
    5959 
    6060            // Mise à jour des données. 
     
    6363            // Ecriture des données. 
    6464            dtreat->writeData<Array<double, 3> >("champ1", arr); 
    65  
    6665         } 
    6766 
    6867         // On écrit l'arborescence résultante du traitement sur la sortie de log. 
    69          Context::ShowTree(std::clog); 
     68         // Context::ShowTree(std::clog); 
    7069 
    7170         delete dtreat; 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp

    r124 r125  
    5353         } 
    5454 
     55         static Context* SwapContext(void) 
     56         { 
     57            if (Stid.size() == 0) 
     58            { 
     59               WARNING("SwapContext impossible car le pile des contextes est vides !"); 
     60               return (NULL); 
     61            } 
     62            string lastId = Stid.top (); Stid.pop (); 
     63            return (Context::GetObject(lastId)); 
     64         } 
     65 
    5566         static Context* GetCurrentContext(void) 
    5667         { return (Context::GetObject(Context::GetCurrentContextId())); } 
    5768 
    58          static void SetCurrentContext(const string& id) 
    59          { 
     69         static void SetCurrentContext(const string& id, bool withSwap = false) 
     70         { 
     71            if (withSwap) Stid.push (Context::GetCurrentContextId()); 
     72 
    6073            // On modifie le context courrant pour tout les ObjectTemplate 
    6174            Context::SetContext(id); 
     
    121134         } 
    122135 
     136         static string GetRootName(void) { return ("simulation"); } 
    123137         static string GetName(void)     { return ("context"); } 
    124          static string GetRootName(void) { return ("simulation"); } 
     138         static string GetDefName(void)  { return (Context::GetName()); } 
     139 
    125140 
    126141         virtual bool hasChild(void) const 
     
    185200      private: 
    186201 
     202         static stack<string> Stid; 
     203 
    187204         AbstractCalendar* ccalendar; 
    188205 
     
    194211 
    195212   }; //class Context 
     213 
     214   //stack<string> Context::Stid(); 
     215 
    196216}// namespace XMLIOSERVER 
    197217 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/domain.hpp

    r122 r125  
    1717 
    1818         static string GetName(void) {return ("domain"); } 
     19         static string GetDefName(void) { return (CDomain::GetName()); } 
    1920 
    2021         inline void check(void) ; 
     
    2627   void CDomain::check(void) 
    2728   { 
    28       static bool isChecked = false ; 
     29      //static bool isChecked = false ; 
    2930 
    30       if (isChecked) return; // Si la vérification a été faite, on arrête tout. 
     31      //if (isChecked) return; // Si la vérification a été faite, on arrête tout. 
    3132 
    3233      // domaine global 
     
    173174      } 
    174175 
    175       isChecked = true ; 
     176      //isChecked = true ; 
    176177   } 
    177178 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp

    r124 r125  
    2020 
    2121         static string GetName(void) { return ("field"); } 
     22         static string GetDefName(void)  { return (CField::GetName()); } 
    2223 
    2324         inline void solveGridRef(void) ; 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp

    r124 r125  
    1717 
    1818         static string GetName(void) { return ("file"); } 
     19         static string GetDefName(void)  { return (CFile::GetName()); } 
    1920 
    2021         virtual void parse (XMLNode& _node) 
     
    9293         void resolveFieldRefInheritance(void) 
    9394         { // Résolution des héritages par référence de chacun des champs contenus dans le fichier. 
    94             std::vector<CField*> allF; getAllFields(allF); 
     95            std::vector<CField*> allF; this->getAllFields(allF); 
    9596            for (unsigned int i = 0; i < allF.size(); i++) allF[i]->resolveRefInheritance(); 
    9697         } 
     
    103104            std::vector<CField*>::iterator it; 
    104105 
    105             getAllFields(enabledFields); 
     106            this->getAllFields(enabledFields); 
    106107 
    107108            for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 
    108             { 
     109            { // TODO Jeu avec les itérateurs un peu bizarre, à modifier. 
     110              // std::cout << (*it)->field_ref <<std::endl; 
    109111               if ((*it)->enabled.hasValue()) // Si l'attribut 'enabled' est défini ... 
    110112               { 
    111113                  if (! ((*it)->enabled)) 
    112                   { enabledFields.erase(it); continue; } 
     114                  { it--; enabledFields.erase(it+1); continue; } 
    113115               } 
    114116               else // Si l'attribut 'enabled' n'est pas défini ... 
    115117               { 
    116118                  if (!default_enabled) 
    117                   { enabledFields.erase(it); continue; } 
     119                  { it--; enabledFields.erase(it+1); continue; } 
    118120               } 
    119121 
     
    121123               { 
    122124                  if ((*it)->level > _outputlevel) 
    123                   { enabledFields.erase(it); continue; } 
     125                  { it--; enabledFields.erase(it+1); continue; } 
    124126               } 
    125127               else // Si l'attribut 'level' n'est pas défini ... 
    126128               { 
    127129                  if (default_level > _outputlevel) 
    128                   { enabledFields.erase(it); continue; } 
     130                  { it--; enabledFields.erase(it+1); continue; } 
    129131               } 
    130132 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/grid.hpp

    r124 r125  
    1818 
    1919         static string GetName(void) { return ("grid"); } 
     20         static string GetDefName(void)  { return (CGrid::GetName()); } 
    2021 
    2122         const CAxis* getRelAxis(void) const { return (axis); } 
    2223         const CDomain* getRelDomain(void) const { return (domain); } 
     24 
     25         const Array<int, 1>& getStoreIndex(void) { return (storeIndex); } 
     26         const Array<int, 1>& getOutIIndex(void) { return (out_i_index); } 
     27         const Array<int, 1>& getOutJIndex(void) { return (out_j_index); } 
     28         const Array<int, 1>& getOutLIndex(void) { return (out_l_index); } 
    2329 
    2430         inline void solveReference(void) ; 
     
    8288   { 
    8389 
    84       static bool isReferenceSolved = false; 
    85       if (isReferenceSolved) return; 
     90      /**static bool isReferenceSolved = false; 
     91      if (isReferenceSolved) 
     92      { 
     93         std::cout << "C'est n'importe quoi, A modifierrrrrrrrrrr!!!!!!!!!!!!!!!!!!!!!" << std::endl; 
     94         return; 
     95      }*/ 
    8696 
    8797      // Résolution de chacune des références et indexation. 
     
    90100      computeIndex() ; 
    91101 
    92       isReferenceSolved = true ; 
     102      //isReferenceSolved = true ; 
    93103   } 
    94104 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp

    r124 r125  
    4141         } 
    4242 
    43          string getName(void) const {return (T::GetName()); } 
     43         string getName(void) const 
     44         { 
     45            if (hasId()) 
     46               if (T::GetDefName().compare(getId()) == 0) 
     47                  return T::GetDefName(); 
     48            return (T::GetName()); 
     49         } 
    4450 
    4551         T* getBaseObject(void) const { return (baseObject); } 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xml_parser.hpp

    r123 r125  
    3737                  Context& context = *Context::CreateObject(attributes["id"]); 
    3838 
    39                   if (attributes.end() != attributes.find("calendar_type") && attributes.end() != attributes.find("start_date")) 
     39                  if ((attributes.end() != attributes.find("calendar_type")) && 
     40                      (attributes.end() != attributes.find("start_date"))) 
    4041                     context.setCalendar(attributes["calendar_type"], attributes["start_date"]); 
    4142 
  • XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp

    r124 r125  
    77#include <cmath> 
    88 
    9  
    109// Conteneurs. 
    1110#include <vector> 
    1211#include <set> 
     12#include <stack> 
    1313 
    1414//Flux. 
Note: See TracChangeset for help on using the changeset viewer.