Changeset 266
- Timestamp:
- 09/06/11 16:45:08 (13 years ago)
- Location:
- XMLIO_V2/dev/common/src/xmlio
- Files:
-
- 4 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/common/src/xmlio/calendar.cpp
r219 r266 53 53 54 54 CDate & CCalendar::update(int step) 55 { return (this->getCurrentDate() = this->getCurrentDate() + step * this->timestep); } 55 { 56 std::cout << "step : " << step << std::endl; 57 return (this->getCurrentDate() = this->getInitDate() + step * this->timestep); 58 } 56 59 57 60 //----------------------------------------------------------------- -
XMLIO_V2/dev/common/src/xmlio/calendar_util.cpp
r219 r266 37 37 { 38 38 CDuration dur(ddr); 39 dur.year = -dur.year; dur.month = -dur.month ; dur.day = -dur.day; 40 dur.hour = -dur.hour; dur.minute = -dur.minute; dur.second = -dur.second; 39 dur.year = -dur.year; 40 dur.month = -dur.month; 41 dur.day = -dur.day; 42 dur.hour = -dur.hour; 43 dur.minute = -dur.minute; 44 dur.second = -dur.second; 41 45 return (dur); 42 46 } … … 68 72 69 73 // Ajustement des mois en fonction des jours. 70 int signVal = drr.day/fabs(drr.day);74 int signVal = (drr.day != 0) ? drr.day/fabs(drr.day) : 0; 71 75 CDate dtt(dt); dtt.addMonth (signVal); 72 76 … … 77 81 if (day < 0) { drr.month --; day += c.getMonthLength(dtt); } 78 82 if (day >= c.getMonthLength(dtt)) { drr.month ++; day -= c.getMonthLength(dtt); } // << ProblÚme ici 79 if (day == 0) day = c.getMonthLength(dtt);80 83 if (day == 0){ day = c.getMonthLength(dtt); drr.month --; } 84 81 85 drr.resolve(dt.getRelCalendar()); 82 86 83 87 // Ajustement des années en fonction des mois. 84 88 month += dt.getMonth() + drr.month; 85 if (month < 0) { year --; month += c.getYearLength(); }86 if (month > = c.getYearLength()) {year ++; month -= c.getYearLength(); }87 if (month == 0) month = c.getYearLength();89 if (month < 0) { drr.year --; month += c.getYearLength(); } 90 if (month > c.getYearLength()) { drr.year ++; month -= c.getYearLength(); } 91 if (month == 0){ month = c.getYearLength(); drr.year--; } 88 92 89 93 year += dt.getYear() + drr.year; … … 118 122 { 119 123 // TODO :: Vérifier que les deux dates (dt0 et dt1) ont une référence vers le même calendrier. 120 if (dt0.getYear() < dt1.getYear()) return true; if (dt0.getMonth() < dt1.getMonth()) return true; 121 if (dt0.getDay() < dt1.getDay()) return true; if (dt0.getHour() < dt1.getHour()) return true; 122 if (dt0.getMinute() < dt1.getMinute()) return true; if (dt0.getSecond() < dt1.getSecond()) return true; 124 if (dt0.getYear() < dt1.getYear()) 125 { 126 return true; 127 } 128 else if (dt0.getYear() == dt1.getYear()) 129 { 130 if (dt0.getMonth() < dt1.getMonth()) 131 { 132 return true; 133 } 134 else if (dt0.getMonth() == dt1.getMonth()) 135 { 136 if (dt0.getDay() < dt1.getDay()) 137 { 138 return true; 139 } 140 else if (dt0.getDay() == dt1.getDay()) 141 { 142 if (dt0.getHour() < dt1.getHour()) 143 { 144 return true; 145 } 146 else if (dt0.getHour() == dt1.getHour()) 147 { 148 if (dt0.getMinute() < dt1.getMinute()) 149 { 150 return true; 151 } 152 else if (dt0.getMinute() == dt1.getMinute()) 153 { 154 if (dt0.getSecond() < dt1.getSecond()) 155 return true; 156 } 157 } 158 } 159 } 160 } 123 161 return false; 124 162 } -
XMLIO_V2/dev/common/src/xmlio/config/field_attribute.conf
r219 r266 7 7 8 8 DECLARE_ATTRIBUTE(StdString, freq_op) 9 DECLARE_ATTRIBUTE(StdString, freq_offset) 9 10 DECLARE_ATTRIBUTE(int, level) 10 11 DECLARE_ATTRIBUTE(int, prec) -
XMLIO_V2/dev/common/src/xmlio/config/file_attribute.conf
r219 r266 2 2 DECLARE_ATTRIBUTE(StdString, description) 3 3 4 DECLARE_ATTRIBUTE(StdString, name_suffix) 5 4 6 DECLARE_ATTRIBUTE(StdString, output_freq) 5 6 7 DECLARE_ATTRIBUTE(int, output_level) 7 8 -
XMLIO_V2/dev/common/src/xmlio/config/functor_type.conf
r219 r266 8 8 9 9 #ifdef __XMLIO_COnce__ 10 DECLARE_FUNCTOR(Once 10 DECLARE_FUNCTOR(Once, once) 11 11 #endif //__XMLIO_COnce__ 12 12 13 #ifdef __XMLIO_CMaximum__ 14 DECLARE_FUNCTOR(Maximum , maximum) 15 #endif //__XMLIO_CMaximum__ 16 17 #ifdef __XMLIO_CMinimum__ 18 DECLARE_FUNCTOR(Minimum , minimum) 19 #endif //__XMLIO_CMinimum__ 20 21 13 22 #undef DECLARE_FUNCTOR -
XMLIO_V2/dev/common/src/xmlio/data_treatment.cpp
r219 r266 38 38 // Mise à jour cÃŽté client 39 39 this->currentContext->getCalendar()->update(step); 40 // std::cout << "current date : " << this->currentContext->getCalendar()->getCurrentDate() << std::endl; 40 41 if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT) 41 42 { // Mise à jour cÃŽté serveur … … 49 50 // Mise à jour cÃŽté client 50 51 this->currentContext->getCalendar()->setTimeStep(duration); 52 std::cout << "timestep :" << duration << std::endl; 51 53 if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT) 52 54 { // Mise à jour cÃŽté serveur -
XMLIO_V2/dev/common/src/xmlio/data_treatment.hpp
r231 r266 81 81 boost::shared_ptr<CFile> file = *it; 82 82 StdString filename = (!file->name.isEmpty()) 83 ? file->name.getValue() : file->getId();83 ? file->name.getValue() : file->getId(); 84 84 StdOStringStream oss; 85 oss << "wk/data/" << filename << "_node" << comm::CMPIManager::GetCommRank() << ".nc"; 85 if (!CObjectFactory::GetObject<CContext> 86 (CObjectFactory::GetCurrentContextId())->output_dir.isEmpty()) 87 oss << CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId())->output_dir.getValue(); 88 oss << filename; 89 if (!file->name_suffix.isEmpty()) 90 oss << file->name_suffix.getValue(); 91 if (comm::CMPIManager::GetCommSize() > 1) 92 oss << "_node" << comm::CMPIManager::GetCommRank(); 93 oss << ".nc"; 86 94 boost::shared_ptr<io::CDataOutput> dout(new T(oss.str(), false)); 87 95 file->initializeDataOutput(dout); … … 93 101 (const StdString & fieldId, const ARRAY(float, N) & data) 94 102 { 95 103 typedef typename boost::multi_array<double, N>::size_type sizetp; 96 104 std::vector<sizetp> shape; 97 105 const sizetp * shapearr = data->shape(); 98 106 99 107 shape.assign(shapearr, shapearr + N); 100 ARRAY_CREATE(datad, double, N, [shape]); 101 datad->assign(data->begin(), data->end()); 108 ARRAY(double, N) datad(new CArray<double, N>(shape)); 109 for (StdSize i = 0; i < datad->num_elements(); i++) 110 datad->data()[i] = data->data()[i]; 102 111 103 112 this->write_data(fieldId, datad); … … 110 119 const date::CDate & currDate = 111 120 this->currentContext->getCalendar()->getCurrentDate(); 121 const date::CDuration & timestep = 122 this->currentContext->getCalendar()->getTimeStep(); 112 123 const std::vector<boost::shared_ptr<CField> > & refField= 113 124 CObjectFactory::GetObject<CField>(fieldId)->getAllReference(); 114 125 std::vector<boost::shared_ptr<CField> >::const_iterator 115 126 it = refField.begin(), end = refField.end(); 116 127 // std::cout << "nb :" << refField.size() << std::endl; 117 128 for (; it != end; it++) 118 129 { 119 130 boost::shared_ptr<CField> field = *it; 120 131 boost::shared_ptr<CFile> file = field->getRelFile(); 121 if (field->updateData(currDate, data)) 132 // std::cout << ">> " << fieldId << ", " << file->getId() << std::endl; 133 if (field->updateData(currDate, timestep, data)) 122 134 { 123 135 if (CXIOSManager::GetStatus() == CXIOSManager::LOC_CLIENT) … … 131 143 } 132 144 } 133 return;134 145 } 135 146 -
XMLIO_V2/dev/common/src/xmlio/duration.cpp
r219 r266 50 50 while (!in.eof()) 51 51 { 52 in >> v >> c; 52 if (!(in >> v >> c)) 53 { 54 //DEBUG("----> Pb StdIStream & operator>>(StdIStream & in , CDuration & duration)") ; 55 //if (in.eof()) DEBUG("----> Fin de fichier StdIStream & operator>>(StdIStream & in , CDuration & duration)") ; 56 } 57 if (in.eof()) 58 { 59 //DEBUG("----> Fin de fichier StdIStream & operator>>(StdIStream & in , CDuration & duration)") ; 60 break ; 61 } 53 62 switch (c) 54 63 { 55 case 'y': duration.year = v; continue;56 case 'd': duration.day = v; continue;57 case 'h': duration.hour = v; continue;58 case 's': duration.second = v; continue;64 case 'y': duration.year = v; break; 65 case 'd': duration.day = v; break; 66 case 'h': duration.hour = v; break; 67 case 's': duration.second = v; break; 59 68 case 'm': 69 { 60 70 in >> c; 61 71 if (c == 'i') duration.minute = v; … … 64 74 { 65 75 StdString valc("m"); valc.append(1, c); 66 DEBUG("La chaine \"" << valc << "\" ne permet pas de définir une unité de durée.");67 continue;76 //DEBUG("La chaine \"" << valc << "\" ne permet pas de définir une unité de durée."); 77 break; 68 78 } 69 continue; 79 break; 80 } 70 81 default: 71 82 StdString valc; valc.append(1, c); 72 DEBUG("La chaine \"" << valc << "\" ne permet pas de définir une unité de durée.");73 continue;83 //DEBUG("La chaine \"" << valc << "\" ne permet pas de définir une unité de durée."); 84 break; 74 85 } 75 86 } -
XMLIO_V2/dev/common/src/xmlio/fake_client/fake_lmdz.f90
r219 r266 6 6 7 7 ! Modules de la bibliothÚque xmlioserver 8 USE IXMLIOSERVER8 USE XIOS 9 9 USE ISO_C_BINDING 10 10 -
XMLIO_V2/dev/common/src/xmlio/fake_client/fake_nemo.f90
r219 r266 6 6 7 7 ! Modules de la bibliothÚque xmlioserver 8 USE IXMLIOSERVER8 USE XIOS 9 9 USE ISO_C_BINDING 10 10 -
XMLIO_V2/dev/common/src/xmlio/fake_client/fake_orchidee.f90
r219 r266 6 6 7 7 ! Modules de la bibliothÚque xmlioserver 8 USE IXMLIOSERVER8 USE XIOS 9 9 USE ISO_C_BINDING 10 10 -
XMLIO_V2/dev/common/src/xmlio/fortran/ixmlioserver.f03.in
r219 r266 6 6 #include "macro.inc" 7 7 8 MODULE IXMLIOSERVER8 MODULE XIOS 9 9 USE, INTRINSIC :: ISO_C_BINDING 10 10 … … 110 110 111 111 SUBROUTINE xios_write_data(fieldid, fieldid_size, data_k8, data_Xsize, data_Ysize, data_Zsize) BIND(C) 112 import C_INT, C_CHAR, C_PTR, C_ FLOAT, C_DOUBLE, C_BOOL112 import C_INT, C_CHAR, C_PTR, C_DOUBLE, C_BOOL 113 113 CHARACTER(kind = C_CHAR), DIMENSION(*) :: fieldid 114 114 INTEGER (kind = C_INT), VALUE :: fieldid_size … … 116 116 INTEGER (kind = C_INT), VALUE :: data_Xsize, data_Ysize, data_Zsize 117 117 END SUBROUTINE xios_write_data 118 119 SUBROUTINE xios_write_data_f(fieldid, fieldid_size, data_k4, data_Xsize, data_Ysize, data_Zsize) BIND(C) 120 import C_INT, C_CHAR, C_PTR, C_FLOAT, C_BOOL 121 CHARACTER(kind = C_CHAR), DIMENSION(*) :: fieldid 122 INTEGER (kind = C_INT), VALUE :: fieldid_size 123 REAL(kind = C_FLOAT), DIMENSION(*) :: data_k4 124 INTEGER (kind = C_INT), VALUE :: data_Xsize, data_Ysize, data_Zsize 125 END SUBROUTINE xios_write_data_f 126 127 SUBROUTINE xios_init_ioserver(comm_client) BIND(C) 128 import C_INT 129 INTEGER (kind = C_INT) :: comm_client 130 END SUBROUTINE xios_init_ioserver 118 131 119 132 #define DECLARE_ATTRIBUTE(type, name) \ … … 149 162 150 163 CONTAINS ! Fonctions disponibles pour les utilisateurs. 164 165 SUBROUTINE init_ioserver(comm_client) 166 INTEGER, INTENT(INOUT) :: comm_client 167 CALL xios_init_ioserver(comm_client) 168 END SUBROUTINE init_ioserver 151 169 152 170 SUBROUTINE handle_create(ret, dtype, idt) … … 165 183 SUBROUTINE update_calendar(step) 166 184 INTEGER, INTENT(IN):: step 167 IF (step < 1) THEN168 PRINT *, "L'argument 'step' ne peut être négatif ou nul"169 STOP170 END IF171 185 CALL xios_update_calendar(step) 172 186 END SUBROUTINE update_calendar … … 255 269 SUBROUTINE dtreatment_end(context_hdl) 256 270 TYPE(XHandle), INTENT(IN), VALUE :: context_hdl 257 CALL context_set_current(context_hdl)271 !CALL context_set_current(context_hdl) 258 272 CALL xios_dtreatment_end() 259 273 END SUBROUTINE dtreatment_end 260 274 261 SUBROUTINE write_data (fieldid, & 262 data1d_k8, data2d_k8, data3d_k8) 275 SUBROUTINE write_data (fieldid, data1d_k4, data2d_k4, data3d_k4, data1d_k8, data2d_k8, data3d_k8) 263 276 CHARACTER(len = *), INTENT(IN) :: fieldid 264 277 REAL(kind = 8), DIMENSION(*), OPTIONAL, INTENT(IN) :: data1d_k8(:), data2d_k8(:,:), data3d_k8(:,:,:) 278 REAL(kind = 4), DIMENSION(*), OPTIONAL, INTENT(IN) :: data1d_k4(:), data2d_k4(:,:), data3d_k4(:,:,:) 279 265 280 IF((.NOT. PRESENT(data1d_k8)) .AND. & 266 281 (.NOT. PRESENT(data2d_k8)) .AND. & … … 269 284 STOP 270 285 END IF 286 271 287 IF (PRESENT (data1d_k8)) THEN 272 CALL xios_write_data(fieldid, len(fieldid), data1d_k8, & 273 size(data1d_k8, 1), -1, -1) 288 CALL xios_write_data(fieldid, len(fieldid), data1d_k8, size(data1d_k8, 1), -1, -1) 274 289 ELSE IF (PRESENT (data2d_k8)) THEN 275 CALL xios_write_data(fieldid, len(fieldid), data2d_k8, & 276 size(data2d_k8, 1), size(data2d_k8, 2), -1) 290 CALL xios_write_data(fieldid, len(fieldid), data2d_k8, size(data2d_k8, 1), size(data2d_k8, 2), -1) 277 291 ELSE IF (PRESENT (data3d_k8)) THEN 278 CALL xios_write_data(fieldid, len(fieldid), data3d_k8, & 279 size(data3d_k8, 1), size(data3d_k8, 2), size(data3d_k8, 3)) 280 END IF 292 CALL xios_write_data(fieldid, len(fieldid), data3d_k8, size(data3d_k8, 1), size(data3d_k8, 2), size(data3d_k8, 3)) 293 END IF 294 295 IF (PRESENT (data1d_k4)) THEN 296 CALL xios_write_data_f(fieldid, len(fieldid), data1d_k4, size(data1d_k4, 1), -1, -1) 297 ELSE IF (PRESENT (data2d_k4)) THEN 298 CALL xios_write_data_f(fieldid, len(fieldid), data2d_k4, size(data2d_k4, 1), size(data2d_k4, 2), -1) 299 ELSE IF (PRESENT (data3d_k4)) THEN 300 CALL xios_write_data_f(fieldid, len(fieldid), data3d_k4, size(data3d_k4, 1), size(data3d_k4, 2), size(data3d_k4, 3)) 301 END IF 302 303 281 304 END SUBROUTINE 282 305 … … 389 412 END SUBROUTINE set_file_attributes 390 413 391 END MODULE IXMLIOSERVER414 END MODULE XIOS -
XMLIO_V2/dev/common/src/xmlio/functor.cpp
r219 r266 8 8 9 9 CFunctor::CFunctor(const StdString & id, ARRAY(double, 1) doutput) 10 : SuperClass(id), doutput(doutput) 10 : SuperClass(id), doutput(doutput), nbcall(0) 11 11 { /* Ne rien faire de plus */ } 12 12 … … 39 39 ARRAY(double, 1) CFunctor::operator ()(const ARRAY(double, 1) dinput) 40 40 { 41 this->nbcall++; 41 42 if (dinput->size() != this->doutput->size()) 42 43 ERROR("CFunctor::operator ()(dinput)", … … 48 49 } 49 50 51 void CFunctor::final(void) 52 { 53 this->nbcall = 0; 54 } 55 50 56 //--------------------------------------------------------------- 51 57 -
XMLIO_V2/dev/common/src/xmlio/functor.hpp
r219 r266 28 28 virtual ~CFunctor(void); 29 29 30 //Traitement /// 31 virtual void final(void); 32 30 33 protected : 31 34 … … 48 51 DoubleArray doutput; 49 52 53 protected : 54 /// Propriétés protégées /// 55 int nbcall; 50 56 }; // class CFunctor 51 57 } // namespace func -
XMLIO_V2/dev/common/src/xmlio/functor/average.cpp
r219 r266 16 16 //--------------------------------------------------------------- 17 17 18 void CAverage::apply(const DoubleArray UNUSED(dinput),19 DoubleArray UNUSED(doutput))18 void CAverage::apply(const DoubleArray _dinput, 19 DoubleArray _doutput) 20 20 { 21 ERROR("CAverage::apply(...)", << "Not implemented yet !"); 21 const double * it1 = _dinput->data(), 22 * end1 = _dinput->data() + _dinput->num_elements(); 23 double * it = _doutput->data(); 24 if (this->nbcall == 1) 25 for (; it1 != end1; it1++, it++) *it = *it1; 26 else for (; it1 != end1; it1++, it++) *it += *it1; 22 27 } 23 24 //--------------------------------------------------------------- 25 28 29 void CAverage::final(void) 30 { 31 double * it1 = this->getDataOutput()->data(), 32 * end1 = this->getDataOutput()->data() + this->getDataOutput()->num_elements(); 33 for (; it1 != end1; it1++) *it1 /= this->nbcall; 34 this->nbcall = 0; 35 } 26 36 } // namespace func 27 37 } // namespace xmlioserver -
XMLIO_V2/dev/common/src/xmlio/functor/average.hpp
r219 r266 27 27 /// Traitement /// 28 28 virtual void apply(const DoubleArray dinput, DoubleArray doutput); 29 29 virtual void final(void) ; 30 30 31 /// Destructeur /// 31 32 virtual ~CAverage(void); -
XMLIO_V2/dev/common/src/xmlio/functor/functor_type.hpp
r219 r266 5 5 #include "instant.hpp" 6 6 #include "once.hpp" 7 #include "maximum.hpp" 8 #include "minimum.hpp" 7 9 8 10 #endif //__XMLIO_functor_type__ -
XMLIO_V2/dev/common/src/xmlio/functor/instant.cpp
r219 r266 16 16 //--------------------------------------------------------------- 17 17 18 void CInstant::apply(const DoubleArray UNUSED(dinput),19 DoubleArray UNUSED(doutput))18 void CInstant::apply(const DoubleArray _dinput, 19 DoubleArray _doutput) 20 20 { 21 ERROR("CInstant::apply(...)", << "Not implemented yet !"); 21 const double * it1 = _dinput->data(), 22 * end1 = _dinput->data() + _dinput->num_elements(); 23 double * it = _doutput->data(); 24 for (; it1 != end1; it1++, it++) *it = *it1; 22 25 } 23 26 -
XMLIO_V2/dev/common/src/xmlio/functor/once.cpp
r219 r266 16 16 //--------------------------------------------------------------- 17 17 18 void COnce::apply(const DoubleArray UNUSED(dinput),19 DoubleArray UNUSED(doutput))18 void COnce::apply(const DoubleArray _dinput, 19 DoubleArray _doutput) 20 20 { 21 ERROR("COnce::apply(...)", << "Not implemented yet !"); 21 const double * it1 = _dinput->data(), 22 * end1 = _dinput->data() + _dinput->num_elements(); 23 double * it = _doutput->data(); 24 for (; it1 != end1; it1++, it++) *it = *it1; 22 25 } 23 26 -
XMLIO_V2/dev/common/src/xmlio/iface/interface.cpp.in
r233 r266 97 97 void xios_handle_create (XPtr * const _ret, XDType _dtype, const XString _id, XSize _id_len) 98 98 { 99 MAKE_STRING(__id, _id, _id_len); 100 switch(_dtype) 101 { 102 case (ECONTEXT): 103 // Si le context n'existe pas, on retourne un handle vide/nul. 104 *_ret = (!CObjectFactory::HasObject<CContext>(__id)) 105 ? 0 : CObjectFactory::GetObject<CContext>(__id).get(); 106 return ; 107 CASE_ELEM(AXIS , Axis) 108 CASE_ELEM(DOMAIN , Domain) 109 CASE_ELEM(FIELD , Field) 110 CASE_ELEM(FILE , File) 111 CASE_ELEM(GRID , Grid) 112 default : 113 *_ret = 0; 114 return; 99 try 100 { 101 MAKE_STRING(__id, _id, _id_len); 102 switch(_dtype) 103 { 104 case (ECONTEXT): 105 { 106 *_ret = 0; 107 // Si le context n'existe pas, on retourne un handle vide/nul. 108 //*_ret = (!CObjectFactory::HasObject<CContext>(__id)) 109 // ? 0 : CObjectFactory::GetObject<CContext>(__id).get(); 110 std::vector<boost::shared_ptr<CContext> > def_vector = 111 CContext::GetContextGroup()->getChildList(); 112 for (StdSize i = 0; i < def_vector.size(); i++) 113 { 114 //std::cout << "_ " << def_vector[i]->getId() << std::endl; 115 if (def_vector[i]->getId().compare(__id) == 0) 116 *_ret = def_vector[i].get(); 117 } 118 //std::cout << __id << "=" << *_ret << std::endl; 119 return ; 120 } 121 CASE_ELEM(AXIS , Axis) 122 CASE_ELEM(DOMAIN , Domain) 123 CASE_ELEM(FIELD , Field) 124 CASE_ELEM(FILE , File) 125 CASE_ELEM(GRID , Grid) 126 default : 127 *_ret = 0; 128 return; 129 } 130 } 131 catch (CException & exc) 132 { 133 std::cerr << exc.getMessage() << std::endl; 134 exit (EXIT_FAILURE); 115 135 } 116 136 } … … 127 147 CTreeManager::ParseFile(__filename); 128 148 //~ StdOStringStream oss; 129 //~ oss << StdString("d ata/def/def_client_pre.")149 //~ oss << StdString("def_client_pre.") 130 150 //~ << CMPIManager::GetCommRank(CMPIManager::GetCommWorld()); 131 151 //~ CTreeManager::PrintTreeToFile(oss.str()); … … 147 167 CTreeManager::ParseString(__xmlcontent); 148 168 //~ StdOStringStream oss; 149 //~ oss << StdString("d ata/def/def_client_pre.")169 //~ oss << StdString("def_client_pre.") 150 170 //~ << CMPIManager::GetCommRank(CMPIManager::GetCommWorld()); 151 171 //~ CTreeManager::PrintTreeToFile(oss.str()); … … 162 182 void xios_context_set_current (XPtr const _ctx, bool _wswap) 163 183 { 164 boost::shared_ptr<CContext> context = CObjectFactory::GetObject<CContext> ((CContext*)_ctx); 165 CTreeManager::SetCurrentContextId(context->getId()); 184 try 185 { 186 //boost::shared_ptr<CContext> context = CObjectFactory::GetObject<CContext> ((CContext*)_ctx); 187 CTreeManager::SetCurrentContextId(((CContext*)_ctx)->getId()); 188 } 189 catch (CException & exc) 190 { 191 std::cerr << exc.getMessage() << std::endl; 192 exit (EXIT_FAILURE); 193 } 166 194 } 167 195 … … 284 312 { 285 313 MAKE_STRING(__filename, _filename, _filename_len); 286 if (_filename_len != -1) 287 CTreeManager::PrintTreeToFile(__filename); 288 else 289 CTreeManager::PrintTreeToStream(std::clog); 290 } 314 try 315 { 316 if (_filename_len != -1) 317 CTreeManager::PrintTreeToFile(__filename); 318 else 319 CTreeManager::PrintTreeToStream(std::clog); 320 } 321 catch (CException & exc) 322 { 323 std::cerr << exc.getMessage() << std::endl; 324 exit (EXIT_FAILURE); 325 } 326 } 327 328 //------------------------------------------------------------------- 329 330 void xios_init_ioserver(MPIComm * comm_client) 331 { 332 try 333 { 334 MPIComm comm_client_server, comm_server; 335 CMPIManager::Initialise(NULL, NULL); 336 CMPIManager::DispatchClient(false, *comm_client, comm_client_server, comm_server); 337 } 338 catch (CException & exc) 339 { 340 std::cerr << exc.getMessage() << std::endl; 341 exit (EXIT_FAILURE); 342 } 343 } 344 291 345 292 346 //------------------------------------------------------------------- … … 301 355 CObjectFactory::GetObject<CContext>(__context); 302 356 StdOStringStream oss; 303 //~ oss << StdString("data/def/def_client_next.")304 //~<< CMPIManager::GetCommRank(CMPIManager::GetCommWorld());305 //~CTreeManager::PrintTreeToFile(oss.str());306 //~oss.str("");357 oss << StdString("def_client_next.") 358 << CMPIManager::GetCommRank(CMPIManager::GetCommWorld()); 359 CTreeManager::PrintTreeToFile(oss.str()); 360 oss.str(""); 307 361 308 362 boost::shared_ptr<CDataTreatment> dt(new CDataTreatment (context)); 309 363 context->setDataTreatment(dt); 310 364 311 oss << StdString("d ata/def/def_client_end.")365 oss << StdString("def_client_end.") 312 366 << CMPIManager::GetCommRank(CMPIManager::GetCommWorld()); 313 367 CTreeManager::PrintTreeToFile(oss.str()); … … 350 404 void xios_dtreatment_end(void) 351 405 { 352 406 try 407 { 408 CMPIManager::Finalize(); 409 } 410 catch (CException & exc) 411 { 412 std::cerr << exc.getMessage() << std::endl; 413 exit (EXIT_FAILURE); 414 } 353 415 } 354 416 … … 358 420 XSize data_Xsize, XSize data_Ysize, XSize data_Zsize) 359 421 { 360 361 } 422 MAKE_STRING(__field_id, _field_id, _field_id_len); 423 try 424 { 425 boost::shared_ptr<CContext> context = 426 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 427 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 428 if (data_Ysize==-1 && data_Zsize==-1) 429 { 430 ARRAY(double, 1) data(new CArray<double, 1>(boost::extents [data_Xsize])); 431 std::copy(data_k8, data_k8+data->num_elements(), data->data()); 432 dtreat->write_data(__field_id, data); 433 return; 434 } 435 else if (data_Zsize==-1) 436 { 437 ARRAY(double, 2) data(new CArray<double, 2>(boost::extents [data_Xsize][data_Ysize])); 438 std::copy(data_k8, data_k8+data->num_elements(), data->data()); 439 dtreat->write_data(__field_id, data); 440 return; 441 } 442 else 443 { 444 ARRAY(double, 3) data(new CArray<double, 3>(boost::extents [data_Xsize][data_Ysize][data_Zsize])); 445 std::copy(data_k8, data_k8+data->num_elements(), data->data()); 446 dtreat->write_data(__field_id, data); 447 return; 448 } 449 } 450 catch (CException & exc) 451 { 452 std::cerr << exc.getMessage() << std::endl; 453 exit (EXIT_FAILURE); 454 } 455 } 456 457 //------------------------------------------------------------------- 458 459 void xios_write_data_f(const XString _field_id, XSize _field_id_len, float * data_k4, 460 XSize data_Xsize, XSize data_Ysize, XSize data_Zsize) 461 { 462 MAKE_STRING(__field_id, _field_id, _field_id_len); 463 try 464 { 465 boost::shared_ptr<CContext> context = 466 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 467 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 468 if (data_Ysize==-1 && data_Zsize==-1) 469 { 470 ARRAY(float, 1) data(new CArray<float, 1>(boost::extents [data_Xsize])); 471 std::copy(data_k4, &(data_k4[data->num_elements()]), data->data()); 472 dtreat->write_data(__field_id, data); 473 return; 474 } 475 else if (data_Zsize==-1) 476 { 477 ARRAY(float, 2) data(new CArray<float, 2>(boost::extents [data_Xsize][data_Ysize])); 478 std::copy(data_k4, &(data_k4[data->num_elements()]), data->data()); 479 dtreat->write_data(__field_id, data); 480 return; 481 } 482 else 483 { 484 ARRAY(float, 3) data(new CArray<float, 3>(boost::extents [data_Xsize][data_Ysize][data_Zsize])); 485 std::copy(data_k4, &(data_k4[data->num_elements()]), data->data()); 486 dtreat->write_data(__field_id, data); 487 return; 488 } 489 } 490 catch (CException & exc) 491 { 492 std::cerr << exc.getMessage() << std::endl; 493 exit (EXIT_FAILURE); 494 } 495 } 496 362 497 363 498 //------------------------------------------------------------------- … … 367 502 try 368 503 { 504 boost::shared_ptr<CContext> context = 505 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 506 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 507 dtreat->update_calendar(step); 369 508 } 370 509 catch (CException & exc) … … 382 521 try 383 522 { 523 date::CDuration dur = {ts_year, ts_month, ts_day, ts_hour, ts_minute, ts_second}; 524 boost::shared_ptr<CContext> context = 525 CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()); 526 boost::shared_ptr<data::CDataTreatment> dtreat = context->getDataTreatment(); 527 dtreat->set_timestep(dur); 384 528 } 385 529 catch (CException & exc) -
XMLIO_V2/dev/common/src/xmlio/main_server.cpp
r255 r266 25 25 //CXIOSManager::AddClient("lmdz" , 4, 2, &lmdz_fake_entry); 26 26 CMPIManager::DispatchClient(true, comm_client, comm_client_server, comm_server); 27 C MPIManager::RunServer("Nemo", comm_client_server, comm_server);27 CXIOSManager::RunServer("Nemo", comm_client_server, comm_server); 28 28 //CXIOSManager::RunClientServer (comm::CMPIManager::GetCommWorld ()); 29 29 CXIOSManager::Finalize (); -
XMLIO_V2/dev/common/src/xmlio/node/domain.cpp
r219 r266 381 381 data_n_index.setValue(dni); 382 382 383 for(int count = 0, i = 0; i < data_ni.getValue(); i++) 383 //for(int count = 0, i = 0; i < data_ni.getValue(); i++) 384 //for(int j = 0; j < data_nj.getValue(); j++, count++) 385 386 for(int count = 0, j = 0; j < data_nj.getValue(); j++) 384 387 { 385 for(int j = 0; j < data_nj.getValue(); j++, count++)388 for(int i = 0; i < data_ni.getValue(); i++, count++) 386 389 { 387 390 (*__arri)[count] = i+1 ; … … 399 402 //---------------------------------------------------------------- 400 403 401 void CDomain::completeLonLat(void) 404 void CDomain::completeLonLatClient(void) 405 { 406 ARRAY_CREATE(lonvalue_temp, double, 1, [0]); 407 ARRAY_CREATE(latvalue_temp, double, 1, [0]); 408 409 const int zoom_ibegin_client = zoom_ibegin_loc.getValue(), 410 zoom_jbegin_client = zoom_jbegin_loc.getValue(), 411 zoom_ni_client = zoom_ni_loc.getValue(), 412 zoom_nj_client = zoom_nj_loc.getValue(); 413 414 ARRAY(double, 1) lonvalue_ = this->lonvalue.getValue(), 415 latvalue_ = this->latvalue.getValue(); 416 417 if (this->data_dim.getValue() == 2) 418 { 419 StdSize dm = zoom_ni_client * zoom_nj_client; 420 421 lonvalue_temp->resize(boost::extents[dm]); 422 latvalue_temp->resize(boost::extents[dm]); 423 424 for (int i = 0; i < zoom_ni_client; i++) 425 { 426 for (int j = 0; j < zoom_nj_client; j++) 427 { 428 (*lonvalue_temp)[i + j * zoom_ni_client] = (*lonvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; 429 (*latvalue_temp)[i + j * zoom_ni_client] = (*latvalue_)[(i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue()]; 430 } 431 } 432 this->lonvalue.setValue(lonvalue_temp); 433 this->latvalue.setValue(latvalue_temp); 434 } 435 else 436 { 437 lonvalue_temp->resize(boost::extents[zoom_ni_client]); 438 latvalue_temp->resize(boost::extents[zoom_nj_client]); 439 440 for (int i = zoom_ibegin_client - 1; i < (zoom_ni_client - zoom_ibegin_client + 1); i++) 441 { 442 (*lonvalue_temp)[i] = (*lonvalue_)[i]; 443 } 444 445 for (int j = zoom_ibegin_client - 1; j < (zoom_nj_client - zoom_jbegin_client + 1); j++) 446 { 447 (*latvalue_temp)[j] = (*latvalue_)[j]; 448 } 449 450 this->lonvalue.setValue(lonvalue_temp); 451 this->latvalue.setValue(latvalue_temp); 452 } 453 } 454 455 //---------------------------------------------------------------- 456 457 void CDomain::completeLonLatServer(void) 402 458 { 403 459 ARRAY_CREATE(lonvalue_temp, double, 1, [0]); … … 441 497 for (int j = jbegin_loc - jbegin_serv; j < (jend_loc - jbegin_serv + 1); j++) 442 498 { 443 (*lonvalue_)[i + j * this->ni.getValue()] = (*lonvalue_loc)[l]; 444 (*latvalue_)[i + j * this->ni.getValue()] = (*latvalue_loc)[l++]; 499 (*lonvalue_)[i + j * this->ni.getValue()] = (*lonvalue_loc)[l]; // erreur 500 (*latvalue_)[i + j * this->ni.getValue()] = (*latvalue_loc)[l++]; // erreur 445 501 } 446 502 } … … 572 628 this->checkDomainData(); 573 629 this->checkCompression(); 630 631 this->ibegin_sub.push_back(this->ibegin.getValue()); 632 this->jbegin_sub.push_back(this->jbegin.getValue()); 633 this->iend_sub.push_back(this->iend.getValue()); 634 this->jend_sub.push_back(this->jend.getValue()); 635 636 this->latvalue_sub.push_back(this->latvalue.getValue()); 637 this->lonvalue_sub.push_back(this->lonvalue.getValue()); 638 639 if (!this->isEmpty()) 640 { 641 this->completeLonLatClient(); 642 } 574 643 } 575 644 else 576 645 { // CÃŽté serveur uniquement 577 646 if (!this->isEmpty()) 578 this->completeLonLat ();647 this->completeLonLatServer(); 579 648 } 580 649 this->completeMask(); -
XMLIO_V2/dev/common/src/xmlio/node/domain.hpp
r219 r266 90 90 /// Mutateur /// 91 91 void addRelFile(const StdString & filename); 92 void completeLonLat(void); 92 void completeLonLatServer(void); 93 void completeLonLatClient(void); 93 94 94 95 /// Destructeur /// -
XMLIO_V2/dev/common/src/xmlio/node/field.cpp
r219 r266 19 19 , grid(), file() 20 20 , freq_operation(), freq_write() 21 , nstep(0) 21 22 , last_Write(), last_operation() 22 23 , foperation() 23 , data( )24 , data(new CArray<double, 1>(boost::extents[0])) 24 25 { /* Ne rien faire de plus */ } 25 26 … … 29 30 , grid(), file() 30 31 , freq_operation(), freq_write() 32 , nstep(0) 31 33 , last_Write(), last_operation() 32 34 , foperation() 33 , data( )35 , data(new CArray<double, 1>(boost::extents[0])) 34 36 { /* Ne rien faire de plus */ } 35 37 … … 88 90 { 89 91 return (this->file); 92 } 93 94 StdSize CField::getNStep(void) const 95 { 96 return (this->nstep); 97 } 98 99 void CField::incrementNStep(void) 100 { 101 this->nstep++; 90 102 } 91 103 … … 236 248 else 237 249 { 250 CDuration freq_offset_ = NoneDu; 251 if (!freq_offset.isEmpty()) 252 { 253 freq_offset_ = CDuration::FromString(freq_offset.getValue()); 254 } 255 else 256 { 257 freq_offset.setValue(NoneDu.toString()); 258 } 259 238 260 this->freq_operation = CDuration::FromString(freq_op.getValue()); 239 261 this->freq_write = CDuration::FromString(this->file->output_freq.getValue()); … … 242 264 this->last_operation = boost::shared_ptr<xmlioserver::date::CDate> 243 265 (new date::CDate(_context->getCalendar()->getInitDate())); 266 const CDuration toffset = this->freq_operation - freq_offset_ - _context->getCalendar()->getTimeStep(); 267 *this->last_operation = *this->last_operation - toffset; 244 268 245 269 #define DECLARE_FUNCTOR(MType, mtype) \ -
XMLIO_V2/dev/common/src/xmlio/node/field.hpp
r231 r266 64 64 public : 65 65 66 StdSize getNStep(void) const; 67 66 68 const date::CDuration & getFreqOperation(void) const; 67 69 const date::CDuration & getFreqWrite(void) const; … … 78 80 /// Mutateur /// 79 81 void setRelFile(const boost::shared_ptr<CFile> _file); 82 void incrementNStep(void); 80 83 81 84 template <StdSize N> 82 85 inline bool updateData 83 (const date::CDate & currDate, const ARRAY(double, N) data);86 (const date::CDate & currDate, const date::CDuration & timestep, const ARRAY(double, N) data); 84 87 85 88 bool updateDataServer … … 118 121 date::CDuration freq_operation, freq_write; 119 122 123 StdSize nstep; 120 124 boost::shared_ptr<date::CDate> last_Write, last_operation; 121 125 boost::shared_ptr<func::CFunctor> foperation; … … 146 150 147 151 template <StdSize N> 148 bool CField::updateData(const date::CDate & currDate, const ARRAY(double, N) data) 149 { 150 if ((*last_operation + freq_operation) >= currDate) 152 bool CField::updateData(const date::CDate & currDate, const date::CDuration & timestep, const ARRAY(double, N) _data) 153 { 154 const date::CDate opeDate = *last_operation + freq_operation; 155 const date::CDate writeDate = *last_Write + freq_write; 156 157 // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 158 // std::cout << "Champ : " << this->getBaseFieldId() << std::endl; 159 // std::cout << "CurrDate : " << currDate << std::endl; 160 // std::cout << "opeDate : " << opeDate << " = " << *last_operation << " + " << freq_operation << std::endl; 161 // std::cout << "writeDate : " << writeDate << " = " << *last_Write << " + " << freq_write << std::endl; 162 // std::cout << "(opeDate <= currDate) = " << std::boolalpha << (opeDate <= currDate) << std::endl; 163 // std::cout << "(writeDate <= currDate) = " << std::boolalpha << (writeDate <= currDate) << std::endl; 164 165 //std::cout << ">> " << currDate << " : Envoi de données " << this->getBaseFieldId() << std::endl; 166 if (opeDate <= currDate) 151 167 { 152 ARRAY_CREATE(input, double, 1, [0]); 153 input->resize(boost::extents[data->size()]); 154 this->grid->inputField(data, input); 168 //std::cout << "> " << currDate << ": Operation du champs" << this->getBaseFieldId() << std::endl; 169 170 if (this->data->num_elements() != this->grid->storeIndex[0]->num_elements()) 171 { 172 this->data->resize(boost::extents[this->grid->storeIndex[0] ->num_elements()]); 173 } 174 175 ARRAY_CREATE(input, double, 1, [this->data->num_elements()]); 176 this->grid->inputField(_data, input); 155 177 (*this->foperation)(input); 178 156 179 *last_operation = currDate; 180 // std::cout << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 157 181 } 158 182 159 if ( (*last_Write + freq_write) >= currDate)183 if (writeDate < (currDate + freq_operation)) 160 184 { 161 *last_Write = currDate; 162 return (true); 185 this->foperation->final(); 186 this->incrementNStep(); 187 *last_Write = writeDate; 188 // std::cout << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 189 return (true); 163 190 } 191 // std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl; 164 192 return (false); 165 193 }; -
XMLIO_V2/dev/common/src/xmlio/node/file.cpp
r219 r266 106 106 { 107 107 this->setVirtualFieldGroup 108 (CObjectFactory::CreateObject<CFieldGroup>( newVFieldGroupId));108 (CObjectFactory::CreateObject<CFieldGroup>(/*newVFieldGroupId*/)); 109 109 } 110 110 -
XMLIO_V2/dev/common/src/xmlio/node/grid.cpp
r219 r266 1 1 2 #include "grid.hpp" 2 3 … … 100 101 //--------------------------------------------------------------- 101 102 102 std::vector<StdSize> CGrid::get Shape(void) const103 std::vector<StdSize> CGrid::getLocalShape(void) const 103 104 { 104 105 std::vector<StdSize> retvalue; 105 retvalue.push_back( this->domain->ni.getValue());106 retvalue.push_back( this->domain->nj.getValue());106 retvalue.push_back(domain->zoom_ni_loc.getValue()); 107 retvalue.push_back(domain->zoom_nj_loc.getValue()); 107 108 if (this->withAxis) 108 109 retvalue.push_back(this->axis->size.getValue()); … … 111 112 //--------------------------------------------------------------- 112 113 113 StdSize CGrid::get Size(void) const114 StdSize CGrid::getLocalSize(void) const 114 115 { 115 116 StdSize retvalue = 1; 116 std::vector<StdSize> shape_ = this->getShape(); 117 std::vector<StdSize> shape_ = this->getLocalShape(); 118 for (StdSize s = 0; s < shape_.size(); s++) 119 retvalue *= shape_[s]; 120 return (retvalue); 121 } 122 123 //--------------------------------------------------------------- 124 125 std::vector<StdSize> CGrid::getGlobalShape(void) const 126 { 127 std::vector<StdSize> retvalue; 128 retvalue.push_back(domain->ni.getValue()); 129 retvalue.push_back(domain->nj.getValue()); 130 if (this->withAxis) 131 retvalue.push_back(this->axis->size.getValue()); 132 return (retvalue); 133 } 134 //--------------------------------------------------------------- 135 136 StdSize CGrid::getGlobalSize(void) const 137 { 138 StdSize retvalue = 1; 139 std::vector<StdSize> shape_ = this->getGlobalShape(); 117 140 for (StdSize s = 0; s < shape_.size(); s++) 118 141 retvalue *= shape_[s]; … … 129 152 if (this->storeIndex.size() == 1) 130 153 { 154 131 155 this->computeIndex() ; 132 } 133 else 134 { 135 this->computeIndexServer(); 136 } 156 ARRAY_CREATE(storeIndex_ , int, 1, [0]); 157 ARRAY_CREATE(out_l_index_, int, 1, [0]); 158 ARRAY_CREATE(out_i_index_, int, 1, [0]); 159 ARRAY_CREATE(out_j_index_, int, 1, [0]); 160 161 this->storeIndex .push_front(storeIndex_); 162 this->out_i_index.push_front(out_i_index_); 163 this->out_j_index.push_front(out_j_index_); 164 this->out_l_index.push_front(out_l_index_); 165 } 166 this->computeIndexServer(); 137 167 this->isChecked = true; 138 168 } … … 177 207 178 208 void CGrid::computeIndex(void) 179 { 209 { 210 180 211 const int ni = domain->ni.getValue() , 181 212 nj = domain->nj.getValue() , … … 200 231 201 232 ARRAY(bool, 2) mask = domain->mask.getValue() ; 233 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 202 234 203 235 int indexCount = 0; … … 210 242 temp_j = (data_dim == 1) ? -1 211 243 : (*data_j_index)[n] + data_jbegin; 212 i = (data_dim == 1) ? (temp_i - 2) % ni244 i = (data_dim == 1) ? (temp_i - 1) % ni 213 245 : (temp_i - 1) ; 214 j = (data_dim == 1) ? (temp_i - 2) / ni246 j = (data_dim == 1) ? (temp_i - 1) / ni 215 247 : (temp_j - 1) ; 216 248 … … 226 258 ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]); 227 259 ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]); 228 260 261 // for(int count = 0, indexCount = 0, l = 0; l < size; l++) 262 // for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 263 264 //for(int n = 0, i = 0, j = 0, count = 0, indexCount = 0; n < data_n_index; n++) 265 //for(int l = 0; l < size; l++, count++) 266 229 267 for(int count = 0, indexCount = 0, l = 0; l < size; l++) 230 268 { … … 234 272 temp_j = (data_dim == 1) ? -1 235 273 : (*data_j_index)[n] + data_jbegin; 236 i = (data_dim == 1) ? (temp_i - 2) % ni274 i = (data_dim == 1) ? (temp_i - 1) % ni 237 275 : (temp_i - 1) ; 238 j = (data_dim == 1) ? (temp_i - 2) / ni276 j = (data_dim == 1) ? (temp_i - 1) / ni 239 277 : (temp_j - 1) ; 240 278 … … 250 288 } 251 289 } 290 291 292 // if (this->storeIndex[0]->size() != 0) 293 // for (StdSize u = 0; u < this->storeIndex[0]->size(); u++) 294 // (*local_mask)[(*out_i_index[0])[u]][(*out_j_index[0])[u]] = 1; 295 296 // std::cout << "indexCount" << indexCount << std::endl; 297 // std::cout << this->getId() << " : " << (*this->storeIndex[0]).num_elements() << std::endl; 298 // StdOFStream ofs2(("log_client_"+this->getId()).c_str()); 299 // for (StdSize h = 0; h < storeIndex[0]->size(); h++) 300 // { 301 // ofs2 << "(" << (*storeIndex[0])[h] << ";" 302 // << (*out_i_index[0])[h] << "," 303 // << (*out_j_index[0])[h] << "," 304 // << (*out_l_index[0])[h] << ")" << std::endl; 305 // } 306 // ofs2.close(); 252 307 } 253 308 … … 282 337 (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const 283 338 { 339 //std::cout <<"champ : " ; 284 340 for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) 341 { 285 342 (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] = (*stored)[n] ; 343 /*if (storeIndex[0]->num_elements() == 31) 344 { 345 std::cout << "( " << (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] << ", " 346 << (*out_i_index[0])[n] << ", " 347 << (*out_j_index[0])[n] << ", " 348 << (*out_l_index[0])[n] << ")"; 349 }*/ 350 } 351 //std::cout << std::endl; 352 286 353 } 287 354 … … 311 378 (const double * const data, ARRAY(double, 1) stored) const 312 379 { 313 const StdSize size = storeIndex[0]->num_elements() ; 380 const StdSize size = (this->storeIndex[0])->num_elements() ; 381 // std::cout << this->getId() << "> size : " << size << std::endl; 314 382 stored->resize(boost::extents[size]) ; 315 383 for(StdSize i = 0; i < size; i++) … … 365 433 void CGrid::computeIndexServer(void) 366 434 { 367 ARRAY(int, 1) storeIndex_srv = this->storeIndex[0];368 ARRAY(int, 1) out_i_index_srv = this->out_i_index[0];369 ARRAY(int, 1) out_j_index_srv = this->out_j_index[0];370 ARRAY(int, 1) out_l_index_srv = this->out_l_index[0];371 372 435 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 373 436 … … 375 438 const std::vector<int> & jbegin = this->domain->getJBeginSub(); 376 439 377 const int ibegin_srv = this->domain->ibegin.getValue();378 const int jbegin_srv = this->domain->jbegin.getValue();379 const int zoom_ni_srv 380 const int zoom_nj_srv 440 const int ibegin_srv = this->domain->ibegin.getValue(); 441 const int jbegin_srv = this->domain->jbegin.getValue(); 442 const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue(); 443 const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue(); 381 444 382 445 const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue(); … … 387 450 dn += this->out_i_index[j]->size(); 388 451 389 ARRAY_ ASSIGN(storeIndex_srv , int, 1, [dn]);390 ARRAY_ ASSIGN(out_i_index_srv, int, 1, [dn]);391 ARRAY_ ASSIGN(out_j_index_srv, int, 1, [dn]);392 ARRAY_ ASSIGN(out_l_index_srv, int, 1, [dn]);452 ARRAY_CREATE(storeIndex_srv , int, 1, [dn]); 453 ARRAY_CREATE(out_i_index_srv, int, 1, [dn]); 454 ARRAY_CREATE(out_j_index_srv, int, 1, [dn]); 455 ARRAY_CREATE(out_l_index_srv, int, 1, [dn]); 393 456 394 457 for (StdSize i = 0, dn = 0; i < ibegin.size(); i++) … … 404 467 for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 405 468 { 406 (*storeIndex_srv)[n] = (*storeIndex_cl)[m] + dn; // Faux mais inutile dans tous les cas.469 (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 407 470 (*out_i_index_srv)[n] = (*out_i_index_cl)[m] 408 471 + (ibegin_cl - 1) - (ibegin_srv - 1) - (ibegin_zoom_srv - 1); … … 438 501 (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1; 439 502 440 //~ StdOFStream ofs(this->getId().c_str()); 441 //~ for (StdSize h = 0; h < storeIndex_srv->size(); h++) 442 //~ { 443 //~ ofs << "(" << (*storeIndex_srv)[h] << ";" 444 //~ << (*out_i_index_srv)[h] << "," 445 //~ << (*out_j_index_srv)[h] << "," 446 //~ << (*out_l_index_srv)[h] << ")" << std::endl; 447 //~ } 448 //~ ofs.close(); 503 // StdOFStream ofs(("log_server_"+this->getId()).c_str()); 504 // for (StdSize h = 0; h < storeIndex_srv->size(); h++) 505 // { 506 // ofs << "(" << (*storeIndex_srv)[h] << ";" 507 // << (*out_i_index_srv)[h] << "," 508 // << (*out_j_index_srv)[h] << "," 509 // << (*out_l_index_srv)[h] << ")" << std::endl; 510 // } 511 // ofs.close(); 512 513 this->storeIndex [0] = storeIndex_srv ; 514 this->out_i_index[0] = out_i_index_srv; 515 this->out_j_index[0] = out_j_index_srv; 516 this->out_l_index[0] = out_l_index_srv; 517 449 518 this->storeIndex.resize(1); 450 519 this->out_i_index.resize(1); … … 454 523 } 455 524 456 //----------------------------------------------------------------457 525 458 526 void CGrid::inputFieldServer -
XMLIO_V2/dev/common/src/xmlio/node/grid.hpp
r219 r266 68 68 69 69 StdSize getDimension(void) const; 70 StdSize getSize(void) const; 71 std::vector<StdSize> getShape(void) const; 70 71 StdSize getLocalSize(void) const; 72 StdSize getGlobalSize(void) const; 73 std::vector<StdSize> getLocalShape(void) const; 74 std::vector<StdSize> getGlobalShape(void) const; 72 75 73 76 /// Entrées-sorties de champs /// … … 130 133 void CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const 131 134 { 132 if (this->get Size() != field->num_elements())135 if (this->getGlobalSize() != field->num_elements()) 133 136 ERROR("CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored)", 134 << "[ Taille des données attendue = " << this->get Size() << ", "137 << "[ Taille des données attendue = " << this->getGlobalSize() << ", " 135 138 << "Taille des données reçue = " << field->num_elements() << " ] " 136 139 << "Le tableau de données n'a pas la bonne taille !") ; 137 this->storeField_arr(field .data(), stored) ;140 this->storeField_arr(field->data(), stored) ; 138 141 } 139 142 -
XMLIO_V2/dev/common/src/xmlio/object_factory_impl.hpp
r219 r266 53 53 54 54 ERROR("CObjectFactory::GetObject(const U * const object)", 55 << "[type = " << U::GetName() << "]" 55 << "[type = " << U::GetName() << ", " 56 << "adress = " << object << "]" 56 57 << " object was not found !"); 57 58 return (boost::shared_ptr<U>()); // jamais atteint -
XMLIO_V2/dev/common/src/xmlio/output/nc4_data_output.cpp
r219 r266 1 1 2 #include "nc4_data_output.hpp" 2 3 … … 137 138 domain->data_jbegin.getValue()*/); 138 139 139 SuperClassWriter::setDefaultValue(maskid, &dvm);140 //SuperClassWriter::setDefaultValue(maskid, &dvm); 140 141 141 142 SuperClassWriter::definition_end(); … … 223 224 ? field->name.getValue() : field->getBaseFieldReference()->getId(); 224 225 225 unsigned int ssize = domain-> ni.getValue() * domain->nj.getValue();226 unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue(); 226 227 bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize); 227 228 … … 380 381 if (grid->hasAxis()) // 3D 381 382 { 382 ARRAY(double, 3) field_data3D ;383 ARRAY(double, 3) field_data3D (new CArray<double,3>(grid->getLocalShape()/*, boost::c_storage_order()*/)); 383 384 grid->outputField(field_data, field_data3D); 384 SuperClassWriter::writeData(field_data3D, fieldid, true, 0);385 SuperClassWriter::writeData(field_data3D, fieldid, true, field->getNStep()-1); 385 386 386 387 } 387 388 else // 2D 388 389 { 389 ARRAY(double, 3) field_data2D;390 ARRAY(double, 2) field_data2D (new CArray<double, 2>(grid->getLocalShape()/*, boost::c_storage_order()*/)); 390 391 grid->outputField(field_data, field_data2D); 391 SuperClassWriter::writeData(field_data2D, fieldid, true, 0);392 SuperClassWriter::writeData(field_data2D, fieldid, true, field->getNStep()-1); 392 393 } 393 394 } -
XMLIO_V2/dev/common/src/xmlio/output/onetcdf4.cpp
r251 r266 142 142 } 143 143 144 StdString CONetCDF4::getUnlimitedDimensionName(void) 145 { 146 char full_name_in[NC_MAX_NAME +1]; 147 int grpid = this->getGroup(path); 148 int dimid = this->getUnlimitedDimension(); 149 150 if (dimid == -1) return (std::string()); 151 CheckError(nc_inq_dimname(grpid, dimid, full_name_in)); 152 153 StdString dimname(full_name_in); 154 return (dimname); 155 } 156 144 157 //--------------------------------------------------------------- 145 158 … … 166 179 return (retvalue); 167 180 } 181 182 std::vector<std::string> CONetCDF4::getDimensionsIdList (const std::string * _varname) 183 { 184 char full_name_in[NC_MAX_NAME +1]; 185 int nbdim = 0, *dimid = NULL; 186 int grpid = this->getCurrentGroup(); 187 int varid = (_varname != NULL) ? this->getVariable(*_varname) : NC_GLOBAL; 188 std::vector<std::string> retvalue; 189 190 if (_varname != NULL) 191 { 192 CheckError(nc_inq_varndims(grpid, varid, &nbdim)); 193 dimid = new int[nbdim](); 194 CheckError(nc_inq_vardimid(grpid, varid, dimid)); 195 } 196 else 197 { 198 CheckError(nc_inq_dimids(grpid, &nbdim, NULL, 1)); 199 dimid = new int[nbdim](); 200 CheckError(nc_inq_dimids(grpid, NULL, dimid, 1)); 201 } 202 203 for (int i = 0; i < nbdim; i++) 204 { 205 CheckError(nc_inq_dimname(grpid, dimid[i], full_name_in)); 206 std::string dimname(full_name_in); 207 retvalue.push_back(dimname); 208 } 209 delete [] dimid; 210 211 return (retvalue); 212 } 213 168 214 169 215 //--------------------------------------------------------------- … … 271 317 const std::vector<StdSize> * start, 272 318 const std::vector<StdSize> * count) 273 { 274 std::vector<StdSize> sizes = this->getDimensions(name); 275 std::vector<StdSize>::const_iterator 319 { 320 std::vector<std::size_t> sizes = this->getDimensions(name); 321 std::vector<std::string> iddims = this->getDimensionsIdList (&name); 322 std::vector<std::size_t>::const_iterator 276 323 it = sizes.begin(), end = sizes.end(); 277 324 int i = 0; 325 326 if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0) 327 { 328 sstart.push_back(record); 329 scount.push_back(1); 330 if ((start == NULL) && 331 (count == NULL)) i++; 332 it++; 333 } 278 334 279 335 for (;it != end; it++) 280 { 281 StdSize s = *it; 336 { 282 337 if ((start != NULL) && (count != NULL)) 283 338 { 284 if (s == UNLIMITED_DIM) 285 { 286 sstart.push_back(record); 287 scount.push_back(1); 288 } 289 else 290 { 291 sstart.push_back((*start)[i]); 292 scount.push_back((*count)[i]); 293 array_size *= (*count)[i]; 294 i++; 295 } 339 sstart.push_back((*start)[i]); 340 scount.push_back((*count)[i]); 341 array_size *= (*count)[i]; 342 i++; 296 343 } 297 344 else 298 345 { 299 if (s == UNLIMITED_DIM) 300 { 301 sstart.push_back(record); 302 scount.push_back(1); 303 } 304 else 305 { 306 sstart.push_back(0); 307 scount.push_back(sizes[i]); 308 array_size *= sizes[i]; 309 } 346 sstart.push_back(0); 347 scount.push_back(sizes[i]); 348 array_size *= sizes[i]; 310 349 i++; 311 350 } 312 351 } 352 353 354 // for (StdSize u = 0; u < sstart.size(); u++) 355 // std::cout << "(" << sstart[u] << "," << scount[u] << ")" ; 356 // std::cout << std::endl; 313 357 } 314 358 -
XMLIO_V2/dev/common/src/xmlio/output/onetcdf4.hpp
r251 r266 94 94 int getVariable(const StdString & varname); 95 95 int getDimension(const StdString & dimname); 96 std::vector<StdSize> getDimensions(const StdString & varname); 97 int getUnlimitedDimension(void); 96 std::vector<StdSize> getDimensions (const StdString & varname); 97 std::vector<StdString> getDimensionsIdList (const StdString * varname); 98 int getUnlimitedDimension(void); 99 StdString getUnlimitedDimensionName(void); 98 100 99 101 bool varExist(const StdString & varname); … … 144 146 this->getWriteDataInfos 145 147 (name, record, array_size, sstart, scount, start, count); 148 if (data->num_elements() != array_size) 149 { 150 ERROR("CONetCDF4::writeData(...)", 151 << "[ input array size = " << data->num_elements() 152 << ", intern array size = " << array_size 153 << " ] Invalid input data !" ); 154 } 155 146 156 this->writeData_(grpid, varid, sstart, scount, data->data()); 147 157 }
Note: See TracChangeset
for help on using the changeset viewer.