Changeset 214
- Timestamp:
- 06/14/11 16:20:27 (13 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/xmlio
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/client.cpp
r199 r214 19 19 } 20 20 21 ///-------------------------------------------------------------- 22 23 boost::shared_ptr<CClient> CClient::Client; 24 25 ///-------------------------------------------------------------- 26 27 boost::shared_ptr<CClient> CClient::CreateClient(MPIComm comm_client_server) 28 { 29 if (CClient::Client.get() != NULL) 30 CClient::Client = boost::shared_ptr<CClient>(new CClient(comm_client_server)); 31 return (CClient::GetClient()); 32 } 33 34 ///-------------------------------------------------------------- 35 36 boost::shared_ptr<CClient> CClient::GetClient(void) 37 { 38 return (CClient::Client); 39 } 40 21 41 ///-------------------------------------------------------------- 22 42 … … 71 91 this->bpair.getCurrentBuffer().appendInt(timestep); 72 92 } 93 94 //--------------------------------------------------------------- 95 96 void CClient::setTimestep(const date::CDuration & duration) 97 { 98 StdString durationstr = duration.toString(); 99 this->bpair.prepareRequest(1, 2, &durationstr, 100 CLinearBuffer::NULL_ARG, 101 CLinearBuffer::NULL_ARG, 102 CLinearBuffer::NULL_ARG); 103 this->bpair.getCurrentBuffer().appendString(durationstr); 104 } 73 105 74 106 //--------------------------------------------------------------- 75 107 76 void CClient::sendData(const StdString & fieldId, const ARRAY(float, 1) dataArray) 108 void CClient::sendData 109 (const StdString & fieldId, const StdString & fileId, const ARRAY(float, 1) dataArray) 77 110 { 78 this->bpair.prepareRequest(2, 0, &fieldId, &dataArray, 79 CLinearBuffer::NULL_ARG, 111 this->bpair.prepareRequest(2, 0, &fieldId, &fileId, &dataArray, 80 112 CLinearBuffer::NULL_ARG); 81 113 this->bpair.getCurrentBuffer().appendString(fieldId); 114 this->bpair.getCurrentBuffer().appendString(fileId); 82 115 this->bpair.getCurrentBuffer().appendFloatArray(dataArray); 83 116 } … … 85 118 //--------------------------------------------------------------- 86 119 87 void CClient::sendData(const StdString & fieldId, const ARRAY(double, 1) dataArray) 120 void CClient::sendData 121 (const StdString & fieldId, const StdString & fileId, const ARRAY(double, 1) dataArray) 88 122 { 89 this->bpair.prepareRequest(2, 1, &fieldId, &dataArray, 90 CLinearBuffer::NULL_ARG, 123 this->bpair.prepareRequest(2, 1, &fieldId, &fileId, &dataArray, 91 124 CLinearBuffer::NULL_ARG); 92 125 this->bpair.getCurrentBuffer().appendString(fieldId); 126 this->bpair.getCurrentBuffer().appendString(fileId); 93 127 this->bpair.getCurrentBuffer().appendDoubleArray(dataArray); 94 128 } -
XMLIO_V2/dev/dev_rv/src/xmlio/client.hpp
r199 r214 7 7 #include "buffer_pair.hpp" 8 8 #include "array.hpp" 9 #include "duration.hpp" 9 10 10 11 namespace xmlioserver { … … 16 17 { 17 18 public : 18 19 /// Constructeurs ///20 CClient(MPIComm comm_client_server);19 20 static boost::shared_ptr<CClient> CreateClient(MPIComm comm_client_server); 21 static boost::shared_ptr<CClient> GetClient(void); 21 22 22 23 /// Destructeur /// … … 34 35 public : 35 36 36 void setContext(const StdString & idContext); // manager 1, method 0 37 void updateCalendar(long int timestep); // manager 1, method 1 37 void setContext(const StdString & idContext); // manager 1, method 0 38 void updateCalendar(long int timestep); // manager 1, method 1 39 void setTimestep(const date::CDuration & duration);// manager 1, method 2 38 40 39 void sendData(const StdString & fieldId, const ARRAY(float, 1) dataArray); // manager 2, method 0 40 void sendData(const StdString & fieldId, const ARRAY(double, 1) dataArray); // manager 2, method 1 41 void sendData(const StdString & fieldId, 42 const StdString & fileId, 43 const ARRAY(float, 1) dataArray); // manager 2, method 0 44 45 void sendData(const StdString & fieldId, 46 const StdString & fileId, 47 const ARRAY(double, 1) dataArray); // manager 2, method 1 41 48 42 49 private : 50 51 /// Constructeurs /// 52 CClient(MPIComm comm_client_server); 43 53 44 54 /// Propriété privée /// 45 55 CBufferPair bpair; 56 57 static boost::shared_ptr<CClient> Client; 46 58 47 59 }; // class CClient -
XMLIO_V2/dev/dev_rv/src/xmlio/data_treatment.cpp
r206 r214 5 5 #include "group_template_impl.hpp" 6 6 #include "object_factory_impl.hpp" 7 7 8 8 9 namespace xmlioserver … … 30 31 { 31 32 return (this->enabledFiles); 33 } 34 //---------------------------------------------------------------- 35 36 void CDataTreatment::update_calendar(int step) 37 { 38 // Mise à jour cÃŽté client 39 this->currentContext->getCalendar()->update(step); 40 if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT) 41 { // Mise à jour cÃŽté serveur 42 boost::shared_ptr<comm::CClient> client = comm::CClient::GetClient(); 43 client->updateCalendar(step); 44 } 45 } 46 47 void CDataTreatment::set_timestep(const date::CDuration & duration) 48 { 49 // Mise à jour cÃŽté client 50 this->currentContext->getCalendar()->setTimeStep(duration); 51 if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT) 52 { // Mise à jour cÃŽté serveur 53 boost::shared_ptr<comm::CClient> client = comm::CClient::GetClient(); 54 client->setTimestep(duration); 55 } 56 } 57 58 //---------------------------------------------------------------- 59 60 void CDataTreatment::write_data 61 (const StdString & fieldId, 62 const StdString & fileId, 63 const std::deque<ARRAY(double, 1)> & data) 64 { 65 const date::CDate & currDate = 66 this->currentContext->getCalendar()->getCurrentDate(); 67 const std::vector<boost::shared_ptr<CField> > & refField= 68 CObjectFactory::GetObject<CField>(fieldId)->getAllReference(); 69 std::vector<boost::shared_ptr<CField> >::const_iterator 70 it = refField.begin(), end = refField.end(); 71 72 for (; it != end; it++) 73 { 74 boost::shared_ptr<CField> field = *it; 75 boost::shared_ptr<CFile> file = field->getRelFile(); 76 if (file->getId().compare(fileId) == 0) 77 { 78 if (field->updateDataServer(currDate, data)) 79 file->getDataOutput()->writeFieldData(field); 80 return; 81 } 82 } 83 32 84 } 33 85 -
XMLIO_V2/dev/dev_rv/src/xmlio/data_treatment.hpp
r208 r214 7 7 #include "mpi_manager.hpp" 8 8 #include "data_output.hpp" 9 #include "duration.hpp" 10 #include "client.hpp" 11 #include "xios_manager.hpp" 9 12 10 13 namespace xmlioserver … … 29 32 const std::vector<boost::shared_ptr<CFile> > & getEnabledFiles (void) const; 30 33 31 /// Creation des sorties /// 34 /// Ecriture et mise à jour du calendrier /// 35 void write_data(const StdString & fieldId, 36 const StdString & fileId, 37 const std::deque<ARRAY(double, 1)> & data); 38 39 template <StdSize N> 40 void write_data(const StdString & fieldId, const ARRAY(double, N) & data); 41 42 template <StdSize N> 43 void write_data(const StdString & fieldId, const ARRAY(float, N) & data); 44 45 void update_calendar(int step); 46 void set_timestep(const date::CDuration & duration); 47 48 /// Création des sorties /// 32 49 template <class T> void createDataOutput(void); 33 50 … … 72 89 } 73 90 91 template <StdSize N> 92 void CDataTreatment::write_data 93 (const StdString & fieldId, const ARRAY(float, N) & data) 94 { 95 std::vector<boost::multi_array<double, N>::size_type shape() > shape; 96 const size_type * shapearr = data->shape(); 97 98 shape.assign(shapearr, shapearr + N); 99 ARRAY_CREATE(datad, double, N, shape); 100 datad->assign(data->begin(), data->end()); 101 102 this->write_data(fieldId, datad); 103 } 104 105 template <StdSize N> 106 void CDataTreatment::write_data 107 (const StdString & fieldId, const ARRAY(double, N) & data) 108 { 109 const date::CDate & currDate = 110 this->currentContext->getCalendar()->getCurrentDate(); 111 const std::vector<boost::shared_ptr<CField> > & refField= 112 CObjectFactory::GetObject<CField>(fieldId)->getAllReference(); 113 std::vector<boost::shared_ptr<CField> >::const_iterator 114 it = refField.begin(), end = refField.end(); 115 116 for (; it != end; it++) 117 { 118 boost::shared_ptr<CField> field = *it; 119 boost::shared_ptr<CFile> file = field->getRelFile(); 120 if (field->updateData(currDate, data)) 121 { 122 if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT) 123 { 124 boost::shared_ptr<comm::CClient> client = comm::CClient::GetClient(); 125 client.sendData(fieldId, file->getId(), field->getData()); 126 } 127 else 128 { 129 file->getDataOutput()->writeFieldData(field); 130 } 131 } 132 return; 133 } 134 135 } 136 74 137 } // namespace data 75 138 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/field.hpp
r208 r214 54 54 55 55 /// Accesseurs /// 56 boost::shared_ptr<CField> getDirectFieldReference(void) const;57 const boost::shared_ptr<CField> getBaseFieldReference(void) const;56 boost::shared_ptr<CField> getDirectFieldReference(void) const; 57 const boost::shared_ptr<CField> getBaseFieldReference(void) const; 58 58 const std::vector<boost::shared_ptr<CField> > & getAllReference(void) const; 59 59 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/file.cpp
r189 r214 33 33 34 34 //---------------------------------------------------------------- 35 36 boost::shared_ptr<io::CDataOutput> CFile::getDataOutput(void) const 37 { 38 return (data_out); 39 } 35 40 36 41 boost::shared_ptr<CFieldGroup> CFile::getVirtualFieldGroup(void) const -
XMLIO_V2/dev/dev_rv/src/xmlio/node/file.hpp
r174 r214 47 47 48 48 /// Accesseurs /// 49 boost::shared_ptr<io::CDataOutput> getDataOutput(void) const; 49 50 boost::shared_ptr<CFieldGroup> getVirtualFieldGroup(void) const; 50 51 std::vector<boost::shared_ptr<CField> > getAllFields(void) const; … … 54 55 int default_level = 1, 55 56 bool default_enabled = true); 57 58 public : 56 59 57 60 /// Mutateurs /// -
XMLIO_V2/dev/dev_rv/src/xmlio/server.cpp
r199 r214 1 1 #include "server.hpp" 2 3 #include "tree_manager.hpp" 4 #include "duration.hpp" 5 #include "data_treatment.hpp" 2 6 3 7 namespace xmlioserver { … … 14 18 15 19 ///-------------------------------------------------------------- 20 21 boost::shared_ptr<CServer> CServer::Server; 22 23 ///-------------------------------------------------------------- 16 24 17 25 const CBufferList & CServer::getBufferList(void) const 18 26 { 19 27 return (this->blist); 20 } 28 } 29 30 ///-------------------------------------------------------------- 31 32 boost::shared_ptr<CServer> CServer::CreateServer(MPIComm comm_client_server) 33 { 34 if (CServer::Server.get() != NULL) 35 CServer::Server = boost::shared_ptr<CServer>(new CServer(comm_client_server)); 36 return (CServer::GetServer()); 37 } 38 39 ///-------------------------------------------------------------- 40 41 boost::shared_ptr<CServer> CServer::GetServer(void) 42 { 43 return (CServer::Server); 44 } 21 45 22 46 //--------------------------------------------------------------- … … 74 98 this->updateCalendar(lbuffer); 75 99 continue; 100 case (2) : 101 this->setTimestep(lbuffer); 102 continue; 76 103 default : 77 104 ERROR("CServer::run(void)", … … 121 148 comm::CMPIManager::Barrier(); 122 149 } 123 150 151 //-------------------------------------------------------------- 152 153 void CServer::setTimestep(const std::vector<CLinearBuffer> & buffer)// manager 1, method 2 154 { 155 boost::shared_ptr<CContext> context = 156 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 157 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 158 159 StdString durationstr; 160 for (StdSize i = 0; i < buffer.size(); i++) 161 { 162 StdString durationstr_ = buffer[i].getString(3); 163 if (durationstr.compare(durationstr_) != 0 && (i != 0)) 164 { 165 ERROR("CServer::setTimestep(const std::vector<CLinearBuffer> & buffer)", 166 << "[ durationstr 1 = " << durationstr << ", " 167 << "[ durationstr 2 = " << durationstr_ << "] " 168 << " Modification de timestep désynchronisé !"); 169 } 170 else durationstr = durationstr_; 171 172 } 173 std::cout << "setTimestep called " << durationstr << std::endl; 174 dtreat->set_timestep(date::CDuration::FromString(durationstr)); 175 } 176 124 177 //-------------------------------------------------------------- 125 178 … … 141 194 } 142 195 std::cout << "setContext called " << contextId << std::endl; 196 CTreeManager::SetCurrentContextId(contextId); 143 197 } 144 198 … … 147 201 void CServer::updateCalendar(const std::vector<CLinearBuffer> & buffer) // manager 1, method 1 148 202 { 203 boost::shared_ptr<CContext> context = 204 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 205 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 206 149 207 int timestep = -1; 150 208 for (StdSize i = 0; i < buffer.size(); i++) … … 161 219 } 162 220 std::cout << "updateCalendar called " << timestep <<std::endl; 221 dtreat->update_calendar(timestep); 163 222 } 164 223 … … 167 226 void CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec) // manager 2, method 0 - 1 168 227 { 169 StdString fieldId; 228 boost::shared_ptr<CContext> context = 229 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 230 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 231 232 StdString fieldId, fileId; 170 233 for (StdSize i = 0; i < buffer.size(); i++) 171 234 { 172 235 StdString fieldId_ = buffer[i].getString(3); 236 StdString fileId_ = buffer[i].getString(4); 237 173 238 if (fieldId.compare(fieldId_) != 0 && (i != 0)) 174 239 { … … 178 243 << " Ecriture des données désynchronisée !"); 179 244 } 180 else fieldId = fieldId_; 245 else fieldId = fieldId_; 246 247 if (fileId.compare(fileId_) != 0 && (i != 0)) 248 { 249 ERROR("CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec)", 250 << "[fileId 1 = " << fileId << ", " 251 << " fileId 2 = " << fileId_ << "] " 252 << " Ecriture des données désynchronisée !"); 253 } 254 else fileId = fileId_; 181 255 } 182 256 … … 185 259 std::deque<ARRAY(float, 1)> dataArray(buffer.size()); 186 260 for (StdSize i = 0; i < buffer.size(); i++) 187 dataArray[i] = buffer[i].getFloatArray(4); 188 261 dataArray[i] = buffer[i].getFloatArray(5); 189 262 std::cout << "writeData called (float) " << fieldId << ", " << dataArray[0] << std::endl; 263 // Jamais atteint car les données sont transférées en tant que double 190 264 return; 191 265 } … … 194 268 std::deque<ARRAY(double, 1)> dataArray(buffer.size()); 195 269 for (StdSize i = 0; i < buffer.size(); i++) 196 dataArray[i] = buffer[i].getDoubleArray(4); 197 270 dataArray[i] = buffer[i].getDoubleArray(5); 198 271 std::cout << "writeData called (double) " << fieldId << ", " << dataArray[0] << std::endl; 272 dtreat->write_data(fieldId, fileId, dataArray); 199 273 return; 200 274 } -
XMLIO_V2/dev/dev_rv/src/xmlio/server.hpp
r196 r214 16 16 { 17 17 public : 18 19 /// Constructeurs ///20 CServer(MPIComm comm_client_server);21 18 19 static boost::shared_ptr<CServer> CreateServer(MPIComm comm_client_server); 20 static boost::shared_ptr<CServer> GetServer(void); 21 22 22 /// Destructeur /// 23 23 ~CServer(void); … … 36 36 void finalize(void); // manager 0, method 1 37 37 38 void setContext (const std::vector<CLinearBuffer> & buffer);// manager 1, method 038 void setContext (const std::vector<CLinearBuffer> & buffer); // manager 1, method 0 39 39 void updateCalendar(const std::vector<CLinearBuffer> & buffer); // manager 1, method 1 40 void setTimestep (const std::vector<CLinearBuffer> & buffer); // manager 1, method 2 40 41 41 42 void writeData(const std::vector<CLinearBuffer> & buffer, int prec); // manager 2, method 0 - 1 42 43 43 44 private : 45 46 /// Constructeurs /// 47 CServer(MPIComm comm_client_server); 44 48 45 49 /// Propriété privée /// 46 50 CBufferList blist; 51 52 static boost::shared_ptr<CServer> Server; 47 53 48 54 }; // class CServer
Note: See TracChangeset
for help on using the changeset viewer.