- Timestamp:
- 10/05/10 09:47:10 (14 years ago)
- 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 20 20 protected : 21 21 22 Poco::HashMap<string, int> getAllLimitedDim(void) 22 Poco::HashMap<string, int> getAllLimitedDim(void) const 23 23 { 24 24 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 } 33 40 34 41 std::set<const CAxis*>::const_iterator it; 35 42 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 } 37 47 38 48 return (dims); … … 45 55 { 46 56 time_t rawtime; 47 struct tm * timeinfo ;57 struct tm * timeinfo = NULL; 48 58 char buffer [100]; 49 59 … … 77 87 { 78 88 bool withTime = true; 79 const Poco::HashMap<string, int>& allDim = getAllLimitedDim();89 const Poco::HashMap<string, int>& allDim = this->getAllLimitedDim(); 80 90 Poco::HashMap<string, int>::ConstIterator it; 81 91 … … 99 109 Poco::HashMap<string, string> hm; 100 110 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 } 124 142 125 143 // Attribut des autres coordonnées. … … 127 145 for ( it = saxis.begin() ; it != saxis.end(); it++ ) 128 146 { 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())))) 130 149 throw XMLIOUndefinedValueException("Impossible d'ajouter la variable "+ (*it)->getId() +" !"); 131 150 … … 150 169 for ( it = enabledFields.begin() ; it != enabledFields.end(); it++ ) 151 170 { 152 CField*field = (*it);171 CField* field = (*it); 153 172 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. 154 182 155 183 lonlat = !field->getGrid()->_hasAxis(); … … 158 186 { // Si une opération sur le champ est définie ... 159 187 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); } 164 189 } 165 190 else … … 175 200 ((FieldOperation)field->operation).setFreqOp(Duration(field->freq_op)); 176 201 177 178 202 tvar = ncFloat; 179 203 if (field->prec.hasValue()) … … 184 208 if (lonlat) // 2D spatio + temps 185 209 { 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())))) 188 212 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 189 213 } 190 214 else // 3D spatio + temps 191 215 { 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())))) 195 219 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 196 220 } … … 200 224 if (lonlat) // 2D spatio sans temps 201 225 { 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())))) 204 228 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 205 229 } 206 230 else // 3D spatio sans temps 207 231 { 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())))) 211 235 throw XMLIOUndefinedValueException("Impossible d'ajouter le champ "+ field->getId() +" !"); 212 236 } … … 221 245 } 222 246 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 223 259 private : 224 260 -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_output.hpp
r122 r125 34 34 35 35 36 virtual void initFile (void) = 0;37 virtual void setDims (void) = 0;36 virtual void initFile (void) = 0; 37 virtual void setDims (void) = 0; 38 38 virtual void setCoords(void) = 0; 39 virtual void setVars (void) = 0;39 virtual void setVars (void) = 0; 40 40 41 41 private : -
XMLIO_V2/dev/dev_rv/src/XMLIO/abstract_data_treatment.hpp
r124 r125 40 40 41 41 std::vector<CField*>::const_iterator it; 42 42 43 for (it = vectRef.begin(); it != vectRef.end(); it++ ) 43 44 { … … 47 48 (*it)->getGrid()->storeField(arr, data_uni); 48 49 (*it)->storeData(data_uni, currentContext->getCalendar()->getCurrentDate()); 50 } 51 52 if (true) 53 { // Ecriture des données si nécessaire. 54 49 55 } 50 56 } … … 61 67 AbstractDataTreatment(Context* const _ctxt, const AbstractCalendar& cal) : enabledFiles(), currentContext(_ctxt) 62 68 { 69 // Résolution des héritages pour le context actuel (Context::ResolveInheritance() résoud les héritages pour tous les contextes). 63 70 //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).65 71 solveAllInheritance(); 66 72 67 // 73 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 68 74 //std::cout << "(Message temporaire) Initialisation du vecteur enabledFiles ..." << std::endl; 69 75 findEnabledFiles(); 70 76 71 // 77 //Recherche des champs à sortir (enable à true + niveau de sortie correct) pour chaque fichier précédemment listé. 72 78 //std::cout << "(Message temporaire) Recherche des champs à sortir ..." << std::endl; 73 79 findAllEnabledFields(cal.getInitDate()); -
XMLIO_V2/dev/dev_rv/src/XMLIO/axis.hpp
r114 r125 17 17 18 18 static string GetName(void) {return ("axis"); } 19 static string GetDefName(void) { return (CAxis::GetName()); } 19 20 20 21 virtual ~CAxis(void) -
XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp
r124 r125 56 56 calendar->update(); 57 57 58 std::cout << "> Itération de calcul " << tcourant << ", 58 std::cout << "> Itération de calcul " << tcourant << ", " << *calendar << std::endl; 59 59 60 60 // Mise à jour des données. … … 63 63 // Ecriture des données. 64 64 dtreat->writeData<Array<double, 3> >("champ1", arr); 65 66 65 } 67 66 68 67 // On écrit l'arborescence résultante du traitement sur la sortie de log. 69 Context::ShowTree(std::clog);68 // Context::ShowTree(std::clog); 70 69 71 70 delete dtreat; -
XMLIO_V2/dev/dev_rv/src/XMLIO/context.hpp
r124 r125 53 53 } 54 54 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 55 66 static Context* GetCurrentContext(void) 56 67 { return (Context::GetObject(Context::GetCurrentContextId())); } 57 68 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 60 73 // On modifie le context courrant pour tout les ObjectTemplate 61 74 Context::SetContext(id); … … 121 134 } 122 135 136 static string GetRootName(void) { return ("simulation"); } 123 137 static string GetName(void) { return ("context"); } 124 static string GetRootName(void) { return ("simulation"); } 138 static string GetDefName(void) { return (Context::GetName()); } 139 125 140 126 141 virtual bool hasChild(void) const … … 185 200 private: 186 201 202 static stack<string> Stid; 203 187 204 AbstractCalendar* ccalendar; 188 205 … … 194 211 195 212 }; //class Context 213 214 //stack<string> Context::Stid(); 215 196 216 }// namespace XMLIOSERVER 197 217 -
XMLIO_V2/dev/dev_rv/src/XMLIO/domain.hpp
r122 r125 17 17 18 18 static string GetName(void) {return ("domain"); } 19 static string GetDefName(void) { return (CDomain::GetName()); } 19 20 20 21 inline void check(void) ; … … 26 27 void CDomain::check(void) 27 28 { 28 static bool isChecked = false ;29 //static bool isChecked = false ; 29 30 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. 31 32 32 33 // domaine global … … 173 174 } 174 175 175 isChecked = true ;176 //isChecked = true ; 176 177 } 177 178 -
XMLIO_V2/dev/dev_rv/src/XMLIO/field.hpp
r124 r125 20 20 21 21 static string GetName(void) { return ("field"); } 22 static string GetDefName(void) { return (CField::GetName()); } 22 23 23 24 inline void solveGridRef(void) ; -
XMLIO_V2/dev/dev_rv/src/XMLIO/file.hpp
r124 r125 17 17 18 18 static string GetName(void) { return ("file"); } 19 static string GetDefName(void) { return (CFile::GetName()); } 19 20 20 21 virtual void parse (XMLNode& _node) … … 92 93 void resolveFieldRefInheritance(void) 93 94 { // 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); 95 96 for (unsigned int i = 0; i < allF.size(); i++) allF[i]->resolveRefInheritance(); 96 97 } … … 103 104 std::vector<CField*>::iterator it; 104 105 105 getAllFields(enabledFields);106 this->getAllFields(enabledFields); 106 107 107 108 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; 109 111 if ((*it)->enabled.hasValue()) // Si l'attribut 'enabled' est défini ... 110 112 { 111 113 if (! ((*it)->enabled)) 112 { enabledFields.erase(it); continue; }114 { it--; enabledFields.erase(it+1); continue; } 113 115 } 114 116 else // Si l'attribut 'enabled' n'est pas défini ... 115 117 { 116 118 if (!default_enabled) 117 { enabledFields.erase(it); continue; }119 { it--; enabledFields.erase(it+1); continue; } 118 120 } 119 121 … … 121 123 { 122 124 if ((*it)->level > _outputlevel) 123 { enabledFields.erase(it); continue; }125 { it--; enabledFields.erase(it+1); continue; } 124 126 } 125 127 else // Si l'attribut 'level' n'est pas défini ... 126 128 { 127 129 if (default_level > _outputlevel) 128 { enabledFields.erase(it); continue; }130 { it--; enabledFields.erase(it+1); continue; } 129 131 } 130 132 -
XMLIO_V2/dev/dev_rv/src/XMLIO/grid.hpp
r124 r125 18 18 19 19 static string GetName(void) { return ("grid"); } 20 static string GetDefName(void) { return (CGrid::GetName()); } 20 21 21 22 const CAxis* getRelAxis(void) const { return (axis); } 22 23 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); } 23 29 24 30 inline void solveReference(void) ; … … 82 88 { 83 89 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 }*/ 86 96 87 97 // Résolution de chacune des références et indexation. … … 90 100 computeIndex() ; 91 101 92 isReferenceSolved = true ;102 //isReferenceSolved = true ; 93 103 } 94 104 -
XMLIO_V2/dev/dev_rv/src/XMLIO/object_template.hpp
r124 r125 41 41 } 42 42 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 } 44 50 45 51 T* getBaseObject(void) const { return (baseObject); } -
XMLIO_V2/dev/dev_rv/src/XMLIO/xml_parser.hpp
r123 r125 37 37 Context& context = *Context::CreateObject(attributes["id"]); 38 38 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"))) 40 41 context.setCalendar(attributes["calendar_type"], attributes["start_date"]); 41 42 -
XMLIO_V2/dev/dev_rv/src/XMLIO/xmlio.hpp
r124 r125 7 7 #include <cmath> 8 8 9 10 9 // Conteneurs. 11 10 #include <vector> 12 11 #include <set> 12 #include <stack> 13 13 14 14 //Flux.
Note: See TracChangeset
for help on using the changeset viewer.