Changeset 775 for XIOS/trunk
- Timestamp:
- 11/02/15 11:46:25 (9 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 2 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/REMAP/iodef.xml
r753 r775 8 8 <field_definition level="1" > 9 9 <field id="src_field" operation="instant" domain_ref="src_domain"/> 10 <field id="dst_field" operation="instant" field_ref="src_field" domain_ref="dst_domain"/> 11 <field id="tmp_field" operation="instant" domain_ref="src_domain_regular"/> 10 <!-- <field id="dst_field" operation="instant" field_ref="src_field" domain_ref="dst_domain"/>--> 11 <field id="tmp_field" operation="instant" domain_ref="src_domain_regular_tmp"/> 12 <field id="tmp_field_1" operation="instant" grid_ref="src_grid_curvilinear" /> 12 13 <field id="dst_field_regular" operation="instant" field_ref="tmp_field" domain_ref="dst_domain_regular" read_access="true"/> 13 <field id="dst_field_regular_pole" operation="instant" field_ref="src_field" domain_ref="dst_domain_regular_pole" read_access="true"/>14 <!-- <field id="dst_field_regular_pole" operation="instant" field_ref="src_field" domain_ref="dst_domain_regular_pole" read_access="true"/>--> 14 15 </field_definition> 15 16 … … 17 18 <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 18 19 <file id="output" name="output"> 19 <field field_ref="src_field" name="field" />20 <!-- <field field_ref="src_field" name="field" />--> 20 21 </file> 21 22 <file id="output_dst" name="output_dst" type="one_file"> 22 <field field_ref="dst_field" name="field" />23 <!-- <field field_ref="dst_field" name="field" />--> 23 24 </file> 24 25 <file id="out_dst_regular_pole" name="out_dst_regular_pole" type="one_file"> 25 <field field_ref="dst_field_regular_pole" name="field" />26 <!-- <field field_ref="dst_field_regular_pole" name="field" />--> 26 27 </file> 27 28 <file id="output_dst_regular" name="output_dst_regular" type="one_file"> 28 29 <field field_ref="dst_field_regular" name="field" /> 29 30 </file> 31 <file id="output_dst_curvilinear" name="output_dst_curvilinear" type="one_file"> 32 <field field_ref="tmp_field_1" operation="instant"/> 33 </file> 34 30 35 <file id="output_src_regular" name="output_src_regular" mode="read" type="multiple_file"> 31 <field id="src_field_regular" name="field" domain_ref="src_domain_regular" operation="instant"/>36 <!-- <field id="src_field_regular" name="field" domain_ref="src_domain_regular" operation="instant"/>--> 32 37 </file> 33 <file id="output_src_regular_tmp" name="output_src_regular_tmp"> 34 <!-- <field field_ref="tmp_field"/>--> 38 <file id="output_src_regular_tmp" name="output_src_regular_tmp" mode="read" type="one_file"> 39 <field id="src_field_regular_tmp" name="field" domain_ref="src_domain_regular_tmp" operation="instant"/> 40 </file> 41 42 <file id="output_src_curvilinear" name="output_src_curvilinear" mode="read" type="one_file"> 43 <!-- <field id="src_field_curvilinear" name="field_A" domain_ref="src_domain_curvilinear" axis_ref="src_axis_curvilinear" operation="instant"/>--> 44 <field id="src_field_curvilinear" name="field_A" grid_ref="src_grid_curvilinear" operation="instant"/> 35 45 </file> 36 46 </file_definition> … … 38 48 39 49 <axis_definition> 50 <axis id="src_axis_curvilinear" /> 40 51 </axis_definition> 41 52 … … 49 60 <interpolate_domain/> 50 61 </domain> 51 <domain id="dst_domain_regular" domain_src="src_domain_regular" ni_glo="90" nj_glo="45" type="rectilinear"> 62 <!-- <domain id="dst_domain_regular" domain_src="src_domain_regular" ni_glo="90" nj_glo="45" type="rectilinear">--> 63 <domain id="dst_domain_regular" domain_src="src_domain_regular_tmp" ni_glo="90" nj_glo="45" type="rectilinear"> 52 64 <generate_rectilinear_domain /> 53 65 <interpolate_domain/> … … 56 68 <generate_rectilinear_domain lat_start="-90" lat_end="90" lon_start="2" lon_end="360" /> 57 69 </domain> 70 <domain id="src_domain_regular_tmp" type="rectilinear"> 71 <generate_rectilinear_domain /> 72 </domain> 73 <domain id="src_domain_curvilinear" type="rectilinear"> 74 <generate_rectilinear_domain /> 75 </domain> 58 76 </domain_definition> 77 78 <grid_definition> 79 <grid id="src_grid_curvilinear"> 80 <domain domain_ref="src_domain_curvilinear"/> 81 <axis axis_ref="src_axis_curvilinear" /> 82 </grid> 83 </grid_definition> 59 84 </context> 60 61 85 62 86 <context id="xios"> -
XIOS/trunk/inputs/Version2/iodef.xml
r720 r775 33 33 <!-- <field field_ref="field_Axis_transformed_Interpolated" />--> 34 34 </file> 35 <file id="output_Domain_transformed_interpolated" name="output_Domain_transformed_interpolated" >36 <!-- <field field_ref="field_Domain_transformed_Interpolated" />-->35 <file id="output_Domain_transformed_interpolated" name="output_Domain_transformed_interpolated" type="one_file"> 36 <field field_ref="field_Domain_transformed_Interpolated" /> 37 37 </file> 38 38 <file id="output_Scalar" name="output_Scalar" type="one_file"> -
XIOS/trunk/src/attribute_array.hpp
r591 r775 9 9 #include "buffer_out.hpp" 10 10 #include "array_new.hpp" 11 11 #include "attribute_public.hpp" 12 12 13 13 namespace xios … … 15 15 /// ////////////////////// Déclarations ////////////////////// /// 16 16 template <typename T_numtype, int N_rank> 17 class CAttributeArray : public CAttribute, public CArray<T_numtype, N_rank> 17 class CAttributeArray : public CAttribute, public CArray<T_numtype, N_rank>, public PublicAttributes 18 18 { 19 19 public : … … 21 21 using CArray<T_numtype,N_rank>::operator = ; 22 22 // using Array<T_numtype,N_rank>::operator = ; 23 23 24 24 /// Constructeurs /// 25 25 explicit CAttributeArray(const StdString & id); 26 26 CAttributeArray(const StdString & id, xios_map<StdString, CAttribute*> & umap); 27 27 CAttributeArray(const StdString & id, const CArray<T_numtype, N_rank>& value); 28 CAttributeArray(const StdString & id, const CArray<T_numtype, N_rank>& value, 28 CAttributeArray(const StdString & id, const CArray<T_numtype, N_rank>& value, 29 29 xios_map<StdString, CAttribute*> & umap); 30 30 … … 36 36 void set(const CAttribute& attr) ; 37 37 void set(const CAttributeArray& attr) ; 38 void reset(void) ; 38 void reset(void) ; 39 39 void setInheritedValue(const CAttributeArray& attr ); 40 40 void setInheritedValue(const CAttribute& attr ); 41 41 CArray<T_numtype, N_rank> getInheritedValue(void) const ; 42 bool hasInheritedValue(void) const; 42 bool hasInheritedValue(void) const; 43 43 44 44 /// Destructeur /// … … 49 49 virtual string toString(void) const { return _toString();} 50 50 virtual void fromString(const StdString & str) { _fromString(str);} 51 virtual bool toBuffer (CBufferOut& buffer) const { return _toBuffer(buffer);} 52 virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); } 53 51 virtual bool toBuffer (CBufferOut& buffer) const { return _toBuffer(buffer);} 52 virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); } 53 54 54 virtual void generateCInterface(ostream& oss,const string& className) ; 55 55 virtual void generateFortran2003Interface(ostream& oss,const string& className) ; … … 61 61 virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ; 62 62 63 63 64 64 protected : 65 65 … … 72 72 bool _toBuffer (CBufferOut& buffer) const; 73 73 bool _fromBuffer(CBufferIn& buffer) ; 74 }; // class CAttributeEnum 74 }; // class CAttributeEnum 75 75 } // namespace xios 76 76 -
XIOS/trunk/src/attribute_array_impl.hpp
r501 r775 7 7 #include "attribute_array.hpp" 8 8 9 9 10 10 namespace xios 11 11 { … … 47 47 inheritedValue.reset() ; 48 48 } 49 49 50 50 template <typename T_numtype, int N_rank> 51 51 CArray<T_numtype,N_rank> CAttributeArray<T_numtype, N_rank>::getValue(void) const … … 65 65 { 66 66 this->set(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ; 67 } 67 } 68 68 69 69 template <typename T_numtype, int N_rank> … … 71 71 { 72 72 this->setValue(attr) ; 73 } 74 75 73 } 74 75 76 76 template <typename T_numtype, int N_rank> 77 77 void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttribute& attr) 78 78 { 79 79 this->setInheritedValue(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ; 80 } 80 } 81 81 82 82 template <typename T_numtype, int N_rank> 83 83 void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttributeArray& attr) 84 84 { 85 if (this->isEmpty() && attr.hasInheritedValue()) 85 if (this->isEmpty() && attr.hasInheritedValue()) 86 86 { 87 87 inheritedValue.resize(attr.shape()) ; 88 88 inheritedValue=attr ; 89 89 } 90 } 90 } 91 91 92 92 template <typename T_numtype, int N_rank> … … 95 95 if (this->isEmpty()) return inheritedValue.copy() ; 96 96 else return getValue() ; 97 } 98 97 } 98 99 99 template <typename T_numtype, int N_rank> 100 100 bool CAttributeArray<T_numtype,N_rank>::hasInheritedValue(void) const 101 101 { 102 102 return !this->isEmpty() || !inheritedValue.isEmpty() ; 103 } 104 103 } 104 105 105 106 106 template <typename T_numtype, int N_rank> … … 133 133 void CAttributeArray<T_numtype, N_rank>::generateCInterface(ostream& oss,const string& className) 134 134 { 135 CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 135 if (this->isAttributePublic()) 136 CInterface::AttributeCInterface<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 136 137 } 137 138 138 139 template <typename T_numtype, int N_rank> 139 140 void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className) 140 141 { 141 CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 142 if (this->isAttributePublic()) 143 CInterface::AttributeFortran2003Interface<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 142 144 } 143 145 144 146 template <typename T_numtype, int N_rank> 145 147 void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) 146 148 { 147 CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()+"_") ; 149 if (this->isAttributePublic()) 150 CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()+"_") ; 148 151 } 149 152 150 153 template <typename T_numtype, int N_rank> 151 154 void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceBody_(ostream& oss,const string& className) 152 155 { 153 CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 156 if (this->isAttributePublic()) 157 CInterface::AttributeFortranInterfaceBody<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 154 158 } 155 159 … … 157 161 void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) 158 162 { 159 CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 163 if (this->isAttributePublic()) 164 CInterface::AttributeFortranInterfaceDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 160 165 } 161 166 162 167 template <typename T_numtype, int N_rank> 163 168 void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) 164 169 { 165 CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()+"_") ; 170 if (this->isAttributePublic()) 171 CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()+"_") ; 166 172 } 167 173 168 174 template <typename T_numtype, int N_rank> 169 175 void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) 170 176 { 171 CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 177 if (this->isAttributePublic()) 178 CInterface::AttributeFortranInterfaceGetBody<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 172 179 } 173 180 … … 175 182 void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) 176 183 { 177 CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 184 if (this->isAttributePublic()) 185 CInterface::AttributeFortranInterfaceGetDeclaration<CArray<T_numtype, N_rank> >(oss, className, this->getName()) ; 178 186 } 179 187 } // namespace xios -
XIOS/trunk/src/attribute_template.hpp
r591 r775 12 12 #include "buffer_out.hpp" 13 13 #include "type.hpp" 14 14 #include "attribute_public.hpp" 15 15 16 16 namespace xios … … 18 18 /// ////////////////////// Déclarations ////////////////////// /// 19 19 template <class T> 20 class CAttributeTemplate : public CAttribute, public CType<T> 20 class CAttributeTemplate : public CAttribute, public CType<T>, public PublicAttributes 21 21 { 22 22 typedef CAttribute SuperClass; … … 45 45 /// Mutateurs /// 46 46 void setValue(const ValueType & value); 47 47 48 48 void set(const CAttribute& attr) ; 49 49 void set(const CAttributeTemplate& attr) ; … … 54 54 T getInheritedValue(void) const ; 55 55 bool hasInheritedValue(void) const; 56 56 57 57 /// Destructeur /// 58 58 virtual ~CAttributeTemplate(void) { } … … 66 66 // virtual CAttributeTemplate* clone() const {} 67 67 // virtual void toBinary (StdOStream & os) const; 68 // virtual void fromBinary(StdIStream & is); 68 // virtual void fromBinary(StdIStream & is); 69 69 70 virtual bool toBuffer (CBufferOut& buffer) const { return _toBuffer(buffer);} 71 virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); } 70 virtual bool toBuffer (CBufferOut& buffer) const { return _toBuffer(buffer);} 71 virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer); } 72 72 // virtual size_t size(void) const; 73 73 virtual void generateCInterface(ostream& oss,const string& className) ; … … 83 83 // virtual void generateFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className) ; 84 84 85 85 86 86 protected : 87 87 … … 93 93 bool _toBuffer (CBufferOut& buffer) const; 94 94 bool _fromBuffer(CBufferIn& buffer) ; 95 95 96 96 CType<T> inheritedValue ; 97 }; // class CAttribute 98 99 97 }; // class CAttribute 98 99 100 100 template <class T> void FromBinary(StdIStream & is, T & obj); 101 101 102 102 } // namespace xios 103 103 -
XIOS/trunk/src/attribute_template_impl.hpp
r591 r775 8 8 #include "attribute_template.hpp" 9 9 10 10 11 11 namespace xios 12 12 { … … 54 54 template <class T> 55 55 CAttributeTemplate<T>::~CAttributeTemplate(void) 56 { 56 { 57 57 // this->CType<T>::reset() ; 58 58 // this->clear(); … … 108 108 { 109 109 this->set(dynamic_cast<const CAttributeTemplate<T>& >(attr)) ; 110 } 110 } 111 111 112 112 template <class T> … … 114 114 { 115 115 CType<T>::set(attr) ; 116 } 116 } 117 117 118 118 template <class T> … … 120 120 { 121 121 this->setInheritedValue(dynamic_cast<const CAttributeTemplate<T>& >(attr)) ; 122 } 122 } 123 123 124 124 template <class T> … … 126 126 { 127 127 if (this->isEmpty() && attr.hasInheritedValue()) inheritedValue.set(attr.getInheritedValue()) ; 128 } 128 } 129 129 130 130 template <class T> … … 133 133 if (this->isEmpty()) return inheritedValue.get() ; 134 134 else return getValue() ; 135 } 136 135 } 136 137 137 template <class T> 138 138 bool CAttributeTemplate<T>::hasInheritedValue(void) const 139 139 { 140 140 return !this->isEmpty() || !inheritedValue.isEmpty() ; 141 } 142 141 } 142 143 143 //--------------------------------------------------------------- 144 144 … … 188 188 { 189 189 return CType<T>::toBuffer(buffer) ; 190 /* 190 /* 191 191 if (isEmpty()) return buffer.put(true) ; 192 192 else … … 205 205 { 206 206 return CType<T>::fromBuffer(buffer) ; 207 /* 207 /* 208 208 bool empty ; 209 209 bool ret=true ; 210 210 ret&=buffer.get(empty) ; 211 if (empty) 211 if (empty) 212 212 { 213 213 clear() ; … … 230 230 template <class T> 231 231 size_t CAttributeTemplate<T>::size(void) const 232 { 232 { 233 233 return CType<T>::size() ;*/ 234 /* 234 /* 235 235 if (isEmpty()) return sizeof(bool) ; 236 236 else … … 245 245 void CAttributeTemplate<T>::generateCInterface(ostream& oss,const string& className) 246 246 { 247 CInterface::AttributeCInterface<T>(oss, className, this->getName()) ; 247 if (this->isAttributePublic()) 248 CInterface::AttributeCInterface<T>(oss, className, this->getName()) ; 248 249 // CInterface::AttributeIsDefinedCInterface(oss, className, this->getName()) ; 249 250 } 250 251 251 252 template <typename T> 252 253 void CAttributeTemplate<T>::generateFortran2003Interface(ostream& oss,const string& className) 253 254 { 254 CInterface::AttributeFortran2003Interface<T>(oss, className, this->getName()) ; 255 if (this->isAttributePublic()) 256 CInterface::AttributeFortran2003Interface<T>(oss, className, this->getName()) ; 255 257 // CInterface::AttributeIsDefinedFortran2003Interface(oss, className, this->getName()) ; 256 258 } 257 259 258 260 template <typename T> 259 261 void CAttributeTemplate<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) 260 262 { 261 CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()+"_") ; 262 } 263 263 if (this->isAttributePublic()) 264 CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()+"_") ; 265 } 266 264 267 template <typename T> 265 268 void CAttributeTemplate<T>::generateFortranInterfaceBody_(ostream& oss,const string& className) 266 269 { 267 CInterface::AttributeFortranInterfaceBody<T>(oss, className, this->getName()) ; 270 if (this->isAttributePublic()) 271 CInterface::AttributeFortranInterfaceBody<T>(oss, className, this->getName()) ; 268 272 } 269 273 … … 271 275 void CAttributeTemplate<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) 272 276 { 273 CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()) ; 274 } 275 277 if (this->isAttributePublic()) 278 CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()) ; 279 } 280 276 281 template <typename T> 277 282 void CAttributeTemplate<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) 278 283 { 279 CInterface::AttributeFortranInterfaceGetDeclaration<T>(oss, className, this->getName()+"_") ; 280 } 281 282 284 if (this->isAttributePublic()) 285 CInterface::AttributeFortranInterfaceGetDeclaration<T>(oss, className, this->getName()+"_") ; 286 } 287 288 283 289 template <typename T> 284 290 void CAttributeTemplate<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) 285 291 { 286 CInterface::AttributeFortranInterfaceGetBody<T>(oss, className, this->getName()) ; 292 if (this->isAttributePublic()) 293 CInterface::AttributeFortranInterfaceGetBody<T>(oss, className, this->getName()) ; 287 294 } 288 295 … … 290 297 void CAttributeTemplate<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) 291 298 { 292 CInterface::AttributeFortranInterfaceGetDeclaration<T>(oss, className, this->getName()) ; 293 } 294 295 296 /* 297 //--------------------------------------------------------------- 298 299 // Spécialisations des templates pour la fonction [toString] 299 if (this->isAttributePublic()) 300 CInterface::AttributeFortranInterfaceGetDeclaration<T>(oss, className, this->getName()) ; 301 } 302 303 304 /* 305 //--------------------------------------------------------------- 306 307 // Spécialisations des templates pour la fonction [toString] 300 308 301 309 template <> … … 304 312 //--------------------------------------------------------------- 305 313 306 // Spécialisations des templates pour la fonction [fromString] 314 // Spécialisations des templates pour la fonction [fromString] 307 315 308 316 template <> // Chaîne de caractÚres. … … 333 341 template <> // Booléen 334 342 void CAttributeTemplate<bool>::toBinary(StdOStream & os) const; 335 343 336 344 template <> // Double 337 345 void CAttributeTemplate<double>::toBinary(StdOStream & os) const; … … 349 357 template <> // Booléen 350 358 void CAttributeTemplate<bool>::fromBinary(StdIStream & is); 351 359 352 360 template <> // Double 353 361 void CAttributeTemplate<double>::fromBinary(StdIStream & is); 354 362 355 363 ///-------------------------------------------------------------- 356 */ 364 */ 357 365 } // namespace xios 358 366 -
XIOS/trunk/src/config/axis_attribute.conf
r666 r775 7 7 DECLARE_ATTRIBUTE(int, n_glo) 8 8 DECLARE_ENUM2(positive, up, down) 9 10 /* GLOBAL */ 11 DECLARE_ATTRIBUTE(int, n_distributed_partition) 9 12 10 13 /* LOCAL */ -
XIOS/trunk/src/data_input.cpp
r602 r775 30 30 this->closeFile_(); 31 31 } 32 33 void CDataInput::readFieldAttributesMetaData(CField* field) 34 { 35 this->readFieldAttributes_(field, false); 36 } 37 38 void CDataInput::readFieldAttributesValues(CField* field) 39 { 40 this->readFieldAttributes_(field, true); 41 } 32 42 } // namespace xios -
XIOS/trunk/src/data_input.hpp
r602 r775 19 19 StdSize getFieldNbRecords(CField* field); 20 20 void readFieldData(CField* field); 21 void readFieldAttributesMetaData(CField* field); 22 void readFieldAttributesValues(CField* field); 21 23 void closeFile(void); 22 24 … … 26 28 virtual StdSize getFieldNbRecords_(CField* field) = 0; 27 29 virtual void readFieldData_(CField* field) = 0; 30 virtual void readFieldAttributes_(CField* field, bool readAttributeValues) = 0; 28 31 virtual void closeFile_(void) = 0; 29 32 -
XIOS/trunk/src/declare_attribute.hpp
r591 r775 3 3 4 4 /// ///////////////////////////// Macros ///////////////////////////// /// 5 6 5 #define DECLARE_ATTRIBUTE(type, name) \ 7 6 class name##_attr : public CAttributeTemplate<type> \ … … 18 17 } name; 19 18 19 #define DECLARE_ATTRIBUTE_PRIVATE(type, name) \ 20 class name##_attr : public CAttributeTemplate<type> \ 21 { \ 22 public : \ 23 name##_attr(void) \ 24 : CAttributeTemplate<type> \ 25 (#name, *CAttributeMap::Current) \ 26 { /* Ne rien faire de plus */ } \ 27 type operator=(const type & value) \ 28 { return (CAttributeTemplate<type>::operator=(value)); } \ 29 virtual bool isAttributePublic() \ 30 { return false; } \ 31 virtual ~name##_attr(void) \ 32 { /* Ne rien faire de plus */ } \ 33 } name; 34 20 35 #define DECLARE_ARRAY(T_num, T_rank, name) \ 21 36 class name##_attr : public CAttributeArray<T_num, T_rank> \ … … 26 41 virtual ~name##_attr(void) {} \ 27 42 } name; 28 43 44 #define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name) \ 45 class name##_attr : public CAttributeArray<T_num, T_rank> \ 46 { \ 47 public : \ 48 using CAttributeArray<T_num, T_rank>::operator = ; \ 49 name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \ 50 virtual bool isAttributePublic() \ 51 { return false; } \ 52 virtual ~name##_attr(void) {} \ 53 } name; 54 29 55 #define DECLARE_CLASS_ENUM(name) \ 30 56 class name##_attr : public CAttributeEnum<Enum_##name> \ … … 34 60 virtual ~name##_attr(void) {} \ 35 61 } name; 36 62 37 63 #define DECLARE_ENUM2(name,arg1,arg2) \ 38 64 class Enum_##name \ … … 44 70 } ; \ 45 71 DECLARE_CLASS_ENUM(name) 46 72 47 73 #define DECLARE_ENUM3(name,arg1,arg2,arg3) \ 48 74 class Enum_##name \ … … 113 139 int getSize(void) const { return 9 ; } \ 114 140 } ; \ 115 DECLARE_CLASS_ENUM(name) 141 DECLARE_CLASS_ENUM(name) 116 142 117 143 #define DECLARE_TYPE(name) \ -
XIOS/trunk/src/declare_ref_func.hpp
- Property svn:executable set to *
r771 r775 19 19 C##type* getDirect##type##Reference(void) const; \ 20 20 const StdString& get##type##OutputName(void) const; \ 21 void setAttributesBaseReference(bool apply = true); \ 21 22 22 23 // Definitions … … 43 44 SuperClassAttribute::setAttributes(refer_ptr, apply); \ 44 45 } \ 46 } \ 47 \ 48 void C##type::setAttributesBaseReference(bool apply) \ 49 { \ 50 baseRefObject->setAttributes(this, apply); \ 45 51 } \ 46 52 \ -
XIOS/trunk/src/io/nc4_data_input.cpp
r770 r775 3 3 #include "context.hpp" 4 4 #include "context_server.hpp" 5 #include "context_client.hpp" 6 #include "domain.hpp" 7 #include "axis.hpp" 5 8 6 9 namespace xios … … 12 15 , filename(filename) 13 16 , isCollective(isCollective) 17 , readMetaDataDomains_(), readValueDomains_() 18 , readMetaDataAxis_(), readValueAxis_() 14 19 { 15 20 SuperClass::type = multifile ? MULTI_FILE : ONE_FILE; … … 126 131 } 127 132 133 void CNc4DataInput::readFieldAttributes_(CField* field, bool readAttributeValues) 134 { 135 StdString fieldId = !field->name.isEmpty() ? field->name.getValue() : field->getBaseFieldReference()->getId(); 136 137 CGrid* grid = field->grid; 138 139 std::vector<CDomain*> domainP = grid->getDomains(); 140 std::vector<CAxis*> axisP = grid->getAxis(); 141 int gridDim = domainP.size() * 2 + axisP.size(); 142 143 // Verify the compatibility of dimension of declared grid and real grid in file 144 int realGridDim = 1; 145 std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId); 146 realGridDim = SuperClassWriter::isTemporal(fieldId) ? dimSizeMap.size() - 1 : dimSizeMap.size(); 147 148 if (gridDim != realGridDim) 149 ERROR("CNc4DataInput::readFieldAttributes_(CField* field, bool readAttributeValues)", 150 << "Field '" << fieldId << "' has incorrect dimension " << std::endl 151 << "Verify dimension of grid defined by 'grid_ref' or 'domain_ref'/'axis_ref' and dimension of grid in read file."); 152 153 // Remove unlimited dimension from the map, we dont need it anymore 154 if (SuperClassWriter::isTemporal(fieldId)) dimSizeMap.erase(SuperClassWriter::getUnlimitedDimensionName()); 155 int mapSize = dimSizeMap.size() - 1; 156 157 // Now process domain and axis 158 CArray<bool,1> axisDomainOrder = grid->axis_domain_order; 159 int numElement = domainP.size() + axisP.size(); 160 int elementPosition = 0; 161 int idxDomain = 0, idxAxis = 0; 162 163 std::pair<std::set<StdString>::iterator,bool> it; 164 for (int i = 0; i < numElement; ++i) 165 { 166 if(axisDomainOrder(i)) 167 { 168 if (readAttributeValues) 169 { 170 it = readValueDomains_.insert(domainP[idxDomain]->getId()); 171 if (it.second) readDomainAttributeValueFromFile(domainP[idxDomain], dimSizeMap, mapSize - 1 - elementPosition, fieldId); 172 } 173 else 174 { 175 it = readMetaDataDomains_.insert(domainP[idxDomain]->getId()); 176 if (it.second) readDomainAttributesFromFile(domainP[idxDomain], dimSizeMap, mapSize - 1 - elementPosition, fieldId); 177 } 178 ++idxDomain; 179 elementPosition += 2; 180 } 181 else 182 { 183 if (readAttributeValues) 184 { 185 it = readValueAxis_.insert(axisP[idxAxis]->getId()); 186 if (it.second) readAxisAttributeValueFromFile(axisP[idxAxis], dimSizeMap, mapSize - elementPosition, fieldId); 187 } 188 else 189 { 190 it = readMetaDataAxis_.insert(axisP[idxAxis]->getId()); 191 if (it.second) readAxisAttributesFromFile(axisP[idxAxis], dimSizeMap, mapSize - elementPosition, fieldId); 192 } 193 ++idxAxis; 194 ++elementPosition; 195 } 196 } 197 } 198 199 /*! 200 Read attributes of a domain from a file 201 \param [in] domain domain whose attributes are read from the file 202 \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file 203 \param [in] emelentPosition position of domain in grid 204 */ 205 void CNc4DataInput::readDomainAttributeValueFromFile(CDomain* domain, std::map<StdString, StdSize>& dimSizeMap, 206 int elementPosition, const StdString& fieldId) 207 { 208 // There are some optional attributes of a domain to retrieve from file // + lon lat? 209 std::map<StdString, StdSize>::const_iterator itMapNj = dimSizeMap.begin(), itMapNi, 210 iteMap = dimSizeMap.end(); 211 212 for (int i = 0; i < elementPosition; ++i, ++itMapNj) {} 213 itMapNi = itMapNj; ++itMapNi; 214 215 if (this->isRectilinear(fieldId)) 216 { 217 // Ok, try to read some f.. attributes such as longitude and latitude 218 domain->latvalue_rectilinear_read_from_file.resize(itMapNj->second); 219 std::vector<StdSize> nBeginLat(1, 0), nSizeLat(1, itMapNj->second); 220 readFieldVariableValue(domain->latvalue_rectilinear_read_from_file, itMapNj->first, nBeginLat, nSizeLat, true); 221 222 domain->lonvalue_rectilinear_read_from_file.resize(itMapNi->second); 223 std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second); 224 readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true); 225 domain->fillInRectilinearLonLat(); 226 } 227 else if (this->isCurvilinear(fieldId)) 228 { 229 230 } 231 else if (this->isUnstructured(fieldId)) 232 { 233 234 } 235 } 236 237 /*! 238 Read attributes of a domain from a file 239 \param [in] domain domain whose attributes are read from the file 240 \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file 241 \param [in] emelentPosition position of domain in grid 242 */ 243 void CNc4DataInput::readDomainAttributesFromFile(CDomain* domain, std::map<StdString, StdSize>& dimSizeMap, 244 int elementPosition, const StdString& fieldId) 245 { 246 // There are some mandatory attributes of a domain to retrieve from file 247 // + ni_glo, nj_glo 248 std::map<StdString, StdSize>::const_iterator itMapNj = dimSizeMap.begin(), itMapNi, 249 iteMap = dimSizeMap.end(); 250 for (int i = 0; i < elementPosition; ++i, ++itMapNj) {} 251 itMapNi = itMapNj; ++itMapNi; 252 253 if (this->isRectilinear(fieldId)) 254 { 255 domain->nj_glo.setValue(itMapNj->second); 256 domain->ni_glo.setValue((itMapNi)->second); 257 } 258 else if (this->isCurvilinear(fieldId)) 259 { 260 261 } 262 else if (this->isUnstructured(fieldId)) 263 { 264 265 } 266 } 267 268 /*! 269 Read attributes of an axis from a file 270 \param [in] axis axis whose attributes are read from the file 271 \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file 272 \param [in] emelentPosition position of axis in grid 273 */ 274 void CNc4DataInput::readAxisAttributesFromFile(CAxis* axis, std::map<StdString, StdSize>& dimSizeMap, 275 int elementPosition, const StdString& fieldId) 276 { 277 std::map<StdString, StdSize>::const_iterator itMapN = dimSizeMap.begin(), 278 iteMap = dimSizeMap.end(); 279 for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 280 axis->n_glo.setValue(itMapN->second); 281 } 282 283 /*! 284 Read attributes of an axis from a file 285 \param [in] axis axis whose attributes are read from the file 286 \param [in] dimSizeMap Dimensions and and their corresponding names and size read from file 287 \param [in] emelentPosition position of axis in grid 288 */ 289 void CNc4DataInput::readAxisAttributeValueFromFile(CAxis* axis, std::map<StdString, StdSize>& dimSizeMap, 290 int elementPosition, const StdString& fieldId) 291 { 292 std::map<StdString, StdSize>::const_iterator itMapN = dimSizeMap.begin(), 293 iteMap = dimSizeMap.end(); 294 for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 295 296 { // Read axis value 297 std::vector<StdSize> nBegin(1, 0), nSize(1, itMapN->second); 298 CArray<double,1> readAxisValue(itMapN->second); 299 readFieldVariableValue(readAxisValue, itMapN->first, nBegin, nSize, true); 300 int begin = 0, n = itMapN->second; 301 if (!axis->begin.isEmpty()) begin = axis->begin.getValue(); 302 if (!axis->n.isEmpty()) n = axis->n.getValue(); 303 axis->value.resize(n); 304 for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 305 } 306 } 307 308 void CNc4DataInput::readFieldVariableValue(CArray<double,1>& var, const StdString& varId, 309 const std::vector<StdSize>& nBegin, 310 const std::vector<StdSize>& nSize, 311 bool forceIndependent) 312 { 313 if (SuperClass::type==MULTI_FILE || !isCollective) return; 314 315 bool openCollective = isCollective; 316 if (forceIndependent) openCollective = !isCollective; 317 switch (SuperClass::type) 318 { 319 case MULTI_FILE: 320 SuperClassWriter::getData(var, varId, openCollective, 0); 321 break; 322 case ONE_FILE: 323 { 324 SuperClassWriter::getData(var, varId, openCollective, 0, &nBegin, &nSize); 325 break; 326 } 327 } 328 } 329 128 330 void CNc4DataInput::closeFile_(void) 129 331 { -
XIOS/trunk/src/io/nc4_data_input.hpp
r685 r775 9 9 namespace xios 10 10 { 11 class CDomain; 12 class CAxis; 13 11 14 class CNc4DataInput 12 15 : protected CINetCDF4 … … 33 36 virtual StdSize getFieldNbRecords_(CField* field); 34 37 virtual void readFieldData_(CField* field); 38 virtual void readFieldAttributes_(CField* field, bool readAttributeValues); 35 39 virtual void closeFile_(void); 40 41 private: 42 void readDomainAttributesFromFile(CDomain* domain, std::map<StdString, StdSize>& dimSizeMap, 43 int elementPosition, const StdString& fieldId); 44 void readDomainAttributeValueFromFile(CDomain* domain, std::map<StdString, StdSize>& dimSizeMap, 45 int elementPosition, const StdString& fieldId); 46 47 void readAxisAttributesFromFile(CAxis* axis, std::map<StdString, StdSize>& dimSizeMap, 48 int elementPosition, const StdString& fieldId); 49 void readAxisAttributeValueFromFile(CAxis* axis, std::map<StdString, StdSize>& dimSizeMap, 50 int elementPosition, const StdString& fieldId); 51 52 void readFieldVariableValue(CArray<double,1>& var, const StdString& varId, 53 const std::vector<StdSize>& nBegin, 54 const std::vector<StdSize>& nSize, 55 bool forceIndependent = false); 56 57 private: 58 std::set<StdString> readMetaDataDomains_, readValueDomains_; 59 std::set<StdString> readMetaDataAxis_, readValueAxis_; 36 60 37 61 private: -
XIOS/trunk/src/node/axis.cpp
r772 r775 185 185 CAxis* axis = CAxisGroup::get("axis_definition")->createChild(); 186 186 return axis; 187 } 188 189 void CAxis::fillInValues(const CArray<double,1>& values) 190 { 191 this->value = values; 187 192 } 188 193 -
XIOS/trunk/src/node/axis.hpp
r742 r775 111 111 void solveInheritanceTransformation(); 112 112 TransMapTypes getAllTransformations(); 113 void fillInValues(const CArray<double,1>& values); 113 114 114 115 public: -
XIOS/trunk/src/node/context.cpp
r773 r775 313 313 registryOut=new CRegistry(intraComm) ; 314 314 registryOut->setPath(getId()) ; 315 315 316 316 MPI_Comm intraCommClient, interCommClient; 317 317 if (cxtClient) // Attached mode … … 362 362 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 363 363 } 364 364 365 365 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 366 366 MPI_Comm_free(&(*it)); … … 439 439 for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 440 440 (void)this->enabledFiles[i]->getEnabledFields(); 441 } 442 443 void CContext::findAllEnabledFieldsInReadModeFiles(void) 444 { 445 for (unsigned int i = 0; i < this->enabledReadModeFiles.size(); ++i) 446 (void)this->enabledReadModeFiles[i]->getEnabledFields(); 447 } 448 449 void CContext::readAttributesOfEnabledFieldsInReadModeFiles() 450 { 451 for (unsigned int i = 0; i < this->enabledReadModeFiles.size(); ++i) 452 (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 441 453 } 442 454 … … 785 797 // Find all enabled fields of each file 786 798 this->findAllEnabledFields(); 787 799 this->findAllEnabledFieldsInReadModeFiles(); 800 801 if (hasClient && !hasServer) 802 { 803 // Try to read attributes of fields in file then fill in corresponding grid (or domain, axis) 804 this->readAttributesOfEnabledFieldsInReadModeFiles(); 805 } 788 806 // Search and rebuild all reference object of enabled fields 789 807 this->solveAllRefOfEnabledFields(false); … … 1053 1071 if (hasClient) 1054 1072 { 1055 checkPrefetchingOfEnabledReadModeFiles();1073 //checkPrefetchingOfEnabledReadModeFiles(); 1056 1074 garbageCollector.invalidate(calendar->getCurrentDate()); 1057 1075 } -
XIOS/trunk/src/node/context.hpp
r740 r775 103 103 // Some functions to process context 104 104 void findAllEnabledFields(void); 105 void findAllEnabledFieldsInReadModeFiles(void); 106 void readAttributesOfEnabledFieldsInReadModeFiles(); 105 107 void solveAllInheritance(bool apply=true); 106 108 void findEnabledFiles(void); … … 218 220 // Concrete contex client 219 221 CContextClient* client; 220 CRegistry* registryIn ; //!< input registry which is read from file 222 CRegistry* registryIn ; //!< input registry which is read from file 221 223 CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 222 224 223 225 private: 224 226 bool isPostProcessed; -
XIOS/trunk/src/node/domain.cpp
r772 r775 339 339 void CDomain::fillInRectilinearLonLat() 340 340 { 341 if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); 342 if (!latvalue_2d.isEmpty()) latvalue_1d.free(); 343 lonvalue_1d.resize(ni); 344 latvalue_1d.resize(nj); 345 346 double lonRange = lon_end - lon_start; 347 double latRange = lat_end - lat_start; 348 349 double lonStep = (1 == ni_glo.getValue()) ? lonRange : lonRange/double(ni_glo.getValue()-1); 350 double latStep = (1 == nj_glo.getValue()) ? latRange : latRange/double(nj_glo.getValue()-1); 351 352 // Assign lon value 353 for (int i = 0; i < ni; ++i) 354 { 355 if (0 == (ibegin + i)) 341 if (!lonvalue_rectilinear_read_from_file.isEmpty()) 342 { 343 lonvalue_1d.resize(ni); 344 for (int idx = 0; idx < ni; ++idx) 345 lonvalue_1d(idx) = lonvalue_rectilinear_read_from_file(idx+ibegin); 346 lon_start.setValue(lonvalue_rectilinear_read_from_file(0)); 347 lon_end.setValue(lonvalue_rectilinear_read_from_file(ni_glo-1)); 348 } 349 else 350 { 351 if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); 352 lonvalue_1d.resize(ni); 353 double lonRange = lon_end - lon_start; 354 double lonStep = (1 == ni_glo.getValue()) ? lonRange : lonRange/double(ni_glo.getValue()-1); 355 356 // Assign lon value 357 for (int i = 0; i < ni; ++i) 356 358 { 357 lonvalue_1d(i) = lon_start; 359 if (0 == (ibegin + i)) 360 { 361 lonvalue_1d(i) = lon_start; 362 } 363 else if (ni_glo == (ibegin + i + 1)) 364 { 365 lonvalue_1d(i) = lon_end; 366 } 367 else 368 { 369 lonvalue_1d(i) = (ibegin + i) * lonStep + lon_start; 370 } 358 371 } 359 else if (ni_glo == (ibegin + i + 1)) 372 } 373 374 375 if (!latvalue_rectilinear_read_from_file.isEmpty()) 376 { 377 latvalue_1d.resize(nj); 378 for (int idx = 0; idx < nj; ++idx) 379 latvalue_1d(idx) = latvalue_rectilinear_read_from_file(idx+jbegin); 380 lat_start.setValue(latvalue_rectilinear_read_from_file(0)); 381 lat_end.setValue(latvalue_rectilinear_read_from_file(nj_glo-1)); 382 } 383 else 384 { 385 if (!latvalue_2d.isEmpty()) latvalue_1d.free(); 386 latvalue_1d.resize(nj); 387 388 double latRange = lat_end - lat_start; 389 double latStep = (1 == nj_glo.getValue()) ? latRange : latRange/double(nj_glo.getValue()-1); 390 391 for (int j = 0; j < nj; ++j) 360 392 { 361 lonvalue_1d(i) = lon_end; 362 } 363 else 364 { 365 lonvalue_1d(i) = (ibegin + i) * lonStep + lon_start; 366 } 367 } 368 369 for (int j = 0; j < nj; ++j) 370 { 371 if (0 == (jbegin + j)) 372 { 373 latvalue_1d(j) = lat_start; 374 } 375 else if (nj_glo == (jbegin + j + 1)) 376 { 377 latvalue_1d(j) = lat_end; 378 } 379 else 380 { 381 latvalue_1d(j) = (jbegin + j) * latStep + lat_start; 393 if (0 == (jbegin + j)) 394 { 395 latvalue_1d(j) = lat_start; 396 } 397 else if (nj_glo == (jbegin + j + 1)) 398 { 399 latvalue_1d(j) = lat_end; 400 } 401 else 402 { 403 latvalue_1d(j) = (jbegin + j) * latStep + lat_start; 404 } 382 405 } 383 406 } … … 389 412 int i,j,k; 390 413 const int nvertexValue = 4; 391 392 double boundsLonRange = bounds_lon_end - bounds_lon_start;393 double boundsLatRange = bounds_lat_end - bounds_lat_start;394 395 414 boundsLon.resize(nvertexValue,ni*nj); 415 416 if (!lonvalue_rectilinear_read_from_file.isEmpty()) 417 { 418 double lonStepStart = lonvalue_rectilinear_read_from_file(1)-lonvalue_rectilinear_read_from_file(0); 419 bounds_lon_start.setValue(lonvalue_rectilinear_read_from_file(0) - lonStepStart/2); 420 double lonStepEnd = (lonvalue_rectilinear_read_from_file(ni_glo-1)-lonvalue_rectilinear_read_from_file(ni_glo-2)); 421 bounds_lon_end.setValue(lonvalue_rectilinear_read_from_file(ni_glo-1) + lonStepEnd/2); 422 double errorBoundsLon = std::abs(360-std::abs(bounds_lon_end-bounds_lon_start)); 423 if (errorBoundsLon > NumTraits<double>::epsilon()) bounds_lon_end.setValue(bounds_lon_start+360); 424 for(j=0;j<nj;++j) 425 for(i=0;i<ni;++i) 426 { 427 k=j*ni+i; 428 boundsLon(0,k) = boundsLon(1,k) = (0 == (ibegin + i)) ? bounds_lon_start 429 : (lonvalue_rectilinear_read_from_file(ibegin + i)+lonvalue_rectilinear_read_from_file(ibegin + i-1))/2; 430 boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) == ni_glo) ? bounds_lon_end 431 : (lonvalue_rectilinear_read_from_file(ibegin + i + 1)+lonvalue_rectilinear_read_from_file(ibegin + i))/2; 432 } 433 } 434 else 435 { 436 double boundsLonRange = bounds_lon_end - bounds_lon_start; 437 double lonStep = boundsLonRange/double(ni_glo.getValue()); 438 for(j=0;j<nj;++j) 439 for(i=0;i<ni;++i) 440 { 441 k=j*ni+i; 442 boundsLon(0,k) = boundsLon(1,k) = (0 != (ibegin + i)) ? (ibegin + i) * lonStep + bounds_lon_start 443 : bounds_lon_start; 444 boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) != ni_glo) ? (ibegin + i +1) * lonStep + bounds_lon_start 445 : bounds_lon_end; 446 } 447 } 448 396 449 boundsLat.resize(nvertexValue,nj*ni); 397 398 double lonStep = boundsLonRange/double(ni_glo.getValue()); 399 double latStep = boundsLatRange/double(nj_glo.getValue()); 400 401 for(j=0;j<nj;++j) 402 for(i=0;i<ni;++i) 403 { 404 k=j*ni+i; 405 boundsLon(0,k) = boundsLon(1,k) = (0 != (ibegin + i)) ? (ibegin + i) * lonStep + bounds_lon_start 406 : bounds_lon_start; 407 boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) != ni_glo) ? (ibegin + i +1) * lonStep + bounds_lon_start 408 : bounds_lon_end; 409 } 410 411 double bounds_lat_start_pole = bounds_lat_start; 412 double bounds_lat_end_pole = bounds_lat_end; 413 if (isNorthPole) bounds_lat_start_pole = lat_start; 414 if (isSouthPole) bounds_lat_end_pole = lat_end; 415 416 for(j=0;j<nj;++j) 417 for(i=0;i<ni;++i) 418 { 419 k=j*ni+i; 420 boundsLat(1,k) = boundsLat(2,k) = (0 != (jbegin + j)) ? (jbegin + j) * latStep + bounds_lat_start 421 : bounds_lat_start_pole; 422 boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) != nj_glo) ? (jbegin + j +1) * latStep + bounds_lat_start 423 : bounds_lat_end_pole; 424 } 425 } 426 427 /*! 428 Temporary function to verify whether a rectilinear domain is created automatically. 429 The domain is distributed into number of parts which are equal to number of clients (intracomm) 430 */ 431 void CDomain::checkGenerate() 432 { 433 TransMapTypes trans = this->getAllTransformations(); 434 TransMapTypes::const_iterator it = trans.begin(), ite = trans.end(); 435 int transOrder = 0; 436 for (; it != ite; ++it, ++transOrder) 437 { 438 ETranformationType transType = it->first; 439 if ((TRANS_GENERATE_RECTILINEAR_DOMAIN == transType) && (0 == transOrder)) 440 { 441 CContext* context = CContext::getCurrent(); 442 CContextClient* client = context->client; 443 int nbClient; 444 MPI_Comm_size(client->intraComm,&nbClient); 445 it->second->checkValid(this); 446 this->redistribute(nbClient); 447 break; 448 } 449 } 450 } 451 450 if (!latvalue_rectilinear_read_from_file.isEmpty()) 451 { 452 double latStepStart = latvalue_rectilinear_read_from_file(1)-latvalue_rectilinear_read_from_file(0); 453 bounds_lat_start.setValue(latvalue_rectilinear_read_from_file(0) - latStepStart/2); 454 double latStepEnd = (latvalue_rectilinear_read_from_file(nj_glo-1)-latvalue_rectilinear_read_from_file(nj_glo-2)); 455 bounds_lat_end.setValue(latvalue_rectilinear_read_from_file(nj_glo-1) + latStepEnd/2); 456 double bounds_lat_start_pole = bounds_lat_start; 457 double bounds_lat_end_pole = bounds_lat_end; 458 if (isNorthPole) bounds_lat_start_pole = lat_start; 459 if (isSouthPole) bounds_lat_end_pole = lat_end; 460 461 for(j=0;j<nj;++j) 462 for(i=0;i<ni;++i) 463 { 464 k=j*ni+i; 465 boundsLat(1,k) = boundsLat(2,k) = (0 == (jbegin + j)) ? bounds_lat_start_pole 466 : (latvalue_rectilinear_read_from_file(jbegin + j)+latvalue_rectilinear_read_from_file(jbegin + j-1))/2; 467 boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) == nj_glo) ? bounds_lat_end_pole 468 : (latvalue_rectilinear_read_from_file(jbegin + j + 1)+latvalue_rectilinear_read_from_file(jbegin + j))/2; 469 } 470 } 471 else 472 { 473 double boundsLatRange = bounds_lat_end - bounds_lat_start; 474 double latStep = boundsLatRange/double(nj_glo.getValue()); 475 double bounds_lat_start_pole = bounds_lat_start; 476 double bounds_lat_end_pole = bounds_lat_end; 477 if (isNorthPole) bounds_lat_start_pole = lat_start; 478 if (isSouthPole) bounds_lat_end_pole = lat_end; 479 480 for(j=0;j<nj;++j) 481 for(i=0;i<ni;++i) 482 { 483 k=j*ni+i; 484 boundsLat(1,k) = boundsLat(2,k) = (0 != (jbegin + j)) ? (jbegin + j) * latStep + bounds_lat_start 485 : bounds_lat_start_pole; 486 boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) != nj_glo) ? (jbegin + j +1) * latStep + bounds_lat_start 487 : bounds_lat_end_pole; 488 } 489 } 490 491 } 452 492 453 493 void CDomain::checkDomain(void) … … 1029 1069 CContext* context=CContext::getCurrent(); 1030 1070 1031 this->checkGenerate();1032 1071 this->checkDomain(); 1033 1072 this->checkBounds(); -
XIOS/trunk/src/node/domain.hpp
r743 r775 30 30 BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain) 31 31 # include "domain_attribute.conf" 32 # include "domain_attribute_private.conf" 32 33 END_DECLARE_ATTRIBUTE_MAP(CDomain) 33 34 … … 105 106 int nj_srv,jbegin_srv,jend_srv ; 106 107 int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ; 107 108 double bounds_lon_start, bounds_lon_end;109 double bounds_lat_start, bounds_lat_end;110 double lon_start, lon_end;111 double lat_start, lat_end;112 108 113 109 CArray<double, 1> lonvalue_srv, latvalue_srv ; … … 133 129 void fillInRectilinearBoundLonLat(CArray<double,2>& boundsLon, CArray<double,2>& boundsLat, 134 130 bool isNorthPole = false, bool isSouthPole = false); 131 void fillInRectilinearLonLat(); 135 132 136 133 static bool dispatchEvent(CEventServer& event); … … 172 169 void checkArea(void); 173 170 void checkLonLat(); 174 void checkGenerate();175 171 176 172 void checkTransformations(); 177 173 void setTransformations(const TransMapTypes&); 178 174 void computeNGlobDomain(); 179 void fillInRectilinearLonLat();180 175 181 176 void sendIndex(); -
XIOS/trunk/src/node/field.cpp
r771 r775 826 826 if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) 827 827 grid->completeGrid(getDirectFieldReference()->grid); 828 else 829 grid->completeGrid(); 830 } 831 832 void CField::solveGridDomainAxisBaseRef() 833 { 834 grid->solveDomainAxisRef(false); 835 grid->solveDomainAxisBaseRef(); 828 836 } 829 837 -
XIOS/trunk/src/node/field.hpp
r737 r775 114 114 void solveTransformedGrid(); 115 115 void solveGenerateGrid(); 116 void solveGridDomainAxisBaseRef(); 116 117 117 118 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); -
XIOS/trunk/src/node/file.cpp
r773 r775 24 24 : CObjectTemplate<CFile>(), CFileAttributes() 25 25 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 26 , allDomainEmpty(false), isOpen(false) 26 27 { 27 28 setVirtualFieldGroup(); … … 32 33 : CObjectTemplate<CFile>(id), CFileAttributes() 33 34 , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 35 , allDomainEmpty(false), isOpen(false) 34 36 { 35 37 setVirtualFieldGroup(); … … 543 545 //---------------------------------------------------------------- 544 546 547 void CFile::readAttributesOfEnabledFieldsInReadMode() 548 { 549 if (enabledFields.empty()) return; 550 551 // Just check file and try to open it 552 CContext* context = CContext::getCurrent(); 553 CContextClient* client=context->client; 554 555 MPI_Comm_dup(client->intraComm, &fileComm); 556 checkFile(); 557 for (int idx = 0; idx < enabledFields.size(); ++idx) 558 { 559 // First of all, find out which domain and axis associated with this field 560 enabledFields[idx]->solveGridReference(); 561 562 // Read attributes of domain and axis from this file 563 this->data_in->readFieldAttributesMetaData(enabledFields[idx]); 564 565 // Now complete domain and axis associated with this field 566 enabledFields[idx]->solveGenerateGrid(); 567 568 // Read necessary value from file 569 this->data_in->readFieldAttributesValues(enabledFields[idx]); 570 571 // Fill attributes for base reference 572 enabledFields[idx]->solveGridDomainAxisBaseRef(); 573 } 574 575 // Now everything is ok, close it 576 close(); 577 578 } 579 580 545 581 /*! 546 582 \brief Parse xml file and write information into file object -
XIOS/trunk/src/node/file.hpp
r773 r775 101 101 void openInReadMode(void); 102 102 void close(void); 103 void readAttributesOfEnabledFieldsInReadMode(); 103 104 104 105 // Some processing on file -
XIOS/trunk/src/node/generate_rectilinear_domain.cpp
r734 r775 89 89 double boundsLonRange = bounds_lon_end - bounds_lon_start; 90 90 double boundsLonStep = boundsLonRange/(double(niGlo)); 91 domainDst->bounds_lon_start = bounds_lon_start;92 domainDst->bounds_lon_end = bounds_lon_end;93 domainDst->lon_start = bounds_lon_start + boundsLonStep/2;94 domainDst->lon_end = bounds_lon_end - boundsLonStep/2;91 domainDst->bounds_lon_start.setValue(bounds_lon_start); 92 domainDst->bounds_lon_end.setValue(bounds_lon_end); 93 domainDst->lon_start.setValue(bounds_lon_start + boundsLonStep/2); 94 domainDst->lon_end.setValue( bounds_lon_end - boundsLonStep/2); 95 95 } 96 96 … … 101 101 double boundsLatRange = bounds_lat_end - bounds_lat_start; 102 102 double boundsLatStep = boundsLatRange/(double(njGlo)); 103 domainDst->bounds_lat_start = bounds_lat_start;104 domainDst->bounds_lat_end = bounds_lat_end;105 domainDst->lat_start = bounds_lat_start + boundsLatStep/2;106 domainDst->lat_end = bounds_lat_end - boundsLatStep/2;103 domainDst->bounds_lat_start.setValue(bounds_lat_start); 104 domainDst->bounds_lat_end.setValue(bounds_lat_end); 105 domainDst->lat_start.setValue(bounds_lat_start + boundsLatStep/2); 106 domainDst->lat_end.setValue(bounds_lat_end - boundsLatStep/2); 107 107 } 108 108 … … 115 115 double lonRange = lon_end - lon_start; 116 116 double lonStep = (1 == niGlo) ? lonRange : lonRange/(double(niGlo)-1); 117 domainDst->lon_start = lon_start;118 domainDst->lon_end = lon_end;119 domainDst->bounds_lon_start = lon_start - lonStep/2;120 domainDst->bounds_lon_end = lon_end + lonStep/2;117 domainDst->lon_start.setValue(lon_start); 118 domainDst->lon_end.setValue(lon_end); 119 domainDst->bounds_lon_start.setValue(lon_start - lonStep/2); 120 domainDst->bounds_lon_end.setValue(lon_end + lonStep/2); 121 121 } 122 122 … … 127 127 double latRange = lat_end - lat_start; 128 128 double latStep = (1 == njGlo) ? latRange : latRange/(double(njGlo)-1); 129 domainDst->lat_start = lat_start;130 domainDst->lat_end = lat_end;131 domainDst->bounds_lat_start = lat_start - latStep/2;132 domainDst->bounds_lat_end = lat_end + latStep/2;129 domainDst->lat_start.setValue(lat_start); 130 domainDst->lat_end.setValue(lat_end); 131 domainDst->bounds_lat_start.setValue(lat_start - latStep/2); 132 domainDst->bounds_lat_end.setValue(lat_end + latStep/2); 133 133 } 134 134 } -
XIOS/trunk/src/node/grid.cpp
r771 r775 31 31 , globalDim_(), connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 32 32 , transformations_(0), isTransformed_(false) 33 , axisPositionInGrid_(), positionDimensionDistributed_(1) 33 , axisPositionInGrid_(), positionDimensionDistributed_(1), hasDomainAxisBaseRef_(false) 34 34 { 35 35 setVirtualDomainGroup(); … … 45 45 , globalDim_(), connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 46 46 , transformations_(0), isTransformed_(false) 47 , axisPositionInGrid_(), positionDimensionDistributed_(1) 47 , axisPositionInGrid_(), positionDimensionDistributed_(1), hasDomainAxisBaseRef_(false) 48 48 { 49 49 setVirtualDomainGroup(); … … 203 203 computeGridGlobalDimension(getDomains(), getAxis(), axis_domain_order); 204 204 this->isDomainAxisChecked = areAttributesChecked; 205 } 206 207 void CGrid::solveDomainAxisBaseRef() 208 { 209 if (this->hasDomainAxisBaseRef_) return; 210 // Account for the axis attributes 211 std::vector<CAxis*> axisList = getAxis(); 212 for (size_t i = 0; i < axisList.size(); ++i) 213 { 214 axisList[i]->solveBaseReference(); 215 axisList[i]->setAttributesBaseReference(); 216 } 217 218 // Account for the domain attributes 219 std::vector<CDomain*> domList = getDomains(); 220 for (size_t i = 0; i < domList.size(); ++i) 221 { 222 domList[i]->solveBaseReference(); 223 domList[i]->setAttributesBaseReference(); 224 } 225 this->hasDomainAxisBaseRef_ = true; 205 226 } 206 227 … … 1260 1281 void CGrid::completeGrid(CGrid* transformGridSrc) 1261 1282 { 1262 if (!transformGridSrc) 1263 ERROR("CGrid::completeGrid(CGrid* transformGridSrc)", 1264 << "Impossible to complete grid '" << getId() << "', the source grid is null."); 1265 1266 if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements()) 1267 { 1268 ERROR("CGrid::completeGrid(CGrid* transformGridSrc)", 1269 << "Two grids have different dimension size" 1270 << "Dimension of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl 1271 << "Dimension of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements()); 1272 } 1273 else 1274 { 1275 int ssize = axis_domain_order.numElements(); 1276 for (int i = 0; i < ssize; ++i) 1277 if (axis_domain_order(i) != (transformGridSrc->axis_domain_order)(i)) 1278 ERROR("CGrid::completeGrid(CGrid* transformGridSrc)", 1279 << "Grids " << this->getId() << " and " << transformGridSrc->getId() 1280 << " don't have elements in the same order"); 1283 if (0 != transformGridSrc) 1284 { 1285 if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements()) 1286 { 1287 ERROR("CGrid::completeGrid(CGrid* transformGridSrc)", 1288 << "Two grids have different dimension size" 1289 << "Dimension of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl 1290 << "Dimension of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements()); 1291 } 1292 else 1293 { 1294 int ssize = axis_domain_order.numElements(); 1295 for (int i = 0; i < ssize; ++i) 1296 if (axis_domain_order(i) != (transformGridSrc->axis_domain_order)(i)) 1297 ERROR("CGrid::completeGrid(CGrid* transformGridSrc)", 1298 << "Grids " << this->getId() << " and " << transformGridSrc->getId() 1299 << " don't have elements in the same order"); 1300 } 1281 1301 } 1282 1302 -
XIOS/trunk/src/node/grid.hpp
r745 r775 144 144 void solveDomainAxisRefInheritance(bool apply = true); 145 145 void solveTransformations(); 146 void solveDomainAxisBaseRef(); 146 147 147 148 void sendAddDomain(const std::string& id=""); … … 186 187 187 188 void transformGrid(CGrid* transformGridSrc); 188 void completeGrid(CGrid* transformGridSrc );189 void completeGrid(CGrid* transformGridSrc = 0); 189 190 void doAutoDistribution(CGrid* transformGridSrc); 190 191 bool isTransformed(); … … 263 264 std::vector<int> axisPositionInGrid_; 264 265 CGridTransformation* transformations_; 266 bool hasDomainAxisBaseRef_; 265 267 }; // class CGrid 266 268 -
XIOS/trunk/src/test/test_new_features.f90
r755 r775 15 15 CHARACTER(len=15) :: calendar_type 16 16 TYPE(xios_context) :: ctx_hdl 17 INTEGER,PARAMETER :: ni_glo=10 18 INTEGER,PARAMETER :: nj_glo=10 17 INTEGER,PARAMETER :: ni_glo=100 18 INTEGER,PARAMETER :: nj_glo=100 19 19 INTEGER,PARAMETER :: llm=2 20 20 INTEGER,PARAMETER :: llmInterPolated=5 -
XIOS/trunk/src/test/test_remap.f90
r742 r775 20 20 DOUBLE PRECISION,ALLOCATABLE :: src_boundslon(:,:), dst_boundslon(:,:) 21 21 DOUBLE PRECISION,ALLOCATABLE :: src_boundslat(:,:), dst_boundslat(:,:) 22 DOUBLE PRECISION,ALLOCATABLE :: src_field(:), tmp_field(:) 22 DOUBLE PRECISION,ALLOCATABLE :: src_field(:), tmp_field(:), tmp_field_1(:) 23 23 INTEGER :: src_ni_glo, dst_ni_glo; 24 24 INTEGER :: src_nvertex, dst_nvertex; 25 25 INTEGER :: src_ibegin, dst_ibegin; 26 26 INTEGER :: src_ni, dst_ni; 27 INTEGER :: src_tmp_ni, src_tmp_nj, src_tmp_n; 27 28 CHARACTER(LEN=*),PARAMETER :: src_file="h14.nc" 28 29 CHARACTER(LEN=*),PARAMETER :: dst_file="r180x90.nc" … … 119 120 bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex) 120 121 121 ALLOCATE(tmp_field(180*90/2)) 122 122 123 dtime%second = 3600 123 124 CALL xios_set_timestep(dtime) 124 125 125 126 CALL xios_close_context_definition() 127 CALL xios_get_domain_attr("src_domain_regular_tmp", ni=src_tmp_ni, nj=src_tmp_nj) 128 ALLOCATE(tmp_field(src_tmp_ni*src_tmp_nj)) 129 130 CALL xios_get_axis_attr("src_axis_curvilinear", n=src_tmp_n) 131 CALL xios_get_domain_attr("src_domain_curvilinear", ni=src_tmp_ni, nj=src_tmp_nj) 132 ALLOCATE(tmp_field_1(src_tmp_ni*src_tmp_nj*src_tmp_n)) 126 133 127 134 DO ts=1,1 128 CALL xios_recv_field("src_field_regular", tmp_field) 135 CALL xios_recv_field("src_field_regular_tmp", tmp_field) 136 CALL xios_recv_field("src_field_curvilinear", tmp_field_1) 129 137 CALL xios_update_calendar(ts) 130 138 CALL xios_send_field("src_field",src_field) 131 139 CALL xios_send_field("tmp_field",tmp_field) 140 CALL xios_send_field("tmp_field_1",tmp_field_1) 132 141 CALL wait_us(5000) ; 133 142 ENDDO -
XIOS/trunk/src/transformation/domain_algorithm_generate_rectilinear.cpp
r727 r775 17 17 18 18 CDomainAlgorithmGenerateRectilinear::CDomainAlgorithmGenerateRectilinear(CDomain* domainDestination, CDomain* domainSource, 19 CGrid* gridSource, CGenerateRectilinearDomain* genRectDomain) 20 : CDomainAlgorithmTransformation(domainDestination, domainSource), gridSrc_(gridSource), nbDomainDistributedPart_(0) 19 CGrid* gridDest, CGrid* gridSource, 20 CGenerateRectilinearDomain* genRectDomain) 21 : CDomainAlgorithmTransformation(domainDestination, domainSource), nbDomainDistributedPart_(0) 21 22 { 22 23 genRectDomain->checkValid(domainDestination); 23 computeDistributionGridSource(); 24 if (0 != gridSource) computeDistributionGridSource(gridSource); 25 else 26 { 27 computeDistributionGridDestination(gridDest); 28 } 24 29 fillInAttributesDomainDestination(); 25 30 } … … 36 41 Calculate the number of distributed parts on domain source 37 42 */ 38 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridSource( )43 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridSource(CGrid* gridSrc) 39 44 { 40 45 CContext* context = CContext::getCurrent(); 41 46 CContextClient* client = context->client; 42 47 43 std::vector<CDomain*> domListSrcP = gridSrc _->getDomains();44 std::vector<CAxis*> axisListSrcP = gridSrc _->getAxis();48 std::vector<CDomain*> domListSrcP = gridSrc->getDomains(); 49 std::vector<CAxis*> axisListSrcP = gridSrc->getAxis(); 45 50 46 51 for (int i = 0; i < domListSrcP.size(); ++i) // support we have only domain, more than one, for now, dont know how to process … … 50 55 else 51 56 { 52 gridSrc _->solveAxisRef(false);57 gridSrc->solveAxisRef(false); 53 58 int nbAxis = axisListSrcP.size(); 54 59 std::vector<int> nbLocalAxis(nbAxis, 0); … … 90 95 91 96 /*! 97 Compute the distribution of the domain destination by using available information provided by user such as n_distributed_partition of axis 98 */ 99 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridDestination(CGrid* gridDest) 100 { 101 // For now, just suppose that the grid contains only one domain 102 std::vector<CAxis*> axisListDestP = gridDest->getAxis(); 103 int nbPartition = 1, idx = 0; 104 for (int i = 0; i < gridDest->axis_domain_order.numElements(); ++i) 105 { 106 if (false == (gridDest->axis_domain_order)(i)) 107 { 108 nbPartition *= (axisListDestP[idx]->n_distributed_partition.isEmpty()) ? 1: (axisListDestP[idx]->n_distributed_partition.getValue()); 109 ++idx; 110 } 111 } 112 113 CContext* context = CContext::getCurrent(); 114 CContextClient* client = context->client; 115 int modPart = (client->clientSize) % nbPartition; 116 if (0 != modPart) 117 ERROR("CDomainAlgorithmGenerateRectilinear::computeDistributionGridDestination(CGrid* gridDest)", 118 << "The grid " <<gridDest->getId() << " is not well-distributed. There is an incompatibility between distribution of axis and domain."); 119 nbDomainDistributedPart_ = client->clientSize/nbPartition; 120 121 } 122 123 /*! 92 124 Fill in all necessary attributes of domain destination and their values 93 125 */ -
XIOS/trunk/src/transformation/domain_algorithm_generate_rectilinear.hpp
r687 r775 27 27 { 28 28 public: 29 CDomainAlgorithmGenerateRectilinear(CDomain* domainDestination, CDomain* domainSource, CGrid* gridSource, CGenerateRectilinearDomain* zoomDomain); 29 CDomainAlgorithmGenerateRectilinear(CDomain* domainDestination, CDomain* domainSource, 30 CGrid* gridDest, CGrid* gridSource, 31 CGenerateRectilinearDomain* zoomDomain); 30 32 31 33 virtual ~CDomainAlgorithmGenerateRectilinear() {} … … 34 36 35 37 private: 36 void computeDistributionGridSource(); 38 void computeDistributionGridSource(CGrid* gridSrc); 39 void computeDistributionGridDestination(CGrid* gridDest); 37 40 void fillInAttributesDomainDestination(); 38 41 39 42 private: 40 CGrid* gridSrc_;41 43 int nbDomainDistributedPart_; //! Number of local domain. 42 44 -
XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp
r753 r775 78 78 bool isNorthPole = false; 79 79 bool isSouthPole = false; 80 if ( poleValue == std::abs(domainSrc_->lat_start)) isNorthPole = true;81 if ( poleValue == std::abs(domainSrc_->lat_end)) isSouthPole = true;80 if (std::abs(poleValue - std::abs(domainSrc_->lat_start)) < NumTraits<double>::epsilon()) isNorthPole = true; 81 if (std::abs(poleValue - std::abs(domainSrc_->lat_end)) < NumTraits<double>::epsilon()) isSouthPole = true; 82 82 83 83 nVertexSrc = constNVertex; … … 121 121 bool isNorthPole = false; 122 122 bool isSouthPole = false; 123 if ( poleValue == std::abs(domainDest_->lat_start)) isNorthPole = true;124 if ( poleValue == std::abs(domainDest_->lat_end)) isSouthPole = true;123 if (std::abs(poleValue - std::abs(domainDest_->lat_start)) < NumTraits<double>::epsilon()) isNorthPole = true; 124 if (std::abs(poleValue - std::abs(domainDest_->lat_end)) < NumTraits<double>::epsilon()) isSouthPole = true; 125 125 if (isNorthPole && (0 == domainDest_->jbegin.getValue())) 126 126 { -
XIOS/trunk/src/transformation/grid_generate.cpp
r687 r775 17 17 : gridSource_(source), gridDestination_(destination), algoTypes_() 18 18 { 19 //Verify the compatibity between two grids 20 int numElement = gridDestination_->axis_domain_order.numElements(); 21 if (numElement != gridSource_->axis_domain_order.numElements()) 22 ERROR("CGridGenerate::CGridGenerate(CGrid* destination, CGrid* source)", 23 << "Two grids have different number of elements" 24 << "Number of elements of grid source " <<gridSource_->getId() << " is " << gridSource_->axis_domain_order.numElements() << std::endl 25 << "Number of elements of grid destination " <<gridDestination_->getId() << " is " << numElement); 26 27 for (int i = 0; i < numElement; ++i) 28 { 29 if (gridDestination_->axis_domain_order(i) != gridSource_->axis_domain_order(i)) 19 if (0 != source) 20 { 21 //Verify the compatibity between two grids 22 int numElement = gridDestination_->axis_domain_order.numElements(); 23 if (numElement != gridSource_->axis_domain_order.numElements()) 30 24 ERROR("CGridGenerate::CGridGenerate(CGrid* destination, CGrid* source)", 31 << "Transformed grid and its grid source have incompatible elements" 32 << "Grid source " <<gridSource_->getId() << std::endl 33 << "Grid destination " <<gridDestination_->getId()); 25 << "Two grids have different number of elements" 26 << "Number of elements of grid source " <<gridSource_->getId() << " is " << gridSource_->axis_domain_order.numElements() << std::endl 27 << "Number of elements of grid destination " <<gridDestination_->getId() << " is " << numElement); 28 29 for (int i = 0; i < numElement; ++i) 30 { 31 if (gridDestination_->axis_domain_order(i) != gridSource_->axis_domain_order(i)) 32 ERROR("CGridGenerate::CGridGenerate(CGrid* destination, CGrid* source)", 33 << "Transformed grid and its grid source have incompatible elements" 34 << "Grid source " <<gridSource_->getId() << std::endl 35 << "Grid destination " <<gridDestination_->getId()); 36 } 34 37 } 35 38 … … 179 182 { 180 183 std::vector<CAxis*> axisListDestP = gridDestination_->getAxis(); 181 std::vector<CAxis*> axisListSrcP = gridSource_->getAxis();182 184 183 185 int axisIndex = elementPosition2AxisPositionInGrid_[elementPositionInGrid]; … … 207 209 { 208 210 std::vector<CDomain*> domainListDestP = gridDestination_->getDomains(); 209 std::vector<CDomain*> domainListSrcP = gridSource_->getDomains(); 211 std::vector<CDomain*> domainListSrcP(domainListDestP.size()); 212 if (0 != gridSource_) domainListSrcP = gridSource_->getDomains(); 210 213 211 214 int domainIndex = elementPosition2DomainPositionInGrid_[elementPositionInGrid]; … … 223 226 { 224 227 genRectDomain = dynamic_cast<CGenerateRectilinearDomain*> (it->second); 225 algo = new CDomainAlgorithmGenerateRectilinear(domainListDestP[domainIndex], domainListSrcP[domainIndex], gridSource_, genRectDomain); 228 algo = new CDomainAlgorithmGenerateRectilinear(domainListDestP[domainIndex], domainListSrcP[domainIndex], 229 gridDestination_, gridSource_, genRectDomain); 226 230 } 227 231 else -
XIOS/trunk/src/transformation/grid_generate.hpp
r687 r775 32 32 public: 33 33 /** Default constructor */ 34 CGridGenerate(CGrid* destination, CGrid* source );34 CGridGenerate(CGrid* destination, CGrid* source = 0); 35 35 ~CGridGenerate(); 36 36 -
XIOS/trunk/src/utils.hpp
r687 r775 225 225 return std::numeric_limits<Scalar>::max(); 226 226 } 227 static inline Scalar sflowest() { 228 return -(std::numeric_limits<Scalar>::max()); 229 } 230 static inline Scalar epsilon() { 231 return std::numeric_limits<Scalar>::epsilon(); 232 } 227 233 }; 228 234 … … 238 244 static inline Scalar sfmax() { 239 245 return std::numeric_limits<Scalar>::max(); 246 } 247 static inline Scalar sflowest() { 248 return -(std::numeric_limits<Scalar>::max()); 249 } 250 static inline Scalar epsilon() { 251 return std::numeric_limits<Scalar>::epsilon(); 240 252 } 241 253 };
Note: See TracChangeset
for help on using the changeset viewer.