Changeset 775 for XIOS/trunk


Ignore:
Timestamp:
11/02/15 11:46:25 (8 years ago)
Author:
mhnguyen
Message:

Implementing the reading of attributes of an axis from a file

+) 3d grid can be read directly from a file
+) Clean some redundant codes
+) Add new attribute declaration that allows to output only desired attributes

Test
+) On Curie
+) test_remap passes and result is correct

Location:
XIOS/trunk
Files:
2 added
34 edited

Legend:

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

    r753 r775  
    88   <field_definition level="1" > 
    99     <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" /> 
    1213     <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"/>--> 
    1415   </field_definition> 
    1516 
     
    1718   <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 
    1819     <file id="output" name="output"> 
    19         <field field_ref="src_field" name="field" /> 
     20<!--        <field field_ref="src_field" name="field" />--> 
    2021     </file> 
    2122     <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" />--> 
    2324     </file> 
    2425     <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" />--> 
    2627     </file> 
    2728     <file id="output_dst_regular" name="output_dst_regular" type="one_file"> 
    2829        <field field_ref="dst_field_regular" name="field" /> 
    2930     </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 
    3035     <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"/>--> 
    3237     </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"/> 
    3545     </file> 
    3646   </file_definition> 
     
    3848 
    3949   <axis_definition> 
     50     <axis id="src_axis_curvilinear" /> 
    4051   </axis_definition> 
    4152 
     
    4960       <interpolate_domain/> 
    5061     </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"> 
    5264       <generate_rectilinear_domain /> 
    5365       <interpolate_domain/> 
     
    5668       <generate_rectilinear_domain lat_start="-90" lat_end="90" lon_start="2" lon_end="360" /> 
    5769     </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> 
    5876   </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> 
    5984  </context> 
    60  
    6185 
    6286  <context id="xios"> 
  • XIOS/trunk/inputs/Version2/iodef.xml

    r720 r775  
    3333<!--        <field field_ref="field_Axis_transformed_Interpolated" />--> 
    3434     </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" /> 
    3737     </file> 
    3838     <file id="output_Scalar" name="output_Scalar" type="one_file"> 
  • XIOS/trunk/src/attribute_array.hpp

    r591 r775  
    99#include "buffer_out.hpp" 
    1010#include "array_new.hpp" 
    11  
     11#include "attribute_public.hpp" 
    1212 
    1313namespace xios 
     
    1515      /// ////////////////////// Déclarations ////////////////////// /// 
    1616      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 
    1818      { 
    1919        public : 
     
    2121           using CArray<T_numtype,N_rank>::operator = ; 
    2222//           using Array<T_numtype,N_rank>::operator = ; 
    23             
     23 
    2424            /// Constructeurs /// 
    2525            explicit CAttributeArray(const StdString & id); 
    2626            CAttributeArray(const StdString & id, xios_map<StdString, CAttribute*> & umap); 
    2727            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, 
    2929                           xios_map<StdString, CAttribute*> & umap); 
    3030 
     
    3636            void set(const CAttribute& attr) ; 
    3737            void set(const CAttributeArray& attr) ; 
    38             void reset(void) ;             
     38            void reset(void) ; 
    3939            void setInheritedValue(const CAttributeArray& attr ); 
    4040            void setInheritedValue(const CAttribute& attr ); 
    4141            CArray<T_numtype, N_rank> getInheritedValue(void) const ; 
    42             bool hasInheritedValue(void) const;             
     42            bool hasInheritedValue(void) const; 
    4343 
    4444            /// Destructeur /// 
     
    4949            virtual string toString(void) const { return _toString();} 
    5050            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 
    5454            virtual void generateCInterface(ostream& oss,const string& className) ; 
    5555            virtual void generateFortran2003Interface(ostream& oss,const string& className) ; 
     
    6161            virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ; 
    6262 
    63        
     63 
    6464         protected : 
    6565 
     
    7272          bool _toBuffer  (CBufferOut& buffer) const; 
    7373          bool _fromBuffer(CBufferIn& buffer) ; 
    74       }; // class CAttributeEnum     
     74      }; // class CAttributeEnum 
    7575} // namespace xios 
    7676 
  • XIOS/trunk/src/attribute_array_impl.hpp

    r501 r775  
    77#include "attribute_array.hpp" 
    88 
    9    
     9 
    1010namespace xios 
    1111{ 
     
    4747        inheritedValue.reset() ; 
    4848      } 
    49        
     49 
    5050      template <typename T_numtype, int N_rank> 
    5151      CArray<T_numtype,N_rank> CAttributeArray<T_numtype, N_rank>::getValue(void) const 
     
    6565    { 
    6666      this->set(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ; 
    67     }  
     67    } 
    6868 
    6969    template <typename T_numtype, int N_rank> 
     
    7171    { 
    7272      this->setValue(attr) ; 
    73     }  
    74      
    75      
     73    } 
     74 
     75 
    7676    template <typename T_numtype, int N_rank> 
    7777    void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttribute& attr) 
    7878    { 
    7979      this->setInheritedValue(dynamic_cast<const CAttributeArray<T_numtype,N_rank>& >(attr)) ; 
    80     }  
     80    } 
    8181 
    8282    template <typename T_numtype, int N_rank> 
    8383    void CAttributeArray<T_numtype,N_rank>::setInheritedValue(const CAttributeArray& attr) 
    8484    { 
    85       if (this->isEmpty() && attr.hasInheritedValue())  
     85      if (this->isEmpty() && attr.hasInheritedValue()) 
    8686      { 
    8787        inheritedValue.resize(attr.shape()) ; 
    8888        inheritedValue=attr ; 
    8989      } 
    90     }  
     90    } 
    9191 
    9292    template <typename T_numtype, int N_rank> 
     
    9595      if (this->isEmpty()) return inheritedValue.copy() ; 
    9696      else return getValue() ; 
    97     }  
    98      
     97    } 
     98 
    9999    template <typename T_numtype, int N_rank> 
    100100    bool CAttributeArray<T_numtype,N_rank>::hasInheritedValue(void) const 
    101101    { 
    102102      return !this->isEmpty() || !inheritedValue.isEmpty() ; 
    103     }  
    104      
     103    } 
     104 
    105105 
    106106    template <typename T_numtype, int N_rank> 
     
    133133      void CAttributeArray<T_numtype, N_rank>::generateCInterface(ostream& oss,const string& className) 
    134134      { 
    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()) ; 
    136137      } 
    137        
     138 
    138139      template <typename T_numtype, int N_rank> 
    139140      void CAttributeArray<T_numtype, N_rank>::generateFortran2003Interface(ostream& oss,const string& className) 
    140141      { 
    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()) ; 
    142144      } 
    143        
     145 
    144146      template <typename T_numtype, int N_rank> 
    145147      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) 
    146148      { 
    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()+"_") ; 
    148151      } 
    149   
     152 
    150153      template <typename T_numtype, int N_rank> 
    151154      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceBody_(ostream& oss,const string& className) 
    152155      { 
    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()) ; 
    154158      } 
    155159 
     
    157161      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) 
    158162      { 
    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()) ; 
    160165      } 
    161        
     166 
    162167      template <typename T_numtype, int N_rank> 
    163168      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) 
    164169      { 
    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()+"_") ; 
    166172      } 
    167   
     173 
    168174      template <typename T_numtype, int N_rank> 
    169175      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) 
    170176      { 
    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()) ; 
    172179      } 
    173180 
     
    175182      void CAttributeArray<T_numtype, N_rank>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) 
    176183      { 
    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()) ; 
    178186      } 
    179187} // namespace xios 
  • XIOS/trunk/src/attribute_template.hpp

    r591 r775  
    1212#include "buffer_out.hpp" 
    1313#include "type.hpp" 
    14  
     14#include "attribute_public.hpp" 
    1515 
    1616namespace xios 
     
    1818      /// ////////////////////// Déclarations ////////////////////// /// 
    1919      template <class T> 
    20          class CAttributeTemplate : public CAttribute, public CType<T> 
     20         class CAttributeTemplate : public CAttribute, public CType<T>, public PublicAttributes 
    2121      { 
    2222            typedef CAttribute SuperClass; 
     
    4545            /// Mutateurs /// 
    4646            void setValue(const ValueType & value); 
    47              
     47 
    4848            void set(const CAttribute& attr) ; 
    4949            void set(const CAttributeTemplate& attr) ; 
     
    5454            T getInheritedValue(void) const ; 
    5555            bool hasInheritedValue(void) const; 
    56              
     56 
    5757            /// Destructeur /// 
    5858            virtual ~CAttributeTemplate(void) { } 
     
    6666//            virtual CAttributeTemplate* clone() const {} 
    6767//            virtual void toBinary  (StdOStream & os) const; 
    68 //            virtual void fromBinary(StdIStream & is);             
     68//            virtual void fromBinary(StdIStream & is); 
    6969 
    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); } 
    7272//            virtual size_t size(void) const; 
    7373            virtual void generateCInterface(ostream& oss,const string& className) ; 
     
    8383//            virtual void generateFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className) ; 
    8484 
    85        
     85 
    8686         protected : 
    8787 
     
    9393          bool _toBuffer  (CBufferOut& buffer) const; 
    9494          bool _fromBuffer(CBufferIn& buffer) ; 
    95            
     95 
    9696          CType<T> inheritedValue ; 
    97       }; // class CAttribute     
    98        
    99     
     97      }; // class CAttribute 
     98 
     99 
    100100   template <class T>  void FromBinary(StdIStream & is, T & obj); 
    101     
     101 
    102102} // namespace xios 
    103103 
  • XIOS/trunk/src/attribute_template_impl.hpp

    r591 r775  
    88#include "attribute_template.hpp" 
    99 
    10    
     10 
    1111namespace xios 
    1212{ 
     
    5454      template <class T> 
    5555      CAttributeTemplate<T>::~CAttributeTemplate(void) 
    56       {  
     56      { 
    5757//         this->CType<T>::reset() ; 
    5858//         this->clear(); 
     
    108108    { 
    109109      this->set(dynamic_cast<const CAttributeTemplate<T>& >(attr)) ; 
    110     }  
     110    } 
    111111 
    112112   template <class T> 
     
    114114    { 
    115115      CType<T>::set(attr) ; 
    116     }  
     116    } 
    117117 
    118118    template <class T> 
     
    120120    { 
    121121      this->setInheritedValue(dynamic_cast<const CAttributeTemplate<T>& >(attr)) ; 
    122     }  
     122    } 
    123123 
    124124    template <class T> 
     
    126126    { 
    127127      if (this->isEmpty() && attr.hasInheritedValue()) inheritedValue.set(attr.getInheritedValue()) ; 
    128     }  
     128    } 
    129129 
    130130    template <class T> 
     
    133133      if (this->isEmpty()) return inheritedValue.get() ; 
    134134      else return getValue() ; 
    135     }  
    136      
     135    } 
     136 
    137137    template <class T> 
    138138    bool CAttributeTemplate<T>::hasInheritedValue(void) const 
    139139    { 
    140140      return !this->isEmpty() || !inheritedValue.isEmpty() ; 
    141     }  
    142      
     141    } 
     142 
    143143      //--------------------------------------------------------------- 
    144144 
     
    188188      { 
    189189         return CType<T>::toBuffer(buffer) ; 
    190 /*          
     190/* 
    191191         if (isEmpty()) return buffer.put(true) ; 
    192192         else 
     
    205205      { 
    206206        return CType<T>::fromBuffer(buffer) ; 
    207 /*         
     207/* 
    208208        bool empty ; 
    209209        bool ret=true ; 
    210210        ret&=buffer.get(empty) ; 
    211         if (empty)  
     211        if (empty) 
    212212        { 
    213213          clear() ; 
     
    230230      template <class T> 
    231231      size_t CAttributeTemplate<T>::size(void) const 
    232       {  
     232      { 
    233233        return CType<T>::size() ;*/ 
    234 /*         
     234/* 
    235235        if (isEmpty()) return sizeof(bool) ; 
    236236        else 
     
    245245      void CAttributeTemplate<T>::generateCInterface(ostream& oss,const string& className) 
    246246      { 
    247         CInterface::AttributeCInterface<T>(oss, className, this->getName()) ; 
     247        if (this->isAttributePublic()) 
     248          CInterface::AttributeCInterface<T>(oss, className, this->getName()) ; 
    248249//        CInterface::AttributeIsDefinedCInterface(oss, className, this->getName()) ; 
    249250      } 
    250        
     251 
    251252      template <typename T> 
    252253      void CAttributeTemplate<T>::generateFortran2003Interface(ostream& oss,const string& className) 
    253254      { 
    254         CInterface::AttributeFortran2003Interface<T>(oss, className, this->getName()) ; 
     255        if (this->isAttributePublic()) 
     256          CInterface::AttributeFortran2003Interface<T>(oss, className, this->getName()) ; 
    255257//        CInterface::AttributeIsDefinedFortran2003Interface(oss, className, this->getName()) ; 
    256258      } 
    257        
     259 
    258260      template <typename T> 
    259261      void CAttributeTemplate<T>::generateFortranInterfaceDeclaration_(ostream& oss,const string& className) 
    260262      { 
    261         CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()+"_") ; 
    262       } 
    263   
     263        if (this->isAttributePublic()) 
     264          CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()+"_") ; 
     265      } 
     266 
    264267      template <typename T> 
    265268      void CAttributeTemplate<T>::generateFortranInterfaceBody_(ostream& oss,const string& className) 
    266269      { 
    267         CInterface::AttributeFortranInterfaceBody<T>(oss, className, this->getName()) ; 
     270        if (this->isAttributePublic()) 
     271          CInterface::AttributeFortranInterfaceBody<T>(oss, className, this->getName()) ; 
    268272      } 
    269273 
     
    271275      void CAttributeTemplate<T>::generateFortranInterfaceDeclaration(ostream& oss,const string& className) 
    272276      { 
    273         CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()) ; 
    274       } 
    275        
     277        if (this->isAttributePublic()) 
     278          CInterface::AttributeFortranInterfaceDeclaration<T>(oss, className, this->getName()) ; 
     279      } 
     280 
    276281      template <typename T> 
    277282      void CAttributeTemplate<T>::generateFortranInterfaceGetDeclaration_(ostream& oss,const string& className) 
    278283      { 
    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 
    283289      template <typename T> 
    284290      void CAttributeTemplate<T>::generateFortranInterfaceGetBody_(ostream& oss,const string& className) 
    285291      { 
    286         CInterface::AttributeFortranInterfaceGetBody<T>(oss, className, this->getName()) ; 
     292        if (this->isAttributePublic()) 
     293          CInterface::AttributeFortranInterfaceGetBody<T>(oss, className, this->getName()) ; 
    287294      } 
    288295 
     
    290297      void CAttributeTemplate<T>::generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) 
    291298      { 
    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] 
    300308 
    301309      template <> 
     
    304312      //--------------------------------------------------------------- 
    305313 
    306       // Spécialisations des templates pour la fonction [fromString]  
     314      // Spécialisations des templates pour la fonction [fromString] 
    307315 
    308316      template <> // Chaîne de caractÚres. 
     
    333341      template <> // Booléen 
    334342         void CAttributeTemplate<bool>::toBinary(StdOStream & os) const; 
    335           
     343 
    336344      template <> // Double 
    337345         void CAttributeTemplate<double>::toBinary(StdOStream & os) const; 
     
    349357      template <> // Booléen 
    350358         void CAttributeTemplate<bool>::fromBinary(StdIStream & is); 
    351           
     359 
    352360      template <> // Double 
    353361         void CAttributeTemplate<double>::fromBinary(StdIStream & is); 
    354362 
    355363      ///-------------------------------------------------------------- 
    356 */       
     364*/ 
    357365} // namespace xios 
    358366 
  • XIOS/trunk/src/config/axis_attribute.conf

    r666 r775  
    77DECLARE_ATTRIBUTE(int,       n_glo) 
    88DECLARE_ENUM2(positive, up, down) 
     9 
     10/* GLOBAL */ 
     11DECLARE_ATTRIBUTE(int,       n_distributed_partition) 
    912 
    1013/* LOCAL */ 
  • XIOS/trunk/src/data_input.cpp

    r602 r775  
    3030    this->closeFile_(); 
    3131  } 
     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  } 
    3242} // namespace xios 
  • XIOS/trunk/src/data_input.hpp

    r602 r775  
    1919      StdSize getFieldNbRecords(CField* field); 
    2020      void readFieldData(CField* field); 
     21      void readFieldAttributesMetaData(CField* field); 
     22      void readFieldAttributesValues(CField* field); 
    2123      void closeFile(void); 
    2224 
     
    2628      virtual StdSize getFieldNbRecords_(CField* field) = 0; 
    2729      virtual void readFieldData_(CField* field) = 0; 
     30      virtual void readFieldAttributes_(CField* field, bool readAttributeValues) = 0; 
    2831      virtual void closeFile_(void) = 0; 
    2932 
  • XIOS/trunk/src/declare_attribute.hpp

    r591 r775  
    33 
    44/// ///////////////////////////// Macros ///////////////////////////// /// 
    5  
    65#define DECLARE_ATTRIBUTE(type, name)                             \ 
    76   class name##_attr : public CAttributeTemplate<type>            \ 
     
    1817   } name; 
    1918 
     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 
    2035#define DECLARE_ARRAY(T_num, T_rank, name)                        \ 
    2136   class name##_attr : public CAttributeArray<T_num, T_rank>      \ 
     
    2641         virtual ~name##_attr(void) {}                            \ 
    2742   } 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 
    2955#define DECLARE_CLASS_ENUM(name)                                   \ 
    3056   class name##_attr : public CAttributeEnum<Enum_##name>          \ 
     
    3460         virtual ~name##_attr(void) {}                           \ 
    3561   } name; 
    36     
     62 
    3763#define DECLARE_ENUM2(name,arg1,arg2)                             \ 
    3864   class Enum_##name                                              \ 
     
    4470   } ;                                                            \ 
    4571   DECLARE_CLASS_ENUM(name) 
    46     
     72 
    4773#define DECLARE_ENUM3(name,arg1,arg2,arg3)                             \ 
    4874   class Enum_##name                                              \ 
     
    113139     int getSize(void) const { return 9 ; }                       \ 
    114140   } ;                                                            \ 
    115    DECLARE_CLASS_ENUM(name)  
     141   DECLARE_CLASS_ENUM(name) 
    116142 
    117143  #define DECLARE_TYPE(name)                                      \ 
  • XIOS/trunk/src/declare_ref_func.hpp

    • Property svn:executable set to *
    r771 r775  
    1919  C##type* getDirect##type##Reference(void) const;          \ 
    2020  const StdString& get##type##OutputName(void) const;       \ 
     21  void setAttributesBaseReference(bool apply = true);       \ 
    2122 
    2223// Definitions 
     
    4344    SuperClassAttribute::setAttributes(refer_ptr, apply);              \ 
    4445  }                                                                    \ 
     46}                                                                      \ 
     47                                                                       \ 
     48void C##type::setAttributesBaseReference(bool apply)                   \ 
     49{                                                                      \ 
     50  baseRefObject->setAttributes(this, apply);                           \ 
    4551}                                                                      \ 
    4652                                                                       \ 
  • XIOS/trunk/src/io/nc4_data_input.cpp

    r770 r775  
    33#include "context.hpp" 
    44#include "context_server.hpp" 
     5#include "context_client.hpp" 
     6#include "domain.hpp" 
     7#include "axis.hpp" 
    58 
    69namespace xios 
     
    1215    , filename(filename) 
    1316    , isCollective(isCollective) 
     17    , readMetaDataDomains_(), readValueDomains_() 
     18    , readMetaDataAxis_(), readValueAxis_() 
    1419  { 
    1520    SuperClass::type = multifile ? MULTI_FILE : ONE_FILE; 
     
    126131  } 
    127132 
     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 
    128330  void CNc4DataInput::closeFile_(void) 
    129331  { 
  • XIOS/trunk/src/io/nc4_data_input.hpp

    r685 r775  
    99namespace xios 
    1010{ 
     11  class CDomain; 
     12  class CAxis; 
     13 
    1114  class CNc4DataInput 
    1215    : protected CINetCDF4 
     
    3336    virtual StdSize getFieldNbRecords_(CField* field); 
    3437    virtual void readFieldData_(CField* field); 
     38    virtual void readFieldAttributes_(CField* field, bool readAttributeValues); 
    3539    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_; 
    3660 
    3761  private: 
  • XIOS/trunk/src/node/axis.cpp

    r772 r775  
    185185     CAxis* axis = CAxisGroup::get("axis_definition")->createChild(); 
    186186     return axis; 
     187   } 
     188 
     189   void CAxis::fillInValues(const CArray<double,1>& values) 
     190   { 
     191     this->value = values; 
    187192   } 
    188193 
  • XIOS/trunk/src/node/axis.hpp

    r742 r775  
    111111         void solveInheritanceTransformation(); 
    112112         TransMapTypes getAllTransformations(); 
     113         void fillInValues(const CArray<double,1>& values); 
    113114 
    114115      public: 
  • XIOS/trunk/src/node/context.cpp

    r773 r775  
    313313     registryOut=new CRegistry(intraComm) ; 
    314314     registryOut->setPath(getId()) ; 
    315   
     315 
    316316     MPI_Comm intraCommClient, interCommClient; 
    317317     if (cxtClient) // Attached mode 
     
    362362          if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 
    363363        } 
    364          
     364 
    365365        for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 
    366366          MPI_Comm_free(&(*it)); 
     
    439439     for (unsigned int i = 0; i < this->enabledFiles.size(); i++) 
    440440     (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(); 
    441453   } 
    442454 
     
    785797      // Find all enabled fields of each file 
    786798      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     } 
    788806      // Search and rebuild all reference object of enabled fields 
    789807      this->solveAllRefOfEnabledFields(false); 
     
    10531071      if (hasClient) 
    10541072      { 
    1055         checkPrefetchingOfEnabledReadModeFiles(); 
     1073        //checkPrefetchingOfEnabledReadModeFiles(); 
    10561074        garbageCollector.invalidate(calendar->getCurrentDate()); 
    10571075      } 
  • XIOS/trunk/src/node/context.hpp

    r740 r775  
    103103         // Some functions to process context 
    104104         void findAllEnabledFields(void); 
     105         void findAllEnabledFieldsInReadModeFiles(void); 
     106         void readAttributesOfEnabledFieldsInReadModeFiles(); 
    105107         void solveAllInheritance(bool apply=true); 
    106108         void findEnabledFiles(void); 
     
    218220         // Concrete contex client 
    219221         CContextClient* client; 
    220          CRegistry* registryIn ;  //!< input registry which is read from file  
     222         CRegistry* registryIn ;  //!< input registry which is read from file 
    221223         CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 
    222           
     224 
    223225      private: 
    224226         bool isPostProcessed; 
  • XIOS/trunk/src/node/domain.cpp

    r772 r775  
    339339   void CDomain::fillInRectilinearLonLat() 
    340340   { 
    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) 
    356358       { 
    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         } 
    358371       } 
    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) 
    360392       { 
    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         } 
    382405       } 
    383406     } 
     
    389412     int i,j,k; 
    390413     const int nvertexValue = 4; 
    391  
    392      double boundsLonRange = bounds_lon_end - bounds_lon_start; 
    393      double boundsLatRange = bounds_lat_end - bounds_lat_start; 
    394  
    395414     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 
    396449     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   } 
    452492 
    453493   void CDomain::checkDomain(void) 
     
    10291069     CContext* context=CContext::getCurrent(); 
    10301070 
    1031       this->checkGenerate(); 
    10321071      this->checkDomain(); 
    10331072      this->checkBounds(); 
  • XIOS/trunk/src/node/domain.hpp

    r743 r775  
    3030   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain) 
    3131#  include "domain_attribute.conf" 
     32#  include "domain_attribute_private.conf" 
    3233   END_DECLARE_ATTRIBUTE_MAP(CDomain) 
    3334 
     
    105106         int nj_srv,jbegin_srv,jend_srv ; 
    106107         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; 
    112108 
    113109         CArray<double, 1> lonvalue_srv, latvalue_srv ; 
     
    133129         void fillInRectilinearBoundLonLat(CArray<double,2>& boundsLon, CArray<double,2>& boundsLat, 
    134130                                           bool isNorthPole = false, bool isSouthPole = false); 
     131         void fillInRectilinearLonLat(); 
    135132 
    136133         static bool dispatchEvent(CEventServer& event); 
     
    172169         void checkArea(void); 
    173170         void checkLonLat(); 
    174          void checkGenerate(); 
    175171 
    176172         void checkTransformations(); 
    177173         void setTransformations(const TransMapTypes&); 
    178174         void computeNGlobDomain(); 
    179          void fillInRectilinearLonLat(); 
    180175 
    181176         void sendIndex(); 
  • XIOS/trunk/src/node/field.cpp

    r771 r775  
    826826     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) 
    827827       grid->completeGrid(getDirectFieldReference()->grid); 
     828     else 
     829       grid->completeGrid(); 
     830   } 
     831 
     832   void CField::solveGridDomainAxisBaseRef() 
     833   { 
     834     grid->solveDomainAxisRef(false); 
     835     grid->solveDomainAxisBaseRef(); 
    828836   } 
    829837 
  • XIOS/trunk/src/node/field.hpp

    r737 r775  
    114114         void solveTransformedGrid(); 
    115115         void solveGenerateGrid(); 
     116         void solveGridDomainAxisBaseRef(); 
    116117 
    117118         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 
  • XIOS/trunk/src/node/file.cpp

    r773 r775  
    2424      : CObjectTemplate<CFile>(), CFileAttributes() 
    2525      , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 
     26      , allDomainEmpty(false), isOpen(false) 
    2627   { 
    2728     setVirtualFieldGroup(); 
     
    3233      : CObjectTemplate<CFile>(id), CFileAttributes() 
    3334      , vFieldGroup(), data_out(), enabledFields(), fileComm(MPI_COMM_NULL) 
     35      , allDomainEmpty(false), isOpen(false) 
    3436    { 
    3537      setVirtualFieldGroup(); 
     
    543545   //---------------------------------------------------------------- 
    544546 
     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 
    545581   /*! 
    546582   \brief Parse xml file and write information into file object 
  • XIOS/trunk/src/node/file.hpp

    r773 r775  
    101101         void openInReadMode(void); 
    102102         void close(void); 
     103         void readAttributesOfEnabledFieldsInReadMode(); 
    103104 
    104105         // Some processing on file 
  • XIOS/trunk/src/node/generate_rectilinear_domain.cpp

    r734 r775  
    8989      double boundsLonRange = bounds_lon_end - bounds_lon_start; 
    9090      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); 
    9595    } 
    9696 
     
    101101      double boundsLatRange = bounds_lat_end - bounds_lat_start; 
    102102      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); 
    107107    } 
    108108 
     
    115115      double lonRange = lon_end - lon_start; 
    116116      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); 
    121121    } 
    122122 
     
    127127      double latRange = lat_end - lat_start; 
    128128      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); 
    133133    } 
    134134  } 
  • XIOS/trunk/src/node/grid.cpp

    r771 r775  
    3131      , globalDim_(), connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 
    3232      , transformations_(0), isTransformed_(false) 
    33       , axisPositionInGrid_(), positionDimensionDistributed_(1) 
     33      , axisPositionInGrid_(), positionDimensionDistributed_(1), hasDomainAxisBaseRef_(false) 
    3434   { 
    3535     setVirtualDomainGroup(); 
     
    4545      , globalDim_(), connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 
    4646      , transformations_(0), isTransformed_(false) 
    47       , axisPositionInGrid_(), positionDimensionDistributed_(1) 
     47      , axisPositionInGrid_(), positionDimensionDistributed_(1), hasDomainAxisBaseRef_(false) 
    4848   { 
    4949     setVirtualDomainGroup(); 
     
    203203     computeGridGlobalDimension(getDomains(), getAxis(), axis_domain_order); 
    204204     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; 
    205226   } 
    206227 
     
    12601281  void CGrid::completeGrid(CGrid* transformGridSrc) 
    12611282  { 
    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      } 
    12811301    } 
    12821302 
  • XIOS/trunk/src/node/grid.hpp

    r745 r775  
    144144         void solveDomainAxisRefInheritance(bool apply = true); 
    145145         void solveTransformations(); 
     146         void solveDomainAxisBaseRef(); 
    146147 
    147148         void sendAddDomain(const std::string& id=""); 
     
    186187 
    187188         void transformGrid(CGrid* transformGridSrc); 
    188          void completeGrid(CGrid* transformGridSrc); 
     189         void completeGrid(CGrid* transformGridSrc = 0); 
    189190         void doAutoDistribution(CGrid* transformGridSrc); 
    190191         bool isTransformed(); 
     
    263264        std::vector<int> axisPositionInGrid_; 
    264265        CGridTransformation* transformations_; 
     266        bool hasDomainAxisBaseRef_; 
    265267   }; // class CGrid 
    266268 
  • XIOS/trunk/src/test/test_new_features.f90

    r755 r775  
    1515  CHARACTER(len=15) :: calendar_type 
    1616  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 
    1919  INTEGER,PARAMETER :: llm=2 
    2020  INTEGER,PARAMETER :: llmInterPolated=5 
  • XIOS/trunk/src/test/test_remap.f90

    r742 r775  
    2020  DOUBLE PRECISION,ALLOCATABLE :: src_boundslon(:,:), dst_boundslon(:,:) 
    2121  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(:) 
    2323  INTEGER :: src_ni_glo, dst_ni_glo; 
    2424  INTEGER :: src_nvertex, dst_nvertex; 
    2525  INTEGER :: src_ibegin, dst_ibegin; 
    2626  INTEGER :: src_ni, dst_ni; 
     27  INTEGER :: src_tmp_ni, src_tmp_nj, src_tmp_n; 
    2728  CHARACTER(LEN=*),PARAMETER :: src_file="h14.nc" 
    2829  CHARACTER(LEN=*),PARAMETER :: dst_file="r180x90.nc" 
     
    119120                            bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex) 
    120121 
    121   ALLOCATE(tmp_field(180*90/2)) 
     122 
    122123  dtime%second = 3600 
    123124  CALL xios_set_timestep(dtime) 
    124125 
    125126  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)) 
    126133 
    127134  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) 
    129137    CALL xios_update_calendar(ts) 
    130138    CALL xios_send_field("src_field",src_field) 
    131139    CALL xios_send_field("tmp_field",tmp_field) 
     140    CALL xios_send_field("tmp_field_1",tmp_field_1) 
    132141    CALL wait_us(5000) ; 
    133142  ENDDO 
  • XIOS/trunk/src/transformation/domain_algorithm_generate_rectilinear.cpp

    r727 r775  
    1717 
    1818CDomainAlgorithmGenerateRectilinear::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) 
    2122{ 
    2223  genRectDomain->checkValid(domainDestination); 
    23   computeDistributionGridSource(); 
     24  if (0 != gridSource) computeDistributionGridSource(gridSource); 
     25  else 
     26  { 
     27    computeDistributionGridDestination(gridDest); 
     28  } 
    2429  fillInAttributesDomainDestination(); 
    2530} 
     
    3641  Calculate the number of distributed parts on domain source 
    3742*/ 
    38 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridSource() 
     43void CDomainAlgorithmGenerateRectilinear::computeDistributionGridSource(CGrid* gridSrc) 
    3944{ 
    4045  CContext* context = CContext::getCurrent(); 
    4146  CContextClient* client = context->client; 
    4247 
    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(); 
    4550 
    4651  for (int i = 0; i < domListSrcP.size(); ++i) // support we have only domain, more than one, for now, dont know how to process 
     
    5055    else 
    5156    { 
    52       gridSrc_->solveAxisRef(false); 
     57      gridSrc->solveAxisRef(false); 
    5358      int nbAxis = axisListSrcP.size(); 
    5459      std::vector<int> nbLocalAxis(nbAxis, 0); 
     
    9095 
    9196/*! 
     97  Compute the distribution of the domain destination by using available information provided by user such as n_distributed_partition of axis 
     98*/ 
     99void 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/*! 
    92124  Fill in all necessary attributes of domain destination and their values 
    93125*/ 
  • XIOS/trunk/src/transformation/domain_algorithm_generate_rectilinear.hpp

    r687 r775  
    2727{ 
    2828public: 
    29   CDomainAlgorithmGenerateRectilinear(CDomain* domainDestination, CDomain* domainSource, CGrid* gridSource, CGenerateRectilinearDomain* zoomDomain); 
     29  CDomainAlgorithmGenerateRectilinear(CDomain* domainDestination, CDomain* domainSource, 
     30                                      CGrid* gridDest, CGrid* gridSource, 
     31                                      CGenerateRectilinearDomain* zoomDomain); 
    3032 
    3133  virtual ~CDomainAlgorithmGenerateRectilinear() {} 
     
    3436 
    3537private: 
    36   void computeDistributionGridSource(); 
     38  void computeDistributionGridSource(CGrid* gridSrc); 
     39  void computeDistributionGridDestination(CGrid* gridDest); 
    3740  void fillInAttributesDomainDestination(); 
    3841 
    3942private: 
    40   CGrid* gridSrc_; 
    4143  int nbDomainDistributedPart_; //! Number of local domain. 
    4244 
  • XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp

    r753 r775  
    7878    bool isNorthPole = false; 
    7979    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; 
    8282 
    8383    nVertexSrc = constNVertex; 
     
    121121    bool isNorthPole = false; 
    122122    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; 
    125125    if (isNorthPole && (0 == domainDest_->jbegin.getValue())) 
    126126    { 
  • XIOS/trunk/src/transformation/grid_generate.cpp

    r687 r775  
    1717: gridSource_(source), gridDestination_(destination), algoTypes_() 
    1818{ 
    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()) 
    3024      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    } 
    3437  } 
    3538 
     
    179182{ 
    180183  std::vector<CAxis*> axisListDestP = gridDestination_->getAxis(); 
    181   std::vector<CAxis*> axisListSrcP = gridSource_->getAxis(); 
    182184 
    183185  int axisIndex =  elementPosition2AxisPositionInGrid_[elementPositionInGrid]; 
     
    207209{ 
    208210  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(); 
    210213 
    211214  int domainIndex =  elementPosition2DomainPositionInGrid_[elementPositionInGrid]; 
     
    223226      { 
    224227        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); 
    226230      } 
    227231      else 
  • XIOS/trunk/src/transformation/grid_generate.hpp

    r687 r775  
    3232public: 
    3333  /** Default constructor */ 
    34   CGridGenerate(CGrid* destination, CGrid* source); 
     34  CGridGenerate(CGrid* destination, CGrid* source = 0); 
    3535  ~CGridGenerate(); 
    3636 
  • XIOS/trunk/src/utils.hpp

    r687 r775  
    225225    return std::numeric_limits<Scalar>::max(); 
    226226  } 
     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  } 
    227233}; 
    228234 
     
    238244  static inline Scalar sfmax() { 
    239245    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(); 
    240252  } 
    241253}; 
Note: See TracChangeset for help on using the changeset viewer.