Changeset 676
- Timestamp:
- 08/25/15 16:52:45 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/field_attribute.conf
r606 r676 14 14 DECLARE_ATTRIBUTE(bool, enabled) 15 15 DECLARE_ATTRIBUTE(bool, read_access) 16 DECLARE_ATTRIBUTE(bool, indexed_output) 16 17 17 18 DECLARE_ATTRIBUTE(StdString, domain_ref) -
XIOS/trunk/src/data_output.cpp
r540 r676 14 14 //---------------------------------------------------------------- 15 15 16 void CDataOutput::writeGrid(CGrid* grid )16 void CDataOutput::writeGrid(CGrid* grid, bool allowCompressedOutput /*= false*/) 17 17 { 18 // if (grid->domain_ref.isEmpty())19 // ERROR("CDataOutput::writeGrid(grid)",20 // << " domain is not defined !");21 //22 // if (grid->axis_ref.isEmpty())23 // {24 // this->writeGrid(CDomain::get(grid->domain_ref.getValue()));25 // }26 // else27 // {28 // this->writeGrid(CDomain::get(grid->domain_ref.getValue()),29 // CAxis::get(grid->axis_ref.getValue()));30 // }31 // this->writeGrid(grid->domain, grid->axis);32 18 this->writeGrid(grid->getDomains(), grid->getAxis()); 19 20 if (allowCompressedOutput) 21 writeGridCompressed_(grid); 33 22 } 34 23 … … 57 46 //---------------------------------------------------------------- 58 47 59 void CDataOutput::writeGrid(CDomain* domain, CAxis* axis)48 void CDataOutput::writeGrid(CDomain* domain, CAxis* axis) 60 49 { 61 50 this->writeDomain_(domain); … … 98 87 void CDataOutput::writeFieldGrid(CField* field) 99 88 { 100 this->writeGrid(field->getRelGrid()); 89 this->writeGrid(field->getRelGrid(), 90 !field->indexed_output.isEmpty() && field->indexed_output); 101 91 } 102 92 -
XIOS/trunk/src/data_output.hpp
r591 r676 20 20 21 21 /// Ecriture /// 22 void writeFile (CFile* file);23 void writeAttribute(CVariable* 24 void syncFile (void);22 void writeFile (CFile* file); 23 void writeAttribute(CVariable* var); 24 void syncFile (void); 25 25 void closeFile (void); 26 26 void writeField (CField* field); … … 40 40 41 41 /// Ecriture /// 42 void writeGrid(CGrid* grid); 43 void writeGrid(CDomain* domain, 44 CAxis* axis); 42 void writeGrid(CGrid* grid, bool allowCompressedOutput = false); 43 void writeGrid(CDomain* domain, CAxis* axis); 45 44 void writeGrid(CDomain* domain); 46 45 void writeGrid(std::vector<CDomain*> domain, std::vector<CAxis*> axis); 47 46 48 virtual void writeFile_ (CFile* file) = 0; 49 virtual void writeAttribute_(CVariable* var) = 0 ; 50 virtual void closeFile_ (void) = 0; 51 virtual void syncFile_ (void) = 0; 52 virtual void writeField_ (CField* field) = 0; 53 virtual void writeFieldData_ (CField* field) = 0; 54 virtual void writeDomain_ (CDomain* domain) = 0; 55 virtual void writeTimeDimension_ (void) = 0; 56 virtual void writeAxis_ (CAxis* axis) = 0; 57 virtual void writeTimeAxis_ (CField* field, 58 const shared_ptr<CCalendar> cal) = 0; 47 virtual void writeFile_ (CFile* file) = 0; 48 virtual void writeAttribute_(CVariable* var) = 0; 49 virtual void closeFile_ (void) = 0; 50 virtual void syncFile_ (void) = 0; 51 virtual void writeField_ (CField* field) = 0; 52 virtual void writeFieldData_(CField* field) = 0; 53 virtual void writeDomain_ (CDomain* domain) = 0; 54 virtual void writeAxis_ (CAxis* axis) = 0; 55 virtual void writeGridCompressed_(CGrid* grid) = 0; 56 virtual void writeTimeDimension_(void) = 0; 57 virtual void writeTimeAxis_ (CField* field, 58 const shared_ptr<CCalendar> cal) = 0; 59 59 60 60 /// Propriétés protégées /// -
XIOS/trunk/src/distribution_client.hpp
r668 r676 46 46 bool isDataDistributed() { return isDataDistributed_; } 47 47 48 static int getDomainIndex(const int& dataIIndex, const int& dataJIndex, 49 const int& dataIBegin, const int& dataJBegin, 50 const int& dataDim, const int& ni, int& j); 51 static int getAxisIndex(const int& dataIndex, const int& dataBegin, const int& ni); 52 48 53 protected: 49 54 void createGlobalIndex(); … … 61 66 //! Create local index of an axis 62 67 void createLocalAxisDataIndex(); 63 64 inline int getDomainIndex(const int& dataIIndex, const int& dataJIndex,65 const int& dataIBegin, const int& dataJBegin,66 const int& dataDim, const int& ni, int& j);67 inline int getAxisIndex(const int& dataIndex, const int& dataBegin, const int& ni);68 68 69 69 template<int N> -
XIOS/trunk/src/distribution_server.cpp
r668 r676 146 146 } 147 147 148 /*! 149 Transforms local indexes owned by the server into global indexes 150 \param [in/out] indexes on input, local indexes of the server, 151 on output, the corresponding global indexes 152 */ 153 void CDistributionServer::computeGlobalIndex(CArray<int,1>& indexes) const 154 { 155 for (int i = 0; i < indexes.numElements(); ++i) 156 { 157 indexes(i) = globalIndex_(indexes(i)); 158 } 159 } 148 160 149 std::vector<int> CDistributionServer::getZoomBeginGlobal() const 161 162 const std::vector<int>& CDistributionServer::getZoomBeginGlobal() const 150 163 { 151 164 return nZoomBeginGlobal_; 152 165 } 153 166 154 std::vector<int>CDistributionServer::getZoomBeginServer() const167 const std::vector<int>& CDistributionServer::getZoomBeginServer() const 155 168 { 156 169 return nZoomBegin_; 157 170 } 158 171 159 std::vector<int>CDistributionServer::getZoomSizeServer() const172 const std::vector<int>& CDistributionServer::getZoomSizeServer() const 160 173 { 161 174 return nZoomSize_; -
XIOS/trunk/src/distribution_server.hpp
r653 r676 34 34 virtual ~CDistributionServer(); 35 35 36 std::vector<int>getZoomBeginGlobal() const;37 std::vector<int>getZoomBeginServer() const;38 std::vector<int>getZoomSizeServer() const;36 const std::vector<int>& getZoomBeginGlobal() const; 37 const std::vector<int>& getZoomBeginServer() const; 38 const std::vector<int>& getZoomSizeServer() const; 39 39 40 40 virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); 41 41 virtual void computeLocalIndex(CArray<size_t,1>& globalIndex); 42 virtual void computeGlobalIndex(CArray<int,1>& indexes) const; 42 43 43 44 protected: -
XIOS/trunk/src/interface/c_attr/icfield_attr.cpp
r608 r676 313 313 314 314 315 void cxios_set_field_indexed_output(field_Ptr field_hdl, bool indexed_output) 316 { 317 CTimer::get("XIOS").resume(); 318 field_hdl->indexed_output.setValue(indexed_output); 319 CTimer::get("XIOS").suspend(); 320 } 321 322 void cxios_get_field_indexed_output(field_Ptr field_hdl, bool* indexed_output) 323 { 324 CTimer::get("XIOS").resume(); 325 *indexed_output = field_hdl->indexed_output.getInheritedValue(); 326 CTimer::get("XIOS").suspend(); 327 } 328 329 bool cxios_is_defined_field_indexed_output(field_Ptr field_hdl) 330 { 331 CTimer::get("XIOS").resume(); 332 bool isDefined = field_hdl->indexed_output.hasInheritedValue(); 333 CTimer::get("XIOS").suspend(); 334 return isDefined; 335 } 336 337 315 338 void cxios_set_field_level(field_Ptr field_hdl, int level) 316 339 { -
XIOS/trunk/src/interface/c_attr/icfieldgroup_attr.cpp
r608 r676 339 339 340 340 341 void cxios_set_fieldgroup_indexed_output(fieldgroup_Ptr fieldgroup_hdl, bool indexed_output) 342 { 343 CTimer::get("XIOS").resume(); 344 fieldgroup_hdl->indexed_output.setValue(indexed_output); 345 CTimer::get("XIOS").suspend(); 346 } 347 348 void cxios_get_fieldgroup_indexed_output(fieldgroup_Ptr fieldgroup_hdl, bool* indexed_output) 349 { 350 CTimer::get("XIOS").resume(); 351 *indexed_output = fieldgroup_hdl->indexed_output.getInheritedValue(); 352 CTimer::get("XIOS").suspend(); 353 } 354 355 bool cxios_is_defined_fieldgroup_indexed_output(fieldgroup_Ptr fieldgroup_hdl) 356 { 357 CTimer::get("XIOS").resume(); 358 bool isDefined = fieldgroup_hdl->indexed_output.hasInheritedValue(); 359 CTimer::get("XIOS").suspend(); 360 return isDefined; 361 } 362 363 341 364 void cxios_set_fieldgroup_level(fieldgroup_Ptr fieldgroup_hdl, int level) 342 365 { -
XIOS/trunk/src/interface/fortran_attr/field_interface_attr.F90
r608 r676 231 231 232 232 233 SUBROUTINE cxios_set_field_indexed_output(field_hdl, indexed_output) BIND(C) 234 USE ISO_C_BINDING 235 INTEGER (kind = C_INTPTR_T), VALUE :: field_hdl 236 LOGICAL (KIND=C_BOOL) , VALUE :: indexed_output 237 END SUBROUTINE cxios_set_field_indexed_output 238 239 SUBROUTINE cxios_get_field_indexed_output(field_hdl, indexed_output) BIND(C) 240 USE ISO_C_BINDING 241 INTEGER (kind = C_INTPTR_T), VALUE :: field_hdl 242 LOGICAL (KIND=C_BOOL) :: indexed_output 243 END SUBROUTINE cxios_get_field_indexed_output 244 245 FUNCTION cxios_is_defined_field_indexed_output(field_hdl) BIND(C) 246 USE ISO_C_BINDING 247 LOGICAL(kind=C_BOOL) :: cxios_is_defined_field_indexed_output 248 INTEGER (kind = C_INTPTR_T), VALUE :: field_hdl 249 END FUNCTION cxios_is_defined_field_indexed_output 250 251 233 252 SUBROUTINE cxios_set_field_level(field_hdl, level) BIND(C) 234 253 USE ISO_C_BINDING -
XIOS/trunk/src/interface/fortran_attr/fieldgroup_interface_attr.F90
r608 r676 252 252 253 253 254 SUBROUTINE cxios_set_fieldgroup_indexed_output(fieldgroup_hdl, indexed_output) BIND(C) 255 USE ISO_C_BINDING 256 INTEGER (kind = C_INTPTR_T), VALUE :: fieldgroup_hdl 257 LOGICAL (KIND=C_BOOL) , VALUE :: indexed_output 258 END SUBROUTINE cxios_set_fieldgroup_indexed_output 259 260 SUBROUTINE cxios_get_fieldgroup_indexed_output(fieldgroup_hdl, indexed_output) BIND(C) 261 USE ISO_C_BINDING 262 INTEGER (kind = C_INTPTR_T), VALUE :: fieldgroup_hdl 263 LOGICAL (KIND=C_BOOL) :: indexed_output 264 END SUBROUTINE cxios_get_fieldgroup_indexed_output 265 266 FUNCTION cxios_is_defined_fieldgroup_indexed_output(fieldgroup_hdl) BIND(C) 267 USE ISO_C_BINDING 268 LOGICAL(kind=C_BOOL) :: cxios_is_defined_fieldgroup_indexed_output 269 INTEGER (kind = C_INTPTR_T), VALUE :: fieldgroup_hdl 270 END FUNCTION cxios_is_defined_fieldgroup_indexed_output 271 272 254 273 SUBROUTINE cxios_set_fieldgroup_level(fieldgroup_hdl, level) BIND(C) 255 274 USE ISO_C_BINDING -
XIOS/trunk/src/interface/fortran_attr/ifield_attr.F90
r608 r676 13 13 SUBROUTINE xios(set_field_attr) & 14 14 ( field_id, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 15 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&16 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )15 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 16 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 17 17 18 18 IMPLICIT NONE … … 32 32 TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: freq_op 33 33 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 34 LOGICAL , OPTIONAL, INTENT(IN) :: indexed_output 35 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 34 36 INTEGER , OPTIONAL, INTENT(IN) :: level 35 37 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name … … 48 50 CALL xios(set_field_attr_hdl_) & 49 51 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 50 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&51 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )52 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 53 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 52 54 53 55 END SUBROUTINE xios(set_field_attr) … … 55 57 SUBROUTINE xios(set_field_attr_hdl) & 56 58 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 57 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&58 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )59 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 60 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 59 61 60 62 IMPLICIT NONE … … 73 75 TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: freq_op 74 76 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 77 LOGICAL , OPTIONAL, INTENT(IN) :: indexed_output 78 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 75 79 INTEGER , OPTIONAL, INTENT(IN) :: level 76 80 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name … … 88 92 CALL xios(set_field_attr_hdl_) & 89 93 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 90 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&91 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )94 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 95 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 92 96 93 97 END SUBROUTINE xios(set_field_attr_hdl) … … 95 99 SUBROUTINE xios(set_field_attr_hdl_) & 96 100 ( field_hdl, add_offset_, axis_ref_, compression_level_, default_value_, detect_missing_value_ & 97 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, level_, long_name_, name_ &98 , operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_, valid_min_ &99 )101 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, indexed_output_, level_ & 102 , long_name_, name_, operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_ & 103 , valid_min_ ) 100 104 101 105 IMPLICIT NONE … … 114 118 TYPE(txios(duration)) , OPTIONAL, INTENT(IN) :: freq_op_ 115 119 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref_ 120 LOGICAL , OPTIONAL, INTENT(IN) :: indexed_output_ 121 LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 116 122 INTEGER , OPTIONAL, INTENT(IN) :: level_ 117 123 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name_ … … 173 179 ENDIF 174 180 181 IF (PRESENT(indexed_output_)) THEN 182 indexed_output__tmp = indexed_output_ 183 CALL cxios_set_field_indexed_output(field_hdl%daddr, indexed_output__tmp) 184 ENDIF 185 175 186 IF (PRESENT(level_)) THEN 176 187 CALL cxios_set_field_level(field_hdl%daddr, level_) … … 222 233 SUBROUTINE xios(get_field_attr) & 223 234 ( field_id, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 224 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&225 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )235 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 236 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 226 237 227 238 IMPLICIT NONE … … 241 252 TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: freq_op 242 253 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 254 LOGICAL , OPTIONAL, INTENT(OUT) :: indexed_output 255 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 243 256 INTEGER , OPTIONAL, INTENT(OUT) :: level 244 257 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name … … 257 270 CALL xios(get_field_attr_hdl_) & 258 271 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 259 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&260 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )272 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 273 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 261 274 262 275 END SUBROUTINE xios(get_field_attr) … … 264 277 SUBROUTINE xios(get_field_attr_hdl) & 265 278 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 266 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&267 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )279 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 280 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 268 281 269 282 IMPLICIT NONE … … 282 295 TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: freq_op 283 296 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 297 LOGICAL , OPTIONAL, INTENT(OUT) :: indexed_output 298 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 284 299 INTEGER , OPTIONAL, INTENT(OUT) :: level 285 300 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name … … 297 312 CALL xios(get_field_attr_hdl_) & 298 313 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 299 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&300 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )314 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 315 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 301 316 302 317 END SUBROUTINE xios(get_field_attr_hdl) … … 304 319 SUBROUTINE xios(get_field_attr_hdl_) & 305 320 ( field_hdl, add_offset_, axis_ref_, compression_level_, default_value_, detect_missing_value_ & 306 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, level_, long_name_, name_ &307 , operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_, valid_min_ &308 )321 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, indexed_output_, level_ & 322 , long_name_, name_, operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_ & 323 , valid_min_ ) 309 324 310 325 IMPLICIT NONE … … 323 338 TYPE(txios(duration)) , OPTIONAL, INTENT(OUT) :: freq_op_ 324 339 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref_ 340 LOGICAL , OPTIONAL, INTENT(OUT) :: indexed_output_ 341 LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 325 342 INTEGER , OPTIONAL, INTENT(OUT) :: level_ 326 343 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name_ … … 382 399 ENDIF 383 400 401 IF (PRESENT(indexed_output_)) THEN 402 CALL cxios_get_field_indexed_output(field_hdl%daddr, indexed_output__tmp) 403 indexed_output_ = indexed_output__tmp 404 ENDIF 405 384 406 IF (PRESENT(level_)) THEN 385 407 CALL cxios_get_field_level(field_hdl%daddr, level_) … … 431 453 SUBROUTINE xios(is_defined_field_attr) & 432 454 ( field_id, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 433 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&434 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )455 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 456 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 435 457 436 458 IMPLICIT NONE … … 459 481 LOGICAL, OPTIONAL, INTENT(OUT) :: grid_ref 460 482 LOGICAL(KIND=C_BOOL) :: grid_ref_tmp 483 LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 484 LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 461 485 LOGICAL, OPTIONAL, INTENT(OUT) :: level 462 486 LOGICAL(KIND=C_BOOL) :: level_tmp … … 485 509 CALL xios(is_defined_field_attr_hdl_) & 486 510 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 487 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&488 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )511 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 512 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 489 513 490 514 END SUBROUTINE xios(is_defined_field_attr) … … 492 516 SUBROUTINE xios(is_defined_field_attr_hdl) & 493 517 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 494 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&495 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )518 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 519 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 496 520 497 521 IMPLICIT NONE … … 519 543 LOGICAL, OPTIONAL, INTENT(OUT) :: grid_ref 520 544 LOGICAL(KIND=C_BOOL) :: grid_ref_tmp 545 LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 546 LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 521 547 LOGICAL, OPTIONAL, INTENT(OUT) :: level 522 548 LOGICAL(KIND=C_BOOL) :: level_tmp … … 544 570 CALL xios(is_defined_field_attr_hdl_) & 545 571 ( field_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value, domain_ref & 546 , enabled, field_ref, freq_offset, freq_op, grid_ref, level, long_name, name, operation, prec&547 , read_access, scale_factor, standard_name, unit, valid_max, valid_min )572 , enabled, field_ref, freq_offset, freq_op, grid_ref, indexed_output, level, long_name, name & 573 , operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min ) 548 574 549 575 END SUBROUTINE xios(is_defined_field_attr_hdl) … … 551 577 SUBROUTINE xios(is_defined_field_attr_hdl_) & 552 578 ( field_hdl, add_offset_, axis_ref_, compression_level_, default_value_, detect_missing_value_ & 553 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, level_, long_name_, name_ &554 , operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_, valid_min_ &555 )579 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, indexed_output_, level_ & 580 , long_name_, name_, operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_ & 581 , valid_min_ ) 556 582 557 583 IMPLICIT NONE … … 579 605 LOGICAL, OPTIONAL, INTENT(OUT) :: grid_ref_ 580 606 LOGICAL(KIND=C_BOOL) :: grid_ref__tmp 607 LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output_ 608 LOGICAL(KIND=C_BOOL) :: indexed_output__tmp 581 609 LOGICAL, OPTIONAL, INTENT(OUT) :: level_ 582 610 LOGICAL(KIND=C_BOOL) :: level__tmp … … 657 685 ENDIF 658 686 687 IF (PRESENT(indexed_output_)) THEN 688 indexed_output__tmp = cxios_is_defined_field_indexed_output(field_hdl%daddr) 689 indexed_output_ = indexed_output__tmp 690 ENDIF 691 659 692 IF (PRESENT(level_)) THEN 660 693 level__tmp = cxios_is_defined_field_level(field_hdl%daddr) -
XIOS/trunk/src/interface/fortran_attr/ifieldgroup_attr.F90
r608 r676 13 13 SUBROUTINE xios(set_fieldgroup_attr) & 14 14 ( fieldgroup_id, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 15 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&16 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&17 )15 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 16 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 17 , valid_min ) 18 18 19 19 IMPLICIT NONE … … 34 34 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 35 35 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 36 LOGICAL , OPTIONAL, INTENT(IN) :: indexed_output 37 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 36 38 INTEGER , OPTIONAL, INTENT(IN) :: level 37 39 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name … … 50 52 CALL xios(set_fieldgroup_attr_hdl_) & 51 53 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 52 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&53 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&54 )54 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 55 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 56 , valid_min ) 55 57 56 58 END SUBROUTINE xios(set_fieldgroup_attr) … … 58 60 SUBROUTINE xios(set_fieldgroup_attr_hdl) & 59 61 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 60 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&61 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&62 )62 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 63 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 64 , valid_min ) 63 65 64 66 IMPLICIT NONE … … 78 80 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 79 81 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 82 LOGICAL , OPTIONAL, INTENT(IN) :: indexed_output 83 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 80 84 INTEGER , OPTIONAL, INTENT(IN) :: level 81 85 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name … … 93 97 CALL xios(set_fieldgroup_attr_hdl_) & 94 98 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 95 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&96 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&97 )99 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 100 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 101 , valid_min ) 98 102 99 103 END SUBROUTINE xios(set_fieldgroup_attr_hdl) … … 101 105 SUBROUTINE xios(set_fieldgroup_attr_hdl_) & 102 106 ( fieldgroup_hdl, add_offset_, axis_ref_, compression_level_, default_value_, detect_missing_value_ & 103 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, group_ref_, level_, long_name_ &104 , name_, operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_, valid_min_ &105 )107 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, group_ref_, indexed_output_ & 108 , level_, long_name_, name_, operation_, prec_, read_access_, scale_factor_, standard_name_ & 109 , unit_, valid_max_, valid_min_ ) 106 110 107 111 IMPLICIT NONE … … 121 125 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref_ 122 126 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref_ 127 LOGICAL , OPTIONAL, INTENT(IN) :: indexed_output_ 128 LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 123 129 INTEGER , OPTIONAL, INTENT(IN) :: level_ 124 130 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name_ … … 184 190 ENDIF 185 191 192 IF (PRESENT(indexed_output_)) THEN 193 indexed_output__tmp = indexed_output_ 194 CALL cxios_set_fieldgroup_indexed_output(fieldgroup_hdl%daddr, indexed_output__tmp) 195 ENDIF 196 186 197 IF (PRESENT(level_)) THEN 187 198 CALL cxios_set_fieldgroup_level(fieldgroup_hdl%daddr, level_) … … 233 244 SUBROUTINE xios(get_fieldgroup_attr) & 234 245 ( fieldgroup_id, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 235 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&236 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&237 )246 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 247 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 248 , valid_min ) 238 249 239 250 IMPLICIT NONE … … 254 265 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 255 266 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 267 LOGICAL , OPTIONAL, INTENT(OUT) :: indexed_output 268 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 256 269 INTEGER , OPTIONAL, INTENT(OUT) :: level 257 270 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name … … 270 283 CALL xios(get_fieldgroup_attr_hdl_) & 271 284 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 272 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&273 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&274 )285 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 286 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 287 , valid_min ) 275 288 276 289 END SUBROUTINE xios(get_fieldgroup_attr) … … 278 291 SUBROUTINE xios(get_fieldgroup_attr_hdl) & 279 292 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 280 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&281 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&282 )293 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 294 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 295 , valid_min ) 283 296 284 297 IMPLICIT NONE … … 298 311 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 299 312 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 313 LOGICAL , OPTIONAL, INTENT(OUT) :: indexed_output 314 LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 300 315 INTEGER , OPTIONAL, INTENT(OUT) :: level 301 316 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name … … 313 328 CALL xios(get_fieldgroup_attr_hdl_) & 314 329 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 315 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&316 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&317 )330 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 331 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 332 , valid_min ) 318 333 319 334 END SUBROUTINE xios(get_fieldgroup_attr_hdl) … … 321 336 SUBROUTINE xios(get_fieldgroup_attr_hdl_) & 322 337 ( fieldgroup_hdl, add_offset_, axis_ref_, compression_level_, default_value_, detect_missing_value_ & 323 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, group_ref_, level_, long_name_ &324 , name_, operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_, valid_min_ &325 )338 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, group_ref_, indexed_output_ & 339 , level_, long_name_, name_, operation_, prec_, read_access_, scale_factor_, standard_name_ & 340 , unit_, valid_max_, valid_min_ ) 326 341 327 342 IMPLICIT NONE … … 341 356 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref_ 342 357 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref_ 358 LOGICAL , OPTIONAL, INTENT(OUT) :: indexed_output_ 359 LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 343 360 INTEGER , OPTIONAL, INTENT(OUT) :: level_ 344 361 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name_ … … 404 421 ENDIF 405 422 423 IF (PRESENT(indexed_output_)) THEN 424 CALL cxios_get_fieldgroup_indexed_output(fieldgroup_hdl%daddr, indexed_output__tmp) 425 indexed_output_ = indexed_output__tmp 426 ENDIF 427 406 428 IF (PRESENT(level_)) THEN 407 429 CALL cxios_get_fieldgroup_level(fieldgroup_hdl%daddr, level_) … … 453 475 SUBROUTINE xios(is_defined_fieldgroup_attr) & 454 476 ( fieldgroup_id, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 455 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&456 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&457 )477 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 478 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 479 , valid_min ) 458 480 459 481 IMPLICIT NONE … … 484 506 LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 485 507 LOGICAL(KIND=C_BOOL) :: group_ref_tmp 508 LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 509 LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 486 510 LOGICAL, OPTIONAL, INTENT(OUT) :: level 487 511 LOGICAL(KIND=C_BOOL) :: level_tmp … … 510 534 CALL xios(is_defined_fieldgroup_attr_hdl_) & 511 535 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 512 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&513 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&514 )536 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 537 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 538 , valid_min ) 515 539 516 540 END SUBROUTINE xios(is_defined_fieldgroup_attr) … … 518 542 SUBROUTINE xios(is_defined_fieldgroup_attr_hdl) & 519 543 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 520 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&521 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&522 )544 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 545 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 546 , valid_min ) 523 547 524 548 IMPLICIT NONE … … 548 572 LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 549 573 LOGICAL(KIND=C_BOOL) :: group_ref_tmp 574 LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 575 LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 550 576 LOGICAL, OPTIONAL, INTENT(OUT) :: level 551 577 LOGICAL(KIND=C_BOOL) :: level_tmp … … 573 599 CALL xios(is_defined_fieldgroup_attr_hdl_) & 574 600 ( fieldgroup_hdl, add_offset, axis_ref, compression_level, default_value, detect_missing_value & 575 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, level, long_name&576 , name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max, valid_min&577 )601 , domain_ref, enabled, field_ref, freq_offset, freq_op, grid_ref, group_ref, indexed_output & 602 , level, long_name, name, operation, prec, read_access, scale_factor, standard_name, unit, valid_max & 603 , valid_min ) 578 604 579 605 END SUBROUTINE xios(is_defined_fieldgroup_attr_hdl) … … 581 607 SUBROUTINE xios(is_defined_fieldgroup_attr_hdl_) & 582 608 ( fieldgroup_hdl, add_offset_, axis_ref_, compression_level_, default_value_, detect_missing_value_ & 583 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, group_ref_, level_, long_name_ &584 , name_, operation_, prec_, read_access_, scale_factor_, standard_name_, unit_, valid_max_, valid_min_ &585 )609 , domain_ref_, enabled_, field_ref_, freq_offset_, freq_op_, grid_ref_, group_ref_, indexed_output_ & 610 , level_, long_name_, name_, operation_, prec_, read_access_, scale_factor_, standard_name_ & 611 , unit_, valid_max_, valid_min_ ) 586 612 587 613 IMPLICIT NONE … … 611 637 LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref_ 612 638 LOGICAL(KIND=C_BOOL) :: group_ref__tmp 639 LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output_ 640 LOGICAL(KIND=C_BOOL) :: indexed_output__tmp 613 641 LOGICAL, OPTIONAL, INTENT(OUT) :: level_ 614 642 LOGICAL(KIND=C_BOOL) :: level__tmp … … 694 722 ENDIF 695 723 724 IF (PRESENT(indexed_output_)) THEN 725 indexed_output__tmp = cxios_is_defined_fieldgroup_indexed_output(fieldgroup_hdl%daddr) 726 indexed_output_ = indexed_output__tmp 727 ENDIF 728 696 729 IF (PRESENT(level_)) THEN 697 730 level__tmp = cxios_is_defined_fieldgroup_level(fieldgroup_hdl%daddr) -
XIOS/trunk/src/node/axis.cpp
r670 r676 8 8 #include "context.hpp" 9 9 #include "context_client.hpp" 10 #include "context_server.hpp" 10 11 #include "xios_spl.hpp" 11 12 #include "inverse_axis.hpp" … … 14 15 #include "server_distribution_description.hpp" 15 16 #include "client_server_mapping_distributed.hpp" 17 #include "distribution_client.hpp" 16 18 17 19 namespace xios { … … 22 24 : CObjectTemplate<CAxis>() 23 25 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 24 , isDistributed_(false), hasBounds_(false) 26 , isDistributed_(false), hasBounds_(false), isCompressible_(false) 27 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 25 28 , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 26 29 { … … 30 33 : CObjectTemplate<CAxis>(id) 31 34 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 32 , isDistributed_(false), hasBounds_(false) 35 , isDistributed_(false), hasBounds_(false), isCompressible_(false) 36 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 33 37 , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 34 38 { … … 50 54 } 51 55 56 bool CAxis::isWrittenCompressed(const StdString& filename) const 57 { 58 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 59 } 60 52 61 bool CAxis::isDistributed(void) const 53 62 { … … 55 64 } 56 65 66 /*! 67 * Test whether the data defined on the axis can be outputted in a compressed way. 68 * 69 * \return true if and only if a mask was defined for this axis 70 */ 71 bool CAxis::isCompressible(void) const 72 { 73 return isCompressible_; 74 } 75 57 76 void CAxis::addRelFile(const StdString & filename) 58 77 { 59 78 this->relFiles.insert(filename); 79 } 80 81 void CAxis::addRelFileCompressed(const StdString& filename) 82 { 83 this->relFilesCompressed.insert(filename); 84 } 85 86 //---------------------------------------------------------------- 87 88 const std::vector<int>& CAxis::getIndexesToWrite(void) const 89 { 90 return indexesToWrite; 91 } 92 93 /*! 94 Returns the number of indexes written by each server. 95 \return the number of indexes written by each server 96 */ 97 int CAxis::getNumberWrittenIndexes() const 98 { 99 return numberWrittenIndexes_; 100 } 101 102 /*! 103 Returns the total number of indexes written by the servers. 104 \return the total number of indexes written by the servers 105 */ 106 int CAxis::getTotalNumberWrittenIndexes() const 107 { 108 return totalNumberWrittenIndexes_; 109 } 110 111 /*! 112 Returns the offset of indexes written by each server. 113 \return the offset of indexes written by each server 114 */ 115 int CAxis::getOffsetWrittenIndexes() const 116 { 117 return offsetWrittenIndexes_; 60 118 } 61 119 … … 171 229 } 172 230 231 void CAxis::checkEligibilityForCompressedOutput() 232 { 233 // We don't check if the mask is valid here, just if a mask has been defined at this point. 234 isCompressible_ = !mask.isEmpty(); 235 } 173 236 174 237 bool CAxis::dispatchEvent(CEventServer& event) … … 277 340 } 278 341 342 std::set<int> writtenInd; 343 if (isCompressible_) 344 { 345 for (int idx = 0; idx < data_index.numElements(); ++idx) 346 { 347 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 348 349 if (ind >= 0 && ind < ni && mask(ind)) 350 { 351 ind += ibegin; 352 if (ind >= global_zoom_begin && ind <= zoom_end) 353 writtenInd.insert(ind); 354 } 355 } 356 } 357 279 358 std::vector<int> nGlobDomain(1); 280 359 nGlobDomain[0] = n_glo.getValue(); … … 303 382 iteVec = (globalAxisZoom).end(); 304 383 indSrv_.clear(); 384 indWrittenSrv_.clear(); 305 385 for (; it != ite; ++it) 306 386 { … … 315 395 indSrv_[rank].push_back(globalIndexTmp[i]); 316 396 } 397 398 if (writtenInd.count(globalIndexTmp[i])) 399 { 400 indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 401 } 317 402 } 318 403 } … … 337 422 CContext* context = CContext::getCurrent(); 338 423 CContextClient* client = context->client; 339 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_VALUE);340 341 int zoom_end = global_zoom_begin +global_zoom_size-1;342 int nb = 0;424 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_VALUE); 425 426 int zoom_end = global_zoom_begin + global_zoom_size - 1; 427 int nb = 0; 343 428 for (size_t idx = 0; idx < n; ++idx) 344 429 { 345 430 size_t globalIndex = begin + idx; 346 431 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nb; 432 } 433 434 int nbWritten = 0; 435 if (isCompressible_) 436 { 437 for (int idx = 0; idx < data_index.numElements(); ++idx) 438 { 439 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, n); 440 441 if (ind >= 0 && ind < n && mask(ind)) 442 { 443 ind += begin; 444 if (ind >= global_zoom_begin && ind <= zoom_end) 445 ++nbWritten; 446 } 447 } 347 448 } 348 449 … … 359 460 } 360 461 462 CArray<int, 1> writtenInd(nbWritten); 463 nbWritten = 0; 464 if (isCompressible_) 465 { 466 for (int idx = 0; idx < data_index.numElements(); ++idx) 467 { 468 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, n); 469 470 if (ind >= 0 && ind < n && mask(ind)) 471 { 472 ind += begin; 473 if (ind >= global_zoom_begin && ind <= zoom_end) 474 { 475 writtenInd(nbWritten) = ind; 476 ++nbWritten; 477 } 478 } 479 } 480 } 481 361 482 if (client->isServerLeader()) 362 483 { … … 366 487 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 367 488 { 368 // Use const int to ensure CMessage holds a copy of the value instead of just a reference369 489 msgs.push_back(CMessage()); 370 490 CMessage& msg = msgs.back(); 371 491 msg << this->getId(); 372 492 msg << val; 373 event.push(*itRank,1,msg); 493 if (isCompressible_) 494 msg << writtenInd; 495 event.push(*itRank, 1, msg); 374 496 } 375 497 client->sendEvent(event); … … 390 512 list<CMessage> list_msgsIndex, list_msgsVal; 391 513 list<CArray<int,1> > list_indi; 514 list<CArray<int,1> > list_writtenInd; 392 515 list<CArray<double,1> > list_val; 393 516 list<CArray<double,2> > list_bounds; … … 433 556 list_msgsIndex.back() << this->getId() << list_indi.back(); 434 557 558 if (isCompressible_) 559 { 560 std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 561 list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 562 CArray<int,1>& writtenInd = list_writtenInd.back(); 563 564 for (n = 0; n < writtenInd.numElements(); ++n) 565 writtenInd(n) = writtenIndSrc[n]; 566 567 list_msgsIndex.back() << writtenInd; 568 } 569 435 570 list_msgsVal.push_back(CMessage()); 436 571 list_msgsVal.back() << this->getId() << list_val.back(); … … 451 586 void CAxis::recvIndex(CEventServer& event) 452 587 { 588 CAxis* axis; 589 453 590 list<CEventServer::SSubEvent>::iterator it; 454 591 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 455 592 { 456 593 CBufferIn* buffer = it->buffer; 457 string domainId; 458 *buffer >> domainId; 459 get(domainId)->recvIndex(it->rank, *buffer); 594 string axisId; 595 *buffer >> axisId; 596 axis = get(axisId); 597 axis->recvIndex(it->rank, *buffer); 598 } 599 600 if (axis->isCompressible_) 601 { 602 std::sort(axis->indexesToWrite.begin(), axis->indexesToWrite.end()); 603 604 CContextServer* server = CContext::getCurrent()->server; 605 axis->numberWrittenIndexes_ = axis->indexesToWrite.size(); 606 MPI_Allreduce(&axis->numberWrittenIndexes_, &axis->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 607 MPI_Scan(&axis->numberWrittenIndexes_, &axis->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 608 axis->offsetWrittenIndexes_ -= axis->numberWrittenIndexes_; 460 609 } 461 610 } … … 464 613 { 465 614 buffer >> indiSrv_[rank]; 615 616 if (isCompressible_) 617 { 618 CArray<int, 1> writtenIndexes; 619 buffer >> writtenIndexes; 620 indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 621 for (int i = 0; i < writtenIndexes.numElements(); ++i) 622 indexesToWrite.push_back(writtenIndexes(i)); 623 } 466 624 } 467 625 … … 472 630 { 473 631 CBufferIn* buffer = it->buffer; 474 string domainId;475 *buffer >> domainId;476 get( domainId)->recvDistributedValue(it->rank, *buffer);632 string axisId; 633 *buffer >> axisId; 634 get(axisId)->recvDistributedValue(it->rank, *buffer); 477 635 } 478 636 } … … 503 661 void CAxis::recvNonDistributedValue(CEventServer& event) 504 662 { 663 CAxis* axis; 664 505 665 list<CEventServer::SSubEvent>::iterator it; 506 666 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 507 667 { 508 668 CBufferIn* buffer = it->buffer; 509 string domainId; 510 *buffer >> domainId; 511 get(domainId)->recvNonDistributedValue(it->rank, *buffer); 669 string axisId; 670 *buffer >> axisId; 671 axis = get(axisId); 672 axis->recvNonDistributedValue(it->rank, *buffer); 673 } 674 675 if (axis->isCompressible_) 676 { 677 std::sort(axis->indexesToWrite.begin(), axis->indexesToWrite.end()); 678 679 axis->numberWrittenIndexes_ = axis->totalNumberWrittenIndexes_ = axis->indexesToWrite.size(); 680 axis->offsetWrittenIndexes_ = 0; 512 681 } 513 682 } … … 526 695 bound_srv(1,ind) = bounds(1,ind); 527 696 } 697 } 698 699 if (isCompressible_) 700 { 701 CArray<int, 1> writtenIndexes; 702 buffer >> writtenIndexes; 703 indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 704 for (int i = 0; i < writtenIndexes.numElements(); ++i) 705 indexesToWrite.push_back(writtenIndexes(i)); 528 706 } 529 707 } … … 561 739 msg << ni << begin << end; 562 740 msg << global_zoom_begin << global_zoom_size; 741 msg << isCompressible_; 563 742 564 743 event.push(*itRank,1,msg); … … 581 760 int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_size_tmp; 582 761 583 buffer>>ni_srv>>begin_srv>>end_srv>>global_zoom_begin_tmp>>global_zoom_size_tmp; 762 buffer >> ni_srv >> begin_srv >> end_srv; 763 buffer >> global_zoom_begin_tmp >> global_zoom_size_tmp; 764 buffer >> isCompressible_; 584 765 global_zoom_begin = global_zoom_begin_tmp; 585 766 global_zoom_size = global_zoom_size_tmp; -
XIOS/trunk/src/node/axis.hpp
r633 r676 67 67 const std::set<StdString> & getRelFiles(void) const; 68 68 69 const std::vector<int>& getIndexesToWrite(void) const; 70 int getNumberWrittenIndexes() const; 71 int getTotalNumberWrittenIndexes() const; 72 int getOffsetWrittenIndexes() const; 73 69 74 /// Test /// 70 75 bool IsWritten(const StdString & filename) const; 76 bool isWrittenCompressed(const StdString& filename) const; 71 77 bool isDistributed(void) const; 78 bool isCompressible(void) const; 72 79 73 80 /// Mutateur /// 74 81 void addRelFile(const StdString & filename); 82 void addRelFileCompressed(const StdString& filename); 75 83 76 84 /// Vérifications /// … … 97 105 CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); 98 106 107 void checkEligibilityForCompressedOutput(); 108 99 109 bool hasTransformation(); 100 110 void solveInheritanceTransformation(); … … 107 117 CArray<double,1> value_srv; 108 118 CArray<double,2> bound_srv; 109 private : 119 120 private: 110 121 void checkData(); 111 122 void checkMask(); … … 128 139 129 140 void setTransformations(const TransMapTypes&); 141 130 142 private: 131 143 bool isChecked; 132 144 bool areClientAttributesChecked_; 133 std::set<StdString> relFiles ;145 std::set<StdString> relFiles, relFilesCompressed; 134 146 TransMapTypes transformationMap_; 135 147 bool isDistributed_; 148 //! True if and only if the data defined on the axis can be outputted in a compressed way 149 bool isCompressible_; 136 150 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 137 151 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 152 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 153 std::vector<int> indexesToWrite; 154 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 138 155 std::vector<int> connectedServerRank_; 139 156 std::map<int, CArray<int,1> > indiSrv_; -
XIOS/trunk/src/node/context.cpp
r655 r676 745 745 // Find all inheritance in xml structure 746 746 this->solveAllInheritance(); 747 748 // Check if some axis, domains or grids are eligible to for compressed indexed output. 749 // Warning: This must be done after solving the inheritance and before the rest of post-processing 750 checkAxisDomainsGridsEligibilityForCompressedOutput(); 747 751 748 752 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. … … 851 855 } 852 856 857 //! Client side: Check if the defined axis, domains and grids are eligible for compressed indexed output 858 void CContext::checkAxisDomainsGridsEligibilityForCompressedOutput() 859 { 860 if (!hasClient) return; 861 862 const vector<CAxis*> allAxis = CAxis::getAll(); 863 for (vector<CAxis*>::const_iterator it = allAxis.begin(); it != allAxis.end(); it++) 864 (*it)->checkEligibilityForCompressedOutput(); 865 866 const vector<CDomain*> allDomains = CDomain::getAll(); 867 for (vector<CDomain*>::const_iterator it = allDomains.begin(); it != allDomains.end(); it++) 868 (*it)->checkEligibilityForCompressedOutput(); 869 870 const vector<CGrid*> allGrids = CGrid::getAll(); 871 for (vector<CGrid*>::const_iterator it = allGrids.begin(); it != allGrids.end(); it++) 872 (*it)->checkEligibilityForCompressedOutput(); 873 } 874 853 875 //! Client side: Send information of reference grid of active fields 854 876 void CContext::sendRefGrid() -
XIOS/trunk/src/node/context.hpp
r655 r676 109 109 void updateCalendar(int step); 110 110 void createFileHeader(void ); 111 void checkAxisDomainsGridsEligibilityForCompressedOutput(); 111 112 void solveAllRefOfEnabledFields(bool sendToServer); 112 113 void buildFilterGraphOfEnabledFields(); -
XIOS/trunk/src/node/domain.cpp
r675 r676 13 13 #include "context.hpp" 14 14 #include "context_client.hpp" 15 #include "context_server.hpp" 15 16 #include "array_new.hpp" 17 #include "distribution_client.hpp" 16 18 #include "server_distribution_description.hpp" 17 19 #include "client_server_mapping_distributed.hpp" … … 19 21 #include "interpolate_from_file_domain.hpp" 20 22 23 #include <algorithm> 24 21 25 namespace xios { 22 26 … … 26 30 : CObjectTemplate<CDomain>(), CDomainAttributes() 27 31 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 28 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), is Unstructed_(false)32 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 29 33 , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 30 34 , isClientAfterTransformationChecked(false), hasLonLat(false) … … 35 39 : CObjectTemplate<CDomain>(id), CDomainAttributes() 36 40 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 37 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), is Unstructed_(false)41 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 38 42 , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 39 43 , isClientAfterTransformationChecked(false), hasLonLat(false) … … 64 68 65 69 //---------------------------------------------------------------- 70 71 const std::vector<int>& CDomain::getIndexesToWrite(void) const 72 { 73 return indexesToWrite; 74 } 75 76 /*! 77 Returns the number of indexes written by each server. 78 \return the number of indexes written by each server 79 */ 80 int CDomain::getNumberWrittenIndexes() const 81 { 82 return numberWrittenIndexes_; 83 } 84 85 /*! 86 Returns the total number of indexes written by the servers. 87 \return the total number of indexes written by the servers 88 */ 89 int CDomain::getTotalNumberWrittenIndexes() const 90 { 91 return totalNumberWrittenIndexes_; 92 } 93 94 /*! 95 Returns the offset of indexes written by each server. 96 \return the offset of indexes written by each server 97 */ 98 int CDomain::getOffsetWrittenIndexes() const 99 { 100 return offsetWrittenIndexes_; 101 } 102 103 //---------------------------------------------------------------- 104 66 105 bool CDomain::isEmpty(void) const 67 106 { … … 71 110 72 111 //---------------------------------------------------------------- 112 73 113 bool CDomain::IsWritten(const StdString & filename) const 74 114 { … … 76 116 } 77 117 118 bool CDomain::isWrittenCompressed(const StdString& filename) const 119 { 120 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 121 } 122 78 123 //---------------------------------------------------------------- 124 79 125 bool CDomain::isDistributed(void) const 80 126 { … … 83 129 84 130 //---------------------------------------------------------------- 131 132 /*! 133 * Test whether the data defined on the domain can be outputted in a compressed way. 134 * 135 * \return true if and only if a mask was defined for this domain 136 */ 137 bool CDomain::isCompressible(void) const 138 { 139 return isCompressible_; 140 } 141 142 //---------------------------------------------------------------- 143 85 144 void CDomain::addRelFile(const StdString & filename) 86 145 { 87 146 this->relFiles.insert(filename); 147 } 148 149 void CDomain::addRelFileCompressed(const StdString& filename) 150 { 151 this->relFilesCompressed.insert(filename); 88 152 } 89 153 … … 246 310 } 247 311 248 249 312 //---------------------------------------------------------------- 313 250 314 void CDomain::checkDomainData(void) 251 315 { … … 357 421 358 422 //---------------------------------------------------------------- 423 424 void CDomain::checkEligibilityForCompressedOutput(void) 425 { 426 // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. 427 isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); 428 } 429 430 //---------------------------------------------------------------- 431 359 432 void CDomain::completeLonLatClient(void) 360 433 { … … 746 819 msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 747 820 msg << global_zoom_ni << global_zoom_ibegin << global_zoom_nj << global_zoom_jbegin; 821 msg << isCompressible_; 748 822 749 823 event.push(*itRank,1,msg); … … 783 857 { 784 858 ++globalIndexCountZoom; 859 } 860 } 861 862 int globalIndexWrittenCount = 0; 863 if (isCompressible_) 864 { 865 for (i = 0; i < data_i_index.numElements(); ++i) 866 { 867 i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 868 data_ibegin, data_jbegin, data_dim, ni, 869 j_ind); 870 if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 871 { 872 i_ind += ibegin; 873 j_ind += jbegin; 874 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 875 ++globalIndexWrittenCount; 876 } 785 877 } 786 878 } … … 809 901 } 810 902 811 size_t globalSizeIndex = 1, indexBegin, indexEnd; 812 int range, clientSize = client->clientSize; 813 for (int i = 0; i < nGlobDomain_.size(); ++i) globalSizeIndex *= nGlobDomain_[i]; 814 indexBegin = 0; 815 for (int i = 0; i < clientSize; ++i) 816 { 817 range = globalSizeIndex / clientSize; 818 if (i < (globalSizeIndex%clientSize)) ++range; 819 if (i == client->clientRank) break; 820 indexBegin += range; 821 } 822 indexEnd = indexBegin + range - 1; 903 CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 904 if (isCompressible_) 905 { 906 globalIndexWrittenCount = 0; 907 for (i = 0; i < data_i_index.numElements(); ++i) 908 { 909 i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 910 data_ibegin, data_jbegin, data_dim, ni, 911 j_ind); 912 if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 913 { 914 i_ind += ibegin; 915 j_ind += jbegin; 916 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 917 { 918 globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 919 ++globalIndexWrittenCount; 920 } 921 } 922 } 923 } 924 925 size_t globalSizeIndex = 1, indexBegin, indexEnd; 926 int range, clientSize = client->clientSize; 927 for (int i = 0; i < nGlobDomain_.size(); ++i) globalSizeIndex *= nGlobDomain_[i]; 928 indexBegin = 0; 929 for (int i = 0; i < clientSize; ++i) 930 { 931 range = globalSizeIndex / clientSize; 932 if (i < (globalSizeIndex%clientSize)) ++range; 933 if (i == client->clientRank) break; 934 indexBegin += range; 935 } 936 indexEnd = indexBegin + range - 1; 823 937 824 938 CServerDistributionDescription serverDescription(nGlobDomain_); … … 837 951 838 952 indSrv_.clear(); 953 indWrittenSrv_.clear(); 839 954 for (; it != ite; ++it) 840 955 { … … 853 968 } 854 969 } 970 for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 971 { 972 if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 973 { 974 indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 975 } 976 } 855 977 } 856 978 … … 888 1010 889 1011 list<CMessage> list_msgsIndex; 890 list<CArray<int,1> > list_indi, list_indj ;1012 list<CArray<int,1> > list_indi, list_indj, list_writtenInd; 891 1013 892 1014 std::map<int, std::vector<size_t> >::const_iterator it, iteMap; … … 918 1040 list_msgsIndex.back() << isCurvilinear; 919 1041 list_msgsIndex.back() << list_indi.back() << list_indj.back(); 1042 1043 if (isCompressible_) 1044 { 1045 std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 1046 list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 1047 CArray<int,1>& writtenInd = list_writtenInd.back(); 1048 1049 for (n = 0; n < writtenInd.numElements(); ++n) 1050 writtenInd(n) = writtenIndSrc[n]; 1051 1052 list_msgsIndex.back() << writtenInd; 1053 } 920 1054 921 1055 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); … … 1118 1252 { 1119 1253 buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv 1120 >> global_zoom_ni >> global_zoom_ibegin >> global_zoom_nj >> global_zoom_jbegin; 1254 >> global_zoom_ni >> global_zoom_ibegin >> global_zoom_nj >> global_zoom_jbegin 1255 >> isCompressible_; 1121 1256 1122 1257 int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; … … 1158 1293 void CDomain::recvIndex(CEventServer& event) 1159 1294 { 1295 CDomain* domain; 1296 1160 1297 list<CEventServer::SSubEvent>::iterator it; 1161 1298 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) … … 1164 1301 string domainId; 1165 1302 *buffer >> domainId; 1166 get(domainId)->recvIndex(it->rank, *buffer); 1303 domain = get(domainId); 1304 domain->recvIndex(it->rank, *buffer); 1305 } 1306 1307 if (domain->isCompressible_) 1308 { 1309 std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 1310 1311 CContextServer* server = CContext::getCurrent()->server; 1312 domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 1313 MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 1314 MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 1315 domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 1167 1316 } 1168 1317 } … … 1178 1327 buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 1179 1328 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 1329 1330 if (isCompressible_) 1331 { 1332 CArray<int, 1> writtenIndexes; 1333 buffer >> writtenIndexes; 1334 indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 1335 for (int i = 0; i < writtenIndexes.numElements(); ++i) 1336 indexesToWrite.push_back(writtenIndexes(i)); 1337 } 1180 1338 } 1181 1339 -
XIOS/trunk/src/node/domain.hpp
r667 r676 47 47 typedef CDomainAttributes SuperClassAttribute; 48 48 49 public 49 public: 50 50 51 51 typedef CDomainAttributes RelAttributes; … … 70 70 void checkAttributesOnClientAfterTransformation(); 71 71 72 void checkEligibilityForCompressedOutput(void); 73 72 74 void sendCheckedAttributes(); 73 75 … … 76 78 TransMapTypes getAllTransformations(); 77 79 78 public 80 public: 79 81 const std::set<StdString> & getRelFiles(void) const; 80 82 bool IsWritten(const StdString & filename) const; 83 bool isWrittenCompressed(const StdString& filename) const; 84 85 const std::vector<int>& getIndexesToWrite(void) const; 86 int getNumberWrittenIndexes() const; 87 int getTotalNumberWrittenIndexes() const; 88 int getOffsetWrittenIndexes() const; 89 81 90 bool isEmpty(void) const; 82 91 bool isDistributed(void) const; 83 92 bool isCompressible(void) const; 84 93 85 94 int global_zoom_ibegin, global_zoom_ni; … … 104 113 vector< vector<int> > j_indSrv ; // for each server, j global index to send 105 114 106 public 115 public: 107 116 /// Mutateur /// 108 117 void addRelFile(const StdString & filename); 118 void addRelFileCompressed(const StdString& filename); 109 119 void completeLonLatClient(void); 110 120 void sendServerAttribut(void) ; … … 159 169 void sendLonLat(); 160 170 161 private 171 private: 162 172 bool isChecked; 163 std::set<StdString> relFiles ;173 std::set<StdString> relFiles, relFilesCompressed; 164 174 bool isClientChecked; // Verify whether all attributes of domain on the client side are good 165 175 bool isClientAfterTransformationChecked; … … 167 177 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 168 178 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 179 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 180 std::vector<int> indexesToWrite; 181 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 169 182 std::vector<int> connectedServerRank_; 170 183 bool isDistributed_; 184 //! True if and only if the data defined on the domain can be outputted in a compressed way 185 bool isCompressible_; 171 186 TransMapTypes transformationMap_; 172 187 std::vector<int> nGlobDomain_; -
XIOS/trunk/src/node/field.cpp
r651 r676 35 35 , hasOutputFile(false) 36 36 , domAxisIds_("", ""), areAllReferenceSolved(false) 37 , useCompressedOutput(false) 37 38 , isReadDataRequestPending(false) 38 39 { setVirtualVariableGroup(); } … … 45 46 , hasOutputFile(false) 46 47 , domAxisIds_("", ""), areAllReferenceSolved(false) 48 , useCompressedOutput(false) 47 49 , isReadDataRequestPending(false) 48 50 { setVirtualVariableGroup(); } … … 455 457 { 456 458 return !this->refObject.empty(); 459 } 460 461 //---------------------------------------------------------------- 462 463 bool CField::getUseCompressedOutput() const 464 { 465 return useCompressedOutput; 466 } 467 468 void CField::setUseCompressedOutput() 469 { 470 useCompressedOutput = true; 457 471 } 458 472 … … 814 828 for(it=data_srv.begin();it!=data_srv.end();it++) 815 829 { 816 grid->outputField(it->first, it->second, fieldOut.dataFirst()) 830 grid->outputField(it->first, it->second, fieldOut.dataFirst()); 817 831 } 818 832 } … … 824 838 for (it = data_srv.begin(); it != data_srv.end(); it++) 825 839 { 826 grid->outputField(it->first, it->second, fieldOut.dataFirst()) 840 grid->outputField(it->first, it->second, fieldOut.dataFirst()); 827 841 } 828 842 } … … 852 866 { 853 867 grid->inputField(it->first, fieldOut.dataFirst(), it->second); 868 } 869 } 870 871 void CField::outputCompressedField(CArray<double,1>& fieldOut) 872 { 873 map<int, CArray<double,1> >::iterator it; 874 875 for (it = data_srv.begin(); it != data_srv.end(); it++) 876 { 877 grid->outputCompressedField(it->first, it->second, fieldOut.dataFirst()); 854 878 } 855 879 } -
XIOS/trunk/src/node/field.hpp
r651 r676 99 99 bool isActive(void) const; 100 100 bool hasOutputFile; 101 102 bool getUseCompressedOutput() const; 103 void setUseCompressedOutput(); 101 104 102 105 /// Traitements /// … … 142 145 void inputField(CArray<double,2>& fieldOut); 143 146 void inputField(CArray<double,1>& fieldOut); 147 void outputCompressedField(CArray<double, 1>& fieldOut); 144 148 void scaleFactorAddOffset(double scaleFactor, double addOffset); 145 149 void invertScaleFactorAddOffset(double scaleFactor, double addOffset); … … 187 191 std::pair<StdString,StdString> domAxisIds_; 188 192 bool isReadDataRequestPending; 193 bool useCompressedOutput; 189 194 190 195 DECLARE_REF_FUNC(Field,field) -
XIOS/trunk/src/node/grid.cpp
r671 r676 25 25 : CObjectTemplate<CGrid>(), CGridAttributes() 26 26 , isChecked(false), isDomainAxisChecked(false) 27 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 28 , serverDistribution_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 29 , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), transformations_(0), isTransformed_(false) 27 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false) 28 , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0) 29 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 30 , globalDim_(), connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 31 , transformations_(0), isTransformed_(false) 30 32 , axisPositionInGrid_(), positionDimensionDistributed_(1) 31 33 { … … 37 39 : CObjectTemplate<CGrid>(id), CGridAttributes() 38 40 , isChecked(false), isDomainAxisChecked(false) 39 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 40 , serverDistribution_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 41 , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), transformations_(0), isTransformed_(false) 41 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false) 42 , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0) 43 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 44 , globalDim_(), connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 45 , transformations_(0), isTransformed_(false) 42 46 , axisPositionInGrid_(), positionDimensionDistributed_(1) 43 47 { … … 149 153 } 150 154 155 //--------------------------------------------------------------- 156 157 /*! 158 * Test whether the data defined on the grid can be outputted in a compressed way. 159 * 160 * \return true if and only if a mask was defined for this grid 161 */ 162 bool CGrid::isCompressible(void) const 163 { 164 return isCompressible_; 165 } 166 167 //--------------------------------------------------------------- 168 169 void CGrid::addRelFileCompressed(const StdString& filename) 170 { 171 this->relFilesCompressed.insert(filename); 172 } 173 174 bool CGrid::isWrittenCompressed(const StdString& filename) const 175 { 176 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 177 } 178 179 //--------------------------------------------------------------- 180 151 181 void CGrid::solveDomainAxisRef(bool areAttributesChecked) 152 182 { … … 157 187 computeGridGlobalDimension(getDomains(), getAxis(), axis_domain_order); 158 188 this->isDomainAxisChecked = areAttributesChecked; 189 } 190 191 void CGrid::checkEligibilityForCompressedOutput() 192 { 193 // We don't check if the mask is valid here, just if a mask has been defined at this point. 194 isCompressible_ = !mask1.isEmpty() || !mask2.isEmpty() || !mask3.isEmpty(); 159 195 } 160 196 … … 488 524 } 489 525 526 void CGrid::outputCompressedField(int rank, const CArray<double,1>& stored, double* field) 527 { 528 const CArray<size_t,1>& out_i = compressedOutIndexFromClient[rank]; 529 StdSize numElements = stored.numElements(); 530 for (StdSize n = 0; n < numElements; ++n) 531 { 532 field[out_i(n)] = stored(n); 533 } 534 } 535 490 536 //---------------------------------------------------------------- 491 537 … … 518 564 } 519 565 isDataDistributed_ = false; 566 } 567 568 void CGrid::computeCompressedIndex() 569 { 570 compressedOutIndexFromClient = outIndexFromClient; 571 572 std::map<size_t, size_t> indexes; 573 574 { 575 std::map<int, CArray<size_t,1> >::const_iterator it = compressedOutIndexFromClient.begin(); 576 std::map<int, CArray<size_t,1> >::const_iterator itEnd = compressedOutIndexFromClient.end(); 577 for (; it != itEnd; ++it) 578 { 579 for (int i = 0; i < it->second.numElements(); ++i) 580 indexes.insert(std::make_pair(it->second(i), 0)); 581 } 582 } 583 584 { 585 std::map<size_t, size_t>::iterator it = indexes.begin(); 586 std::map<size_t, size_t>::iterator itEnd = indexes.end(); 587 for (size_t i = 0; it != itEnd; ++it, ++i) 588 it->second = i; 589 } 590 591 { 592 std::map<int, CArray<size_t,1> >::iterator it = compressedOutIndexFromClient.begin(); 593 std::map<int, CArray<size_t,1> >::iterator itEnd = compressedOutIndexFromClient.end(); 594 for (; it != itEnd; ++it) 595 { 596 for (int i = 0; i < it->second.numElements(); ++i) 597 it->second(i) = indexes[it->second(i)]; 598 } 599 } 520 600 } 521 601 … … 547 627 548 628 listMsg.push_back(CMessage()); 549 listMsg.back() << getId( )<< isDataDistributed_ << listOutIndex.back();629 listMsg.back() << getId( )<< isDataDistributed_ << isCompressible_ << listOutIndex.back(); 550 630 551 631 event.push(rank, 1, listMsg.back()); … … 589 669 590 670 listMsg.push_back(CMessage()); 591 listMsg.back() << getId() << isDataDistributed_ << listOutIndex.back();671 listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 592 672 593 673 event.push(rank, 1, listMsg.back()); … … 650 730 651 731 listMsg.push_back(CMessage()); 652 listMsg.back() << getId() << isDataDistributed_ << listOutIndex.back();732 listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 653 733 654 734 event.push(rank, nbSenders[rank], listMsg.back()); … … 741 821 } 742 822 823 /*! 824 Returns the number of indexes written by each server. 825 \return the number of indexes written by each server 826 */ 827 int CGrid::getNumberWrittenIndexes() const 828 { 829 return numberWrittenIndexes_; 830 } 831 832 /*! 833 Returns the total number of indexes written by the servers. 834 \return the total number of indexes written by the servers 835 */ 836 int CGrid::getTotalNumberWrittenIndexes() const 837 { 838 return totalNumberWrittenIndexes_; 839 } 840 841 /*! 842 Returns the offset of indexes written by each server. 843 \return the offset of indexes written by each server 844 */ 845 int CGrid::getOffsetWrittenIndexes() const 846 { 847 return offsetWrittenIndexes_; 848 } 849 743 850 const CDistributionServer* CGrid::getDistributionServer() const 744 851 { … … 762 869 CContext* context = CContext::getCurrent(); 763 870 CContextServer* server = context->server; 871 numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 764 872 765 873 for (int n = 0; n < ranks.size(); n++) … … 768 876 CBufferIn& buffer = *buffers[n]; 769 877 770 buffer >> isDataDistributed_ ;878 buffer >> isDataDistributed_ >> isCompressible_; 771 879 size_t dataSize = 0; 772 880 773 881 if (isScalarGrid()) 774 882 { 775 writtenDataSize_ = 1;883 writtenDataSize_ = numberWrittenIndexes_ = totalNumberWrittenIndexes_ = 1; 776 884 CArray<size_t,1> outIndex; 777 885 buffer >> outIndex; … … 849 957 outIndexFromClient.insert(std::make_pair(rank, outIndex)); 850 958 connectedDataSize_[rank] = outIndex.numElements(); 851 } 959 numberWrittenIndexes_ += outIndex.numElements(); 960 } 961 962 if (isDataDistributed_) 963 { 964 MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 965 MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 966 offsetWrittenIndexes_ -= numberWrittenIndexes_; 967 } 968 else 969 totalNumberWrittenIndexes_ = numberWrittenIndexes_; 852 970 853 971 nbSenders = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); -
XIOS/trunk/src/node/grid.hpp
r664 r676 48 48 typedef CGridAttributes SuperClassAttribute; 49 49 50 public 50 public: 51 51 52 52 typedef CGridAttributes RelAttributes; … … 72 72 // void solveReference(void); 73 73 74 void checkEligibilityForCompressedOutput(); 75 74 76 void solveDomainAxisRef(bool areAttributesChecked); 75 77 … … 79 81 // virtual void fromBinary(StdIStream& is); 80 82 83 void addRelFileCompressed(const StdString& filename); 84 81 85 /// Tests /// 82 bool hasAxis(void) const; 83 84 public : 86 bool isCompressible(void) const; 87 bool isWrittenCompressed(const StdString& filename) const; 88 89 public: 85 90 86 91 /// Accesseurs /// … … 98 103 void inputField(int rank, const double* const field, CArray<double,1>& stored); 99 104 105 void outputCompressedField(int rank, const CArray<double,1>& stored, double* field); 106 100 107 virtual void parse(xml::CXMLNode& node); 101 108 … … 103 110 virtual ~CGrid(void); 104 111 105 public 112 public: 106 113 107 114 /// Accesseurs statiques /// … … 116 123 static CGrid* createGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis, CArray<bool,1> axisDomainOrder = CArray<bool,1>()); 117 124 118 public 125 public: 119 126 120 127 /// Entrées-sorties de champs (interne) /// … … 126 133 void computeIndex(void); 127 134 void computeIndexScalarGrid(); 135 void computeCompressedIndex(); 128 136 129 137 void solveDomainRef(bool checkAtt); … … 163 171 bool doGridHaveDataDistributed(); 164 172 size_t getWrittenDataSize() const; 173 int getNumberWrittenIndexes() const; 174 int getTotalNumberWrittenIndexes() const; 175 int getOffsetWrittenIndexes() const; 165 176 166 177 const CDistributionServer* getDistributionServer() const; … … 184 195 map<int,int> nbSenders; 185 196 186 map<int, CArray<size_t, 1> > outIndexFromClient ;197 map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; 187 198 void checkMask(void); 188 199 void modifyMask(const CArray<int,1>& indexToModify); … … 221 232 222 233 std::vector<int> globalDim_; 234 223 235 private: 224 236 CDomainGroup* vDomainGroup_; … … 231 243 CClientServerMapping* clientServerMap_; 232 244 size_t writtenDataSize_; 245 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 233 246 std::map<int,size_t> connectedDataSize_; 234 247 std::vector<int> connectedServerRank_; 235 248 bool isDataDistributed_; 236 249 int positionDimensionDistributed_; 250 //! True if and only if the data defined on the grid can be outputted in a compressed way 251 bool isCompressible_; 252 std::set<std::string> relFilesCompressed; 237 253 238 254 bool isTransformed_; -
XIOS/trunk/src/output/nc4_data_output.cpp
r665 r676 741 741 } 742 742 743 //-------------------------------------------------------------- 744 745 void CNc4DataOutput::writeGridCompressed_(CGrid* grid) 746 { 747 if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; 748 749 try 750 { 751 CArray<bool,1> axisDomainOrder = grid->axis_domain_order; 752 std::vector<StdString> domainList = grid->getDomainList(); 753 std::vector<StdString> axisList = grid->getAxisList(); 754 int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0; 755 756 std::vector<StdString> dims; 757 758 if (grid->isCompressible()) 759 { 760 StdString varId = grid->getId() + "_points"; 761 762 int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes(); 763 SuperClassWriter::addDimension(varId, nbIndexes); 764 765 dims.push_back(varId); 766 SuperClassWriter::addVariable(varId, NC_INT, dims); 767 768 StdOStringStream compress; 769 for (int i = numElement - 1; i >= 0; --i) 770 { 771 if (axisDomainOrder(i)) 772 { 773 CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]); 774 StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId(); 775 StdString appendDomId = singleDomain ? "" : "_" + domId; 776 777 switch (domain->type) 778 { 779 case CDomain::type_attr::curvilinear: 780 compress << "y" << appendDomId << " x" << appendDomId; 781 break; 782 case CDomain::type_attr::rectilinear: 783 compress << "lat" << appendDomId << " lon" << appendDomId; 784 break; 785 case CDomain::type_attr::unstructured: 786 compress << "cell" << appendDomId; 787 break; 788 } 789 ++idxDomain; 790 } 791 else 792 { 793 CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]); 794 compress << (!axis->name.isEmpty() ? axis->name.getValue() : axis->getId()); 795 ++idxAxis; 796 } 797 798 if (i != 0) compress << ' '; 799 } 800 SuperClassWriter::addAttribute("compress", compress.str(), &varId); 801 802 grid->computeCompressedIndex(); 803 804 CArray<int, 1> indexes(grid->getNumberWrittenIndexes()); 805 std::map<int, CArray<size_t, 1> >::const_iterator it; 806 for (it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 807 { 808 const CArray<size_t, 1> compressedIndexes = grid->compressedOutIndexFromClient[it->first]; 809 for (int i = 0; i < it->second.numElements(); i++) 810 indexes(compressedIndexes(i)) = it->second(i); 811 } 812 813 switch (SuperClass::type) 814 { 815 case (MULTI_FILE): 816 { 817 SuperClassWriter::writeData(indexes, varId, isCollective, 0); 818 break; 819 } 820 case (ONE_FILE): 821 { 822 if (grid->doGridHaveDataDistributed()) 823 grid->getDistributionServer()->computeGlobalIndex(indexes); 824 825 std::vector<StdSize> start, count; 826 start.push_back(grid->getOffsetWrittenIndexes()); 827 count.push_back(grid->getNumberWrittenIndexes()); 828 829 SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 830 break; 831 } 832 } 833 } 834 else 835 { 836 for (int i = 0; i < numElement; ++i) 837 { 838 StdString varId, compress; 839 CArray<int, 1> indexes; 840 bool isDistributed; 841 StdSize nbIndexes, totalNbIndexes, offset; 842 int firstGlobalIndex; 843 844 if (axisDomainOrder(i)) 845 { 846 CDomain* domain = CDomain::get(domainList[idxDomain]); 847 if (!domain->isCompressible() 848 || domain->type == CDomain::type_attr::unstructured 849 || domain->isWrittenCompressed(this->filename)) 850 continue; 851 852 StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId(); 853 StdString appendDomId = singleDomain ? "" : "_" + domId; 854 855 varId = domId + "_points"; 856 switch (domain->type) 857 { 858 case CDomain::type_attr::curvilinear: 859 compress = "y" + appendDomId + " x" + appendDomId; 860 break; 861 case CDomain::type_attr::rectilinear: 862 compress = "lat" + appendDomId + " lon" + appendDomId; 863 break; 864 } 865 866 const std::vector<int>& indexesToWrite = domain->getIndexesToWrite(); 867 indexes.resize(indexesToWrite.size()); 868 for (int n = 0; n < indexes.numElements(); ++n) 869 indexes(n) = indexesToWrite[n]; 870 871 isDistributed = domain->isDistributed(); 872 nbIndexes = domain->getNumberWrittenIndexes(); 873 totalNbIndexes = domain->getTotalNumberWrittenIndexes(); 874 offset = domain->getOffsetWrittenIndexes(); 875 firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; 876 877 domain->addRelFileCompressed(this->filename); 878 ++idxDomain; 879 } 880 else 881 { 882 CAxis* axis = CAxis::get(axisList[idxAxis]); 883 if (!axis->isCompressible() || axis->isWrittenCompressed(this->filename)) 884 continue; 885 886 StdString axisId = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId(); 887 varId = axisId + "_points"; 888 compress = axisId; 889 890 const std::vector<int>& indexesToWrite = axis->getIndexesToWrite(); 891 indexes.resize(indexesToWrite.size()); 892 for (int n = 0; n < indexes.numElements(); ++n) 893 indexes(n) = indexesToWrite[n]; 894 895 isDistributed = axis->isDistributed(); 896 nbIndexes = axis->getNumberWrittenIndexes(); 897 totalNbIndexes = axis->getTotalNumberWrittenIndexes(); 898 offset = axis->getOffsetWrittenIndexes(); 899 firstGlobalIndex = axis->begin; 900 901 axis->addRelFileCompressed(this->filename); 902 ++idxAxis; 903 } 904 905 if (!varId.empty()) 906 { 907 SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); 908 909 dims.clear(); 910 dims.push_back(varId); 911 SuperClassWriter::addVariable(varId, NC_INT, dims); 912 913 SuperClassWriter::addAttribute("compress", compress, &varId); 914 915 switch (SuperClass::type) 916 { 917 case (MULTI_FILE): 918 { 919 indexes -= firstGlobalIndex; 920 SuperClassWriter::writeData(indexes, varId, isCollective, 0); 921 break; 922 } 923 case (ONE_FILE): 924 { 925 std::vector<StdSize> start, count; 926 start.push_back(offset); 927 count.push_back(nbIndexes); 928 929 SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); 930 break; 931 } 932 } 933 } 934 } 935 936 if (!dims.empty()) 937 grid->computeCompressedIndex(); 938 } 939 940 grid->addRelFileCompressed(this->filename); 941 } 942 catch (CNetCdfException& e) 943 { 944 StdString msg("On writing compressed grid : "); 945 msg.append(grid->getId()); msg.append("\n"); 946 msg.append("In the context : "); 947 CContext* context = CContext::getCurrent(); 948 msg.append(context->getId()); msg.append("\n"); 949 msg.append(e.what()); 950 ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); 951 } 952 } 953 954 //-------------------------------------------------------------- 955 743 956 void CNc4DataOutput::writeTimeDimension_(void) 744 957 { … … 757 970 } 758 971 } 972 759 973 //-------------------------------------------------------------- 760 974 … … 779 993 bool hasArea = false; 780 994 StdString cellMeasures = "area:"; 995 bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; 781 996 782 997 for (int i = 0; i < numElement; ++i) … … 785 1000 { 786 1001 CDomain* domain = CDomain::get(domainList[idxDomain]); 787 StdString domid = (!domain->name.isEmpty()) 788 ? domain->name.getValue() : domain->getId(); 789 StdString appendDomid = (singleDomain) ? "" : "_"+domid ; 1002 StdString domId = !domain->name.isEmpty() ? domain->name.getValue() : domain->getId(); 1003 StdString appendDomId = singleDomain ? "" : "_" + domId ; 1004 1005 if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured) 1006 { 1007 dimIdList.push_back(domId + "_points"); 1008 field->setUseCompressedOutput(); 1009 } 1010 790 1011 switch (domain->type) 791 1012 { 792 case CDomain::type_attr::curvilinear : 793 dimXid = StdString("x").append(appendDomid); 1013 case CDomain::type_attr::curvilinear: 1014 if (!compressedOutput || !domain->isCompressible()) 1015 { 1016 dimXid = StdString("x").append(appendDomId); 1017 dimIdList.push_back(dimXid); 1018 dimYid = StdString("y").append(appendDomId); 1019 dimIdList.push_back(dimYid); 1020 } 1021 dimCoordList.push_back(StdString("nav_lon").append(appendDomId)); 1022 dimCoordList.push_back(StdString("nav_lat").append(appendDomId)); 1023 break ; 1024 case CDomain::type_attr::rectilinear: 1025 if (!compressedOutput || !domain->isCompressible()) 1026 { 1027 dimXid = StdString("lon").append(appendDomId); 1028 dimIdList.push_back(dimXid); 1029 dimYid = StdString("lat").append(appendDomId); 1030 dimIdList.push_back(dimYid); 1031 } 1032 break ; 1033 case CDomain::type_attr::unstructured: 1034 dimXid = StdString("cell").append(appendDomId); 794 1035 dimIdList.push_back(dimXid); 795 dimYid = StdString("y").append(appendDomid); 796 dimIdList.push_back(dimYid); 797 dimCoordList.push_back(StdString("nav_lon").append(appendDomid)); 798 dimCoordList.push_back(StdString("nav_lat").append(appendDomid)); 1036 dimCoordList.push_back(StdString("lon").append(appendDomId)); 1037 dimCoordList.push_back(StdString("lat").append(appendDomId)); 799 1038 break ; 800 case CDomain::type_attr::rectilinear : 801 dimXid = StdString("lon").append(appendDomid); 802 dimIdList.push_back(dimXid); 803 dimYid = StdString("lat").append(appendDomid); 804 dimIdList.push_back(dimYid); 805 break ; 806 case CDomain::type_attr::unstructured : 807 dimXid = StdString("cell").append(appendDomid); 808 dimIdList.push_back(dimXid); 809 dimCoordList.push_back(StdString("lon").append(appendDomid)); 810 dimCoordList.push_back(StdString("lat").append(appendDomid)); 811 break ; 812 } 813 if (domain->hasArea) 814 { 815 hasArea = true; 816 cellMeasures += " area" + appendDomid; 817 } 818 ++idxDomain; 1039 } 1040 if (domain->hasArea) 1041 { 1042 hasArea = true; 1043 cellMeasures += " area" + appendDomId; 1044 } 1045 ++idxDomain; 819 1046 } 820 1047 else 821 1048 { 822 1049 CAxis* axis = CAxis::get(axisList[idxAxis]); 823 StdString axisid = (!axis->name.isEmpty()) 824 ? axis->name.getValue() : axis->getId(); 825 dimIdList.push_back(axisid); 826 dimCoordList.push_back(axisid); 827 ++idxAxis; 1050 StdString axisId = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId(); 1051 1052 if (compressedOutput && axis->isCompressible()) 1053 { 1054 dimIdList.push_back(axisId + "_points"); 1055 field->setUseCompressedOutput(); 1056 } 1057 else 1058 dimIdList.push_back(axisId); 1059 1060 dimCoordList.push_back(axisId); 1061 ++idxAxis; 828 1062 } 829 1063 } … … 867 1101 } 868 1102 869 while (!dimIdList.empty()) 870 { 871 dims.push_back(dimIdList.back()); 872 dimIdList.pop_back(); 1103 if (compressedOutput && grid->isCompressible()) 1104 { 1105 dims.push_back(grid->getId() + "_points"); 1106 field->setUseCompressedOutput(); 1107 } 1108 else 1109 { 1110 while (!dimIdList.empty()) 1111 { 1112 dims.push_back(dimIdList.back()); 1113 dimIdList.pop_back(); 1114 } 873 1115 } 874 1116 … … 1211 1453 try 1212 1454 { 1213 CArray<double,1> fieldData(grid->getWrittenDataSize()); 1455 size_t writtenSize; 1456 if (field->getUseCompressedOutput()) 1457 writtenSize = grid->getNumberWrittenIndexes(); 1458 else 1459 writtenSize = grid->getWrittenDataSize(); 1460 1461 CArray<double,1> fieldData(writtenSize); 1214 1462 if (!field->default_value.isEmpty()) fieldData = field->default_value; 1215 field->outputField(fieldData); 1463 1464 if (field->getUseCompressedOutput()) 1465 field->outputCompressedField(fieldData); 1466 else 1467 field->outputField(fieldData); 1468 1216 1469 if (!field->prec.isEmpty() && field->prec==2) fieldData=round(fieldData) ; 1217 1470 … … 1232 1485 case (ONE_FILE) : 1233 1486 { 1234 std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 1235 std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); 1236 std::vector<int> nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer(); 1237 1238 int ssize = nZoomBeginGlobal.size(); 1239 1240 std::vector<StdSize> start(ssize) ; 1241 std::vector<StdSize> count(ssize) ; 1242 1243 for (int i = 0; i < ssize; ++i) 1487 const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 1488 const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); 1489 const std::vector<int>& nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer(); 1490 1491 std::vector<StdSize> start, count; 1492 1493 if (field->getUseCompressedOutput()) 1244 1494 { 1245 start[i] = nZoomBeginServer[ssize-i-1] - nZoomBeginGlobal[ssize-i-1]; 1246 count[i] = nZoomSizeServer[ssize-i-1]; 1495 if (grid->isCompressible()) 1496 { 1497 start.push_back(grid->getOffsetWrittenIndexes()); 1498 count.push_back(grid->getNumberWrittenIndexes()); 1499 } 1500 else 1501 { 1502 CArray<bool,1> axisDomainOrder = grid->axis_domain_order; 1503 std::vector<StdString> domainList = grid->getDomainList(); 1504 std::vector<StdString> axisList = grid->getAxisList(); 1505 int numElement = axisDomainOrder.numElements(); 1506 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 1507 int idx = nZoomBeginGlobal.size() - 1; 1508 1509 start.reserve(nZoomBeginGlobal.size()); 1510 count.reserve(nZoomBeginGlobal.size()); 1511 1512 1513 for (int i = numElement - 1; i >= 0; --i) 1514 { 1515 if (axisDomainOrder(i)) 1516 { 1517 CDomain* domain = CDomain::get(domainList[idxDomain]); 1518 1519 if (domain->isCompressible()) 1520 { 1521 start.push_back(domain->getOffsetWrittenIndexes()); 1522 count.push_back(domain->getNumberWrittenIndexes()); 1523 } 1524 else 1525 { 1526 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 1527 count.push_back(nZoomSizeServer[idx]); 1528 start.push_back(nZoomBeginServer[idx - 1] - nZoomBeginGlobal[idx - 1]); 1529 count.push_back(nZoomSizeServer[idx - 1]); 1530 } 1531 1532 --idxDomain; 1533 idx -= 2; 1534 } 1535 else 1536 { 1537 CAxis* axis = CAxis::get(axisList[idxAxis]); 1538 1539 if (axis->isCompressible()) 1540 { 1541 start.push_back(axis->getOffsetWrittenIndexes()); 1542 count.push_back(axis->getNumberWrittenIndexes()); 1543 } 1544 else 1545 { 1546 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 1547 count.push_back(nZoomSizeServer[idx]); 1548 } 1549 1550 --idxAxis; 1551 --idx; 1552 } 1553 } 1554 } 1247 1555 } 1248 1249 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep()-1,&start,&count ); 1556 else 1557 { 1558 int ssize = nZoomBeginGlobal.size(); 1559 1560 start.resize(ssize); 1561 count.resize(ssize); 1562 1563 for (int i = 0; i < ssize; ++i) 1564 { 1565 start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1]; 1566 count[i] = nZoomSizeServer[ssize - i - 1]; 1567 } 1568 } 1569 1570 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1, &start, &count); 1250 1571 if (wtime) 1251 1572 { 1252 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() -1,isRoot);1253 SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep() -1,isRoot);1254 SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() -1, isRoot);1255 SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() -1, isRoot);1573 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 1574 SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep() - 1, isRoot); 1575 SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); 1576 SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); 1256 1577 } 1257 1578 -
XIOS/trunk/src/output/nc4_data_output.hpp
r628 r676 41 41 42 42 /// Ecriture /// 43 virtual void writeDomain_ (CDomain* domain); 44 virtual void writeAxis_ (CAxis* axis); 43 virtual void writeDomain_ (CDomain* domain); 44 virtual void writeAxis_ (CAxis* axis); 45 virtual void writeGridCompressed_(CGrid* grid); 45 46 virtual void writeTimeDimension_(void); 46 virtual void writeField_ 47 virtual void writeAttribute_ 48 virtual void writeAttribute_ 49 virtual void writeFieldData_ 50 virtual void writeFile_ 51 virtual void closeFile_ 47 virtual void writeField_ (CField* field); 48 virtual void writeAttribute_(CVariable* var); 49 virtual void writeAttribute_(CVariable* var, const string& fieldId); 50 virtual void writeFieldData_(CField* field); 51 virtual void writeFile_ (CFile* file); 52 virtual void closeFile_ (void); 52 53 virtual void syncFile_ (void); 53 virtual void writeTimeAxis_ 54 54 virtual void writeTimeAxis_ (CField* field, 55 const boost::shared_ptr<CCalendar> cal); 55 56 56 57 protected : -
XIOS/trunk/src/output/onetcdf4_decl.cpp
r501 r676 9 9 const std::vector<StdSize> * count) ; 10 10 11 macro(double,1) 12 macro(double,2) 13 macro(double,3) 11 macro(int, 1) 12 macro(double, 1) 13 macro(double, 2) 14 macro(double, 3) 14 15 15 16 template void CONetCDF4::setDefaultValue<double>(const StdString & varname, const double* value) ;
Note: See TracChangeset
for help on using the changeset viewer.