Changeset 1642 for XIOS/dev/branch_openmp/src/transformation
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- Location:
- XIOS/dev/branch_openmp/src/transformation
- Files:
-
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/transformation/Functions/reduction.cpp
r1339 r1642 9 9 10 10 CReductionAlgorithm::CallBackMap* CReductionAlgorithm::reductionCreationCallBacks_ = 0; 11 std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0; 12 11 std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>(); 13 12 bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m) 14 13 { … … 30 29 } 31 30 32 bool CReductionAlgorithm::initReductionOperation() 33 { 34 CReductionAlgorithm::ReductionOperations_ptr = new std::map<StdString,EReductionType>(); 35 // So so stupid way to intialize operation but it works ... 36 (*CReductionAlgorithm::ReductionOperations_ptr)["sum"] = TRANS_REDUCE_SUM; 37 CSumReductionAlgorithm::registerTrans(); 38 39 (*CReductionAlgorithm::ReductionOperations_ptr)["min"] = TRANS_REDUCE_MIN; 40 CMinReductionAlgorithm::registerTrans(); 41 42 (*CReductionAlgorithm::ReductionOperations_ptr)["max"] = TRANS_REDUCE_MAX; 43 CMaxReductionAlgorithm::registerTrans(); 44 45 (*CReductionAlgorithm::ReductionOperations_ptr)["extract"] = TRANS_REDUCE_EXTRACT; 46 CExtractReductionAlgorithm::registerTrans(); 47 48 (*CReductionAlgorithm::ReductionOperations_ptr)["average"] = TRANS_REDUCE_AVERAGE; 49 CAverageReductionAlgorithm::registerTrans(); 50 } 51 52 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations); 53 //bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 31 bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations); 54 32 55 33 CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType) -
XIOS/dev/branch_openmp/src/transformation/Functions/reduction.hpp
r1545 r1642 23 23 { 24 24 public: 25 static std::map<StdString,EReductionType> *ReductionOperations_ptr;26 #pragma omp threadprivate(ReductionOperations_ptr) 25 static std::map<StdString,EReductionType> ReductionOperations; 26 27 27 public: 28 28 CReductionAlgorithm() {} … … 61 61 typedef std::map<EReductionType, CreateOperationCallBack> CallBackMap; 62 62 static CallBackMap* reductionCreationCallBacks_; 63 #pragma omp threadprivate(reductionCreationCallBacks_)64 63 65 64 static bool registerOperation(EReductionType reduceType, CreateOperationCallBack createFn); … … 68 67 protected: 69 68 static bool initReductionOperation(std::map<StdString,EReductionType>& m); 70 static bool initReductionOperation();71 69 static bool _dummyInit; 72 #pragma omp threadprivate(_dummyInit)73 70 }; 74 71 -
XIOS/dev/branch_openmp/src/transformation/algo_types.hpp
r1460 r1642 17 17 #include "axis_algorithm_zoom.hpp" 18 18 #include "axis_algorithm_interpolate.hpp" 19 #include "axis_algorithm_extract.hpp" 19 20 #include "axis_algorithm_reduce_domain.hpp" 20 21 #include "axis_algorithm_reduce_axis.hpp" … … 30 31 #include "scalar_algorithm_reduce_scalar.hpp" 31 32 #include "domain_algorithm_reorder.hpp" 33 #include "domain_algorithm_extract.hpp" 32 34 33 35 -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_duplicate_scalar.cpp
r1460 r1642 21 21 std::map<int, int>& elementPositionInGridDst2AxisPosition, 22 22 std::map<int, int>& elementPositionInGridDst2DomainPosition) 23 TRY 23 24 { 24 25 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 31 32 return (new CAxisAlgorithmDuplicateScalar(axisListDestP[axisDstIndex], scalarListSrcP[scalarSrcIndex], duplicateScalar)); 32 33 } 34 CATCH 33 35 34 36 bool CAxisAlgorithmDuplicateScalar::registerTrans() 37 TRY 35 38 { 36 39 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_DUPLICATE_SCALAR_TO_AXIS, create); 37 40 } 41 CATCH 38 42 39 43 … … 50 54 51 55 void CAxisAlgorithmDuplicateScalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 56 TRY 52 57 { 53 58 this->transformationMapping_.resize(1); … … 69 74 } 70 75 } 71 76 CATCH 72 77 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.cpp
r1545 r1642 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 #include "reduction.hpp" 15 16 16 17 namespace xios { … … 24 25 std::map<int, int>& elementPositionInGridDst2AxisPosition, 25 26 std::map<int, int>& elementPositionInGridDst2DomainPosition) 27 TRY 26 28 { 27 29 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 34 36 return (new CAxisAlgorithmExtractDomain(axisListDestP[axisDstIndex], domainListSrcP[domainSrcIndex], extractDomain)); 35 37 } 38 CATCH 36 39 37 40 //bool CAxisAlgorithmExtractDomain::_dummyRegistered = CAxisAlgorithmExtractDomain::registerTrans(); 38 41 bool CAxisAlgorithmExtractDomain::registerTrans() 42 TRY 39 43 { 40 44 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_EXTRACT_DOMAIN_TO_AXIS, create); 41 45 } 46 CATCH 42 47 43 48 44 49 CAxisAlgorithmExtractDomain::CAxisAlgorithmExtractDomain(CAxis* axisDestination, CDomain* domainSource, CExtractDomainToAxis* algo) 45 50 : CAxisAlgorithmTransformation(axisDestination, domainSource), pos_(-1), reduction_(0) 51 TRY 46 52 { 47 53 algo->checkValid(axisDestination, domainSource); … … 61 67 62 68 pos_ = algo->position; 63 if(CReductionAlgorithm::ReductionOperations_ptr == 0) 64 { 65 CReductionAlgorithm::initReductionOperation(); 66 } 67 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 69 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 68 70 } 71 CATCH 69 72 70 73 void CAxisAlgorithmExtractDomain::apply(const std::vector<std::pair<int,double> >& localIndex, … … 73 76 std::vector<bool>& flagInitial, 74 77 bool ignoreMissingValue, bool firstPass) 78 TRY 75 79 { 76 80 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 77 81 } 82 CATCH 78 83 79 84 CAxisAlgorithmExtractDomain::~CAxisAlgorithmExtractDomain() 85 TRY 80 86 { 81 87 if (0 != reduction_) delete reduction_; 82 88 } 89 CATCH 83 90 84 91 void CAxisAlgorithmExtractDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 92 TRY 85 93 { 86 94 this->transformationMapping_.resize(1); … … 120 128 {} 121 129 } 122 130 CATCH 123 131 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_extract_domain.hpp
r1339 r1642 13 13 #include "transformation.hpp" 14 14 15 #include "reduction.hpp"16 15 namespace xios { 17 16 … … 26 25 Extract a domain to an axis 27 26 */ 28 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation , public CReductionAlgorithm27 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation 29 28 { 30 29 public: -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_interpolate.cpp
r1460 r1642 29 29 std::map<int, int>& elementPositionInGridDst2AxisPosition, 30 30 std::map<int, int>& elementPositionInGridDst2DomainPosition) 31 TRY 31 32 { 32 33 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 39 40 return (new CAxisAlgorithmInterpolate(axisListDestP[axisDstIndex], axisListSrcP[axisSrcIndex], interpolateAxis)); 40 41 } 42 CATCH 41 43 42 44 bool CAxisAlgorithmInterpolate::registerTrans() 45 TRY 43 46 { 44 47 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_INTERPOLATE_AXIS, create); 45 48 } 46 49 CATCH 47 50 48 51 CAxisAlgorithmInterpolate::CAxisAlgorithmInterpolate(CAxis* axisDestination, CAxis* axisSource, CInterpolateAxis* interpAxis) 49 52 : CAxisAlgorithmTransformation(axisDestination, axisSource), coordinate_(), transPosition_() 53 TRY 50 54 { 51 55 interpAxis->checkValid(axisSource); … … 58 62 } 59 63 } 64 CATCH 60 65 61 66 /*! … … 63 68 */ 64 69 void CAxisAlgorithmInterpolate::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 70 TRY 65 71 { 66 72 CTimer::get("CAxisAlgorithmInterpolate::computeIndexSourceMapping_").resume() ; … … 88 94 CTimer::get("CAxisAlgorithmInterpolate::computeIndexSourceMapping_").suspend() ; 89 95 } 96 CATCH 90 97 91 98 /*! … … 98 105 const std::vector<int>& indexVec, 99 106 int transPos) 107 TRY 100 108 { 101 109 std::vector<double>::const_iterator itb = axisValue.begin(), ite = axisValue.end(); … … 162 170 computeWeightedValueAndMapping(interpolatingIndexValues, transPos); 163 171 } 172 CATCH 164 173 165 174 /*! … … 168 177 */ 169 178 void CAxisAlgorithmInterpolate::computeWeightedValueAndMapping(const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos) 179 TRY 170 180 { 171 181 TransformationIndexMap& transMap = this->transformationMapping_[transPos]; … … 205 215 206 216 } 217 CATCH 207 218 208 219 /*! … … 213 224 void CAxisAlgorithmInterpolate::retrieveAllAxisValue(const CArray<double,1>& axisValue, const CArray<bool,1>& axisMask, 214 225 std::vector<double>& recvBuff, std::vector<int>& indexVec) 226 TRY 215 227 { 216 228 CContext* context = CContext::getCurrent(); … … 260 272 261 273 int* recvCount=new int[nbClient]; 262 MPI_Allgather(&numValue,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm);274 ep_lib::MPI_Allgather(&numValue,1,EP_INT,recvCount,1,EP_INT,client->intraComm); 263 275 264 276 int* displ=new int[nbClient]; … … 267 279 268 280 // Each client have enough global info of axis 269 MPI_Allgatherv(sendIndexBuff,numValue,MPI_INT,recvIndexBuff,recvCount,displ,MPI_INT,client->intraComm);270 MPI_Allgatherv(sendValueBuff,numValue,MPI_DOUBLE,&(recvBuff[0]),recvCount,displ,MPI_DOUBLE,client->intraComm);281 ep_lib::MPI_Allgatherv(sendIndexBuff,numValue,EP_INT,recvIndexBuff,recvCount,displ,EP_INT,client->intraComm); 282 ep_lib::MPI_Allgatherv(sendValueBuff,numValue,EP_DOUBLE,&(recvBuff[0]),recvCount,displ,EP_DOUBLE,client->intraComm); 271 283 272 284 for (int idx = 0; idx < srcSize; ++idx) … … 282 294 } 283 295 } 296 CATCH 284 297 285 298 /*! … … 289 302 void CAxisAlgorithmInterpolate::fillInAxisValue(std::vector<CArray<double,1> >& vecAxisValue, 290 303 const std::vector<CArray<double,1>* >& dataAuxInputs) 304 TRY 291 305 { 292 306 if (coordinate_.empty()) … … 377 391 } 378 392 } 379 380 } 393 CATCH 394 395 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_inverse.cpp
r1545 r1642 15 15 #include "inverse_axis.hpp" 16 16 #include "client_client_dht_template.hpp" 17 using namespace ep_lib;18 17 19 18 namespace xios { … … 28 27 std::map<int, int>& elementPositionInGridDst2AxisPosition, 29 28 std::map<int, int>& elementPositionInGridDst2DomainPosition) 29 TRY 30 30 { 31 31 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 38 38 return (new CAxisAlgorithmInverse(axisListDestP[axisDstIndex], axisListSrcP[axisSrcIndex], inverseAxis)); 39 39 } 40 CATCH 40 41 41 42 bool CAxisAlgorithmInverse::registerTrans() 43 TRY 42 44 { 43 45 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_INVERSE_AXIS, create); 44 46 } 45 47 CATCH 46 48 47 49 CAxisAlgorithmInverse::CAxisAlgorithmInverse(CAxis* axisDestination, CAxis* axisSource, CInverseAxis* inverseAxis) 48 50 : CAxisAlgorithmTransformation(axisDestination, axisSource) 51 TRY 49 52 { 50 53 if (axisDestination->n_glo.getValue() != axisSource->n_glo.getValue()) … … 56 59 } 57 60 } 61 CATCH 58 62 59 63 void CAxisAlgorithmInverse::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 64 TRY 60 65 { 61 66 this->transformationMapping_.resize(1); … … 83 88 } 84 89 } 90 CATCH 85 91 86 92 /*! … … 89 95 */ 90 96 void CAxisAlgorithmInverse::updateAxisValue() 97 TRY 91 98 { 92 99 CContext* context = CContext::getCurrent(); … … 154 161 sendRankSizeMap[itIndex->first] = sendSize; 155 162 } 156 MPI_Allgather(&connectedClient,1,MPI_INT,recvCount,1,MPI_INT,client->intraComm);163 ep_lib::MPI_Allgather(&connectedClient,1,EP_INT,recvCount,1,EP_INT,client->intraComm); 157 164 158 165 displ[0]=0 ; … … 161 168 int* recvRankBuff=new int[recvSize]; 162 169 int* recvSizeBuff=new int[recvSize]; 163 MPI_Allgatherv(sendRankBuff,connectedClient,MPI_INT,recvRankBuff,recvCount,displ,MPI_INT,client->intraComm);164 MPI_Allgatherv(sendSizeBuff,connectedClient,MPI_INT,recvSizeBuff,recvCount,displ,MPI_INT,client->intraComm);170 ep_lib::MPI_Allgatherv(sendRankBuff,connectedClient,EP_INT,recvRankBuff,recvCount,displ,EP_INT,client->intraComm); 171 ep_lib::MPI_Allgatherv(sendSizeBuff,connectedClient,EP_INT,recvSizeBuff,recvCount,displ,EP_INT,client->intraComm); 165 172 for (int i = 0; i < nbClient; ++i) 166 173 { … … 174 181 175 182 // Sending global index of grid source to corresponding process as well as the corresponding mask 176 std::vector< MPI_Request> requests;177 std::vector< MPI_Status> status;183 std::vector<ep_lib::MPI_Request> requests; 184 std::vector<ep_lib::MPI_Status> status; 178 185 std::unordered_map<int, unsigned long* > recvGlobalIndexSrc; 179 186 std::unordered_map<int, double* > sendValueToDest; … … 185 192 sendValueToDest[recvRank] = new double [recvSize]; 186 193 187 requests.push_back( MPI_Request());188 MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests.back());194 requests.push_back(ep_lib::MPI_Request()); 195 ep_lib::MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, EP_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests.back()); 189 196 } 190 197 … … 207 214 208 215 // Send global index source and mask 209 requests.push_back( MPI_Request());210 MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests.back());216 requests.push_back(ep_lib::MPI_Request()); 217 ep_lib::MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, EP_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests.back()); 211 218 } 212 219 213 220 status.resize(requests.size()); 214 MPI_Waitall(requests.size(), &requests[0], &status[0]);215 216 217 std::vector< MPI_Request>().swap(requests);218 std::vector< MPI_Status>().swap(status);221 ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 222 223 224 std::vector<ep_lib::MPI_Request>().swap(requests); 225 std::vector<ep_lib::MPI_Status>().swap(status); 219 226 220 227 // Okie, on destination side, we will wait for information of masked index of source … … 224 231 int recvSize = itSend->second; 225 232 226 requests.push_back( MPI_Request());227 MPI_Irecv(recvValueFromSrc[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back());233 requests.push_back(ep_lib::MPI_Request()); 234 ep_lib::MPI_Irecv(recvValueFromSrc[recvRank], recvSize, EP_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 228 235 } 229 236 … … 242 249 } 243 250 // Okie, now inform the destination which source index are masked 244 requests.push_back( MPI_Request());245 MPI_Isend(sendValueToDest[recvRank], recvSize, MPI_DOUBLE, recvRank, 48, client->intraComm, &requests.back());251 requests.push_back(ep_lib::MPI_Request()); 252 ep_lib::MPI_Isend(sendValueToDest[recvRank], recvSize, EP_DOUBLE, recvRank, 48, client->intraComm, &requests.back()); 246 253 } 247 254 status.resize(requests.size()); 248 MPI_Waitall(requests.size(), &requests[0], &status[0]);255 ep_lib::MPI_Waitall(requests.size(), &requests[0], &status[0]); 249 256 250 257 … … 283 290 delete [] itLong->second; 284 291 } 285 286 } 292 CATCH 293 294 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_axis.cpp
r1545 r1642 12 12 #include "grid.hpp" 13 13 #include "grid_transformation_factory_impl.hpp" 14 #include "reduction.hpp" 14 15 15 16 namespace xios { … … 23 24 std::map<int, int>& elementPositionInGridDst2AxisPosition, 24 25 std::map<int, int>& elementPositionInGridDst2DomainPosition) 26 TRY 25 27 { 26 28 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 33 35 return (new CAxisAlgorithmReduceAxis(axisListDestP[axisDstIndex], axisListSrcP[axisSrcIndex], reduceAxis)); 34 36 } 37 CATCH 35 38 36 39 bool CAxisAlgorithmReduceAxis::registerTrans() 40 TRY 37 41 { 38 42 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_REDUCE_AXIS_TO_AXIS, create); 39 43 } 44 CATCH 40 45 41 46 42 47 CAxisAlgorithmReduceAxis::CAxisAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToAxis* algo) 43 48 : CAxisAlgorithmTransformation(axisDestination, axisSource), reduction_(0) 49 TRY 44 50 { 45 51 eliminateRedondantSrc_= false ; … … 67 73 68 74 } 69 if(CReductionAlgorithm::ReductionOperations_ptr == 0)70 {71 CReductionAlgorithm::initReductionOperation();72 }73 75 74 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations _ptr->at(op));76 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 75 77 } 78 CATCH 76 79 77 80 void CAxisAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, … … 80 83 std::vector<bool>& flagInitial, 81 84 bool ignoreMissingValue, bool firstPass) 85 TRY 82 86 { 83 87 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 84 88 } 89 CATCH 85 90 86 91 void CAxisAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 92 TRY 87 93 { 88 94 reduction_->updateData(dataOut); 89 95 } 96 CATCH 90 97 91 98 CAxisAlgorithmReduceAxis::~CAxisAlgorithmReduceAxis() 99 TRY 92 100 { 93 101 if (0 != reduction_) delete reduction_; 94 102 } 103 CATCH 95 104 96 105 void CAxisAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 106 TRY 97 107 { 98 108 this->transformationMapping_.resize(1); … … 112 122 } 113 123 } 124 CATCH 114 125 115 126 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_axis.hpp
r1460 r1642 12 12 #include "axis_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 24 23 Reduce a axis to an axis 25 24 */ 26 class CAxisAlgorithmReduceAxis : public CAxisAlgorithmTransformation , public CReductionAlgorithm25 class CAxisAlgorithmReduceAxis : public CAxisAlgorithmTransformation 27 26 { 28 27 public: -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.cpp
r1545 r1642 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 15 #include "reduction.hpp" 16 16 17 17 namespace xios { … … 25 25 std::map<int, int>& elementPositionInGridDst2AxisPosition, 26 26 std::map<int, int>& elementPositionInGridDst2DomainPosition) 27 TRY 27 28 { 28 29 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 35 36 return (new CAxisAlgorithmReduceDomain(axisListDestP[axisDstIndex], domainListSrcP[domainSrcIndex], reduceDomain)); 36 37 } 38 CATCH 37 39 38 40 bool CAxisAlgorithmReduceDomain::registerTrans() 41 TRY 39 42 { 40 43 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_REDUCE_DOMAIN_TO_AXIS, create); 41 44 } 45 CATCH 42 46 43 47 44 48 CAxisAlgorithmReduceDomain::CAxisAlgorithmReduceDomain(CAxis* axisDestination, CDomain* domainSource, CReduceDomainToAxis* algo) 45 49 : CAxisAlgorithmTransformation(axisDestination, domainSource), reduction_(0) 50 TRY 46 51 { 47 52 algo->checkValid(axisDestination, domainSource); … … 70 75 71 76 dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction) ? iDir : jDir; 72 if(CReductionAlgorithm::ReductionOperations_ptr == 0) 73 { 74 CReductionAlgorithm::initReductionOperation(); 75 } 76 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 77 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 77 78 local = algo->local ; 78 79 } 80 CATCH 79 81 80 82 void CAxisAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex, … … 83 85 std::vector<bool>& flagInitial, 84 86 bool ignoreMissingValue, bool firstPass) 87 TRY 85 88 { 86 89 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 87 90 } 91 CATCH 88 92 89 93 void CAxisAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 94 TRY 90 95 { 91 96 reduction_->updateData(dataOut); 92 97 } 98 CATCH 93 99 94 100 CAxisAlgorithmReduceDomain::~CAxisAlgorithmReduceDomain() 101 TRY 95 102 { 96 103 if (0 != reduction_) delete reduction_; 97 104 } 105 CATCH 98 106 99 107 void CAxisAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 108 TRY 100 109 { 101 110 this->transformationMapping_.resize(1); … … 178 187 {} 179 188 } 189 CATCH 180 190 181 191 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_reduce_domain.hpp
r1460 r1642 12 12 #include "axis_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Reduce a domain to an axis 26 25 */ 27 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation , public CReductionAlgorithm26 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation 28 27 { 29 28 public: … … 47 46 jDir = 2 48 47 }; 49 48 50 49 ReduceDirection dir_; 51 50 bool local ; -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_temporal_splitting.cpp
r1460 r1642 21 21 std::map<int, int>& elementPositionInGridDst2AxisPosition, 22 22 std::map<int, int>& elementPositionInGridDst2DomainPosition) 23 TRY 23 24 { 24 25 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 31 32 return (new CAxisAlgorithmTemporalSplitting(axisListDestP[axisDstIndex], scalarListSrcP[scalarSrcIndex], temporalSplitting)); 32 33 } 34 CATCH 33 35 34 36 bool CAxisAlgorithmTemporalSplitting::registerTrans() 37 TRY 35 38 { 36 39 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_TEMPORAL_SPLITTING, create); 37 40 } 38 41 CATCH 39 42 40 43 CAxisAlgorithmTemporalSplitting::CAxisAlgorithmTemporalSplitting(CAxis* axisDestination, CScalar* scalarSource, CTemporalSplitting* algo) … … 50 53 51 54 void CAxisAlgorithmTemporalSplitting::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 55 TRY 52 56 { 53 57 this->transformationMapping_.resize(1); … … 72 76 } 73 77 } 78 CATCH 74 79 75 80 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_transformation.cpp
r1460 r1642 20 20 CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CAxis* axisSource) 21 21 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(axisSource), domainSrc_(0),scalarSrc_(0) 22 TRY 22 23 { 23 24 axisDestGlobalSize_ = axisDestination->n_glo.getValue(); … … 28 29 if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); 29 30 } 31 CATCH 30 32 31 33 CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CDomain* domainSource) 32 34 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(domainSource),scalarSrc_(0) 35 TRY 33 36 { 34 37 axisDestGlobalSize_ = axisDestination->n_glo.getValue(); … … 39 42 if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); 40 43 } 44 CATCH 41 45 42 46 CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CScalar* scalarSource) 43 47 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(0), scalarSrc_(scalarSource) 48 TRY 44 49 { 45 50 axisDestGlobalSize_ = axisDestination->n_glo.getValue(); … … 50 55 if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); 51 56 } 57 CATCH 58 52 59 CAxisAlgorithmTransformation::~CAxisAlgorithmTransformation() 53 60 { … … 66 73 int elementType, 67 74 CClientClientDHTInt::Index2VectorInfoTypeMap& globalAxisIndexOnProc) 75 TRY 68 76 { 69 77 CContext* context = CContext::getCurrent(); … … 124 132 globalAxisIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); 125 133 } 134 CATCH 126 135 127 136 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.cpp
r1460 r1642 1 1 /*! 2 2 \file axis_algorithm_zoom.cpp 3 \author Ha NGUYEN 4 \since 03 June 2015 5 \date 12 June 2015 6 7 \brief Algorithm for zooming on an axis. 3 \brief Algorithm for zooming an axis. 8 4 */ 9 5 #include "axis_algorithm_zoom.hpp" … … 23 19 std::map<int, int>& elementPositionInGridDst2AxisPosition, 24 20 std::map<int, int>& elementPositionInGridDst2DomainPosition) 21 TRY 25 22 { 26 23 std::vector<CAxis*> axisListDestP = gridDst->getAxis(); … … 33 30 return (new CAxisAlgorithmZoom(axisListDestP[axisDstIndex], axisListSrcP[axisSrcIndex], zoomAxis)); 34 31 } 32 CATCH 33 35 34 bool CAxisAlgorithmZoom::registerTrans() 35 TRY 36 36 { 37 37 CGridTransformationFactory<CAxis>::registerTransformation(TRANS_ZOOM_AXIS, create); 38 38 } 39 CATCH 39 40 40 41 CAxisAlgorithmZoom::CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis) 41 42 : CAxisAlgorithmTransformation(axisDestination, axisSource) 43 TRY 42 44 { 43 45 zoomAxis->checkValid(axisSource); 44 46 zoomBegin_ = zoomAxis->begin.getValue(); 45 zoom Size_ = zoomAxis->n.getValue();46 zoomEnd_ = zoomBegin_ + zoom Size_ - 1;47 zoomN_ = zoomAxis->n.getValue(); 48 zoomEnd_ = zoomBegin_ + zoomN_ - 1; 47 49 48 if (zoom Size_ > axisSource->n_glo.getValue())50 if (zoomN_ > axisSource->n_glo.getValue()) 49 51 { 50 52 ERROR("CAxisAlgorithmZoom::CAxisAlgorithmZoom(CAxis* axisDestination, CAxis* axisSource, CZoomAxis* zoomAxis)", 51 << "Zoom size is greater than global size of axis source"52 << "Global size of axis source" <<axisSource->getId() << " is " << axisSource->n_glo.getValue() << std::endl53 << "Zoom size is " << zoom Size_ );53 << "Zoom size is greater than global size of source axis" 54 << "Global size of source axis " <<axisSource->getId() << " is " << axisSource->n_glo.getValue() << std::endl 55 << "Zoom size is " << zoomN_ ); 54 56 } 55 57 56 if (!zoomAxis->index.isEmpty()) 58 int idxSrc, nDest = 0, beginDestLoc, beginDestGlo = 0 ; 59 int indGloDest, indGloSrc, iSrc; 60 for (int i = 0; i < axisSrc_->n.getValue(); i++) 57 61 { 58 int sz = zoomAxis->index.numElements(); 59 zoomIndex_.resize(sz); 60 for (int i = 0; i < sz; ++i) 61 zoomIndex_[i] = zoomAxis->index(i); 62 idxSrc = axisSrc_->index(i); 63 if ((idxSrc >= zoomBegin_) && (idxSrc <= zoomEnd_)) 64 { 65 if (nDest == 0) beginDestLoc = i; 66 ++nDest; 67 } 68 } 69 beginDestGlo = beginDestLoc + axisSrc_->begin - zoomBegin_; 70 axisDest_->n_glo.setValue(zoomN_); 71 axisDest_->n.setValue(nDest); 72 axisDest_->begin.setValue(beginDestGlo); 73 axisDest_->index.resize(nDest); 62 74 63 std::sort(zoomIndex_.begin(), zoomIndex_.end()); 75 axisDest_->data_n.setValue(nDest); 76 axisDest_->data_begin.setValue(0); 77 axisDest_->data_index.resize(nDest); 78 79 axisDest_->mask.resize(nDest); 80 if (axisSrc_->hasValue) axisDest_->value.resize(nDest); 81 if (axisSrc_->hasLabel) axisDest_->label.resize(nDest); 82 if (axisSrc_->hasBounds) axisDest_->bounds.resize(2,nDest); 83 84 this->transformationMapping_.resize(1); 85 this->transformationWeight_.resize(1); 86 TransformationIndexMap& transMap = this->transformationMapping_[0]; 87 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 88 89 for (int iDest = 0; iDest < nDest; iDest++) 90 { 91 iSrc = iDest + beginDestLoc; 92 axisDest_->index(iDest) = iDest + beginDestGlo; 93 axisDest_->data_index(iDest) = axisSrc_->data_index(iSrc) - beginDestLoc; 94 axisDest_->mask(iDest) = axisSrc_->mask(iSrc); 95 96 if (axisSrc_->hasValue) 97 axisDest_->value(iDest) = axisSrc_->value(iSrc); 98 if (axisSrc_->hasLabel) 99 axisDest_->label(iDest) = axisSrc_->label(iSrc); 100 if (axisSrc_->hasBounds) 101 { 102 axisDest_->bounds(0,iDest) = axisSrc_->bounds(0,iSrc); 103 axisDest_->bounds(1,iDest) = axisSrc_->bounds(1,iSrc); 104 } 105 indGloDest = axisDest_->index(iDest); 106 indGloSrc = axisSrc_->index(iSrc); 107 transMap[indGloDest].push_back(indGloSrc); 108 transWeight[indGloDest].push_back(1.0); 109 64 110 } 65 66 111 } 112 CATCH 67 113 68 114 /*! 69 Compute the index mapping between axison grid source and one on grid destination115 Compute the index mapping between domain on grid source and one on grid destination 70 116 */ 71 117 void CAxisAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 72 118 { 73 // We use all index of source and destination to calculate the mapping index of zoom.74 // The server who receives the "zoomed" fields will decide whether it will forward these fields or write "real zoomed" fields into file75 // That means servers need to change to cover this problem.76 StdSize niSource = axisSrc_->n.getValue();77 StdSize ibeginSource = axisSrc_->begin.getValue();78 StdSize iendSource = ibeginSource + niSource - 1;79 80 StdSize ibegin = std::max(ibeginSource, zoomBegin_);81 StdSize iend = std::min(iendSource, zoomEnd_);82 StdSize ni = iend + 1 - ibegin;83 if (iend < ibegin) ni = 0;84 85 this->transformationMapping_.resize(1);86 this->transformationWeight_.resize(1);87 88 TransformationIndexMap& transMap = this->transformationMapping_[0];89 TransformationWeightMap& transWeight = this->transformationWeight_[0];90 91 if (!zoomIndex_.empty())92 {93 std::vector<int>::iterator itZoomBegin, itZoomEnd;94 itZoomBegin = std::lower_bound(zoomIndex_.begin(), zoomIndex_.end(), ibeginSource);95 itZoomEnd = std::upper_bound(zoomIndex_.begin(), zoomIndex_.end(), iendSource);96 for (; itZoomBegin != itZoomEnd; ++itZoomBegin)97 {98 transMap[*itZoomBegin].push_back(*itZoomBegin);99 transWeight[*itZoomBegin].push_back(1.0);100 }101 }102 else103 {104 for (StdSize idx = 0; idx < ni; ++idx)105 {106 transMap[ibegin+idx].push_back(ibegin+idx);107 transWeight[ibegin+idx].push_back(1.0);108 }109 }110 111 updateZoom();112 // updateAxisDestinationMask();113 119 } 114 120 115 /*!116 After a zoom on axis, it should be certain that (global) zoom begin and (global) zoom size are updated117 */118 void CAxisAlgorithmZoom::updateZoom()119 {120 axisDest_->global_zoom_begin = zoomBegin_;121 axisDest_->global_zoom_n = zoomSize_;122 if (!zoomIndex_.empty())123 {124 axisDest_->global_zoom_index.resize(zoomIndex_.size());125 std::copy(zoomIndex_.begin(), zoomIndex_.end(), axisDest_->global_zoom_index.begin());126 }127 121 } 128 129 /*!130 Update mask on axis131 Because only zoomed region on axis is not masked, the remaining must be masked to make sure132 correct index be extracted133 */134 // void CAxisAlgorithmZoom::updateAxisDestinationMask()135 // {136 // StdSize niMask = axisDest_->mask.numElements();137 // StdSize iBeginMask = axisDest_->begin.getValue();138 // StdSize globalIndexMask = 0;139 // TransformationIndexMap& transMap = this->transformationMapping_[0];140 // TransformationIndexMap::const_iterator ite = (transMap).end();141 // for (StdSize idx = 0; idx < niMask; ++idx)142 // {143 // globalIndexMask = iBeginMask + idx;144 // if (transMap.find(globalIndexMask) == ite)145 // (axisDest_->mask)(idx) = false;146 // }147 // }148 149 } -
XIOS/dev/branch_openmp/src/transformation/axis_algorithm_zoom.hpp
r1460 r1642 1 1 /*! 2 2 \file axis_algorithm_zoom.hpp 3 \author Ha NGUYEN 4 \since 03 June 2015 5 \date 12 June 2015 6 7 \brief Algorithm for zooming on an axis. 3 \brief Algorithm for zooming an axis. 8 4 */ 9 5 #ifndef __XIOS_AXIS_ALGORITHM_ZOOM_HPP__ … … 21 17 Implementing zoom on axis 22 18 A zoomed region can be considered as region that isn't masked. 23 Only this zoomed region is extracted to write on Netcdf.19 Only this zoomed region is zoomed to write on Netcdf. 24 20 */ 25 21 class CAxisAlgorithmZoom : public CAxisAlgorithmTransformation … … 35 31 36 32 private: 37 // void updateAxisDestinationMask();38 void updateZoom();39 33 40 34 private: … … 46 40 47 41 //! Global zoom size on axis 48 StdSize zoom Size_;42 StdSize zoomN_; 49 43 50 44 std::vector<int> zoomIndex_; -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_compute_connectivity.cpp
r978 r1642 24 24 std::map<int, int>& elementPositionInGridDst2AxisPosition, 25 25 std::map<int, int>& elementPositionInGridDst2DomainPosition) 26 TRY 26 27 { 27 28 std::vector<CDomain*> domainListDestP = gridDst->getDomains(); … … 34 35 return (new CDomainAlgorithmComputeConnectivity(domainListDestP[domainDstIndex], domainListSrcP[domainSrcIndex], compute_connectivityDomain)); 35 36 } 37 CATCH 36 38 37 39 bool CDomainAlgorithmComputeConnectivity::registerTrans() 40 TRY 38 41 { 39 42 CGridTransformationFactory<CDomain>::registerTransformation(TRANS_COMPUTE_CONNECTIVITY_DOMAIN, create); 40 43 } 44 CATCH 41 45 42 46 CDomainAlgorithmComputeConnectivity::CDomainAlgorithmComputeConnectivity(CDomain* domainDestination, CDomain* domainSource, 43 47 CComputeConnectivityDomain* compute_connectivityDomain) 44 48 : CDomainAlgorithmTransformation(domainDestination, domainSource) 49 TRY 45 50 { 46 51 this->type_ = (ELEMENT_NO_MODIFICATION_WITHOUT_DATA); … … 64 69 computeLocalConnectivity(type, domainDestination, nbNeighborMax, nbNeighbor, localNeighbors); 65 70 } 71 CATCH 66 72 67 73 /*! … … 78 84 CArray<int,1>& nbConnectivity, 79 85 CArray<int,2>& localConnectivity) 86 TRY 80 87 { 81 88 … … 93 100 if (nbConnectivityMax < nbConnectivity(idx)) nbConnectivityMax = nbConnectivity(idx); 94 101 } 95 96 102 CATCH 97 103 98 104 /*! -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_expand.cpp
r1460 r1642 26 26 std::map<int, int>& elementPositionInGridDst2AxisPosition, 27 27 std::map<int, int>& elementPositionInGridDst2DomainPosition) 28 TRY 28 29 { 29 30 std::vector<CDomain*> domainListDestP = gridDst->getDomains(); … … 36 37 return (new CDomainAlgorithmExpand(domainListDestP[domainDstIndex], domainListSrcP[domainSrcIndex], expandDomain)); 37 38 } 39 CATCH 38 40 39 41 bool CDomainAlgorithmExpand::registerTrans() 42 TRY 40 43 { 41 44 CGridTransformationFactory<CDomain>::registerTransformation(TRANS_EXPAND_DOMAIN, create); 42 45 } 46 CATCH 43 47 44 48 CDomainAlgorithmExpand::CDomainAlgorithmExpand(CDomain* domainDestination, … … 47 51 : CDomainAlgorithmTransformation(domainDestination, domainSource), 48 52 isXPeriodic_(false), isYPeriodic_(false) 53 TRY 49 54 { 50 55 if (domainDestination == domainSource) … … 77 82 } 78 83 } 84 CATCH 79 85 80 86 /*! … … 85 91 void CDomainAlgorithmExpand::expandDomainEdgeConnectivity(CDomain* domainDestination, 86 92 CDomain* domainSource) 93 TRY 87 94 { 88 95 CContext* context = CContext::getCurrent(); … … 104 111 } 105 112 } 113 CATCH 106 114 107 115 /*! … … 112 120 void CDomainAlgorithmExpand::expandDomainNodeConnectivity(CDomain* domainDestination, 113 121 CDomain* domainSource) 122 TRY 114 123 { 115 124 CContext* context = CContext::getCurrent(); … … 131 140 } 132 141 } 142 CATCH 133 143 134 144 /*! … … 142 152 CDomain* domainSource, 143 153 CArray<int,2>& neighborsDomainSrc) 154 TRY 144 155 { 145 156 int index, globalIndex, idx; … … 161 172 else domainDestination->domain_ref.setValue(domainDstRef); 162 173 174 163 175 // Here are attributes of source need tranfering 164 176 int niGloSrc = domainSource->ni_glo; … … 227 239 domainDestination->ni.setValue(niDst); 228 240 domainDestination->nj.setValue(njDst); 229 domainDestination->global_zoom_ni.setValue(domainSource->global_zoom_ni+2);230 domainDestination->global_zoom_nj.setValue(domainSource->global_zoom_nj+2);231 241 232 242 CArray<bool,1>& mask_1d_dst = domainDestination->domainMask; … … 456 466 domainDestination->computeLocalMask() ; 457 467 } 468 CATCH 458 469 459 470 /*! … … 467 478 CDomain* domainSource, 468 479 CArray<int,2>& neighborsDomainSrc) 480 TRY 469 481 { 470 482 … … 670 682 domainDestination->computeLocalMask() ; 671 683 } 672 684 CATCH 673 685 674 686 /*! -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_generate_rectilinear.cpp
r1064 r1642 20 20 CGenerateRectilinearDomain* genRectDomain) 21 21 : CDomainAlgorithmTransformation(domainDestination, domainSource), nbDomainDistributedPart_(0) 22 TRY 22 23 { 23 24 type_ = ELEMENT_GENERATION; … … 30 31 fillInAttributesDomainDestination(); 31 32 } 33 CATCH 32 34 33 35 /*! … … 43 45 */ 44 46 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridSource(CGrid* gridSrc) 47 TRY 45 48 { 46 49 CContext* context = CContext::getCurrent(); … … 67 70 StdSize hashValue = hashFunc.hashVec(globalAxisIndex); 68 71 std::vector<StdSize> recvBuff(client->clientSize); 69 MPI_Gather(&hashValue, 1, MPI_UNSIGNED_LONG,70 &recvBuff[0], 1, MPI_UNSIGNED_LONG,72 ep_lib::MPI_Gather(&hashValue, 1, EP_UNSIGNED_LONG, 73 &recvBuff[0], 1, EP_UNSIGNED_LONG, 71 74 0, 72 75 client->intraComm); … … 84 87 } 85 88 86 MPI_Bcast(&nbLocalAxis[0], nbAxis, MPI_INT,89 ep_lib::MPI_Bcast(&nbLocalAxis[0], nbAxis, EP_INT, 87 90 0, client->intraComm); 88 91 } … … 94 97 } 95 98 } 99 CATCH 96 100 97 101 /*! … … 99 103 */ 100 104 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridDestination(CGrid* gridDest) 105 TRY 101 106 { 102 107 // For now, just suppose that the grid contains only one domain … … 121 126 122 127 } 128 CATCH 123 129 124 130 /*! … … 126 132 */ 127 133 void CDomainAlgorithmGenerateRectilinear::fillInAttributesDomainDestination() 134 TRY 128 135 { 129 136 if (!domainDest_->distributionAttributesHaveValue()) … … 131 138 domainDest_->fillInLonLat(); 132 139 } 133 140 CATCH 134 141 } -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp
r1555 r1642 20 20 #include "interpolate_domain.hpp" 21 21 #include "grid.hpp" 22 using namespace ep_lib;23 22 24 23 namespace xios { … … 32 31 std::map<int, int>& elementPositionInGridDst2AxisPosition, 33 32 std::map<int, int>& elementPositionInGridDst2DomainPosition) 33 TRY 34 34 { 35 35 std::vector<CDomain*> domainListDestP = gridDst->getDomains(); … … 42 42 return (new CDomainAlgorithmInterpolate(domainListDestP[domainDstIndex], domainListSrcP[domainSrcIndex], interpolateDomain)); 43 43 } 44 CATCH 44 45 45 46 bool CDomainAlgorithmInterpolate::registerTrans() 47 TRY 46 48 { 47 49 CGridTransformationFactory<CDomain>::registerTransformation(TRANS_INTERPOLATE_DOMAIN, create); 48 50 } 51 CATCH 49 52 50 53 CDomainAlgorithmInterpolate::CDomainAlgorithmInterpolate(CDomain* domainDestination, CDomain* domainSource, CInterpolateDomain* interpDomain) 51 54 : CDomainAlgorithmTransformation(domainDestination, domainSource), interpDomain_(interpDomain), writeToFile_(false), readFromFile_(false) 55 TRY 52 56 { 53 57 CContext* context = CContext::getCurrent(); … … 94 98 95 99 } 100 CATCH 96 101 97 102 /*! … … 99 104 */ 100 105 void CDomainAlgorithmInterpolate::computeRemap() 106 TRY 101 107 { 102 108 using namespace sphereRemap; … … 305 311 CArray<double,2> boundsLonSrcUnmasked(nVertexSrc,nSrcLocalUnmasked); 306 312 CArray<double,2> boundsLatSrcUnmasked(nVertexSrc,nSrcLocalUnmasked); 313 CArray<double,1> areaSrcUnmasked(nSrcLocalUnmasked); 314 307 315 long int * globalSrcUnmasked = new long int [nSrcLocalUnmasked]; 308 316 309 317 nSrcLocalUnmasked=0 ; 318 bool hasSrcArea=domainSrc_->hasArea && !domainSrc_->radius.isEmpty() && !interpDomain_->use_area.isEmpty() && interpDomain_->use_area==true ; 319 double srcAreaFactor ; 320 if (hasSrcArea) srcAreaFactor=1./(domainSrc_->radius*domainSrc_->radius) ; 321 310 322 for (int idx=0 ; idx < nSrcLocal; idx++) 311 323 { … … 317 329 boundsLatSrcUnmasked(n,nSrcLocalUnmasked) = boundsLatSrc(n,idx) ; 318 330 } 331 if (hasSrcArea) areaSrcUnmasked(nSrcLocalUnmasked) = domainSrc_->areavalue(idx)*srcAreaFactor ; 319 332 globalSrcUnmasked[nSrcLocalUnmasked]=globalSrc[idx] ; 320 333 ++nSrcLocalUnmasked ; 321 334 } 322 335 } 323 336 324 337 325 338 int nDstLocalUnmasked = 0 ; … … 328 341 CArray<double,2> boundsLonDestUnmasked(nVertexDest,nDstLocalUnmasked); 329 342 CArray<double,2> boundsLatDestUnmasked(nVertexDest,nDstLocalUnmasked); 343 CArray<double,1> areaDstUnmasked(nDstLocalUnmasked); 344 330 345 long int * globalDstUnmasked = new long int [nDstLocalUnmasked]; 331 346 332 347 nDstLocalUnmasked=0 ; 348 bool hasDstArea=domainDest_->hasArea && !domainDest_->radius.isEmpty() && !interpDomain_->use_area.isEmpty() && interpDomain_->use_area==true ; 349 double dstAreaFactor ; 350 if (hasDstArea) dstAreaFactor=1./(domainDest_->radius*domainDest_->radius) ; 333 351 for (int idx=0 ; idx < nDstLocal; idx++) 334 352 { … … 340 358 boundsLatDestUnmasked(n,nDstLocalUnmasked) = boundsLatDest(n,idx) ; 341 359 } 360 if (hasDstArea) areaDstUnmasked(nDstLocalUnmasked) = domainDest_->areavalue(idx)*dstAreaFactor ; 342 361 globalDstUnmasked[nDstLocalUnmasked]=globalDst[idx] ; 343 362 ++nDstLocalUnmasked ; … … 345 364 } 346 365 347 mapper.setSourceMesh(boundsLonSrcUnmasked.dataFirst(), boundsLatSrcUnmasked.dataFirst(), nVertexSrc, nSrcLocalUnmasked, &srcPole[0], globalSrcUnmasked); 348 mapper.setTargetMesh(boundsLonDestUnmasked.dataFirst(), boundsLatDestUnmasked.dataFirst(), nVertexDest, nDstLocalUnmasked, &dstPole[0], globalDstUnmasked); 366 double* ptAreaSrcUnmasked = NULL ; 367 if (hasSrcArea) ptAreaSrcUnmasked=areaSrcUnmasked.dataFirst() ; 368 369 double* ptAreaDstUnmasked = NULL ; 370 if (hasDstArea) ptAreaDstUnmasked=areaDstUnmasked.dataFirst() ; 371 372 mapper.setSourceMesh(boundsLonSrcUnmasked.dataFirst(), boundsLatSrcUnmasked.dataFirst(), ptAreaSrcUnmasked, nVertexSrc, nSrcLocalUnmasked, &srcPole[0], globalSrcUnmasked); 373 mapper.setTargetMesh(boundsLonDestUnmasked.dataFirst(), boundsLatDestUnmasked.dataFirst(), ptAreaDstUnmasked, nVertexDest, nDstLocalUnmasked, &dstPole[0], globalDstUnmasked); 349 374 350 375 std::vector<double> timings = mapper.computeWeights(orderInterp,renormalize,quantity); … … 400 425 401 426 } 427 CATCH 402 428 403 429 void CDomainAlgorithmInterpolate::processPole(std::map<int,std::vector<std::pair<int,double> > >& interMapValuePole, 404 430 int nbGlobalPointOnPole) 431 TRY 405 432 { 406 433 CContext* context = CContext::getCurrent(); 407 434 CContextClient* client=context->client; 408 435 409 ep_lib::MPI_Comm poleComme = MPI_COMM_NULL; 436 ep_lib::MPI_Comm poleComme(EP_COMM_NULL); 437 #ifdef _usingMPI 438 MPI_Comm_split(client->intraComm, interMapValuePole.empty() ? MPI_UNDEFINED : 1, 0, &poleComme); 439 #elif _usingEP 410 440 ep_lib::MPI_Comm_split(client->intraComm, interMapValuePole.empty() ? 0 : 1, 0, &poleComme); 411 if (poleComme!=MPI_COMM_NULL) 441 #endif 442 if (EP_COMM_NULL != poleComme) 412 443 { 413 444 int nbClientPole; … … 423 454 std::vector<int> recvCount(nbClientPole,0); 424 455 std::vector<int> displ(nbClientPole,0); 425 ep_lib::MPI_Allgather(&nbWeight,1,MPI_INT,&recvCount[0],1,MPI_INT,poleComme) ; 456 ep_lib::MPI_Allgather(&nbWeight,1,EP_INT,&recvCount[0],1,EP_INT,poleComme) ; 457 426 458 displ[0]=0; 427 459 for(int n=1;n<nbClientPole;++n) displ[n]=displ[n-1]+recvCount[n-1] ; … … 445 477 446 478 // Gather all index and weight for pole 447 ep_lib::MPI_Allgatherv(&sendSourceIndexBuff[0],nbWeight, MPI_INT,&recvSourceIndexBuff[0],&recvCount[0],&displ[0],MPI_INT,poleComme);448 ep_lib::MPI_Allgatherv(&sendSourceWeightBuff[0],nbWeight, MPI_DOUBLE,&recvSourceWeightBuff[0],&recvCount[0],&displ[0],MPI_DOUBLE,poleComme);479 ep_lib::MPI_Allgatherv(&sendSourceIndexBuff[0],nbWeight,EP_INT,&recvSourceIndexBuff[0],&recvCount[0],&displ[0],EP_INT,poleComme); 480 ep_lib::MPI_Allgatherv(&sendSourceWeightBuff[0],nbWeight,EP_DOUBLE,&recvSourceWeightBuff[0],&recvCount[0],&displ[0],EP_DOUBLE,poleComme); 449 481 450 482 std::map<int,double> recvTemp; … … 468 500 469 501 } 502 CATCH 470 503 471 504 /*! … … 473 506 */ 474 507 void CDomainAlgorithmInterpolate::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 508 TRY 475 509 { 476 510 if (readFromFile_) … … 481 515 } 482 516 } 517 CATCH 483 518 484 519 void CDomainAlgorithmInterpolate::writeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 520 TRY 485 521 { 486 522 writeInterpolationInfo(fileToReadWrite_, interpMapValue); 487 523 } 524 CATCH 488 525 489 526 void CDomainAlgorithmInterpolate::readRemapInfo() 527 TRY 490 528 { 491 529 std::map<int,std::vector<std::pair<int,double> > > interpMapValue; … … 494 532 exchangeRemapInfo(interpMapValue); 495 533 } 534 CATCH 496 535 497 536 void CDomainAlgorithmInterpolate::convertRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 537 TRY 498 538 { 499 539 CContext* context = CContext::getCurrent(); … … 520 560 } 521 561 } 562 CATCH 522 563 523 564 /*! … … 525 566 */ 526 567 void CDomainAlgorithmInterpolate::exchangeRemapInfo(std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 568 TRY 527 569 { 528 570 CContext* context = CContext::getCurrent(); … … 593 635 594 636 595 ep_lib::MPI_Allreduce(sendBuff, recvBuff, nbClient, MPI_INT, MPI_SUM, client->intraComm);637 ep_lib::MPI_Allreduce(sendBuff, recvBuff, nbClient, EP_INT, EP_SUM, client->intraComm); 596 638 597 639 int* sendIndexDestBuff = new int [sendBuffSize]; … … 599 641 double* sendWeightBuff = new double [sendBuffSize]; 600 642 601 std::vector<ep_lib::MPI_Request> sendRequest (3*globalIndexInterpSendToClient.size());643 std::vector<ep_lib::MPI_Request> sendRequest; 602 644 603 645 int sendOffSet = 0, l = 0; 604 int position = 0;605 646 for (itMap = itbMap; itMap != iteMap; ++itMap) 606 647 { … … 621 662 } 622 663 664 sendRequest.push_back(ep_lib::MPI_Request()); 623 665 ep_lib::MPI_Isend(sendIndexDestBuff + sendOffSet, 624 666 k, 625 MPI_INT,667 EP_INT, 626 668 itMap->first, 627 669 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 628 670 client->intraComm, 629 &sendRequest[position++]); 671 &sendRequest.back()); 672 sendRequest.push_back(ep_lib::MPI_Request()); 630 673 ep_lib::MPI_Isend(sendIndexSrcBuff + sendOffSet, 631 674 k, 632 MPI_INT,675 EP_INT, 633 676 itMap->first, 634 677 MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 635 678 client->intraComm, 636 &sendRequest[position++]); 679 &sendRequest.back()); 680 sendRequest.push_back(ep_lib::MPI_Request()); 637 681 ep_lib::MPI_Isend(sendWeightBuff + sendOffSet, 638 682 k, 639 MPI_DOUBLE,683 EP_DOUBLE, 640 684 itMap->first, 641 685 MPI_DOMAIN_INTERPOLATION_WEIGHT, 642 686 client->intraComm, 643 &sendRequest [position++]);687 &sendRequest.back()); 644 688 sendOffSet += k; 645 689 } … … 654 698 { 655 699 ep_lib::MPI_Status recvStatus; 700 #ifdef _usingMPI 701 MPI_Recv((recvIndexDestBuff + receivedSize), 702 recvBuffSize, 703 EP_INT, 704 MPI_ANY_SOURCE, 705 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 706 client->intraComm, 707 &recvStatus); 708 #elif _usingEP 656 709 ep_lib::MPI_Recv((recvIndexDestBuff + receivedSize), 657 710 recvBuffSize, 658 MPI_INT,711 EP_INT, 659 712 -2, 660 713 MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 661 714 client->intraComm, 662 715 &recvStatus); 716 #endif 663 717 664 718 int countBuff = 0; 665 ep_lib::MPI_Get_count(&recvStatus, MPI_INT, &countBuff);719 ep_lib::MPI_Get_count(&recvStatus, EP_INT, &countBuff); 666 720 #ifdef _usingMPI 667 721 clientSrcRank = recvStatus.MPI_SOURCE; … … 672 726 ep_lib::MPI_Recv((recvIndexSrcBuff + receivedSize), 673 727 recvBuffSize, 674 MPI_INT,728 EP_INT, 675 729 clientSrcRank, 676 730 MPI_DOMAIN_INTERPOLATION_SRC_INDEX, … … 680 734 ep_lib::MPI_Recv((recvWeightBuff + receivedSize), 681 735 recvBuffSize, 682 MPI_DOUBLE,736 EP_DOUBLE, 683 737 clientSrcRank, 684 738 MPI_DOMAIN_INTERPOLATION_WEIGHT, … … 695 749 696 750 std::vector<ep_lib::MPI_Status> requestStatus(sendRequest.size()); 697 ep_lib::MPI_Waitall(sendRequest.size(), &sendRequest[0], &requestStatus[0]); 751 #ifdef _usingMPI 752 MPI_Waitall(sendRequest.size(), &sendRequest[0], MPI_STATUS_IGNORE); 753 #elif _usingEP 754 std::vector<ep_lib::MPI_Status> waitstat(sendRequest.size()); 755 ep_lib::MPI_Waitall(sendRequest.size(), &sendRequest[0], &waitstat[0]); 756 #endif 698 757 699 758 delete [] sendIndexDestBuff; … … 706 765 delete [] recvBuff; 707 766 } 767 CATCH 708 768 709 769 /*! Redefined some functions of CONetCDF4 to make use of them */ 710 770 CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm) 711 771 : CNc4DataOutput(NULL, filename, false, false, true, comm, false, true) {} 712 713 CDomainAlgorithmInterpolate::WriteNetCdf::WriteNetCdf(const StdString& filename, bool exist, const ep_lib::MPI_Comm comm)714 : CNc4DataOutput(NULL, filename, exist, false, true, comm, false, true) {}715 716 772 int CDomainAlgorithmInterpolate::WriteNetCdf::addDimensionWrite(const StdString& name, 717 773 const StdSize size) 774 TRY 718 775 { 719 776 return CONetCDF4::addDimension(name, size); 720 777 } 778 CATCH 721 779 722 780 int CDomainAlgorithmInterpolate::WriteNetCdf::addVariableWrite(const StdString& name, nc_type type, 723 781 const std::vector<StdString>& dim) 782 TRY 724 783 { 725 784 return CONetCDF4::addVariable(name, type, dim); 726 785 } 786 CATCH 727 787 728 788 void CDomainAlgorithmInterpolate::WriteNetCdf::endDefinition() 789 TRY 729 790 { 730 791 CONetCDF4::definition_end(); 731 792 } 793 CATCH 732 794 733 795 void CDomainAlgorithmInterpolate::WriteNetCdf::writeDataIndex(const CArray<int,1>& data, const StdString& name, … … 735 797 const std::vector<StdSize>* start, 736 798 const std::vector<StdSize>* count) 799 TRY 737 800 { 738 801 CONetCDF4::writeData<int,1>(data, name, collective, record, start, count); 739 802 } 803 CATCH 740 804 741 805 void CDomainAlgorithmInterpolate::WriteNetCdf::writeDataIndex(const CArray<double,1>& data, const StdString& name, … … 743 807 const std::vector<StdSize>* start, 744 808 const std::vector<StdSize>* count) 809 TRY 745 810 { 746 811 CONetCDF4::writeData<double,1>(data, name, collective, record, start, count); 747 812 } 813 CATCH 748 814 749 815 /* … … 754 820 void CDomainAlgorithmInterpolate::writeInterpolationInfo(std::string& filename, 755 821 std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 822 TRY 756 823 { 757 824 CContext* context = CContext::getCurrent(); … … 791 858 } 792 859 793 ep_lib::MPI_Allreduce(&localNbWeight, &globalNbWeight, 1, MPI_LONG, MPI_SUM, client->intraComm);794 ep_lib::MPI_Scan(&localNbWeight, &startIndex, 1, MPI_LONG, MPI_SUM, client->intraComm);860 ep_lib::MPI_Allreduce(&localNbWeight, &globalNbWeight, 1, EP_LONG, EP_SUM, client->intraComm); 861 ep_lib::MPI_Scan(&localNbWeight, &startIndex, 1, EP_LONG, EP_SUM, client->intraComm); 795 862 796 863 if (0 == globalNbWeight) … … 806 873 std::vector<StdSize> count(1, localNbWeight); 807 874 808 int my_rank_loc = client->intraComm->ep_comm_ptr->size_rank_info[1].first; 809 int my_rank = client->intraComm->ep_comm_ptr->size_rank_info[0].first; 875 WriteNetCdf netCdfWriter(filename, client->intraComm); 876 877 // Define some dimensions 878 netCdfWriter.addDimensionWrite("n_src", n_src); 879 netCdfWriter.addDimensionWrite("n_dst", n_dst); 880 netCdfWriter.addDimensionWrite("n_weight", globalNbWeight); 810 881 811 812 813 WriteNetCdf *netCdfWriter; 814 815 MPI_Barrier_local(client->intraComm); 816 817 if(my_rank_loc==0) 818 { 819 info(100)<<"rank "<< my_rank <<" create weight info file"<< std::endl; 820 821 WriteNetCdf my_writer(filename, client->intraComm); 822 info(100)<<"rank "<< my_rank <<" file created"<< std::endl; 823 netCdfWriter = &my_writer; 824 825 // Define some dimensions 826 netCdfWriter->addDimensionWrite("n_src", n_src); 827 netCdfWriter->addDimensionWrite("n_dst", n_dst); 828 netCdfWriter->addDimensionWrite("n_weight", globalNbWeight); 829 info(100)<<"rank "<< my_rank <<" addDimensionWrite : n_src, n_dst, n_weight"<< std::endl; 830 831 std::vector<StdString> dims(1,"n_weight"); 832 833 // Add some variables 834 netCdfWriter->addVariableWrite("src_idx", NC_INT, dims); 835 netCdfWriter->addVariableWrite("dst_idx", NC_INT, dims); 836 netCdfWriter->addVariableWrite("weight", NC_DOUBLE, dims); 837 838 info(100)<<"rank "<< my_rank <<" addVariableWrite : src_idx, dst_idx, weight"<< std::endl; 839 840 // End of definition 841 netCdfWriter->endDefinition(); 842 info(100)<<"rank "<< my_rank <<" endDefinition"<< std::endl; 843 844 netCdfWriter->closeFile(); 845 info(100)<<"rank "<< my_rank <<" file closed"<< std::endl; 846 } 847 848 MPI_Barrier_local(client->intraComm); 849 850 #pragma omp critical (write_weight_data) 851 { 852 // open file 853 info(100)<<"rank "<< my_rank <<" writing in weight info file"<< std::endl; 854 855 WriteNetCdf my_writer(filename, true, client->intraComm); 856 info(100)<<"rank "<< my_rank <<" file opened"<< std::endl; 857 netCdfWriter = &my_writer; 858 859 // // Write variables 860 if (0 != localNbWeight) 861 { 862 netCdfWriter->writeDataIndex(src_idx, "src_idx", false, 0, &start, &count); 863 netCdfWriter->writeDataIndex(dst_idx, "dst_idx", false, 0, &start, &count); 864 netCdfWriter->writeDataIndex(weights, "weight", false, 0, &start, &count); 865 866 info(100)<<"rank "<< my_rank <<" WriteDataIndex : src_idx, dst_idx, weight"<< std::endl; 867 } 868 869 netCdfWriter->closeFile(); 870 info(100)<<"rank "<< my_rank <<" file closed"<< std::endl; 871 872 } 873 874 MPI_Barrier_local(client->intraComm); 875 876 877 } 882 std::vector<StdString> dims(1,"n_weight"); 883 884 // Add some variables 885 netCdfWriter.addVariableWrite("src_idx", NC_INT, dims); 886 netCdfWriter.addVariableWrite("dst_idx", NC_INT, dims); 887 netCdfWriter.addVariableWrite("weight", NC_DOUBLE, dims); 888 889 // End of definition 890 netCdfWriter.endDefinition(); 891 892 // // Write variables 893 if (0 != localNbWeight) 894 { 895 netCdfWriter.writeDataIndex(src_idx, "src_idx", false, 0, &start, &count); 896 netCdfWriter.writeDataIndex(dst_idx, "dst_idx", false, 0, &start, &count); 897 netCdfWriter.writeDataIndex(weights, "weight", false, 0, &start, &count); 898 } 899 900 netCdfWriter.closeFile(); 901 } 902 CATCH 878 903 879 904 /*! … … 885 910 void CDomainAlgorithmInterpolate::readInterpolationInfo(std::string& filename, 886 911 std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 912 TRY 887 913 { 888 914 int ncid ; … … 904 930 } 905 931 906 #pragma omp critical (read_weight_data) 907 { 908 nc_open(filename.c_str(),NC_NOWRITE, &ncid) ; 909 nc_inq_dimid(ncid,"n_weight",&weightDimId) ; 910 nc_inq_dimlen(ncid,weightDimId,&nbWeightGlo) ; 911 912 size_t nbWeight ; 913 size_t start ; 914 size_t div = nbWeightGlo/clientSize ; 915 size_t mod = nbWeightGlo%clientSize ; 916 if (clientRank < mod) 917 { 918 nbWeight=div+1 ; 919 start=clientRank*(div+1) ; 920 } 921 else 922 { 923 nbWeight=div ; 924 start= mod * (div+1) + (clientRank-mod) * div ; 925 } 926 927 double* weight=new double[nbWeight] ; 928 int weightId ; 929 nc_inq_varid (ncid, "weight", &weightId) ; 930 nc_get_vara_double(ncid, weightId, &start, &nbWeight, weight) ; 931 932 long* srcIndex=new long[nbWeight] ; 933 int srcIndexId ; 934 nc_inq_varid (ncid, "src_idx", &srcIndexId) ; 935 nc_get_vara_long(ncid, srcIndexId, &start, &nbWeight, srcIndex) ; 936 937 long* dstIndex=new long[nbWeight] ; 938 int dstIndexId ; 939 nc_inq_varid (ncid, "dst_idx", &dstIndexId) ; 940 nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 941 942 int indexOffset=0 ; 943 if (fortranConvention) indexOffset=1 ; 944 for(size_t ind=0; ind<nbWeight;++ind) 945 interpMapValue[dstIndex[ind]-indexOffset].push_back(make_pair(srcIndex[ind]-indexOffset,weight[ind])); 946 } 947 } 932 nc_open(filename.c_str(),NC_NOWRITE, &ncid) ; 933 nc_inq_dimid(ncid,"n_weight",&weightDimId) ; 934 nc_inq_dimlen(ncid,weightDimId,&nbWeightGlo) ; 935 936 size_t nbWeight ; 937 size_t start ; 938 size_t div = nbWeightGlo/clientSize ; 939 size_t mod = nbWeightGlo%clientSize ; 940 if (clientRank < mod) 941 { 942 nbWeight=div+1 ; 943 start=clientRank*(div+1) ; 944 } 945 else 946 { 947 nbWeight=div ; 948 start= mod * (div+1) + (clientRank-mod) * div ; 949 } 950 951 double* weight=new double[nbWeight] ; 952 int weightId ; 953 nc_inq_varid (ncid, "weight", &weightId) ; 954 nc_get_vara_double(ncid, weightId, &start, &nbWeight, weight) ; 955 956 long* srcIndex=new long[nbWeight] ; 957 int srcIndexId ; 958 nc_inq_varid (ncid, "src_idx", &srcIndexId) ; 959 nc_get_vara_long(ncid, srcIndexId, &start, &nbWeight, srcIndex) ; 960 961 long* dstIndex=new long[nbWeight] ; 962 int dstIndexId ; 963 nc_inq_varid (ncid, "dst_idx", &dstIndexId) ; 964 nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 965 966 int indexOffset=0 ; 967 if (fortranConvention) indexOffset=1 ; 968 for(size_t ind=0; ind<nbWeight;++ind) 969 interpMapValue[dstIndex[ind]-indexOffset].push_back(make_pair(srcIndex[ind]-indexOffset,weight[ind])); 970 } 971 CATCH 948 972 949 973 void CDomainAlgorithmInterpolate::apply(const std::vector<std::pair<int,double> >& localIndex, … … 952 976 std::vector<bool>& flagInitial, 953 977 bool ignoreMissingValue, bool firstPass ) 978 TRY 954 979 { 955 980 int nbLocalIndex = localIndex.size(); … … 993 1018 } 994 1019 } 1020 CATCH 995 1021 996 1022 void CDomainAlgorithmInterpolate::updateData(CArray<double,1>& dataOut) 1023 TRY 997 1024 { 998 1025 if (detectMissingValue) … … 1001 1028 size_t nbIndex=dataOut.numElements() ; 1002 1029 1003 for (int idx = 0; idx < nbIndex; ++idx) 1004 { 1005 if (allMissing(idx)) dataOut(idx) = defaultValue; // If all data source are nan then data destination must be nan 1030 if (allMissing.numElements()>0) 1031 { 1032 for (int idx = 0; idx < nbIndex; ++idx) 1033 { 1034 if (allMissing(idx)) dataOut(idx) = defaultValue; // If all data source are nan then data destination must be nan 1035 } 1006 1036 } 1007 1037 … … 1013 1043 } 1014 1044 } 1015 1016 } 1045 CATCH 1046 1047 } -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.hpp
r1540 r1642 9 9 #ifndef __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 10 10 #define __XIOS_DOMAIN_ALGORITHM_INTERPOLATE_HPP__ 11 #include "mpi_std.hpp" 11 12 12 #include "domain_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" … … 71 71 public: 72 72 WriteNetCdf(const StdString& filename, const ep_lib::MPI_Comm comm); 73 WriteNetCdf(const StdString& filename, bool exist, const ep_lib::MPI_Comm comm);74 73 int addDimensionWrite(const StdString& name, const StdSize size = UNLIMITED_DIM); 75 74 int addVariableWrite(const StdString& name, nc_type type, -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_reorder.cpp
r1460 r1642 19 19 std::map<int, int>& elementPositionInGridDst2AxisPosition, 20 20 std::map<int, int>& elementPositionInGridDst2DomainPosition) 21 TRY 21 22 { 22 23 std::vector<CDomain*> domainListDestP = gridDst->getDomains(); … … 29 30 return (new CDomainAlgorithmReorder(domainListDestP[domainDstIndex], domainListSrcP[domainSrcIndex], reorderDomain)); 30 31 } 32 CATCH 31 33 32 34 bool CDomainAlgorithmReorder::registerTrans() 35 TRY 33 36 { 34 37 CGridTransformationFactory<CDomain>::registerTransformation(TRANS_REORDER_DOMAIN, create); 35 38 } 39 CATCH 36 40 37 41 CDomainAlgorithmReorder::CDomainAlgorithmReorder(CDomain* domainDestination, CDomain* domainSource, CReorderDomain* reorderDomain) 38 42 : CDomainAlgorithmTransformation(domainDestination, domainSource) 43 TRY 39 44 { 40 45 reorderDomain->checkValid(domainSource); … … 109 114 } 110 115 } 111 112 113 116 } 117 CATCH 114 118 115 119 /*! -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_transformation.cpp
r1460 r1642 36 36 int elementType, 37 37 CClientClientDHTInt::Index2VectorInfoTypeMap& globalDomainIndexOnProc) 38 TRY 38 39 { 39 40 CContext* context = CContext::getCurrent(); … … 65 66 globalDomainIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); 66 67 } 68 CATCH 67 69 68 70 } -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_zoom.cpp
r1460 r1642 1 /*!2 \file domain_algorithm_zoom.cpp3 \author Ha NGUYEN4 \since 02 Jul 20155 \date 02 Jul 20156 7 \brief Algorithm for zooming on an domain.8 */9 1 #include "domain_algorithm_zoom.hpp" 10 2 #include "zoom_domain.hpp" … … 12 4 #include "grid.hpp" 13 5 #include "grid_transformation_factory_impl.hpp" 6 #include "attribute_template.hpp" 14 7 15 8 namespace xios { … … 23 16 std::map<int, int>& elementPositionInGridDst2AxisPosition, 24 17 std::map<int, int>& elementPositionInGridDst2DomainPosition) 18 TRY 25 19 { 26 20 std::vector<CDomain*> domainListDestP = gridDst->getDomains(); … … 33 27 return (new CDomainAlgorithmZoom(domainListDestP[domainDstIndex], domainListSrcP[domainSrcIndex], zoomDomain)); 34 28 } 29 CATCH 35 30 36 31 bool CDomainAlgorithmZoom::registerTrans() 32 TRY 37 33 { 38 34 CGridTransformationFactory<CDomain>::registerTransformation(TRANS_ZOOM_DOMAIN, create); 39 35 } 36 CATCH 40 37 41 38 CDomainAlgorithmZoom::CDomainAlgorithmZoom(CDomain* domainDestination, CDomain* domainSource, CZoomDomain* zoomDomain) 42 39 : CDomainAlgorithmTransformation(domainDestination, domainSource) 40 TRY 43 41 { 44 42 zoomDomain->checkValid(domainSource); … … 67 65 << "Zoom size is " << zoomNj_ ); 68 66 } 69 } 67 68 // Calculate the size of local domain 69 int ind, indLocSrc, indLocDest, iIdxSrc, jIdxSrc, destIBegin = -1, destJBegin = -1, niDest = 0, njDest = 0, ibeginDest, jbeginDest ; 70 int indGloDest, indGloSrc, niGloSrc = domainSrc_->ni_glo, iSrc, jSrc, nvertex = 0; 71 for (int j = 0; j < domainSrc_->nj.getValue(); j++) 72 { 73 for (int i = 0; i < domainSrc_->ni.getValue(); i++) 74 { 75 ind = j*domainSrc_->ni + i; 76 iIdxSrc = domainSrc_->i_index(ind); 77 if ((iIdxSrc >= zoomIBegin_) && (iIdxSrc <= zoomIEnd_)) 78 { 79 jIdxSrc = domainSrc_->j_index(ind); 80 if ((jIdxSrc >= zoomJBegin_) && (jIdxSrc <= zoomJEnd_)) 81 { 82 if ((niDest == 0) && (njDest == 0)) 83 { 84 destIBegin = i; 85 destJBegin = j; 86 } 87 if (i == destIBegin) ++njDest; 88 } 89 if (j == destJBegin) ++niDest; 90 91 } 92 } 93 } 94 ibeginDest = destIBegin + domainSrc_->ibegin - zoomIBegin_; 95 jbeginDest = destJBegin + domainSrc_->jbegin - zoomJBegin_; 96 domainDest_->ni_glo.setValue(zoomNi_); 97 domainDest_->nj_glo.setValue(zoomNj_); 98 domainDest_->ni.setValue(niDest); 99 domainDest_->nj.setValue(njDest); 100 if ( (niDest==0) || (njDest==0)) 101 { 102 domainDest_->ibegin.setValue(0); 103 domainDest_->jbegin.setValue(0); 104 } 105 else 106 { 107 domainDest_->ibegin.setValue(ibeginDest); 108 domainDest_->jbegin.setValue(jbeginDest); 109 } 110 domainDest_->i_index.resize(niDest*njDest); 111 domainDest_->j_index.resize(niDest*njDest); 112 113 domainDest_->data_ni.setValue(niDest); 114 domainDest_->data_nj.setValue(njDest); 115 domainDest_->data_ibegin.setValue(0); 116 domainDest_->data_jbegin.setValue(0); 117 domainDest_->data_i_index.resize(niDest*njDest); 118 domainDest_->data_j_index.resize(niDest*njDest); 119 120 domainDest_->domainMask.resize(niDest*njDest); 121 122 if (!domainSrc_->lonvalue_1d.isEmpty()) 123 { 124 if (domainDest_->type == CDomain::type_attr::rectilinear) 125 { 126 domainDest_->lonvalue_1d.resize(niDest); 127 domainDest_->latvalue_1d.resize(njDest); 128 } 129 else if (domainDest_->type == CDomain::type_attr::unstructured) 130 { 131 domainDest_->lonvalue_1d.resize(niDest); 132 domainDest_->latvalue_1d.resize(niDest); 133 } 134 else if (domainDest_->type == CDomain::type_attr::curvilinear) 135 { 136 domainDest_->lonvalue_1d.resize(niDest*njDest); 137 domainDest_->latvalue_1d.resize(niDest*njDest); 138 } 139 } 140 else if (!domainSrc_->lonvalue_2d.isEmpty()) 141 { 142 domainDest_->lonvalue_2d.resize(niDest,njDest); 143 domainDest_->latvalue_2d.resize(niDest,njDest); 144 } 145 146 if (domainSrc_->hasBounds) 147 { 148 nvertex = domainSrc_->nvertex; 149 domainDest_->nvertex.setValue(nvertex); 150 if (!domainSrc_->bounds_lon_1d.isEmpty()) 151 { 152 if (domainDest_->type == CDomain::type_attr::rectilinear) 153 { 154 domainDest_->bounds_lon_1d.resize(nvertex, niDest); 155 domainDest_->bounds_lat_1d.resize(nvertex, njDest); 156 } 157 else if (domainDest_->type == CDomain::type_attr::unstructured) 158 { 159 domainDest_->bounds_lon_1d.resize(nvertex, niDest); 160 domainDest_->bounds_lat_1d.resize(nvertex, niDest); 161 } 162 else if (domainDest_->type == CDomain::type_attr::curvilinear) 163 { 164 domainDest_->bounds_lon_1d.resize(nvertex, niDest*njDest); 165 domainDest_->bounds_lat_1d.resize(nvertex, niDest*njDest); 166 } 167 } 168 else if (!domainSrc_->bounds_lon_2d.isEmpty()) 169 { 170 domainDest_->bounds_lon_2d.resize(nvertex, niDest, njDest); 171 domainDest_->bounds_lat_2d.resize(nvertex, niDest, njDest); 172 } 173 } 174 if (domainSrc_->hasArea) domainDest_->area.resize(niDest,njDest); 175 176 this->transformationMapping_.resize(1); 177 this->transformationWeight_.resize(1); 178 TransformationIndexMap& transMap = this->transformationMapping_[0]; 179 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 180 181 for (int iDest = 0; iDest < niDest; iDest++) 182 { 183 iSrc = iDest + destIBegin; 184 for (int jDest = 0; jDest < njDest; jDest++) 185 { 186 jSrc = jDest + destJBegin; 187 ind = jSrc * domainSrc_->ni + iSrc; 188 iIdxSrc = domainSrc_->i_index(ind); 189 jIdxSrc = domainSrc_->j_index(ind); 190 indLocDest = jDest*niDest + iDest; 191 indGloDest = (jDest + jbeginDest)*zoomNi_ + (iDest + ibeginDest); 192 indLocSrc = (jDest+destJBegin)*domainSrc_->ni + (iDest+destIBegin); 193 indGloSrc = (jIdxSrc )* niGloSrc + iIdxSrc; 194 domainDest_->i_index(indLocDest) = iDest + ibeginDest; // i_index contains global positions 195 domainDest_->j_index(indLocDest) = jDest + jbeginDest; // i_index contains global positions 196 domainDest_->data_i_index(indLocDest) = (domainSrc_->data_dim == 1) ? indLocDest : iDest; // data_i_index contains local positions 197 domainDest_->data_j_index(indLocDest) = (domainSrc_->data_dim == 1) ? 0 :jDest; // data_i_index contains local positions 198 domainDest_->domainMask(indLocDest) = domainSrc_->domainMask(indLocSrc); 199 200 if (domainSrc_->hasArea) 201 domainDest_->area(iDest,jDest) = domainSrc_->area(iSrc,jSrc); 202 203 if (domainSrc_->hasLonLat) 204 { 205 if (!domainSrc_->latvalue_1d.isEmpty()) 206 { 207 if (domainDest_->type == CDomain::type_attr::rectilinear) 208 { 209 domainDest_->latvalue_1d(jDest) = domainSrc_->latvalue_1d(jSrc); 210 } 211 else 212 { 213 domainDest_->lonvalue_1d(indLocDest) = domainSrc_->lonvalue_1d(ind); 214 domainDest_->latvalue_1d(indLocDest) = domainSrc_->latvalue_1d(ind); 215 } 216 } 217 else if (!domainSrc_->latvalue_2d.isEmpty()) 218 { 219 domainDest_->lonvalue_2d(iDest,jDest) = domainSrc_->lonvalue_2d(iSrc,jSrc); 220 domainDest_->latvalue_2d(iDest,jDest) = domainSrc_->latvalue_2d(iSrc,jSrc); 221 } 222 } 223 224 if (domainSrc_->hasBounds) 225 { 226 if (!domainSrc_->bounds_lon_1d.isEmpty()) 227 { 228 if (domainDest_->type == CDomain::type_attr::rectilinear) 229 { 230 for (int n = 0; n < nvertex; ++n) 231 domainDest_->bounds_lat_1d(n,jDest) = domainSrc_->bounds_lat_1d(n,jSrc); 232 } 233 else 234 { 235 for (int n = 0; n < nvertex; ++n) 236 { 237 domainDest_->bounds_lon_1d(n,indLocDest) = domainSrc_->bounds_lon_1d(n,ind); 238 domainDest_->bounds_lat_1d(n,indLocDest) = domainSrc_->bounds_lat_1d(n,ind); 239 } 240 } 241 } 242 else if (!domainSrc_->bounds_lon_2d.isEmpty()) 243 { 244 for (int n = 0; n < nvertex; ++n) 245 { 246 domainDest_->bounds_lon_2d(n,iDest,jDest) = domainSrc_->bounds_lon_2d(n,iSrc,jSrc); 247 domainDest_->bounds_lat_2d(n,iDest,jDest) = domainSrc_->bounds_lat_2d(n,iSrc,jSrc); 248 } 249 } 250 251 } 252 253 transMap[indGloDest].push_back(indGloSrc); 254 transWeight[indGloDest].push_back(1.0); 255 } 256 257 if (domainSrc_->hasLonLat && !domainSrc_->latvalue_1d.isEmpty()) 258 { 259 if (domainDest_->type == CDomain::type_attr::rectilinear) 260 { 261 domainDest_->lonvalue_1d(iDest) = domainSrc_->lonvalue_1d(iSrc); 262 } 263 } 264 265 if (domainSrc_->hasBounds && !domainSrc_->bounds_lon_1d.isEmpty()) 266 { 267 if (domainDest_->type == CDomain::type_attr::rectilinear) 268 { 269 for (int n = 0; n < nvertex; ++n) 270 domainDest_->bounds_lon_1d(n,iDest) = domainSrc_->bounds_lon_1d(n,iSrc); 271 } 272 } 273 } 274 domainDest_->computeLocalMask(); 275 } 276 CATCH 70 277 71 278 /*! … … 74 281 void CDomainAlgorithmZoom::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 75 282 { 76 77 int niGlob = domainSrc_->ni_glo.getValue(); 78 int njGlob = domainSrc_->nj_glo.getValue(); 79 80 this->transformationMapping_.resize(1); 81 this->transformationWeight_.resize(1); 82 83 TransformationIndexMap& transMap = this->transformationMapping_[0]; 84 TransformationWeightMap& transWeight = this->transformationWeight_[0]; 85 86 int domainGlobalIndex; 87 int iglob ; 88 int jglob ; 89 const CArray<int,1>& i_index = domainSrc_->i_index.getValue() ; 90 const CArray<int,1>& j_index = domainSrc_->j_index.getValue() ; 91 92 int nglo = i_index.numElements() ; 93 for (size_t i = 0; i < nglo ; ++i) 94 { 95 iglob=i_index(i) ; jglob=j_index(i) ; 96 if (iglob>=zoomIBegin_ && iglob<=zoomIEnd_ && jglob>=zoomJBegin_ && jglob<=zoomJEnd_) 97 { 98 domainGlobalIndex = jglob*niGlob + iglob; 99 transMap[domainGlobalIndex].push_back(domainGlobalIndex); 100 transWeight[domainGlobalIndex].push_back(1.0); 101 } 102 } 103 updateZoom(); 104 } 105 106 /*! 107 After a zoom on domain, it should be certain that (global) zoom begin and (global) zoom size are updated 108 */ 109 void CDomainAlgorithmZoom::updateZoom() 110 { 111 domainDest_->global_zoom_ibegin = zoomIBegin_; 112 domainDest_->global_zoom_jbegin = zoomJBegin_; 113 domainDest_->global_zoom_ni = zoomNi_; 114 domainDest_->global_zoom_nj = zoomNj_; 115 } 116 117 /*! 118 Update mask on domain 119 Because only zoomed region on domain is not masked, the remaining must be masked to make sure 120 correct index be extracted 121 */ 122 // void CDomainAlgorithmZoom::updateDomainDestinationMask() 123 // { 124 // int niMask = domainDest_->ni.getValue(); 125 // int iBeginMask = domainDest_->ibegin.getValue(); 126 // int njMask = domainDest_->nj.getValue(); 127 // int jBeginMask = domainDest_->jbegin.getValue(); 128 // int niGlob = domainDest_->ni_glo.getValue(); 129 // int globalIndexMask = 0; 130 131 // TransformationIndexMap& transMap = this->transformationMapping_[0]; 132 // TransformationIndexMap::const_iterator ite = (transMap).end(); 133 // for (int j = 0; j < njMask; ++j) 134 // { 135 // for (int i = 0; i < niMask; ++i) 136 // { 137 // globalIndexMask = (j+jBeginMask) * niGlob + (i + iBeginMask); 138 // if (transMap.find(globalIndexMask) == ite) 139 // (domainDest_->mask_1d)(i+j*niMask) = false; 140 // } 141 // } 142 // } 143 144 } 283 } 284 285 286 } -
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_zoom.hpp
r1460 r1642 1 /*!2 \file domain_algorithm_zoom.hpp3 \author Ha NGUYEN4 \since 03 June 20155 \date 12 June 20156 1 7 \brief Algorithm for zooming on an domain.8 */9 2 #ifndef __XIOS_DOMAIN_ALGORITHM_ZOOM_HPP__ 10 3 #define __XIOS_DOMAIN_ALGORITHM_ZOOM_HPP__ … … 20 13 /*! 21 14 \class CDomainAlgorithmZoom 22 Implementing zoom on domain 23 A zoomed region can be considered as region that isnt masked. 24 Only this zoomed region is extracted to write on Netcdf. 15 Implementing zoom (alternative zoom) on domain 25 16 */ 26 17 class CDomainAlgorithmZoom : public CDomainAlgorithmTransformation … … 33 24 static bool registerTrans(); 34 25 protected: 26 void updateDomainAttributes(); 35 27 void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs); 36 28 37 29 private: 38 // void updateDomainDestinationMask();39 30 void updateZoom(); 40 31 -
XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.cpp
r1545 r1642 34 34 std::vector<bool>& flagInitial, 35 35 bool ignoreMissingValue, bool firstPass ) 36 TRY 36 37 { 37 38 int nbLocalIndex = localIndex.size(); 38 39 double defaultValue = std::numeric_limits<double>::quiet_NaN(); 39 40 40 41 if (ignoreMissingValue) 41 42 { 42 43 if (firstPass) dataOut=defaultValue ; 43 44 44 45 for (int idx = 0; idx < nbLocalIndex; ++idx) 45 46 { … … 61 62 } 62 63 } 64 CATCH 63 65 64 66 void CGenericAlgorithmTransformation::computePositionElements(CGrid* dst, CGrid* src) 67 TRY 65 68 { 66 69 int idxScalar = 0, idxAxis = 0, idxDomain = 0; … … 108 111 } 109 112 } 113 CATCH 110 114 111 115 bool CGenericAlgorithmTransformation::isDistributedTransformation(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst) 116 TRY 112 117 { 113 118 … … 131 136 { 132 137 distributed=domainListSrcP[elementPositionInGridSrc2DomainPosition_[elementPositionInGrid]]->isDistributed() ; 133 ep_lib::MPI_Allreduce(&distributed,&distributed_glo, 1, MPI_INT, MPI_LOR, client->intraComm) ;138 ep_lib::MPI_Allreduce(&distributed,&distributed_glo, 1, EP_INT, EP_LOR, client->intraComm) ; 134 139 135 140 } … … 137 142 { 138 143 distributed=axisListSrcP[elementPositionInGridSrc2AxisPosition_[elementPositionInGrid]]->isDistributed() ; 139 ep_lib::MPI_Allreduce(&distributed,&distributed_glo, 1, MPI_INT, MPI_LOR, client->intraComm) ;144 ep_lib::MPI_Allreduce(&distributed,&distributed_glo, 1, EP_INT, EP_LOR, client->intraComm) ; 140 145 } 141 146 else //it's a scalar … … 147 152 } 148 153 return isDistributed_ ; 149 } 154 } 155 CATCH 156 150 157 /*! 151 158 This function computes the global indexes of grid source, which the grid destination is in demand. … … 160 167 CGrid* gridDst, 161 168 SourceDestinationIndexMap& globaIndexWeightFromSrcToDst) 169 TRY 162 170 { 163 171 CContext* context = CContext::getCurrent(); … … 230 238 int sendValue = (computeGlobalIndexOnProc) ? 1 : 0; 231 239 int recvValue = 0; 232 ep_lib::MPI_Allreduce(&sendValue, &recvValue, 1, MPI_INT, MPI_SUM, client->intraComm);240 ep_lib::MPI_Allreduce(&sendValue, &recvValue, 1, EP_INT, EP_SUM, client->intraComm); 233 241 computeGlobalIndexOnProc = (0 < recvValue); 234 242 … … 443 451 } 444 452 } 453 CATCH 445 454 446 455 /*! … … 461 470 std::vector<std::unordered_map<int,std::vector<size_t> > >& globalElementIndexOnProc, 462 471 SourceDestinationIndexMap& globaIndexWeightFromSrcToDst) 472 TRY 463 473 { 464 474 SourceDestinationIndexMap globaIndexWeightFromSrcToDst_tmp ; … … 640 650 } 641 651 } 642 643 } 652 } 653 CATCH 644 654 645 655 /*! … … 654 664 CArray<size_t,1>& destGlobalIndexPositionInGrid, 655 665 std::unordered_map<int,std::vector<size_t> >& globalScalarIndexOnProc) 666 TRY 656 667 { 657 668 CContext* context = CContext::getCurrent(); … … 666 677 } 667 678 } 679 CATCH 668 680 669 681 /*! … … 678 690 CArray<size_t,1>& destGlobalIndexPositionInGrid, 679 691 std::unordered_map<int,std::vector<size_t> >& globalAxisIndexOnProc) 692 TRY 680 693 { 681 694 CContext* context = CContext::getCurrent(); … … 735 748 } 736 749 } 750 CATCH 737 751 738 752 /*! … … 747 761 CArray<size_t,1>& destGlobalIndexPositionInGrid, 748 762 std::unordered_map<int,std::vector<size_t> >& globalDomainIndexOnProc) 763 TRY 749 764 { 750 765 CContext* context = CContext::getCurrent(); … … 838 853 } 839 854 } 840 841 842 843 844 855 CATCH 845 856 846 857 void CGenericAlgorithmTransformation::computeTransformationMappingNonDistributed(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst, 847 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, vector<bool>& localMaskOnGridDest) 858 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, 859 int& nlocalIndexDest) 860 TRY 848 861 { 849 862 … … 871 884 872 885 int nlocalIndexSrc=1 ; 873 int nlocalIndexDest=1 ; 886 // int nlocalIndexDest=1 ; 887 nlocalIndexDest=1 ; 874 888 CArray<bool,1> maskScalar(1) ; 875 889 maskScalar = true ; … … 933 947 nlocalIndexDest=nlocalIndexDest*nIndexDst[i] ; 934 948 } 935 936 937 938 939 940 949 941 950 vector<int> dstLocalInd ; … … 985 994 } 986 995 987 // just get the local src mask988 CArray<bool,1> localMaskOnSrcGrid;989 gridSrc->getLocalMask(localMaskOnSrcGrid) ;990 // intermediate grid, mask is not initialized => set up mask to true991 if (localMaskOnSrcGrid.isEmpty())992 {993 localMaskOnSrcGrid.resize(nlocalIndexSrc) ;994 localMaskOnSrcGrid=true ;995 }996 997 998 localMaskOnGridDest.resize(nlocalIndexDest,false) ;999 1000 996 vector<vector<vector<pair<int,double> > > > dstIndWeight(transformationMapping_.size()) ; 1001 997 … … 1024 1020 1025 1021 nonDistributedrecursiveFunct(nElement-1,true,elementPositionInGrid,maskSrc,maskDst, srcInd, srcIndCompressed, nIndexSrc, t, dstIndWeight, 1026 currentInd,localSrc,localDst,weight , localMaskOnSrcGrid, localMaskOnGridDest);1022 currentInd,localSrc,localDst,weight); 1027 1023 1028 1024 } 1029 1030 1031 void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid, vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 1032 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest ) 1025 CATCH 1026 1027 1028 void CGenericAlgorithmTransformation::nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid, 1029 vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, 1030 int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, 1031 int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 1032 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight) 1033 TRY 1033 1034 { 1034 1035 int masked_ ; … … 1043 1044 masked_=masked ; 1044 1045 if (!mask(i)) masked_=false ; 1045 nonDistributedrecursiveFunct(currentPos-1, masked_, elementPositionInGrid, maskSrc, maskDst, srcInd, srcIndCompressed, nIndexSrc, t, dstIndWeight, currentInd, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 1046 nonDistributedrecursiveFunct(currentPos-1, masked_, elementPositionInGrid, maskSrc, maskDst, srcInd, srcIndCompressed, nIndexSrc, t, 1047 dstIndWeight, currentInd, localSrc, localDst, weight); 1046 1048 } 1047 1049 } … … 1057 1059 for(vector<pair<int,double> >::iterator it = dstIndWeight[t][currentInd].begin(); it!=dstIndWeight[t][currentInd].end(); ++it) 1058 1060 { 1059 if (localMaskOnGridSrc(srcInd)) 1060 { 1061 localSrc.push_back(srcIndCompressed) ; 1062 localDst.push_back(it->first) ; 1063 weight.push_back(it->second) ; 1064 localMaskOnGridDest[it->first]=true ; 1065 } 1061 localSrc.push_back(srcIndCompressed) ; 1062 localDst.push_back(it->first) ; 1063 weight.push_back(it->second) ; 1066 1064 (it->first)++ ; 1067 1065 } 1068 1066 } 1069 1067 if (t < dstIndWeight.size()-1) t++ ; 1070 if (localMaskOnGridSrc(srcInd))srcIndCompressed ++ ;1068 srcIndCompressed ++ ; 1071 1069 } 1072 1070 srcInd++ ; … … 1086 1084 masked_=masked ; 1087 1085 if (!mask(i)) masked_=false ; 1088 nonDistributedrecursiveFunct(currentPos-1, masked_, elementPositionInGrid, maskSrc, maskDst, srcInd, srcIndCompressed, nIndexSrc, t, dstIndWeight , i, localSrc, localDst, weight, localMaskOnGridSrc, localMaskOnGridDest) ; 1086 nonDistributedrecursiveFunct(currentPos-1, masked_, elementPositionInGrid, maskSrc, maskDst, srcInd, 1087 srcIndCompressed, nIndexSrc, t, dstIndWeight , i, localSrc, localDst, weight); 1089 1088 } 1090 1089 } … … 1100 1099 for(vector<pair<int,double> >::iterator it = dstIndWeight[t][i].begin(); it!=dstIndWeight[t][i].end(); ++it) 1101 1100 { 1102 if (localMaskOnGridSrc(srcInd)) 1103 { 1104 localSrc.push_back(srcIndCompressed) ; 1105 localDst.push_back(it->first) ; 1106 weight.push_back(it->second) ; 1107 localMaskOnGridDest[it->first]=true ; 1108 } 1101 localSrc.push_back(srcIndCompressed) ; 1102 localDst.push_back(it->first) ; 1103 weight.push_back(it->second) ; 1109 1104 (it->first)++ ; 1110 1105 } 1111 1106 } 1112 1107 if (t < dstIndWeight.size()-1) t++ ; 1113 if (localMaskOnGridSrc(srcInd))srcIndCompressed ++ ;1108 srcIndCompressed ++ ; 1114 1109 } 1115 1110 srcInd++ ; … … 1119 1114 1120 1115 } 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1116 CATCH 1131 1117 1132 1118 /*! … … 1136 1122 */ 1137 1123 void CGenericAlgorithmTransformation::computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs) 1124 TRY 1138 1125 { 1139 1126 computeIndexSourceMapping_(dataAuxInputs); 1140 1127 } 1128 CATCH 1141 1129 1142 1130 std::vector<StdString> CGenericAlgorithmTransformation::getIdAuxInputs() 1131 TRY 1143 1132 { 1144 1133 return idAuxInputs_; 1145 1134 } 1135 CATCH 1146 1136 1147 1137 CGenericAlgorithmTransformation::AlgoTransType CGenericAlgorithmTransformation::type() 1138 TRY 1148 1139 { 1149 1140 return type_; 1150 1141 } 1151 1152 } 1142 CATCH 1143 1144 } -
XIOS/dev/branch_openmp/src/transformation/generic_algorithm_transformation.hpp
r1545 r1642 88 88 void computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs = std::vector<CArray<double,1>* >()); 89 89 void computeTransformationMappingNonDistributed(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst, 90 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, vector<bool>& localMaskOnGridDest); 91 void nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid, vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 92 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, CArray<bool,1>& localMaskOnGridSrc, vector<bool>& localMaskOnGridDest) ; 90 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, int& nbLocalIndexOnGridDest); 91 void nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid, vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, 92 int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, 93 int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 94 vector<int>& localSrc, vector<int>& localDst, vector<double>& weight) ; 93 95 94 96 protected: -
XIOS/dev/branch_openmp/src/transformation/grid_generate.cpp
r978 r1642 30 30 */ 31 31 void CGridGenerate::selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 32 TRY 32 33 { 33 34 CGenericAlgorithmTransformation* algo = 0; 34 35 algoTransformation_.push_back(algo); 35 36 } 37 CATCH 36 38 37 39 /*! … … 43 45 */ 44 46 void CGridGenerate::selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 47 TRY 45 48 { 46 49 CGenericAlgorithmTransformation* algo = 0; 47 50 algoTransformation_.push_back(algo); 48 51 } 52 CATCH 49 53 50 54 /*! … … 56 60 */ 57 61 void CGridGenerate::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 62 TRY 58 63 { 59 64 std::vector<CDomain*> domainListDestP = gridDestination_->getDomains(); … … 89 94 algoTransformation_.push_back(algo); 90 95 } 96 CATCH 91 97 92 98 /*! … … 94 100 */ 95 101 void CGridGenerate::completeGrid() 102 TRY 96 103 { 97 104 ListAlgoType::const_iterator itb = listAlgos_.begin(), … … 110 117 } 111 118 } 119 CATCH 112 120 113 121 } -
XIOS/dev/branch_openmp/src/transformation/grid_transformation.cpp
r1545 r1642 38 38 */ 39 39 void CGridTransformation::selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 40 TRY 40 41 { 41 42 std::vector<CScalar*> scaListDestP = gridDestination_->getScalars(); … … 59 60 algoTransformation_.push_back(algo); 60 61 } 62 CATCH 61 63 62 64 /*! … … 67 69 */ 68 70 void CGridTransformation::selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 71 TRY 69 72 { 70 73 std::vector<CAxis*> axisListDestP = gridDestination_->getAxis(); … … 88 91 algoTransformation_.push_back(algo); 89 92 } 93 CATCH 90 94 91 95 /*! … … 96 100 */ 97 101 void CGridTransformation::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) 102 TRY 98 103 { 99 104 std::vector<CDomain*> domainListDestP = gridDestination_->getDomains(); … … 117 122 algoTransformation_.push_back(algo); 118 123 } 124 CATCH 119 125 120 126 /*! … … 123 129 */ 124 130 std::map<int,std::pair<int,int> > CGridTransformation::getElementPosition(CGrid* grid) 131 TRY 125 132 { 126 133 std::vector<CScalar*> scalarListP = grid->getScalars(); … … 155 162 return elementPosition; 156 163 } 164 CATCH 157 165 158 166 /*! … … 163 171 */ 164 172 void CGridTransformation::setUpGridDestination(int elementPositionInGrid, ETranformationType transType) 173 TRY 165 174 { 166 175 if (isSpecialTransformation(transType)) return; … … 240 249 tempGridDests_.push_back(tmpGridDestination_); 241 250 } 251 CATCH 242 252 243 253 /*! … … 249 259 */ 250 260 void CGridTransformation::setUpGridSource(int elementPositionInGrid) 261 TRY 251 262 { 252 263 if (!tempGridSrcs_.empty() && (getNbAlgo()-1) == tempGridSrcs_.size()) … … 326 337 tempGridSrcs_.push_back(gridSource_); 327 338 } 339 CATCH 328 340 329 341 /*! … … 336 348 */ 337 349 void CGridTransformation::computeAll(const std::vector<CArray<double,1>* >& dataAuxInputs, Time timeStamp) 350 TRY 338 351 { 339 352 if (nbNormalAlgos_ < 1) return; … … 346 359 std::list<RecvIndexGridDestinationMap>().swap(localIndexToReceiveOnGridDest_); 347 360 std::list<size_t>().swap(nbLocalIndexOnGridDest_); 348 std::list<std::vector<bool> >().swap(localMaskOnGridDest_);349 361 } 350 362 else … … 399 411 vector<int> localDst ; 400 412 vector<double> weight ; 401 localMaskOnGridDest_.push_back(vector<bool>());413 int nbLocalIndexOnGridDest; 402 414 CTimer::get("computeTransformationMappingNonDistributed").resume(); 403 415 algo->computeTransformationMappingNonDistributed(elementPosition, gridSource_, tmpGridDestination_, 404 localSrc, localDst, weight, localMaskOnGridDest_.back()) ;416 localSrc, localDst, weight, nbLocalIndexOnGridDest) ; 405 417 CTimer::get("computeTransformationMappingNonDistributed").suspend(); 406 418 407 419 CTimer::get("computeTransformationMappingConvert").resume(); 408 nbLocalIndexOnGridDest_.push_back( localMaskOnGridDest_.back().size()) ;420 nbLocalIndexOnGridDest_.push_back(nbLocalIndexOnGridDest) ; 409 421 int clientRank=client->clientRank ; 410 422 { … … 453 465 } 454 466 } 467 CATCH 455 468 456 469 /*! … … 459 472 */ 460 473 void CGridTransformation::computeTransformationMapping(const SourceDestinationIndexMap& globaIndexWeightFromSrcToDst) 474 TRY 461 475 { 462 476 CContext* context = CContext::getCurrent(); … … 472 486 size_t nbLocalIndex = globalLocalIndexGridDestSendToServer.size(); 473 487 nbLocalIndexOnGridDest_.push_back(nbLocalIndex); 474 localMaskOnGridDest_.push_back(std::vector<bool>());475 std::vector<bool>& tmpMask = localMaskOnGridDest_.back();476 tmpMask.resize(nbLocalIndex,false);488 // localMaskOnGridDest_.push_back(std::vector<bool>()); 489 // std::vector<bool>& tmpMask = localMaskOnGridDest_.back(); 490 // tmpMask.resize(nbLocalIndex,false); 477 491 478 492 // Find out number of index sent from grid source and number of index received on grid destination … … 500 514 sendRankSizeMap[itIndex->first] = sendSize; 501 515 } 502 ep_lib::MPI_Allgather(&connectedClient,1, MPI_INT,recvCount,1,MPI_INT,client->intraComm);516 ep_lib::MPI_Allgather(&connectedClient,1,EP_INT,recvCount,1,EP_INT,client->intraComm); 503 517 504 518 displ[0]=0 ; … … 507 521 int* recvRankBuff=new int[recvSize]; 508 522 int* recvSizeBuff=new int[recvSize]; 509 ep_lib::MPI_Allgatherv(sendRankBuff,connectedClient, MPI_INT,recvRankBuff,recvCount,displ,MPI_INT,client->intraComm);510 ep_lib::MPI_Allgatherv(sendSizeBuff,connectedClient, MPI_INT,recvSizeBuff,recvCount,displ,MPI_INT,client->intraComm);523 ep_lib::MPI_Allgatherv(sendRankBuff,connectedClient,EP_INT,recvRankBuff,recvCount,displ,EP_INT,client->intraComm); 524 ep_lib::MPI_Allgatherv(sendSizeBuff,connectedClient,EP_INT,recvSizeBuff,recvCount,displ,EP_INT,client->intraComm); 511 525 for (int i = 0; i < nbClient; ++i) 512 526 { … … 532 546 recvGlobalIndexSrc[recvRank] = new unsigned long [recvSize]; 533 547 534 ep_lib::MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, MPI_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests[requests_position++]); 535 ep_lib::MPI_Irecv(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests[requests_position++]); 548 ep_lib::MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, EP_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests[requests_position++]); 549 ep_lib::MPI_Irecv(recvMaskDst[recvRank], recvSize, EP_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests[requests_position++]); 550 551 //requests.push_back(ep_lib::MPI_Request()); 552 //ep_lib::MPI_Irecv(recvGlobalIndexSrc[recvRank], recvSize, EP_UNSIGNED_LONG, recvRank, 46, client->intraComm, &requests.back()); 553 //requests.push_back(ep_lib::MPI_Request()); 554 //ep_lib::MPI_Irecv(recvMaskDst[recvRank], recvSize, EP_UNSIGNED_CHAR, recvRank, 47, client->intraComm, &requests.back()); 536 555 } 537 556 … … 568 587 569 588 // Send global index source and mask 570 ep_lib::MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, MPI_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests[requests_position++]); 571 ep_lib::MPI_Isend(sendMaskDst[sendRank], sendSize, MPI_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests[requests_position++]); 589 ep_lib::MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, EP_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests[requests_position++]); 590 ep_lib::MPI_Isend(sendMaskDst[sendRank], sendSize, EP_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests[requests_position++]); 591 //requests.push_back(ep_lib::MPI_Request()); 592 //ep_lib::MPI_Isend(sendGlobalIndexSrc[sendRank], sendSize, EP_UNSIGNED_LONG, sendRank, 46, client->intraComm, &requests.back()); 593 //requests.push_back(ep_lib::MPI_Request()); 594 //ep_lib::MPI_Isend(sendMaskDst[sendRank], sendSize, EP_UNSIGNED_CHAR, sendRank, 47, client->intraComm, &requests.back()); 572 595 } 573 596 … … 585 608 int recvSize = itSend->second; 586 609 587 ep_lib::MPI_Irecv(sendMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 610 ep_lib::MPI_Irecv(sendMaskDst[recvRank], recvSize, EP_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 611 //requests.push_back(ep_lib::MPI_Request()); 612 //ep_lib::MPI_Irecv(sendMaskDst[recvRank], recvSize, EP_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests.back()); 588 613 } 589 614 … … 621 646 622 647 // Okie, now inform the destination which source index are masked 623 ep_lib::MPI_Isend(recvMaskDst[recvRank], recvSize, MPI_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 648 ep_lib::MPI_Isend(recvMaskDst[recvRank], recvSize, EP_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests[requests_position++]); 649 //requests.push_back(ep_lib::MPI_Request()); 650 //ep_lib::MPI_Isend(recvMaskDst[recvRank], recvSize, EP_UNSIGNED_CHAR, recvRank, 48, client->intraComm, &requests.back()); 624 651 } 625 652 status.resize(requests.size()); … … 653 680 recvTmp[recvRank][realRecvSize].first = globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]; 654 681 recvTmp[recvRank][realRecvSize].second = recvWeightDst(idx); 655 tmpMask[globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]] = true;656 682 ++realRecvSize; 657 683 } … … 678 704 679 705 } 706 CATCH 680 707 681 708 /*! … … 684 711 */ 685 712 const std::list<CGridTransformation::SendingIndexGridSourceMap>& CGridTransformation::getLocalIndexToSendFromGridSource() const 713 TRY 686 714 { 687 715 return localIndexToSendFromGridSource_; 688 716 } 717 CATCH 689 718 690 719 /*! … … 693 722 */ 694 723 const std::list<CGridTransformation::RecvIndexGridDestinationMap>& CGridTransformation::getLocalIndexToReceiveOnGridDest() const 724 TRY 695 725 { 696 726 return localIndexToReceiveOnGridDest_; 697 727 } 728 CATCH 698 729 699 730 /*! … … 702 733 */ 703 734 const std::list<size_t>& CGridTransformation::getNbLocalIndexToReceiveOnGridDest() const 735 TRY 704 736 { 705 737 return nbLocalIndexOnGridDest_; 706 738 } 707 708 /*! 709 Local mask of data which will be received on the grid destination 710 \return local mask of data 711 */ 712 const std::list<std::vector<bool> >& CGridTransformation::getLocalMaskIndexOnGridDest() const 713 { 714 return localMaskOnGridDest_; 715 } 716 717 } 739 CATCH 740 741 } -
XIOS/dev/branch_openmp/src/transformation/grid_transformation.hpp
r1328 r1642 12 12 #include <map> 13 13 #include <vector> 14 #include "mpi_std.hpp"15 14 #include "generic_algorithm_transformation.hpp" 16 15 #include "transformation_enum.hpp" … … 50 49 const std::list<RecvIndexGridDestinationMap>& getLocalIndexToReceiveOnGridDest() const; 51 50 const std::list<size_t>& getNbLocalIndexToReceiveOnGridDest() const; 52 const std::list<std::vector<bool> >& getLocalMaskIndexOnGridDest() const;53 51 54 52 CGrid* getGridSource() { return originalGridSource_; } … … 85 83 //! Number of local index of data to receive on grid destination 86 84 std::list<size_t> nbLocalIndexOnGridDest_; 87 std::list<std::vector<bool> > localMaskOnGridDest_;88 85 89 86 bool dynamicalTransformation_; -
XIOS/dev/branch_openmp/src/transformation/grid_transformation_factory_impl.hpp
r1334 r1642 57 57 typedef std::map<ETranformationType, CreateTransformationCallBack> CallBackMap; 58 58 static CallBackMap* transformationCreationCallBacks_; 59 #pragma omp threadprivate(transformationCreationCallBacks_)60 59 static bool registerTransformation(ETranformationType transType, CreateTransformationCallBack createFn); 61 60 static bool unregisterTransformation(ETranformationType transType); 62 61 static bool initializeTransformation_; 63 #pragma omp threadprivate(initializeTransformation_)64 62 }; 65 63 -
XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.cpp
r1460 r1642 10 10 #include "grid.hpp" 11 11 #include "algo_types.hpp" 12 using namespace ep_lib;13 12 14 13 namespace xios { … … 29 28 CAxisAlgorithmExtractDomain::registerTrans(); 30 29 CAxisAlgorithmInterpolate::registerTrans(); 30 CAxisAlgorithmExtract::registerTrans(); 31 31 CAxisAlgorithmInverse::registerTrans(); 32 32 CAxisAlgorithmReduceDomain::registerTrans(); … … 41 41 CDomainAlgorithmExpand::registerTrans(); 42 42 CDomainAlgorithmReorder::registerTrans(); 43 CDomainAlgorithmExtract::registerTrans(); 43 44 } 44 45 … … 46 47 : gridSource_(source), gridDestination_(destination), isSameGrid_(false), 47 48 listAlgos_(), algoTypes_(), nbNormalAlgos_(0), nbSpecialAlgos_(0), auxInputs_() 49 TRY 48 50 { 49 51 if (0 == source) … … 61 63 initializeTransformations(type); 62 64 } 65 CATCH 63 66 64 67 /*! … … 69 72 */ 70 73 void CGridTransformationSelector::initializeTransformations(TransformationType type) 74 TRY 71 75 { 72 76 // Initialize algorithms … … 99 103 } 100 104 } 105 CATCH 101 106 102 107 CGridTransformationSelector::~CGridTransformationSelector() 108 TRY 103 109 { 104 110 std::vector<CGenericAlgorithmTransformation*>::const_iterator itb = algoTransformation_.begin(), it, … … 106 112 for (it = itb; it != ite; ++it) delete (*it); 107 113 } 114 CATCH 108 115 109 116 /*! … … 111 118 */ 112 119 void CGridTransformationSelector::updateElementPosition() 120 TRY 113 121 { 114 122 int idxScalar = 0, idxAxis = 0, idxDomain = 0; … … 162 170 } 163 171 } 172 CATCH 164 173 165 174 /*! … … 167 176 */ 168 177 void CGridTransformationSelector::initializeAlgorithms() 178 TRY 169 179 { 170 180 updateElementPosition(); … … 187 197 } 188 198 } 199 CATCH 189 200 190 201 /*! … … 196 207 */ 197 208 void CGridTransformationSelector::initializeScalarAlgorithms(int scalarPositionInGrid) 209 TRY 198 210 { 199 211 std::vector<CScalar*> scalarListDestP = gridDestination_->getScalars(); … … 228 240 } 229 241 } 242 CATCH 230 243 231 244 /*! … … 237 250 */ 238 251 void CGridTransformationSelector::initializeAxisAlgorithms(int axisPositionInGrid) 252 TRY 239 253 { 240 254 std::vector<CAxis*> axisListDestP = gridDestination_->getAxis(); … … 269 283 } 270 284 } 285 CATCH 271 286 272 287 /*! … … 277 292 */ 278 293 void CGridTransformationSelector::initializeDomainAlgorithms(int domPositionInGrid) 294 TRY 279 295 { 280 296 std::vector<CDomain*> domListDestP = gridDestination_->getDomains(); … … 308 324 } 309 325 } 310 311 } 326 } 327 CATCH 312 328 313 329 /*! … … 320 336 */ 321 337 void CGridTransformationSelector::selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, int algoType) 338 TRY 322 339 { 323 340 updateElementPosition(); … … 337 354 } 338 355 } 356 CATCH 339 357 340 358 bool CGridTransformationSelector::isSpecialTransformation(ETranformationType transType) 359 TRY 341 360 { 342 361 bool res = false; … … 352 371 return res; 353 372 } 354 355 } 373 CATCH 374 375 } -
XIOS/dev/branch_openmp/src/transformation/grid_transformation_selector.hpp
r1460 r1642 12 12 #include <map> 13 13 #include <vector> 14 #include "mpi_std.hpp"15 14 #include "generic_algorithm_transformation.hpp" 16 15 #include "transformation_enum.hpp" -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.cpp
r1545 r1642 14 14 #include "grid_transformation_factory_impl.hpp" 15 15 16 16 #include "reduction.hpp" 17 17 18 18 namespace xios { … … 26 26 std::map<int, int>& elementPositionInGridDst2AxisPosition, 27 27 std::map<int, int>& elementPositionInGridDst2DomainPosition) 28 TRY 28 29 { 29 30 std::vector<CScalar*> scalarListDestP = gridDst->getScalars(); … … 36 37 return (new CScalarAlgorithmExtractAxis(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], extractAxis)); 37 38 } 39 CATCH 38 40 39 41 bool CScalarAlgorithmExtractAxis::registerTrans() 42 TRY 40 43 { 41 44 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_EXTRACT_AXIS_TO_SCALAR, create); 42 45 } 46 CATCH 43 47 44 48 CScalarAlgorithmExtractAxis::CScalarAlgorithmExtractAxis(CScalar* scalarDestination, CAxis* axisSource, CExtractAxisToScalar* algo) 45 49 : CScalarAlgorithmTransformation(scalarDestination, axisSource), 46 50 reduction_(0) 51 TRY 47 52 { 48 53 algo->checkValid(scalarDestination, axisSource); 49 54 StdString op = "extract"; 50 55 pos_ = algo->position; 51 if(CReductionAlgorithm::ReductionOperations_ptr == 0) 52 { 53 CReductionAlgorithm::initReductionOperation(); 54 } 55 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations_ptr->at(op)); 56 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 56 57 } 58 CATCH 57 59 58 60 void CScalarAlgorithmExtractAxis::apply(const std::vector<std::pair<int,double> >& localIndex, … … 61 63 std::vector<bool>& flagInitial, 62 64 bool ignoreMissingValue, bool firstPass) 65 TRY 63 66 { 64 67 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 65 68 } 69 CATCH 66 70 67 71 CScalarAlgorithmExtractAxis::~CScalarAlgorithmExtractAxis() 72 TRY 68 73 { 69 74 if (0 != reduction_) delete reduction_; 70 75 } 76 CATCH 71 77 72 78 void CScalarAlgorithmExtractAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 79 TRY 73 80 { 74 81 this->transformationMapping_.resize(1); … … 81 88 transWeight[0].push_back(1.0); 82 89 } 90 CATCH 83 91 84 92 } -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_extract_axis.hpp
r1339 r1642 12 12 #include "scalar_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Extract a scalar from an axis 26 25 */ 27 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation , public CReductionAlgorithm26 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 28 27 { 29 28 public: -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.cpp
r1545 r1642 13 13 #include "grid.hpp" 14 14 #include "grid_transformation_factory_impl.hpp" 15 #include "reduction.hpp" 15 16 16 17 #include "reduction.hpp" 17 18 18 19 namespace xios { … … 26 27 std::map<int, int>& elementPositionInGridDst2AxisPosition, 27 28 std::map<int, int>& elementPositionInGridDst2DomainPosition) 29 TRY 28 30 { 29 31 std::vector<CScalar*> scalarListDestP = gridDst->getScalars(); … … 36 38 return (new CScalarAlgorithmReduceAxis(scalarListDestP[scalarDstIndex], axisListSrcP[axisSrcIndex], reduceAxis)); 37 39 } 40 CATCH 38 41 39 42 bool CScalarAlgorithmReduceAxis::registerTrans() 43 TRY 40 44 { 41 45 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, create); 42 46 } 47 CATCH 43 48 44 49 CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CScalar* scalarDestination, CAxis* axisSource, CReduceAxisToScalar* algo) 45 50 : CScalarAlgorithmTransformation(scalarDestination, axisSource), 46 51 reduction_(0) 52 TRY 47 53 { 48 54 if (algo->operation.isEmpty()) … … 74 80 } 75 81 76 if(CReductionAlgorithm::ReductionOperations_ptr == 0) 77 { 78 CReductionAlgorithm::initReductionOperation(); 79 } 80 81 if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 82 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 82 83 ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 83 84 << "Operation '" << op << "' not found. Please make sure to use a supported one" … … 85 86 << "Scalar destination " << scalarDestination->getId()); 86 87 87 reduction_ = CReductionAlgorithm::createOperation( (*CReductionAlgorithm::ReductionOperations_ptr)[op]);88 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 88 89 } 90 CATCH 89 91 90 92 void CScalarAlgorithmReduceAxis::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut, 91 93 std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass) 94 TRY 92 95 { 93 96 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 94 97 } 98 CATCH 95 99 96 100 void CScalarAlgorithmReduceAxis::updateData(CArray<double,1>& dataOut) 101 TRY 97 102 { 98 103 reduction_->updateData(dataOut); 99 104 } 105 CATCH 100 106 101 107 CScalarAlgorithmReduceAxis::~CScalarAlgorithmReduceAxis() 108 TRY 102 109 { 103 110 if (0 != reduction_) delete reduction_; 104 111 } 112 CATCH 105 113 106 114 void CScalarAlgorithmReduceAxis::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 115 TRY 107 116 { 108 117 this->transformationMapping_.resize(1); … … 120 129 } 121 130 } 131 CATCH 122 132 123 133 } -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_axis.hpp
r1339 r1642 12 12 #include "scalar_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Reducing an axis to a scalar 26 25 */ 27 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation , public CReductionAlgorithm26 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 28 27 { 29 28 public: -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.cpp
r1545 r1642 14 14 #include "grid_transformation_factory_impl.hpp" 15 15 16 #include "reduction.hpp" 16 17 17 18 namespace xios { … … 25 26 std::map<int, int>& elementPositionInGridDst2AxisPosition, 26 27 std::map<int, int>& elementPositionInGridDst2DomainPosition) 28 TRY 27 29 { 28 30 std::vector<CScalar*> scalarListDestP = gridDst->getScalars(); … … 35 37 return (new CScalarAlgorithmReduceDomain(scalarListDestP[scalarDstIndex], domainListSrcP[domainSrcIndex], reduceDomain)); 36 38 } 39 CATCH 37 40 38 41 bool CScalarAlgorithmReduceDomain::registerTrans() 42 TRY 39 43 { 40 44 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_REDUCE_DOMAIN_TO_SCALAR, create); 41 45 } 46 CATCH 42 47 43 48 CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CScalar* scalarDestination, CDomain* domainSource, CReduceDomainToScalar* algo) 44 49 : CScalarAlgorithmTransformation(scalarDestination, domainSource), 45 50 reduction_(0) 51 TRY 46 52 { 47 53 algo->checkValid(scalarDestination, domainSource); … … 70 76 } 71 77 72 if(CReductionAlgorithm::ReductionOperations_ptr == 0) 73 { 74 CReductionAlgorithm::initReductionOperation(); 75 } 76 if (CReductionAlgorithm::ReductionOperations_ptr->end() == CReductionAlgorithm::ReductionOperations_ptr->find(op)) 78 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 77 79 ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)", 78 80 << "Operation '" << op << "' not found. Please make sure to use a supported one" … … 80 82 << "Scalar destination " << scalarDestination->getId()); 81 83 82 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations _ptr->at(op));84 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 83 85 local = algo->local ; 84 86 } 87 CATCH 85 88 86 89 void CScalarAlgorithmReduceDomain::apply(const std::vector<std::pair<int,double> >& localIndex, … … 89 92 std::vector<bool>& flagInitial, 90 93 bool ignoreMissingValue, bool firstPass) 94 TRY 91 95 { 92 96 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 93 97 } 98 CATCH 94 99 95 100 void CScalarAlgorithmReduceDomain::updateData(CArray<double,1>& dataOut) 101 TRY 96 102 { 97 103 reduction_->updateData(dataOut); 98 104 } 105 CATCH 99 106 100 107 CScalarAlgorithmReduceDomain::~CScalarAlgorithmReduceDomain() 108 TRY 101 109 { 102 110 if (0 != reduction_) delete reduction_; 103 111 } 112 CATCH 104 113 105 114 void CScalarAlgorithmReduceDomain::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 115 TRY 106 116 { 107 117 this->transformationMapping_.resize(1); … … 140 150 141 151 } 152 CATCH 142 153 143 154 } -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_domain.hpp
r1460 r1642 12 12 #include "scalar_algorithm_transformation.hpp" 13 13 #include "transformation.hpp" 14 #include "reduction.hpp"15 14 16 15 namespace xios { … … 25 24 Reducing an DOMAIN to a scalar 26 25 */ 27 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation , public CReductionAlgorithm26 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation 28 27 { 29 28 public: -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_scalar.cpp
r1545 r1642 9 9 #include "grid.hpp" 10 10 #include "grid_transformation_factory_impl.hpp" 11 11 #include "reduction.hpp" 12 12 13 13 … … 22 22 std::map<int, int>& elementPositionInGridDst2AxisPosition, 23 23 std::map<int, int>& elementPositionInGridDst2DomainPosition) 24 TRY 24 25 { 25 26 std::vector<CScalar*> scalarListDestP = gridDst->getScalars(); … … 32 33 return (new CScalarAlgorithmReduceScalar(scalarListDestP[scalarDstIndex], scalarListSrcP[scalarSrcIndex], reduceScalar)); 33 34 } 35 CATCH 34 36 35 37 bool CScalarAlgorithmReduceScalar::registerTrans() 38 TRY 36 39 { 37 40 CGridTransformationFactory<CScalar>::registerTransformation(TRANS_REDUCE_SCALAR_TO_SCALAR, create); 38 41 } 42 CATCH 39 43 40 44 CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo) 41 45 : CScalarAlgorithmTransformation(scalarDestination, scalarSource), 42 46 reduction_(0) 47 TRY 43 48 { 44 49 eliminateRedondantSrc_= false ; … … 70 75 71 76 } 72 73 if(CReductionAlgorithm::ReductionOperations_ptr == 0)74 {75 CReductionAlgorithm::initReductionOperation();76 }77 77 78 if (CReductionAlgorithm::ReductionOperations _ptr->end() == CReductionAlgorithm::ReductionOperations_ptr->find(op))78 if (CReductionAlgorithm::ReductionOperations.end() == CReductionAlgorithm::ReductionOperations.find(op)) 79 79 ERROR("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)", 80 80 << "Operation '" << op << "' not found. Please make sure to use a supported one" … … 82 82 << "Scalar destination " << scalarDestination->getId()); 83 83 84 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations _ptr->at(op));84 reduction_ = CReductionAlgorithm::createOperation(CReductionAlgorithm::ReductionOperations[op]); 85 85 } 86 CATCH 86 87 87 88 void CScalarAlgorithmReduceScalar::apply(const std::vector<std::pair<int,double> >& localIndex, const double* dataInput, CArray<double,1>& dataOut, 88 89 std::vector<bool>& flagInitial, bool ignoreMissingValue, bool firstPass) 90 TRY 89 91 { 90 92 reduction_->apply(localIndex, dataInput, dataOut, flagInitial, ignoreMissingValue, firstPass); 91 93 } 94 CATCH 92 95 93 96 void CScalarAlgorithmReduceScalar::updateData(CArray<double,1>& dataOut) 97 TRY 94 98 { 95 99 reduction_->updateData(dataOut); 96 100 } 101 CATCH 97 102 98 103 CScalarAlgorithmReduceScalar::~CScalarAlgorithmReduceScalar() 104 TRY 99 105 { 100 106 if (0 != reduction_) delete reduction_; 101 107 } 108 CATCH 102 109 103 110 void CScalarAlgorithmReduceScalar::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 111 TRY 104 112 { 105 113 this->transformationMapping_.resize(1); … … 113 121 114 122 } 123 CATCH 115 124 116 125 } -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_reduce_scalar.hpp
r1460 r1642 8 8 #include "scalar_algorithm_transformation.hpp" 9 9 #include "transformation.hpp" 10 #include "reduction.hpp"11 10 12 11 namespace xios { … … 20 19 Reducing an scalar to a scalar 21 20 */ 22 class CScalarAlgorithmReduceScalar : public CScalarAlgorithmTransformation , public CReductionAlgorithm21 class CScalarAlgorithmReduceScalar : public CScalarAlgorithmTransformation 23 22 { 24 23 public: -
XIOS/dev/branch_openmp/src/transformation/scalar_algorithm_transformation.cpp
r1460 r1642 57 57 int elementSourceType, 58 58 CClientClientDHTInt::Index2VectorInfoTypeMap& globalIndexElementSourceOnProc) 59 TRY 59 60 { 60 61 CContext* context = CContext::getCurrent(); … … 121 122 } 122 123 } 123 124 CATCH 124 125 }
Note: See TracChangeset
for help on using the changeset viewer.