Changeset 567
- Timestamp:
- 03/10/15 10:49:02 (9 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/Version2/iodef.xml
r553 r567 6 6 7 7 8 <field_definition level="1" enabled=". FALSE.">8 <field_definition level="1" enabled=".TRUE."> 9 9 <!-- <field id="field_A" operation="average" freq_op="3600s" domain_ref="domain_A" axis_ref="axis_A" />--> 10 10 <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" /> 11 13 </field_definition> 12 14 … … 16 18 <field field_ref="field_A" /> 17 19 </file> 20 <file id="output_Axis" name="output_Axis"> 21 <field field_ref="field_Axis" /> 22 <field field_ref="field_All_Axis" /> 23 </file> 18 24 </file_definition> 19 25 20 26 21 27 <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"/> 24 32 </axis_definition> 25 33 … … 32 40 <grid id="grid_A"> 33 41 <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"> 34 48 <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" /> 40 51 </grid> 41 52 </grid_group> … … 57 68 <variable_group id="buffer"> 58 69 <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> 60 71 </variable_group> 61 72 -
XIOS/trunk/src/attribute_array_decl.cpp
r551 r567 12 12 template class CAttributeArray<bool,2> ; 13 13 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> ; 14 18 } -
XIOS/trunk/src/client_server_mapping.cpp
r554 r567 26 26 } 27 27 28 void 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 28 35 /*! 29 36 Compute index of data which are sent to server and index global on server side … … 32 39 */ 33 40 void 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) 35 43 { 36 44 int nServer = globalIndexServer.size(); … … 52 60 // Just try to calculate local index server on client side 53 61 (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); 55 65 continue; 56 66 } -
XIOS/trunk/src/client_server_mapping.hpp
r554 r567 33 33 const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 34 34 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 35 39 std::map<int,int> computeConnectedClients(int nbServer, int nbClient, 36 40 MPI_Comm& clientIntraComm, … … 42 46 protected: 43 47 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); 45 50 46 51 private: -
XIOS/trunk/src/config/grid_attribute.conf
r551 r567 1 1 DECLARE_ATTRIBUTE(StdString, name) 2 2 DECLARE_ATTRIBUTE(StdString, description) 3 //DECLARE_ATTRIBUTE(StdString, domain_ref) 4 //DECLARE_ATTRIBUTE(StdString, axis_ref) 5 DECLARE_ARRAY(bool, 3 , mask) 3 4 DECLARE_ARRAY(bool, 1 , mask1) 5 DECLARE_ARRAY(bool, 2 , mask2) 6 DECLARE_ARRAY(bool, 3 , mask3) 6 7 //DECLARE_ARRAY(bool, 4 , mask4) 7 8 //DECLARE_ARRAY(bool, 5 , mask5) -
XIOS/trunk/src/interface/c_attr/icgrid_attr.cpp
r555 r567 69 69 70 70 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) 72 72 { 73 73 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()); 76 76 CTimer::get("XIOS").suspend(); 77 77 } 78 78 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) 80 80 { 81 81 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() ; 84 84 CTimer::get("XIOS").suspend(); 85 85 } 86 86 87 bool cxios_is_defined_grid_mask (grid_Ptr grid_hdl )87 bool cxios_is_defined_grid_mask1(grid_Ptr grid_hdl ) 88 88 { 89 89 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(); 91 141 CTimer::get("XIOS").suspend(); 92 142 } -
XIOS/trunk/src/interface/c_attr/icgridgroup_attr.cpp
r555 r567 95 95 96 96 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) 98 98 { 99 99 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()); 102 102 CTimer::get("XIOS").suspend(); 103 103 } 104 104 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) 106 106 { 107 107 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() ; 110 110 CTimer::get("XIOS").suspend(); 111 111 } 112 112 113 bool cxios_is_defined_gridgroup_mask (gridgroup_Ptr gridgroup_hdl )113 bool cxios_is_defined_gridgroup_mask1(gridgroup_Ptr gridgroup_hdl ) 114 114 { 115 115 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(); 117 167 CTimer::get("XIOS").suspend(); 118 168 } -
XIOS/trunk/src/interface/fortran_attr/grid_interface_attr.F90
r555 r567 52 52 53 53 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) 55 55 USE ISO_C_BINDING 56 56 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 58 102 INTEGER (kind = C_INT), VALUE :: extent1 59 103 INTEGER (kind = C_INT), VALUE :: extent2 60 104 INTEGER (kind = C_INT), VALUE :: extent3 61 END SUBROUTINE cxios_set_grid_mask 105 END SUBROUTINE cxios_set_grid_mask3 62 106 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) 64 108 USE ISO_C_BINDING 65 109 INTEGER (kind = C_INTPTR_T), VALUE :: grid_hdl 66 LOGICAL (KIND=C_BOOL) , DIMENSION(*) :: mask 110 LOGICAL (KIND=C_BOOL) , DIMENSION(*) :: mask3 67 111 INTEGER (kind = C_INT), VALUE :: extent1 68 112 INTEGER (kind = C_INT), VALUE :: extent2 69 113 INTEGER (kind = C_INT), VALUE :: extent3 70 END SUBROUTINE cxios_get_grid_mask 114 END SUBROUTINE cxios_get_grid_mask3 71 115 72 FUNCTION cxios_is_defined_grid_mask (grid_hdl ) BIND(C)116 FUNCTION cxios_is_defined_grid_mask3(grid_hdl ) BIND(C) 73 117 USE ISO_C_BINDING 74 LOGICAL(kind=C_BOOL) :: cxios_is_defined_grid_mask 118 LOGICAL(kind=C_BOOL) :: cxios_is_defined_grid_mask3 75 119 INTEGER (kind = C_INTPTR_T), VALUE :: grid_hdl 76 END FUNCTION cxios_is_defined_grid_mask 120 END FUNCTION cxios_is_defined_grid_mask3 77 121 78 122 -
XIOS/trunk/src/interface/fortran_attr/gridgroup_interface_attr.F90
r555 r567 73 73 74 74 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) 76 76 USE ISO_C_BINDING 77 77 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 79 123 INTEGER (kind = C_INT), VALUE :: extent1 80 124 INTEGER (kind = C_INT), VALUE :: extent2 81 125 INTEGER (kind = C_INT), VALUE :: extent3 82 END SUBROUTINE cxios_set_gridgroup_mask 126 END SUBROUTINE cxios_set_gridgroup_mask3 83 127 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) 85 129 USE ISO_C_BINDING 86 130 INTEGER (kind = C_INTPTR_T), VALUE :: gridgroup_hdl 87 LOGICAL (KIND=C_BOOL) , DIMENSION(*) :: mask 131 LOGICAL (KIND=C_BOOL) , DIMENSION(*) :: mask3 88 132 INTEGER (kind = C_INT), VALUE :: extent1 89 133 INTEGER (kind = C_INT), VALUE :: extent2 90 134 INTEGER (kind = C_INT), VALUE :: extent3 91 END SUBROUTINE cxios_get_gridgroup_mask 135 END SUBROUTINE cxios_get_gridgroup_mask3 92 136 93 FUNCTION cxios_is_defined_gridgroup_mask (gridgroup_hdl ) BIND(C)137 FUNCTION cxios_is_defined_gridgroup_mask3(gridgroup_hdl ) BIND(C) 94 138 USE ISO_C_BINDING 95 LOGICAL(kind=C_BOOL) :: cxios_is_defined_gridgroup_mask 139 LOGICAL(kind=C_BOOL) :: cxios_is_defined_gridgroup_mask3 96 140 INTEGER (kind = C_INTPTR_T), VALUE :: gridgroup_hdl 97 END FUNCTION cxios_is_defined_gridgroup_mask 141 END FUNCTION cxios_is_defined_gridgroup_mask3 98 142 99 143 -
XIOS/trunk/src/interface/fortran_attr/igrid_attr.F90
r556 r567 12 12 13 13 SUBROUTINE xios(set_grid_attr) & 14 ( grid_id, axisDomainOrder, description, mask , name )14 ( grid_id, axisDomainOrder, description, mask1, mask2, mask3, name ) 15 15 16 16 IMPLICIT NONE … … 20 20 LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 21 21 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(:,:,:) 24 28 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 25 29 26 30 CALL xios(get_grid_handle)(grid_id,grid_hdl) 27 31 CALL xios(set_grid_attr_hdl_) & 28 ( grid_hdl, axisDomainOrder, description, mask , name )32 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 29 33 30 34 END SUBROUTINE xios(set_grid_attr) 31 35 32 36 SUBROUTINE xios(set_grid_attr_hdl) & 33 ( grid_hdl, axisDomainOrder, description, mask , name )37 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 34 38 35 39 IMPLICIT NONE … … 38 42 LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 39 43 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(:,:,:) 42 50 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 43 51 44 52 CALL xios(set_grid_attr_hdl_) & 45 ( grid_hdl, axisDomainOrder, description, mask , name )53 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 46 54 47 55 END SUBROUTINE xios(set_grid_attr_hdl) 48 56 49 57 SUBROUTINE xios(set_grid_attr_hdl_) & 50 ( grid_hdl, axisDomainOrder_, description_, mask _, name_ )58 ( grid_hdl, axisDomainOrder_, description_, mask1_, mask2_, mask3_, name_ ) 51 59 52 60 IMPLICIT NONE … … 55 63 LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder__tmp(:) 56 64 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(:,:,:) 59 71 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 60 72 … … 69 81 ENDIF 70 82 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)) 75 99 ENDIF 76 100 … … 84 108 85 109 SUBROUTINE xios(get_grid_attr) & 86 ( grid_id, axisDomainOrder, description, mask , name )110 ( grid_id, axisDomainOrder, description, mask1, mask2, mask3, name ) 87 111 88 112 IMPLICIT NONE … … 92 116 LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 93 117 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(:,:,:) 96 124 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 97 125 98 126 CALL xios(get_grid_handle)(grid_id,grid_hdl) 99 127 CALL xios(get_grid_attr_hdl_) & 100 ( grid_hdl, axisDomainOrder, description, mask , name )128 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 101 129 102 130 END SUBROUTINE xios(get_grid_attr) 103 131 104 132 SUBROUTINE xios(get_grid_attr_hdl) & 105 ( grid_hdl, axisDomainOrder, description, mask , name )133 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 106 134 107 135 IMPLICIT NONE … … 110 138 LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder_tmp(:) 111 139 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(:,:,:) 114 146 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 115 147 116 148 CALL xios(get_grid_attr_hdl_) & 117 ( grid_hdl, axisDomainOrder, description, mask , name )149 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 118 150 119 151 END SUBROUTINE xios(get_grid_attr_hdl) 120 152 121 153 SUBROUTINE xios(get_grid_attr_hdl_) & 122 ( grid_hdl, axisDomainOrder_, description_, mask _, name_ )154 ( grid_hdl, axisDomainOrder_, description_, mask1_, mask2_, mask3_, name_ ) 123 155 124 156 IMPLICIT NONE … … 127 159 LOGICAL (KIND=C_BOOL) , ALLOCATABLE :: axisDomainOrder__tmp(:) 128 160 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(:,:,:) 131 167 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 132 168 … … 141 177 ENDIF 142 178 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 147 195 ENDIF 148 196 … … 156 204 157 205 SUBROUTINE xios(is_defined_grid_attr) & 158 ( grid_id, axisDomainOrder, description, mask , name )206 ( grid_id, axisDomainOrder, description, mask1, mask2, mask3, name ) 159 207 160 208 IMPLICIT NONE … … 165 213 LOGICAL, OPTIONAL, INTENT(OUT) :: description 166 214 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 169 221 LOGICAL, OPTIONAL, INTENT(OUT) :: name 170 222 LOGICAL(KIND=C_BOOL) :: name_tmp … … 172 224 CALL xios(get_grid_handle)(grid_id,grid_hdl) 173 225 CALL xios(is_defined_grid_attr_hdl_) & 174 ( grid_hdl, axisDomainOrder, description, mask , name )226 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 175 227 176 228 END SUBROUTINE xios(is_defined_grid_attr) 177 229 178 230 SUBROUTINE xios(is_defined_grid_attr_hdl) & 179 ( grid_hdl, axisDomainOrder, description, mask , name )231 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 180 232 181 233 IMPLICIT NONE … … 185 237 LOGICAL, OPTIONAL, INTENT(OUT) :: description 186 238 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 189 245 LOGICAL, OPTIONAL, INTENT(OUT) :: name 190 246 LOGICAL(KIND=C_BOOL) :: name_tmp 191 247 192 248 CALL xios(is_defined_grid_attr_hdl_) & 193 ( grid_hdl, axisDomainOrder, description, mask , name )249 ( grid_hdl, axisDomainOrder, description, mask1, mask2, mask3, name ) 194 250 195 251 END SUBROUTINE xios(is_defined_grid_attr_hdl) 196 252 197 253 SUBROUTINE xios(is_defined_grid_attr_hdl_) & 198 ( grid_hdl, axisDomainOrder_, description_, mask _, name_ )254 ( grid_hdl, axisDomainOrder_, description_, mask1_, mask2_, mask3_, name_ ) 199 255 200 256 IMPLICIT NONE … … 204 260 LOGICAL, OPTIONAL, INTENT(OUT) :: description_ 205 261 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 208 268 LOGICAL, OPTIONAL, INTENT(OUT) :: name_ 209 269 LOGICAL(KIND=C_BOOL) :: name__tmp … … 219 279 ENDIF 220 280 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 224 294 ENDIF 225 295 -
XIOS/trunk/src/interface/fortran_attr/igridgroup_attr.F90
r556 r567 12 12 13 13 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 ) 15 15 16 16 IMPLICIT NONE … … 21 21 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 22 22 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(:,:,:) 25 29 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 26 30 27 31 CALL xios(get_gridgroup_handle)(gridgroup_id,gridgroup_hdl) 28 32 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 ) 30 34 31 35 END SUBROUTINE xios(set_gridgroup_attr) 32 36 33 37 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 ) 35 39 36 40 IMPLICIT NONE … … 40 44 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 41 45 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(:,:,:) 44 52 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 45 53 46 54 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 ) 48 56 49 57 END SUBROUTINE xios(set_gridgroup_attr_hdl) 50 58 51 59 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_ ) 53 61 54 62 IMPLICIT NONE … … 58 66 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description_ 59 67 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(:,:,:) 62 74 CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 63 75 … … 76 88 ENDIF 77 89 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)) 82 106 ENDIF 83 107 … … 91 115 92 116 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 ) 94 118 95 119 IMPLICIT NONE … … 100 124 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 101 125 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(:,:,:) 104 132 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 105 133 106 134 CALL xios(get_gridgroup_handle)(gridgroup_id,gridgroup_hdl) 107 135 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 ) 109 137 110 138 END SUBROUTINE xios(get_gridgroup_attr) 111 139 112 140 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 ) 114 142 115 143 IMPLICIT NONE … … 119 147 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 120 148 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(:,:,:) 123 155 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 124 156 125 157 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 ) 127 159 128 160 END SUBROUTINE xios(get_gridgroup_attr_hdl) 129 161 130 162 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_ ) 132 164 133 165 IMPLICIT NONE … … 137 169 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description_ 138 170 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(:,:,:) 141 177 CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 142 178 … … 155 191 ENDIF 156 192 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 161 209 ENDIF 162 210 … … 170 218 171 219 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 ) 173 221 174 222 IMPLICIT NONE … … 181 229 LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 182 230 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 185 237 LOGICAL, OPTIONAL, INTENT(OUT) :: name 186 238 LOGICAL(KIND=C_BOOL) :: name_tmp … … 188 240 CALL xios(get_gridgroup_handle)(gridgroup_id,gridgroup_hdl) 189 241 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 ) 191 243 192 244 END SUBROUTINE xios(is_defined_gridgroup_attr) 193 245 194 246 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 ) 196 248 197 249 IMPLICIT NONE … … 203 255 LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 204 256 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 207 263 LOGICAL, OPTIONAL, INTENT(OUT) :: name 208 264 LOGICAL(KIND=C_BOOL) :: name_tmp 209 265 210 266 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 ) 212 268 213 269 END SUBROUTINE xios(is_defined_gridgroup_attr_hdl) 214 270 215 271 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_ ) 217 273 218 274 IMPLICIT NONE … … 224 280 LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref_ 225 281 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 228 288 LOGICAL, OPTIONAL, INTENT(OUT) :: name_ 229 289 LOGICAL(KIND=C_BOOL) :: name__tmp … … 244 304 ENDIF 245 305 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 249 319 ENDIF 250 320 -
XIOS/trunk/src/node/axis.cpp
- Property svn:executable set to *
r566 r567 6 6 #include "message.hpp" 7 7 #include "type.hpp" 8 #include "context.hpp" 9 #include "context_client.hpp" 8 10 #include "xmlioserver_spl.hpp" 9 11 … … 14 16 CAxis::CAxis(void) 15 17 : CObjectTemplate<CAxis>() 16 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 18 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 17 19 { /* Ne rien faire de plus */ } 18 20 19 21 CAxis::CAxis(const StdString & id) 20 22 : CObjectTemplate<CAxis>(id) 21 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject() 23 , CAxisAttributes(), isChecked(false), relFiles(), baseRefObject(), areClientAttributesChecked_(false) 22 24 { /* Ne rien faire de plus */ } 23 25 … … 52 54 void CAxis::checkAttributes(void) 53 55 { 54 if (this->isChecked) return;55 56 if (this->size.isEmpty()) 56 57 ERROR("CAxis::checkAttributes(void)", … … 76 77 else this->ni.setValue(size); 77 78 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)",91 79 << "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 97 80 StdSize true_size = value.numElements(); 98 81 if (size != true_size) … … 102 85 this->checkData(); 103 86 this->checkMask(); 104 this-> isChecked = true;87 this->checkZoom(); 105 88 } 106 89 … … 122 105 for (int i = 0; i < dn; ++i) data_index(i) = (i+1); 123 106 } 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 ; 124 133 } 125 134 … … 166 175 } 167 176 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 168 289 DEFINE_REF_FUNC(Axis,axis) 169 290 -
XIOS/trunk/src/node/axis.hpp
r551 r567 11 11 #include "attribute_enum.hpp" 12 12 #include "attribute_enum_impl.hpp" 13 #include "server_distribution_description.hpp" 13 14 14 15 namespace xios { … … 33 34 , public CAxisAttributes 34 35 { 36 enum EEventId 37 { 38 EVENT_ID_SERVER_ATTRIBUT 39 } ; 40 35 41 /// typedef /// 36 42 typedef CObjectTemplate<CAxis> SuperClass; … … 66 72 static StdString GetName(void); 67 73 static StdString GetDefName(void); 68 69 74 static ENodeType GetType(void); 70 75 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; 71 87 private : 72 88 void checkData(); 73 89 void checkMask(); 90 void checkZoom(); 91 void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 92 CServerDistributionDescription::ServerDistributionType disType); 93 private: 94 74 95 bool isChecked; 96 bool areClientAttributesChecked_; 75 97 std::set<StdString> relFiles; 76 98 -
XIOS/trunk/src/node/context.cpp
r550 r567 308 308 if (hasClient) 309 309 { 310 // std::cout << "Current context " << *this << std::endl;311 310 // After xml is parsed, there are some more works with post processing 312 311 postProcessing(); … … 317 316 if (hasClient && !hasServer) 318 317 { 319 // After xml is parsed, there are some more works with post processing320 // postProcessing();321 322 // setClientServerBuffer();323 324 318 // Send all attributes of current context to server 325 319 this->sendAllAttributesToServer(); … … 336 330 337 331 // At last, we have all info of domain and axis, then send them 338 sendRefDomainsAxis();332 // sendRefDomainsAxis(); 339 333 340 334 // After that, send all grid (if any) 341 335 sendRefGrid(); 342 343 344 336 } 345 337 … … 416 408 } 417 409 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 425 410 void CContext::solveAllRefOfEnabledFields(bool sendToServer) 426 411 { … … 440 425 } 441 426 } 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 // }460 427 461 428 void CContext::solveAllInheritance(bool apply) … … 671 638 CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 672 639 postProcessing(); 673 // std::cout << "server context " << *this << std::endl;674 640 } 675 641 … … 719 685 std::map<int, StdSize>& CContext::getDataSize() 720 686 { 721 std::set<StdString> domainIds; 687 // Set of grid used by enabled fields 688 std::set<StdString> usedGrid; 722 689 723 690 // Find all reference domain and axis of all active fields … … 729 696 for (int j = 0; j < numEnabledFields; ++j) 730 697 { 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(); 732 700 const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataSize(); 733 701 if (dataSize_.empty()) 734 702 { 735 703 dataSize_ = mapSize; 736 domainIds.insert(prDomAxisId.first); 704 usedGrid.insert(currentGrid); 705 // domainIds.insert(prDomAxisId.first); 737 706 } 738 707 else 739 708 { 740 709 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()) 742 711 { 743 712 for (; it != itE; ++it) … … 830 799 831 800 //! 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 fields838 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 side852 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 side868 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 // } 879 848 880 849 //! Update calendar in each time step -
XIOS/trunk/src/node/distribution_client.cpp
r553 r567 16 16 nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_(), 17 17 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) 19 20 { 20 21 } … … 25 26 nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_(), 26 27 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) 28 30 { 29 31 readDistributionInfo(grid); … … 34 36 { 35 37 if (0 != localDataIndex_) delete localDataIndex_; 38 if (0 != localDataIndexSendToServer_) delete localDataIndexSendToServer_; 36 39 } 37 40 … … 46 49 std::vector<CDomain*> domList = grid->getDomains(); 47 50 std::vector<CAxis*> axisList = grid->getAxis(); 48 CArray<bool,1> &axisDomainOrder = grid->axisDomainOrder;51 CArray<bool,1> axisDomainOrder = grid->axisDomainOrder; 49 52 50 53 std::vector<CDomain*>::iterator itbDom, iteDom, itDom; … … 55 58 56 59 // 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); 59 64 60 65 // Then check mask of grid 66 int gridDim = domList.size()*2 + axisList.size(); 61 67 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 } 87 81 } 88 82 … … 96 90 \param [in] axisList List of axis of grid 97 91 \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 changing92 // \param [in] gridMask Mask of grid, for now, keep it 3 dimension, but it needs changing 99 93 */ 100 94 void CDistributionClient::readDistributionInfo(const std::vector<CDomain*>& domList, 101 95 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(); 105 100 numElement_ = axisDomainOrder.numElements(); // Number of element, e.x: Axis, Domain 106 101 … … 109 104 110 105 // Each domain or axis has its mask, of course 111 domainMasks_.resize(dom List.size());112 for (int i = 0; i < domain Masks_.size();++i)106 domainMasks_.resize(domainNum_); 107 for (int i = 0; i < domainNum_;++i) 113 108 { 114 109 domainMasks_[i].resize(domList[i]->mask.extent(0), domList[i]->mask.extent(1)); … … 116 111 } 117 112 118 axisMasks_.resize(axis List.size());119 for (int i = 0; i < axis Masks_.size(); ++i)113 axisMasks_.resize(axisNum_); 114 for (int i = 0; i < axisNum_; ++i) 120 115 { 121 116 axisMasks_[i].resize(axisList[i]->mask.numElements()); 122 117 axisMasks_[i] = axisList[i]->mask; 123 118 } 124 125 gridMask_.resize(gridMask.extent(0), gridMask.extent(1), gridMask.extent(2));126 gridMask_ = gridMask;127 119 128 120 // Because domain and axis can be in any order (axis1, domain1, axis2, axis3, ) … … 139 131 idx += 2; 140 132 } 133 else ++idx; 141 134 } 142 135 … … 215 208 ++idx; 216 209 } 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; 217 216 } 218 217 … … 343 342 344 343 // 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) 345 346 idxDomain = idxAxis = 0; 347 if (axisDomainOrder_(0)) ++idxDomain; 348 else ++idxAxis; 346 349 for (int i = 1; i < numElement_; ++i) 347 350 { … … 359 362 } 360 363 364 int maskIndex = currentIndex[0]; 365 for (int j = 0; j < this->dims_; ++j) 366 361 367 // Inner most index 362 368 idxDomain = idxAxis = 0; … … 370 376 else currentIndex[0] = localAxisIndex_[idxAxis][i]; 371 377 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])) 373 387 { 374 388 ++indexLocalDataOnClientCount; … … 389 403 this->globalIndex_ = new CArray<size_t,1>(indexSend2ServerCount); 390 404 localDataIndex_ = new CArray<int,1>(indexLocalDataOnClientCount); 405 localDataIndexSendToServer_ = new CArray<int,1>(indexSend2ServerCount); 391 406 392 407 // We need to loop with data index 393 innerLoopSize = dataNIndex_[0];394 ssize = 1; for (int i = 0; i < numElement_; ++i) ssize *= dataNIndex_[i];395 408 idxLoop.assign(numElement_,0); 396 409 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); 398 414 while (idx < ssize) 399 415 { … … 403 419 { 404 420 idxLoop[i] = 0; 421 correctOuterIndex[i] = 0; 405 422 ++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) 410 429 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; 413 434 414 435 for (int i = 1; i < numElement_; ++i) … … 418 439 if (indexDomainData_[idxDomain][idxLoop[i]]) 419 440 { 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; 425 445 ++idxDomain; 426 446 } … … 429 449 if (indexAxisData_[idxAxis][idxLoop[i]]) 430 450 { 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; 435 454 ++idxAxis; 436 455 } … … 464 483 } 465 484 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 466 493 if (isIndexDomainDataCorrect && 467 494 isIndexAxisDataCorrect && 468 gridMask_(currentIndex[0], currentIndex[1], currentIndex[2])) 469 { 470 (*localDataIndex_)(indexLocalDataOnClientCount) = count; 471 ++indexLocalDataOnClientCount; 495 gridMask_(gridMaskIndex)) 496 { 497 (*localDataIndex_)(indexLocalDataOnClientCount) = countLocalData; 472 498 473 499 bool isIndexOnServer = true; … … 486 512 } 487 513 (*this->globalIndex_)(indexSend2ServerCount) = globalIndex; 514 (*localDataIndexSendToServer_)(indexSend2ServerCount) = indexLocalDataOnClientCount; 488 515 ++indexSend2ServerCount; 489 516 } 490 } 491 ++count; 517 ++indexLocalDataOnClientCount; 518 } 519 ++countLocalData; 492 520 } 493 521 idxLoop[0] += innerLoopSize; … … 546 574 } 547 575 576 const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServerOnClient() const 577 { 578 return (*localDataIndexSendToServer_); 579 } 580 548 581 } // namespace xios -
XIOS/trunk/src/node/distribution_client.hpp
r554 r567 37 37 38 38 virtual const CArray<int,1>& getLocalDataIndexOnClient() const; 39 virtual const CArray<int,1>& getLocalDataIndexSendToServerOnClient() const; 40 39 41 std::vector<int> getNGlob() { return nGlob_; } 42 std::vector<int> getDataNIndex() { return dataNIndex_; } 43 bool isDataDistributed() { return isDataDistributed_; } 40 44 41 45 protected: … … 44 48 void readDistributionInfo(const std::vector<CDomain*>& domList, 45 49 const std::vector<CAxis*>& axisList, 46 const CArray<bool,1>& axisDomainOrder, 47 const CArray<bool,3>& gridMask); 48 50 const CArray<bool,1>& axisDomainOrder); 49 51 private: 50 52 //! Create local index of a domain … … 59 61 inline int getAxisIndex(const int& dataIndex, const int& dataBegin, const int& ni); 60 62 63 template<int N> 64 void readGridMaskInfo(const CArray<bool,N>& gridMask); 65 61 66 private: 62 67 //!< LocalData index on client 63 68 CArray<int,1>* localDataIndex_; 69 CArray<int,1>* localDataIndexSendToServer_; 64 70 65 71 private: … … 85 91 std::vector<CArray<bool,1> > axisMasks_; //!< Axis mask 86 92 87 // Just suppose that grid mask has 3 dimension. Need change88 CArray<bool,3> gridMask_; // TODO: more general grid mask89 90 93 std::vector<std::vector<int> > localDomainIndex_; 91 94 std::vector<std::vector<int> > localAxisIndex_; … … 96 99 std::vector<std::vector<bool> > indexAxisData_; 97 100 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 98 110 private: 99 111 CDistributionClient(const CDistributionClient& distClient); //! Not implement 100 112 }; 101 113 114 template<int N> 115 void 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 102 150 } // namespace xios 103 151 #endif // __XIOS_DISTRIBUTIONCLIENT_HPP__ -
XIOS/trunk/src/node/distribution_server.cpp
r553 r567 19 19 const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal) 20 20 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin) 21 { 22 createGlobalIndex(); 23 } 24 25 CDistributionServer::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) 21 31 { 22 32 createGlobalIndex(); … … 89 99 for (int i = 0; i < ssize; ++i) 90 100 { 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)); 92 103 if (itEnd != it) 93 104 { … … 114 125 for (int i = 0; i < ssize; ++i) 115 126 { 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)); 117 129 if (itEnd != it) 118 130 { … … 125 137 } 126 138 139 140 std::vector<int> CDistributionServer::getZoomBeginGlobal() const 141 { 142 return nZoomBeginGlobal_; 143 } 144 145 std::vector<int> CDistributionServer::getZoomBeginServer() const 146 { 147 return nZoomBegin_; 148 } 149 150 std::vector<int> CDistributionServer::getZoomSizeServer() const 151 { 152 return nZoomSize_; 153 } 127 154 } // namespace xios -
XIOS/trunk/src/node/distribution_server.hpp
r554 r567 24 24 /** Default constructor */ 25 25 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); 28 32 29 33 /** Default destructor */ 30 34 virtual ~CDistributionServer(); 35 36 std::vector<int> getZoomBeginGlobal() const; 37 std::vector<int> getZoomBeginServer() const; 38 std::vector<int> getZoomSizeServer() const; 31 39 32 40 virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); … … 37 45 private: 38 46 std::vector<int> nGlobal_; 47 std::vector<int> nZoomBeginGlobal_; 39 48 std::vector<int> nZoomSize_; 40 49 std::vector<int> nZoomBegin_; 50 41 51 }; 42 52 -
XIOS/trunk/src/node/field.cpp
- Property svn:executable set to *
r562 r567 152 152 list< CArray<double,1>* > list_data; 153 153 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 } 166 188 167 189 for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it; … … 189 211 void CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 190 212 { 191 192 213 if (data_srv.empty()) 193 214 { 194 // for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++)195 215 for (map<int, CArray<size_t, 1>* >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 196 216 { … … 234 254 { 235 255 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) 237 257 { 238 258 getRelFile()->checkFile(); … … 553 573 } 554 574 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();573 575 574 576 if (domList.empty() && axisList.empty()) … … 576 578 this->grid = CGrid::createGrid(vecDom, vecAxis); 577 579 } 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 // else588 // {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 // else623 // {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();632 580 } 633 581 … … 682 630 grid->outputField(it->first,*it->second, fieldOut.dataFirst()); 683 631 } 684 685 // grid->outputField(it->first,*it->second, fieldOut.);686 632 } 687 633 … … 689 635 { 690 636 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; 691 646 692 647 for (it = data_srv.begin(); it != data_srv.end(); it++) 693 648 { 694 grid->outputField(it->first, *it->second, fieldOut);649 grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ; 695 650 } 696 651 } … … 844 799 \return pair of Domain and Axis id 845 800 */ 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 // } 857 812 858 813 CVariable* CField::addVariable(const string& id) -
XIOS/trunk/src/node/field.hpp
r540 r567 135 135 void outputField(CArray<double,3>& fieldOut) ; 136 136 void outputField(CArray<double,2>& fieldOut) ; 137 void outputField(CArray<double,1>& fieldOut) ; 137 138 void scaleFactorAddOffset(double scaleFactor, double addOffset) ; 138 139 void parse(xml::CXMLNode & node) ; … … 156 157 157 158 158 const std::pair<StdString, StdString>& getDomainAxisIds();159 // const std::pair<StdString, StdString>& getDomainAxisIds(); 159 160 public : 160 161 /// Propriétés privées /// -
XIOS/trunk/src/node/file.cpp
r561 r567 212 212 213 213 allDomainEmpty=true ; 214 214 215 set<CDomain*> setDomain ; 215 216 … … 218 219 { 219 220 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) ; 222 227 } 223 228 nbDomain=setDomain.size() ; … … 320 325 321 326 bool append = !this->append.isEmpty() && this->append.getValue(); 322 327 323 328 bool useClassicFormat = !format.isEmpty() && format == format_attr::netcdf4_classic; 324 329 -
XIOS/trunk/src/node/grid.cpp
r553 r567 20 20 CGrid::CGrid(void) 21 21 : 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) 24 23 , 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_() 26 25 { 27 26 setVirtualDomainGroup(); … … 31 30 CGrid::CGrid(const StdString & id) 32 31 : 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) 35 33 , 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_() 37 35 { 38 36 setVirtualDomainGroup(); … … 42 40 CGrid::~CGrid(void) 43 41 { 44 // this->axis.reset() ;45 // this->domain.reset() ;46 42 deque< CArray<int, 1>* >::iterator it ; 47 43 48 44 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 57 45 for(map<int,CArray<size_t,1>* >::iterator it=outIndexFromClient.begin();it!=outIndexFromClient.end();++it) delete (it->second); 58 46 … … 60 48 if (0 != serverDistribution_) delete serverDistribution_; 61 49 if (0 != serverDistributionDescription_) delete serverDistributionDescription_; 62 63 50 } 64 51 … … 77 64 78 65 //--------------------------------------------------------------- 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 // } 84 99 85 100 //--------------------------------------------------------------- 86 101 87 const std::deque< CArray<int,1>* > & CGrid::getOutJIndex(void)const88 {89 return (this->out_j_index);90 }102 // bool CGrid::hasAxis(void) const 103 // { 104 // return (this->withAxis); 105 // } 91 106 92 107 //--------------------------------------------------------------- 93 108 94 const std::deque< CArray<int,1>* > & CGrid::getOutLIndex(void) const95 {96 return (this->out_l_index );97 }98 99 //---------------------------------------------------------------100 101 const CAxis* CGrid::getRelAxis (void) const102 {103 return (this->axis );104 }105 106 //---------------------------------------------------------------107 108 const CDomain* CGrid::getRelDomain(void) const109 {110 return (this->domain );111 }112 113 //---------------------------------------------------------------114 115 bool CGrid::hasAxis(void) const116 {117 return (this->withAxis);118 }119 120 //---------------------------------------------------------------121 122 109 StdSize CGrid::getDimension(void) const 123 110 { 124 return ( (this->withAxis)?3:2);111 return (globalDim_.size()); 125 112 } 126 113 … … 176 163 StdSize CGrid::getDataSize(void) const 177 164 { 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]; 182 168 return (retvalue); 183 169 } … … 201 187 202 188 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 228 189 void CGrid::solveDomainAxisRef(bool areAttributesChecked) 229 190 { … … 250 211 checkMask() ; 251 212 this->computeIndex() ; 252 253 213 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>());257 214 } 258 // this->computeIndexServer();259 215 this->isChecked = true; 260 216 } 261 217 262 263 218 void CGrid::checkMask(void) 264 219 { 265 220 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 } 295 256 //--------------------------------------------------------------- 296 257 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 332 258 void CGrid::solveDomainRef(bool sendAtt) 333 259 { 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") ;347 260 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 } 357 271 } 358 272 359 273 //--------------------------------------------------------------- 360 274 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 { 376 277 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) 381 284 { 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; 384 291 } 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 } 400 294 } 401 295 … … 415 309 416 310 // 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()); 418 314 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_.getGlobalIndexOnServer(); 419 315 std::vector<int> connectedServerRank; … … 427 323 storeIndex_client = (clientDistribution_->getLocalDataIndexOnClient()); 428 324 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) ? -1455 : data_j_index(n) + data_jbegin;456 i = (data_dim == 1) ? (temp_i - 1) % ni457 : (temp_i - 1) ;458 j = (data_dim == 1) ? (temp_i - 1) / ni459 : (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) ? -1485 : data_j_index(n) + data_jbegin;486 i = (data_dim == 1) ? (temp_i - 1) % ni487 : (temp_i - 1) ;488 j = (data_dim == 1) ? (temp_i - 1) / ni489 : (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 513 325 } 514 326 … … 517 329 CGrid* CGrid::createGrid(CDomain* domain) 518 330 { 519 StdString new_id = StdString("__") + domain->getId() + StdString("__") ;520 CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ;521 522 331 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 525 336 return (grid); 526 337 } … … 528 339 CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis) 529 340 { 530 StdString new_id = StdString("__") + domain->getId() +531 StdString("_") + axis->getId() + StdString("__") ;532 CGrid* grid = CGridGroup::get("grid_definition")->createChild(new_id) ;533 534 341 std::vector<CDomain*> vecDom(1,domain); 535 342 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 540 345 return (grid); 541 346 } … … 564 369 } 565 370 371 grid->computeGridGlobalDimension(domains, axis, grid->axisDomainOrder); 372 566 373 return (grid); 567 374 } … … 575 382 { 576 383 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) ;607 384 } 608 385 … … 629 406 } 630 407 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 723 408 void CGrid::sendIndex(void) 724 409 { … … 739 424 itLocal = localIndexSendToServer.begin(); 740 425 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 762 478 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 */809 479 } 810 480 … … 820 490 get(gridId)->recvIndex(rank,*buffer) ; 821 491 } 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(); 822 553 } 823 554 … … 835 566 indexMap[i] = idx; 836 567 if (true == axisDomainOrder(i)) 837 { 838 ++ssize; 839 idx += 2; 840 } 568 { 569 ++ssize; 570 idx += 2; 571 } 572 else 573 ++idx; 841 574 } 842 575 … … 844 577 std::vector<CDomain*> domainList = getDomains(); 845 578 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); 847 580 for (int i = 0; i < numElement; ++i) 848 581 { … … 851 584 nZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin_srv; 852 585 nZoomSize[indexMap[i]] = domainList[domainId]->zoom_ni_srv; 586 nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->zoom_ibegin; 853 587 nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 854 588 855 589 nZoomBegin[indexMap[i]+1] = domainList[domainId]->zoom_jbegin_srv; 856 590 nZoomSize[indexMap[i]+1] = domainList[domainId]->zoom_nj_srv; 591 nZoomBeginGlobal[indexMap[i]+1] = domainList[domainId]->zoom_jbegin; 857 592 nGlob[indexMap[i]+1] = domainList[domainId]->nj_glo; 858 593 ++domainId; … … 860 595 else 861 596 { 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; 864 600 nGlob[indexMap[i]] = axisList[axisId]->size; 865 601 ++axisId; 866 602 } 867 603 } 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); 869 610 } 870 611 … … 873 614 serverDistribution_->computeLocalIndex(outIndex); 874 615 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 */890 616 } 891 617 … … 1240 966 { 1241 967 SuperClass::parse(node); 968 1242 969 // 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;1244 970 std::vector<bool> order; 1245 971 -
XIOS/trunk/src/node/grid.hpp
r553 r567 15 15 #include "server_distribution_description.hpp" 16 16 #include "client_server_mapping.hpp" 17 #include "utils.hpp" 17 18 18 19 namespace xios { … … 133 134 void computeIndexServer(void); 134 135 void computeIndex(void); 135 // void solveDomainRef(void); //TODO temporarily comment136 // void solveAxisRef(void); // TODO: temporarily comment137 136 138 137 void solveDomainRef(bool checkAtt); … … 164 163 std::vector<CAxis*> getAxis(); 165 164 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; 166 172 167 173 public: 168 174 169 175 /// Propriétés privées /// 170 bool withAxis ;171 176 bool isChecked; 172 177 bool isDomainAxisChecked; 173 178 bool isIndexSent; 174 179 175 CAxis* axis ;176 CDomain* domain ;177 178 180 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 183 181 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 187 183 188 184 map<int, CArray<int, 1>* > storeIndex_toSrv ; 189 185 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 ;197 186 198 187 map<int, CArray<size_t, 1>* > outIndexFromClient; 199 188 void checkMask(void) ; 200 189 201 std::map<int, int> domConnectedServerSide_;202 bool isDomConServerComputed_;203 204 190 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); 205 196 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); 206 197 void setVirtualDomainGroup(); 207 198 void setVirtualAxisGroup(CAxisGroup* newVAxisGroup); 208 199 void setVirtualAxisGroup(); 209 // void setAxisList(); 200 210 201 void setAxisList(const std::vector<CAxis*> axis = std::vector<CAxis*>()); 211 // void setDomainList();212 202 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); 213 207 214 208 CDomain* addDomain(const std::string& id); … … 217 211 CAxisGroup* getVirtualAxisGroup() const; 218 212 CDomainGroup* getVirtualDomainGroup() const; 213 std::vector<int> globalDim_; 219 214 private: 220 215 CDomainGroup* vDomainGroup_; … … 222 217 std::vector<std::string> axisList_, domList_; 223 218 bool isAxisListSet, isDomListSet; 219 224 220 CDistributionClient* clientDistribution_; 225 221 CDistributionServer* serverDistribution_; 226 222 CServerDistributionDescription* serverDistributionDescription_; 227 223 CClientServerMapping clientServerMap_; 224 size_t writtenDataSize_; 228 225 }; // class CGrid 229 226 … … 231 228 232 229 template <int n> 233 230 void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 234 231 { 235 232 if (this->getDataSize() != field.numElements()) … … 241 238 } 242 239 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 243 329 ///-------------------------------------------------------------- 244 330 -
XIOS/trunk/src/output/nc4_data_output.cpp
r544 r567 483 483 if (axis->IsWritten(this->filename)) return; 484 484 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; 487 487 488 488 … … 492 492 try 493 493 { 494 SuperClassWriter::addDimension(axisid, zoom_size );494 SuperClassWriter::addDimension(axisid, zoom_size_srv); 495 495 dims.push_back(axisid); 496 496 … … 527 527 SuperClassWriter::definition_end(); 528 528 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) ; 531 531 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 532 532 … … 580 580 std::vector<StdString> dims, coodinates; 581 581 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 } 611 637 612 638 /* … … 648 674 } 649 675 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 } 680 687 681 688 try … … 772 779 } 773 780 } 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 // } 774 982 775 983 //-------------------------------------------------------------- … … 932 1140 933 1141 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 ; 938 1145 939 1146 StdString fieldid = (!field->name.isEmpty()) … … 992 1199 try 993 1200 { 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) 995 1207 { 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) 1007 1232 { 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]; 1017 1235 } 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; 1043 1246 } 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 } 1094 1248 } 1095 1249 catch (CNetCdfException& e) … … 1103 1257 } 1104 1258 } 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 // } 1105 1440 1106 1441 //--------------------------------------------------------------- -
XIOS/trunk/src/test/test_new_features.f90
r557 r567 25 25 26 26 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 30 30 INTEGER :: i,j,l,ts,n 31 31 … … 47 47 lon_glo(i,j)=(i-1)+(j-1)*ni_glo 48 48 lat_glo(i,j)=1000+(i-1)+(j-1)*ni_glo 49 lval_ni(i) = i-1 49 50 DO l=1,llm 50 51 field_A_glo(i,j,l)=(i-1)+(j-1)*ni_glo+10000*l 51 52 ENDDO 52 53 ENDDO 54 lval_nj(j) = j-1 53 55 ENDDO 54 56 ni=ni_glo ; ibegin=0 … … 61 63 jbegin=jbegin+nj 62 64 ENDDO 63 64 65 iend=ibegin+ni-1 ; jend=jbegin+nj-1 65 66 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)) 67 78 lon(:,:)=lon_glo(ibegin+1:iend+1,jbegin+1:jend+1) 68 79 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,:) 70 83 71 84 CALL xios_context_initialize("test",comm) … … 73 86 CALL xios_set_current_context(ctx_hdl) 74 87 75 CALL xios_get_calendar_type(calendar_type)76 PRINT *, "calendar_type = ", calendar_type88 ! CALL xios_get_calendar_type(calendar_type) 89 ! PRINT *, "calendar_type = ", calendar_type 77 90 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) 79 95 CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 80 96 CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) … … 89 105 CALL xios_add_child(file_hdl,field_hdl) 90 106 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") 91 111 92 112 dtime%second = 3600 … … 126 146 CALL xios_update_calendar(ts) 127 147 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) 128 150 CALL wait_us(5000) ; 129 151 ENDDO
Note: See TracChangeset
for help on using the changeset viewer.