Changeset 676


Ignore:
Timestamp:
08/25/15 16:52:45 (9 years ago)
Author:
rlacroix
Message:

Add support for indexed output.

If the new field attribute "indexed_output" is set to true and a mask is defined (either at grid, domain or axis level), the indexed data will be outputed instead of the full data with missing values.

See http://cfconventions.org/Data/cf-conventions/cf-conventions-1.5/build/cf-conventions.html#compression-by-gathering for more information.

Location:
XIOS/trunk/src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/field_attribute.conf

    r606 r676  
    1414DECLARE_ATTRIBUTE(bool,      enabled) 
    1515DECLARE_ATTRIBUTE(bool,      read_access) 
     16DECLARE_ATTRIBUTE(bool,      indexed_output) 
    1617 
    1718DECLARE_ATTRIBUTE(StdString, domain_ref) 
  • XIOS/trunk/src/data_output.cpp

    r540 r676  
    1414      //---------------------------------------------------------------- 
    1515 
    16       void CDataOutput::writeGrid(CGrid* grid) 
     16      void CDataOutput::writeGrid(CGrid* grid, bool allowCompressedOutput /*= false*/) 
    1717      { 
    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 //         else 
    27 //         { 
    28 //            this->writeGrid(CDomain::get(grid->domain_ref.getValue()), 
    29 //                            CAxis::get(grid->axis_ref.getValue())); 
    30 //         } 
    31 //        this->writeGrid(grid->domain, grid->axis); 
    3218        this->writeGrid(grid->getDomains(), grid->getAxis()); 
     19 
     20        if (allowCompressedOutput) 
     21          writeGridCompressed_(grid); 
    3322      } 
    3423 
     
    5746      //---------------------------------------------------------------- 
    5847 
    59       void CDataOutput::writeGrid(CDomain* domain,CAxis* axis) 
     48      void CDataOutput::writeGrid(CDomain* domain, CAxis* axis) 
    6049      { 
    6150         this->writeDomain_(domain); 
     
    9887      void CDataOutput::writeFieldGrid(CField* field) 
    9988      { 
    100          this->writeGrid(field->getRelGrid()); 
     89         this->writeGrid(field->getRelGrid(), 
     90                         !field->indexed_output.isEmpty() && field->indexed_output); 
    10191      } 
    10292 
  • XIOS/trunk/src/data_output.hpp

    r591 r676  
    2020 
    2121            /// Ecriture /// 
    22             void writeFile     (CFile*  file); 
    23             void writeAttribute(CVariable*  var); 
    24             void syncFile     (void); 
     22            void writeFile     (CFile*     file); 
     23            void writeAttribute(CVariable* var); 
     24            void syncFile      (void); 
    2525            void closeFile     (void); 
    2626            void writeField    (CField* field); 
     
    4040 
    4141            /// 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); 
    4544            void writeGrid(CDomain* domain); 
    4645            void writeGrid(std::vector<CDomain*> domain, std::vector<CAxis*> axis); 
    4746 
    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; 
    5959 
    6060            /// Propriétés protégées /// 
  • XIOS/trunk/src/distribution_client.hpp

    r668 r676  
    4646    bool isDataDistributed() { return isDataDistributed_; } 
    4747 
     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 
    4853  protected: 
    4954    void createGlobalIndex(); 
     
    6166    //! Create local index of an axis 
    6267    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); 
    6868 
    6969    template<int N> 
  • XIOS/trunk/src/distribution_server.cpp

    r668 r676  
    146146} 
    147147 
     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*/ 
     153void 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} 
    148160 
    149 std::vector<int> CDistributionServer::getZoomBeginGlobal() const 
     161 
     162const std::vector<int>& CDistributionServer::getZoomBeginGlobal() const 
    150163{ 
    151164  return nZoomBeginGlobal_; 
    152165} 
    153166 
    154 std::vector<int> CDistributionServer::getZoomBeginServer() const 
     167const std::vector<int>& CDistributionServer::getZoomBeginServer() const 
    155168{ 
    156169  return nZoomBegin_; 
    157170} 
    158171 
    159 std::vector<int> CDistributionServer::getZoomSizeServer() const 
     172const std::vector<int>& CDistributionServer::getZoomSizeServer() const 
    160173{ 
    161174  return nZoomSize_; 
  • XIOS/trunk/src/distribution_server.hpp

    r653 r676  
    3434    virtual ~CDistributionServer(); 
    3535 
    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; 
    3939 
    4040    virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); 
    4141    virtual void computeLocalIndex(CArray<size_t,1>& globalIndex); 
     42    virtual void computeGlobalIndex(CArray<int,1>& indexes) const; 
    4243 
    4344  protected: 
  • XIOS/trunk/src/interface/c_attr/icfield_attr.cpp

    r608 r676  
    313313 
    314314 
     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 
    315338  void cxios_set_field_level(field_Ptr field_hdl, int level) 
    316339  { 
  • XIOS/trunk/src/interface/c_attr/icfieldgroup_attr.cpp

    r608 r676  
    339339 
    340340 
     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 
    341364  void cxios_set_fieldgroup_level(fieldgroup_Ptr fieldgroup_hdl, int level) 
    342365  { 
  • XIOS/trunk/src/interface/fortran_attr/field_interface_attr.F90

    r608 r676  
    231231 
    232232 
     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 
    233252    SUBROUTINE cxios_set_field_level(field_hdl, level) BIND(C) 
    234253      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/fieldgroup_interface_attr.F90

    r608 r676  
    252252 
    253253 
     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 
    254273    SUBROUTINE cxios_set_fieldgroup_level(fieldgroup_hdl, level) BIND(C) 
    255274      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/ifield_attr.F90

    r608 r676  
    1313  SUBROUTINE xios(set_field_attr)  & 
    1414    ( 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 ) 
    1717 
    1818    IMPLICIT NONE 
     
    3232      TYPE(txios(duration))  , OPTIONAL, INTENT(IN) :: freq_op 
    3333      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 
     34      LOGICAL  , OPTIONAL, INTENT(IN) :: indexed_output 
     35      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    3436      INTEGER  , OPTIONAL, INTENT(IN) :: level 
    3537      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name 
     
    4850      CALL xios(set_field_attr_hdl_)   & 
    4951      ( 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 ) 
    5254 
    5355  END SUBROUTINE xios(set_field_attr) 
     
    5557  SUBROUTINE xios(set_field_attr_hdl)  & 
    5658    ( 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 ) 
    5961 
    6062    IMPLICIT NONE 
     
    7375      TYPE(txios(duration))  , OPTIONAL, INTENT(IN) :: freq_op 
    7476      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 
     77      LOGICAL  , OPTIONAL, INTENT(IN) :: indexed_output 
     78      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    7579      INTEGER  , OPTIONAL, INTENT(IN) :: level 
    7680      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name 
     
    8892      CALL xios(set_field_attr_hdl_)  & 
    8993      ( 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 ) 
    9296 
    9397  END SUBROUTINE xios(set_field_attr_hdl) 
     
    9599  SUBROUTINE xios(set_field_attr_hdl_)   & 
    96100    ( 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_ ) 
    100104 
    101105    IMPLICIT NONE 
     
    114118      TYPE(txios(duration))  , OPTIONAL, INTENT(IN) :: freq_op_ 
    115119      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref_ 
     120      LOGICAL  , OPTIONAL, INTENT(IN) :: indexed_output_ 
     121      LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 
    116122      INTEGER  , OPTIONAL, INTENT(IN) :: level_ 
    117123      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name_ 
     
    173179      ENDIF 
    174180 
     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 
    175186      IF (PRESENT(level_)) THEN 
    176187        CALL cxios_set_field_level(field_hdl%daddr, level_) 
     
    222233  SUBROUTINE xios(get_field_attr)  & 
    223234    ( 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 ) 
    226237 
    227238    IMPLICIT NONE 
     
    241252      TYPE(txios(duration))  , OPTIONAL, INTENT(OUT) :: freq_op 
    242253      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 
     254      LOGICAL  , OPTIONAL, INTENT(OUT) :: indexed_output 
     255      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    243256      INTEGER  , OPTIONAL, INTENT(OUT) :: level 
    244257      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name 
     
    257270      CALL xios(get_field_attr_hdl_)   & 
    258271      ( 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 ) 
    261274 
    262275  END SUBROUTINE xios(get_field_attr) 
     
    264277  SUBROUTINE xios(get_field_attr_hdl)  & 
    265278    ( 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 ) 
    268281 
    269282    IMPLICIT NONE 
     
    282295      TYPE(txios(duration))  , OPTIONAL, INTENT(OUT) :: freq_op 
    283296      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 
     297      LOGICAL  , OPTIONAL, INTENT(OUT) :: indexed_output 
     298      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    284299      INTEGER  , OPTIONAL, INTENT(OUT) :: level 
    285300      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name 
     
    297312      CALL xios(get_field_attr_hdl_)  & 
    298313      ( 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 ) 
    301316 
    302317  END SUBROUTINE xios(get_field_attr_hdl) 
     
    304319  SUBROUTINE xios(get_field_attr_hdl_)   & 
    305320    ( 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_ ) 
    309324 
    310325    IMPLICIT NONE 
     
    323338      TYPE(txios(duration))  , OPTIONAL, INTENT(OUT) :: freq_op_ 
    324339      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref_ 
     340      LOGICAL  , OPTIONAL, INTENT(OUT) :: indexed_output_ 
     341      LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 
    325342      INTEGER  , OPTIONAL, INTENT(OUT) :: level_ 
    326343      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name_ 
     
    382399      ENDIF 
    383400 
     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 
    384406      IF (PRESENT(level_)) THEN 
    385407        CALL cxios_get_field_level(field_hdl%daddr, level_) 
     
    431453  SUBROUTINE xios(is_defined_field_attr)  & 
    432454    ( 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 ) 
    435457 
    436458    IMPLICIT NONE 
     
    459481      LOGICAL, OPTIONAL, INTENT(OUT) :: grid_ref 
    460482      LOGICAL(KIND=C_BOOL) :: grid_ref_tmp 
     483      LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 
     484      LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 
    461485      LOGICAL, OPTIONAL, INTENT(OUT) :: level 
    462486      LOGICAL(KIND=C_BOOL) :: level_tmp 
     
    485509      CALL xios(is_defined_field_attr_hdl_)   & 
    486510      ( 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 ) 
    489513 
    490514  END SUBROUTINE xios(is_defined_field_attr) 
     
    492516  SUBROUTINE xios(is_defined_field_attr_hdl)  & 
    493517    ( 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 ) 
    496520 
    497521    IMPLICIT NONE 
     
    519543      LOGICAL, OPTIONAL, INTENT(OUT) :: grid_ref 
    520544      LOGICAL(KIND=C_BOOL) :: grid_ref_tmp 
     545      LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 
     546      LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 
    521547      LOGICAL, OPTIONAL, INTENT(OUT) :: level 
    522548      LOGICAL(KIND=C_BOOL) :: level_tmp 
     
    544570      CALL xios(is_defined_field_attr_hdl_)  & 
    545571      ( 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 ) 
    548574 
    549575  END SUBROUTINE xios(is_defined_field_attr_hdl) 
     
    551577  SUBROUTINE xios(is_defined_field_attr_hdl_)   & 
    552578    ( 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_ ) 
    556582 
    557583    IMPLICIT NONE 
     
    579605      LOGICAL, OPTIONAL, INTENT(OUT) :: grid_ref_ 
    580606      LOGICAL(KIND=C_BOOL) :: grid_ref__tmp 
     607      LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output_ 
     608      LOGICAL(KIND=C_BOOL) :: indexed_output__tmp 
    581609      LOGICAL, OPTIONAL, INTENT(OUT) :: level_ 
    582610      LOGICAL(KIND=C_BOOL) :: level__tmp 
     
    657685      ENDIF 
    658686 
     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 
    659692      IF (PRESENT(level_)) THEN 
    660693        level__tmp = cxios_is_defined_field_level(field_hdl%daddr) 
  • XIOS/trunk/src/interface/fortran_attr/ifieldgroup_attr.F90

    r608 r676  
    1313  SUBROUTINE xios(set_fieldgroup_attr)  & 
    1414    ( 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 ) 
    1818 
    1919    IMPLICIT NONE 
     
    3434      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 
    3535      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
     36      LOGICAL  , OPTIONAL, INTENT(IN) :: indexed_output 
     37      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    3638      INTEGER  , OPTIONAL, INTENT(IN) :: level 
    3739      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name 
     
    5052      CALL xios(set_fieldgroup_attr_hdl_)   & 
    5153      ( 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 ) 
    5557 
    5658  END SUBROUTINE xios(set_fieldgroup_attr) 
     
    5860  SUBROUTINE xios(set_fieldgroup_attr_hdl)  & 
    5961    ( 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 ) 
    6365 
    6466    IMPLICIT NONE 
     
    7880      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref 
    7981      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
     82      LOGICAL  , OPTIONAL, INTENT(IN) :: indexed_output 
     83      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    8084      INTEGER  , OPTIONAL, INTENT(IN) :: level 
    8185      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name 
     
    9397      CALL xios(set_fieldgroup_attr_hdl_)  & 
    9498      ( 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 ) 
    98102 
    99103  END SUBROUTINE xios(set_fieldgroup_attr_hdl) 
     
    101105  SUBROUTINE xios(set_fieldgroup_attr_hdl_)   & 
    102106    ( 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_ ) 
    106110 
    107111    IMPLICIT NONE 
     
    121125      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: grid_ref_ 
    122126      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref_ 
     127      LOGICAL  , OPTIONAL, INTENT(IN) :: indexed_output_ 
     128      LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 
    123129      INTEGER  , OPTIONAL, INTENT(IN) :: level_ 
    124130      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: long_name_ 
     
    184190      ENDIF 
    185191 
     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 
    186197      IF (PRESENT(level_)) THEN 
    187198        CALL cxios_set_fieldgroup_level(fieldgroup_hdl%daddr, level_) 
     
    233244  SUBROUTINE xios(get_fieldgroup_attr)  & 
    234245    ( 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 ) 
    238249 
    239250    IMPLICIT NONE 
     
    254265      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 
    255266      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
     267      LOGICAL  , OPTIONAL, INTENT(OUT) :: indexed_output 
     268      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    256269      INTEGER  , OPTIONAL, INTENT(OUT) :: level 
    257270      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name 
     
    270283      CALL xios(get_fieldgroup_attr_hdl_)   & 
    271284      ( 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 ) 
    275288 
    276289  END SUBROUTINE xios(get_fieldgroup_attr) 
     
    278291  SUBROUTINE xios(get_fieldgroup_attr_hdl)  & 
    279292    ( 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 ) 
    283296 
    284297    IMPLICIT NONE 
     
    298311      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref 
    299312      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
     313      LOGICAL  , OPTIONAL, INTENT(OUT) :: indexed_output 
     314      LOGICAL (KIND=C_BOOL) :: indexed_output_tmp 
    300315      INTEGER  , OPTIONAL, INTENT(OUT) :: level 
    301316      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name 
     
    313328      CALL xios(get_fieldgroup_attr_hdl_)  & 
    314329      ( 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 ) 
    318333 
    319334  END SUBROUTINE xios(get_fieldgroup_attr_hdl) 
     
    321336  SUBROUTINE xios(get_fieldgroup_attr_hdl_)   & 
    322337    ( 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_ ) 
    326341 
    327342    IMPLICIT NONE 
     
    341356      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: grid_ref_ 
    342357      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref_ 
     358      LOGICAL  , OPTIONAL, INTENT(OUT) :: indexed_output_ 
     359      LOGICAL (KIND=C_BOOL) :: indexed_output__tmp 
    343360      INTEGER  , OPTIONAL, INTENT(OUT) :: level_ 
    344361      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: long_name_ 
     
    404421      ENDIF 
    405422 
     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 
    406428      IF (PRESENT(level_)) THEN 
    407429        CALL cxios_get_fieldgroup_level(fieldgroup_hdl%daddr, level_) 
     
    453475  SUBROUTINE xios(is_defined_fieldgroup_attr)  & 
    454476    ( 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 ) 
    458480 
    459481    IMPLICIT NONE 
     
    484506      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 
    485507      LOGICAL(KIND=C_BOOL) :: group_ref_tmp 
     508      LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 
     509      LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 
    486510      LOGICAL, OPTIONAL, INTENT(OUT) :: level 
    487511      LOGICAL(KIND=C_BOOL) :: level_tmp 
     
    510534      CALL xios(is_defined_fieldgroup_attr_hdl_)   & 
    511535      ( 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 ) 
    515539 
    516540  END SUBROUTINE xios(is_defined_fieldgroup_attr) 
     
    518542  SUBROUTINE xios(is_defined_fieldgroup_attr_hdl)  & 
    519543    ( 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 ) 
    523547 
    524548    IMPLICIT NONE 
     
    548572      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 
    549573      LOGICAL(KIND=C_BOOL) :: group_ref_tmp 
     574      LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output 
     575      LOGICAL(KIND=C_BOOL) :: indexed_output_tmp 
    550576      LOGICAL, OPTIONAL, INTENT(OUT) :: level 
    551577      LOGICAL(KIND=C_BOOL) :: level_tmp 
     
    573599      CALL xios(is_defined_fieldgroup_attr_hdl_)  & 
    574600      ( 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 ) 
    578604 
    579605  END SUBROUTINE xios(is_defined_fieldgroup_attr_hdl) 
     
    581607  SUBROUTINE xios(is_defined_fieldgroup_attr_hdl_)   & 
    582608    ( 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_ ) 
    586612 
    587613    IMPLICIT NONE 
     
    611637      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref_ 
    612638      LOGICAL(KIND=C_BOOL) :: group_ref__tmp 
     639      LOGICAL, OPTIONAL, INTENT(OUT) :: indexed_output_ 
     640      LOGICAL(KIND=C_BOOL) :: indexed_output__tmp 
    613641      LOGICAL, OPTIONAL, INTENT(OUT) :: level_ 
    614642      LOGICAL(KIND=C_BOOL) :: level__tmp 
     
    694722      ENDIF 
    695723 
     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 
    696729      IF (PRESENT(level_)) THEN 
    697730        level__tmp = cxios_is_defined_fieldgroup_level(fieldgroup_hdl%daddr) 
  • XIOS/trunk/src/node/axis.cpp

    r670 r676  
    88#include "context.hpp" 
    99#include "context_client.hpp" 
     10#include "context_server.hpp" 
    1011#include "xios_spl.hpp" 
    1112#include "inverse_axis.hpp" 
     
    1415#include "server_distribution_description.hpp" 
    1516#include "client_server_mapping_distributed.hpp" 
     17#include "distribution_client.hpp" 
    1618 
    1719namespace xios { 
     
    2224      : CObjectTemplate<CAxis>() 
    2325      , 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) 
    2528      , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 
    2629   { 
     
    3033      : CObjectTemplate<CAxis>(id) 
    3134      , 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) 
    3337      , transformationMap_(), global_zoom_begin(0), global_zoom_size(0) 
    3438   { 
     
    5054   } 
    5155 
     56   bool CAxis::isWrittenCompressed(const StdString& filename) const 
     57   { 
     58      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
     59   } 
     60 
    5261   bool CAxis::isDistributed(void) const 
    5362   { 
     
    5564   } 
    5665 
     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 
    5776   void CAxis::addRelFile(const StdString & filename) 
    5877   { 
    5978      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_; 
    60118   } 
    61119 
     
    171229  } 
    172230 
     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  } 
    173236 
    174237  bool CAxis::dispatchEvent(CEventServer& event) 
     
    277340    } 
    278341 
     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 
    279358    std::vector<int> nGlobDomain(1); 
    280359    nGlobDomain[0] = n_glo.getValue(); 
     
    303382                                        iteVec = (globalAxisZoom).end(); 
    304383    indSrv_.clear(); 
     384    indWrittenSrv_.clear(); 
    305385    for (; it != ite; ++it) 
    306386    { 
     
    315395          indSrv_[rank].push_back(globalIndexTmp[i]); 
    316396        } 
     397 
     398        if (writtenInd.count(globalIndexTmp[i])) 
     399        { 
     400          indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
     401        } 
    317402      } 
    318403    } 
     
    337422    CContext* context = CContext::getCurrent(); 
    338423    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; 
    343428    for (size_t idx = 0; idx < n; ++idx) 
    344429    { 
    345430      size_t globalIndex = begin + idx; 
    346431      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      } 
    347448    } 
    348449 
     
    359460    } 
    360461 
     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 
    361482    if (client->isServerLeader()) 
    362483    { 
     
    366487      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    367488      { 
    368         // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
    369489        msgs.push_back(CMessage()); 
    370490        CMessage& msg = msgs.back(); 
    371491        msg << this->getId(); 
    372492        msg << val; 
    373         event.push(*itRank,1,msg); 
     493        if (isCompressible_) 
     494          msg << writtenInd; 
     495        event.push(*itRank, 1, msg); 
    374496      } 
    375497      client->sendEvent(event); 
     
    390512    list<CMessage> list_msgsIndex, list_msgsVal; 
    391513    list<CArray<int,1> > list_indi; 
     514    list<CArray<int,1> > list_writtenInd; 
    392515    list<CArray<double,1> > list_val; 
    393516    list<CArray<double,2> > list_bounds; 
     
    433556      list_msgsIndex.back() << this->getId() << list_indi.back(); 
    434557 
     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 
    435570      list_msgsVal.push_back(CMessage()); 
    436571      list_msgsVal.back() << this->getId() << list_val.back(); 
     
    451586  void CAxis::recvIndex(CEventServer& event) 
    452587  { 
     588    CAxis* axis; 
     589 
    453590    list<CEventServer::SSubEvent>::iterator it; 
    454591    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    455592    { 
    456593      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_; 
    460609    } 
    461610  } 
     
    464613  { 
    465614    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    } 
    466624  } 
    467625 
     
    472630    { 
    473631      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); 
    477635    } 
    478636  } 
     
    503661   void CAxis::recvNonDistributedValue(CEventServer& event) 
    504662  { 
     663    CAxis* axis; 
     664 
    505665    list<CEventServer::SSubEvent>::iterator it; 
    506666    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    507667    { 
    508668      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; 
    512681    } 
    513682  } 
     
    526695        bound_srv(1,ind) = bounds(1,ind); 
    527696      } 
     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)); 
    528706    } 
    529707  } 
     
    561739        msg << ni << begin << end; 
    562740        msg << global_zoom_begin << global_zoom_size; 
     741        msg << isCompressible_; 
    563742 
    564743        event.push(*itRank,1,msg); 
     
    581760    int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_size_tmp; 
    582761 
    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_; 
    584765    global_zoom_begin = global_zoom_begin_tmp; 
    585766    global_zoom_size  = global_zoom_size_tmp; 
  • XIOS/trunk/src/node/axis.hpp

    r633 r676  
    6767         const std::set<StdString> & getRelFiles(void) const; 
    6868 
     69         const std::vector<int>& getIndexesToWrite(void) const; 
     70         int getNumberWrittenIndexes() const; 
     71         int getTotalNumberWrittenIndexes() const; 
     72         int getOffsetWrittenIndexes() const; 
     73 
    6974         /// Test /// 
    7075         bool IsWritten(const StdString & filename) const; 
     76         bool isWrittenCompressed(const StdString& filename) const; 
    7177         bool isDistributed(void) const; 
     78         bool isCompressible(void) const; 
    7279 
    7380         /// Mutateur /// 
    7481         void addRelFile(const StdString & filename); 
     82         void addRelFileCompressed(const StdString& filename); 
    7583 
    7684         /// Vérifications /// 
     
    97105                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); 
    98106 
     107         void checkEligibilityForCompressedOutput(); 
     108 
    99109         bool hasTransformation(); 
    100110         void solveInheritanceTransformation(); 
     
    107117        CArray<double,1> value_srv; 
    108118        CArray<double,2> bound_srv; 
    109       private : 
     119 
     120      private: 
    110121         void checkData(); 
    111122         void checkMask(); 
     
    128139 
    129140         void setTransformations(const TransMapTypes&); 
     141 
    130142      private: 
    131143         bool isChecked; 
    132144         bool areClientAttributesChecked_; 
    133          std::set<StdString> relFiles; 
     145         std::set<StdString> relFiles, relFilesCompressed; 
    134146         TransMapTypes transformationMap_; 
    135147         bool isDistributed_; 
     148         //! True if and only if the data defined on the axis can be outputted in a compressed way 
     149         bool isCompressible_; 
    136150         std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 
    137151         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_; 
    138155         std::vector<int> connectedServerRank_; 
    139156         std::map<int, CArray<int,1> > indiSrv_; 
  • XIOS/trunk/src/node/context.cpp

    r655 r676  
    745745      // Find all inheritance in xml structure 
    746746      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(); 
    747751 
    748752      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
     
    851855   } 
    852856 
     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 
    853875   //! Client side: Send information of reference grid of active fields 
    854876   void CContext::sendRefGrid() 
  • XIOS/trunk/src/node/context.hpp

    r655 r676  
    109109         void updateCalendar(int step); 
    110110         void createFileHeader(void ); 
     111         void checkAxisDomainsGridsEligibilityForCompressedOutput(); 
    111112         void solveAllRefOfEnabledFields(bool sendToServer); 
    112113         void buildFilterGraphOfEnabledFields(); 
  • XIOS/trunk/src/node/domain.cpp

    r675 r676  
    1313#include "context.hpp" 
    1414#include "context_client.hpp" 
     15#include "context_server.hpp" 
    1516#include "array_new.hpp" 
     17#include "distribution_client.hpp" 
    1618#include "server_distribution_description.hpp" 
    1719#include "client_server_mapping_distributed.hpp" 
     
    1921#include "interpolate_from_file_domain.hpp" 
    2022 
     23#include <algorithm> 
     24 
    2125namespace xios { 
    2226 
     
    2630      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    2731      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    28       , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
     32      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 
    2933      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    3034      , isClientAfterTransformationChecked(false), hasLonLat(false) 
     
    3539      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    3640      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    37       , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
     41      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 
    3842      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    3943      , isClientAfterTransformationChecked(false), hasLonLat(false) 
     
    6468 
    6569   //---------------------------------------------------------------- 
     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 
    66105   bool CDomain::isEmpty(void) const 
    67106   { 
     
    71110 
    72111   //---------------------------------------------------------------- 
     112 
    73113   bool CDomain::IsWritten(const StdString & filename) const 
    74114   { 
     
    76116   } 
    77117 
     118   bool CDomain::isWrittenCompressed(const StdString& filename) const 
     119   { 
     120      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
     121   } 
     122 
    78123   //---------------------------------------------------------------- 
     124 
    79125   bool CDomain::isDistributed(void) const 
    80126   { 
     
    83129 
    84130   //---------------------------------------------------------------- 
     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 
    85144   void CDomain::addRelFile(const StdString & filename) 
    86145   { 
    87146      this->relFiles.insert(filename); 
     147   } 
     148 
     149   void CDomain::addRelFileCompressed(const StdString& filename) 
     150   { 
     151      this->relFilesCompressed.insert(filename); 
    88152   } 
    89153 
     
    246310   } 
    247311 
    248  
    249312   //---------------------------------------------------------------- 
     313 
    250314   void CDomain::checkDomainData(void) 
    251315   { 
     
    357421 
    358422   //---------------------------------------------------------------- 
     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 
    359432   void CDomain::completeLonLatClient(void) 
    360433   { 
     
    746819        msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 
    747820        msg << global_zoom_ni << global_zoom_ibegin << global_zoom_nj << global_zoom_jbegin; 
     821        msg << isCompressible_; 
    748822 
    749823        event.push(*itRank,1,msg); 
     
    783857      { 
    784858        ++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        } 
    785877      } 
    786878    } 
     
    809901    } 
    810902 
    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; 
    823937 
    824938    CServerDistributionDescription serverDescription(nGlobDomain_); 
     
    837951 
    838952    indSrv_.clear(); 
     953    indWrittenSrv_.clear(); 
    839954    for (; it != ite; ++it) 
    840955    { 
     
    853968        } 
    854969      } 
     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      } 
    855977    } 
    856978 
     
    8881010 
    8891011    list<CMessage> list_msgsIndex; 
    890     list<CArray<int,1> > list_indi, list_indj; 
     1012    list<CArray<int,1> > list_indi, list_indj, list_writtenInd; 
    8911013 
    8921014    std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     
    9181040      list_msgsIndex.back() << isCurvilinear; 
    9191041      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      } 
    9201054 
    9211055      eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
     
    11181252  { 
    11191253    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_; 
    11211256 
    11221257    int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; 
     
    11581293  void CDomain::recvIndex(CEventServer& event) 
    11591294  { 
     1295    CDomain* domain; 
     1296 
    11601297    list<CEventServer::SSubEvent>::iterator it; 
    11611298    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     
    11641301      string domainId; 
    11651302      *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_; 
    11671316    } 
    11681317  } 
     
    11781327    buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 
    11791328    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    } 
    11801338  } 
    11811339 
  • XIOS/trunk/src/node/domain.hpp

    r667 r676  
    4747         typedef CDomainAttributes SuperClassAttribute; 
    4848 
    49       public : 
     49      public: 
    5050 
    5151         typedef CDomainAttributes RelAttributes; 
     
    7070         void checkAttributesOnClientAfterTransformation(); 
    7171 
     72         void checkEligibilityForCompressedOutput(void); 
     73 
    7274         void sendCheckedAttributes(); 
    7375 
     
    7678         TransMapTypes getAllTransformations(); 
    7779 
    78       public : 
     80      public: 
    7981         const std::set<StdString> & getRelFiles(void) const; 
    8082         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 
    8190         bool isEmpty(void) const; 
    8291         bool isDistributed(void) const; 
    83  
     92         bool isCompressible(void) const; 
    8493 
    8594         int global_zoom_ibegin, global_zoom_ni; 
     
    104113        vector< vector<int> > j_indSrv ; // for each server, j global index to send 
    105114 
    106       public : 
     115      public: 
    107116         /// Mutateur /// 
    108117         void addRelFile(const StdString & filename); 
     118         void addRelFileCompressed(const StdString& filename); 
    109119         void completeLonLatClient(void); 
    110120         void sendServerAttribut(void) ; 
     
    159169         void sendLonLat(); 
    160170 
    161        private : 
     171       private: 
    162172         bool isChecked; 
    163          std::set<StdString> relFiles; 
     173         std::set<StdString> relFiles, relFilesCompressed; 
    164174         bool isClientChecked; // Verify whether all attributes of domain on the client side are good 
    165175         bool isClientAfterTransformationChecked; 
     
    167177         std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 
    168178         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_; 
    169182         std::vector<int> connectedServerRank_; 
    170183         bool isDistributed_; 
     184         //! True if and only if the data defined on the domain can be outputted in a compressed way 
     185         bool isCompressible_; 
    171186         TransMapTypes transformationMap_; 
    172187         std::vector<int> nGlobDomain_; 
  • XIOS/trunk/src/node/field.cpp

    r651 r676  
    3535      , hasOutputFile(false) 
    3636      , domAxisIds_("", ""), areAllReferenceSolved(false) 
     37      , useCompressedOutput(false) 
    3738      , isReadDataRequestPending(false) 
    3839   { setVirtualVariableGroup(); } 
     
    4546      , hasOutputFile(false) 
    4647      , domAxisIds_("", ""), areAllReferenceSolved(false) 
     48      , useCompressedOutput(false) 
    4749      , isReadDataRequestPending(false) 
    4850   { setVirtualVariableGroup(); } 
     
    455457   { 
    456458      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; 
    457471   } 
    458472 
     
    814828      for(it=data_srv.begin();it!=data_srv.end();it++) 
    815829      { 
    816          grid->outputField(it->first, it->second, fieldOut.dataFirst()) ; 
     830         grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
    817831      } 
    818832   } 
     
    824838      for (it = data_srv.begin(); it != data_srv.end(); it++) 
    825839      { 
    826          grid->outputField(it->first, it->second, fieldOut.dataFirst()) ; 
     840         grid->outputField(it->first, it->second, fieldOut.dataFirst()); 
    827841      } 
    828842   } 
     
    852866      { 
    853867         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()); 
    854878      } 
    855879   } 
  • XIOS/trunk/src/node/field.hpp

    r651 r676  
    9999         bool isActive(void) const; 
    100100         bool hasOutputFile; 
     101 
     102         bool getUseCompressedOutput() const; 
     103         void setUseCompressedOutput(); 
    101104 
    102105         /// Traitements /// 
     
    142145        void inputField(CArray<double,2>& fieldOut); 
    143146        void inputField(CArray<double,1>& fieldOut); 
     147        void outputCompressedField(CArray<double, 1>& fieldOut); 
    144148        void scaleFactorAddOffset(double scaleFactor, double addOffset); 
    145149        void invertScaleFactorAddOffset(double scaleFactor, double addOffset); 
     
    187191         std::pair<StdString,StdString> domAxisIds_; 
    188192         bool isReadDataRequestPending; 
     193         bool useCompressedOutput; 
    189194 
    190195         DECLARE_REF_FUNC(Field,field) 
  • XIOS/trunk/src/node/grid.cpp

    r671 r676  
    2525      : CObjectTemplate<CGrid>(), CGridAttributes() 
    2626      , 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) 
    3032      , axisPositionInGrid_(), positionDimensionDistributed_(1) 
    3133   { 
     
    3739      : CObjectTemplate<CGrid>(id), CGridAttributes() 
    3840      , 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) 
    4246      , axisPositionInGrid_(), positionDimensionDistributed_(1) 
    4347   { 
     
    149153   } 
    150154 
     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 
    151181   void CGrid::solveDomainAxisRef(bool areAttributesChecked) 
    152182   { 
     
    157187     computeGridGlobalDimension(getDomains(), getAxis(), axis_domain_order); 
    158188     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(); 
    159195   } 
    160196 
     
    488524   } 
    489525 
     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 
    490536   //---------------------------------------------------------------- 
    491537 
     
    518564    } 
    519565    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    } 
    520600  } 
    521601 
     
    547627 
    548628        listMsg.push_back(CMessage()); 
    549         listMsg.back() << getId( )<< isDataDistributed_ << listOutIndex.back(); 
     629        listMsg.back() << getId( )<< isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
    550630 
    551631        event.push(rank, 1, listMsg.back()); 
     
    589669 
    590670          listMsg.push_back(CMessage()); 
    591           listMsg.back() << getId() << isDataDistributed_ << listOutIndex.back(); 
     671          listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
    592672 
    593673          event.push(rank, 1, listMsg.back()); 
     
    650730 
    651731        listMsg.push_back(CMessage()); 
    652         listMsg.back() << getId() << isDataDistributed_ << listOutIndex.back(); 
     732        listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
    653733 
    654734        event.push(rank, nbSenders[rank], listMsg.back()); 
     
    741821  } 
    742822 
     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 
    743850  const CDistributionServer* CGrid::getDistributionServer() const 
    744851  { 
     
    762869    CContext* context = CContext::getCurrent(); 
    763870    CContextServer* server = context->server; 
     871    numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 
    764872 
    765873    for (int n = 0; n < ranks.size(); n++) 
     
    768876      CBufferIn& buffer = *buffers[n]; 
    769877 
    770       buffer >> isDataDistributed_; 
     878      buffer >> isDataDistributed_ >> isCompressible_; 
    771879      size_t dataSize = 0; 
    772880 
    773881      if (isScalarGrid()) 
    774882      { 
    775         writtenDataSize_ = 1; 
     883        writtenDataSize_ = numberWrittenIndexes_ = totalNumberWrittenIndexes_ = 1; 
    776884        CArray<size_t,1> outIndex; 
    777885        buffer >> outIndex; 
     
    849957      outIndexFromClient.insert(std::make_pair(rank, outIndex)); 
    850958      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_; 
    852970 
    853971    nbSenders = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
  • XIOS/trunk/src/node/grid.hpp

    r664 r676  
    4848         typedef CGridAttributes SuperClassAttribute; 
    4949 
    50       public : 
     50      public: 
    5151 
    5252         typedef CGridAttributes RelAttributes; 
     
    7272//         void solveReference(void); 
    7373 
     74         void checkEligibilityForCompressedOutput(); 
     75 
    7476         void solveDomainAxisRef(bool areAttributesChecked); 
    7577 
     
    7981//         virtual void fromBinary(StdIStream& is); 
    8082 
     83         void addRelFileCompressed(const StdString& filename); 
     84 
    8185         /// Tests /// 
    82          bool hasAxis(void) const; 
    83  
    84       public : 
     86         bool isCompressible(void) const; 
     87         bool isWrittenCompressed(const StdString& filename) const; 
     88 
     89      public: 
    8590 
    8691         /// Accesseurs /// 
     
    98103         void inputField(int rank, const double* const field, CArray<double,1>& stored); 
    99104 
     105         void outputCompressedField(int rank, const CArray<double,1>& stored, double* field); 
     106 
    100107         virtual void parse(xml::CXMLNode& node); 
    101108 
     
    103110         virtual ~CGrid(void); 
    104111 
    105       public : 
     112      public: 
    106113 
    107114         /// Accesseurs statiques /// 
     
    116123         static CGrid* createGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis, CArray<bool,1> axisDomainOrder = CArray<bool,1>()); 
    117124 
    118       public : 
     125      public: 
    119126 
    120127         /// Entrées-sorties de champs (interne) /// 
     
    126133         void computeIndex(void); 
    127134         void computeIndexScalarGrid(); 
     135         void computeCompressedIndex(); 
    128136 
    129137         void solveDomainRef(bool checkAtt); 
     
    163171         bool doGridHaveDataDistributed(); 
    164172         size_t getWrittenDataSize() const; 
     173         int getNumberWrittenIndexes() const; 
     174         int getTotalNumberWrittenIndexes() const; 
     175         int getOffsetWrittenIndexes() const; 
    165176 
    166177         const CDistributionServer* getDistributionServer() const; 
     
    184195         map<int,int> nbSenders; 
    185196 
    186          map<int, CArray<size_t, 1> > outIndexFromClient; 
     197         map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; 
    187198         void checkMask(void); 
    188199         void modifyMask(const CArray<int,1>& indexToModify); 
     
    221232 
    222233        std::vector<int> globalDim_; 
     234 
    223235      private: 
    224236        CDomainGroup* vDomainGroup_; 
     
    231243        CClientServerMapping* clientServerMap_; 
    232244        size_t writtenDataSize_; 
     245        int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
    233246        std::map<int,size_t> connectedDataSize_; 
    234247        std::vector<int> connectedServerRank_; 
    235248        bool isDataDistributed_; 
    236249        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; 
    237253 
    238254        bool isTransformed_; 
  • XIOS/trunk/src/output/nc4_data_output.cpp

    r665 r676  
    741741     } 
    742742 
     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 
    743956     void CNc4DataOutput::writeTimeDimension_(void) 
    744957     { 
     
    757970       } 
    758971     } 
     972 
    759973      //-------------------------------------------------------------- 
    760974 
     
    779993         bool hasArea = false; 
    780994         StdString cellMeasures = "area:"; 
     995         bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; 
    781996 
    782997         for (int i = 0; i < numElement; ++i) 
     
    7851000           { 
    7861001             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 
    7901011             switch (domain->type) 
    7911012             { 
    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); 
    7941035                 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)); 
    7991038                 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; 
    8191046           } 
    8201047           else 
    8211048           { 
    8221049             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; 
    8281062           } 
    8291063         } 
     
    8671101         } 
    8681102 
    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           } 
    8731115         } 
    8741116 
     
    12111453         try 
    12121454         { 
    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); 
    12141462           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 
    12161469           if (!field->prec.isEmpty() && field->prec==2) fieldData=round(fieldData) ; 
    12171470 
     
    12321485              case (ONE_FILE) : 
    12331486              { 
    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()) 
    12441494                { 
    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                  } 
    12471555                } 
    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); 
    12501571                if (wtime) 
    12511572                { 
    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); 
    12561577                } 
    12571578 
  • XIOS/trunk/src/output/nc4_data_output.hpp

    r628 r676  
    4141 
    4242            /// 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); 
    4546            virtual void writeTimeDimension_(void); 
    46             virtual void writeField_     (CField* field); 
    47             virtual void writeAttribute_ (CVariable* var); 
    48             virtual void writeAttribute_ (CVariable* var, const string& fieldId); 
    49             virtual void writeFieldData_ (CField* field); 
    50             virtual void writeFile_      (CFile* file); 
    51             virtual void closeFile_      (void); 
     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); 
    5253            virtual void syncFile_      (void); 
    53             virtual void writeTimeAxis_  (CField* field, 
    54                                           const boost::shared_ptr<CCalendar> cal); 
     54            virtual void writeTimeAxis_ (CField* field, 
     55                                         const boost::shared_ptr<CCalendar> cal); 
    5556 
    5657         protected : 
  • XIOS/trunk/src/output/onetcdf4_decl.cpp

    r501 r676  
    99                                               const std::vector<StdSize> * count) ; 
    1010  
    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) 
    1415  
    1516  template void CONetCDF4::setDefaultValue<double>(const StdString & varname, const double* value) ; 
Note: See TracChangeset for help on using the changeset viewer.