Changeset 969


Ignore:
Timestamp:
10/13/16 15:48:40 (8 years ago)
Author:
mhnguyen
Message:

Ticket 111: Loosening the checking condition for domain with data_dim == 1

+) Validation of local domain distribution information not by domain type anymore
but by data_dim defined on this domain

Test
+) NO

File:
1 edited

Legend:

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

    r968 r969  
    614614             << "please define the 'type' attribute.") 
    615615     } 
     616 
    616617     if (type == type_attr::gaussian)  
    617618     { 
    618            hasPole=true ; 
    619            type.setValue(type_attr::unstructured) ; 
    620          } 
    621          else if (type == type_attr::rectilinear) hasPole=true ; 
     619           hasPole=true ; 
     620             type.setValue(type_attr::unstructured) ; 
     621           } 
     622           else if (type == type_attr::rectilinear) hasPole=true ; 
    622623          
    623624     if (type == type_attr::unstructured) 
     
    679680     } 
    680681 
    681      isDistributed_ = !ibegin.isEmpty() || !ni.isEmpty() || !jbegin.isEmpty() || !nj.isEmpty(); 
    682  
    683682     checkLocalIDomain(); 
    684683     checkLocalJDomain(); 
     
    699698     computeNGlobDomain(); 
    700699     checkZoom(); 
    701    } 
    702  
     700 
     701     isDistributed_ = !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || 
     702                        (!i_index.isEmpty() && i_index.numElements() == ni_glo*nj_glo)); 
     703   } 
     704 
     705   // Check global zoom of a domain 
     706   // If there is no zoom defined for the domain, zoom will have value of global doamin 
    703707   void CDomain::checkZoom(void) 
    704708   { 
     
    715719   //---------------------------------------------------------------- 
    716720 
     721   // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index 
    717722   void CDomain::checkLocalIDomain(void) 
    718723   { 
    719       if (ibegin.isEmpty() && ni.isEmpty()) 
     724      // If ibegin and ni are provided then we use them to check the validity of local domain 
     725      if (i_index.isEmpty() && !ibegin.isEmpty() && !ni.isEmpty()) 
     726      { 
     727        if ((ni.getValue() < 0 || ibegin.getValue() < 0) || ((ibegin.getValue() + ni.getValue()) > ni_glo.getValue())) 
     728        { 
     729          ERROR("CDomain::checkLocalIDomain(void)", 
     730                << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     731                << "The local domain is wrongly defined," 
     732                << " check the attributes 'ni_glo' (" << ni_glo.getValue() << "), 'ni' (" << ni.getValue() << ") and 'ibegin' (" << ibegin.getValue() << ")"); 
     733        } 
     734      } 
     735 
     736      // i_index has higher priority than ibegin and ni 
     737      if (!i_index.isEmpty()) 
     738      { 
     739        int minIIndex = i_index(0); 
     740        if (ni.isEmpty())  
     741        {           
     742         // No information about ni 
     743          int minIndex = ni_glo - 1; 
     744          int maxIndex = 0; 
     745          for (int idx = 0; idx < i_index.numElements(); ++idx) 
     746          { 
     747            if (i_index(idx) < minIndex) minIndex = i_index(idx); 
     748            if (i_index(idx) > maxIndex) maxIndex = i_index(idx); 
     749          } 
     750          ni = maxIndex - minIndex + 1;  
     751          minIIndex = minIIndex;           
     752        } 
     753 
     754        // It's not so correct but if ibegin is not the first value of i_index  
     755        // then data on local domain has user-defined distribution. In this case, ibegin, ni have no meaning. 
     756        if (ibegin.isEmpty()) ibegin = minIIndex; 
     757      } 
     758      else if (ibegin.isEmpty() && ni.isEmpty()) 
    720759      { 
    721760        ibegin = 0; 
    722761        ni = ni_glo; 
    723762      } 
    724       else if (!i_index.isEmpty()) 
    725       { 
    726         if (ibegin.isEmpty()) ibegin = i_index(0); 
    727         if (ni.isEmpty()) ni = i_index.numElements(); 
    728       } 
    729  
    730       if ((ni.getValue() < 0 || ibegin.getValue() < 0) || 
    731          ((type_attr::unstructured != type) && ((ibegin.getValue() + ni.getValue()) > ni_glo.getValue()))) 
     763      else 
     764      { 
     765 
     766        ERROR("CDomain::checkLocalIDomain(void)", 
     767              << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     768              << "The local domain is wrongly defined," 
     769              << "Either 'ni' or 'ibegin' is not defined. "  
     770              << "If 'ni' and 'ibegin' are used to define domain, both of them must have assigned values." << endl 
     771              << "Otherwise, i_index can be used to define domain."); 
     772      } 
     773        
     774 
     775      if ((ni.getValue() < 0 || ibegin.getValue() < 0)) 
    732776      { 
    733777        ERROR("CDomain::checkLocalIDomain(void)", 
     
    738782   } 
    739783 
     784   // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index 
    740785   void CDomain::checkLocalJDomain(void) 
    741786   { 
    742      if (jbegin.isEmpty() && nj.isEmpty()) 
     787    // If jbegin and nj are provided then we use them to check the validity of local domain 
     788     if (j_index.isEmpty() && !jbegin.isEmpty() && !nj.isEmpty()) 
     789     { 
     790       if ((nj.getValue() < 0 || jbegin.getValue() < 0) || (jbegin.getValue() + nj.getValue()) > nj_glo.getValue()) 
     791       { 
     792         ERROR("CDomain::checkLocalJDomain(void)", 
     793                << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     794                << "The local domain is wrongly defined," 
     795                << " check the attributes 'nj_glo' (" << nj_glo.getValue() << "), 'nj' (" << nj.getValue() << ") and 'jbegin' (" << jbegin.getValue() << ")"); 
     796       } 
     797     } 
     798 
     799     if (!j_index.isEmpty()) 
     800     { 
     801        int minJIndex = j_index(0); 
     802        if (nj.isEmpty())  
     803        { 
     804          // No information about nj 
     805          int minIndex = nj_glo - 1; 
     806          int maxIndex = 0; 
     807          for (int idx = 0; idx < j_index.numElements(); ++idx) 
     808          { 
     809            if (j_index(idx) < minIndex) minIndex = j_index(idx); 
     810            if (j_index(idx) > maxIndex) maxIndex = j_index(idx); 
     811          } 
     812          nj = maxIndex - minIndex + 1; 
     813          minJIndex = minIndex;  
     814        }   
     815        // It's the same as checkLocalIDomain. It's not so correct but if jbegin is not the first value of j_index  
     816        // then data on local domain has user-defined distribution. In this case, jbegin has no meaning. 
     817       if (jbegin.isEmpty()) jbegin = minJIndex;        
     818     } 
     819     else if (jbegin.isEmpty() && nj.isEmpty()) 
    743820     { 
    744821       jbegin = 0; 
    745822       nj = nj_glo; 
    746      } 
    747      else if (!j_index.isEmpty()) 
    748      { 
    749        if (jbegin.isEmpty()) jbegin = j_index(0); 
    750        if (nj.isEmpty()) nj = j_index.numElements(); 
    751      } 
    752  
    753       if ((nj.getValue() < 0 || jbegin.getValue() < 0) || 
    754          ((type_attr::unstructured != type) && ((jbegin.getValue() + nj.getValue()) > nj_glo.getValue()))) 
    755       { 
    756         ERROR("CDomain::checkLocalJDomain(void)", 
     823     }       
     824 
     825 
     826     if ((nj.getValue() < 0 || jbegin.getValue() < 0)) 
     827     { 
     828       ERROR("CDomain::checkLocalJDomain(void)", 
    757829              << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    758830              << "The local domain is wrongly defined," 
    759831              << " check the attributes 'nj_glo' (" << nj_glo.getValue() << "), 'nj' (" << nj.getValue() << ") and 'jbegin' (" << jbegin.getValue() << ")"); 
    760       } 
     832     } 
    761833   } 
    762834 
Note: See TracChangeset for help on using the changeset viewer.