- Timestamp:
- 03/30/22 13:51:09 (3 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src/node
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
r2311 r2318 179 179 180 180 template <int N> void setData(const CArray<double, N>& _data); 181 void checkSumLike( const double* array, int numElements, bool output ) const; 181 182 static bool dispatchEvent(CEventServer& event); 182 183 static bool isCollectiveEvent(CEventServer& event); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field_impl.hpp
r1973 r2318 20 20 { 21 21 if (check_if_active.isEmpty() || (!check_if_active.isEmpty() && (!check_if_active) || isActive(true))) 22 { 23 if ( info.getLevel()>100 ) 24 { 25 const double* array = _data.dataFirst(); 26 int numElements( _data.numElements() ); 27 checkSumLike( array, numElements, true ); 28 } 22 29 modelToClientSourceFilter_->streamData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 30 } 23 31 } 24 32 else if (instantDataFilter) … … 27 35 } 28 36 CATCH_DUMP_ATTR 37 29 38 30 39 template <int N> … … 35 44 { 36 45 CDataPacket::StatusCode status = clientToModelStoreFilter_->getData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 46 if ( info.getLevel()>100 ) 47 { 48 const double* array = _data.dataFirst(); 49 int numElements( _data.numElements() ); 50 checkSumLike( array, numElements, false ); 51 } 37 52 38 53 if (status == CDataPacket::END_OF_STREAM) … … 47 62 } 48 63 CATCH 64 65 void CField::checkSumLike( const double* array, int numElements, bool output ) const 66 { 67 int rk = CContext::getCurrent()->getIntraCommRank(); 68 int sz = CContext::getCurrent()->getIntraCommSize(); 69 MPI_Comm comm = CContext::getCurrent()->getIntraComm(); 70 71 double localSum( 0. ); 72 double error( 0. ); 73 unsigned long long checkSum( 0 ); 74 for ( int i=0 ; i<numElements ; i++ ) { 75 bool contributes( true ); 76 if ( (!output) && ( !default_value.isEmpty() ) ) 77 { 78 if ( fabs(array[i]) > 0) 79 if ( fabs(array[i]-default_value.getValue())/array[i] < 2e-16 ) 80 contributes = false; 81 } 82 if (contributes) 83 { 84 double y = array[i] - error; 85 double t = localSum + y; 86 error = (t - localSum) - y; 87 localSum = t; 88 89 checkSum += *((unsigned long long*)(&array[i])); 90 checkSum = checkSum%LLONG_MAX; 91 } 92 } 93 94 double globalSum( 0. ); 95 unsigned long long globalCheck( 0 ); 96 97 if ( rk ==0 ) 98 { 99 MPI_Status status; 100 globalSum = localSum; // rank 0 contribution 101 globalCheck = checkSum; 102 for ( int irk = 1 ; irk < sz ; irk++ ) 103 { 104 MPI_Recv( &localSum, 1, MPI_DOUBLE, irk, 0, comm, &status ); 105 double y = localSum - error; 106 double t = globalSum + y; 107 error = (t - globalSum) - y; 108 globalSum = t; 109 110 MPI_Recv( &checkSum, 1, MPI_UNSIGNED_LONG_LONG, irk, 1, comm, &status ); 111 globalCheck += checkSum; 112 globalCheck = globalCheck%LLONG_MAX; 113 } 114 } 115 else 116 { 117 MPI_Send( &localSum, 1, MPI_DOUBLE, 0, 0, comm ); 118 MPI_Send( &checkSum, 1, MPI_UNSIGNED_LONG_LONG, 0, 1, comm ); 119 } 120 121 if ( rk == 0 ) 122 { 123 info(100) << setprecision(DBL_DIG); 124 if (output ) 125 info(100) << "Check Output key field for : " << getId() << ", key = " << globalCheck << ", sum = " << globalSum << endl; 126 else 127 info(100) << "Check Input key field for : " << getId() << ", key = " << globalCheck << ", sum = " << globalSum << endl; 128 info(100) << setprecision(6); 129 } 130 } 131 49 132 } // namespace xios 50 133
Note: See TracChangeset
for help on using the changeset viewer.