- Timestamp:
- 03/22/18 10:43:20 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/transformation/domain_algorithm_interpolate.cpp
r1338 r1460 53 53 CContext* context = CContext::getCurrent(); 54 54 interpDomain_->checkValid(domainSource); 55 56 detectMissingValue = interpDomain_->detect_missing_value ; 57 renormalize = interpDomain_->renormalize ; 58 quantity = interpDomain_->quantity ; 59 60 if (interpDomain_->read_write_convention == CInterpolateDomain::read_write_convention_attr::fortran) fortranConvention=true ; 61 else fortranConvention=false ; 62 55 63 fileToReadWrite_ = "xios_interpolation_weights_"; 56 64 … … 100 108 std::vector<double> srcPole(3,0), dstPole(3,0); 101 109 int orderInterp = interpDomain_->order.getValue(); 102 bool renormalize ; 103 bool quantity ; 104 105 if (interpDomain_->renormalize.isEmpty()) renormalize=true; 106 else renormalize = interpDomain_->renormalize; 107 108 if (interpDomain_->quantity.isEmpty()) quantity=false; 109 else quantity = interpDomain_->quantity; 110 110 111 111 112 const double poleValue = 90.0; … … 456 457 recvTemp[recvSourceIndexBuff[idx]] += recvSourceWeightBuff[idx]/nbGlobalPointOnPole; 457 458 else 458 recvTemp[recvSourceIndexBuff[idx]] = 0.0;459 recvTemp[recvSourceIndexBuff[idx]] = recvSourceWeightBuff[idx]/nbGlobalPointOnPole; 459 460 } 460 461 … … 476 477 void CDomainAlgorithmInterpolate::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 477 478 { 478 if (readFromFile_ && !writeToFile_)479 if (readFromFile_) 479 480 readRemapInfo(); 480 481 else … … 566 567 } 567 568 568 domainIndexClientClientMapping.computeServerIndexMapping(globalIndexInterp );569 domainIndexClientClientMapping.computeServerIndexMapping(globalIndexInterp, client->serverSize); 569 570 const CClientServerMapping::GlobalIndexMap& globalIndexInterpSendToClient = domainIndexClientClientMapping.getGlobalIndexOnServer(); 570 571 … … 775 776 776 777 int index = 0; 778 int indexOffset=0 ; 779 if (fortranConvention) indexOffset=1 ; 777 780 for (it = itb; it !=ite; ++it) 778 781 { … … 780 783 for (int idx = 0; idx < tmp.size(); ++idx) 781 784 { 782 dst_idx(index) = it->first + 1;783 src_idx(index) = tmp[idx].first + 1;785 dst_idx(index) = it->first + indexOffset; 786 src_idx(index) = tmp[idx].first + indexOffset; 784 787 weights(index) = tmp[idx].second; 785 788 ++index; … … 843 846 size_t nbWeightGlo ; 844 847 848 845 849 CContext* context = CContext::getCurrent(); 846 850 CContextClient* client=context->client; … … 848 852 int clientSize = client->clientSize; 849 853 854 855 { 856 ifstream f(filename.c_str()); 857 if (!f.good()) ERROR("void CDomainAlgorithmInterpolate::readInterpolationInfo", 858 << "Attempt to read file weight :" << filename << " which doesn't seem to exist." << std::endl 859 << "Please check this file "); 860 } 861 850 862 nc_open(filename.c_str(),NC_NOWRITE, &ncid) ; 851 863 nc_inq_dimid(ncid,"n_weight",&weightDimId) ; … … 882 894 nc_get_vara_long(ncid, dstIndexId, &start, &nbWeight, dstIndex) ; 883 895 884 for(size_t ind=0; ind<nbWeight;++ind) 885 interpMapValue[dstIndex[ind]-1].push_back(make_pair(srcIndex[ind]-1,weight[ind])); 886 } 887 888 } 896 int indexOffset=0 ; 897 if (fortranConvention) indexOffset=1 ; 898 for(size_t ind=0; ind<nbWeight;++ind) 899 interpMapValue[dstIndex[ind]-indexOffset].push_back(make_pair(srcIndex[ind]-indexOffset,weight[ind])); 900 } 901 902 void CDomainAlgorithmInterpolate::apply(const std::vector<std::pair<int,double> >& localIndex, 903 const double* dataInput, 904 CArray<double,1>& dataOut, 905 std::vector<bool>& flagInitial, 906 bool ignoreMissingValue, bool firstPass ) 907 { 908 int nbLocalIndex = localIndex.size(); 909 double defaultValue = std::numeric_limits<double>::quiet_NaN(); 910 911 if (detectMissingValue) 912 { 913 if (firstPass && renormalize) 914 { 915 renormalizationFactor.resize(dataOut.numElements()) ; 916 renormalizationFactor=1 ; 917 } 918 919 for (int idx = 0; idx < nbLocalIndex; ++idx) 920 { 921 if (NumTraits<double>::isnan(*(dataInput + idx))) 922 { 923 flagInitial[localIndex[idx].first] = false; 924 if (renormalize) renormalizationFactor(localIndex[idx].first)-=localIndex[idx].second ; 925 } 926 else 927 { 928 dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; 929 flagInitial[localIndex[idx].first] = true; // Reset flag to indicate not all data source are nan 930 } 931 } 932 933 // If all data source are nan then data destination must be nan 934 for (int idx = 0; idx < nbLocalIndex; ++idx) 935 { 936 if (!flagInitial[localIndex[idx].first]) 937 dataOut(localIndex[idx].first) = defaultValue; 938 } 939 } 940 else 941 { 942 for (int idx = 0; idx < nbLocalIndex; ++idx) 943 { 944 dataOut(localIndex[idx].first) += *(dataInput + idx) * localIndex[idx].second; 945 } 946 } 947 } 948 949 void CDomainAlgorithmInterpolate::updateData(CArray<double,1>& dataOut) 950 { 951 if (detectMissingValue && renormalize) 952 { 953 if (renormalizationFactor.numElements()>0) dataOut/=renormalizationFactor ; // In some case, process doesn't received any data for interpolation (mask) 954 // so renormalizationFactor is not initialized 955 } 956 } 957 958 }
Note: See TracChangeset
for help on using the changeset viewer.