Ignore:
Timestamp:
06/06/17 17:58:16 (7 years ago)
Author:
oabramkina
Message:

Two server levels: merging with trunk r1137.
There are bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1144 r1158  
    2626namespace xios { 
    2727 
    28    /// ////////////////////// Dfinitions ////////////////////// /// 
     28   /// ////////////////////// Définitions ////////////////////// /// 
    2929 
    3030   CDomain::CDomain(void) 
     
    7979   } 
    8080 
     81   const std::set<StdString> & CDomain::getRelFiles(void) const 
     82   { 
     83      return (this->relFiles); 
     84   } 
     85 
     86 
    8187   /*! 
    8288     Returns the number of indexes written by each server. 
     
    170176   { 
    171177      return ((this->zoom_i_index.isEmpty()) || (0 == this->zoom_i_index.numElements())); 
    172       // return ((this->zoom_ni_srv == 0) || 
    173       //         (this->zoom_nj_srv == 0)); 
     178 
    174179   } 
    175180 
     
    190195   bool CDomain::isDistributed(void) const 
    191196   { 
    192       return !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || 
     197      bool distributed = !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || 
    193198              (!i_index.isEmpty() && i_index.numElements() == ni_glo*nj_glo)); 
     199      distributed |= (1 == CContext::getCurrent()->client->clientSize); 
     200 
     201      return distributed; 
    194202   } 
    195203 
     
    221229 
    222230   //---------------------------------------------------------------- 
     231 
     232   /*! 
     233      Verify if all distribution information of a domain are available 
     234      This checking verifies the definition of distribution attributes (ni, nj, ibegin, jbegin) 
     235   */ 
     236   bool CDomain::distributionAttributesHaveValue() const 
     237   { 
     238      bool hasValues = true; 
     239 
     240      if (ni.isEmpty() && ibegin.isEmpty() && i_index.isEmpty()) 
     241      { 
     242        hasValues = false; 
     243        return hasValues; 
     244      } 
     245 
     246      return hasValues; 
     247   } 
    223248 
    224249   /*! 
     
    331356            ni.setValue(ni_glo - ibeginVec[iIdx]); 
    332357          } 
    333         } 
    334  
    335         // Now fill other attributes 
    336         if (type_attr::rectilinear == type) fillInRectilinearLonLat(); 
     358        }  
    337359     } 
    338360     else  // unstructured domain 
     
    380402            nj.setValue(1); 
    381403          } 
     404 
     405          i_index.resize(ni);           
     406          for(int idx = 0; idx < ni; ++idx) i_index(idx)=ibegin+idx; 
    382407        } 
    383408        else 
     
    391416 
    392417     checkDomain(); 
     418   } 
     419 
     420   /*! 
     421     Fill in longitude and latitude whose values are read from file 
     422   */ 
     423   void CDomain::fillInLonLat() 
     424   { 
     425     switch (type) 
     426     { 
     427      case type_attr::rectilinear: 
     428        fillInRectilinearLonLat(); 
     429        break; 
     430      case type_attr::curvilinear: 
     431        fillInCurvilinearLonLat(); 
     432        break; 
     433      case type_attr::unstructured: 
     434        fillInUnstructuredLonLat(); 
     435        break; 
     436 
     437      default: 
     438      break; 
     439     } 
     440 
    393441   } 
    394442 
     
    468516   } 
    469517 
    470  
    471  
     518    /* 
     519      Fill in longitude and latitude of curvilinear domain read from a file 
     520      If there are already longitude and latitude defined by model. We just igonore reading value. 
     521    */ 
     522   void CDomain::fillInCurvilinearLonLat() 
     523   { 
     524     if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty()) 
     525     { 
     526       lonvalue_2d.resize(ni,nj); 
     527       for (int jdx = 0; jdx < nj; ++jdx) 
     528        for (int idx = 0; idx < ni; ++idx) 
     529         lonvalue_2d(idx,jdx) = lonvalue_curvilinear_read_from_file(idx+ibegin, jdx+jbegin); 
     530 
     531       lonvalue_curvilinear_read_from_file.free(); 
     532     } 
     533 
     534     if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty()) 
     535     { 
     536       latvalue_2d.resize(ni,nj); 
     537       for (int jdx = 0; jdx < nj; ++jdx) 
     538        for (int idx = 0; idx < ni; ++idx) 
     539         latvalue_2d(idx,jdx) = latvalue_curvilinear_read_from_file(idx+ibegin, jdx+jbegin); 
     540 
     541       latvalue_curvilinear_read_from_file.free(); 
     542     } 
     543 
     544     if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty()) 
     545     { 
     546       bounds_lon_2d.resize(nvertex,ni,nj); 
     547       for (int jdx = 0; jdx < nj; ++jdx) 
     548        for (int idx = 0; idx < ni; ++idx) 
     549          for (int ndx = 0; ndx < nvertex; ++ndx) 
     550         bounds_lon_2d(ndx,idx,jdx) = bounds_lonvalue_curvilinear_read_from_file(ndx,idx+ibegin, jdx+jbegin); 
     551 
     552       bounds_lonvalue_curvilinear_read_from_file.free(); 
     553     } 
     554 
     555     if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty()) 
     556     { 
     557       bounds_lat_2d.resize(nvertex,ni,nj); 
     558       for (int jdx = 0; jdx < nj; ++jdx) 
     559        for (int idx = 0; idx < ni; ++idx) 
     560          for (int ndx = 0; ndx < nvertex; ++ndx) 
     561            bounds_lat_2d(ndx,idx,jdx) = bounds_latvalue_curvilinear_read_from_file(ndx,idx+ibegin, jdx+jbegin); 
     562 
     563       bounds_latvalue_curvilinear_read_from_file.free(); 
     564     } 
     565 
     566   } 
     567 
     568    /* 
     569      Fill in longitude and latitude of unstructured domain read from a file 
     570      If there are already longitude and latitude defined by model. We just igonore reading value. 
     571    */ 
     572   void CDomain::fillInUnstructuredLonLat() 
     573   { 
     574     if (i_index.isEmpty()) 
     575     { 
     576       i_index.resize(ni); 
     577       for(int idx = 0; idx < ni; ++idx) i_index(idx)=ibegin+idx; 
     578     } 
     579 
     580     if (!lonvalue_unstructured_read_from_file.isEmpty() && lonvalue_1d.isEmpty()) 
     581     { 
     582        lonvalue_1d.resize(ni); 
     583        for (int idx = 0; idx < ni; ++idx) 
     584          lonvalue_1d(idx) = lonvalue_unstructured_read_from_file(i_index(idx)); 
     585 
     586        // We dont need these values anymore, so just delete them 
     587        lonvalue_unstructured_read_from_file.free(); 
     588     }  
     589 
     590     if (!latvalue_unstructured_read_from_file.isEmpty() && latvalue_1d.isEmpty()) 
     591     { 
     592        latvalue_1d.resize(ni); 
     593        for (int idx = 0; idx < ni; ++idx) 
     594          latvalue_1d(idx) =  latvalue_unstructured_read_from_file(i_index(idx)); 
     595 
     596        // We dont need these values anymore, so just delete them 
     597        latvalue_unstructured_read_from_file.free(); 
     598     } 
     599 
     600     if (!bounds_lonvalue_unstructured_read_from_file.isEmpty() && bounds_lon_1d.isEmpty()) 
     601     { 
     602        int nbVertex = nvertex; 
     603        bounds_lon_1d.resize(nbVertex,ni); 
     604        for (int idx = 0; idx < ni; ++idx) 
     605          for (int jdx = 0; jdx < nbVertex; ++jdx) 
     606            bounds_lon_1d(jdx,idx) = bounds_lonvalue_unstructured_read_from_file(jdx, i_index(idx)); 
     607 
     608        // We dont need these values anymore, so just delete them 
     609        lonvalue_unstructured_read_from_file.free(); 
     610     } 
     611 
     612     if (!bounds_latvalue_unstructured_read_from_file.isEmpty() && bounds_lat_1d.isEmpty()) 
     613     { 
     614        int nbVertex = nvertex; 
     615        bounds_lat_1d.resize(nbVertex,ni); 
     616        for (int idx = 0; idx < ni; ++idx) 
     617          for (int jdx = 0; jdx < nbVertex; ++jdx) 
     618            bounds_lat_1d(jdx,idx) = bounds_latvalue_unstructured_read_from_file(jdx, i_index(idx)); 
     619 
     620        // We dont need these values anymore, so just delete them 
     621        lonvalue_unstructured_read_from_file.free(); 
     622     } 
     623   } 
     624 
     625  /* 
     626    Get global longitude and latitude of rectilinear domain. 
     627  */ 
    472628   void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) 
    473629   { 
     
    590746    else 
    591747    { 
    592       if (bounds_lat_start.isEmpty()) bounds_lon_start=-90. ; 
     748      if (bounds_lat_start.isEmpty()) bounds_lat_start=-90. ; 
    593749      if (bounds_lat_end.isEmpty()) bounds_lat_end=90 ; 
    594750    } 
     
    695851       for (int j = 0; j < nj; ++j) 
    696852         for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 
    697      }      
     853     } 
     854      
    698855     checkZoom(); 
    699856   } 
     
    14311588     if (context->hasClient) 
    14321589     { 
    1433        // this->checkMask(); 
    14341590      this->computeConnectedClients(); 
    1435        // if (hasLonLat || hasArea || isCompressible_) this->computeConnectedClients(); 
    14361591       if (hasLonLat) 
    14371592         if (!context->hasServer) 
     
    14821637     if (context->hasClient) 
    14831638     { 
    1484 //       this->completeLonLatClient(); 
    14851639       sendAttributes(); 
    14861640     } 
     
    26942848  } 
    26952849 
    2696  
    26972850  /*! 
    26982851    Receive area information from client(s) 
     
    27422895       
    27432896    } 
     2897  } 
     2898 
     2899  /*! 
     2900    Compare two domain objects.  
     2901    They are equal if only if they have identical attributes as well as their values. 
     2902    Moreover, they must have the same transformations. 
     2903  \param [in] domain Compared domain 
     2904  \return result of the comparison 
     2905  */ 
     2906  bool CDomain::isEqual(CDomain* obj) 
     2907  { 
     2908    vector<StdString> excludedAttr; 
     2909    excludedAttr.push_back("domain_ref"); 
     2910    bool objEqual = SuperClass::isEqual(obj, excludedAttr); 
     2911    if (!objEqual) return objEqual; 
     2912 
     2913    TransMapTypes thisTrans = this->getAllTransformations(); 
     2914    TransMapTypes objTrans  = obj->getAllTransformations(); 
     2915 
     2916    TransMapTypes::const_iterator it, itb, ite; 
     2917    std::vector<ETranformationType> thisTransType, objTransType; 
     2918    for (it = thisTrans.begin(); it != thisTrans.end(); ++it) 
     2919      thisTransType.push_back(it->first); 
     2920    for (it = objTrans.begin(); it != objTrans.end(); ++it) 
     2921      objTransType.push_back(it->first); 
     2922 
     2923    if (thisTransType.size() != objTransType.size()) return false; 
     2924    for (int idx = 0; idx < thisTransType.size(); ++idx) 
     2925      objEqual &= (thisTransType[idx] == objTransType[idx]); 
     2926 
     2927    return objEqual; 
    27442928  } 
    27452929 
Note: See TracChangeset for help on using the changeset viewer.