Changeset 873
- Timestamp:
- 06/14/16 16:28:07 (9 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/REMAP/iodef.xml
r871 r873 5 5 <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" /> 6 6 <field_definition level="1" > 7 <field id="src_field" operation="instant" domain_ref="src_domain "/>7 <field id="src_field" operation="instant" domain_ref="src_domain_clone"/> 8 8 <field id="src_field_3D" operation="instant" domain_ref="src_domain" axis_ref="src_axis"/> 9 9 <field id="src_field_3D_interp" operation="instant" field_ref="src_field_3D" axis_ref="dst_axis"/> … … 24 24 <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 25 25 <file id="output" name="output"> 26 <!-- <field field_ref="src_field" name="field" />-->26 <field field_ref="src_field" name="field" /> 27 27 </file> 28 <file id="output_ 3D" name="output_3D">29 <field field_ref="src_field _3D" name="field"/>28 <file id="output_2D" name="output_2D"> 29 <field field_ref="src_field" name="field" domain_ref="dst_domain_regular_pole" default_value="10.e+5"/> 30 30 </file> 31 31 <file id="output_3D_pression" name="output_3D_pression"> -
XIOS/trunk/src/filter/spatial_transform_filter.cpp
r842 r873 6 6 namespace xios 7 7 { 8 CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount)9 : CFilter(gc, inputSlotsCount, engine) 8 CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount) 9 : CFilter(gc, inputSlotsCount, engine), outputDefaultValue(outputValue) 10 10 { /* Nothing to do */ } 11 11 12 12 std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 13 CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid )13 CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue) 14 14 { 15 15 if (!srcGrid || !destGrid) … … 26 26 const std::vector<StdString>& auxInputs = gridTransformation->getAuxInputs(); 27 27 size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size()); 28 boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, inputCount));28 boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 29 29 30 30 if (!lastFilter) … … 48 48 } 49 49 50 void CSpatialTransformFilter::onInputReady(std::vector<CDataPacketPtr> data) 51 { 52 CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 53 CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 54 if (outputPacket) 55 deliverOuput(outputPacket); 56 } 57 50 58 CSpatialTransformFilterEngine::CSpatialTransformFilterEngine(CGridTransformation* gridTransformation) 51 59 : gridTransformation(gridTransformation) … … 75 83 76 84 CDataPacketPtr CSpatialTransformFilterEngine::apply(std::vector<CDataPacketPtr> data) 85 { 86 /* Nothing to do */ 87 } 88 89 CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue) 77 90 { 78 91 CDataPacketPtr packet(new CDataPacket); … … 90 103 } 91 104 packet->data.resize(gridTransformation->getGridDestination()->storeIndex_client.numElements()); 105 packet->data = defaultValue; 92 106 apply(data[0]->data, packet->data); 93 107 } … … 99 113 { 100 114 CContextClient* client = CContext::getCurrent()->client; 115 116 // Get default value for output data 117 double defaultValue = 0.0; 118 if (0 != dataDest.numElements()) defaultValue = dataDest(0); 101 119 102 120 const std::list<CGridTransformation::SendingIndexGridSourceMap>& listLocalIndexSend = gridTransformation->getLocalIndexToSendFromGridSource(); 103 121 const std::list<CGridTransformation::RecvIndexGridDestinationMap>& listLocalIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 104 122 const std::list<size_t>& listNbLocalIndexToReceive = gridTransformation->getNbLocalIndexToReceiveOnGridDest(); 123 const std::list<std::vector<bool> >& listLocalIndexMaskOnDest = gridTransformation->getLocalMaskIndexOnGridDest(); 105 124 106 125 CArray<double,1> dataCurrentDest(dataSrc.copy()); … … 110 129 std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin(); 111 130 std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin(); 112 113 for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv) 131 std::list<std::vector<bool> >::const_iterator itLocalMaskIndexOnDest = listLocalIndexMaskOnDest.begin(); 132 133 for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itLocalMaskIndexOnDest) 114 134 { 115 135 CArray<double,1> dataCurrentSrc(dataCurrentDest); … … 164 184 165 185 dataCurrentDest.resize(*itNbListRecv); 166 dataCurrentDest = 0.0; 186 const std::vector<bool>& localMaskDest = *itLocalMaskIndexOnDest; 187 for (int i = 0; i < localMaskDest.size(); ++i) 188 if (localMaskDest[i]) dataCurrentDest(i) = 0.0; 189 else dataCurrentDest(i) = defaultValue; 190 167 191 currentBuff = 0; 168 192 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) -
XIOS/trunk/src/filter/spatial_transform_filter.hpp
r827 r873 21 21 * \param gc the associated garbage collector 22 22 * \param engine the engine defining the spatial transformation 23 * \param outputValue default value of output pin 23 24 * \param [in] inputSlotsCount number of input, by default there is only one for field src 24 25 */ 25 CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount = 1);26 CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount = 1); 26 27 27 28 /*! … … 34 35 */ 35 36 static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 36 buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid); 37 buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue); 38 39 protected: 40 /*! 41 Overriding this function to process transformations with auxillary inputs 42 */ 43 void virtual onInputReady(std::vector<CDataPacketPtr> data); 44 45 protected: 46 //! Default value of output pin 47 double outputDefaultValue; 37 48 }; // class CSpatialTransformFilter 38 49 … … 56 67 * 57 68 * \param data a vector of packets corresponding to each slot (one in this case) 69 * \param [in] defaultValue default value of output data 70 * \return the result of the grid transformation 71 */ 72 CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0); 73 74 /*! 75 * Applies the grid transformation to the input data and returns the result. 76 * 77 * \param data a vector of packets corresponding to each slot (one in this case) 58 78 * \return the result of the grid transformation 59 79 */ 60 80 CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 81 82 61 83 62 84 protected: -
XIOS/trunk/src/node/field.cpp
r854 r873 289 289 cout<<"file->output_freq.getValue() : "<<file->output_freq.getValue()<<endl ; 290 290 cout<<"lastDataRequestedFromServer + file->output_freq.getValue() : "<<lastDataRequestedFromServer + file->output_freq.getValue()<<endl ; 291 291 292 292 sendReadDataRequest(); 293 293 } … … 346 346 nstepMax = getRelFile()->getDataInput()->getFieldNbRecords(CField::get(this)); 347 347 } 348 348 349 349 this->incrementNStep(); 350 350 … … 780 780 // Check if a spatial transformation is needed 781 781 if (grid && grid != fieldRef->grid && grid->hasTransform()) 782 filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid); 782 { 783 double defaultValue = 0.0; 784 if (!default_value.isEmpty()) defaultValue = this->default_value; 785 filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, defaultValue); 786 } 787 783 788 else 784 789 filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc)); -
XIOS/trunk/src/test/test_remap.f90
r871 r873 21 21 DOUBLE PRECISION,ALLOCATABLE :: src_boundslat(:,:), dst_boundslat(:,:) 22 22 DOUBLE PRECISION,ALLOCATABLE :: src_field(:), tmp_field(:), tmp_field_1(:), tmp_field_2(:), src_field_3D(:,:), lval(:), lval1(:), src_field_pression(:,:) 23 LOGICAL,ALLOCATABLE :: src_mask_2D(:) 23 24 INTEGER :: src_ni_glo, dst_ni_glo; 24 25 INTEGER :: src_nvertex, dst_nvertex; … … 67 68 ALLOCATE(src_field(src_ni)) 68 69 ALLOCATE(src_field_3D(src_ni,llm)) 70 ALLOCATE(src_mask_2D(src_ni)) 69 71 ALLOCATE(src_field_pression(src_ni,llm)) 70 72 ALLOCATE(lval(llm)) … … 83 85 DO i=1,src_ni 84 86 src_field_3D(i,:) = src_field(i) 87 IF (MOD(i,10)==0) THEN 88 src_mask_2D(i)=.FALSE. 89 ELSE 90 src_mask_2D(i)=.TRUE. 91 ENDIF 85 92 ENDDO 86 93 … … 136 143 CALL xios_set_domain_attr("src_domain_clone", ni_glo=src_ni_glo, ibegin=src_ibegin, ni=src_ni, type="unstructured") 137 144 CALL xios_set_domain_attr("src_domain_clone", lonvalue_1D=src_lon, latvalue_1D=src_lat, & 138 bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex) 145 bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex, & 146 mask_1d=src_mask_2D) 139 147 140 148 CALL xios_set_axis_attr("src_axis", n_glo=llm, value=lval) -
XIOS/trunk/src/transformation/grid_transformation.cpp
r872 r873 438 438 std::list<RecvIndexGridDestinationMap>().swap(localIndexToReceiveOnGridDest_); 439 439 std::list<size_t>().swap(nbLocalIndexOnGridDest_); 440 std::list<std::vector<bool> >().swap(localMaskOnGridDest_); 440 441 } 441 442 else … … 458 459 SourceDestinationIndexMap globaIndexWeightFromSrcToDst; 459 460 460 // if (1 < nbAlgos_) 461 // { 462 // // Create a temporary grid destination which contains transformed element of grid destination and 463 // // non-transformed elements fo grid source 464 //// if (nbAgloTransformation != (nbAlgos_-1)) setUpGridDestination(elementPositionInGrid, transType, nbAgloTransformation); 465 // } 461 // Create a temporary grid destination which contains transformed element of grid destination and 462 // non-transformed elements fo grid source 466 463 setUpGridDestination(elementPositionInGrid, transType, nbAgloTransformation); 467 464 … … 512 509 // Recalculate the distribution of grid destination 513 510 CDistributionClient distributionClientDest(client->clientRank, tmpGridDestination_); 514 // CDistributionClient distributionClientDest(client->clientRank, gridDestination_);515 511 CDistributionClient::GlobalLocalDataMap& globalLocalIndexGridDestSendToServer = distributionClientDest.getGlobalLocalDataSendToServer(); 516 const std::vector<int>& localMask = distributionClientDest.getLocalMaskIndexOnClient();517 512 518 513 // Update number of local index on each transformation … … 522 517 std::vector<bool>& tmpMask = localMaskOnGridDest_.back(); 523 518 tmpMask.resize(nbLocalIndex,false); 524 // for (int idx = 0; idx < nbLocalIndex; ++idx)525 // {526 // tmpMask[localMask[idx]] = true;527 // }528 519 529 520 // Find out number of index sent from grid source and number of index received on grid destination … … 708 699 recvTmp[recvRank][realRecvSize].first = globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]; 709 700 recvTmp[recvRank][realRecvSize].second = recvWeightDst(idx); 701 tmpMask[globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]] = true; 710 702 ++realRecvSize; 711 703 }
Note: See TracChangeset
for help on using the changeset viewer.