Changeset 567


Ignore:
Timestamp:
03/10/15 10:49:02 (9 years ago)
Author:
mhnguyen
Message:

Implementing a grid formed by only one axis or group of axis

+) Add several new attributes to axis. From now on, each axis can be distributed on client side
+) Modify mask of grid to make it more flexible to different dimension
+) Fix some bugs relating to calculation of local data index on client
+) Clean some redundant codes

Test
+) On Curie, only test_new_features.f90
+) Test cases:

  • Grid composed of: 1 domain and 1 axis, 3 axis, 1 axis
  • Mode: Attached and connected
  • No of client-server: 6-2(Connected), 2 (Attached)

+) All tests passed and results are correct

Location:
XIOS/trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/Version2/iodef.xml

    r553 r567  
    66 
    77 
    8    <field_definition level="1" enabled=".FALSE."> 
     8   <field_definition level="1" enabled=".TRUE."> 
    99<!--     <field id="field_A"  operation="average" freq_op="3600s" domain_ref="domain_A"  axis_ref="axis_A" />--> 
    1010     <field id="field_A"  operation="average" freq_op="3600s" grid_ref="grid_A" /> 
     11     <field id="field_Axis"  operation="average" freq_op="3600s" grid_ref="grid_Axis" /> 
     12     <field id="field_All_Axis" operation="average" freq_op="3600s" grid_ref="grid_All_Axis" /> 
    1113   </field_definition> 
    1214 
     
    1618        <field field_ref="field_A" /> 
    1719     </file> 
     20     <file id="output_Axis" name="output_Axis"> 
     21        <field field_ref="field_Axis" /> 
     22        <field field_ref="field_All_Axis" /> 
     23     </file> 
    1824   </file_definition> 
    1925 
    2026 
    2127   <axis_definition> 
    22      <axis id="axis_A" zoom_size="2" zoom_end="2"/> 
    23      <axis id="axis_B" zoom_size="2" zoom_end="3" /> 
     28     <axis id="axis_A" /> 
     29     <axis id="axis_B" /> 
     30     <axis id="axis_C" zoom_size="2" zoom_end="2" /> 
     31     <axis id="axis_D" zoom_size="2" zoom_end="3"/> 
    2432   </axis_definition> 
    2533 
     
    3240       <grid id="grid_A"> 
    3341         <domain domain_ref="domain_A" /> 
     42         <axis axis_ref="axis_C" /> 
     43       </grid> 
     44       <grid id="grid_Axis"> 
     45         <axis axis_ref="axis_D" /> 
     46       </grid> 
     47       <grid id="grid_All_Axis"> 
    3448         <axis axis_ref="axis_A" /> 
    35        <!--       <axis axis_ref="axis_A" />--> 
    36 <!--       <domain id="domain_A" />--> 
    37 <!--       <axis axis_ref="axis_B" />--> 
    38       <!--       <axis id="axis_A" />--> 
    39 <!--       <axis id="axis_B" />--> 
     49         <axis axis_ref="axis_B" /> 
     50         <axis axis_ref="axis_C" /> 
    4051       </grid> 
    4152     </grid_group> 
     
    5768        <variable_group id="buffer"> 
    5869            <variable id="optimal_buffer_size" type="string">performance</variable> 
    59             <variable id="buffer_factor_size" type="double">1.0</variable> 
     70            <variable id="buffer_factor_size" type="double">10.0</variable> 
    6071         </variable_group> 
    6172 
  • XIOS/trunk/src/attribute_array_decl.cpp

    r551 r567  
    1212  template class CAttributeArray<bool,2> ; 
    1313  template class CAttributeArray<bool,3> ; 
     14//  template class CAttributeArray<bool,4> ; 
     15//  template class CAttributeArray<bool,5> ; 
     16//  template class CAttributeArray<bool,6> ; 
     17//  template class CAttributeArray<bool,7> ; 
    1418} 
  • XIOS/trunk/src/client_server_mapping.cpp

    r554 r567  
    2626} 
    2727 
     28void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     29                                                     const CArray<int,1>& localIndexOnClient, 
     30                                                     const std::vector<CArray<size_t,1>* >& globalIndexOnServer) 
     31{ 
     32  defaultComputeServerIndexMapping(globalIndexOnClient, globalIndexOnServer, &localIndexOnClient); 
     33} 
     34 
    2835/*! 
    2936   Compute index of data which are sent to server and index global on server side 
     
    3239*/ 
    3340void CClientServerMapping::defaultComputeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    34                                                             const std::vector<CArray<size_t,1>* >& globalIndexServer) 
     41                                                            const std::vector<CArray<size_t,1>* >& globalIndexServer, 
     42                                                            const CArray<int,1>* localIndexOnClient) 
    3543{ 
    3644  int nServer = globalIndexServer.size(); 
     
    5260        // Just try to calculate local index server on client side 
    5361        (indexGlobalOnServer_[j]).push_back((globalIndexOnClient)(i)); 
    54         (localIndexSend2Server_[j]).push_back(i); 
     62        if (0 != localIndexOnClient) (localIndexSend2Server_[j]).push_back((*localIndexOnClient)(i)); 
     63        else 
     64          (localIndexSend2Server_[j]).push_back(i); 
    5565        continue; 
    5666      } 
  • XIOS/trunk/src/client_server_mapping.hpp

    r554 r567  
    3333                                           const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 
    3434 
     35    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     36                                           const CArray<int,1>& localIndexOnClient, 
     37                                           const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 
     38 
    3539    std::map<int,int> computeConnectedClients(int nbServer, int nbClient, 
    3640                                              MPI_Comm& clientIntraComm, 
     
    4246  protected: 
    4347    void defaultComputeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    44                                           const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 
     48                                          const std::vector<CArray<size_t,1>* >& globalIndexOnServer, 
     49                                          const CArray<int,1>* localIndexOnClient = 0); 
    4550 
    4651  private: 
  • XIOS/trunk/src/config/grid_attribute.conf

    r551 r567  
    11DECLARE_ATTRIBUTE(StdString, name) 
    22DECLARE_ATTRIBUTE(StdString, description) 
    3 //DECLARE_ATTRIBUTE(StdString, domain_ref) 
    4 //DECLARE_ATTRIBUTE(StdString, axis_ref) 
    5 DECLARE_ARRAY(bool, 3 , mask) 
     3 
     4DECLARE_ARRAY(bool, 1 , mask1) 
     5DECLARE_ARRAY(bool, 2 , mask2) 
     6DECLARE_ARRAY(bool, 3 , mask3) 
    67//DECLARE_ARRAY(bool, 4 , mask4) 
    78//DECLARE_ARRAY(bool, 5 , mask5) 
  • XIOS/trunk/src/interface/c_attr/icgrid_attr.cpp

    r555 r567  
    6969   
    7070   
    71   void cxios_set_grid_mask(grid_Ptr grid_hdl, bool* mask, int extent1, int extent2, int extent3) 
     71  void cxios_set_grid_mask1(grid_Ptr grid_hdl, bool* mask1, int extent1) 
    7272  { 
    7373    CTimer::get("XIOS").resume(); 
    74     CArray<bool,3> tmp(mask,shape(extent1,extent2,extent3),neverDeleteData) ; 
    75     grid_hdl->mask.reference(tmp.copy()); 
     74    CArray<bool,1> tmp(mask1,shape(extent1),neverDeleteData) ; 
     75    grid_hdl->mask1.reference(tmp.copy()); 
    7676     CTimer::get("XIOS").suspend(); 
    7777  } 
    7878   
    79   void cxios_get_grid_mask(grid_Ptr grid_hdl, bool* mask, int extent1, int extent2, int extent3) 
     79  void cxios_get_grid_mask1(grid_Ptr grid_hdl, bool* mask1, int extent1) 
    8080  { 
    8181    CTimer::get("XIOS").resume(); 
    82     CArray<bool,3> tmp(mask,shape(extent1,extent2,extent3),neverDeleteData) ; 
    83     tmp=grid_hdl->mask.getInheritedValue() ; 
     82    CArray<bool,1> tmp(mask1,shape(extent1),neverDeleteData) ; 
     83    tmp=grid_hdl->mask1.getInheritedValue() ; 
    8484     CTimer::get("XIOS").suspend(); 
    8585  } 
    8686   
    87   bool cxios_is_defined_grid_mask(grid_Ptr grid_hdl ) 
     87  bool cxios_is_defined_grid_mask1(grid_Ptr grid_hdl ) 
    8888  { 
    8989     CTimer::get("XIOS").resume(); 
    90     return grid_hdl->mask.hasInheritedValue(); 
     90    return grid_hdl->mask1.hasInheritedValue(); 
     91     CTimer::get("XIOS").suspend(); 
     92  } 
     93   
     94   
     95   
     96  void cxios_set_grid_mask2(grid_Ptr grid_hdl, bool* mask2, int extent1, int extent2) 
     97  { 
     98    CTimer::get("XIOS").resume(); 
     99    CArray<bool,2> tmp(mask2,shape(extent1,extent2),neverDeleteData) ; 
     100    grid_hdl->mask2.reference(tmp.copy()); 
     101     CTimer::get("XIOS").suspend(); 
     102  } 
     103   
     104  void cxios_get_grid_mask2(grid_Ptr grid_hdl, bool* mask2, int extent1, int extent2) 
     105  { 
     106    CTimer::get("XIOS").resume(); 
     107    CArray<bool,2> tmp(mask2,shape(extent1,extent2),neverDeleteData) ; 
     108    tmp=grid_hdl->mask2.getInheritedValue() ; 
     109     CTimer::get("XIOS").suspend(); 
     110  } 
     111   
     112  bool cxios_is_defined_grid_mask2(grid_Ptr grid_hdl ) 
     113  { 
     114     CTimer::get("XIOS").resume(); 
     115    return grid_hdl->mask2.hasInheritedValue(); 
     116     CTimer::get("XIOS").suspend(); 
     117  } 
     118   
     119   
     120   
     121  void cxios_set_grid_mask3(grid_Ptr grid_hdl, bool* mask3, int extent1, int extent2, int extent3) 
     122  { 
     123    CTimer::get("XIOS").resume(); 
     124    CArray<bool,3> tmp(mask3,shape(extent1,extent2,extent3),neverDeleteData) ; 
     125    grid_hdl->mask3.reference(tmp.copy()); 
     126     CTimer::get("XIOS").suspend(); 
     127  } 
     128   
     129  void cxios_get_grid_mask3(grid_Ptr grid_hdl, bool* mask3, int extent1, int extent2, int extent3) 
     130  { 
     131    CTimer::get("XIOS").resume(); 
     132    CArray<bool,3> tmp(mask3,shape(extent1,extent2,extent3),neverDeleteData) ; 
     133    tmp=grid_hdl->mask3.getInheritedValue() ; 
     134     CTimer::get("XIOS").suspend(); 
     135  } 
     136   
     137  bool cxios_is_defined_grid_mask3(grid_Ptr grid_hdl ) 
     138  { 
     139     CTimer::get("XIOS").resume(); 
     140    return grid_hdl->mask3.hasInheritedValue(); 
    91141     CTimer::get("XIOS").suspend(); 
    92142  } 
  • XIOS/trunk/src/interface/c_attr/icgridgroup_attr.cpp

    r555 r567  
    9595   
    9696   
    97   void cxios_set_gridgroup_mask(gridgroup_Ptr gridgroup_hdl, bool* mask, int extent1, int extent2, int extent3) 
     97  void cxios_set_gridgroup_mask1(gridgroup_Ptr gridgroup_hdl, bool* mask1, int extent1) 
    9898  { 
    9999    CTimer::get("XIOS").resume(); 
    100     CArray<bool,3> tmp(mask,shape(extent1,extent2,extent3),neverDeleteData) ; 
    101     gridgroup_hdl->mask.reference(tmp.copy()); 
     100    CArray<bool,1> tmp(mask1,shape(extent1),neverDeleteData) ; 
     101    gridgroup_hdl->mask1.reference(tmp.copy()); 
    102102     CTimer::get("XIOS").suspend(); 
    103103  } 
    104104   
    105   void cxios_get_gridgroup_mask(gridgroup_Ptr gridgroup_hdl, bool* mask, int extent1, int extent2, int extent3) 
     105  void cxios_get_gridgroup_mask1(gridgroup_Ptr gridgroup_hdl, bool* mask1, int extent1) 
    106106  { 
    107107    CTimer::get("XIOS").resume(); 
    108     CArray<bool,3> tmp(mask,shape(extent1,extent2,extent3),neverDeleteData) ; 
    109     tmp=gridgroup_hdl->mask.getInheritedValue() ; 
     108    CArray<bool,1> tmp(mask1,shape(extent1),neverDeleteData) ; 
     109    tmp=gridgroup_hdl->mask1.getInheritedValue() ; 
    110110     CTimer::get("XIOS").suspend(); 
    111111  } 
    112112   
    113   bool cxios_is_defined_gridgroup_mask(gridgroup_Ptr gridgroup_hdl ) 
     113  bool cxios_is_defined_gridgroup_mask1(gridgroup_Ptr gridgroup_hdl ) 
    114114  { 
    115115     CTimer::get("XIOS").resume(); 
    116     return gridgroup_hdl->mask.hasInheritedValue(); 
     116    return gridgroup_hdl->mask1.hasInheritedValue(); 
     117     CTimer::get("XIOS").suspend(); 
     118  } 
     119   
     120   
     121   
     122  void cxios_set_gridgroup_mask2(gridgroup_Ptr gridgroup_hdl, bool* mask2, int extent1, int extent2) 
     123  { 
     124    CTimer::get("XIOS").resume(); 
     125    CArray<bool,2> tmp(mask2,shape(extent1,extent2),neverDeleteData) ; 
     126    gridgroup_hdl->mask2.reference(tmp.copy()); 
     127     CTimer::get("XIOS").suspend(); 
     128  } 
     129   
     130  void cxios_get_gridgroup_mask2(gridgroup_Ptr gridgroup_hdl, bool* mask2, int extent1, int extent2) 
     131  { 
     132    CTimer::get("XIOS").resume(); 
     133    CArray<bool,2> tmp(mask2,shape(extent1,extent2),neverDeleteData) ; 
     134    tmp=gridgroup_hdl->mask2.getInheritedValue() ; 
     135     CTimer::get("XIOS").suspend(); 
     136  } 
     137   
     138  bool cxios_is_defined_gridgroup_mask2(gridgroup_Ptr gridgroup_hdl ) 
     139  { 
     140     CTimer::get("XIOS").resume(); 
     141    return gridgroup_hdl->mask2.hasInheritedValue(); 
     142     CTimer::get("XIOS").suspend(); 
     143  } 
     144   
     145   
     146   
     147  void cxios_set_gridgroup_mask3(gridgroup_Ptr gridgroup_hdl, bool* mask3, int extent1, int extent2, int extent3) 
     148  { 
     149    CTimer::get("XIOS").resume(); 
     150    CArray<bool,3> tmp(mask3,shape(extent1,extent2,extent3),neverDeleteData) ; 
     151    gridgroup_hdl->mask3.reference(tmp.copy()); 
     152     CTimer::get("XIOS").suspend(); 
     153  } 
     154   
     155  void cxios_get_gridgroup_mask3(gridgroup_Ptr gridgroup_hdl, bool* mask3, int extent1, int extent2, int extent3) 
     156  { 
     157    CTimer::get("XIOS").resume(); 
     158    CArray<bool,3> tmp(mask3,shape(extent1,extent2,extent3),neverDeleteData) ; 
     159    tmp=gridgroup_hdl->mask3.getInheritedValue() ; 
     160     CTimer::get("XIOS").suspend(); 
     161  } 
     162   
     163  bool cxios_is_defined_gridgroup_mask3(gridgroup_Ptr gridgroup_hdl ) 
     164  { 
     165     CTimer::get("XIOS").resume(); 
     166    return gridgroup_hdl->mask3.hasInheritedValue(); 
    117167     CTimer::get("XIOS").suspend(); 
    118168  } 
  • XIOS/trunk/src/interface/fortran_attr/grid_interface_attr.F90

    r555 r567  
    5252     
    5353     
    54     SUBROUTINE cxios_set_grid_mask(grid_hdl, mask, extent1, extent2, extent3) BIND(C) 
     54    SUBROUTINE cxios_set_grid_mask1(grid_hdl, mask1, extent1) BIND(C) 
    5555      USE ISO_C_BINDING 
    5656      INTEGER (kind = C_INTPTR_T), VALUE       :: grid_hdl 
    57       LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask 
     57      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask1 
     58      INTEGER (kind = C_INT), VALUE  :: extent1 
     59    END SUBROUTINE cxios_set_grid_mask1 
     60     
     61    SUBROUTINE cxios_get_grid_mask1(grid_hdl, mask1, extent1) BIND(C) 
     62      USE ISO_C_BINDING 
     63      INTEGER (kind = C_INTPTR_T), VALUE       :: grid_hdl 
     64      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask1 
     65      INTEGER (kind = C_INT), VALUE  :: extent1 
     66    END SUBROUTINE cxios_get_grid_mask1 
     67     
     68    FUNCTION cxios_is_defined_grid_mask1(grid_hdl ) BIND(C) 
     69      USE ISO_C_BINDING 
     70      LOGICAL(kind=C_BOOL) :: cxios_is_defined_grid_mask1 
     71      INTEGER (kind = C_INTPTR_T), VALUE :: grid_hdl 
     72    END FUNCTION cxios_is_defined_grid_mask1 
     73     
     74     
     75    SUBROUTINE cxios_set_grid_mask2(grid_hdl, mask2, extent1, extent2) BIND(C) 
     76      USE ISO_C_BINDING 
     77      INTEGER (kind = C_INTPTR_T), VALUE       :: grid_hdl 
     78      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask2 
     79      INTEGER (kind = C_INT), VALUE  :: extent1 
     80      INTEGER (kind = C_INT), VALUE  :: extent2 
     81    END SUBROUTINE cxios_set_grid_mask2 
     82     
     83    SUBROUTINE cxios_get_grid_mask2(grid_hdl, mask2, extent1, extent2) BIND(C) 
     84      USE ISO_C_BINDING 
     85      INTEGER (kind = C_INTPTR_T), VALUE       :: grid_hdl 
     86      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask2 
     87      INTEGER (kind = C_INT), VALUE  :: extent1 
     88      INTEGER (kind = C_INT), VALUE  :: extent2 
     89    END SUBROUTINE cxios_get_grid_mask2 
     90     
     91    FUNCTION cxios_is_defined_grid_mask2(grid_hdl ) BIND(C) 
     92      USE ISO_C_BINDING 
     93      LOGICAL(kind=C_BOOL) :: cxios_is_defined_grid_mask2 
     94      INTEGER (kind = C_INTPTR_T), VALUE :: grid_hdl 
     95    END FUNCTION cxios_is_defined_grid_mask2 
     96     
     97     
     98    SUBROUTINE cxios_set_grid_mask3(grid_hdl, mask3, extent1, extent2, extent3) BIND(C) 
     99      USE ISO_C_BINDING 
     100      INTEGER (kind = C_INTPTR_T), VALUE       :: grid_hdl 
     101      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask3 
    58102      INTEGER (kind = C_INT), VALUE  :: extent1 
    59103      INTEGER (kind = C_INT), VALUE  :: extent2 
    60104      INTEGER (kind = C_INT), VALUE  :: extent3 
    61     END SUBROUTINE cxios_set_grid_mask 
     105    END SUBROUTINE cxios_set_grid_mask3 
    62106     
    63     SUBROUTINE cxios_get_grid_mask(grid_hdl, mask, extent1, extent2, extent3) BIND(C) 
     107    SUBROUTINE cxios_get_grid_mask3(grid_hdl, mask3, extent1, extent2, extent3) BIND(C) 
    64108      USE ISO_C_BINDING 
    65109      INTEGER (kind = C_INTPTR_T), VALUE       :: grid_hdl 
    66       LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask 
     110      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask3 
    67111      INTEGER (kind = C_INT), VALUE  :: extent1 
    68112      INTEGER (kind = C_INT), VALUE  :: extent2 
    69113      INTEGER (kind = C_INT), VALUE  :: extent3 
    70     END SUBROUTINE cxios_get_grid_mask 
     114    END SUBROUTINE cxios_get_grid_mask3 
    71115     
    72     FUNCTION cxios_is_defined_grid_mask(grid_hdl ) BIND(C) 
     116    FUNCTION cxios_is_defined_grid_mask3(grid_hdl ) BIND(C) 
    73117      USE ISO_C_BINDING 
    74       LOGICAL(kind=C_BOOL) :: cxios_is_defined_grid_mask 
     118      LOGICAL(kind=C_BOOL) :: cxios_is_defined_grid_mask3 
    75119      INTEGER (kind = C_INTPTR_T), VALUE :: grid_hdl 
    76     END FUNCTION cxios_is_defined_grid_mask 
     120    END FUNCTION cxios_is_defined_grid_mask3 
    77121     
    78122     
  • XIOS/trunk/src/interface/fortran_attr/gridgroup_interface_attr.F90

    r555 r567  
    7373     
    7474     
    75     SUBROUTINE cxios_set_gridgroup_mask(gridgroup_hdl, mask, extent1, extent2, extent3) BIND(C) 
     75    SUBROUTINE cxios_set_gridgroup_mask1(gridgroup_hdl, mask1, extent1) BIND(C) 
    7676      USE ISO_C_BINDING 
    7777      INTEGER (kind = C_INTPTR_T), VALUE       :: gridgroup_hdl 
    78       LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask 
     78      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask1 
     79      INTEGER (kind = C_INT), VALUE  :: extent1 
     80    END SUBROUTINE cxios_set_gridgroup_mask1 
     81     
     82    SUBROUTINE cxios_get_gridgroup_mask1(gridgroup_hdl, mask1, extent1) BIND(C) 
     83      USE ISO_C_BINDING 
     84      INTEGER (kind = C_INTPTR_T), VALUE       :: gridgroup_hdl 
     85      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask1 
     86      INTEGER (kind = C_INT), VALUE  :: extent1 
     87    END SUBROUTINE cxios_get_gridgroup_mask1 
     88     
     89    FUNCTION cxios_is_defined_gridgroup_mask1(gridgroup_hdl ) BIND(C) 
     90      USE ISO_C_BINDING 
     91      LOGICAL(kind=C_BOOL) :: cxios_is_defined_gridgroup_mask1 
     92      INTEGER (kind = C_INTPTR_T), VALUE :: gridgroup_hdl 
     93    END FUNCTION cxios_is_defined_gridgroup_mask1 
     94     
     95     
     96    SUBROUTINE cxios_set_gridgroup_mask2(gridgroup_hdl, mask2, extent1, extent2) BIND(C) 
     97      USE ISO_C_BINDING 
     98      INTEGER (kind = C_INTPTR_T), VALUE       :: gridgroup_hdl 
     99      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask2 
     100      INTEGER (kind = C_INT), VALUE  :: extent1 
     101      INTEGER (kind = C_INT), VALUE  :: extent2 
     102    END SUBROUTINE cxios_set_gridgroup_mask2 
     103     
     104    SUBROUTINE cxios_get_gridgroup_mask2(gridgroup_hdl, mask2, extent1, extent2) BIND(C) 
     105      USE ISO_C_BINDING 
     106      INTEGER (kind = C_INTPTR_T), VALUE       :: gridgroup_hdl 
     107      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask2 
     108      INTEGER (kind = C_INT), VALUE  :: extent1 
     109      INTEGER (kind = C_INT), VALUE  :: extent2 
     110    END SUBROUTINE cxios_get_gridgroup_mask2 
     111     
     112    FUNCTION cxios_is_defined_gridgroup_mask2(gridgroup_hdl ) BIND(C) 
     113      USE ISO_C_BINDING 
     114      LOGICAL(kind=C_BOOL) :: cxios_is_defined_gridgroup_mask2 
     115      INTEGER (kind = C_INTPTR_T), VALUE :: gridgroup_hdl 
     116    END FUNCTION cxios_is_defined_gridgroup_mask2 
     117     
     118     
     119    SUBROUTINE cxios_set_gridgroup_mask3(gridgroup_hdl, mask3, extent1, extent2, extent3) BIND(C) 
     120      USE ISO_C_BINDING 
     121      INTEGER (kind = C_INTPTR_T), VALUE       :: gridgroup_hdl 
     122      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask3 
    79123      INTEGER (kind = C_INT), VALUE  :: extent1 
    80124      INTEGER (kind = C_INT), VALUE  :: extent2 
    81125      INTEGER (kind = C_INT), VALUE  :: extent3 
    82     END SUBROUTINE cxios_set_gridgroup_mask 
     126    END SUBROUTINE cxios_set_gridgroup_mask3 
    83127     
    84     SUBROUTINE cxios_get_gridgroup_mask(gridgroup_hdl, mask, extent1, extent2, extent3) BIND(C) 
     128    SUBROUTINE cxios_get_gridgroup_mask3(gridgroup_hdl, mask3, extent1, extent2, extent3) BIND(C) 
    85129      USE ISO_C_BINDING 
    86130      INTEGER (kind = C_INTPTR_T), VALUE       :: gridgroup_hdl 
    87       LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask 
     131      LOGICAL (KIND=C_BOOL)     , DIMENSION(*) :: mask3 
    88132      INTEGER (kind = C_INT), VALUE  :: extent1 
    89133      INTEGER (kind = C_INT), VALUE  :: extent2 
    90134      INTEGER (kind = C_INT), VALUE  :: extent3 
    91     END SUBROUTINE cxios_get_gridgroup_mask 
     135    END SUBROUTINE cxios_get_gridgroup_mask3 
    92136     
    93     FUNCTION cxios_is_defined_gridgroup_mask(gridgroup_hdl ) BIND(C) 
     137    FUNCTION cxios_is_defined_gridgroup_mask3(gridgroup_hdl ) BIND(C) 
    94138      USE ISO_C_BINDING 
    95       LOGICAL(kind=C_BOOL) :: cxios_is_defined_gridgroup_mask 
     139      LOGICAL(kind=C_BOOL) :: cxios_is_defined_gridgroup_mask3 
    96140      INTEGER (kind = C_INTPTR_T), VALUE :: gridgroup_hdl 
    97     END FUNCTION cxios_is_defined_gridgroup_mask 
     141    END FUNCTION cxios_is_defined_gridgroup_mask3 
    98142     
    99143     
  • XIOS/trunk/src/interface/fortran_attr/igrid_attr.F90

    r556 r567  
    1212   
    1313  SUBROUTINE xios(set_grid_attr)  & 
    14     ( grid_id, axisDomainOrder, description, mask, name ) 
     14    ( grid_id, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    1515     
    1616    IMPLICIT NONE 
     
    2020      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 
    2121      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    22       LOGICAL  , OPTIONAL, INTENT(IN) :: mask(:,:,:) 
    23       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     22      LOGICAL  , OPTIONAL, INTENT(IN) :: mask1(:) 
     23      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     24      LOGICAL  , OPTIONAL, INTENT(IN) :: mask2(:,:) 
     25      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     26      LOGICAL  , OPTIONAL, INTENT(IN) :: mask3(:,:,:) 
     27      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    2428      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    2529       
    2630      CALL xios(get_grid_handle)(grid_id,grid_hdl) 
    2731      CALL xios(set_grid_attr_hdl_)   & 
    28       ( grid_hdl, axisDomainOrder, description, mask, name ) 
     32      ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    2933     
    3034  END SUBROUTINE xios(set_grid_attr) 
    3135   
    3236  SUBROUTINE xios(set_grid_attr_hdl)  & 
    33     ( grid_hdl, axisDomainOrder, description, mask, name ) 
     37    ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    3438     
    3539    IMPLICIT NONE 
     
    3842      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 
    3943      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    40       LOGICAL  , OPTIONAL, INTENT(IN) :: mask(:,:,:) 
    41       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     44      LOGICAL  , OPTIONAL, INTENT(IN) :: mask1(:) 
     45      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     46      LOGICAL  , OPTIONAL, INTENT(IN) :: mask2(:,:) 
     47      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     48      LOGICAL  , OPTIONAL, INTENT(IN) :: mask3(:,:,:) 
     49      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    4250      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    4351       
    4452      CALL xios(set_grid_attr_hdl_)  & 
    45       ( grid_hdl, axisDomainOrder, description, mask, name ) 
     53      ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    4654     
    4755  END SUBROUTINE xios(set_grid_attr_hdl) 
    4856   
    4957  SUBROUTINE xios(set_grid_attr_hdl_)   & 
    50     ( grid_hdl, axisDomainOrder_, description_, mask_, name_ ) 
     58    ( grid_hdl, axisDomainOrder_, description_, mask1_, mask2_, mask3_, name_ ) 
    5159     
    5260    IMPLICIT NONE 
     
    5563      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder__tmp(:) 
    5664      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description_ 
    57       LOGICAL  , OPTIONAL, INTENT(IN) :: mask_(:,:,:) 
    58       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask__tmp(:,:,:) 
     65      LOGICAL  , OPTIONAL, INTENT(IN) :: mask1_(:) 
     66      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1__tmp(:) 
     67      LOGICAL  , OPTIONAL, INTENT(IN) :: mask2_(:,:) 
     68      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2__tmp(:,:) 
     69      LOGICAL  , OPTIONAL, INTENT(IN) :: mask3_(:,:,:) 
     70      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3__tmp(:,:,:) 
    5971      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 
    6072       
     
    6981      ENDIF 
    7082       
    71       IF (PRESENT(mask_)) THEN 
    72         ALLOCATE(mask__tmp(size(mask_,1),size(mask_,2),size(mask_,3))) 
    73         mask__tmp=mask_ 
    74         CALL cxios_set_grid_mask(grid_hdl%daddr, mask__tmp,size(mask_,1),size(mask_,2),size(mask_,3)) 
     83      IF (PRESENT(mask1_)) THEN 
     84        ALLOCATE(mask1__tmp(size(mask1_,1))) 
     85        mask1__tmp=mask1_ 
     86        CALL cxios_set_grid_mask1(grid_hdl%daddr, mask1__tmp,size(mask1_,1)) 
     87      ENDIF 
     88       
     89      IF (PRESENT(mask2_)) THEN 
     90        ALLOCATE(mask2__tmp(size(mask2_,1),size(mask2_,2))) 
     91        mask2__tmp=mask2_ 
     92        CALL cxios_set_grid_mask2(grid_hdl%daddr, mask2__tmp,size(mask2_,1),size(mask2_,2)) 
     93      ENDIF 
     94       
     95      IF (PRESENT(mask3_)) THEN 
     96        ALLOCATE(mask3__tmp(size(mask3_,1),size(mask3_,2),size(mask3_,3))) 
     97        mask3__tmp=mask3_ 
     98        CALL cxios_set_grid_mask3(grid_hdl%daddr, mask3__tmp,size(mask3_,1),size(mask3_,2),size(mask3_,3)) 
    7599      ENDIF 
    76100       
     
    84108   
    85109  SUBROUTINE xios(get_grid_attr)  & 
    86     ( grid_id, axisDomainOrder, description, mask, name ) 
     110    ( grid_id, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    87111     
    88112    IMPLICIT NONE 
     
    92116      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 
    93117      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    94       LOGICAL  , OPTIONAL, INTENT(OUT) :: mask(:,:,:) 
    95       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     118      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask1(:) 
     119      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     120      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask2(:,:) 
     121      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     122      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask3(:,:,:) 
     123      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    96124      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    97125       
    98126      CALL xios(get_grid_handle)(grid_id,grid_hdl) 
    99127      CALL xios(get_grid_attr_hdl_)   & 
    100       ( grid_hdl, axisDomainOrder, description, mask, name ) 
     128      ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    101129     
    102130  END SUBROUTINE xios(get_grid_attr) 
    103131   
    104132  SUBROUTINE xios(get_grid_attr_hdl)  & 
    105     ( grid_hdl, axisDomainOrder, description, mask, name ) 
     133    ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    106134     
    107135    IMPLICIT NONE 
     
    110138      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 
    111139      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    112       LOGICAL  , OPTIONAL, INTENT(OUT) :: mask(:,:,:) 
    113       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     140      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask1(:) 
     141      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     142      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask2(:,:) 
     143      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     144      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask3(:,:,:) 
     145      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    114146      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    115147       
    116148      CALL xios(get_grid_attr_hdl_)  & 
    117       ( grid_hdl, axisDomainOrder, description, mask, name ) 
     149      ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    118150     
    119151  END SUBROUTINE xios(get_grid_attr_hdl) 
    120152   
    121153  SUBROUTINE xios(get_grid_attr_hdl_)   & 
    122     ( grid_hdl, axisDomainOrder_, description_, mask_, name_ ) 
     154    ( grid_hdl, axisDomainOrder_, description_, mask1_, mask2_, mask3_, name_ ) 
    123155     
    124156    IMPLICIT NONE 
     
    127159      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder__tmp(:) 
    128160      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description_ 
    129       LOGICAL  , OPTIONAL, INTENT(OUT) :: mask_(:,:,:) 
    130       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask__tmp(:,:,:) 
     161      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask1_(:) 
     162      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1__tmp(:) 
     163      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask2_(:,:) 
     164      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2__tmp(:,:) 
     165      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask3_(:,:,:) 
     166      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3__tmp(:,:,:) 
    131167      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 
    132168       
     
    141177      ENDIF 
    142178       
    143       IF (PRESENT(mask_)) THEN 
    144         ALLOCATE(mask__tmp(size(mask_,1),size(mask_,2),size(mask_,3))) 
    145         CALL cxios_get_grid_mask(grid_hdl%daddr, mask__tmp,size(mask_,1),size(mask_,2),size(mask_,3)) 
    146         mask_=mask__tmp 
     179      IF (PRESENT(mask1_)) THEN 
     180        ALLOCATE(mask1__tmp(size(mask1_,1))) 
     181        CALL cxios_get_grid_mask1(grid_hdl%daddr, mask1__tmp,size(mask1_,1)) 
     182        mask1_=mask1__tmp 
     183      ENDIF 
     184       
     185      IF (PRESENT(mask2_)) THEN 
     186        ALLOCATE(mask2__tmp(size(mask2_,1),size(mask2_,2))) 
     187        CALL cxios_get_grid_mask2(grid_hdl%daddr, mask2__tmp,size(mask2_,1),size(mask2_,2)) 
     188        mask2_=mask2__tmp 
     189      ENDIF 
     190       
     191      IF (PRESENT(mask3_)) THEN 
     192        ALLOCATE(mask3__tmp(size(mask3_,1),size(mask3_,2),size(mask3_,3))) 
     193        CALL cxios_get_grid_mask3(grid_hdl%daddr, mask3__tmp,size(mask3_,1),size(mask3_,2),size(mask3_,3)) 
     194        mask3_=mask3__tmp 
    147195      ENDIF 
    148196       
     
    156204   
    157205  SUBROUTINE xios(is_defined_grid_attr)  & 
    158     ( grid_id, axisDomainOrder, description, mask, name ) 
     206    ( grid_id, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    159207     
    160208    IMPLICIT NONE 
     
    165213      LOGICAL, OPTIONAL, INTENT(OUT) :: description 
    166214      LOGICAL(KIND=C_BOOL) :: description_tmp 
    167       LOGICAL, OPTIONAL, INTENT(OUT) :: mask 
    168       LOGICAL(KIND=C_BOOL) :: mask_tmp 
     215      LOGICAL, OPTIONAL, INTENT(OUT) :: mask1 
     216      LOGICAL(KIND=C_BOOL) :: mask1_tmp 
     217      LOGICAL, OPTIONAL, INTENT(OUT) :: mask2 
     218      LOGICAL(KIND=C_BOOL) :: mask2_tmp 
     219      LOGICAL, OPTIONAL, INTENT(OUT) :: mask3 
     220      LOGICAL(KIND=C_BOOL) :: mask3_tmp 
    169221      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    170222      LOGICAL(KIND=C_BOOL) :: name_tmp 
     
    172224      CALL xios(get_grid_handle)(grid_id,grid_hdl) 
    173225      CALL xios(is_defined_grid_attr_hdl_)   & 
    174       ( grid_hdl, axisDomainOrder, description, mask, name ) 
     226      ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    175227     
    176228  END SUBROUTINE xios(is_defined_grid_attr) 
    177229   
    178230  SUBROUTINE xios(is_defined_grid_attr_hdl)  & 
    179     ( grid_hdl, axisDomainOrder, description, mask, name ) 
     231    ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    180232     
    181233    IMPLICIT NONE 
     
    185237      LOGICAL, OPTIONAL, INTENT(OUT) :: description 
    186238      LOGICAL(KIND=C_BOOL) :: description_tmp 
    187       LOGICAL, OPTIONAL, INTENT(OUT) :: mask 
    188       LOGICAL(KIND=C_BOOL) :: mask_tmp 
     239      LOGICAL, OPTIONAL, INTENT(OUT) :: mask1 
     240      LOGICAL(KIND=C_BOOL) :: mask1_tmp 
     241      LOGICAL, OPTIONAL, INTENT(OUT) :: mask2 
     242      LOGICAL(KIND=C_BOOL) :: mask2_tmp 
     243      LOGICAL, OPTIONAL, INTENT(OUT) :: mask3 
     244      LOGICAL(KIND=C_BOOL) :: mask3_tmp 
    189245      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    190246      LOGICAL(KIND=C_BOOL) :: name_tmp 
    191247       
    192248      CALL xios(is_defined_grid_attr_hdl_)  & 
    193       ( grid_hdl, axisDomainOrder, description, mask, name ) 
     249      ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 
    194250     
    195251  END SUBROUTINE xios(is_defined_grid_attr_hdl) 
    196252   
    197253  SUBROUTINE xios(is_defined_grid_attr_hdl_)   & 
    198     ( grid_hdl, axisDomainOrder_, description_, mask_, name_ ) 
     254    ( grid_hdl, axisDomainOrder_, description_, mask1_, mask2_, mask3_, name_ ) 
    199255     
    200256    IMPLICIT NONE 
     
    204260      LOGICAL, OPTIONAL, INTENT(OUT) :: description_ 
    205261      LOGICAL(KIND=C_BOOL) :: description__tmp 
    206       LOGICAL, OPTIONAL, INTENT(OUT) :: mask_ 
    207       LOGICAL(KIND=C_BOOL) :: mask__tmp 
     262      LOGICAL, OPTIONAL, INTENT(OUT) :: mask1_ 
     263      LOGICAL(KIND=C_BOOL) :: mask1__tmp 
     264      LOGICAL, OPTIONAL, INTENT(OUT) :: mask2_ 
     265      LOGICAL(KIND=C_BOOL) :: mask2__tmp 
     266      LOGICAL, OPTIONAL, INTENT(OUT) :: mask3_ 
     267      LOGICAL(KIND=C_BOOL) :: mask3__tmp 
    208268      LOGICAL, OPTIONAL, INTENT(OUT) :: name_ 
    209269      LOGICAL(KIND=C_BOOL) :: name__tmp 
     
    219279      ENDIF 
    220280       
    221       IF (PRESENT(mask_)) THEN 
    222         mask__tmp=cxios_is_defined_grid_mask(grid_hdl%daddr) 
    223         mask_=mask__tmp 
     281      IF (PRESENT(mask1_)) THEN 
     282        mask1__tmp=cxios_is_defined_grid_mask1(grid_hdl%daddr) 
     283        mask1_=mask1__tmp 
     284      ENDIF 
     285       
     286      IF (PRESENT(mask2_)) THEN 
     287        mask2__tmp=cxios_is_defined_grid_mask2(grid_hdl%daddr) 
     288        mask2_=mask2__tmp 
     289      ENDIF 
     290       
     291      IF (PRESENT(mask3_)) THEN 
     292        mask3__tmp=cxios_is_defined_grid_mask3(grid_hdl%daddr) 
     293        mask3_=mask3__tmp 
    224294      ENDIF 
    225295       
  • XIOS/trunk/src/interface/fortran_attr/igridgroup_attr.F90

    r556 r567  
    1212   
    1313  SUBROUTINE xios(set_gridgroup_attr)  & 
    14     ( gridgroup_id, axisDomainOrder, description, group_ref, mask, name ) 
     14    ( gridgroup_id, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    1515     
    1616    IMPLICIT NONE 
     
    2121      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    2222      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
    23       LOGICAL  , OPTIONAL, INTENT(IN) :: mask(:,:,:) 
    24       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     23      LOGICAL  , OPTIONAL, INTENT(IN) :: mask1(:) 
     24      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     25      LOGICAL  , OPTIONAL, INTENT(IN) :: mask2(:,:) 
     26      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     27      LOGICAL  , OPTIONAL, INTENT(IN) :: mask3(:,:,:) 
     28      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    2529      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    2630       
    2731      CALL xios(get_gridgroup_handle)(gridgroup_id,gridgroup_hdl) 
    2832      CALL xios(set_gridgroup_attr_hdl_)   & 
    29       ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     33      ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    3034     
    3135  END SUBROUTINE xios(set_gridgroup_attr) 
    3236   
    3337  SUBROUTINE xios(set_gridgroup_attr_hdl)  & 
    34     ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     38    ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    3539     
    3640    IMPLICIT NONE 
     
    4044      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    4145      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
    42       LOGICAL  , OPTIONAL, INTENT(IN) :: mask(:,:,:) 
    43       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     46      LOGICAL  , OPTIONAL, INTENT(IN) :: mask1(:) 
     47      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     48      LOGICAL  , OPTIONAL, INTENT(IN) :: mask2(:,:) 
     49      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     50      LOGICAL  , OPTIONAL, INTENT(IN) :: mask3(:,:,:) 
     51      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    4452      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    4553       
    4654      CALL xios(set_gridgroup_attr_hdl_)  & 
    47       ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     55      ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    4856     
    4957  END SUBROUTINE xios(set_gridgroup_attr_hdl) 
    5058   
    5159  SUBROUTINE xios(set_gridgroup_attr_hdl_)   & 
    52     ( gridgroup_hdl, axisDomainOrder_, description_, group_ref_, mask_, name_ ) 
     60    ( gridgroup_hdl, axisDomainOrder_, description_, group_ref_, mask1_, mask2_, mask3_, name_ ) 
    5361     
    5462    IMPLICIT NONE 
     
    5866      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description_ 
    5967      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref_ 
    60       LOGICAL  , OPTIONAL, INTENT(IN) :: mask_(:,:,:) 
    61       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask__tmp(:,:,:) 
     68      LOGICAL  , OPTIONAL, INTENT(IN) :: mask1_(:) 
     69      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1__tmp(:) 
     70      LOGICAL  , OPTIONAL, INTENT(IN) :: mask2_(:,:) 
     71      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2__tmp(:,:) 
     72      LOGICAL  , OPTIONAL, INTENT(IN) :: mask3_(:,:,:) 
     73      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3__tmp(:,:,:) 
    6274      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 
    6375       
     
    7688      ENDIF 
    7789       
    78       IF (PRESENT(mask_)) THEN 
    79         ALLOCATE(mask__tmp(size(mask_,1),size(mask_,2),size(mask_,3))) 
    80         mask__tmp=mask_ 
    81         CALL cxios_set_gridgroup_mask(gridgroup_hdl%daddr, mask__tmp,size(mask_,1),size(mask_,2),size(mask_,3)) 
     90      IF (PRESENT(mask1_)) THEN 
     91        ALLOCATE(mask1__tmp(size(mask1_,1))) 
     92        mask1__tmp=mask1_ 
     93        CALL cxios_set_gridgroup_mask1(gridgroup_hdl%daddr, mask1__tmp,size(mask1_,1)) 
     94      ENDIF 
     95       
     96      IF (PRESENT(mask2_)) THEN 
     97        ALLOCATE(mask2__tmp(size(mask2_,1),size(mask2_,2))) 
     98        mask2__tmp=mask2_ 
     99        CALL cxios_set_gridgroup_mask2(gridgroup_hdl%daddr, mask2__tmp,size(mask2_,1),size(mask2_,2)) 
     100      ENDIF 
     101       
     102      IF (PRESENT(mask3_)) THEN 
     103        ALLOCATE(mask3__tmp(size(mask3_,1),size(mask3_,2),size(mask3_,3))) 
     104        mask3__tmp=mask3_ 
     105        CALL cxios_set_gridgroup_mask3(gridgroup_hdl%daddr, mask3__tmp,size(mask3_,1),size(mask3_,2),size(mask3_,3)) 
    82106      ENDIF 
    83107       
     
    91115   
    92116  SUBROUTINE xios(get_gridgroup_attr)  & 
    93     ( gridgroup_id, axisDomainOrder, description, group_ref, mask, name ) 
     117    ( gridgroup_id, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    94118     
    95119    IMPLICIT NONE 
     
    100124      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    101125      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
    102       LOGICAL  , OPTIONAL, INTENT(OUT) :: mask(:,:,:) 
    103       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     126      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask1(:) 
     127      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     128      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask2(:,:) 
     129      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     130      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask3(:,:,:) 
     131      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    104132      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    105133       
    106134      CALL xios(get_gridgroup_handle)(gridgroup_id,gridgroup_hdl) 
    107135      CALL xios(get_gridgroup_attr_hdl_)   & 
    108       ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     136      ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    109137     
    110138  END SUBROUTINE xios(get_gridgroup_attr) 
    111139   
    112140  SUBROUTINE xios(get_gridgroup_attr_hdl)  & 
    113     ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     141    ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    114142     
    115143    IMPLICIT NONE 
     
    119147      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    120148      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
    121       LOGICAL  , OPTIONAL, INTENT(OUT) :: mask(:,:,:) 
    122       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask_tmp(:,:,:) 
     149      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask1(:) 
     150      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1_tmp(:) 
     151      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask2(:,:) 
     152      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2_tmp(:,:) 
     153      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask3(:,:,:) 
     154      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3_tmp(:,:,:) 
    123155      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    124156       
    125157      CALL xios(get_gridgroup_attr_hdl_)  & 
    126       ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     158      ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    127159     
    128160  END SUBROUTINE xios(get_gridgroup_attr_hdl) 
    129161   
    130162  SUBROUTINE xios(get_gridgroup_attr_hdl_)   & 
    131     ( gridgroup_hdl, axisDomainOrder_, description_, group_ref_, mask_, name_ ) 
     163    ( gridgroup_hdl, axisDomainOrder_, description_, group_ref_, mask1_, mask2_, mask3_, name_ ) 
    132164     
    133165    IMPLICIT NONE 
     
    137169      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description_ 
    138170      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref_ 
    139       LOGICAL  , OPTIONAL, INTENT(OUT) :: mask_(:,:,:) 
    140       LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask__tmp(:,:,:) 
     171      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask1_(:) 
     172      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask1__tmp(:) 
     173      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask2_(:,:) 
     174      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask2__tmp(:,:) 
     175      LOGICAL  , OPTIONAL, INTENT(OUT) :: mask3_(:,:,:) 
     176      LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: mask3__tmp(:,:,:) 
    141177      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 
    142178       
     
    155191      ENDIF 
    156192       
    157       IF (PRESENT(mask_)) THEN 
    158         ALLOCATE(mask__tmp(size(mask_,1),size(mask_,2),size(mask_,3))) 
    159         CALL cxios_get_gridgroup_mask(gridgroup_hdl%daddr, mask__tmp,size(mask_,1),size(mask_,2),size(mask_,3)) 
    160         mask_=mask__tmp 
     193      IF (PRESENT(mask1_)) THEN 
     194        ALLOCATE(mask1__tmp(size(mask1_,1))) 
     195        CALL cxios_get_gridgroup_mask1(gridgroup_hdl%daddr, mask1__tmp,size(mask1_,1)) 
     196        mask1_=mask1__tmp 
     197      ENDIF 
     198       
     199      IF (PRESENT(mask2_)) THEN 
     200        ALLOCATE(mask2__tmp(size(mask2_,1),size(mask2_,2))) 
     201        CALL cxios_get_gridgroup_mask2(gridgroup_hdl%daddr, mask2__tmp,size(mask2_,1),size(mask2_,2)) 
     202        mask2_=mask2__tmp 
     203      ENDIF 
     204       
     205      IF (PRESENT(mask3_)) THEN 
     206        ALLOCATE(mask3__tmp(size(mask3_,1),size(mask3_,2),size(mask3_,3))) 
     207        CALL cxios_get_gridgroup_mask3(gridgroup_hdl%daddr, mask3__tmp,size(mask3_,1),size(mask3_,2),size(mask3_,3)) 
     208        mask3_=mask3__tmp 
    161209      ENDIF 
    162210       
     
    170218   
    171219  SUBROUTINE xios(is_defined_gridgroup_attr)  & 
    172     ( gridgroup_id, axisDomainOrder, description, group_ref, mask, name ) 
     220    ( gridgroup_id, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    173221     
    174222    IMPLICIT NONE 
     
    181229      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 
    182230      LOGICAL(KIND=C_BOOL) :: group_ref_tmp 
    183       LOGICAL, OPTIONAL, INTENT(OUT) :: mask 
    184       LOGICAL(KIND=C_BOOL) :: mask_tmp 
     231      LOGICAL, OPTIONAL, INTENT(OUT) :: mask1 
     232      LOGICAL(KIND=C_BOOL) :: mask1_tmp 
     233      LOGICAL, OPTIONAL, INTENT(OUT) :: mask2 
     234      LOGICAL(KIND=C_BOOL) :: mask2_tmp 
     235      LOGICAL, OPTIONAL, INTENT(OUT) :: mask3 
     236      LOGICAL(KIND=C_BOOL) :: mask3_tmp 
    185237      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    186238      LOGICAL(KIND=C_BOOL) :: name_tmp 
     
    188240      CALL xios(get_gridgroup_handle)(gridgroup_id,gridgroup_hdl) 
    189241      CALL xios(is_defined_gridgroup_attr_hdl_)   & 
    190       ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     242      ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    191243     
    192244  END SUBROUTINE xios(is_defined_gridgroup_attr) 
    193245   
    194246  SUBROUTINE xios(is_defined_gridgroup_attr_hdl)  & 
    195     ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     247    ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    196248     
    197249    IMPLICIT NONE 
     
    203255      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 
    204256      LOGICAL(KIND=C_BOOL) :: group_ref_tmp 
    205       LOGICAL, OPTIONAL, INTENT(OUT) :: mask 
    206       LOGICAL(KIND=C_BOOL) :: mask_tmp 
     257      LOGICAL, OPTIONAL, INTENT(OUT) :: mask1 
     258      LOGICAL(KIND=C_BOOL) :: mask1_tmp 
     259      LOGICAL, OPTIONAL, INTENT(OUT) :: mask2 
     260      LOGICAL(KIND=C_BOOL) :: mask2_tmp 
     261      LOGICAL, OPTIONAL, INTENT(OUT) :: mask3 
     262      LOGICAL(KIND=C_BOOL) :: mask3_tmp 
    207263      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    208264      LOGICAL(KIND=C_BOOL) :: name_tmp 
    209265       
    210266      CALL xios(is_defined_gridgroup_attr_hdl_)  & 
    211       ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask, name ) 
     267      ( gridgroup_hdl, axisDomainOrder, description, group_ref, mask1, mask2, mask3, name ) 
    212268     
    213269  END SUBROUTINE xios(is_defined_gridgroup_attr_hdl) 
    214270   
    215271  SUBROUTINE xios(is_defined_gridgroup_attr_hdl_)   & 
    216     ( gridgroup_hdl, axisDomainOrder_, description_, group_ref_, mask_, name_ ) 
     272    ( gridgroup_hdl, axisDomainOrder_, description_, group_ref_, mask1_, mask2_, mask3_, name_ ) 
    217273     
    218274    IMPLICIT NONE 
     
    224280      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref_ 
    225281      LOGICAL(KIND=C_BOOL) :: group_ref__tmp 
    226       LOGICAL, OPTIONAL, INTENT(OUT) :: mask_ 
    227       LOGICAL(KIND=C_BOOL) :: mask__tmp 
     282      LOGICAL, OPTIONAL, INTENT(OUT) :: mask1_ 
     283      LOGICAL(KIND=C_BOOL) :: mask1__tmp 
     284      LOGICAL, OPTIONAL, INTENT(OUT) :: mask2_ 
     285      LOGICAL(KIND=C_BOOL) :: mask2__tmp 
     286      LOGICAL, OPTIONAL, INTENT(OUT) :: mask3_ 
     287      LOGICAL(KIND=C_BOOL) :: mask3__tmp 
    228288      LOGICAL, OPTIONAL, INTENT(OUT) :: name_ 
    229289      LOGICAL(KIND=C_BOOL) :: name__tmp 
     
    244304      ENDIF 
    245305       
    246       IF (PRESENT(mask_)) THEN 
    247         mask__tmp=cxios_is_defined_gridgroup_mask(gridgroup_hdl%daddr) 
    248         mask_=mask__tmp 
     306      IF (PRESENT(mask1_)) THEN 
     307        mask1__tmp=cxios_is_defined_gridgroup_mask1(gridgroup_hdl%daddr) 
     308        mask1_=mask1__tmp 
     309      ENDIF 
     310       
     311      IF (PRESENT(mask2_)) THEN 
     312        mask2__tmp=cxios_is_defined_gridgroup_mask2(gridgroup_hdl%daddr) 
     313        mask2_=mask2__tmp 
     314      ENDIF 
     315       
     316      IF (PRESENT(mask3_)) THEN 
     317        mask3__tmp=cxios_is_defined_gridgroup_mask3(gridgroup_hdl%daddr) 
     318        mask3_=mask3__tmp 
    249319      ENDIF 
    250320       
  • XIOS/trunk/src/node/axis.cpp

    • Property svn:executable set to *
    r566 r567  
    66#include "message.hpp" 
    77#include "type.hpp" 
     8#include "context.hpp" 
     9#include "context_client.hpp" 
    810#include "xmlioserver_spl.hpp" 
    911 
     
    1416   CAxis::CAxis(void) 
    1517      : CObjectTemplate<CAxis>() 
    16       , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 
     18      , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 
    1719   { /* Ne rien faire de plus */ } 
    1820 
    1921   CAxis::CAxis(const StdString & id) 
    2022      : CObjectTemplate<CAxis>(id) 
    21       , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 
     23      , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 
    2224   { /* Ne rien faire de plus */ } 
    2325 
     
    5254   void CAxis::checkAttributes(void) 
    5355   { 
    54       if (this->isChecked) return; 
    5556      if (this->size.isEmpty()) 
    5657         ERROR("CAxis::checkAttributes(void)", 
     
    7677      else this->ni.setValue(size); 
    7778 
    78       StdSize zoom_begin,zoom_end, zoom_size; 
    79  
    80       // Maybe index begins at 0 (zero) 
    81       zoom_begin = (this->zoom_begin.isEmpty()) ?  0 : this->zoom_begin.getValue(); 
    82       zoom_end = (this->zoom_end.isEmpty()) ?  size-1 : this->zoom_end.getValue(); 
    83       zoom_size = (this->zoom_size.isEmpty()) ?  size : this->zoom_size.getValue(); 
    84  
    85       if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1; 
    86       if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1; 
    87       if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1; 
    88  
    89       if ( (zoom_begin < 0) || (zoom_begin > size-1) || (zoom_end<0) || (zoom_end>size-1) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 
    90         ERROR("CAxis::checkAttributes(void)", 
    9179              << "One or more attributes among <zoom_begin>, <zoom_end>, <zoom_size> of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); 
    92  
    93       this->zoom_begin.setValue(zoom_begin); 
    94       this->zoom_end.setValue(zoom_end); 
    95       this->zoom_size.setValue(zoom_size); 
    96  
    9780      StdSize true_size = value.numElements(); 
    9881      if (size != true_size) 
     
    10285      this->checkData(); 
    10386      this->checkMask(); 
    104       this->isChecked = true; 
     87      this->checkZoom(); 
    10588   } 
    10689 
     
    122105        for (int i = 0; i < dn; ++i) data_index(i) = (i+1); 
    123106      } 
     107   } 
     108 
     109   void CAxis::checkZoom(void) 
     110   { 
     111      StdSize zoom_begin,zoom_end, zoom_size; 
     112 
     113      zoom_begin = (this->zoom_begin.isEmpty()) ?  0 : this->zoom_begin.getValue() ; 
     114      zoom_size  = (this->zoom_size.isEmpty()) ?  size.getValue() : this->zoom_size.getValue() ; 
     115      zoom_end   = (this->zoom_end.isEmpty()) ?  (size.getValue() - 1) : this->zoom_end.getValue() ; 
     116 
     117      if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1 ; 
     118      if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1 ; 
     119      if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1 ; 
     120 
     121      if ( (zoom_begin < 0) || (zoom_begin > size-1) || (zoom_end<0) || (zoom_end>size-1) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 
     122        ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; 
     123 
     124      this->zoom_begin.setValue(zoom_begin) ; 
     125      this->zoom_end.setValue(zoom_end) ; 
     126      this->zoom_size.setValue(zoom_size) ; 
     127 
     128      // compute client zoom indices 
     129//      zoom_begin_client = ibegin_client > zoom_begin ? begin_client : zoom_begin ; 
     130//      zoom_end_client   = iend_client < zoom_end ? iend_client : zoom_end ; 
     131//      zoom_size_client  = zoom_end_client-zoom_begin_client+1 ; 
     132//      if (zoom_ni_client<0) zoom_ni_client=0 ; 
    124133   } 
    125134 
     
    166175   } 
    167176 
     177  bool CAxis::dispatchEvent(CEventServer& event) 
     178   { 
     179      if (SuperClass::dispatchEvent(event)) return true ; 
     180      else 
     181      { 
     182        switch(event.type) 
     183        { 
     184           case EVENT_ID_SERVER_ATTRIBUT : 
     185             recvServerAttribut(event) ; 
     186             return true ; 
     187             break ; 
     188           default : 
     189             ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
     190                    <<"Unknown Event") ; 
     191           return false ; 
     192         } 
     193      } 
     194   } 
     195 
     196   void CAxis::checkAttributesOnClient(const std::vector<int>& globalDim, int orderPositionInGrid, 
     197                                       CServerDistributionDescription::ServerDistributionType distType) 
     198   { 
     199     if (this->areClientAttributesChecked_) return; 
     200     this->checkAttributes(); 
     201 
     202     CContext* context=CContext::getCurrent() ; 
     203     if (context->hasClient) 
     204     { 
     205       computeServerIndex(globalDim, orderPositionInGrid, distType); 
     206     } 
     207 
     208     this->areClientAttributesChecked_ = true; 
     209   } 
     210 
     211   void CAxis::computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 
     212                                  CServerDistributionDescription::ServerDistributionType distType) 
     213   { 
     214     CServerDistributionDescription serverDescription(globalDim); 
     215 
     216     CContext* context=CContext::getCurrent() ; 
     217     CContextClient* client=context->client ; 
     218     int nbServer=client->serverSize ; 
     219     int serverRank=client->getServerLeader() ; 
     220 
     221     serverDescription.computeServerDistribution(nbServer, false, distType); 
     222     std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
     223     std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
     224     begin_srv = (serverIndexBegin[serverRank])[orderPositionInGrid]; 
     225     ni_srv = serverDimensionSizes[serverRank][orderPositionInGrid]; 
     226     end_srv = begin_srv+ni_srv-1; 
     227   } 
     228 
     229   // Send all checked attributes to server 
     230   void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
     231                                     CServerDistributionDescription::ServerDistributionType distType) 
     232   { 
     233     if (!this->areClientAttributesChecked_) checkAttributesOnClient(globalDim, 
     234                                                                     orderPositionInGrid, 
     235                                                                     distType); 
     236     CContext* context=CContext::getCurrent() ; 
     237 
     238     if (this->isChecked) return; 
     239     if (context->hasClient) 
     240     { 
     241       sendServerAttribut() ; 
     242     } 
     243 
     244     this->isChecked = true; 
     245   } 
     246 
     247  void CAxis::sendServerAttribut(void) 
     248  { 
     249    CContext* context=CContext::getCurrent(); 
     250    CContextClient* client=context->client; 
     251 
     252    CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 
     253    if (client->isServerLeader()) 
     254    { 
     255      CMessage msg ; 
     256      msg<<this->getId() ; 
     257      msg<<ni_srv<<begin_srv<<end_srv; 
     258      event.push(client->getServerLeader(),1,msg) ; 
     259      client->sendEvent(event) ; 
     260    } 
     261    else client->sendEvent(event) ; 
     262  } 
     263 
     264  void CAxis::recvServerAttribut(CEventServer& event) 
     265  { 
     266    CBufferIn* buffer=event.subEvents.begin()->buffer; 
     267    string axisId ; 
     268    *buffer>>axisId ; 
     269    get(axisId)->recvServerAttribut(*buffer) ; 
     270  } 
     271 
     272  void CAxis::recvServerAttribut(CBufferIn& buffer) 
     273  { 
     274    int zoom_end = zoom_begin.getValue()+zoom_size.getValue()-1; 
     275    int ni_srv, begin_srv, end_srv; 
     276 
     277    buffer>>ni_srv>>begin_srv>>end_srv; 
     278 
     279    zoom_begin_srv = zoom_begin.getValue() > begin_srv ? zoom_begin.getValue() : begin_srv ; 
     280    zoom_end_srv   = zoom_end < end_srv ? zoom_end : end_srv ; 
     281    zoom_size_srv  = zoom_end_srv-zoom_begin_srv+1 ; 
     282 
     283    if (zoom_size_srv<=0) 
     284    { 
     285      zoom_begin_srv=0 ; zoom_end_srv=0 ; zoom_size_srv=0 ; 
     286    } 
     287  } 
     288 
    168289   DEFINE_REF_FUNC(Axis,axis) 
    169290 
  • XIOS/trunk/src/node/axis.hpp

    r551 r567  
    1111#include "attribute_enum.hpp" 
    1212#include "attribute_enum_impl.hpp" 
     13#include "server_distribution_description.hpp" 
    1314 
    1415namespace xios { 
     
    3334      , public CAxisAttributes 
    3435   { 
     36         enum EEventId 
     37         { 
     38           EVENT_ID_SERVER_ATTRIBUT 
     39         } ; 
     40 
    3541         /// typedef /// 
    3642         typedef CObjectTemplate<CAxis>   SuperClass; 
     
    6672         static StdString GetName(void); 
    6773         static StdString GetDefName(void); 
    68  
    6974         static ENodeType GetType(void); 
    7075 
     76         void sendServerAttribut(void); 
     77         static bool dispatchEvent(CEventServer& event); 
     78         static void recvServerAttribut(CEventServer& event); 
     79         void recvServerAttribut(CBufferIn& buffer) ; 
     80         void checkAttributesOnClient(const std::vector<int>& globalDim, int orderPositionInGrid, 
     81                                      CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); 
     82         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
     83                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); 
     84      public: 
     85        int zoom_begin_srv, zoom_end_srv, zoom_size_srv; 
     86        int ni_srv, begin_srv, end_srv; 
    7187      private : 
    7288         void checkData(); 
    7389         void checkMask(); 
     90         void checkZoom(); 
     91         void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 
     92                                 CServerDistributionDescription::ServerDistributionType disType); 
     93      private: 
     94 
    7495         bool isChecked; 
     96         bool areClientAttributesChecked_; 
    7597         std::set<StdString> relFiles; 
    7698 
  • XIOS/trunk/src/node/context.cpp

    r550 r567  
    308308     if (hasClient) 
    309309     { 
    310 //       std::cout << "Current context " << *this << std::endl; 
    311310       // After xml is parsed, there are some more works with post processing 
    312311       postProcessing(); 
     
    317316     if (hasClient && !hasServer) 
    318317     { 
    319        // After xml is parsed, there are some more works with post processing 
    320 //       postProcessing(); 
    321  
    322 //       setClientServerBuffer(); 
    323  
    324318      // Send all attributes of current context to server 
    325319      this->sendAllAttributesToServer(); 
     
    336330 
    337331      // At last, we have all info of domain and axis, then send them 
    338        sendRefDomainsAxis(); 
     332//       sendRefDomainsAxis(); 
    339333 
    340334      // After that, send all grid (if any) 
    341335       sendRefGrid(); 
    342  
    343  
    344336    } 
    345337 
     
    416408   } 
    417409 
    418 //    void CContext::processEnabledFiles(void) 
    419 //   { 
    420 //     for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 
    421 //     this->enabledFiles[i]->processEnabledFile(); 
    422 //   } 
    423  
    424  
    425410   void CContext::solveAllRefOfEnabledFields(bool sendToServer) 
    426411   { 
     
    440425     } 
    441426   } 
    442  
    443 //   void CContext::solveAllGridRef(void) 
    444 //   { 
    445 //     for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 
    446 //     this->enabledFiles[i]->solveEFGridRef(); 
    447 //   } 
    448 // 
    449 //   void CContext::solveAllOperation(void) 
    450 //   { 
    451 //      for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 
    452 //      this->enabledFiles[i]->solveEFOperation(); 
    453 //   } 
    454 // 
    455 //   void CContext::solveAllExpression(void) 
    456 //   { 
    457 //      for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 
    458 //      this->enabledFiles[i]->solveEFExpression(); 
    459 //   } 
    460427 
    461428   void CContext::solveAllInheritance(bool apply) 
     
    671638      CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 
    672639      postProcessing(); 
    673 //      std::cout << "server context " << *this << std::endl; 
    674640   } 
    675641 
     
    719685   std::map<int, StdSize>& CContext::getDataSize() 
    720686   { 
    721      std::set<StdString> domainIds; 
     687     // Set of grid used by enabled fields 
     688     std::set<StdString> usedGrid; 
    722689 
    723690     // Find all reference domain and axis of all active fields 
     
    729696       for (int j = 0; j < numEnabledFields; ++j) 
    730697       { 
    731          const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 
     698//         const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 
     699         StdString currentGrid = enabledFields[j]->grid->getId(); 
    732700         const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataSize(); 
    733701         if (dataSize_.empty()) 
    734702         { 
    735703           dataSize_ = mapSize; 
    736            domainIds.insert(prDomAxisId.first); 
     704           usedGrid.insert(currentGrid); 
     705//           domainIds.insert(prDomAxisId.first); 
    737706         } 
    738707         else 
    739708         { 
    740709           std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    741            if (domainIds.find(prDomAxisId.first) == domainIds.end()) 
     710           if (usedGrid.find(currentGrid) == usedGrid.end()) 
    742711           { 
    743712             for (; it != itE; ++it) 
     
    830799 
    831800   //! Client side: Send information of reference domain and axis of active fields 
    832    void CContext::sendRefDomainsAxis() 
    833    { 
    834      std::set<StdString> domainIds; 
    835      std::set<StdString> axisIds; 
    836  
    837      // Find all reference domain and axis of all active fields 
    838      int numEnabledFiles = this->enabledFiles.size(); 
    839      for (int i = 0; i < numEnabledFiles; ++i) 
    840      { 
    841        std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 
    842        int numEnabledFields = enabledFields.size(); 
    843        for (int j = 0; j < numEnabledFields; ++j) 
    844        { 
    845          const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 
    846          domainIds.insert(prDomAxisId.first); 
    847          axisIds.insert(prDomAxisId.second); 
    848        } 
    849      } 
    850  
    851      // Create all reference axis on server side 
    852      std::set<StdString>::iterator itDom, itAxis; 
    853      std::set<StdString>::const_iterator itE; 
    854  
    855      StdString axiDefRoot("axis_definition"); 
    856      CAxisGroup* axisPtr = CAxisGroup::get(axiDefRoot); 
    857      itE = axisIds.end(); 
    858      for (itAxis = axisIds.begin(); itAxis != itE; ++itAxis) 
    859      { 
    860        if (!itAxis->empty()) 
    861        { 
    862          axisPtr->sendCreateChild(*itAxis); 
    863          CAxis::get(*itAxis)->sendAllAttributesToServer(); 
    864        } 
    865      } 
    866  
    867      // Create all reference domains on server side 
    868      StdString domDefRoot("domain_definition"); 
    869      CDomainGroup* domPtr = CDomainGroup::get(domDefRoot); 
    870      itE = domainIds.end(); 
    871      for (itDom = domainIds.begin(); itDom != itE; ++itDom) 
    872      { 
    873        if (!itDom->empty()) { 
    874           domPtr->sendCreateChild(*itDom); 
    875           CDomain::get(*itDom)->sendAllAttributesToServer(); 
    876        } 
    877      } 
    878    } 
     801//   void CContext::sendRefDomainsAxis() 
     802//   { 
     803//     std::set<StdString> domainIds; 
     804//     std::set<StdString> axisIds; 
     805// 
     806//     // Find all reference domain and axis of all active fields 
     807//     int numEnabledFiles = this->enabledFiles.size(); 
     808//     for (int i = 0; i < numEnabledFiles; ++i) 
     809//     { 
     810//       std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 
     811//       int numEnabledFields = enabledFields.size(); 
     812//       for (int j = 0; j < numEnabledFields; ++j) 
     813//       { 
     814//         const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 
     815//         domainIds.insert(prDomAxisId.first); 
     816//         axisIds.insert(prDomAxisId.second); 
     817//       } 
     818//     } 
     819// 
     820//     // Create all reference axis on server side 
     821//     std::set<StdString>::iterator itDom, itAxis; 
     822//     std::set<StdString>::const_iterator itE; 
     823// 
     824//     StdString axiDefRoot("axis_definition"); 
     825//     CAxisGroup* axisPtr = CAxisGroup::get(axiDefRoot); 
     826//     itE = axisIds.end(); 
     827//     for (itAxis = axisIds.begin(); itAxis != itE; ++itAxis) 
     828//     { 
     829//       if (!itAxis->empty()) 
     830//       { 
     831//         axisPtr->sendCreateChild(*itAxis); 
     832//         CAxis::get(*itAxis)->sendAllAttributesToServer(); 
     833//       } 
     834//     } 
     835// 
     836//     // Create all reference domains on server side 
     837//     StdString domDefRoot("domain_definition"); 
     838//     CDomainGroup* domPtr = CDomainGroup::get(domDefRoot); 
     839//     itE = domainIds.end(); 
     840//     for (itDom = domainIds.begin(); itDom != itE; ++itDom) 
     841//     { 
     842//       if (!itDom->empty()) { 
     843//          domPtr->sendCreateChild(*itDom); 
     844//          CDomain::get(*itDom)->sendAllAttributesToServer(); 
     845//       } 
     846//     } 
     847//   } 
    879848 
    880849   //! Update calendar in each time step 
  • XIOS/trunk/src/node/distribution_client.cpp

    r553 r567  
    1616   nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_(), 
    1717   dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 
    18    gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_() 
     18   gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 
     19   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0) 
    1920{ 
    2021} 
     
    2526   nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_(), 
    2627   dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 
    27    gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_() 
     28   gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 
     29   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0) 
    2830{ 
    2931  readDistributionInfo(grid); 
     
    3436{ 
    3537  if (0 != localDataIndex_) delete localDataIndex_; 
     38  if (0 != localDataIndexSendToServer_) delete localDataIndexSendToServer_; 
    3639} 
    3740 
     
    4649  std::vector<CDomain*> domList = grid->getDomains(); 
    4750  std::vector<CAxis*> axisList = grid->getAxis(); 
    48   CArray<bool,1>& axisDomainOrder = grid->axisDomainOrder; 
     51  CArray<bool,1> axisDomainOrder = grid->axisDomainOrder; 
    4952 
    5053  std::vector<CDomain*>::iterator itbDom, iteDom, itDom; 
     
    5558 
    5659  // First of all, every attribute of domain and axis should be checked 
    57   for (;itDom != iteDom; ++itDom) (*itDom)->checkAttributesOnClient(); 
    58   for (;itAxis != iteAxis; ++itAxis) (*itAxis)->checkAttributes(); 
     60//  for (;itDom != iteDom; ++itDom) (*itDom)->checkAttributesOnClient(); 
     61//  for (;itAxis != iteAxis; ++itAxis) (*itAxis)->checkAttributesOnClient(); 
     62 
     63  readDistributionInfo(domList, axisList, axisDomainOrder); 
    5964 
    6065  // Then check mask of grid 
     66  int gridDim = domList.size()*2 + axisList.size(); 
    6167  grid->checkMask(); 
    62   CArray<bool,3>& gridMask = grid->mask; 
    63  
    64   //////////////////////////////////////////////////////// 
    65  
    66   int gridDim = domList.size()*2 + axisList.size(); 
    67  
    68   // For now, just suppose that gridMask is all true, but we need to cope with this problem 
    69   //  std::vector<std::vector<bool> > gridMask(gridDim); 
    70 //  int idxDomain = 0, idxAxis = 0; 
    71 //  for (int i = 0; i < axisDomainOrder.size(); ++i) 
    72 //  { 
    73 //    if (axisDomainOrder(i)) 
    74 //    { 
    75 //      gridMask[idxDomain*2+i].resize(domList[idxDomain]->ni); 
    76 //      gridMask[idxDomain*2+i+1].resize(domList[idxDomain]->nj); 
    77 //      ++idxDomain; 
    78 //    } 
    79 //    else 
    80 //    { 
    81 //      gridMask[i].resize(axisList[idxAxis]->ni); 
    82 //      ++idxAxis; 
    83 //    } 
    84 //  } 
    85  
    86   readDistributionInfo(domList, axisList, axisDomainOrder, gridMask); 
     68  switch (gridDim) { 
     69    case 1: 
     70      readGridMaskInfo(grid->mask1); 
     71      break; 
     72    case 2: 
     73      readGridMaskInfo(grid->mask2); 
     74      break; 
     75    case 3: 
     76      readGridMaskInfo(grid->mask3); 
     77      break; 
     78    default: 
     79      break; 
     80  } 
    8781} 
    8882 
     
    9690  \param [in] axisList List of axis of grid 
    9791  \param [in] axisDomainOrder order of axis and domain inside a grid. True if domain, false if axis 
    98   \param [in] gridMask Mask of grid, for now, keep it 3 dimension, but it needs changing 
     92//  \param [in] gridMask Mask of grid, for now, keep it 3 dimension, but it needs changing 
    9993*/ 
    10094void CDistributionClient::readDistributionInfo(const std::vector<CDomain*>& domList, 
    10195                                               const std::vector<CAxis*>& axisList, 
    102                                                const CArray<bool,1>& axisDomainOrder, 
    103                                                const CArray<bool,3>& gridMask) 
    104 { 
     96                                               const CArray<bool,1>& axisDomainOrder) 
     97{ 
     98  domainNum_ = domList.size(); 
     99  axisNum_   = axisList.size(); 
    105100  numElement_ = axisDomainOrder.numElements(); // Number of element, e.x: Axis, Domain 
    106101 
     
    109104 
    110105  // Each domain or axis has its mask, of course 
    111   domainMasks_.resize(domList.size()); 
    112   for (int i = 0; i < domainMasks_.size();++i) 
     106  domainMasks_.resize(domainNum_); 
     107  for (int i = 0; i < domainNum_;++i) 
    113108  { 
    114109    domainMasks_[i].resize(domList[i]->mask.extent(0), domList[i]->mask.extent(1)); 
     
    116111  } 
    117112 
    118   axisMasks_.resize(axisList.size()); 
    119   for (int i = 0; i < axisMasks_.size(); ++i) 
     113  axisMasks_.resize(axisNum_); 
     114  for (int i = 0; i < axisNum_; ++i) 
    120115  { 
    121116    axisMasks_[i].resize(axisList[i]->mask.numElements()); 
    122117    axisMasks_[i] = axisList[i]->mask; 
    123118  } 
    124  
    125   gridMask_.resize(gridMask.extent(0), gridMask.extent(1), gridMask.extent(2)); 
    126   gridMask_ = gridMask; 
    127119 
    128120  // Because domain and axis can be in any order (axis1, domain1, axis2, axis3, ) 
     
    139131      idx += 2; 
    140132    } 
     133    else ++idx; 
    141134  } 
    142135 
     
    215208    ++idx; 
    216209  } 
     210 
     211  // Grid has only one axis and it is not distributed 
     212  bool isDataNotDistributed = true; 
     213  for (int i = 0; i < this->dims_; ++i) 
     214    isDataNotDistributed &= (nLocal_[i] == nGlob_[i]); 
     215  isDataDistributed_ = !isDataNotDistributed; 
    217216} 
    218217 
     
    343342 
    344343    // Find out outer index 
     344    // Depending the inner-most element is axis or domain, 
     345    // The outer loop index begins correspondingly at one (1) or zero (0) 
    345346    idxDomain = idxAxis = 0; 
     347    if (axisDomainOrder_(0)) ++idxDomain; 
     348    else ++idxAxis; 
    346349    for (int i = 1; i < numElement_; ++i) 
    347350    { 
     
    359362    } 
    360363 
     364    int maskIndex = currentIndex[0]; 
     365    for (int j = 0; j < this->dims_; ++j) 
     366 
    361367    // Inner most index 
    362368    idxDomain = idxAxis = 0; 
     
    370376      else currentIndex[0]   = localAxisIndex_[idxAxis][i]; 
    371377 
    372       if (gridMask_(currentIndex[0], currentIndex[1], currentIndex[2])) 
     378      int gridMaskIndex = currentIndex[0]; 
     379      int mulDimMask = 1; 
     380      for (int k = 1; k < this->dims_; ++k) 
     381      { 
     382        mulDimMask *= nLocal_[k-1]; 
     383        gridMaskIndex += (currentIndex[k])*mulDimMask; 
     384      } 
     385 
     386      if (gridMask_(gridMaskIndex)) //(gridMask_(currentIndex[0], currentIndex[1], currentIndex[2])) 
    373387      { 
    374388        ++indexLocalDataOnClientCount; 
     
    389403  this->globalIndex_ = new CArray<size_t,1>(indexSend2ServerCount); 
    390404  localDataIndex_ = new CArray<int,1>(indexLocalDataOnClientCount); 
     405  localDataIndexSendToServer_ = new CArray<int,1>(indexSend2ServerCount); 
    391406 
    392407  // We need to loop with data index 
    393   innerLoopSize = dataNIndex_[0]; 
    394   ssize = 1; for (int i = 0; i < numElement_; ++i) ssize *= dataNIndex_[i]; 
    395408  idxLoop.assign(numElement_,0); 
    396409  idx = indexLocalDataOnClientCount = indexSend2ServerCount = 0; 
    397   int count = 0, correctOuterIndexDomain = 0, correctOuterIndexAxis = 0; 
     410  ssize = 1; for (int i = 0; i < numElement_; ++i) ssize *= dataNIndex_[i]; 
     411  innerLoopSize = dataNIndex_[0]; 
     412  int countLocalData = 0; 
     413  std::vector<int> correctOuterIndex(numElement_,0); 
    398414  while (idx < ssize) 
    399415  { 
     
    403419      { 
    404420        idxLoop[i] = 0; 
     421        correctOuterIndex[i] = 0; 
    405422        ++idxLoop[i+1]; 
    406       } 
    407     } 
    408  
    409     // Outer index 
     423        ++correctOuterIndex[i+1]; 
     424      } 
     425    } 
     426 
     427    // Depending the inner-most element axis or domain, 
     428    // The outer loop index begins correspondingly at one (1) or zero (0) 
    410429    idxDomain = idxAxis = 0; 
    411     bool isIndexDomainDataCorrect = false; 
    412     bool isIndexAxisDataCorrect = false; 
     430    if (axisDomainOrder_(0)) ++idxDomain; 
     431    else ++idxAxis; 
     432    bool isIndexDomainDataCorrect = true; 
     433    bool isIndexAxisDataCorrect = true; 
    413434 
    414435    for (int i = 1; i < numElement_; ++i) 
     
    418439        if (indexDomainData_[idxDomain][idxLoop[i]]) 
    419440        { 
    420           currentIndex[indexMap_[i]]   = localDomainIndex_[idxDomain][correctOuterIndexDomain]; 
    421           currentIndex[indexMap_[i]+1] = localDomainIndex_[idxDomain*2+1][correctOuterIndexDomain]; 
    422           isIndexDomainDataCorrect = true; 
    423           ++correctOuterIndexDomain; 
    424         } 
     441          currentIndex[indexMap_[i]]   = localDomainIndex_[idxDomain][correctOuterIndex[i]]; 
     442          currentIndex[indexMap_[i]+1] = localDomainIndex_[idxDomain*2+1][correctOuterIndex[i]]; 
     443        } 
     444        else isIndexDomainDataCorrect = false; 
    425445        ++idxDomain; 
    426446      } 
     
    429449        if (indexAxisData_[idxAxis][idxLoop[i]]) 
    430450        { 
    431           currentIndex[indexMap_[i]]   = localAxisIndex_[idxAxis][correctOuterIndexAxis]; 
    432           isIndexAxisDataCorrect = true; 
    433           ++correctOuterIndexAxis; 
    434         } 
     451          currentIndex[indexMap_[i]]   = localAxisIndex_[idxAxis][correctOuterIndex[i]]; 
     452        } 
     453        else isIndexAxisDataCorrect = false; 
    435454        ++idxAxis; 
    436455      } 
     
    464483      } 
    465484 
     485      int gridMaskIndex = currentIndex[0]; 
     486      int mulDimMask = 1; 
     487      for (int k = 1; k < this->dims_; ++k) 
     488      { 
     489        mulDimMask *= nLocal_[k-1]; 
     490        gridMaskIndex += (currentIndex[k])*mulDimMask; 
     491      } 
     492 
    466493      if (isIndexDomainDataCorrect && 
    467494          isIndexAxisDataCorrect && 
    468           gridMask_(currentIndex[0], currentIndex[1], currentIndex[2])) 
    469       { 
    470         (*localDataIndex_)(indexLocalDataOnClientCount) = count; 
    471         ++indexLocalDataOnClientCount; 
     495          gridMask_(gridMaskIndex)) 
     496      { 
     497        (*localDataIndex_)(indexLocalDataOnClientCount) = countLocalData; 
    472498 
    473499        bool isIndexOnServer = true; 
     
    486512          } 
    487513          (*this->globalIndex_)(indexSend2ServerCount) = globalIndex; 
     514          (*localDataIndexSendToServer_)(indexSend2ServerCount) = indexLocalDataOnClientCount; 
    488515          ++indexSend2ServerCount; 
    489516        } 
    490       } 
    491       ++count; 
     517        ++indexLocalDataOnClientCount; 
     518      } 
     519      ++countLocalData; 
    492520    } 
    493521    idxLoop[0] += innerLoopSize; 
     
    546574} 
    547575 
     576const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServerOnClient() const 
     577{ 
     578  return (*localDataIndexSendToServer_); 
     579} 
     580 
    548581} // namespace xios 
  • XIOS/trunk/src/node/distribution_client.hpp

    r554 r567  
    3737 
    3838    virtual const CArray<int,1>& getLocalDataIndexOnClient() const; 
     39    virtual const CArray<int,1>& getLocalDataIndexSendToServerOnClient() const; 
     40 
    3941    std::vector<int> getNGlob() { return nGlob_; } 
     42    std::vector<int> getDataNIndex() { return dataNIndex_; } 
     43    bool isDataDistributed() { return isDataDistributed_; } 
    4044 
    4145  protected: 
     
    4448    void readDistributionInfo(const std::vector<CDomain*>& domList, 
    4549                              const std::vector<CAxis*>& axisList, 
    46                               const CArray<bool,1>& axisDomainOrder, 
    47                               const CArray<bool,3>& gridMask); 
    48  
     50                              const CArray<bool,1>& axisDomainOrder); 
    4951  private: 
    5052    //! Create local index of a domain 
     
    5961    inline int getAxisIndex(const int& dataIndex, const int& dataBegin, const int& ni); 
    6062 
     63    template<int N> 
     64    void readGridMaskInfo(const CArray<bool,N>& gridMask); 
     65 
    6166  private: 
    6267    //!< LocalData index on client 
    6368    CArray<int,1>* localDataIndex_; 
     69    CArray<int,1>* localDataIndexSendToServer_; 
    6470 
    6571  private: 
     
    8591    std::vector<CArray<bool,1> > axisMasks_; //!< Axis mask 
    8692 
    87     // Just suppose that grid mask has 3 dimension. Need change 
    88     CArray<bool,3> gridMask_; // TODO: more general grid mask 
    89  
    9093    std::vector<std::vector<int> > localDomainIndex_; 
    9194    std::vector<std::vector<int> > localAxisIndex_; 
     
    9699    std::vector<std::vector<bool> > indexAxisData_; 
    97100 
     101    //!< (Only for grid with one axis or scalar)Flag to determine whether data is distributed or not 
     102    bool isDataDistributed_; 
     103    int axisNum_; 
     104    int domainNum_; 
     105 
     106  private: 
     107    // Just suppose that grid mask has 3 dimension. Need change 
     108    CArray<bool,1> gridMask_; //!< Mask of grid 
     109 
    98110  private: 
    99111    CDistributionClient(const CDistributionClient& distClient); //! Not implement 
    100112}; 
    101113 
     114template<int N> 
     115void CDistributionClient::readGridMaskInfo(const CArray<bool,N>& gridMask) 
     116{ 
     117  int dim = gridMask.dimensions(); 
     118  std::vector<int> dimensionSizes(dim); 
     119  for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i); 
     120 
     121  std::vector<int> idxLoop(dim,0); 
     122  int ssize = gridMask.numElements(), idx = 0; 
     123  gridMask_.resize(ssize); 
     124  while (idx < ssize) 
     125  { 
     126    for (int i = 0; i < dim-1; ++i) 
     127    { 
     128      if (idxLoop[i] == dimensionSizes[i]) 
     129      { 
     130        idxLoop[i] = 0; 
     131        ++idxLoop[i+1]; 
     132      } 
     133    } 
     134 
     135    int maskIndex = idxLoop[0]; 
     136    int mulDim = 1; 
     137    for (int k = 1; k < dim; ++k) 
     138    { 
     139      mulDim *= dimensionSizes[k-1]; 
     140      maskIndex += idxLoop[k]*mulDim; 
     141    } 
     142    gridMask_(maskIndex) = *(gridMask.dataFirst()+maskIndex); 
     143 
     144    ++idxLoop[0]; 
     145    ++idx; 
     146  } 
     147} 
     148 
     149 
    102150} // namespace xios 
    103151#endif // __XIOS_DISTRIBUTIONCLIENT_HPP__ 
  • XIOS/trunk/src/node/distribution_server.cpp

    r553 r567  
    1919                                         const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal) 
    2020  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin) 
     21{ 
     22  createGlobalIndex(); 
     23} 
     24 
     25CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin, 
     26                                         const std::vector<int>& nZoomSize, 
     27                                         const std::vector<int>& nZoomBeginGlobal, 
     28                                         const std::vector<int>& nGlobal) 
     29  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 
     30    nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin) 
    2131{ 
    2232  createGlobalIndex(); 
     
    8999  for (int i = 0; i < ssize; ++i) 
    90100  { 
    91     it = std::lower_bound(it, itEnd, globalIndex(i)); 
     101    it = std::find(itBegin, itEnd, globalIndex(i)); 
     102//    it = std::lower_bound(it, itEnd, globalIndex(i)); 
    92103    if (itEnd != it) 
    93104    { 
     
    114125  for (int i = 0; i < ssize; ++i) 
    115126  { 
    116     it = std::lower_bound(it, itEnd, globalIndex(i)); 
     127    it = std::find(itBegin, itEnd, globalIndex(i)); 
     128//    it = std::lower_bound(it, itEnd, globalIndex(i)); 
    117129    if (itEnd != it) 
    118130    { 
     
    125137} 
    126138 
     139 
     140std::vector<int> CDistributionServer::getZoomBeginGlobal() const 
     141{ 
     142  return nZoomBeginGlobal_; 
     143} 
     144 
     145std::vector<int> CDistributionServer::getZoomBeginServer() const 
     146{ 
     147  return nZoomBegin_; 
     148} 
     149 
     150std::vector<int> CDistributionServer::getZoomSizeServer() const 
     151{ 
     152  return nZoomSize_; 
     153} 
    127154} // namespace xios 
  • XIOS/trunk/src/node/distribution_server.hpp

    r554 r567  
    2424    /** Default constructor */ 
    2525    CDistributionServer(int rank, int dims, CArray<size_t,1>* globalIndex = 0); 
    26     CDistributionServer(int rank, const std::vector<int>& nZoomBegin, 
    27                         const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal); 
     26    CDistributionServer(int rank, const std::vector<int>& nZoomBeginServer, 
     27                        const std::vector<int>& nZoomSizeServer, const std::vector<int>& nGlobal); 
     28    CDistributionServer(int rank, const std::vector<int>& nZoomBeginServer, 
     29                        const std::vector<int>& nZoomSizeServer, 
     30                        const std::vector<int>& nZoomBeginGlobal, 
     31                        const std::vector<int>& nGlobal); 
    2832 
    2933    /** Default destructor */ 
    3034    virtual ~CDistributionServer(); 
     35 
     36    std::vector<int> getZoomBeginGlobal() const; 
     37    std::vector<int> getZoomBeginServer() const; 
     38    std::vector<int> getZoomSizeServer() const; 
    3139 
    3240    virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); 
     
    3745  private: 
    3846    std::vector<int> nGlobal_; 
     47    std::vector<int> nZoomBeginGlobal_; 
    3948    std::vector<int> nZoomSize_; 
    4049    std::vector<int> nZoomBegin_; 
     50 
    4151}; 
    4252 
  • XIOS/trunk/src/node/field.cpp

    • Property svn:executable set to *
    r562 r567  
    152152    list< CArray<double,1>* > list_data; 
    153153 
    154      for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++) 
    155     { 
    156       int rank = (*it).first; 
    157       CArray<int,1>& index = *(it->second); 
    158       CArray<double,1> data_tmp(index.numElements()); 
    159       for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n)); 
    160       list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
    161       list_data.push_back(new CArray<double,1>(data_tmp)); 
    162       *list_msg.back() << getId() << *list_data.back(); 
    163       event.push(rank,grid->nbSenders[rank],*list_msg.back()); 
    164     } 
    165     client->sendEvent(event); 
     154    if (!grid->doGridHaveDataDistributed()) 
     155    { 
     156       if (0 == client->getClientRank()) 
     157       { 
     158          for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
     159          { 
     160            int rank=(*it).first ; 
     161            CArray<int,1>& index = *(it->second) ; 
     162            CArray<double,1> data_tmp(index.numElements()) ; 
     163            for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
     164 
     165            list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
     166            list_data.push_back(new CArray<double,1>(data_tmp)) ; 
     167            *list_msg.back()<<getId()<<*list_data.back() ; 
     168            event.push(rank,1,*list_msg.back()) ; 
     169          } 
     170          client->sendEvent(event) ; 
     171       } else client->sendEvent(event); 
     172    } 
     173    else 
     174    { 
     175      for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
     176      { 
     177        int rank=(*it).first ; 
     178        CArray<int,1>& index = *(it->second) ; 
     179        CArray<double,1> data_tmp(index.numElements()) ; 
     180        for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
     181        list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
     182        list_data.push_back(new CArray<double,1>(data_tmp)) ; 
     183        *list_msg.back()<<getId()<<*list_data.back() ; 
     184        event.push(rank,grid->nbSenders[rank],*list_msg.back()) ; 
     185      } 
     186      client->sendEvent(event) ; 
     187    } 
    166188 
    167189    for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it; 
     
    189211  void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 
    190212  { 
    191  
    192213    if (data_srv.empty()) 
    193214    { 
    194 //      for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++) 
    195215      for (map<int, CArray<size_t, 1>* >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
    196216      { 
     
    234254  { 
    235255    if (!getRelFile()->allDomainEmpty) 
    236       if (!grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
     256      if (grid->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file) //      if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
    237257      { 
    238258        getRelFile()->checkFile(); 
     
    553573      } 
    554574 
    555 //     if (!grid_ref.isEmpty()) 
    556 //     { 
    557 //       domain = grid->domain; 
    558 //       axis = grid->axis; 
    559 //     } 
    560  
    561 //     CType<string> goodDomain; 
    562 //     CType<string> goodAxis; 
    563 //     if (!grid_ref.isEmpty()) 
    564 //     { 
    565 //       if (!grid->domain_ref.isEmpty()) goodDomain = grid->domain_ref; 
    566 //       if (!grid->axis_ref.isEmpty()) goodAxis = grid->axis_ref; 
    567 //     } 
    568 //     if (!domain_ref.isEmpty()) goodDomain = domain_ref; 
    569 //     if (!axis_ref.isEmpty()) goodAxis = axis_ref; 
    570  
    571 //     CArray<std::string,1> domListTmp = grid->domainList.getValue(); 
    572 //     CArray<std::string,1> axisListTmp = grid->axisList.getValue(); 
    573575 
    574576     if (domList.empty() && axisList.empty()) 
     
    576578       this->grid = CGrid::createGrid(vecDom, vecAxis); 
    577579     } 
    578  
    579 //     std::string goodDomain = domListTmp[0]; 
    580 //     std::string goodAxis = axisListTmp[0]; 
    581  
    582 //     if (goodDomain.isEmpty()) 
    583 //     if (goodDomain.empty()) 
    584 //     { 
    585 //       ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined"); 
    586 //     } 
    587 //     else 
    588 //     { 
    589 //       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain); 
    590 //       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'" 
    591 //                  << goodDomain << "\' is wrong"); 
    592 ////                << goodDomain.get() << "\' is wrong"); 
    593 //     } 
    594 // 
    595 ////     if (!goodAxis.isEmpty()) 
    596 //     if (!goodAxis.empty()) 
    597 //     { 
    598 //       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis); 
    599 //       else  ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 
    600 //                   << goodAxis <<"\' is wrong"); 
    601 //                   << goodAxis.get() <<"\' is wrong"); 
    602 //     } 
    603  
    604 //     bool nothingToDo = false; 
    605 // 
    606 //     if (!grid_ref.isEmpty()) 
    607 //     { 
    608 //       if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 
    609 //         if (goodAxis.isEmpty()) nothingToDo = true; 
    610 //         else if (!grid->axis_ref.isEmpty()) 
    611 //                 if (grid->axis_ref.get() == goodAxis.get()) nothingToDo = true; 
    612 //     } 
    613 // 
    614 //     nothingToDo = true; 
    615 //     if (!nothingToDo) 
    616 //     { 
    617 //       if (!goodAxis.isEmpty()) 
    618 //       { 
    619 //         this->grid = CGrid::createGrid(domain, axis); 
    620 //         this->grid_ref.setValue(this->grid->getId()); 
    621 //       } 
    622 //       else 
    623 //       { 
    624 //         this->grid = CGrid::createGrid(domain); 
    625 //         this->grid_ref.setValue(this->grid->getId()); 
    626 //       } 
    627 //     } 
    628  
    629 //     grid->solveReference(); 
    630 //     grid->solveDomainAxisRef(); 
    631 //     grid->checkMaskIndex(); 
    632580   } 
    633581 
     
    682630        grid->outputField(it->first,*it->second, fieldOut.dataFirst()); 
    683631      } 
    684  
    685 //         grid->outputField(it->first,*it->second, fieldOut.); 
    686632   } 
    687633 
     
    689635   { 
    690636      map<int, CArray<double,1>* >::iterator it; 
     637      for(it=data_srv.begin();it!=data_srv.end();it++) 
     638      { 
     639         grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ; 
     640      } 
     641   } 
     642 
     643   void CField::outputField(CArray<double,1>& fieldOut) 
     644   { 
     645      map<int, CArray<double,1>* >::iterator it; 
    691646 
    692647      for (it = data_srv.begin(); it != data_srv.end(); it++) 
    693648      { 
    694          grid->outputField(it->first, *it->second, fieldOut); 
     649         grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ; 
    695650      } 
    696651   } 
     
    844799   \return pair of Domain and Axis id 
    845800   */ 
    846    const std::pair<StdString,StdString>& CField::getDomainAxisIds() 
    847    { 
    848      CGrid* cgPtr = getRelGrid(); 
    849      if (NULL != cgPtr) 
    850      { 
    851        if (NULL != cgPtr->getRelDomain()) domAxisIds_.first = cgPtr->getRelDomain()->getId(); 
    852        if (NULL != cgPtr->getRelAxis()) domAxisIds_.second = cgPtr->getRelAxis()->getId(); 
    853      } 
    854  
    855      return domAxisIds_; 
    856    } 
     801//   const std::pair<StdString,StdString>& CField::getDomainAxisIds() 
     802//   { 
     803//     CGrid* cgPtr = getRelGrid(); 
     804//     if (NULL != cgPtr) 
     805//     { 
     806//       if (NULL != cgPtr->getRelDomain()) domAxisIds_.first = cgPtr->getRelDomain()->getId(); 
     807//       if (NULL != cgPtr->getRelAxis()) domAxisIds_.second = cgPtr->getRelAxis()->getId(); 
     808//     } 
     809// 
     810//     return (domAxisIds_); 
     811//   } 
    857812 
    858813   CVariable* CField::addVariable(const string& id) 
  • XIOS/trunk/src/node/field.hpp

    r540 r567  
    135135        void outputField(CArray<double,3>& fieldOut) ; 
    136136        void outputField(CArray<double,2>& fieldOut) ; 
     137        void outputField(CArray<double,1>& fieldOut) ; 
    137138        void scaleFactorAddOffset(double scaleFactor, double addOffset) ; 
    138139        void parse(xml::CXMLNode & node) ; 
     
    156157 
    157158 
    158         const std::pair<StdString, StdString>& getDomainAxisIds(); 
     159//        const std::pair<StdString, StdString>& getDomainAxisIds(); 
    159160      public : 
    160161         /// Propriétés privées /// 
  • XIOS/trunk/src/node/file.cpp

    r561 r567  
    212212 
    213213      allDomainEmpty=true ; 
     214 
    214215      set<CDomain*> setDomain ; 
    215216 
     
    218219      { 
    219220         CField* field = *it; 
    220          allDomainEmpty&=field->grid->domain->isEmpty() ; 
    221          setDomain.insert(field->grid->domain) ; 
     221//         allDomainEmpty&=field->grid->domain->isEmpty() ; 
     222         allDomainEmpty&=(!field->grid->doGridHaveDataToWrite()); 
     223         std::vector<CDomain*> vecDomain = field->grid->getDomains(); 
     224         for (int i = 0; i < vecDomain.size(); ++i) 
     225            setDomain.insert(vecDomain[i]); 
     226//            setDomain.insert(field->grid->domain) ; 
    222227      } 
    223228      nbDomain=setDomain.size() ; 
     
    320325 
    321326        bool append = !this->append.isEmpty() && this->append.getValue(); 
    322          
     327 
    323328         bool useClassicFormat = !format.isEmpty() && format == format_attr::netcdf4_classic; 
    324329 
  • XIOS/trunk/src/node/grid.cpp

    r553 r567  
    2020   CGrid::CGrid(void) 
    2121      : CObjectTemplate<CGrid>(), CGridAttributes() 
    22       , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 
    23       , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 
     22      , isChecked(false), isDomainAxisChecked(false), storeIndex(1) 
    2423      , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 
    25       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_() 
     24      , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(), writtenDataSize_(0), globalDim_() 
    2625   { 
    2726     setVirtualDomainGroup(); 
     
    3130   CGrid::CGrid(const StdString & id) 
    3231      : CObjectTemplate<CGrid>(id), CGridAttributes() 
    33       , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 
    34       , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 
     32      , isChecked(false), isDomainAxisChecked(false), storeIndex(1) 
    3533      , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 
    36       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_() 
     34      , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(), writtenDataSize_(0), globalDim_() 
    3735   { 
    3836     setVirtualDomainGroup(); 
     
    4240   CGrid::~CGrid(void) 
    4341   { 
    44  //     this->axis.reset() ; 
    45 //      this->domain.reset() ; 
    4642    deque< CArray<int, 1>* >::iterator it ; 
    4743 
    4844    for(deque< CArray<int,1>* >::iterator it=storeIndex.begin(); it!=storeIndex.end();it++)  delete *it ; 
    49     for(deque< CArray<int,1>* >::iterator it=out_i_index.begin();it!=out_i_index.end();it++) delete *it ; 
    50     for(deque< CArray<int,1>* >::iterator it=out_j_index.begin();it!=out_j_index.end();it++) delete *it ; 
    51     for(deque< CArray<int,1>* >::iterator it=out_l_index.begin();it!=out_l_index.end();it++) delete *it ; 
    52  
    53     for(map<int,CArray<int,1>* >::iterator it=out_i_fromClient.begin();it!=out_i_fromClient.end();it++) delete it->second ; 
    54     for(map<int,CArray<int,1>* >::iterator it=out_j_fromClient.begin();it!=out_j_fromClient.end();it++) delete it->second ; 
    55     for(map<int,CArray<int,1>* >::iterator it=out_l_fromClient.begin();it!=out_l_fromClient.end();it++) delete it->second ; 
    56  
    5745    for(map<int,CArray<size_t,1>* >::iterator it=outIndexFromClient.begin();it!=outIndexFromClient.end();++it) delete (it->second); 
    5846 
     
    6048    if (0 != serverDistribution_) delete serverDistribution_; 
    6149    if (0 != serverDistributionDescription_) delete serverDistributionDescription_; 
    62  
    6350   } 
    6451 
     
    7764 
    7865   //--------------------------------------------------------------- 
    79  
    80    const std::deque< CArray<int,1>* > & CGrid::getOutIIndex(void)  const 
    81    { 
    82       return (this->out_i_index ); 
    83    } 
     66// 
     67//   const std::deque< CArray<int,1>* > & CGrid::getOutIIndex(void)  const 
     68//   { 
     69//      return (this->out_i_index ); 
     70//   } 
     71// 
     72//   //--------------------------------------------------------------- 
     73// 
     74//   const std::deque< CArray<int,1>* > & CGrid::getOutJIndex(void)  const 
     75//   { 
     76//      return (this->out_j_index ); 
     77//   } 
     78// 
     79//   //--------------------------------------------------------------- 
     80// 
     81//   const std::deque< CArray<int,1>* > & CGrid::getOutLIndex(void)  const 
     82//   { 
     83//      return (this->out_l_index ); 
     84//   } 
     85// 
     86//   //--------------------------------------------------------------- 
     87// 
     88//   const CAxis*   CGrid::getRelAxis  (void) const 
     89//   { 
     90//      return (this->axis ); 
     91//   } 
     92 
     93//   //--------------------------------------------------------------- 
     94// 
     95//   const CDomain* CGrid::getRelDomain(void) const 
     96//   { 
     97//      return (this->domain ); 
     98//   } 
    8499 
    85100   //--------------------------------------------------------------- 
    86101 
    87    const std::deque< CArray<int,1>* > & CGrid::getOutJIndex(void) const 
    88    { 
    89       return (this->out_j_index ); 
    90    } 
     102//   bool CGrid::hasAxis(void) const 
     103//   { 
     104//      return (this->withAxis); 
     105//   } 
    91106 
    92107   //--------------------------------------------------------------- 
    93108 
    94    const std::deque< CArray<int,1>* > & CGrid::getOutLIndex(void)  const 
    95    { 
    96       return (this->out_l_index ); 
    97    } 
    98  
    99    //--------------------------------------------------------------- 
    100  
    101    const CAxis*   CGrid::getRelAxis  (void) const 
    102    { 
    103       return (this->axis ); 
    104    } 
    105  
    106    //--------------------------------------------------------------- 
    107  
    108    const CDomain* CGrid::getRelDomain(void) const 
    109    { 
    110       return (this->domain ); 
    111    } 
    112  
    113    //--------------------------------------------------------------- 
    114  
    115    bool CGrid::hasAxis(void) const 
    116    { 
    117       return (this->withAxis); 
    118    } 
    119  
    120    //--------------------------------------------------------------- 
    121  
    122109   StdSize CGrid::getDimension(void) const 
    123110   { 
    124       return ((this->withAxis)?3:2); 
     111      return (globalDim_.size()); 
    125112   } 
    126113 
     
    176163   StdSize CGrid::getDataSize(void) const 
    177164   { 
    178       StdSize retvalue=domain->data_ni.getValue() ; 
    179       if (domain->data_dim.getValue()==2) retvalue*=domain->data_nj.getValue() ; 
    180       if (this->withAxis) retvalue*=this->axis->size.getValue() ; 
    181  
     165      std::vector<int> dataNindex = clientDistribution_->getDataNIndex(); 
     166      StdSize retvalue = 1; 
     167      for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i]; 
    182168      return (retvalue); 
    183169   } 
     
    201187 
    202188 
    203    //--------------------------------------------------------------- 
    204  
    205 //   void CGrid::solveReference(void) 
    206 //   { 
    207 //      if (this->isChecked) return; 
    208 //      CContext* context = CContext::getCurrent() ; 
    209 //      CContextClient* client=context->client ; 
    210 // 
    211 //      this->solveDomainRef() ; 
    212 //      this->solveAxisRef() ; 
    213 // 
    214 //      if (context->hasClient) 
    215 //      { 
    216 //         checkMask() ; 
    217 //         this->computeIndex() ; 
    218 // 
    219 //         this->storeIndex.push_front(new CArray<int,1>() ); 
    220 //         this->out_i_index.push_front(new CArray<int,1>()); 
    221 //         this->out_j_index.push_front(new CArray<int,1>()); 
    222 //         this->out_l_index.push_front(new CArray<int,1>()); 
    223 //      } 
    224 ////      this->computeIndexServer(); 
    225 //      this->isChecked = true; 
    226 //   } 
    227  
    228189   void CGrid::solveDomainAxisRef(bool areAttributesChecked) 
    229190   { 
     
    250211        checkMask() ; 
    251212        this->computeIndex() ; 
    252  
    253213        this->storeIndex.push_front(new CArray<int,1>() ); 
    254         this->out_i_index.push_front(new CArray<int,1>()); 
    255         this->out_j_index.push_front(new CArray<int,1>()); 
    256         this->out_l_index.push_front(new CArray<int,1>()); 
    257214     } 
    258 //      this->computeIndexServer(); 
    259215     this->isChecked = true; 
    260216   } 
    261217 
    262  
    263218   void CGrid::checkMask(void) 
    264219   { 
    265220      using namespace std; 
    266  
    267       unsigned int niu = domain->ni, nju = domain->nj; 
    268       unsigned int nlu = 1 ; 
    269       if (hasAxis()) nlu=axis->size ; 
    270  
    271       if (!mask.isEmpty()) 
    272       { 
    273          if ((mask.extent(0) != niu) || 
    274              (mask.extent(1) != nju) || 
    275              (mask.extent(2) != nlu)) 
    276              ERROR("CGrid::checkAttributes(void)", 
    277                   <<"The mask has not the same size than the local grid"<<endl 
    278                   <<"Local size is "<<niu<<"x"<<nju<<"x"<<nlu<<endl 
    279                   <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)<<"x"<<mask.extent(2)); 
    280       } 
    281       else 
    282       { 
    283         mask.resize(niu,nju,nlu) ; 
    284         mask=true  ; 
    285       } 
    286  
    287       CArray<bool,2>& domainMask = domain->mask ; 
    288       for (int l=0; l < nlu ; l++) 
    289         for (int j=0; j < nju ; j++) 
    290           for(int i=0; i<niu ; i++) mask(i,j,l) = mask(i,j,l) && domainMask(i,j) ; 
    291  
    292  
    293    } 
    294  
     221      std::vector<CDomain*> domainP = this->getDomains(); 
     222      std::vector<CAxis*> axisP = this->getAxis(); 
     223      int dim = domainP.size() * 2 + axisP.size(); 
     224 
     225      std::vector<CArray<bool,2>* > domainMasks(domainP.size()); 
     226      for (int i = 0; i < domainMasks.size(); ++i) domainMasks[i] = &(domainP[i]->mask); 
     227      std::vector<CArray<bool,1>* > axisMasks(axisP.size()); 
     228      for (int i = 0; i < axisMasks.size(); ++i) axisMasks[i] = &(axisP[i]->mask); 
     229 
     230      switch (dim) { 
     231        case 1: 
     232          checkGridMask(mask1, domainMasks, axisMasks, axisDomainOrder); 
     233          break; 
     234        case 2: 
     235          checkGridMask(mask2, domainMasks, axisMasks, axisDomainOrder); 
     236          break; 
     237        case 3: 
     238          checkGridMask(mask3, domainMasks, axisMasks, axisDomainOrder); 
     239          break; 
     240//        case 4: 
     241//          checkGridMask(mask4, domainMasks, axisMasks, axisDomainOrder); 
     242//          break; 
     243//        case 5: 
     244//          checkGridMask(mask5, domainMasks, axisMasks, axisDomainOrder); 
     245//          break; 
     246//        case 6: 
     247//          checkGridMask(mask6, domainMasks, axisMasks, axisDomainOrder); 
     248//          break; 
     249//        case 7: 
     250//          checkGridMask(mask7, domainMasks, axisMasks, axisDomainOrder); 
     251//          break; 
     252        default: 
     253          break; 
     254      } 
     255   } 
    295256   //--------------------------------------------------------------- 
    296257 
    297 //   void CGrid::solveDomainRef(void) 
    298 //   { 
    299 //      if (!domain_ref.isEmpty()) 
    300 //      { 
    301 //         if (CDomain::has(domain_ref.getValue())) 
    302 //         { 
    303 //            this->domain = CDomain::get(domain_ref.getValue()) ; 
    304 //            domain->checkAttributes() ; 
    305 //         } 
    306 //         else ERROR("CGrid::solveDomainRef(void)", 
    307 //                     << "Wrong domain reference") ; 
    308 //      } 
    309 //      else ERROR("CGrid::solveDomainRef(void)", 
    310 //                  << "Domain reference is not defined") ; 
    311 //   } 
    312 // 
    313 //   //--------------------------------------------------------------- 
    314 // 
    315 //   void CGrid::solveAxisRef(void) 
    316 //   { 
    317 //      if (!axis_ref.isEmpty()) 
    318 //      { 
    319 //         this->withAxis = true ; 
    320 //         if (CAxis::get(axis_ref.getValue())) 
    321 //         { 
    322 //            this->axis = CAxis::get(axis_ref.getValue()) ; 
    323 //            axis->checkAttributes() ; 
    324 //         } 
    325 //         else ERROR("CGrid::solveAxisRef(void)", 
    326 //                    << "Wrong axis reference") ; 
    327 //      } 
    328 //      else withAxis = false ; 
    329 //   } 
    330  
    331  
    332258   void CGrid::solveDomainRef(bool sendAtt) 
    333259   { 
    334 //      if (!domain_ref.isEmpty()) 
    335 //      { 
    336 //         if (CDomain::has(domain_ref.getValue())) 
    337 //         { 
    338 //            this->domain = CDomain::get(domain_ref.getValue()) ; 
    339 //            if (sendAtt) domain->sendCheckedAttributes(); 
    340 //            else domain->checkAttributesOnClient() ; 
    341 //         } 
    342 //         else ERROR("CGrid::solveDomainRef(void)", 
    343 //                     << "Wrong domain reference") ; 
    344 //      } 
    345 //      else ERROR("CGrid::solveDomainRef(void)", 
    346 //                  << "Domain reference is not defined") ; 
    347260      setDomainList(); 
    348       this->domain = CDomain::get(domList_.at(0)); 
    349       if (0 != this->domain) 
    350       { 
    351 //        this->domain = this->getDomain(); 
    352         if (sendAtt) domain->sendCheckedAttributes(); 
    353         else domain->checkAttributesOnClient() ; 
    354       } 
    355       else ERROR("CGrid::solveDomainRef(void)", 
    356                   << "Domain reference is not defined") ; 
     261      std::vector<CDomain*> domListP = this->getDomains(); 
     262      if (!domListP.empty()) 
     263      { 
     264        computeGridGlobalDimension(getDomains(), getAxis(), axisDomainOrder); 
     265        for (int i = 0; i < domListP.size(); ++i) 
     266        { 
     267          if (sendAtt) domListP[i]->sendCheckedAttributes(); 
     268          else domListP[i]->checkAttributesOnClient(); 
     269        } 
     270      } 
    357271   } 
    358272 
    359273   //--------------------------------------------------------------- 
    360274 
    361    void CGrid::solveAxisRef(bool checkAtt) 
    362    { 
    363 //      if (!axis_ref.isEmpty()) 
    364 //      { 
    365 //         this->withAxis = true ; 
    366 //         if (CAxis::get(axis_ref.getValue())) 
    367 //         { 
    368 //            this->axis = CAxis::get(axis_ref.getValue()) ; 
    369 //            axis->checkAttributes() ; 
    370 //         } 
    371 //         else ERROR("CGrid::solveAxisRef(void)", 
    372 //                    << "Wrong axis reference") ; 
    373 //      } 
    374 //      else withAxis = false ; 
    375 //      getAllAxis(); 
     275   void CGrid::solveAxisRef(bool sendAtt) 
     276   { 
    376277      setAxisList(); 
    377       if (!axisList_.empty()) 
    378       { 
    379         int sizeList = axisList_.size(); 
    380         for (int i = 0; i < sizeList; ++i) 
     278      std::vector<CAxis*> axisListP = this->getAxis(); 
     279      if (!axisListP.empty()) 
     280      { 
     281        int idx = 0; 
     282        computeGridGlobalDimension(getDomains(), getAxis(), axisDomainOrder); 
     283        for (int i = 0; i < axisListP.size(); ++i) 
    381284        { 
    382           CAxis::get(axisList_.at(i))->checkAttributes(); 
    383           this->axis = CAxis::get(axisList_.at(i)); 
     285          while (this->axisDomainOrder(idx)) idx += 2; 
     286          if (sendAtt) 
     287            axisListP[i]->sendCheckedAttributes(globalDim_,idx); 
     288          else 
     289            axisListP[i]->checkAttributesOnClient(globalDim_,idx); 
     290          ++idx; 
    384291        } 
    385         withAxis = true; 
    386  
    387       } 
    388 //      if (!axis_ref.isEmpty()) 
    389 //      { 
    390 //         this->withAxis = true ; 
    391 //         if (CAxis::get(axis_ref.getValue())) 
    392 //         { 
    393 //            this->axis = CAxis::get(axis_ref.getValue()) ; 
    394 //            axis->checkAttributes() ; 
    395 //         } 
    396 //         else ERROR("CGrid::solveAxisRef(void)", 
    397 //                    << "Wrong axis reference") ; 
    398 //      } 
    399       else withAxis = false ; 
     292 
     293      } 
    400294   } 
    401295 
     
    415309 
    416310     // Finally, compute index mapping between client(s) and server(s) 
    417      clientServerMap_.computeServerIndexMapping(clientDistribution_->getGlobalIndex(),serverDistributionDescription_->getGlobalIndex()); 
     311     clientServerMap_.computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 
     312                                                clientDistribution_->getLocalDataIndexSendToServerOnClient(), 
     313                                                serverDistributionDescription_->getGlobalIndex()); 
    418314     const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_.getGlobalIndexOnServer(); 
    419315     std::vector<int> connectedServerRank; 
     
    427323     storeIndex_client = (clientDistribution_->getLocalDataIndexOnClient()); 
    428324 
    429 /* 
    430       const int ni   = domain->ni.getValue() , 
    431                 nj   = domain->nj.getValue() , 
    432                 size = (this->hasAxis()) ? axis->size.getValue() : 1 , 
    433                 lbegin = (this->hasAxis()) ? axis->zoom_begin.getValue()-1 : 0 , 
    434                 lend = (this->hasAxis()) ? axis->zoom_end.getValue()-1 : 0 ; 
    435  
    436  
    437       const int data_dim     = domain->data_dim.getValue() , 
    438                 data_n_index = domain->data_n_index.getValue() , 
    439                 data_ibegin  = domain->data_ibegin.getValue() , 
    440                 data_jbegin  = (data_dim == 2) 
    441                              ? domain->data_jbegin.getValue() : -1; 
    442  
    443       CArray<int,1> data_i_index = domain->data_i_index ; 
    444       CArray<int,1> data_j_index = domain->data_j_index ; 
    445  
    446  
    447       int indexCount = 0; 
    448  
    449       for(int l = 0; l < size ; l++) 
    450       { 
    451          for(int n = 0, i = 0, j = 0; n < data_n_index; n++) 
    452          { 
    453             int temp_i = data_i_index(n) + data_ibegin, 
    454                 temp_j = (data_dim == 1) ? -1 
    455                        : data_j_index(n) + data_jbegin; 
    456             i = (data_dim == 1) ? (temp_i - 1) % ni 
    457                                 : (temp_i - 1) ; 
    458             j = (data_dim == 1) ? (temp_i - 1) / ni 
    459                                 : (temp_j - 1) ; 
    460  
    461             if ((l >=lbegin && l<= lend) && 
    462                 (i >= 0 && i < ni) && 
    463                 (j >= 0 && j < nj) && mask(i,j,l)) 
    464                indexCount++ ; 
    465          } 
    466       } 
    467  
    468       storeIndex[0]  = new CArray<int,1>(indexCount) ; 
    469       out_i_index[0] = new CArray<int,1>(indexCount) ; 
    470       out_j_index[0] = new CArray<int,1>(indexCount) ; 
    471       out_l_index[0] = new CArray<int,1>(indexCount) ; 
    472  
    473       storeIndex_client.resize(indexCount) ; 
    474       out_i_client.resize(indexCount) ; 
    475       out_j_client.resize(indexCount) ; 
    476       out_l_client.resize(indexCount) ; 
    477  
    478  
    479       for(int count = 0, indexCount = 0,  l = 0; l < size; l++) 
    480       { 
    481          for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 
    482          { 
    483             int temp_i = data_i_index(n) + data_ibegin, 
    484                 temp_j = (data_dim == 1) ? -1 
    485                        : data_j_index(n) + data_jbegin; 
    486             i = (data_dim == 1) ? (temp_i - 1) % ni 
    487                                 : (temp_i - 1) ; 
    488             j = (data_dim == 1) ? (temp_i - 1) / ni 
    489                                 : (temp_j - 1) ; 
    490  
    491             if ((l >= lbegin && l <= lend) && 
    492                 (i >= 0 && i < ni) && 
    493                 (j >= 0 && j < nj) && mask(i,j,l)) 
    494             { 
    495                (*storeIndex[0])(indexCount) = count ; 
    496                (*out_l_index[0])(indexCount) = l ; 
    497                (*out_i_index[0])(indexCount) = i ; 
    498                (*out_j_index[0])(indexCount) = j ; 
    499  
    500                storeIndex_client(indexCount) = count ; 
    501                out_i_client(indexCount)=i+domain->ibegin_client-1 ; 
    502                out_j_client(indexCount)=j+domain->jbegin_client-1 ; 
    503                out_l_client(indexCount)=l-lbegin ; 
    504                indexCount++ ; 
    505             } 
    506          } 
    507       } 
    508 */ 
    509 //      computeDomConServer(); 
    510 //      sendIndex() ; 
    511  
    512  
    513325   } 
    514326 
     
    517329   CGrid* CGrid::createGrid(CDomain* domain) 
    518330   { 
    519       StdString new_id = StdString("__") + domain->getId() + StdString("__") ; 
    520       CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ; 
    521  
    522331      std::vector<CDomain*> vecDom(1,domain); 
    523       grid->setDomainList(vecDom); 
    524 //      grid->domain_ref.setValue(domain->getId()); 
     332      std::vector<CAxis*> vecAxis; 
     333 
     334      CGrid* grid = createGrid(vecDom, vecAxis); 
     335 
    525336      return (grid); 
    526337   } 
     
    528339   CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis) 
    529340   { 
    530       StdString new_id = StdString("__") + domain->getId() + 
    531                          StdString("_") + axis->getId() + StdString("__") ; 
    532       CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ; 
    533  
    534341      std::vector<CDomain*> vecDom(1,domain); 
    535342      std::vector<CAxis*> vecAxis(1,axis); 
    536       grid->setDomainList(vecDom); 
    537       grid->setAxisList(vecAxis); 
    538 //      grid->domain_ref.setValue(domain->getId()); 
    539 //      grid->axis_ref.setValue(axis->getId()); 
     343      CGrid* grid = createGrid(vecDom, vecAxis); 
     344 
    540345      return (grid); 
    541346   } 
     
    564369      } 
    565370 
     371      grid->computeGridGlobalDimension(domains, axis, grid->axisDomainOrder); 
     372 
    566373      return (grid); 
    567374   } 
     
    575382   { 
    576383     return (this->vAxisGroup_); 
    577    } 
    578  
    579    //---------------------------------------------------------------- 
    580  
    581    void CGrid::outputField(int rank, const CArray<double, 1>& stored,  CArray<double, 3>& field) 
    582    { 
    583       CArray<int,1>& out_i=*out_i_fromClient[rank] ; 
    584       CArray<int,1>& out_j=*out_j_fromClient[rank] ; 
    585       CArray<int,1>& out_l=*out_l_fromClient[rank] ; 
    586  
    587       for(StdSize n = 0; n < stored.numElements(); n++) 
    588          field(out_i(n), out_j(n), out_l(n)) = stored(n) ; 
    589    } 
    590  
    591    void CGrid::outputField(int rank, const CArray<double, 1>& stored,  CArray<double, 2>& field) 
    592    { 
    593       CArray<int,1>& out_i=*out_i_fromClient[rank] ; 
    594       CArray<int,1>& out_j=*out_j_fromClient[rank] ; 
    595  
    596       for(StdSize n = 0; n < stored.numElements(); n++) 
    597          field(out_i(n), out_j(n)) = stored(n) ;   } 
    598  
    599    //--------------------------------------------------------------- 
    600  
    601    void CGrid::outputField(int rank,const CArray<double, 1>& stored,  CArray<double, 1>& field) 
    602    { 
    603       CArray<int,1>& out_i=*out_i_fromClient[rank] ; 
    604  
    605       for(StdSize n = 0; n < stored.numElements(); n++) 
    606          field(out_i(n)) = stored(n) ; 
    607384   } 
    608385 
     
    629406   } 
    630407 
    631    //--------------------------------------------------------------- 
    632  
    633 //  void CGrid::sendIndex(void) 
    634 //  { 
    635 //    CContext* context = CContext::getCurrent() ; 
    636 //    CContextClient* client=context->client ; 
    637 // 
    638 //    CEventClient event(getType(),EVENT_ID_INDEX) ; 
    639 //    int rank ; 
    640 //    list<shared_ptr<CMessage> > list_msg ; 
    641 //    list< CArray<int,1>* > list_out_i,list_out_j,list_out_l ; 
    642 // 
    643 //    for(int ns=0;ns<domain->connectedServer.size();ns++) 
    644 //    { 
    645 //       rank=domain->connectedServer[ns] ; 
    646 // 
    647 //       int i,j ; 
    648 //       int nb=0 ; 
    649 //       for(int k=0;k<storeIndex_client.numElements();k++) 
    650 //       { 
    651 //         i=out_i_client(k)- domain->ibegin +1; 
    652 //         j=out_j_client(k)- domain->jbegin +1; 
    653 //         if (domain->mapConnectedServer(i,j)==ns)  nb++ ; 
    654 //       } 
    655 //       CArray<int,1> storeIndex(nb) ; 
    656 //       CArray<int,1> out_i(nb) ; 
    657 //       CArray<int,1> out_j(nb) ; 
    658 //       CArray<int,1> out_l(nb) ; 
    659 // 
    660 // 
    661 //       nb=0 ; 
    662 //       for(int k=0;k<storeIndex_client.numElements();k++) 
    663 //       { 
    664 //         i=out_i_client(k)- domain->ibegin +1 ; 
    665 //         j=out_j_client(k)- domain->jbegin +1 ; 
    666 //         if (domain->mapConnectedServer(i,j)==ns) 
    667 //         { 
    668 //            storeIndex(nb)=k ; 
    669 //            out_i(nb)=domain->i_index(i,j) + domain->ibegin-1; 
    670 //            out_j(nb)=domain->j_index(i,j) + domain->jbegin-1; 
    671 //            out_l(nb)=out_l_client(k) ; 
    672 //            nb++ ; 
    673 //         } 
    674 //       } 
    675 // 
    676 //       storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(storeIndex) )) ; 
    677 //       nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; 
    678 //       list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    679 //       list_out_i.push_back(new CArray<int,1>(out_i)) ; 
    680 //       list_out_j.push_back(new CArray<int,1>(out_j)) ; 
    681 //       list_out_l.push_back(new CArray<int,1>(out_l)) ; 
    682 // 
    683 //       *list_msg.back()<<getId()<<*list_out_i.back()<<*list_out_j.back()<<*list_out_l.back() ; 
    684 //       event.push(rank,domain->nbSenders[ns],*list_msg.back()) ; 
    685 //    } 
    686 //    client->sendEvent(event) ; 
    687 // 
    688 //    for(list<CArray<int,1>* >::iterator it=list_out_i.begin();it!=list_out_i.end();it++) delete *it ; 
    689 //    for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 
    690 //    for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 
    691 // 
    692 //  } 
    693  
    694   void CGrid::computeDomConServer() 
    695   { 
    696     if (!isDomConServerComputed_) 
    697     { 
    698       for(int ns=0;ns<domain->connectedServer.size(); ++ns) 
    699       { 
    700          int rank=domain->connectedServer[ns] ; 
    701  
    702          int i,j ; 
    703          int nb=0 ; 
    704          for(int k=0;k<storeIndex_client.numElements();++k) 
    705          { 
    706            i=out_i_client(k)- domain->ibegin +1; 
    707            j=out_j_client(k)- domain->jbegin +1; 
    708            if (domain->mapConnectedServer(i,j)==ns)  ++nb ; 
    709          } 
    710  
    711          domConnectedServerSide_.insert(std::make_pair(rank, nb)); 
    712       } 
    713       isDomConServerComputed_ = true; 
    714     } 
    715   } 
    716  
    717  
    718   std::map<int, int> CGrid::getDomConServerSide() 
    719   { 
    720     return domConnectedServerSide_; 
    721   } 
    722  
    723408  void CGrid::sendIndex(void) 
    724409  { 
     
    739424    itLocal = localIndexSendToServer.begin(); 
    740425 
    741     for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 
    742     { 
    743       rank = itGlobal->first; 
    744       int nb = (itGlobal->second).size(); 
    745  
    746       CArray<size_t, 1> outGlobalIndexOnServer(nb); 
    747       CArray<int, 1> outLocalIndexToServer(nb); 
    748       for (int k = 0; k < nb; ++k) 
    749       { 
    750         outGlobalIndexOnServer(k) = itGlobal->second.at(k); 
    751         outLocalIndexToServer(k)  = itLocal->second.at(k); 
    752       } 
    753  
    754       storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 
    755       listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 
    756  
    757       list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
    758       *list_msg.back()<<getId()<<*listOutIndex.back(); 
    759       event.push(rank, nbSenders[rank], *list_msg.back()); 
    760     } 
    761     client->sendEvent(event); 
     426    if (!doGridHaveDataDistributed()) 
     427    { 
     428      if (0 == client->getClientRank()) 
     429      { 
     430       for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 
     431        { 
     432          rank = itGlobal->first; 
     433          int nb = (itGlobal->second).size(); 
     434 
     435          CArray<size_t, 1> outGlobalIndexOnServer(nb); 
     436          CArray<int, 1> outLocalIndexToServer(nb); 
     437          for (int k = 0; k < nb; ++k) 
     438          { 
     439            outGlobalIndexOnServer(k) = itGlobal->second.at(k); 
     440            outLocalIndexToServer(k)  = itLocal->second.at(k); 
     441          } 
     442 
     443          storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 
     444          listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 
     445 
     446          list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
     447          *list_msg.back()<<getId()<<*listOutIndex.back(); 
     448          event.push(rank, 1, *list_msg.back()); 
     449        } 
     450        client->sendEvent(event); 
     451      } else client->sendEvent(event); 
     452    } 
     453    else 
     454    { 
     455      for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 
     456      { 
     457        rank = itGlobal->first; 
     458        int nb = (itGlobal->second).size(); 
     459 
     460        CArray<size_t, 1> outGlobalIndexOnServer(nb); 
     461        CArray<int, 1> outLocalIndexToServer(nb); 
     462        for (int k = 0; k < nb; ++k) 
     463        { 
     464          outGlobalIndexOnServer(k) = itGlobal->second.at(k); 
     465          outLocalIndexToServer(k)  = itLocal->second.at(k); 
     466        } 
     467 
     468        storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 
     469        listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 
     470 
     471        list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
     472        *list_msg.back()<<getId()<<*listOutIndex.back(); 
     473        event.push(rank, nbSenders[rank], *list_msg.back()); 
     474      } 
     475      client->sendEvent(event); 
     476    } 
     477 
    762478    for(list<CArray<size_t,1>* >::iterator it=listOutIndex.begin();it!=listOutIndex.end();++it) delete *it ; 
    763  
    764 /* 
    765     if (!isDomConServerComputed_) computeDomConServer(); 
    766  
    767     for(int ns=0;ns<domain->connectedServer.size();ns++) 
    768     { 
    769        rank=domain->connectedServer[ns] ; 
    770  
    771        int nb = domConnectedServerSide_.find(rank)->second; 
    772        CArray<int,1> storeIndex(nb) ; 
    773        CArray<int,1> out_i(nb) ; 
    774        CArray<int,1> out_j(nb) ; 
    775        CArray<int,1> out_l(nb) ; 
    776  
    777        int i, j; 
    778        nb=0 ; 
    779        for(int k=0;k<storeIndex_client.numElements();k++) 
    780        { 
    781          i=out_i_client(k)- domain->ibegin +1 ; 
    782          j=out_j_client(k)- domain->jbegin +1 ; 
    783          if (domain->mapConnectedServer(i,j)==ns) 
    784          { 
    785             storeIndex(nb)=k ; 
    786             out_i(nb)=domain->i_index(i,j) + domain->ibegin-1; 
    787             out_j(nb)=domain->j_index(i,j) + domain->jbegin-1; 
    788             out_l(nb)=out_l_client(k) ; 
    789             nb++ ; 
    790          } 
    791        } 
    792  
    793        storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(storeIndex) )) ; 
    794        nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; 
    795        list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    796        list_out_i.push_back(new CArray<int,1>(out_i)) ; 
    797        list_out_j.push_back(new CArray<int,1>(out_j)) ; 
    798        list_out_l.push_back(new CArray<int,1>(out_l)) ; 
    799  
    800        *list_msg.back()<<getId()<<*list_out_i.back()<<*list_out_j.back()<<*list_out_l.back() ; 
    801        event.push(rank,domain->nbSenders[ns],*list_msg.back()) ; 
    802     } 
    803     client->sendEvent(event) ; 
    804  
    805     for(list<CArray<int,1>* >::iterator it=list_out_i.begin();it!=list_out_i.end();it++) delete *it ; 
    806     for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 
    807     for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 
    808 */ 
    809479  } 
    810480 
     
    820490      get(gridId)->recvIndex(rank,*buffer) ; 
    821491    } 
     492  } 
     493 
     494  void CGrid::computeGridGlobalDimension(const std::vector<CDomain*>& domains, 
     495                                         const std::vector<CAxis*>& axis, 
     496                                         const CArray<bool,1>& axisDomainOrder) 
     497  { 
     498    globalDim_.resize(domains.size()*2+axis.size()); 
     499    int idx = 0, idxDomain = 0, idxAxis = 0; 
     500    for (int i = 0; i < axisDomainOrder.numElements(); ++i) 
     501    { 
     502      if (axisDomainOrder(i)) 
     503      { 
     504        globalDim_[idx]   = domains[idxDomain]->ni_glo.getValue(); 
     505        globalDim_[idx+1] = domains[idxDomain]->nj_glo.getValue(); 
     506        ++idxDomain; 
     507        idx += 2; 
     508      } 
     509      else 
     510      { 
     511        globalDim_[idx] = axis[idxAxis]->size.getValue(); 
     512        ++idxAxis; 
     513        ++idx; 
     514      } 
     515    } 
     516  } 
     517 
     518  std::vector<int> CGrid::getGlobalDimension() 
     519  { 
     520    return globalDim_; 
     521  } 
     522 
     523  /*! 
     524    Verify whether one server need to write data 
     525    There are some cases on which one server has nodata to write. For example, when we 
     526  just only want to zoom on a domain. 
     527  */ 
     528  bool CGrid::doGridHaveDataToWrite() 
     529  { 
     530    return (0 != serverDistribution_); 
     531  } 
     532 
     533  /*! 
     534    Return size of data which is written on each server 
     535    Whatever dimension of a grid, data which are written on server must be presented as 
     536  an one dimension array. 
     537  \return size of data written on server 
     538  */ 
     539  size_t CGrid::getWrittenDataSize() const 
     540  { 
     541    return writtenDataSize_; 
     542  } 
     543 
     544 
     545  const CDistributionServer* CGrid::getDistributionServer() const 
     546  { 
     547    return serverDistribution_; 
     548  } 
     549 
     550  bool CGrid::doGridHaveDataDistributed() 
     551  { 
     552    return clientDistribution_->isDataDistributed(); 
    822553  } 
    823554 
     
    835566         indexMap[i] = idx; 
    836567         if (true == axisDomainOrder(i)) 
    837         { 
    838           ++ssize; 
    839           idx += 2; 
    840         } 
     568         { 
     569            ++ssize; 
     570            idx += 2; 
     571         } 
     572         else 
     573          ++idx; 
    841574       } 
    842575 
     
    844577       std::vector<CDomain*> domainList = getDomains(); 
    845578       std::vector<CAxis*> axisList = getAxis(); 
    846        std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize); 
     579       std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize); 
    847580       for (int i = 0; i < numElement; ++i) 
    848581       { 
     
    851584            nZoomBegin[indexMap[i]]   = domainList[domainId]->zoom_ibegin_srv; 
    852585            nZoomSize[indexMap[i]]    = domainList[domainId]->zoom_ni_srv; 
     586            nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->zoom_ibegin; 
    853587            nGlob[indexMap[i]]    = domainList[domainId]->ni_glo; 
    854588 
    855589            nZoomBegin[indexMap[i]+1] = domainList[domainId]->zoom_jbegin_srv; 
    856590            nZoomSize[indexMap[i]+1]  = domainList[domainId]->zoom_nj_srv; 
     591            nZoomBeginGlobal[indexMap[i]+1] = domainList[domainId]->zoom_jbegin; 
    857592            nGlob[indexMap[i]+1]    = domainList[domainId]->nj_glo; 
    858593            ++domainId; 
     
    860595         else 
    861596         { 
    862             nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin; 
    863             nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_size; 
     597            nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin_srv; 
     598            nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_size_srv; 
     599            nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->zoom_begin; 
    864600            nGlob[indexMap[i]]      = axisList[axisId]->size; 
    865601            ++axisId; 
    866602         } 
    867603       } 
    868        serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, nGlob); 
     604       writtenDataSize_ = 1; 
     605       for (int i = 0; i < nZoomSize.size(); ++i) 
     606        writtenDataSize_ *= nZoomSize[i]; 
     607 
     608       serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
     609                                                     nZoomBeginGlobal, nGlob); 
    869610     } 
    870611 
     
    873614     serverDistribution_->computeLocalIndex(outIndex); 
    874615     outIndexFromClient.insert(std::pair<int, CArray<size_t,1>* >(rank, new CArray<size_t,1>(outIndex))); 
    875  
    876     /* 
    877     CArray<int,1> out_i ; 
    878     CArray<int,1> out_j ; 
    879     CArray<int,1> out_l ; 
    880  
    881     buffer>>out_i>>out_j>>out_l ; 
    882  
    883     out_i -= domain->zoom_ibegin_srv-1 ; 
    884     out_j -= domain->zoom_jbegin_srv-1 ; 
    885  
    886     out_i_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_i) )) ; 
    887     out_j_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_j) )) ; 
    888     out_l_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_l) )) ; 
    889     */ 
    890616  } 
    891617 
     
    1240966  { 
    1241967    SuperClass::parse(node); 
     968 
    1242969    // List order of axis and domain in a grid, if there is a domain, it will take value 1 (true), axis 0 (false) 
    1243 //    std::vector<int> axisOrder; 
    1244970    std::vector<bool> order; 
    1245971 
  • XIOS/trunk/src/node/grid.hpp

    r553 r567  
    1515#include "server_distribution_description.hpp" 
    1616#include "client_server_mapping.hpp" 
     17#include "utils.hpp" 
    1718 
    1819namespace xios { 
     
    133134         void computeIndexServer(void); 
    134135         void computeIndex(void); 
    135 //         void solveDomainRef(void);  //TODO temporarily comment 
    136 //         void solveAxisRef(void);   // TODO: temporarily comment 
    137136 
    138137         void solveDomainRef(bool checkAtt); 
     
    164163         std::vector<CAxis*> getAxis(); 
    165164         std::vector<int> getAxisOrder(); 
     165         std::vector<int> getGlobalDimension(); 
     166 
     167         bool doGridHaveDataToWrite(); 
     168         bool doGridHaveDataDistributed(); 
     169         size_t getWrittenDataSize() const; 
     170 
     171         const CDistributionServer* getDistributionServer() const; 
    166172 
    167173      public: 
    168174 
    169175         /// Propriétés privées /// 
    170          bool withAxis ; 
    171176         bool isChecked; 
    172177         bool isDomainAxisChecked; 
    173178         bool isIndexSent; 
    174179 
    175          CAxis*   axis ; 
    176          CDomain* domain ; 
    177  
    178180         std::deque< CArray<int, 1>* > storeIndex ; 
    179          std::deque< CArray<int, 1>* > out_i_index ; 
    180          std::deque< CArray<int, 1>* > out_j_index ; 
    181          std::deque< CArray<int, 1>* > out_l_index ; 
    182  
    183181        CArray<int, 1>  storeIndex_client ; 
    184         CArray<int, 1>  out_i_client ; 
    185         CArray<int, 1>  out_j_client ; 
    186         CArray<int, 1>  out_l_client ; 
     182 
    187183 
    188184         map<int, CArray<int, 1>* >  storeIndex_toSrv ; 
    189185         map<int,int> nbSenders ; 
    190 //         std::deque<ARRAY(int, 1)> out_i_toSrv ; 
    191 //         std::deque<ARRAY(int, 1)> out_j_toSrv ; 
    192 //         std::deque<ARRAY(int, 1)> out_l_toSrv ; 
    193  
    194          map<int, CArray<int, 1>* > out_i_fromClient ; 
    195          map<int, CArray<int, 1>* > out_j_fromClient ; 
    196          map<int, CArray<int, 1>* > out_l_fromClient ; 
    197186 
    198187         map<int, CArray<size_t, 1>* > outIndexFromClient; 
    199188         void checkMask(void) ; 
    200189 
    201          std::map<int, int> domConnectedServerSide_; 
    202          bool isDomConServerComputed_; 
    203  
    204190      private: 
     191       template<int N> 
     192       void checkGridMask(CArray<bool,N>& gridMask, 
     193                          const std::vector<CArray<bool,2>* >& domainMasks, 
     194                          const std::vector<CArray<bool,1>* >& axisMasks, 
     195                          const CArray<bool,1>& axisDomainOrder); 
    205196        void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); 
    206197        void setVirtualDomainGroup(); 
    207198        void setVirtualAxisGroup(CAxisGroup* newVAxisGroup); 
    208199        void setVirtualAxisGroup(); 
    209 //        void setAxisList(); 
     200 
    210201        void setAxisList(const std::vector<CAxis*> axis = std::vector<CAxis*>()); 
    211 //        void setDomainList(); 
    212202        void setDomainList(const std::vector<CDomain*> domains = std::vector<CDomain*>()); 
     203 
     204        void computeGridGlobalDimension(const std::vector<CDomain*>& domains, 
     205                                        const std::vector<CAxis*>& axis, 
     206                                        const CArray<bool,1>& axisDomainOrder); 
    213207 
    214208        CDomain* addDomain(const std::string& id); 
     
    217211        CAxisGroup* getVirtualAxisGroup() const; 
    218212        CDomainGroup* getVirtualDomainGroup() const; 
     213        std::vector<int> globalDim_; 
    219214      private: 
    220215        CDomainGroup* vDomainGroup_; 
     
    222217        std::vector<std::string> axisList_, domList_; 
    223218        bool isAxisListSet, isDomListSet; 
     219 
    224220        CDistributionClient* clientDistribution_; 
    225221        CDistributionServer* serverDistribution_; 
    226222        CServerDistributionDescription* serverDistributionDescription_; 
    227223        CClientServerMapping clientServerMap_; 
     224        size_t writtenDataSize_; 
    228225   }; // class CGrid 
    229226 
     
    231228 
    232229   template <int n> 
    233       void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 
     230   void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 
    234231   { 
    235232      if (this->getDataSize() != field.numElements()) 
     
    241238   } 
    242239 
     240   template<int N> 
     241   void CGrid::checkGridMask(CArray<bool,N>& gridMask, 
     242                             const std::vector<CArray<bool,2>* >& domainMasks, 
     243                             const std::vector<CArray<bool,1>* >& axisMasks, 
     244                             const CArray<bool,1>& axisDomainOrder) 
     245   { 
     246     int idx = 0; 
     247     int numElement = axisDomainOrder.numElements(); 
     248     int dim = domainMasks.size()*2 + axisMasks.size(); 
     249 
     250     std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 
     251     std::vector<int> currentIndex(dim); 
     252     int idxDomain = 0, idxAxis = 0; 
     253    for (int i = 0; i < numElement; ++i) 
     254    { 
     255      indexMap[i] = idx; 
     256      if (true == axisDomainOrder(i)) { 
     257          eachDimSize[indexMap[i]]   = domainMasks[idxDomain]->extent(0); 
     258          eachDimSize[indexMap[i]+1] = domainMasks[idxDomain]->extent(1); 
     259          idx += 2; ++idxDomain; 
     260      } 
     261      else { 
     262        eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); 
     263        ++idx; ++idxAxis; 
     264      } 
     265    } 
     266 
     267    if (!gridMask.isEmpty()) 
     268    { 
     269      for (int i = 0; i < dim; ++i) 
     270      { 
     271        if (gridMask.extent(i) != eachDimSize[i]) 
     272           ERROR("CGrid::checkMask(void)", 
     273                <<"The mask has one dimension whose size is different from the one of the local grid"<<endl 
     274                <<"Local size is "<< i << " " << eachDimSize[i]<<endl 
     275                <<"Mask dimension size is "<<gridMask.extent(i)); 
     276      } 
     277    } 
     278    else { 
     279        CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 
     280        gridMask = true; 
     281    } 
     282 
     283    int ssize = gridMask.numElements(); 
     284    idx = 0; 
     285    while (idx < ssize) 
     286    { 
     287      for (int i = 0; i < dim-1; ++i) 
     288      { 
     289        if (idxLoop[i] == eachDimSize[i]) 
     290        { 
     291          idxLoop[i] = 0; 
     292          ++idxLoop[i+1]; 
     293        } 
     294      } 
     295 
     296      // Find out outer index 
     297      idxDomain = idxAxis = 0; 
     298      bool maskValue = true; 
     299      for (int i = 0; i < numElement; ++i) 
     300      { 
     301        if (axisDomainOrder(i)) 
     302        { 
     303          maskValue = maskValue && (*domainMasks[idxDomain])(idxLoop[indexMap[i]], 
     304                                                          idxLoop[indexMap[i]+1]); 
     305          ++idxDomain; 
     306        } 
     307        else 
     308        { 
     309          maskValue = maskValue && (*axisMasks[idxAxis])(idxLoop[indexMap[i]]); 
     310          ++idxAxis; 
     311        } 
     312      } 
     313 
     314      int maskIndex = idxLoop[0]; 
     315      int mulDim = 1; 
     316      for (int k = 1; k < dim; ++k) 
     317      { 
     318        mulDim *= eachDimSize[k-1]; 
     319        maskIndex += idxLoop[k]*mulDim; 
     320      } 
     321      *(gridMask.dataFirst()+maskIndex) = maskValue; 
     322 
     323      ++idxLoop[0]; 
     324      ++idx; 
     325    } 
     326 
     327   } 
     328 
    243329   ///-------------------------------------------------------------- 
    244330 
  • XIOS/trunk/src/output/nc4_data_output.cpp

    r544 r567  
    483483         if (axis->IsWritten(this->filename)) return; 
    484484         axis->checkAttributes(); 
    485          StdSize zoom_size=axis->zoom_size.getValue() ; 
    486          StdSize zoom_begin=axis->zoom_begin.getValue()-1 ; 
     485         StdSize zoom_size_srv=axis->zoom_size_srv; 
     486         StdSize zoom_begin_srv=axis->zoom_begin_srv; 
    487487 
    488488 
     
    492492         try 
    493493         { 
    494            SuperClassWriter::addDimension(axisid, zoom_size); 
     494           SuperClassWriter::addDimension(axisid, zoom_size_srv); 
    495495           dims.push_back(axisid); 
    496496 
     
    527527                 SuperClassWriter::definition_end(); 
    528528 
    529                  CArray<double,1> axis_value(zoom_size) ; 
    530                  for(StdSize i = 0 ; i < zoom_size ; i++) axis_value(i)=axis->value(i+zoom_begin) ; 
     529                 CArray<double,1> axis_value(zoom_size_srv) ; 
     530                 for(StdSize i = 0 ; i < zoom_size_srv ; i++) axis_value(i)=axis->value(i+zoom_begin_srv) ; 
    531531                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    532532 
     
    580580         std::vector<StdString> dims, coodinates; 
    581581         CGrid* grid = field->grid; 
    582          CDomain* domain = grid->domain; 
    583  
    584          if (domain->isEmpty()) 
    585            if (SuperClass::type==MULTI_FILE) return ; 
    586  
    587          StdString timeid    = StdString("time_counter"); 
    588          StdString domid     = (!domain->name.isEmpty()) 
    589                              ? domain->name.getValue() : domain->getId(); 
    590          StdString appendDomid  = (singleDomain) ? "" : "_"+domid ; 
    591  
    592 //         bool isCurvilinear = domain->isCurvilinear ; 
    593 //         bool isCurvilinear = (domain->type == CDomain::type_attr::curvilinear) ; 
    594  
    595          StdString dimXid,dimYid ; 
    596  
    597          switch (domain->type) 
    598          { 
    599            case CDomain::type_attr::curvilinear : 
    600              dimXid     = StdString("x").append(appendDomid); 
    601              dimYid     = StdString("y").append(appendDomid); 
    602              break ; 
    603            case CDomain::type_attr::regular : 
    604              dimXid     = StdString("lon").append(appendDomid); 
    605              dimYid     = StdString("lat").append(appendDomid); 
    606              break ; 
    607            case CDomain::type_attr::unstructured : 
    608              dimXid     = StdString("cell").append(appendDomid); 
    609              break ; 
    610         } 
     582         if (!grid->doGridHaveDataToWrite()) 
     583          if (SuperClass::type==MULTI_FILE) return ; 
     584 
     585         CArray<bool,1> axisDomainOrder = grid->axisDomainOrder; 
     586         int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0; 
     587         std::vector<StdString> domainList = grid->getDomainList(); 
     588         std::vector<StdString> axisList   = grid->getAxisList(); 
     589 
     590         StdString timeid  = StdString("time_counter"); 
     591         StdString dimXid,dimYid; 
     592         std::deque<StdString> dimIdList, dimCoordList; 
     593 
     594         for (int i = 0; i < numElement; ++i) 
     595         { 
     596           if (axisDomainOrder(i)) 
     597           { 
     598             CDomain* domain = CDomain::get(domainList[idxDomain]); 
     599             StdString domid = (!domain->name.isEmpty()) 
     600                                 ? domain->name.getValue() : domain->getId(); 
     601             StdString appendDomid  = (singleDomain) ? "" : "_"+domid ; 
     602             switch (domain->type) 
     603             { 
     604               case CDomain::type_attr::curvilinear : 
     605                 dimXid     = StdString("x").append(appendDomid); 
     606                 dimIdList.push_back(dimXid); 
     607                 dimYid     = StdString("y").append(appendDomid); 
     608                 dimIdList.push_back(dimYid); 
     609                 dimCoordList.push_back(StdString("nav_lon").append(appendDomid)); 
     610                 dimCoordList.push_back(StdString("nav_lat").append(appendDomid)); 
     611                 break ; 
     612               case CDomain::type_attr::regular : 
     613                 dimXid     = StdString("lon").append(appendDomid); 
     614                 dimIdList.push_back(dimXid); 
     615                 dimYid     = StdString("lat").append(appendDomid); 
     616                 dimIdList.push_back(dimYid); 
     617                 break ; 
     618               case CDomain::type_attr::unstructured : 
     619                 dimXid     = StdString("cell").append(appendDomid); 
     620                 dimIdList.push_back(dimXid); 
     621                 dimCoordList.push_back(StdString("lon").append(appendDomid)); 
     622                 dimCoordList.push_back(StdString("lat").append(appendDomid)); 
     623                 break ; 
     624            } 
     625            ++idxDomain; 
     626           } 
     627           else 
     628           { 
     629             CAxis* axis = CAxis::get(axisList[idxAxis]); 
     630             StdString axisid = (!axis->name.isEmpty()) 
     631                                ? axis->name.getValue() : axis->getId(); 
     632             dimIdList.push_back(axisid); 
     633             dimCoordList.push_back(axisid); 
     634            ++idxAxis; 
     635           } 
     636         } 
    611637 
    612638/* 
     
    648674         } 
    649675 
    650          std::vector<StdString> axisList = grid->getAxisList(); 
    651          if (!axisList.empty()) 
    652          { 
    653            std::vector<StdString>::const_iterator itAxis = axisList.begin(), iteAxis = axisList.end(); 
    654            for (; itAxis != iteAxis; ++itAxis) 
    655            { 
    656              CAxis* axis = CAxis::get(*itAxis); 
    657              StdString axisid = (!axis->name.isEmpty()) 
    658                                 ? axis->name.getValue() : axis->getId(); 
    659  
    660              dims.push_back(axisid); 
    661              coodinates.push_back(axisid); 
    662            } 
    663          } 
    664  
    665          switch (domain->type) 
    666          { 
    667            case CDomain::type_attr::curvilinear : 
    668              coodinates.push_back(StdString("nav_lon").append(appendDomid)); 
    669              coodinates.push_back(StdString("nav_lat").append(appendDomid)); 
    670              break; 
    671            case CDomain::type_attr::regular : 
    672            case CDomain::type_attr::unstructured : 
    673             coodinates.push_back(StdString("lon").append(appendDomid)); 
    674             coodinates.push_back(StdString("lat").append(appendDomid)); 
    675              break; 
    676          } 
    677  
    678          if ( domain->type == CDomain::type_attr::curvilinear || domain->type == CDomain::type_attr::regular)dims.push_back(dimYid); 
    679          dims.push_back(dimXid); 
     676         while (!dimIdList.empty()) 
     677         { 
     678           dims.push_back(dimIdList.back()); 
     679           dimIdList.pop_back(); 
     680         } 
     681 
     682         while (!dimCoordList.empty()) 
     683         { 
     684           coodinates.push_back(dimCoordList.back()); 
     685           dimCoordList.pop_back(); 
     686         } 
    680687 
    681688         try 
     
    772779         } 
    773780      } 
     781 
     782 
     783//      void CNc4DataOutput::writeField_(CField* field) 
     784//      { 
     785//         CContext* context = CContext::getCurrent() ; 
     786//         CContextServer* server=context->server ; 
     787// 
     788//         std::vector<StdString> dims, coodinates; 
     789//         CGrid* grid = field->grid; 
     790//         CDomain* domain = grid->domain; 
     791// 
     792//         if (domain->isEmpty()) 
     793//           if (SuperClass::type==MULTI_FILE) return ; 
     794// 
     795//         StdString timeid    = StdString("time_counter"); 
     796//         StdString domid     = (!domain->name.isEmpty()) 
     797//                             ? domain->name.getValue() : domain->getId(); 
     798//         StdString appendDomid  = (singleDomain) ? "" : "_"+domid ; 
     799// 
     800////         bool isCurvilinear = domain->isCurvilinear ; 
     801////         bool isCurvilinear = (domain->type == CDomain::type_attr::curvilinear) ; 
     802// 
     803//         StdString dimXid,dimYid ; 
     804// 
     805//         switch (domain->type) 
     806//         { 
     807//           case CDomain::type_attr::curvilinear : 
     808//             dimXid     = StdString("x").append(appendDomid); 
     809//             dimYid     = StdString("y").append(appendDomid); 
     810//             break ; 
     811//           case CDomain::type_attr::regular : 
     812//             dimXid     = StdString("lon").append(appendDomid); 
     813//             dimYid     = StdString("lat").append(appendDomid); 
     814//             break ; 
     815//           case CDomain::type_attr::unstructured : 
     816//             dimXid     = StdString("cell").append(appendDomid); 
     817//             break ; 
     818//        } 
     819// 
     820///* 
     821//         StdString lonid_loc = (server->intraCommSize > 1) 
     822//                             ? StdString("lon").append(appendDomid).append("_local") 
     823//                             : lonid; 
     824//         StdString latid_loc = (server->intraCommSize > 1) 
     825//                             ? StdString("lat").append(appendDomid).append("_local") 
     826//                             : latid; 
     827//*/ 
     828//         StdString fieldid   = (!field->name.isEmpty()) 
     829//                             ? field->name.getValue() : field->getBaseFieldReference()->getId(); 
     830// 
     831////         unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue(); 
     832////         bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize); 
     833////          bool isCurvilinear = domain->isCurvilinear ; 
     834// 
     835//         nc_type type ; 
     836//         if (field->prec.isEmpty()) type =  NC_FLOAT ; 
     837//         else 
     838//         { 
     839//           if (field->prec==2) type = NC_SHORT ; 
     840//           else if (field->prec==4)  type =  NC_FLOAT ; 
     841//           else if (field->prec==8)   type =  NC_DOUBLE ; 
     842//         } 
     843// 
     844//         bool wtime   = !(!field->operation.isEmpty() && field->foperation->timeType() == func::CFunctor::once); 
     845// 
     846//         if (wtime) 
     847//         { 
     848// 
     849//            //StdOStringStream oss; 
     850//           // oss << "time_" << field->operation.getValue() 
     851//           //     << "_" << field->getRelFile()->output_freq.getValue(); 
     852//          //oss 
     853//            if (field->foperation->timeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); 
     854//            else if (field->foperation->timeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); 
     855//            dims.push_back(timeid); 
     856//         } 
     857// 
     858//         std::vector<StdString> axisList = grid->getAxisList(); 
     859//         if (!axisList.empty()) 
     860//         { 
     861//           std::vector<StdString>::const_iterator itAxis = axisList.begin(), iteAxis = axisList.end(); 
     862//           for (; itAxis != iteAxis; ++itAxis) 
     863//           { 
     864//             CAxis* axis = CAxis::get(*itAxis); 
     865//             StdString axisid = (!axis->name.isEmpty()) 
     866//                                ? axis->name.getValue() : axis->getId(); 
     867// 
     868//             dims.push_back(axisid); 
     869//             coodinates.push_back(axisid); 
     870//           } 
     871//         } 
     872// 
     873//         switch (domain->type) 
     874//         { 
     875//           case CDomain::type_attr::curvilinear : 
     876//             coodinates.push_back(StdString("nav_lon").append(appendDomid)); 
     877//             coodinates.push_back(StdString("nav_lat").append(appendDomid)); 
     878//             break; 
     879//           case CDomain::type_attr::regular : 
     880//           case CDomain::type_attr::unstructured : 
     881//            coodinates.push_back(StdString("lon").append(appendDomid)); 
     882//            coodinates.push_back(StdString("lat").append(appendDomid)); 
     883//             break; 
     884//         } 
     885// 
     886//         if ( domain->type == CDomain::type_attr::curvilinear || domain->type == CDomain::type_attr::regular)dims.push_back(dimYid); 
     887//         dims.push_back(dimXid); 
     888// 
     889//         try 
     890//         { 
     891//           SuperClassWriter::addVariable(fieldid, type, dims); 
     892// 
     893//           if (!field->standard_name.isEmpty()) 
     894//              SuperClassWriter::addAttribute 
     895//                 ("standard_name",  field->standard_name.getValue(), &fieldid); 
     896// 
     897//           if (!field->long_name.isEmpty()) 
     898//              SuperClassWriter::addAttribute 
     899//                 ("long_name", field->long_name.getValue(), &fieldid); 
     900// 
     901//           if (!field->unit.isEmpty()) 
     902//              SuperClassWriter::addAttribute 
     903//                 ("units", field->unit.getValue(), &fieldid); 
     904// 
     905//            if (!field->valid_min.isEmpty()) 
     906//              SuperClassWriter::addAttribute 
     907//                 ("valid_min", field->valid_min.getValue(), &fieldid); 
     908// 
     909//           if (!field->valid_max.isEmpty()) 
     910//              SuperClassWriter::addAttribute 
     911//                 ("valid_max", field->valid_max.getValue(), &fieldid); 
     912// 
     913//            if (!field->scale_factor.isEmpty()) 
     914//              SuperClassWriter::addAttribute 
     915//                 ("scale_factor", field->scale_factor.getValue(), &fieldid); 
     916// 
     917//             if (!field->add_offset.isEmpty()) 
     918//              SuperClassWriter::addAttribute 
     919//                 ("add_offset", field->add_offset.getValue(), &fieldid); 
     920// 
     921//           SuperClassWriter::addAttribute 
     922//                 ("online_operation", field->operation.getValue(), &fieldid); 
     923// 
     924//          // write child variables as attributes 
     925// 
     926// 
     927//           vector<CVariable*> listVars = field->getAllVariables() ; 
     928//           for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; 
     929// 
     930// 
     931//           if (wtime) 
     932//           { 
     933//              CDuration duration = field->freq_op.getValue(); 
     934//              duration.solveTimeStep(*(context->calendar)); 
     935//              SuperClassWriter::addAttribute("interval_operation", duration.toString(), &fieldid); 
     936// 
     937//              duration = field->getRelFile()->output_freq.getValue(); 
     938//              duration.solveTimeStep(*(context->calendar)); 
     939//              SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); 
     940//           } 
     941// 
     942//           if (!field->default_value.isEmpty()) 
     943//           { 
     944//              double default_value = field->default_value.getValue(); 
     945//              float fdefault_value = (float)default_value; 
     946//              if (type == NC_DOUBLE) 
     947//                 SuperClassWriter::setDefaultValue(fieldid, &default_value); 
     948//              else 
     949//                 SuperClassWriter::setDefaultValue(fieldid, &fdefault_value); 
     950//           } 
     951//           else 
     952//              SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); 
     953// 
     954//           {  // Ecriture des coordonnées 
     955// 
     956//              StdString coordstr; //boost::algorithm::join(coodinates, " ") 
     957//              std::vector<StdString>::iterator 
     958//                 itc = coodinates.begin(), endc = coodinates.end(); 
     959// 
     960//              for (; itc!= endc; itc++) 
     961//              { 
     962//                 StdString & coord = *itc; 
     963//                 if (itc+1 != endc) 
     964//                       coordstr.append(coord).append(" "); 
     965//                 else  coordstr.append(coord); 
     966//              } 
     967// 
     968//              SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid); 
     969// 
     970//           } 
     971//         } 
     972//         catch (CNetCdfException& e) 
     973//         { 
     974//           StdString msg("On writing field : "); 
     975//           msg.append(fieldid); msg.append("\n"); 
     976//           msg.append("In the context : "); 
     977//           msg.append(context->getId()); msg.append("\n"); 
     978//           msg.append(e.what()); 
     979//           ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); 
     980//         } 
     981//      } 
    774982 
    775983      //-------------------------------------------------------------- 
     
    9321140 
    9331141         CGrid* grid = field->grid ; 
    934          CDomain* domain = grid->domain ; 
    935  
    936          if(SuperClass::type==MULTI_FILE || !isCollective) if (domain->isEmpty()) return; 
    937  
     1142 
     1143         if (!grid->doGridHaveDataToWrite()) 
     1144          if (SuperClass::type==MULTI_FILE || !isCollective) return ; 
    9381145 
    9391146         StdString fieldid   = (!field->name.isEmpty()) 
     
    9921199         try 
    9931200         { 
    994            if (grid->hasAxis()) // 3D 
     1201           CArray<double,1> fieldData(grid->getWrittenDataSize()); 
     1202           if (!field->default_value.isEmpty()) fieldData = field->default_value; 
     1203           field->outputField(fieldData); 
     1204           if (!field->prec.isEmpty() && field->prec==2) fieldData=round(fieldData) ; 
     1205 
     1206           switch (SuperClass::type) 
    9951207           { 
    996               CAxis* axis = grid->axis ; 
    997               CArray<double,3> field_data3D(domain->zoom_ni_srv,domain->zoom_nj_srv,axis->zoom_size) ; 
    998               if (!field->default_value.isEmpty()) field_data3D = field->default_value ; 
    999  
    1000               field->outputField(field_data3D); 
    1001  
    1002               if (!field->prec.isEmpty() && field->prec==2) field_data3D=round(field_data3D) ; 
    1003  
    1004               switch (SuperClass::type) 
    1005              { 
    1006                 case (MULTI_FILE) : 
     1208              case (MULTI_FILE) : 
     1209              { 
     1210                 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep()-1); 
     1211                 if (wtime) 
     1212                 { 
     1213                   SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
     1214                   SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
     1215                   SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
     1216                   SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
     1217                 } 
     1218                 break ; 
     1219              } 
     1220              case (ONE_FILE) : 
     1221              { 
     1222                std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 
     1223                std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); 
     1224                std::vector<int> nZoomSizeServer  = grid->getDistributionServer()->getZoomSizeServer(); 
     1225 
     1226                int ssize = nZoomBeginGlobal.size(); 
     1227 
     1228                std::vector<StdSize> start(ssize) ; 
     1229                std::vector<StdSize> count(ssize) ; 
     1230 
     1231                for (int i = 0; i < ssize; ++i) 
    10071232                { 
    1008                    SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1); 
    1009                    if (wtime) 
    1010                    { 
    1011                      SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
    1012                      SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
    1013                      SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
    1014                      SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
    1015                    } 
    1016                    break ; 
     1233                  start[i] = nZoomBeginServer[ssize-i-1] - nZoomBeginGlobal[ssize-i-1]; 
     1234                  count[i] = nZoomSizeServer[ssize-i-1]; 
    10171235                } 
    1018                 case (ONE_FILE) : 
    1019                 { 
    1020                    std::vector<StdSize> start(3) ; 
    1021                    std::vector<StdSize> count(3) ; 
    1022                    if (domain->isEmpty()) 
    1023                    { 
    1024                      start[0]=0 ; start[1]=0 ; start[2]=0 ; 
    1025                      count[0]=0 ; count[1]=0 ; start[2]=0 ; 
    1026                    } 
    1027                    else 
    1028                    { 
    1029   //                 start[2]=domain->zoom_ibegin_loc.getValue()-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_loc.getValue()-domain->zoom_jbegin.getValue() ; start[0]=0 ; 
    1030                      start[2]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; start[0]=0 ; 
    1031                      count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue(); 
    1032                    } 
    1033                    SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count ); 
    1034                    if (wtime) 
    1035                    { 
    1036                      SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); 
    1037                      SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); 
    1038                      SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); 
    1039                      SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
    1040                    } 
    1041                    break; 
    1042                 } 
     1236 
     1237                 SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep()-1,&start,&count ); 
     1238                 if (wtime) 
     1239                 { 
     1240                   SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); 
     1241                   SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); 
     1242                   SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); 
     1243                   SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
     1244                 } 
     1245                 break; 
    10431246              } 
    1044  
    1045            } 
    1046            else // 2D 
    1047            { 
    1048               CArray<double,2> field_data2D(domain->zoom_ni_srv,domain->zoom_nj_srv) ; 
    1049               if (!field->default_value.isEmpty()) field_data2D = field->default_value ; 
    1050               field->outputField(field_data2D); 
    1051               if (!field->prec.isEmpty() && field->prec==2) field_data2D=round(field_data2D) ; 
    1052               switch (SuperClass::type) 
    1053               { 
    1054                 case (MULTI_FILE) : 
    1055                 { 
    1056                   SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1); 
    1057                   if (wtime) 
    1058                   { 
    1059                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
    1060                     SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
    1061                     SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
    1062                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
    1063                   } 
    1064                   break; 
    1065                 } 
    1066                 case (ONE_FILE) : 
    1067                 { 
    1068                    std::vector<StdSize> start(2) ; 
    1069                    std::vector<StdSize> count(2) ; 
    1070                    if (domain->isEmpty()) 
    1071                    { 
    1072                      start[0]=0 ; start[1]=0 ; 
    1073                      count[0]=0 ; count[1]=0 ; 
    1074                    } 
    1075                    else 
    1076                    { 
    1077                      start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 
    1078                      count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 
    1079                    } 
    1080  
    1081                    SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count); 
    1082                    if (wtime) 
    1083                    { 
    1084                      SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot); 
    1085                      SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot); 
    1086                      SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot); 
    1087                      SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
    1088                    } 
    1089                    break; 
    1090  
    1091                 } 
    1092               } 
    1093            } 
     1247            } 
    10941248         } 
    10951249         catch (CNetCdfException& e) 
     
    11031257         } 
    11041258      } 
     1259 
     1260//      //--------------------------------------------------------------- 
     1261// 
     1262//      void CNc4DataOutput::writeFieldData_ (CField*  field) 
     1263//      { 
     1264//         CContext* context = CContext::getCurrent() ; 
     1265////          if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ; 
     1266//         CContextServer* server=context->server ; 
     1267// 
     1268//         CGrid* grid = field->grid ; 
     1269//         CDomain* domain = grid->domain ; 
     1270// 
     1271//         if(SuperClass::type==MULTI_FILE || !isCollective) if (domain->isEmpty()) return; 
     1272// 
     1273// 
     1274//         StdString fieldid   = (!field->name.isEmpty()) 
     1275//                             ? field->name.getValue() 
     1276//                             : field->getBaseFieldReference()->getId(); 
     1277// 
     1278//         StdOStringStream oss; 
     1279//         string timeAxisId ; 
     1280//         if (field->foperation->timeType() == func::CFunctor::instant)  timeAxisId="time_instant" ; 
     1281//         else if (field->foperation->timeType() == func::CFunctor::centered)  timeAxisId="time_centered" ; 
     1282// 
     1283//         StdString timeBoundId("time_counter_bounds"); 
     1284// 
     1285//         StdString timeAxisBoundId; 
     1286//         if (field->foperation->timeType() == func::CFunctor::instant)  timeAxisBoundId="time_instant_bounds" ; 
     1287//         else if (field->foperation->timeType() == func::CFunctor::centered)  timeAxisBoundId="time_centered_bounds" ; 
     1288// 
     1289//         CArray<double,1> time_data(1) ; 
     1290//         CArray<double,1> time_counter(1) ; 
     1291//         CArray<double,1> time_counter_bound(2); 
     1292//         CArray<double,1> time_data_bound(2); 
     1293// 
     1294//        bool wtime   = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once)); 
     1295// 
     1296//        if (wtime) 
     1297//        { 
     1298//          time_counter(0)= (Time(*field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2; 
     1299//          if (field->foperation->timeType() == func::CFunctor::instant) 
     1300//            time_data(0) = Time(*field->last_Write_srv); 
     1301//          else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0); 
     1302// 
     1303//          time_counter_bound(0) = Time(*field->lastlast_Write_srv); 
     1304//          time_counter_bound(1) = Time(*field->last_Write_srv); 
     1305//          if (field->foperation->timeType() == func::CFunctor::instant) 
     1306//            time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv); 
     1307//          else if (field->foperation->timeType() == func::CFunctor::centered) 
     1308//          { 
     1309//            time_data_bound(0) = time_counter_bound(0); 
     1310//            time_data_bound(1) = time_counter_bound(1); 
     1311//          } 
     1312//         } 
     1313// 
     1314//         bool isRoot ; 
     1315//         if (server->intraCommRank==0) isRoot=true ; 
     1316//         else isRoot=false ; 
     1317// 
     1318//         if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) 
     1319//         { 
     1320//           double scaleFactor=1. ; 
     1321//           double addOffset=0. ; 
     1322//           if (!field->scale_factor.isEmpty()) scaleFactor=field->scale_factor ; 
     1323//           if (!field->add_offset.isEmpty()) addOffset=field->add_offset ; 
     1324//           field->scaleFactorAddOffset(scaleFactor,addOffset) ; 
     1325//         } 
     1326// 
     1327//         try 
     1328//         { 
     1329//           if (grid->hasAxis()) // 3D 
     1330//           { 
     1331//              CAxis* axis = grid->axis ; 
     1332//              CArray<double,3> field_data3D(domain->zoom_ni_srv,domain->zoom_nj_srv,axis->zoom_size) ; 
     1333//              if (!field->default_value.isEmpty()) field_data3D = field->default_value ; 
     1334// 
     1335//              field->outputField(field_data3D); 
     1336// 
     1337//              if (!field->prec.isEmpty() && field->prec==2) field_data3D=round(field_data3D) ; 
     1338// 
     1339//              switch (SuperClass::type) 
     1340//             { 
     1341//                case (MULTI_FILE) : 
     1342//                { 
     1343//                   SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1); 
     1344//                   if (wtime) 
     1345//                   { 
     1346//                     SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
     1347//                     SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
     1348//                     SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
     1349//                     SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
     1350//                   } 
     1351//                   break ; 
     1352//                } 
     1353//                case (ONE_FILE) : 
     1354//                { 
     1355//                   std::vector<StdSize> start(3) ; 
     1356//                   std::vector<StdSize> count(3) ; 
     1357//                   if (domain->isEmpty()) 
     1358//                   { 
     1359//                     start[0]=0 ; start[1]=0 ; start[2]=0 ; 
     1360//                     count[0]=0 ; count[1]=0 ; start[2]=0 ; 
     1361//                   } 
     1362//                   else 
     1363//                   { 
     1364//  //                 start[2]=domain->zoom_ibegin_loc.getValue()-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_loc.getValue()-domain->zoom_jbegin.getValue() ; start[0]=0 ; 
     1365//                     start[2]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; start[0]=0 ; 
     1366//                     count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue(); 
     1367//                   } 
     1368//                   SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count ); 
     1369//                   if (wtime) 
     1370//                   { 
     1371//                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); 
     1372//                     SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); 
     1373//                     SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); 
     1374//                     SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
     1375//                   } 
     1376//                   break; 
     1377//                } 
     1378//              } 
     1379// 
     1380//           } 
     1381//           else // 2D 
     1382//           { 
     1383//              CArray<double,2> field_data2D(domain->zoom_ni_srv,domain->zoom_nj_srv) ; 
     1384//              if (!field->default_value.isEmpty()) field_data2D = field->default_value ; 
     1385//              field->outputField(field_data2D); 
     1386//              if (!field->prec.isEmpty() && field->prec==2) field_data2D=round(field_data2D) ; 
     1387//              switch (SuperClass::type) 
     1388//              { 
     1389//                case (MULTI_FILE) : 
     1390//                { 
     1391//                  SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1); 
     1392//                  if (wtime) 
     1393//                  { 
     1394//                    SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 
     1395//                    SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 
     1396//                    SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 
     1397//                    SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 
     1398//                  } 
     1399//                  break; 
     1400//                } 
     1401//                case (ONE_FILE) : 
     1402//                { 
     1403//                   std::vector<StdSize> start(2) ; 
     1404//                   std::vector<StdSize> count(2) ; 
     1405//                   if (domain->isEmpty()) 
     1406//                   { 
     1407//                     start[0]=0 ; start[1]=0 ; 
     1408//                     count[0]=0 ; count[1]=0 ; 
     1409//                   } 
     1410//                   else 
     1411//                   { 
     1412//                     start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 
     1413//                     count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 
     1414//                   } 
     1415// 
     1416//                   SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count); 
     1417//                   if (wtime) 
     1418//                   { 
     1419//                     SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot); 
     1420//                     SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot); 
     1421//                     SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot); 
     1422//                     SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 
     1423//                   } 
     1424//                   break; 
     1425// 
     1426//                } 
     1427//              } 
     1428//           } 
     1429//         } 
     1430//         catch (CNetCdfException& e) 
     1431//         { 
     1432//           StdString msg("On writing field data: "); 
     1433//           msg.append(fieldid); msg.append("\n"); 
     1434//           msg.append("In the context : "); 
     1435//           msg.append(context->getId()); msg.append("\n"); 
     1436//           msg.append(e.what()); 
     1437//           ERROR("CNc4DataOutput::writeFieldData_ (CField*  field)", << msg); 
     1438//         } 
     1439//      } 
    11051440 
    11061441      //--------------------------------------------------------------- 
  • XIOS/trunk/src/test/test_new_features.f90

    r557 r567  
    2525 
    2626  DOUBLE PRECISION,DIMENSION(ni_glo,nj_glo) :: lon_glo,lat_glo 
    27   DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm) 
    28   DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), lonvalue(:) ; 
    29   INTEGER :: ni,ibegin,iend,nj,jbegin,jend 
     27  DOUBLE PRECISION :: field_A_glo(ni_glo,nj_glo,llm), lval_ni(ni_glo), lval_nj(nj_glo) 
     28  DOUBLE PRECISION,ALLOCATABLE :: lon(:,:),lat(:,:),field_A(:,:,:), field_All_Axis(:,:,:), lonvalue(:) , field_Axis(:) 
     29  INTEGER :: ni,ibegin,iend,nj,jbegin,jend, nAxis, axisBegin, axisEnd 
    3030  INTEGER :: i,j,l,ts,n 
    3131 
     
    4747      lon_glo(i,j)=(i-1)+(j-1)*ni_glo 
    4848      lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo 
     49      lval_ni(i) = i-1 
    4950      DO l=1,llm 
    5051        field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l 
    5152      ENDDO 
    5253    ENDDO 
     54    lval_nj(j) = j-1 
    5355  ENDDO 
    5456  ni=ni_glo ; ibegin=0 
     
    6163    jbegin=jbegin+nj 
    6264  ENDDO 
    63  
    6465  iend=ibegin+ni-1 ; jend=jbegin+nj-1 
    6566 
    66   ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj)) 
     67  axisBegin = 0 
     68  nAxis = llm 
     69!  DO n=0, size -1 
     70!    nAxis = llm/size 
     71!    IF (n<MOD(llm,size)) nAxis=nAxis+1 
     72!    IF (n==rank) exit 
     73!    axisBegin=axisBegin+nAxis 
     74!  ENDDO 
     75  axisEnd=axisBegin+nAxis-1 
     76 
     77  ALLOCATE(lon(ni,nj),lat(ni,nj),field_A(0:ni+1,-1:nj+2,llm),lonvalue(ni*nj), field_Axis(nAxis), field_All_Axis(1:ni,1:nj,llm)) 
    6778  lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1) 
    6879  lat(:,:)=lat_glo(ibegin+1:iend+1,jbegin+1:jend+1) 
    69   field_A(1:ni,1:nj,:)=field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) 
     80  field_A(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) 
     81  field_Axis(1:nAxis)  = field_A_glo(1,1,axisBegin+1:axisEnd+1) 
     82  field_All_Axis(1:ni,1:nj,:) = field_A_glo(ibegin+1:iend+1,jbegin+1:jend+1,:) 
    7083 
    7184  CALL xios_context_initialize("test",comm) 
     
    7386  CALL xios_set_current_context(ctx_hdl) 
    7487 
    75   CALL xios_get_calendar_type(calendar_type) 
    76   PRINT *, "calendar_type = ", calendar_type 
     88!  CALL xios_get_calendar_type(calendar_type) 
     89!  PRINT *, "calendar_type = ", calendar_type 
    7790 
    78   CALL xios_set_axis_attr("axis_A",size=llm ,value=lval) ; 
     91  CALL xios_set_axis_attr("axis_A", size=ni_glo, ibegin=ibegin, ni=ni, value=lval_ni) 
     92  CALL xios_set_axis_attr("axis_B", size=nj_glo, ibegin=jbegin, ni=nj, value=lval_nj) 
     93  CALL xios_set_axis_attr("axis_C", size=llm, value=lval) 
     94  CALL xios_set_axis_attr("axis_D", size=llm, value=lval) 
    7995  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    8096  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
     
    89105  CALL xios_add_child(file_hdl,field_hdl) 
    90106  CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_C") 
     107 
     108  CALL xios_get_handle("output_Axis",file_hdl) 
     109  CALL xios_add_child(file_hdl,field_hdl) 
     110  CALL xios_set_attr(field_hdl,field_ref="field_All_Axis",name="field_C") 
    91111 
    92112  dtime%second = 3600 
     
    126146    CALL xios_update_calendar(ts) 
    127147    CALL xios_send_field("field_A",field_A) 
     148    CALL xios_send_field("field_Axis",field_Axis) 
     149    CALL xios_send_field("field_All_Axis",field_All_Axis) 
    128150    CALL wait_us(5000) ; 
    129151  ENDDO 
Note: See TracChangeset for help on using the changeset viewer.