Changeset 727 for XIOS/trunk


Ignore:
Timestamp:
10/09/15 14:51:28 (9 years ago)
Author:
mhnguyen
Message:

Add more attributes to generate_rectilinear_domain

+) Longitude and latitude of an auto-generated domain can be specified by its boundaries whose values are determined by range

Test
+) On Curie
+) test_remap passes

Location:
XIOS/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/client_client_dht_template.hpp

    r721 r727  
    3232  public: 
    3333    typedef T InfoType; 
    34     const int infoTypeSize = sizeof(InfoType); 
     34    static const int infoTypeSize = sizeof(InfoType); 
    3535 
    3636  public: 
  • XIOS/trunk/src/config/generate_rectilinear_domain_attribute.conf

    r687 r727  
     1/* GLOBAL */ 
     2DECLARE_ATTRIBUTE(double    , bounds_lon_start) 
     3DECLARE_ATTRIBUTE(double    , bounds_lon_end) 
     4DECLARE_ATTRIBUTE(double    , bounds_lat_start) 
     5DECLARE_ATTRIBUTE(double    , bounds_lat_end) 
    16 
     7DECLARE_ATTRIBUTE(double    , lon_start) 
     8DECLARE_ATTRIBUTE(double    , lon_end) 
     9DECLARE_ATTRIBUTE(double    , lat_start) 
     10DECLARE_ATTRIBUTE(double    , lat_end) 
  • XIOS/trunk/src/node/domain.cpp

    r720 r727  
    174174     if (type_attr::rectilinear == type) 
    175175     { 
     176        this->isRedistributed_ = true; 
     177 
    176178        CContext* context = CContext::getCurrent(); 
    177179        CContextClient* client = context->client; 
     
    271273        // Now fill other attributes 
    272274        fillInRectilinearLonLat(); 
    273         this->isRedistributed_ = true; 
    274275     } 
    275276   } 
     
    287288     latvalue_1d.resize(nj); 
    288289 
    289      double lonStep = double(360/ni_glo.getValue()); 
    290      double latStep = double(180/nj_glo.getValue()); 
     290     double lonRange = lon_end - lon_start; 
     291     double latRange = lat_end - lat_start; 
     292 
     293     double lonStep = lonRange/double(ni_glo.getValue()); 
     294     double latStep = latRange/double(nj_glo.getValue()); 
    291295 
    292296     // Assign lon value 
    293297     for (int i = 0; i < ni; ++i) 
    294298     { 
    295        lonvalue_1d(i) = static_cast<double>(ibegin + i) * lonStep -180 + lonStep/2; 
     299       if (0 == (ibegin + i)) 
     300       { 
     301         lonvalue_1d(i) = lon_start; 
     302       } 
     303       else if (ni_glo == (ibegin + i + 1)) 
     304       { 
     305         lonvalue_1d(i) = lon_end; 
     306       } 
     307       else 
     308       { 
     309         lonvalue_1d(i) = (ibegin + i) * lonStep  + lon_start; 
     310       } 
    296311     } 
    297312 
    298313     for (int j = 0; j < nj; ++j) 
    299314     { 
    300        latvalue_1d(j) = static_cast<double>(jbegin + j) * latStep - 90 + latStep/2; 
     315       if (0 == (jbegin + j)) 
     316       { 
     317          latvalue_1d(j) = lat_start; 
     318       } 
     319       else if (nj_glo == (jbegin + j + 1)) 
     320       { 
     321          latvalue_1d(j) = lat_end; 
     322       } 
     323       else 
     324       { 
     325         latvalue_1d(j) =  (jbegin + j) * latStep + lat_start; 
     326       } 
    301327     } 
    302328   } 
     
    307333     const int nvertexValue = 4; 
    308334 
     335     double boundsLonRange = bounds_lon_end - bounds_lon_start; 
     336     double boundsLatRange = bounds_lat_end - bounds_lat_start; 
     337 
    309338     boundsLon.resize(nvertexValue,ni*nj); 
    310339     boundsLat.resize(nvertexValue,nj*ni); 
    311340 
    312      double lonStep = double(360/ni_glo.getValue()); 
    313      double latStep = double(180/nj_glo.getValue()); 
     341     double lonStep = boundsLonRange/double(ni_glo.getValue()); 
     342     double latStep = boundsLatRange/double(nj_glo.getValue()); 
    314343 
    315344     for(j=0;j<nj;++j) 
     
    317346       { 
    318347         k=j*ni+i; 
    319          boundsLon(0,k) = boundsLon(1,k) = (0 != (ibegin + i)) ? (ibegin + i) * lonStep -180 
    320                                                                : -180; 
    321          boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) != ni_glo) ? (ibegin + i +1) * lonStep -180 
    322                                                                         : 180; 
    323  
    324          boundsLat(1,k) = boundsLat(2,k) = (0 != (jbegin + j)) ? (jbegin + j) * latStep - 90 
    325                                                                : -90; 
    326          boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) != nj_glo) ? (jbegin + j +1) * latStep - 90 
    327                                                                : +90; 
     348         boundsLon(0,k) = boundsLon(1,k) = (0 != (ibegin + i)) ? (ibegin + i) * lonStep + bounds_lon_start 
     349                                                               : bounds_lon_start; 
     350         boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) != ni_glo) ? (ibegin + i +1) * lonStep + bounds_lon_start 
     351                                                                        : bounds_lon_end; 
     352 
     353         boundsLat(1,k) = boundsLat(2,k) = (0 != (jbegin + j)) ? (jbegin + j) * latStep + bounds_lat_start 
     354                                                               : bounds_lat_start; 
     355         boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) != nj_glo) ? (jbegin + j +1) * latStep + bounds_lat_start 
     356                                                               : bounds_lat_end; 
    328357       } 
    329358   } 
  • XIOS/trunk/src/node/domain.hpp

    r715 r727  
    103103         int nj_srv,jbegin_srv,jend_srv ; 
    104104         int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ; 
     105 
     106         double bounds_lon_start, bounds_lon_end; 
     107         double bounds_lat_start, bounds_lat_end; 
     108         double lon_start, lon_end; 
     109         double lat_start, lat_end; 
    105110 
    106111         CArray<double, 1> lonvalue_srv, latvalue_srv ; 
  • XIOS/trunk/src/node/generate_rectilinear_domain.cpp

    r687 r727  
    2323  ENodeType CGenerateRectilinearDomain::GetType(void)    { return eGenerateRectilinearDomain; } 
    2424 
    25   void CGenerateRectilinearDomain::checkValid(CDomain* domainSrc) 
     25  void CGenerateRectilinearDomain::checkValid(CDomain* domainDst) 
    2626  { 
     27    const double defaultBndsLonStart = 0; 
     28    const double defaultBndsLonEnd = 360; 
     29 
     30    const double defaultBndsLatStart = -90; 
     31    const double defaultBndsLatEnd = 90; 
     32 
     33    if ((!lon_start.isEmpty() && lon_end.isEmpty()) || 
     34        (lon_start.isEmpty() && !lon_end.isEmpty())) 
     35         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     36               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     37               << "Only longitude start or longitude end attribute is defined." << std::endl 
     38               << "Must define both: 'lon_start' and 'lon_end'."); 
     39 
     40    if ((!lat_start.isEmpty() && lat_end.isEmpty()) || 
     41        (lat_start.isEmpty() && !lat_end.isEmpty())) 
     42         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     43               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     44               << "Only latitude start or latitude end attribute is defined." << std::endl 
     45               << "Must define both: 'lat_start' and 'lat_end'."); 
     46 
     47    if ((!bounds_lon_start.isEmpty() && bounds_lon_end.isEmpty()) || 
     48        (bounds_lon_start.isEmpty() && !bounds_lon_end.isEmpty())) 
     49         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     50               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     51               << "Only longitude boundary start or longitude boundary end attribute is defined." << std::endl 
     52               << "Must define both: 'bounds_lon_start' and 'bounds_lon_end'."); 
     53 
     54    if ((!bounds_lat_start.isEmpty() && bounds_lat_end.isEmpty()) || 
     55        (bounds_lat_start.isEmpty() && !bounds_lat_end.isEmpty())) 
     56         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     57               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     58               << "Only latitude boundary start or latitude boundary end attribute is defined." << std::endl 
     59               << "Must define both: 'bounds_lat_start' and 'bounds_lat_end'."); 
     60 
     61    if (!bounds_lon_start.isEmpty() && !lon_start.isEmpty()) 
     62         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     63               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     64               << "Only one longitude boundary attribute or longitude can be used but both 'bounds_lon_start' and 'lon_start' are defined." << std::endl 
     65               << "Define only one attribute: 'bounds_lon_start' or 'lon_start'."); 
     66 
     67    if (!bounds_lat_start.isEmpty() && !lat_start.isEmpty()) 
     68         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     69               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     70               << "Only one latitude boundary attribute or latitude can be used but both 'bounds_lat_start' and 'lat_start' are defined." << std::endl 
     71               << "Define only one attribute: 'bounds_lat_start' or 'lat_start'."); 
     72 
     73    if (!bounds_lon_start.isEmpty() && !lat_start.isEmpty()) 
     74         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     75               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     76               << "Only one latitude boundary attribute or latitude can be used but both 'bounds_lon_start' and 'lat_start' are defined." << std::endl 
     77               << "Define only one pair of attributes: ('bounds_lon_start' and 'bounds_lat_start') or ('lon_start' and 'lat_start')."); 
     78 
     79    if (!bounds_lat_start.isEmpty() && !lon_start.isEmpty()) 
     80         ERROR("CGenerateRectilinearDomain::checkValid(CDomain* domainDst)", 
     81               << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     82               << "Only one latitude boundary attribute or latitude can be used but both 'bounds_lat_start' and 'lon_start' are defined." << std::endl 
     83               << "Define only one pair of attributes: ('bounds_lon_start' and 'bounds_lat_start') or ('lon_start' and 'lat_start')."); 
     84 
     85    if (bounds_lon_start.isEmpty() && bounds_lat_start.isEmpty() && 
     86        lon_start.isEmpty() && lat_start.isEmpty()) 
     87    { 
     88      bounds_lon_start.setValue(defaultBndsLonStart); 
     89      bounds_lon_end.setValue(defaultBndsLonEnd); 
     90      bounds_lat_start.setValue(defaultBndsLatStart); 
     91      bounds_lat_end.setValue(defaultBndsLatEnd); 
     92    } 
     93 
     94    if (!bounds_lon_start.isEmpty()) 
     95    { 
     96      int niGlo = domainDst->ni_glo.getValue(); 
     97 
     98      double boundsLonRange = bounds_lon_end - bounds_lon_start; 
     99      double boundsLonStep = boundsLonRange/double(niGlo); 
     100      domainDst->bounds_lon_start = bounds_lon_start; 
     101      domainDst->bounds_lon_end   = bounds_lon_end; 
     102      domainDst->lon_start = bounds_lon_start + boundsLonStep/2; 
     103      domainDst->lon_end   = bounds_lon_end   - boundsLonStep/2; 
     104    } 
     105 
     106    if (!bounds_lat_start.isEmpty()) 
     107    { 
     108      int njGlo = domainDst->nj_glo.getValue(); 
     109 
     110      double boundsLatRange = bounds_lat_end - bounds_lat_start; 
     111      double boundsLatStep = boundsLatRange/double(njGlo); 
     112      domainDst->bounds_lat_start = bounds_lat_start; 
     113      domainDst->bounds_lat_end   = bounds_lat_end; 
     114      domainDst->lat_start = bounds_lat_start + boundsLatStep/2; 
     115      domainDst->lat_end   = bounds_lat_end   - boundsLatStep/2; 
     116    } 
     117 
     118    if (lon_start.isEmpty() && lat_start.isEmpty()) return; 
     119 
     120    if (!lon_start.isEmpty()) 
     121    { 
     122      int niGlo = domainDst->ni_glo.getValue(); 
     123 
     124      double lonRange = lon_end - lon_start; 
     125      double lonStep = lonRange/double(niGlo); 
     126      domainDst->lon_start = lon_start; 
     127      domainDst->lon_end   = lon_end; 
     128      domainDst->bounds_lon_start = lon_start - lonStep/2; 
     129      domainDst->bounds_lon_end   = lon_end   + lonStep/2; 
     130    } 
     131 
     132    if (!lat_start.isEmpty()) 
     133    { 
     134      int njGlo = domainDst->nj_glo.getValue(); 
     135 
     136      double latRange = lat_end - lat_start; 
     137      double latStep = latRange/double(njGlo); 
     138      domainDst->lat_start = lat_start; 
     139      domainDst->lat_end   = lat_end; 
     140      domainDst->bounds_lat_start = lat_start - latStep/2; 
     141      domainDst->bounds_lat_end   = lat_end   + latStep/2; 
     142    } 
    27143  } 
    28144 
  • XIOS/trunk/src/transformation/domain_algorithm_generate_rectilinear.cpp

    r687 r727  
    2020: CDomainAlgorithmTransformation(domainDestination, domainSource), gridSrc_(gridSource), nbDomainDistributedPart_(0) 
    2121{ 
    22   genRectDomain->checkValid(domainSource); 
     22  genRectDomain->checkValid(domainDestination); 
    2323  computeDistributionGridSource(); 
    2424  fillInAttributesDomainDestination(); 
Note: See TracChangeset for help on using the changeset viewer.