Ignore:
Timestamp:
07/30/15 15:18:00 (9 years ago)
Author:
mhnguyen
Message:

Adding interpolation test_remap

+) Add new test case for domain interpolation
+) Resolve circular dependence
+) Add function to read weigh file

Test
+) On Curie
+) test_remap can print out .nc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/domain.cpp

    r657 r660  
    135135         if (!area.isEmpty()) 
    136136           area.transposeSelf(1, 0); 
    137  
    138 //         ni=1 ; 
    139 //         ibegin=0 ; 
    140 //         iend=0 ; 
    141  
    142137      } 
    143138      else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
     
    332327      else if (data_dim.isEmpty()) 
    333328      { 
    334          ERROR("CDomain::checkAttributes(void)", 
    335                << "Data dimension undefined !") ; 
     329        data_dim.setValue(1); 
     330//         ERROR("CDomain::checkAttributes(void)", 
     331//               << "Data dimension undefined !") ; 
    336332      } 
    337333 
    338334      if (data_ibegin.isEmpty()) 
    339335         data_ibegin.setValue(0) ; 
    340       if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) 
     336      if (data_jbegin.isEmpty()) 
    341337         data_jbegin.setValue(0) ; 
    342338 
     
    353349      } 
    354350 
    355       if (data_dim.getValue() == 2) 
    356       { 
    357          if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) 
     351      if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) 
     352      { 
     353         ERROR("CDomain::checkAttributes(void)", 
     354               << "Data dimension is negative (data_nj).") ; 
     355      } 
     356 
     357      if (data_nj.isEmpty()) 
     358         data_nj.setValue((data_dim.getValue() == 1) 
     359                   ? (ni.getValue() * nj.getValue()) 
     360                   : nj.getValue()); 
     361 
     362   } 
     363 
     364   //---------------------------------------------------------------- 
     365 
     366   void CDomain::checkCompression(void) 
     367   { 
     368      if (!data_i_index.isEmpty()) 
     369      { 
     370//         int ssize = data_i_index.numElements(); 
     371//         if (!data_n_index.isEmpty() && 
     372//            (data_n_index.getValue() != ssize)) 
     373//         { 
     374//            ERROR("CDomain::checkAttributes(void)", 
     375//                  <<"Dimension data_i_index incompatible with data_n_index.") ; 
     376//         } 
     377//         else if (data_n_index.isEmpty()) 
     378//            data_n_index.setValue(ssize) ; 
     379          if (!data_j_index.isEmpty() && 
     380             (data_j_index.numElements() != data_i_index.numElements())) 
     381          { 
     382             ERROR("CDomain::checkAttributes(void)", 
     383                   <<"Dimension data_j_index incompatible with data_i_index.") ; 
     384          } 
     385 
     386         if (2 == data_dim.getValue()) 
    358387         { 
    359             ERROR("CDomain::checkAttributes(void)", 
    360                   << "Data dimension is negative (data_nj).") ; 
    361          } 
    362          else if (data_nj.isEmpty()) 
    363             data_nj.setValue(nj.getValue()) ; 
    364       } 
    365  
    366    } 
    367  
    368    //---------------------------------------------------------------- 
    369  
    370    void CDomain::checkCompression(void) 
    371    { 
    372       if (!data_i_index.isEmpty()) 
    373       { 
    374          int ssize = data_i_index.numElements(); 
    375          if (!data_n_index.isEmpty() && 
    376             (data_n_index.getValue() != ssize)) 
    377          { 
    378             ERROR("CDomain::checkAttributes(void)", 
    379                   <<"Dimension data_i_index incompatible with data_n_index.") ; 
    380          } 
    381          else if (data_n_index.isEmpty()) 
    382             data_n_index.setValue(ssize) ; 
    383  
    384          if (data_dim.getValue() == 2) 
    385          { 
    386             if (!data_j_index.isEmpty() && 
    387                (data_j_index.numElements() != data_i_index.numElements())) 
    388             { 
    389                ERROR("CDomain::checkAttributes(void)", 
    390                      <<"Dimension data_j_index incompatible with data_i_index.") ; 
    391             } 
    392             else if (data_j_index.isEmpty()) 
     388            if (data_j_index.isEmpty()) 
    393389            { 
    394390               ERROR("CDomain::checkAttributes(void)", 
     
    396392            } 
    397393         } 
     394         else // (1 == data_dim.getValue()) 
     395         { 
     396            if (data_j_index.isEmpty()) 
     397            { 
     398              const int dni = data_ni.getValue(); 
     399              data_j_index.resize(dni); 
     400              for (int j = 0; j < dni; ++j) data_j_index(j) = 0; 
     401            } 
     402 
     403         } 
    398404      } 
    399405      else 
    400406      { 
    401          if (!data_n_index.isEmpty() || 
    402             ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 
     407//         if (!data_n_index.isEmpty() || 
     408//            ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 
     409//            ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; 
     410         if ((data_dim.getValue() == 2) && (!data_j_index.isEmpty())) 
    403411            ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; 
    404       } 
    405  
    406       if (data_n_index.isEmpty()) 
    407       { // -> bloc re-vérifié OK 
    408          if (data_dim.getValue() == 1) 
     412 
     413         if (1 == data_dim.getValue()) 
    409414         { 
    410415            const int dni = data_ni.getValue(); 
    411416            data_i_index.resize(dni) ; 
     417            data_j_index.resize(dni) ; 
    412418            data_n_index.setValue(dni); 
    413             for (int i = 0; i < dni; i++) data_i_index(i) = i+1 ; 
     419            for (int i = 0; i < dni; ++i) 
     420            { 
     421              data_i_index(i) = i; 
     422              data_j_index(i) = 0; 
     423            } 
    414424         } 
    415425         else   // (data_dim == 2) 
     
    421431            data_n_index.setValue(dni); 
    422432 
    423             for(int count = 0, j = 0; j  < data_nj.getValue(); j++) 
     433            for(int count = 0, j = 0; j  < data_nj.getValue(); ++j) 
    424434            { 
    425                for(int i = 0; i < data_ni.getValue(); i++, count++) 
     435               for(int i = 0; i < data_ni.getValue(); ++i, ++count) 
    426436               { 
    427                   data_i_index(count) = i+1 ; 
    428                   data_j_index(count) = j+1 ; 
     437                  data_i_index(count) = i; 
     438                  data_j_index(count) = j; 
    429439               } 
    430440            } 
    431441         } 
    432442      } 
     443 
     444//      if (data_n_index.isEmpty()) 
     445//      { // -> bloc re-vérifié OK 
     446//         if (data_dim.getValue() == 1) 
     447//         { 
     448//            const int dni = data_ni.getValue(); 
     449//            data_i_index.resize(dni) ; 
     450//            data_n_index.setValue(dni); 
     451//            for (int i = 0; i < dni; i++) data_i_index(i) = i+1 ; 
     452//         } 
     453//         else   // (data_dim == 2) 
     454//         { 
     455//            const int dni = data_ni.getValue() * data_nj.getValue(); 
     456//            data_i_index.resize(dni) ; 
     457//            data_j_index.resize(dni) ; 
     458// 
     459//            data_n_index.setValue(dni); 
     460// 
     461//            for(int count = 0, j = 0; j  < data_nj.getValue(); j++) 
     462//            { 
     463//               for(int i = 0; i < data_ni.getValue(); i++, count++) 
     464//               { 
     465//                  data_i_index(count) = i+1 ; 
     466//                  data_j_index(count) = j+1 ; 
     467//               } 
     468//            } 
     469//         } 
     470//      } 
    433471   } 
    434472 
Note: See TracChangeset for help on using the changeset viewer.