Changeset 1980
- Timestamp:
- 11/24/20 11:33:59 (4 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/interpolate_axis_attribute.conf
r827 r1980 3 3 DECLARE_ATTRIBUTE(int, order) 4 4 DECLARE_ATTRIBUTE(StdString, coordinate) 5 DECLARE_ATTRIBUTE(StdString, coordinate_src) 6 DECLARE_ATTRIBUTE(StdString, coordinate_dst) 7 -
XIOS/trunk/src/node/interpolate_axis.cpp
r937 r1980 41 41 { 42 42 if (this->order.isEmpty()) this->order.setValue(1); 43 if (this->coordinate.isEmpty() && !this->coordinate_src.isEmpty()) this->coordinate.setValue(this->coordinate_src.getValue()); 44 if (this->coordinate_src.isEmpty() && !this->coordinate.isEmpty()) this->coordinate_src.setValue(this->coordinate.getValue()); 43 45 int order = this->order.getValue(); 44 46 if (order >= axisSrc->n_glo.getValue()) … … 67 69 << "Please define one"); 68 70 } 71 72 if (!this->coordinate_dst.isEmpty()) 73 { 74 StdString coordinate = this->coordinate_dst.getValue(); 75 if (!CField::has(coordinate)) 76 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 77 << "Coordinate field whose id " << coordinate << "does not exist " 78 << "Please define one"); 79 } 80 69 81 } 70 82 … … 72 84 { 73 85 std::vector<StdString> auxInputs; 74 if (!this->coordinate.isEmpty() )86 if (!this->coordinate.isEmpty() && this->coordinate_src.isEmpty()) 75 87 { 76 88 StdString coordinate = this->coordinate.getValue(); 89 this->coordinate_src.setValue(coordinate); 90 if (!CField::has(coordinate)) 91 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 92 << "Coordinate field whose id " << coordinate << "does not exist " 93 << "Please define one"); 94 auxInputs.push_back(coordinate); 95 } 96 if (!this->coordinate_src.isEmpty() || !this->coordinate.isEmpty()) 97 { 98 StdString coordinate = !this->coordinate.isEmpty()? this->coordinate.getValue():this->coordinate_src.getValue(); 99 this->coordinate.setValue(coordinate); 100 if (!CField::has(coordinate)) 101 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 102 << "Coordinate field whose id " << coordinate << "does not exist " 103 << "Please define one"); 104 auxInputs.push_back(coordinate); 105 } 106 107 if (!this->coordinate_dst.isEmpty()) 108 { 109 StdString coordinate = this->coordinate_dst.getValue(); 77 110 if (!CField::has(coordinate)) 78 111 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", -
XIOS/trunk/src/test/generic_testcase.f90
r1976 r1980 1 PROGRAM generic_testcase 1 PROGRAM generic_testcase 2 2 USE xios 3 3 USE mod_wait … … 161 161 DOUBLE PRECISION, POINTER :: field3D_sub(:,:), other_field3D_sub(:,:) 162 162 DOUBLE PRECISION, POINTER :: field3D_recv(:,:), other_field3D_recv(:,:) 163 DOUBLE PRECISION, POINTER :: pressure(:,:), other_pressure(:,:) 163 DOUBLE PRECISION, POINTER :: pressure(:,:), other_pressure(:,:), pressure_shifted(:,:) 164 164 165 165 DOUBLE PRECISION, POINTER :: field2D_W(:,:), other_field2D_W(:,:) … … 188 188 INTEGER :: ierr 189 189 190 LOGICAL :: ok_field2D, ok_field3D, ok_pressure , ok_field2D_sub, ok_field3D_sub,ok_field3D_recv, ok_field3D_send190 LOGICAL :: ok_field2D, ok_field3D, ok_pressure_shifted, ok_pressure, ok_field2D_sub, ok_field3D_sub,ok_field3D_recv, ok_field3D_send 191 191 LOGICAL :: ok_field_X, ok_field_Y, ok_field_XY, ok_field_Z, ok_field_XYZ, ok_field_XZ, ok_field_YZ 192 192 LOGICAL :: ok_field2D_W, ok_field3D_W, ok_pressure_W, ok_field2D_sub_W, ok_field3D_sub_W,ok_field3D_recv_W, ok_field3D_send_W … … 290 290 w=size(ensemble_value) 291 291 292 292 293 ALLOCATE(field2D(0:xy-1)) 293 294 ALLOCATE(field3D(0:xy-1,0:z-1)) 295 ALLOCATE(pressure_shifted(0:xy-1,0:z-1)) 294 296 ALLOCATE(pressure(0:xy-1,0:z-1)) 295 297 ALLOCATE(field3D_recv(0:xy-1,0:z-1)) … … 364 366 dist=sqrt((lat(k)/90.)**2+(lon(k)/180.)**2) ; 365 367 pressure(i,j)=pressure(i,j)*(1+params%pressure_factor*exp(-(4*dist)**2)) 368 pressure_shifted(i,j)=pressure(i,j)+5000 366 369 ENDIF 367 370 ENDIF … … 382 385 field_YZW(:,:,0) = field_YZ(:,:)*(1+0.1*ensemble_value(0)) 383 386 384 385 387 ok_field2D=xios_is_valid_field("field2D") ; 386 388 ok_field3D=xios_is_valid_field("field3D") ; 389 ok_pressure_shifted=xios_is_valid_field("pressure_shifted") ; 387 390 ok_pressure=xios_is_valid_field("pressure") ; 388 391 ok_field2D_sub=xios_is_valid_field("field2D_sub") ; … … 628 631 CALL xios_update_calendar(ts) 629 632 633 630 634 IF (ok_field2D) CALL xios_send_field("field2D",field2D) 631 635 IF (ok_field3D) CALL xios_send_field("field3D",field3D) 636 IF (ok_pressure_shifted) CALL xios_send_field("pressure_shifted",pressure_shifted) 632 637 IF (ok_pressure) CALL xios_send_field("pressure",pressure) 633 638 IF (ok_field_X) CALL xios_send_field("field_X",field_X) … … 2384 2389 END SUBROUTINE get_decomposition 2385 2390 2386 END PROGRAM generic_testcase 2387 2388 2391 END PROGRAM generic_testcase 2392 2393 -
XIOS/trunk/src/test/test_interpolate.f90
r1979 r1980 162 162 DOUBLE PRECISION, POINTER :: field3D_sub(:,:), other_field3D_sub(:,:) 163 163 DOUBLE PRECISION, POINTER :: field3D_recv(:,:), other_field3D_recv(:,:) 164 DOUBLE PRECISION, POINTER :: pressure(:,:), other_pressure(:,:) 164 DOUBLE PRECISION, POINTER :: pressure(:,:), other_pressure(:,:), pressure_shifted(:,:) 165 165 166 166 DOUBLE PRECISION, POINTER :: field2D_W(:,:), other_field2D_W(:,:) … … 190 190 191 191 LOGICAL :: ok_field_in 192 LOGICAL :: ok_field2D, ok_field3D, ok_pressure , ok_field2D_sub, ok_field3D_sub,ok_field3D_recv, ok_field3D_send192 LOGICAL :: ok_field2D, ok_field3D, ok_pressure_shifted, ok_pressure, ok_field2D_sub, ok_field3D_sub,ok_field3D_recv, ok_field3D_send 193 193 LOGICAL :: ok_field_X, ok_field_Y, ok_field_XY, ok_field_Z, ok_field_XYZ, ok_field_XZ, ok_field_YZ 194 194 LOGICAL :: ok_field2D_W, ok_field3D_W, ok_pressure_W, ok_field2D_sub_W, ok_field3D_sub_W,ok_field3D_recv_W, ok_field3D_send_W … … 296 296 ALLOCATE(field2D(0:xy-1)) 297 297 ALLOCATE(field3D(0:xy-1,0:z-1)) 298 ALLOCATE(pressure_shifted(0:xy-1,0:z-1)) 298 299 ALLOCATE(pressure(0:xy-1,0:z-1)) 299 300 ALLOCATE(field3D_recv(0:xy-1,0:z-1)) … … 368 369 dist=sqrt((lat(k)/90.)**2+(lon(k)/180.)**2) ; 369 370 pressure(i,j)=pressure(i,j)*(1+params%pressure_factor*exp(-(4*dist)**2)) 371 pressure_shifted(i,j)=pressure(i,j)+5000 370 372 ENDIF 371 373 ENDIF … … 386 388 field_YZW(:,:,0) = field_YZ(:,:)*(1+0.1*ensemble_value(0)) 387 389 388 ok_field_in=xios_is_valid_field("field_in") ; 390 ok_field_in=xios_is_valid_field("field_input") ; 391 ok_field_in=.FALSE. 389 392 ok_field2D=xios_is_valid_field("field2D") ; 390 393 ok_field3D=xios_is_valid_field("field3D") ; 394 ok_pressure_shifted=xios_is_valid_field("pressure_shifted") ; 391 395 ok_pressure=xios_is_valid_field("pressure") ; 392 396 ok_field2D_sub=xios_is_valid_field("field2D_sub") ; … … 632 636 CALL xios_update_calendar(ts) 633 637 634 if (ok_field_in) CALL xios_recv_field("field_in ", field_in)638 if (ok_field_in) CALL xios_recv_field("field_input", field_in) 635 639 if (ok_field_in) CALL xios_send_field("field_out", field_in) 636 640 637 641 IF (ok_field2D) CALL xios_send_field("field2D",field2D) 638 642 IF (ok_field3D) CALL xios_send_field("field3D",field3D) 643 IF (ok_pressure_shifted) CALL xios_send_field("pressure_shifted",pressure_shifted) 639 644 IF (ok_pressure) CALL xios_send_field("pressure",pressure) 640 645 IF (ok_field_X) CALL xios_send_field("field_X",field_X) -
XIOS/trunk/src/transformation/axis_algorithm_interpolate.cpp
r1852 r1980 50 50 51 51 CAxisAlgorithmInterpolate::CAxisAlgorithmInterpolate(CAxis* axisDestination, CAxis* axisSource, CInterpolateAxis* interpAxis) 52 : CAxisAlgorithmTransformation(axisDestination, axisSource), coordinate_(), transPosition_()52 : CAxisAlgorithmTransformation(axisDestination, axisSource), coordinate_(), coordinateDST_(),transPosition_() 53 53 TRY 54 54 { 55 55 interpAxis->checkValid(axisSource); 56 56 order_ = interpAxis->order.getValue(); 57 this->idAuxInputs_.clear(); 57 58 if (!interpAxis->coordinate.isEmpty()) 58 59 { … … 61 62 this->idAuxInputs_[0] = coordinate_; 62 63 } 64 else if (!interpAxis->coordinate_src.isEmpty()) 65 { 66 coordinate_ = interpAxis->coordinate_src.getValue(); 67 this->idAuxInputs_.resize(1); 68 this->idAuxInputs_[0] = coordinate_; 69 } 70 if (!interpAxis->coordinate_dst.isEmpty()) 71 { 72 coordinateDST_ = interpAxis->coordinate_dst.getValue(); 73 this->idAuxInputs_.resize(this->idAuxInputs_.size()+1); 74 this->idAuxInputs_[this->idAuxInputs_.size()-1] = coordinateDST_; 75 } 76 77 63 78 } 64 79 CATCH … … 71 86 { 72 87 CTimer::get("CAxisAlgorithmInterpolate::computeIndexSourceMapping_").resume() ; 73 CContext* context = CContext::getCurrent(); 74 CContextClient* client=context->client; 75 int nbClient = client->clientSize; 88 76 89 CArray<bool,1>& axisMask = axisSrc_->mask; 77 90 int srcSize = axisSrc_->n_glo.getValue(); … … 90 103 XIOSAlgorithms::sortWithIndex<double, CVectorStorage>(recvBuff, indexVec); 91 104 for (int i = 0; i < srcSize; ++i) valueSrc[i] = recvBuff[indexVec[i]]; 92 computeInterpolantPoint(valueSrc, indexVec, idx);105 computeInterpolantPoint(valueSrc, indexVec, dataAuxInputs, idx); 93 106 } 94 107 CTimer::get("CAxisAlgorithmInterpolate::computeIndexSourceMapping_").suspend() ; … … 97 110 98 111 /*! 99 Compute the interpolant points 112 Compute the interpolant points 100 113 Assume that we have all value of axis source, with these values, need to calculate weight (coeff) of Lagrange polynomial 101 114 \param [in] axisValue all value of axis source 115 \param [in] dataAuxInputs data for setting values of axis destination 102 116 \param [in] tranPos position of axis on a domain 103 117 */ 104 118 void CAxisAlgorithmInterpolate::computeInterpolantPoint(const std::vector<double>& axisValue, 105 119 const std::vector<int>& indexVec, 120 const std::vector<CArray<double,1>* >& dataAuxInputs, 106 121 int transPos) 107 122 TRY … … 115 130 CArray<double,1>& axisDestValue = axisDest_->value; 116 131 int numValue = axisDestValue.numElements(); 132 if(!coordinateDST_.empty()) 133 { 134 int nDomPoint = (*dataAuxInputs[0]).numElements()/numValue ; 135 int dst_position_in_data = dataAuxInputs.size()-1; 136 for(int ii=0; ii<numValue; ii++) 137 { 138 axisDestValue(ii) = (*dataAuxInputs[dst_position_in_data])(ii*nDomPoint+transPos); 139 } 140 } 141 117 142 std::map<int, std::vector<std::pair<int,double> > > interpolatingIndexValues; 118 143 … … 172 197 CATCH 173 198 199 200 174 201 /*! 175 202 Compute weight (coeff) of Lagrange's polynomial … … 233 260 int numValue = axisValue.numElements(); 234 261 262 235 263 if (srcSize == numValue) // Only one client or axis not distributed 236 264 { … … 248 276 } 249 277 } 250 251 278 } 252 279 else // Axis distributed … … 304 331 TRY 305 332 { 306 if (coordinate_.empty()) 333 bool has_src = !coordinate_.empty(); 334 bool has_dst = !coordinateDST_.empty(); 335 336 int nb_inputs=dataAuxInputs.size(); 337 338 339 if (!has_src) 307 340 { 308 341 vecAxisValue.resize(1); … … 312 345 this->transformationWeight_.resize(1); 313 346 } 314 else 347 else 315 348 { 316 349 CField* field = CField::get(coordinate_); -
XIOS/trunk/src/transformation/axis_algorithm_interpolate.hpp
r1704 r1980 34 34 35 35 virtual StdString getName() {return "Axis Trans. Filter \\n Interpolation";} 36 bool isInversed() {return isInversed_;} 36 37 37 38 protected: … … 42 43 std::vector<double>& recvBuff, std::vector<int>& indexVec); 43 44 void computeInterpolantPoint(const std::vector<double>& recvBuff, const std::vector<int>&, int transPos = 0); 45 void computeInterpolantPoint(const std::vector<double>& recvBuff, const std::vector<int>&, 46 const std::vector<CArray<double,1>* >& dataAuxInputs, int transPos = 0); 44 47 void computeWeightedValueAndMapping(const std::map<int, std::vector<std::pair<int,double> > >& interpolatingIndexValues, int transPos = 0); 45 48 void fillInAxisValue(std::vector<CArray<double,1> >& vecAxisValue, … … 50 53 int order_; 51 54 StdString coordinate_; 55 StdString coordinateDST_; 56 bool isInversed_; 52 57 std::vector<std::vector<int> > transPosition_; 53 58
Note: See TracChangeset
for help on using the changeset viewer.