Changeset 1642 for XIOS/dev/branch_openmp/src/io
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- Location:
- XIOS/dev/branch_openmp/src/io
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/io/inetcdf4.cpp
r1545 r1642 2 2 #include "netCdfInterface.hpp" 3 3 #include "netCdf_cf_constant.hpp" 4 #include "ep_mpi.hpp" 4 5 5 #include <boost/algorithm/string.hpp> 6 6 … … 23 23 // even if Parallel NetCDF ends up being used. 24 24 if (mpi) 25 CNetCdfInterface::openPar(filename, NC_NOWRITE | NC_MPIIO, to_mpi_comm((*comm)->mpi_comm), to_mpi_info(MPI_INFO_NULL), this->ncidp);25 CNetCdfInterface::openPar(filename, NC_NOWRITE | NC_MPIIO, *comm, EP_INFO_NULL, this->ncidp); 26 26 else 27 27 CNetCdfInterface::open(filename, NC_NOWRITE, this->ncidp); -
XIOS/dev/branch_openmp/src/io/inetcdf4.hpp
r1545 r1642 7 7 #include "array_new.hpp" 8 8 9 #include "mpi _std.hpp"9 #include "mpi.hpp" 10 10 #include "netcdf.hpp" 11 11 -
XIOS/dev/branch_openmp/src/io/nc4_data_input.cpp
r1545 r1642 29 29 30 30 StdSize CNc4DataInput::getFieldNbRecords_(CField* field) 31 TRY 31 32 { 32 33 StdString fieldId = field->getFieldOutputName(); … … 40 41 return 1; 41 42 } 43 CATCH 42 44 43 45 void CNc4DataInput::readFieldData_(CField* field) 46 TRY 44 47 { 45 48 CContext* context = CContext::getCurrent(); … … 55 58 CArray<double,1> fieldData(grid->getWrittenDataSize()); 56 59 if (!field->default_value.isEmpty()) fieldData = field->default_value; 57 #ifdef _usingEP 58 SuperClass::type = ONE_FILE; 59 printf("SuperClass::type = %d\n", SuperClass::type); 60 #endif 61 60 62 61 switch (SuperClass::type) 63 62 { … … 67 66 case ONE_FILE: 68 67 { 69 /*70 std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();71 std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();72 std::vector<int> nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer();73 74 int ssize = nZoomBeginGlobal.size();75 76 std::vector<StdSize> start(ssize);77 std::vector<StdSize> count(ssize);78 79 for (int i = 0; i < ssize; ++i)80 {81 start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1];82 count[i] = nZoomSizeServer[ssize - i - 1];83 }84 */85 86 std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();87 std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();88 std::vector<int> nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer();89 90 68 std::vector<StdSize> start, count; 91 69 … … 95 73 int numElement = axisDomainOrder.numElements(); 96 74 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 97 int idx = nZoomBeginGlobal.size() - 1;98 99 start.reserve( nZoomBeginGlobal.size());100 count.reserve( nZoomBeginGlobal.size());75 int idx = domainList.size() * 2 + axisList.size() - 1; 76 77 start.reserve(idx+1); 78 count.reserve(idx+1); 101 79 102 80 for (int i = numElement - 1; i >= 0; --i) … … 107 85 if ((domain->type) != CDomain::type_attr::unstructured) 108 86 { 109 start.push_back( nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);110 count.push_back( nZoomSizeServer[idx]);87 start.push_back(domain->jbegin); 88 count.push_back(domain->nj); 111 89 } 112 --idx ; 113 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 114 count.push_back(nZoomSizeServer[idx]); 115 --idx ; 90 start.push_back(domain->ibegin); 91 count.push_back(domain->ni); 116 92 --idxDomain; 117 93 } 118 94 else if (1 == axisDomainOrder(i)) 119 95 { 120 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 121 count.push_back(nZoomSizeServer[idx]); 122 --idx; 96 CAxis* axis = CAxis::get(axisList[idxAxis]); 97 start.push_back(axis->begin); 98 count.push_back(axis->n); 99 --idxAxis ; 123 100 } 124 101 else … … 129 106 count.push_back(1); 130 107 } 131 --idx;132 108 } 133 109 } … … 148 124 } 149 125 } 126 CATCH 150 127 151 128 void CNc4DataInput::readFieldAttributes_(CField* field, bool readAttributeValues) 129 TRY 152 130 { 153 131 StdString fieldId = field->getFieldOutputName(); … … 166 144 // Verify the compatibility of dimension of declared grid and real grid in file 167 145 int realGridDim = 1; 168 bool isUnstructuredGrid = SuperClassWriter::isUnstructured(fieldId);146 bool isUnstructuredGrid = ((gridDim < 2) ? false : SuperClassWriter::isUnstructured(fieldId)); 169 147 std::map<StdString, StdSize> dimSizeMap = SuperClassWriter::getDimensions(&fieldId); 170 148 std::list<StdString> dimList = SuperClassWriter::getDimensionsList(&fieldId); … … 191 169 */ 192 170 193 for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 171 // if (!SuperClassWriter::isRectilinear(fieldId)) 172 if (true) 173 { 174 for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 194 175 listDimSize.push_front(*dimSizeMap.find(*it)); 176 } 177 else 178 { 179 std::list<StdString> coords = SuperClassWriter::getCoordinatesIdList(fieldId); 180 std::list<StdString>::const_iterator itCoord = coords.begin(); 181 for (; itCoord != coords.end(); itCoord++) 182 { 183 const StdString& coord = *itCoord; 184 if (SuperClassWriter::hasVariable(coord) && !SuperClassWriter::isTemporal(coord)) 185 { 186 std::map<StdString, StdSize> dimsTmp = SuperClassWriter::getDimensions(&coord); 187 StdString dimNameTmp = dimsTmp.begin()->first; 188 StdSize dimSizeTmp = dimsTmp.begin()->second; 189 listDimSize.push_front(make_pair(coord, dimSizeTmp)); 190 dimSizeMap.erase(dimNameTmp); 191 dimList.remove(dimNameTmp); 192 } 193 } 194 for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 195 listDimSize.push_front(*dimSizeMap.find(*it)); 196 } 195 197 196 198 // Now process domain and axis … … 251 253 } 252 254 } 255 CATCH 253 256 254 257 /*! … … 261 264 void CNc4DataInput::readDomainAttributeValueFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 262 265 int elementPosition, const StdString& fieldId) 266 TRY 263 267 { 264 268 // There are some optional attributes of a domain to retrieve from file // + lon lat? … … 439 443 domain->fillInLonLat(); 440 444 } 445 CATCH 441 446 442 447 /*! … … 449 454 void CNc4DataInput::readDomainAttributesFromFile(CDomain* domain, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 450 455 int elementPosition, const StdString& fieldId) 456 TRY 451 457 { 452 458 // There are some mandatory attributes of a domain to retrieve from file … … 497 503 domain->ni_glo.setValue(itMapNi->second); 498 504 } 499 } 505 506 // determine if coordinates values are present in file 507 if ((CDomain::type_attr::rectilinear == domain->type)) 508 { 509 // Ok, try to read some attributes such as longitude and latitude 510 domain->hasLatInReadFile_ = SuperClassWriter::hasVariable(itMapNj->first); 511 domain->hasLonInReadFile_ = SuperClassWriter::hasVariable(itMapNi->first); 512 } 513 else if ((CDomain::type_attr::curvilinear == domain->type) || (CDomain::type_attr::unstructured == domain->type) ) 514 { 515 StdString latName = this->getLatCoordName(fieldId); 516 domain->hasLatInReadFile_ = SuperClassWriter::hasVariable(latName) ; 517 StdString lonName = this->getLonCoordName(fieldId); 518 domain->hasLonInReadFile_ = SuperClassWriter::hasVariable(lonName) ; 519 StdString boundsLatName = this->getBoundsId(latName); 520 domain->hasBoundsLatInReadFile_ = SuperClassWriter::hasVariable(boundsLatName) ; 521 StdString boundsLonName = this->getBoundsId(lonName); 522 domain->hasBoundsLonInReadFile_ = SuperClassWriter::hasVariable(boundsLonName) ; 523 } 524 } 525 CATCH 500 526 501 527 /*! … … 508 534 void CNc4DataInput::readAxisAttributesFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 509 535 int elementPosition, const StdString& fieldId) 536 TRY 510 537 { 511 538 std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), … … 524 551 axis->n_glo.setValue(itMapN->second); 525 552 } 553 CATCH 526 554 527 555 /*! … … 534 562 void CNc4DataInput::readAxisAttributeValueFromFile(CAxis* axis, std::list<std::pair<StdString, StdSize> >& dimSizeMap, 535 563 int elementPosition, const StdString& fieldId) 564 TRY 536 565 { 537 566 std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), … … 554 583 } 555 584 } 585 CATCH 556 586 557 587 /*! … … 582 612 583 613 void CNc4DataInput::closeFile_(void) 614 TRY 584 615 { 585 616 SuperClassWriter::close(); 586 617 } 618 CATCH 587 619 } // namespace xios -
XIOS/dev/branch_openmp/src/io/nc4_data_input.hpp
r1545 r1642 3 3 4 4 /// XIOS headers /// 5 #include "mpi_std.hpp"6 5 #include "xios_spl.hpp" 7 6 #include "data_input.hpp" -
XIOS/dev/branch_openmp/src/io/nc4_data_output.cpp
r1545 r1642 54 54 55 55 void CNc4DataOutput::writeDomain_(CDomain* domain) 56 TRY 56 57 { 57 58 StdString lonName,latName ; … … 154 155 */ 155 156 156 CArray< size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer;157 CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 157 158 int nbWritten = indexToWrite.numElements(); 158 159 CArray<double,1> writtenLat, writtenLon; … … 166 167 for (int idx = 0; idx < nbWritten; ++idx) 167 168 { 168 if (idx < domain->latvalue.numElements())169 170 writtenLat(idx) = domain->latvalue(indexToWrite(idx));171 writtenLon(idx) = domain->lonvalue(indexToWrite(idx));172 173 174 175 writtenLat(idx) = 0.;176 writtenLon(idx) = 0.;177 169 if (indexToWrite(idx) < 0) 170 { 171 writtenLat(idx) = -1.; // hole 172 writtenLon(idx) = -1.; 173 } 174 else 175 { 176 writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 177 writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 178 } 178 179 } 179 180 180 181 181 if (domain->hasBounds) … … 189 189 for (int nv = 0; nv < nvertex; ++nv) 190 190 { 191 if (idx < boundslat.columns()) 192 { 191 if (indexToWrite(idx) < 0) 192 { 193 writtenBndsLat(nv, idx) = -1.; // hole 194 writtenBndsLon(nv, idx) = -1.; 195 } 196 else 197 { 193 198 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 194 199 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 195 } 196 else 197 { 198 writtenBndsLat(nv, idx) = 0.; 199 writtenBndsLon(nv, idx) = 0.; 200 } 200 } 201 201 } 202 202 } … … 208 208 for (int idx = 0; idx < nbWritten; ++idx) 209 209 { 210 if (i dx < domain->areavalue.numElements())211 writtenArea(idx) = domain->areavalue(indexToWrite(idx));210 if (indexToWrite(idx) < 0) 211 writtenArea(idx) = -1.; 212 212 else 213 writtenArea(idx) = 0.;213 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 214 214 } 215 215 } … … 221 221 case (MULTI_FILE) : 222 222 { 223 // if (domain->isEmpty()) return;224 225 if (server->intraCommSize > 1)226 {227 // SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue());228 // SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue());229 }230 231 223 switch (domain->type) 232 224 { … … 248 240 else bounds_latid = "bounds_"+latName+appendDomid; 249 241 250 SuperClassWriter::addDimension(dimXid, domain-> zoom_ni);251 SuperClassWriter::addDimension(dimYid, domain-> zoom_nj);242 SuperClassWriter::addDimension(dimXid, domain->ni); 243 SuperClassWriter::addDimension(dimYid, domain->nj); 252 244 253 245 if (domain->hasBounds) … … 256 248 if (server->intraCommSize > 1) 257 249 { 258 this->writeLocalAttributes(domain-> zoom_ibegin,259 domain-> zoom_ni,260 domain-> zoom_jbegin,261 domain-> zoom_nj,250 this->writeLocalAttributes(domain->ibegin, 251 domain->ni, 252 domain->jbegin, 253 domain->nj, 262 254 appendDomid); 263 255 264 256 if (singleDomain) 265 257 this->writeLocalAttributes_IOIPSL(dimXid, dimYid, 266 domain-> zoom_ibegin,267 domain-> zoom_ni,268 domain-> zoom_jbegin,269 domain-> zoom_nj,258 domain->ibegin, 259 domain->ni, 260 domain->jbegin, 261 domain->nj, 270 262 domain->ni_glo,domain->nj_glo, 271 263 server->intraCommRank,server->intraCommSize); … … 340 332 break; 341 333 case CDomain::type_attr::rectilinear : 342 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain-> zoom_ni)) ;334 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->ni)) ; 343 335 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 344 CArray<double,1> lon = writtenLon(Range(0,domain-> zoom_ni-1)) ;336 CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)) ; 345 337 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 346 338 break; … … 365 357 case (ONE_FILE) : 366 358 { 367 SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni);368 SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj);359 SuperClassWriter::addDimension(dimXid, domain->ni_glo); 360 SuperClassWriter::addDimension(dimYid, domain->nj_glo); 369 361 370 362 if (domain->hasBounds) … … 434 426 std::vector<StdSize> start(2) ; 435 427 std::vector<StdSize> count(2) ; 436 if (domain->isEmpty()) 428 // Comment out: it is not working for a hole 429 // if (domain->isEmpty()) 430 // { 431 // start[0]=0 ; start[1]=0 ; 432 // count[0]=0 ; count[1]=0 ; 433 // } 434 // else 437 435 { 438 start[0]=0 ; start[1]=0 ; 439 count[0]=0 ; count[1]=0 ; 440 } 441 else 442 { 443 start[1]=domain->zoom_ibegin-domain->global_zoom_ibegin; 444 start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; 445 count[1]=domain->zoom_ni ; count[0]=domain->zoom_nj ; 436 start[1]=domain->ibegin; 437 start[0]=domain->jbegin; 438 count[1]=domain->ni ; count[0]=domain->nj ; 446 439 } 447 440 … … 468 461 else 469 462 { 470 start[0]=domain-> zoom_jbegin-domain->global_zoom_jbegin;471 count[0]=domain-> zoom_nj;472 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain-> zoom_ni));463 start[0]=domain->jbegin; 464 count[0]=domain->nj; 465 CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->ni)); 473 466 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 474 467 475 start[0]=domain-> zoom_ibegin-domain->global_zoom_ibegin;476 count[0]=domain-> zoom_ni;477 CArray<double,1> lon = writtenLon(Range(0,domain-> zoom_ni-1));468 start[0]=domain->ibegin; 469 count[0]=domain->ni; 470 CArray<double,1> lon = writtenLon(Range(0,domain->ni-1)); 478 471 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 479 472 } … … 495 488 { 496 489 start[2] = 0; 497 start[1] = domain-> zoom_ibegin - domain->global_zoom_ibegin;498 start[0] = domain-> zoom_jbegin - domain->global_zoom_jbegin;490 start[1] = domain->ibegin; 491 start[0] = domain->jbegin; 499 492 count[2] = domain->nvertex; 500 count[1] = domain-> zoom_ni;501 count[0] = domain-> zoom_nj;493 count[1] = domain->ni; 494 count[0] = domain->nj; 502 495 } 503 496 … … 518 511 else 519 512 { 520 start[1] = domain-> zoom_ibegin - domain->global_zoom_ibegin;521 start[0] = domain-> zoom_jbegin - domain->global_zoom_jbegin;522 count[1] = domain-> zoom_ni;523 count[0] = domain-> zoom_nj;513 start[1] = domain->ibegin; 514 start[0] = domain->jbegin; 515 count[1] = domain->ni; 516 count[0] = domain->nj; 524 517 } 525 518 … … 548 541 domain->addRelFile(this->filename); 549 542 } 543 CATCH 550 544 551 545 //-------------------------------------------------------------- … … 786 780 else 787 781 { 788 startNodes[0] = domain-> zoom_ibegin-domain->global_zoom_ibegin;789 countNodes[0] = domain-> zoom_ni ;782 startNodes[0] = domain->ibegin; 783 countNodes[0] = domain->ni ; 790 784 } 791 785 … … 809 803 else 810 804 { 811 startEdges[0] = domain-> zoom_ibegin-domain->global_zoom_ibegin;812 countEdges[0] = domain-> zoom_ni;805 startEdges[0] = domain->ibegin; 806 countEdges[0] = domain->ni; 813 807 startNodes[0] = domain->mesh->node_start; 814 808 countNodes[0] = domain->mesh->node_count; 815 startEdgeNodes[0] = domain-> zoom_ibegin-domain->global_zoom_ibegin;809 startEdgeNodes[0] = domain->ibegin; 816 810 startEdgeNodes[1] = 0; 817 countEdgeNodes[0] = domain-> zoom_ni;811 countEdgeNodes[0] = domain->ni; 818 812 countEdgeNodes[1] = 2; 819 813 } … … 845 839 else 846 840 { 847 startFaces[0] = domain-> zoom_ibegin-domain->global_zoom_ibegin;848 countFaces[0] = domain-> zoom_ni ;841 startFaces[0] = domain->ibegin; 842 countFaces[0] = domain->ni ; 849 843 startNodes[0] = domain->mesh->node_start; 850 844 countNodes[0] = domain->mesh->node_count; … … 859 853 countEdgeFaces[0] = domain->mesh->edge_count; 860 854 countEdgeFaces[1]= 2; 861 startFaceConctv[0] = domain-> zoom_ibegin-domain->global_zoom_ibegin;855 startFaceConctv[0] = domain->ibegin; 862 856 startFaceConctv[1] = 0; 863 countFaceConctv[0] = domain-> zoom_ni;857 countFaceConctv[0] = domain->ni; 864 858 countFaceConctv[1] = domain->nvertex; 865 859 } … … 883 877 case (MULTI_FILE) : 884 878 { 879 ERROR("CNc4DataOutput::writeDomain(domain)", 880 << "[ type = multiple_file ]" 881 << " is not yet implemented for UGRID files !"); 885 882 break; 886 883 } … … 948 945 int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 949 946 950 CArray< size_t, 1>& indexToWrite = domain->localIndexToWriteOnServer;947 CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; 951 948 int nbWritten = indexToWrite.numElements(); 952 949 CArray<double,1> writtenLat, writtenLon; … … 960 957 for (int idx = 0; idx < nbWritten; ++idx) 961 958 { 962 if (i dx < domain->latvalue.numElements())963 {964 writtenLat(idx) = domain->latvalue(indexToWrite(idx));965 writtenLon(idx) = domain->lonvalue(indexToWrite(idx));966 }967 else968 {969 writtenLat(idx) = 0.;970 writtenLon(idx) = 0.;971 }959 if (indexToWrite(idx) < 0) 960 { 961 writtenLat(idx) = -1.; 962 writtenLon(idx) = -1.; 963 } 964 else 965 { 966 writtenLat(idx) = domain->latvalue(indexToWrite(idx)); 967 writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); 968 } 972 969 } 973 970 } … … 984 981 for (int nv = 0; nv < nvertex; ++nv) 985 982 { 986 if (idx < boundslat.columns()) 983 if (indexToWrite(idx) < 0) 984 { 985 writtenBndsLat(nv, idx) = -1.; 986 writtenBndsLon(nv, idx) = -1.; 987 } 988 else 987 989 { 988 990 writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); 989 991 writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); 990 }991 else992 {993 writtenBndsLat(nv, idx) = 0.;994 writtenBndsLon(nv, idx) = 0.;995 992 } 996 993 } … … 1003 1000 for (int idx = 0; idx < nbWritten; ++idx) 1004 1001 { 1005 if (idx < domain->areavalue.numElements())1006 writtenArea(idx) = domain->areavalue(indexToWrite(idx));1007 1008 writtenArea(idx) = 0.;1002 if (indexToWrite(idx) < 0) 1003 writtenArea(idx) = -1.; 1004 else 1005 writtenArea(idx) = domain->areavalue(indexToWrite(idx)); 1009 1006 } 1010 1007 } … … 1017 1014 { 1018 1015 dim0.push_back(dimXid); 1019 SuperClassWriter::addDimension(dimXid, domain-> zoom_ni);1016 SuperClassWriter::addDimension(dimXid, domain->ni); 1020 1017 1021 1018 lonid = lonName+appendDomid; … … 1130 1127 else 1131 1128 { 1132 start[0]=domain-> zoom_ibegin - domain->global_zoom_ibegin;1133 count[0]=domain-> zoom_ni;1134 startBounds[0]=domain-> zoom_ibegin-domain->global_zoom_ibegin;1129 start[0]=domain->ibegin; 1130 count[0]=domain->ni; 1131 startBounds[0]=domain->ibegin; 1135 1132 startBounds[1]=0 ; 1136 countBounds[0]=domain-> zoom_ni;1133 countBounds[0]=domain->ni; 1137 1134 countBounds[1]=nvertex ; 1138 1135 } … … 1183 1180 axis->computeWrittenCompressedIndex(comm_file); 1184 1181 1185 int zoom_size = (MULTI_FILE == SuperClass::type) ? axis->zoom_n.getValue() 1186 : axis->global_zoom_n.getValue(); 1187 1188 int zoom_count = axis->zoom_n; 1189 int zoom_begin = axis->zoom_begin; 1190 // int zoom_begin = (MULTI_FILE == SuperClass::type) ? axis->global_zoom_begin 1191 // : axis->zoom_begin; 1192 1193 if ((0 == axis->zoom_n) && (MULTI_FILE == SuperClass::type)) return; 1182 int size = (MULTI_FILE == SuperClass::type) ? axis->n.getValue() 1183 : axis->n_glo.getValue(); 1184 1185 if ((0 == axis->n) && (MULTI_FILE == SuperClass::type)) return; 1194 1186 1195 1187 std::vector<StdString> dims; … … 1210 1202 if (axis->dim_name.isEmpty()) axisDim = axisid; 1211 1203 else axisDim=axis->dim_name.getValue(); 1212 SuperClassWriter::addDimension(axisDim, zoom_size);1204 SuperClassWriter::addDimension(axisDim, size); 1213 1205 dims.push_back(axisDim); 1214 1206 … … 1288 1280 SuperClassWriter::definition_end(); 1289 1281 1290 CArray< size_t, 1>& indexToWrite = axis->localIndexToWriteOnServer;1282 CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; 1291 1283 int nbWritten = indexToWrite.numElements(); 1292 1284 CArray<double,1> axis_value(indexToWrite.numElements()); … … 1295 1287 for (int i = 0; i < nbWritten; i++) 1296 1288 { 1297 if (i < axis->value.numElements()) 1289 if (indexToWrite(i) < 0) 1290 axis_value(i) = -1; // Some value in case of a hole 1291 else 1298 1292 axis_value(i) = axis->value(indexToWrite(i)); 1299 else1300 axis_value(i) = 0.;1301 1293 } 1302 1294 } … … 1308 1300 for (int i = 0; i < nbWritten; i++) 1309 1301 { 1310 if (i < axis->label.numElements()) 1302 if (indexToWrite(i) < 0) 1303 axis_label(i) = boost::lexical_cast<string>(-1); // Some value in case of a hole 1304 else 1311 1305 axis_label(i) = axis->label(indexToWrite(i)); 1312 else1313 axis_label(i) = boost::lexical_cast<string>(0); // Write 0 as a label1314 1306 } 1315 1307 } … … 1329 1321 for (int i = 0; i < nbWritten; ++i) 1330 1322 { 1331 if (i < axis->bounds.columns()) 1323 if (indexToWrite(i) < 0) 1324 { 1325 axis_bounds(0, i) = -1.; // Some value in case of a hole 1326 axis_bounds(1, i) = -1.; 1327 } 1328 else 1332 1329 { 1333 1330 axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 1334 1331 axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 1335 }1336 else1337 {1338 axis_bounds(0, i) = 0.;1339 axis_bounds(1, i) = 0.;1340 1341 1332 } 1342 1333 } … … 1354 1345 std::vector<StdSize> start(1), startBounds(2) ; 1355 1346 std::vector<StdSize> count(1), countBounds(2) ; 1356 start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin;1357 count[0] = countBounds[0] = zoom_count; // zoom_size1347 start[0] = startBounds[0] = axis->begin; 1348 count[0] = countBounds[0] = axis->n; 1358 1349 startBounds[1] = 0; 1359 1350 countBounds[1] = 2; … … 1369 1360 for (int i = 0; i < nbWritten; ++i) 1370 1361 { 1371 if (i < axis->bounds.columns()) 1362 if (indexToWrite(i) < 0) 1363 { 1364 axis_bounds(0, i) = -1.; 1365 axis_bounds(1, i) = -1.; 1366 } 1367 else 1372 1368 { 1373 1369 axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); 1374 1370 axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); 1375 }1376 else1377 {1378 axis_bounds(0, i) = 0.;1379 axis_bounds(1, i) = 0.;1380 1371 } 1381 1372 } … … 2512 2503 if ( wtimeData) 2513 2504 { 2514 // SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);2515 // SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);2516 2505 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 2517 2506 SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); … … 2519 2508 if (wtimeCounter) 2520 2509 { 2521 // SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);2522 // if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);2523 2510 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); 2524 2511 if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); … … 2530 2517 case (ONE_FILE) : 2531 2518 { 2532 const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal();2533 const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer();2534 const std::vector<int>& nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer();2535 2519 2536 2520 std::vector<StdSize> start, count; … … 2550 2534 int numElement = axisDomainOrder.numElements(); 2551 2535 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2552 int idx = nZoomBeginGlobal.size() - 1; 2553 2554 start.reserve(nZoomBeginGlobal.size()); 2555 count.reserve(nZoomBeginGlobal.size()); 2556 2536 int idx = domainList.size() * 2 + axisList.size() - 1; 2537 2538 start.reserve(idx+1); 2539 count.reserve(idx+1); 2557 2540 2558 2541 for (int i = numElement - 1; i >= 0; --i) … … 2572 2555 if ((domain->type) != CDomain::type_attr::unstructured) 2573 2556 { 2574 start.push_back( nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);2575 count.push_back( nZoomSizeServer[idx]);2557 start.push_back(domain->jbegin); 2558 count.push_back(domain->nj); 2576 2559 } 2577 2560 --idx; 2578 start.push_back( nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);2579 count.push_back( nZoomSizeServer[idx]);2561 start.push_back(domain->ibegin); 2562 count.push_back(domain->ni); 2580 2563 --idx; 2581 2564 } … … 2593 2576 else 2594 2577 { 2595 start.push_back( nZoomBeginServer[idx] - nZoomBeginGlobal[idx]);2596 count.push_back( nZoomSizeServer[idx]);2578 start.push_back(axis->begin); 2579 count.push_back(axis->n); 2597 2580 } 2598 2599 2581 --idxAxis; 2600 2582 --idx; … … 2610 2592 int numElement = axisDomainOrder.numElements(); 2611 2593 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2612 int idx = domainList.size() * 2 + axisList.size() - 1; // nZoomBeginGlobal.size() - 1;2613 2614 start.reserve( nZoomBeginGlobal.size());2615 count.reserve( nZoomBeginGlobal.size());2594 int idx = domainList.size() * 2 + axisList.size() - 1; 2595 2596 start.reserve(idx+1); 2597 count.reserve(idx+1); 2616 2598 2617 2599 for (int i = numElement - 1; i >= 0; --i) … … 2622 2604 if ((domain->type) != CDomain::type_attr::unstructured) 2623 2605 { 2624 start.push_back(domain-> zoom_jbegin - domain->global_zoom_jbegin);2625 count.push_back(domain-> zoom_nj);2606 start.push_back(domain->jbegin); 2607 count.push_back(domain->nj); 2626 2608 } 2627 2609 --idx ; 2628 2610 2629 start.push_back(domain-> zoom_ibegin - domain->global_zoom_ibegin);2630 count.push_back(domain-> zoom_ni);2611 start.push_back(domain->ibegin); 2612 count.push_back(domain->ni); 2631 2613 --idx ; 2632 2614 --idxDomain; … … 2635 2617 { 2636 2618 CAxis* axis = CAxis::get(axisList[idxAxis]); 2637 start.push_back(axis-> zoom_begin - axis->global_zoom_begin);2638 count.push_back(axis-> zoom_n);2619 start.push_back(axis->begin); 2620 count.push_back(axis->n); 2639 2621 --idx; 2640 2622 --idxAxis; … … 2662 2644 if ( wtimeData) 2663 2645 { 2664 // SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep() - 1);2665 // SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1);2666 2646 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); 2667 2647 SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); … … 2669 2649 if (wtimeCounter) 2670 2650 { 2671 // SuperClassWriter::writeData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1);2672 // if (timeCounterType!=record) SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1);2673 2651 SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); 2674 2652 if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); -
XIOS/dev/branch_openmp/src/io/nc4_data_output.hpp
r1545 r1642 4 4 /// XIOS headers /// 5 5 #include "xios_spl.hpp" 6 #include "mpi_std.hpp"7 6 #include "onetcdf4.hpp" 8 7 #include "data_output.hpp" -
XIOS/dev/branch_openmp/src/io/netCdfInterface.cpp
r1555 r1642 22 22 int CNetCdfInterface::create(const StdString& fileName, int cMode, int& ncId) 23 23 { 24 int status; 25 #pragma omp critical (_netcdf) 26 { 27 info(100)<<"start nc_create"<<std::endl; 28 status = nc_create(fileName.c_str(), cMode, &ncId); 29 info(100)<<"end nc_create"<<std::endl; 30 } 24 int status = nc_create(fileName.c_str(), cMode, &ncId); 31 25 if (NC_NOERR != status) 32 26 { … … 53 47 \return Status code 54 48 */ 55 int CNetCdfInterface::createPar(const StdString& fileName, int cMode, MPI_Comm comm, MPI_Info info, int& ncId) 56 { 57 int status = xios::nc_create_par(fileName.c_str(), cMode, comm, to_mpi_info(MPI_INFO_NULL), &ncId); 58 49 int CNetCdfInterface::createPar(const StdString& fileName, int cMode, ep_lib::MPI_Comm comm, ep_lib::MPI_Info info, int& ncId) 50 { 51 #ifdef _usingMPI 52 int status = xios::nc_create_par(fileName.c_str(), cMode, comm, info, &ncId); 53 #elif _usingEP 54 int status = xios::nc_create_par(fileName.c_str(), cMode, to_mpi_comm(comm->mpi_comm), to_mpi_info(info), &ncId); 55 #endif 59 56 if (NC_NOERR != status) 60 57 { … … 81 78 int CNetCdfInterface::open(const StdString& fileName, int oMode, int& ncId) 82 79 { 83 int status; 84 #pragma omp critical (_netcdf) 85 { 86 info(100)<<"start nc_open"<<std::endl; 87 status = nc_open(fileName.c_str(), oMode, &ncId); 88 info(100)<<"end nc_open"<<std::endl; 89 } 80 int status = nc_open(fileName.c_str(), oMode, &ncId); 90 81 if (NC_NOERR != status) 91 82 { … … 113 104 \return Status code 114 105 */ 115 int CNetCdfInterface::openPar(const StdString& fileName, int oMode, MPI_Comm comm, MPI_Info info, int& ncId) 116 { 117 int status = xios::nc_open_par(fileName.c_str(), oMode, comm, to_mpi_info(MPI_INFO_NULL), &ncId); 118 106 int CNetCdfInterface::openPar(const StdString& fileName, int oMode, ep_lib::MPI_Comm comm, ep_lib::MPI_Info info, int& ncId) 107 { 108 #ifdef _usingMPI 109 int status = xios::nc_open_par(fileName.c_str(), oMode, comm, info, &ncId); 110 #elif _usingEP 111 int status = xios::nc_open_par(fileName.c_str(), oMode, to_mpi_comm(comm->mpi_comm), to_mpi_info(info), &ncId); 112 #endif 119 113 if (NC_NOERR != status) 120 114 { … … 139 133 int CNetCdfInterface::close(int ncId) 140 134 { 141 int status = NC_NOERR; 142 #pragma omp critical (_netcdf) 143 { 144 info(100)<<"start nc_close"<<std::endl; 145 status = nc_close(ncId); 146 info(100)<<"end nc_close"<<std::endl; 147 } 148 135 int status = nc_close(ncId); 149 136 if (NC_NOERR != status) 150 137 { … … 168 155 int CNetCdfInterface::reDef(int ncId) 169 156 { 170 int status; 171 #pragma omp critical (_netcdf) 172 { 173 info(100)<<"start nc_reDef"<<std::endl; 174 status = nc_redef(ncId); 175 info(100)<<"end nc_reDef"<<std::endl; 176 } 177 157 int status = nc_redef(ncId); 178 158 if (NC_NOERR != status) 179 159 { … … 197 177 int CNetCdfInterface::endDef(int ncId) 198 178 { 199 int status; 200 #pragma omp critical (_netcdf) 201 { 202 info(100)<<"start nc_enddef"<<std::endl; 203 status = nc_enddef(ncId); 204 info(100)<<"end nc_enddef"<<std::endl; 205 } 179 int status = nc_enddef(ncId); 206 180 if (NC_NOERR != status) 207 181 { … … 228 202 int CNetCdfInterface::inqNcId(int ncid, const StdString& grpName, int& grpId) 229 203 { 230 int status; 231 #pragma omp critical (_netcdf) 232 { 233 info(100)<<"start nc_inq_ncid"<<std::endl; 234 status = nc_inq_ncid(ncid, grpName.c_str(), &grpId); 235 info(100)<<"end nc_inq_ncid"<<std::endl; 236 } 237 204 int status = nc_inq_ncid(ncid, grpName.c_str(), &grpId); 238 205 if (NC_NOERR != status) 239 206 { … … 261 228 int CNetCdfInterface::inqVarId(int ncid, const StdString& varName, int& varId) 262 229 { 263 int status; 264 #pragma omp critical (_netcdf) 265 { 266 info(100)<<"start nc_inq_varid"<<std::endl; 267 status = nc_inq_varid(ncid, varName.c_str(), &varId); 268 info(100)<<"end nc_inq_varid"<<std::endl; 269 } 230 int status = nc_inq_varid(ncid, varName.c_str(), &varId); 270 231 if (NC_NOERR != status) 271 232 { … … 292 253 int CNetCdfInterface::inqDimId(int ncid, const StdString& dimName, int& dimId) 293 254 { 294 int status; 295 #pragma omp critical (_netcdf) 296 { 297 info(100)<<"start nc_inq_dimid"<<std::endl; 298 status = nc_inq_dimid(ncid, dimName.c_str(), &dimId); 299 info(100)<<"end nc_inq_dimid"<<std::endl; 300 } 301 255 int status = nc_inq_dimid(ncid, dimName.c_str(), &dimId); 302 256 if (NC_NOERR != status) 303 257 { … … 325 279 { 326 280 char varNameBuff[NC_MAX_NAME + 1]; 327 int status; 328 #pragma omp critical (_netcdf) 329 { 330 info(100)<<"start nc_inq_varname"<<std::endl; 331 status = nc_inq_varname(ncid, varId, varNameBuff); 332 info(100)<<"end nc_inq_varname"<<std::endl; 333 } 281 int status = nc_inq_varname(ncid, varId, varNameBuff); 334 282 if (NC_NOERR != status) 335 283 { … … 355 303 int CNetCdfInterface::inqUnLimDim(int ncid, int& dimId) 356 304 { 357 int status; 358 #pragma omp critical (_netcdf) 359 { 360 info(100)<<"start nc_inq_unlimdim"<<std::endl; 361 status = nc_inq_unlimdim(ncid, &dimId); 362 info(100)<<"end nc_inq_unlimdim"<<std::endl; 363 } 305 int status = nc_inq_unlimdim(ncid, &dimId); 364 306 if (NC_NOERR != status) 365 307 { … … 387 329 { 388 330 char fullNameIn[NC_MAX_NAME + 1]; 389 int status; 390 #pragma omp critical (_netcdf) 391 { 392 info(100)<<"start nc_inq_dimname"<<std::endl; 393 status = nc_inq_dimname(ncid, dimId, fullNameIn); 394 info(100)<<"end nc_inq_dimname"<<std::endl; 395 } 331 int status = nc_inq_dimname(ncid, dimId, fullNameIn); 396 332 if (NC_NOERR != status) 397 333 { … … 418 354 int CNetCdfInterface::inqDimLen(int ncid, int dimId, StdSize& dimLen) 419 355 { 420 int status; 421 #pragma omp critical (_netcdf) 422 { 423 info(100)<<"start nc_inq_dimlen"<<std::endl; 424 status = nc_inq_dimlen(ncid, dimId, &dimLen); 425 info(100)<<"end nc_inq_dimlen"<<std::endl; 426 } 356 int status = nc_inq_dimlen(ncid, dimId, &dimLen); 427 357 if (NC_NOERR != status) 428 358 { … … 449 379 int CNetCdfInterface::inqVarNDims(int ncid, int varId, int& nDims) 450 380 { 451 int status; 452 #pragma omp critical (_netcdf) 453 { 454 info(100)<<"start nc_inq_varndims"<<std::endl; 455 status = nc_inq_varndims(ncid, varId, &nDims); 456 info(100)<<"end nc_inq_varndims"<<std::endl; 457 } 381 int status = nc_inq_varndims(ncid, varId, &nDims); 458 382 if (NC_NOERR != status) 459 383 { … … 480 404 int CNetCdfInterface::inqVarDimId(int ncid, int varId, int* dimIds) 481 405 { 482 int status; 483 #pragma omp critical (_netcdf) 484 { 485 info(100)<<"start nc_inq_vardimid"<<std::endl; 486 status = nc_inq_vardimid(ncid, varId, dimIds); 487 info(100)<<"end nc_inq_vardimid"<<std::endl; 488 } 406 int status = nc_inq_vardimid(ncid, varId, dimIds); 489 407 if (NC_NOERR != status) 490 408 { … … 512 430 int CNetCdfInterface::inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents) 513 431 { 514 int status; 515 #pragma omp critical (_netcdf) 516 { 517 info(100)<<"start nc_inq_dimids"<<std::endl; 518 status = nc_inq_dimids(ncid, &nDims, dimIds, includeParents); 519 info(100)<<"end nc_inq_dimids"<<std::endl; 520 } 432 int status = nc_inq_dimids(ncid, &nDims, dimIds, includeParents); 521 433 if (NC_NOERR != status) 522 434 { … … 545 457 StdSize strlen = 0; 546 458 std::vector<char> buff; 547 int status; 548 #pragma omp critical (_netcdf) 549 { 550 info(100)<<"start nc_inq_grpname_full"<<std::endl; 551 status = nc_inq_grpname_full(ncid, &strlen, NULL); 552 info(100)<<"end nc_inq_grpname_full"<<std::endl; 553 554 if (NC_NOERR == status) 555 { 556 buff.resize(strlen + 1); 557 status = nc_inq_grpname_full(ncid, NULL, &buff[0]); 558 } 559 info(100)<<"start nc_inq_grpname_full"<<std::endl; 560 } 459 int status = nc_inq_grpname_full(ncid, &strlen, NULL); 460 if (NC_NOERR == status) 461 { 462 buff.resize(strlen + 1); 463 status = nc_inq_grpname_full(ncid, NULL, &buff[0]); 464 } 465 561 466 if (NC_NOERR != status) 562 467 { … … 585 490 int CNetCdfInterface::inqGrpIds(int ncid, int& numgrps, int* ncids) 586 491 { 587 int status; 588 #pragma omp critical (_netcdf) 589 { 590 info(100)<<"start nc_inq_grps"<<std::endl; 591 status = nc_inq_grps(ncid, &numgrps, ncids); 592 info(100)<<"end nc_inq_grps"<<std::endl; 593 } 492 int status = nc_inq_grps(ncid, &numgrps, ncids); 594 493 if (NC_NOERR != status) 595 494 { … … 616 515 int CNetCdfInterface::inqVarIds(int ncid, int& nvars, int* varids) 617 516 { 618 int status; 619 #pragma omp critical (_netcdf) 620 { 621 info(100)<<"start nc_inq_varids"<<std::endl; 622 status = nc_inq_varids(ncid, &nvars, varids); 623 info(100)<<"end nc_inq_varids"<<std::endl; 624 } 517 int status = nc_inq_varids(ncid, &nvars, varids); 625 518 if (NC_NOERR != status) 626 519 { … … 649 542 int CNetCdfInterface::inqAtt(int ncid, int varid, const StdString& name, nc_type& type, size_t& len) 650 543 { 651 int status; 652 #pragma omp critical (_netcdf) 653 { 654 info(100)<<"start nc_inq_att"<<std::endl; 655 status = nc_inq_att(ncid, varid, name.c_str(), &type, &len); 656 info(100)<<"end nc_inq_att"<<std::endl; 657 } 658 544 int status = nc_inq_att(ncid, varid, name.c_str(), &type, &len); 659 545 if (NC_NOERR != status) 660 546 { … … 680 566 int CNetCdfInterface::inqNAtts(int ncid, int& ngatts) 681 567 { 682 int status; 683 #pragma omp critical (_netcdf) 684 { 685 info(100)<<"start nc_inq_natts"<<std::endl; 686 status = nc_inq_natts(ncid, &ngatts); 687 info(100)<<"end nc_inq_natts"<<std::endl; 688 } 568 int status = nc_inq_natts(ncid, &ngatts); 689 569 if (NC_NOERR != status) 690 570 { … … 711 591 int CNetCdfInterface::inqVarNAtts(int ncid, int varid, int& natts) 712 592 { 713 int status; 714 #pragma omp critical (_netcdf) 715 { 716 info(100)<<"start nc_inq_varnatts"<<std::endl; 717 status = nc_inq_varnatts(ncid, varid, &natts); 718 info(100)<<"end nc_inq_varnatts"<<std::endl; 719 } 593 int status = nc_inq_varnatts(ncid, varid, &natts); 720 594 if (NC_NOERR != status) 721 595 { … … 738 612 { 739 613 std::vector<char> attName(NC_MAX_NAME + 1,' '); 740 int status; 741 #pragma omp critical (_netcdf) 742 { 743 info(100)<<"start nc_inq_attname"<<std::endl; 744 status = nc_inq_attname(ncid, varid, attnum, &attName[0]); 745 info(100)<<"end nc_inq_attname"<<std::endl; 746 } 614 int status = nc_inq_attname(ncid, varid, attnum, &attName[0]); 747 615 if (NC_NOERR != status) 748 616 { … … 775 643 int CNetCdfInterface::defGrp(int parentNcid, const StdString& grpName, int& grpId) 776 644 { 777 int status; 778 #pragma omp critical (_netcdf) 779 { 780 info(100)<<"start nc_def_grp"<<std::endl; 781 status = nc_def_grp(parentNcid, grpName.c_str(), &grpId); 782 info(100)<<"end nc_def_grp"<<std::endl; 783 } 645 int status = nc_def_grp(parentNcid, grpName.c_str(), &grpId); 784 646 if (NC_NOERR != status) 785 647 { … … 806 668 int CNetCdfInterface::defDim(int ncid, const StdString& dimName, StdSize dimLen, int& dimId) 807 669 { 808 int status; 809 #pragma omp critical (_netcdf) 810 { 811 info(100)<<"start nc_def_dim"<<std::endl; 812 status = nc_def_dim(ncid, dimName.c_str(), dimLen, &dimId); 813 info(100)<<"end nc_def_dim"<<std::endl; 814 } 670 int status = nc_def_dim(ncid, dimName.c_str(), dimLen, &dimId); 815 671 if (NC_NOERR != status) 816 672 { … … 843 699 int nDims, const int dimIds[], int& varId) 844 700 { 845 int status; 846 #pragma omp critical (_netcdf) 847 { 848 info(100)<<"start nc_def_var"<<std::endl; 849 status = nc_def_var(ncid, varName.c_str(), xtype, nDims, dimIds, &varId); 850 info(100)<<"end nc_def_var"<<std::endl; 851 } 701 int status = nc_def_var(ncid, varName.c_str(), xtype, nDims, dimIds, &varId); 852 702 if (NC_NOERR != status) 853 703 { … … 878 728 int CNetCdfInterface::defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]) 879 729 { 880 int status; 881 #pragma omp critical (_netcdf) 882 { 883 info(100)<<"start nc_def_var_chunking"<<std::endl; 884 status = nc_def_var_chunking(ncid, varId, storage, chunkSize); 885 info(100)<<"end nc_def_var_chunking"<<std::endl; 886 } 730 int status = nc_def_var_chunking(ncid, varId, storage, chunkSize); 887 731 if (NC_NOERR != status) 888 732 { … … 912 756 913 757 if (compressionLevel == 0) return NC_NOERR ; 914 int status; 915 #pragma omp critical (_netcdf) 916 { 917 info(100)<<"start nc_def_var_deflate"<<std::endl; 918 status = nc_def_var_deflate(ncid, varId, (compressionLevel > 0), (compressionLevel > 0), compressionLevel); 919 info(100)<<"end nc_def_var_deflate"<<std::endl; 920 } 758 int status = nc_def_var_deflate(ncid, varId, (compressionLevel > 0), (compressionLevel > 0), compressionLevel); 921 759 if (NC_NOERR != status) 922 760 { … … 944 782 { 945 783 int old_fill_mode; 946 int status; 947 #pragma omp critical (_netcdf) 948 { 949 info(100)<<"start nc_set_fill"<<std::endl; 950 status = nc_set_fill(ncid, fill ? NC_FILL: NC_NOFILL, &old_fill_mode); 951 info(100)<<"end nc_set_fill"<<std::endl; 952 } 784 int status = nc_set_fill(ncid, fill ? NC_FILL: NC_NOFILL, &old_fill_mode); 953 785 if (NC_NOERR != status) 954 786 { … … 977 809 int CNetCdfInterface::defVarFill(int ncid, int varId, int noFill, void* fillValue) 978 810 { 979 int status; 980 #pragma omp critical (_netcdf) 981 { 982 info(100)<<"start nc_def_var_fill"<<std::endl; 983 status = nc_def_var_fill(ncid, varId, noFill, fillValue); 984 info(100)<<"end nc_def_var_fill"<<std::endl; 985 } 811 int status = nc_def_var_fill(ncid, varId, noFill, fillValue); 986 812 if (NC_NOERR != status) 987 813 { … … 1011 837 int CNetCdfInterface::varParAccess(int ncid, int varId, int access) 1012 838 { 1013 int status; 1014 #pragma omp critical (_netcdf) 1015 { 1016 info(100)<<"start nc_var_par_access"<<std::endl; 1017 status = nc_var_par_access(ncid, varId, access); 1018 info(100)<<"end nc_var_par_access"<<std::endl; 1019 } 839 int status = nc_var_par_access(ncid, varId, access); 1020 840 if (NC_NOERR != status) 1021 841 { … … 1040 860 int CNetCdfInterface::sync(int ncid) 1041 861 { 1042 int status; 1043 #pragma omp critical (_netcdf) 1044 { 1045 info(100)<<"start nc_sync"<<std::endl; 1046 status = nc_sync(ncid); 1047 info(100)<<"end nc_sync"<<std::endl; 1048 } 862 int status = nc_sync(ncid); 1049 863 if (NC_NOERR != status) 1050 864 { … … 1066 880 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, double* data) 1067 881 { 1068 int status; 1069 #pragma omp critical (_netcdf) 1070 { 1071 info(100)<<"start nc_get_att_double"<<std::endl; 1072 status = nc_get_att_double(ncid, varid, attrName, data); 1073 info(100)<<"end nc_get_att_double"<<std::endl; 1074 } 1075 return status; 882 return nc_get_att_double(ncid, varid, attrName, data); 1076 883 } 1077 884 … … 1079 886 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, float* data) 1080 887 { 1081 int status; 1082 #pragma omp critical (_netcdf) 1083 { 1084 info(100)<<"start nc_get_att_float"<<std::endl; 1085 status = nc_get_att_float(ncid, varid, attrName, data); 1086 info(100)<<"end nc_get_att_float"<<std::endl; 1087 } 1088 return status; 888 return nc_get_att_float(ncid, varid, attrName, data); 1089 889 } 1090 890 … … 1092 892 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, int* data) 1093 893 { 1094 int status; 1095 #pragma omp critical (_netcdf) 1096 { 1097 info(100)<<"start nc_get_att_int"<<std::endl; 1098 status = nc_get_att_int(ncid, varid, attrName, data); 1099 info(100)<<"end nc_get_att_int"<<std::endl; 1100 } 1101 return status; 894 return nc_get_att_int(ncid, varid, attrName, data); 1102 895 } 1103 896 … … 1105 898 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, long* data) 1106 899 { 1107 int status; 1108 #pragma omp critical (_netcdf) 1109 { 1110 info(100)<<"start nc_get_att_long"<<std::endl; 1111 status = nc_get_att_long(ncid, varid, attrName, data); 1112 info(100)<<"end nc_get_att_long"<<std::endl; 1113 } 1114 return status; 900 return nc_get_att_long(ncid, varid, attrName, data); 1115 901 } 1116 902 … … 1118 904 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, short* data) 1119 905 { 1120 int status; 1121 #pragma omp critical (_netcdf) 1122 { 1123 info(100)<<"start nc_get_att_short"<<std::endl; 1124 status = nc_get_att_short(ncid, varid, attrName, data); 1125 info(100)<<"end nc_get_att_short"<<std::endl; 1126 } 1127 return status; 906 return nc_get_att_short(ncid, varid, attrName, data); 1128 907 } 1129 908 … … 1131 910 int CNetCdfInterface::ncGetAttType(int ncid, int varid, const char* attrName, char* data) 1132 911 { 1133 int status; 1134 #pragma omp critical (_netcdf) 1135 { 1136 info(100)<<"start nc_get_att_text"<<std::endl; 1137 status = nc_get_att_text(ncid, varid, attrName, data); 1138 info(100)<<"end nc_get_att_text"<<std::endl; 1139 } 1140 return status; 912 return nc_get_att_text(ncid, varid, attrName, data); 1141 913 } 1142 914 … … 1146 918 StdSize numVal, const double* data) 1147 919 { 1148 int status; 1149 #pragma omp critical (_netcdf) 1150 { 1151 info(100)<<"start nc_put_att_double"<<std::endl; 1152 status = nc_put_att_double(ncid, varid, attrName, NC_DOUBLE, numVal, data); 1153 info(100)<<"end nc_put_att_double"<<std::endl; 1154 } 1155 return status; 920 return nc_put_att_double(ncid, varid, attrName, NC_DOUBLE, numVal, data); 1156 921 } 1157 922 … … 1160 925 StdSize numVal, const float* data) 1161 926 { 1162 int status; 1163 #pragma omp critical (_netcdf) 1164 { 1165 info(100)<<"start nc_put_att_float"<<std::endl; 1166 status = nc_put_att_float(ncid, varid, attrName, NC_FLOAT, numVal, data); 1167 info(100)<<"end nc_put_att_float"<<std::endl; 1168 } 1169 return status; 927 return nc_put_att_float(ncid, varid, attrName, NC_FLOAT, numVal, data); 1170 928 } 1171 929 … … 1174 932 StdSize numVal, const int* data) 1175 933 { 1176 int status; 1177 #pragma omp critical (_netcdf) 1178 { 1179 info(100)<<"start nc_put_att_int"<<std::endl; 1180 status = nc_put_att_int(ncid, varid, attrName, NC_INT, numVal, data); 1181 info(100)<<"end nc_put_att_int"<<std::endl; 1182 } 1183 return status; 934 return nc_put_att_int(ncid, varid, attrName, NC_INT, numVal, data); 1184 935 } 1185 936 … … 1188 939 StdSize numVal, const long* data) 1189 940 { 1190 int status; 1191 #pragma omp critical (_netcdf) 1192 { 1193 info(100)<<"start nc_put_att_long"<<std::endl; 1194 status = nc_put_att_long(ncid, varid, attrName, NC_LONG, numVal, data); 1195 info(100)<<"end nc_put_att_long"<<std::endl; 1196 } 1197 return status; 941 return nc_put_att_long(ncid, varid, attrName, NC_LONG, numVal, data); 1198 942 } 1199 943 … … 1202 946 StdSize numVal, const short* data) 1203 947 { 1204 int status; 1205 #pragma omp critical (_netcdf) 1206 { 1207 info(100)<<"start nc_put_att_short"<<std::endl; 1208 status = nc_put_att_short(ncid, varid, attrName, NC_SHORT, numVal, data); 1209 info(100)<<"end nc_put_att_short"<<std::endl; 1210 } 1211 return status; 948 return nc_put_att_short(ncid, varid, attrName, NC_SHORT, numVal, data); 1212 949 } 1213 950 … … 1216 953 StdSize numVal, const char* data) 1217 954 { 1218 int status; 1219 #pragma omp critical (_netcdf) 1220 { 1221 info(100)<<"start nc_put_att_text"<<std::endl; 1222 status = nc_put_att_text(ncid, varid, attrName, numVal, data); 1223 info(100)<<"end nc_put_att_text"<<std::endl; 1224 } 1225 return status; 955 return nc_put_att_text(ncid, varid, attrName, numVal, data); 1226 956 } 1227 957 … … 1230 960 int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, double* data) 1231 961 { 1232 int status; 1233 #pragma omp critical (_netcdf) 1234 { 1235 info(100)<<"start nc_get_vara_double"<<std::endl; 1236 status = nc_get_vara_double(ncid, varid, start, count, data); 1237 info(100)<<"end nc_get_vara_double"<<std::endl; 1238 } 1239 return status; 962 return nc_get_vara_double(ncid, varid, start, count, data); 1240 963 } 1241 964 … … 1243 966 int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, float* data) 1244 967 { 1245 int status; 1246 #pragma omp critical (_netcdf) 1247 { 1248 info(100)<<"start nc_get_vara_float"<<std::endl; 1249 status = nc_get_vara_float(ncid, varid, start, count, data); 1250 info(100)<<"end nc_get_vara_float"<<std::endl; 1251 } 1252 return status; 968 return nc_get_vara_float(ncid, varid, start, count, data); 1253 969 } 1254 970 … … 1256 972 int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, int* data) 1257 973 { 1258 int status; 1259 #pragma omp critical (_netcdf) 1260 { 1261 info(100)<<"start nc_get_vara_int"<<std::endl; 1262 status = nc_get_vara_int(ncid, varid, start, count, data); 1263 info(100)<<"end nc_get_vara_int"<<std::endl; 1264 } 1265 return status; 974 return nc_get_vara_int(ncid, varid, start, count, data); 1266 975 } 1267 976 … … 1269 978 int CNetCdfInterface::ncGetVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, char* data) 1270 979 { 1271 int status; 1272 #pragma omp critical (_netcdf) 1273 { 1274 info(100)<<"start nc_get_vara_text"<<std::endl; 1275 status = nc_get_vara_text(ncid, varid, start, count, data); 1276 info(100)<<"end nc_get_vara_text"<<std::endl; 1277 } 1278 return status; 980 return nc_get_vara_text(ncid, varid, start, count, data); 1279 981 } 1280 982 … … 1283 985 int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const double* data) 1284 986 { 1285 int status; 1286 #pragma omp critical (_netcdf) 1287 { 1288 info(100)<<"start nc_put_vara_double"<<std::endl; 1289 status = nc_put_vara_double(ncid, varid, start, count, data); 1290 info(100)<<"end nc_put_vara_double"<<std::endl; 1291 } 1292 return status; 987 return nc_put_vara_double(ncid, varid, start, count, data); 1293 988 } 1294 989 … … 1296 991 int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const float* data) 1297 992 { 1298 int status; 1299 #pragma omp critical (_netcdf) 1300 { 1301 info(100)<<"start nc_put_vara_float"<<std::endl; 1302 status = nc_put_vara_float(ncid, varid, start, count, data); 1303 info(100)<<"end nc_put_vara_float"<<std::endl; 1304 } 1305 return status; 993 return nc_put_vara_float(ncid, varid, start, count, data); 1306 994 } 1307 995 … … 1309 997 int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const int* data) 1310 998 { 1311 int status; 1312 #pragma omp critical (_netcdf) 1313 { 1314 info(100)<<"start nc_put_vara_int"<<std::endl; 1315 status = nc_put_vara_int(ncid, varid, start, count, data); 1316 info(100)<<"end nc_put_vara_int"<<std::endl; 1317 } 1318 return status; 999 return nc_put_vara_int(ncid, varid, start, count, data); 1319 1000 } 1320 1001 … … 1322 1003 int CNetCdfInterface::ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const char* data) 1323 1004 { 1324 int status; 1325 #pragma omp critical (_netcdf) 1326 { 1327 info(100)<<"start nc_put_vara_text"<<std::endl; 1328 status = nc_put_vara_text(ncid, varid, start, count, data); 1329 info(100)<<"end nc_put_vara_text"<<std::endl; 1330 } 1331 return status; 1005 return nc_put_vara_text(ncid, varid, start, count, data); 1332 1006 } 1333 1007 … … 1342 1016 { 1343 1017 int varId = 0; 1344 int status; 1345 #pragma omp critical (_netcdf) 1346 { 1347 info(100)<<"start isVarExisted"<<std::endl; 1348 status = nc_inq_varid(ncId, varName.c_str(), &varId); 1349 info(100)<<"end isVarExisted"<<std::endl; 1350 } 1351 return (NC_NOERR == status); 1018 return (NC_NOERR == (nc_inq_varid(ncId, varName.c_str(), &varId))); 1352 1019 } 1353 1020 … … 1355 1022 { 1356 1023 int dimId = 0; 1357 int status; 1358 #pragma omp critical (_netcdf) 1359 { 1360 info(100)<<"start isDimExisted"<<std::endl; 1361 status = nc_inq_dimid(ncId, dimName.c_str(), &dimId); 1362 info(100)<<"end isDimExisted"<<std::endl; 1363 } 1364 return (NC_NOERR == status); 1024 return (NC_NOERR == (nc_inq_dimid(ncId, dimName.c_str(), &dimId))); 1365 1025 } 1366 1026 -
XIOS/dev/branch_openmp/src/io/netCdfInterface.hpp
r1545 r1642 10 10 #define __NETCDF_INTERFACE_HPP_ 11 11 12 #include "mpi_std.hpp"13 12 #include "xios_spl.hpp" 14 13 … … 17 16 #endif 18 17 19 18 #include "mpi.hpp" 20 19 #include "netcdf.hpp" 21 20 … … 33 32 34 33 //! Create a netcdf file on a parallel file system 35 static int createPar(const StdString& path, int cmode, MPI_Comm comm,MPI_Info info, int& ncId);34 static int createPar(const StdString& path, int cmode, ep_lib::MPI_Comm comm, ep_lib::MPI_Info info, int& ncId); 36 35 37 36 //! Open a netcdf file … … 39 38 40 39 //! Open a netcdf file 41 static int openPar(const StdString& path, int cmode, MPI_Comm comm,MPI_Info info, int& ncId);40 static int openPar(const StdString& path, int cmode, ep_lib::MPI_Comm comm, ep_lib::MPI_Info info, int& ncId); 42 41 43 42 //! Close a netcdf file -
XIOS/dev/branch_openmp/src/io/netcdf.hpp
r1555 r1642 1 1 #ifndef __XIOS_NETCDF_HPP__ 2 2 #define __XIOS_NETCDF_HPP__ 3 #include "mpi _std.hpp"3 #include "mpi.hpp" 4 4 #define MPI_INCLUDED 5 5 #include <netcdf.h> … … 33 33 { 34 34 #if defined(USING_NETCDF_PAR) 35 int status; 36 #pragma omp critical (_netcdf) 37 { 38 status = ::nc_create_par(path, cmode, comm, info, ncidp) ; 39 } 40 return status; 35 return ::nc_create_par(path, cmode, comm, info, ncidp) ; 41 36 #else 42 37 ERROR("int nc_create_par(const char *path, int cmode, MPI_Comm comm, MPI_Info info,int *ncidp)", … … 49 44 { 50 45 #if defined(USING_NETCDF_PAR) 51 int status; 52 #pragma omp critical (_netcdf) 53 { 54 status = ::nc_open_par(path, mode, comm, info, ncidp) ; 55 } 56 return status; 46 return ::nc_open_par(path, mode, comm, info, ncidp) ; 57 47 #else 58 48 ERROR("int nc_open_par(const char *path, int mode, MPI_Comm comm, MPI_Info info,int *ncidp)", … … 65 55 { 66 56 #if defined(USING_NETCDF_PAR) 67 int status = ::nc_var_par_access(ncid, varid, par_access) ; 68 69 return status; 57 return ::nc_var_par_access(ncid, varid, par_access) ; 70 58 #else 71 59 ERROR("int nc_var_par_access(int ncid, int varid, int par_access)", -
XIOS/dev/branch_openmp/src/io/onetcdf4.cpp
r1545 r1642 3 3 #include "onetcdf4.hpp" 4 4 #include "group_template.hpp" 5 #include " ep_mpi.hpp"5 #include "mpi.hpp" 6 6 #include "netcdf.hpp" 7 7 #include "netCdfInterface.hpp" … … 58 58 CTimer::get("Files : create").resume(); 59 59 if (wmpi) 60 CNetCdfInterface::createPar(filename, mode, to_mpi_comm((*comm)->mpi_comm), to_mpi_info(MPI_INFO_NULL), this->ncidp);60 CNetCdfInterface::createPar(filename, mode, *comm, EP_INFO_NULL, this->ncidp); 61 61 else 62 62 CNetCdfInterface::create(filename, mode, this->ncidp); … … 70 70 CTimer::get("Files : open").resume(); 71 71 if (wmpi) 72 CNetCdfInterface::openPar(filename, mode, to_mpi_comm((*comm)->mpi_comm), to_mpi_info(MPI_INFO_NULL), this->ncidp);72 CNetCdfInterface::openPar(filename, mode, *comm, EP_INFO_NULL, this->ncidp); 73 73 else 74 74 CNetCdfInterface::open(filename, mode, this->ncidp); -
XIOS/dev/branch_openmp/src/io/onetcdf4.hpp
r1545 r1642 4 4 /// XIOS headers /// 5 5 #include "xios_spl.hpp" 6 #include "mpi_std.hpp"7 6 #include "exception.hpp" 8 7 #include "data_output.hpp" 9 8 #include "array_new.hpp" 9 #include "mpi.hpp" 10 10 #include "netcdf.hpp" 11 11 -
XIOS/dev/branch_openmp/src/io/onetcdf4_impl.hpp
r1460 r1642 73 73 } 74 74 char *PtrArrayStr ; 75 PtrArrayStr=new char[stringArrayLen] ; 75 PtrArrayStr=new char[stringArrayLen*data.numElements()] ; 76 memset (PtrArrayStr,' ',stringArrayLen*data.numElements()); 77 size_t offset=0 ; 76 78 Array<StdString,1>::const_iterator it, itb=data.begin(), ite=data.end() ; 77 int lineNb = 0; 78 for(it=itb;it!=ite;++it) 79 for(it=itb;it!=ite;++it, offset+=stringArrayLen) 79 80 { 80 it->copy(PtrArrayStr,it->size()) ; 81 PtrArrayStr[it->size()]='\0' ; 82 sstart[0] = lineNb; 83 sstart[dimArrayLen] = 0; 84 scount[0] = 1; 85 scount[dimArrayLen] = it->size() + 1; 86 CTimer::get("CONetCDF4::writeData writeData_").resume(); 87 this->writeData_(grpid, varid, sstart, scount, PtrArrayStr); 88 CTimer::get("CONetCDF4::writeData writeData_").suspend(); 89 ++lineNb; 81 it->copy(PtrArrayStr+offset,it->size()) ; 82 PtrArrayStr[offset+it->size()]='\0' ; 90 83 } 84 85 CTimer::get("CONetCDF4::writeData writeData_").resume(); 86 this->writeData_(grpid, varid, sstart, scount, PtrArrayStr); 87 CTimer::get("CONetCDF4::writeData writeData_").suspend(); 88 91 89 delete [] PtrArrayStr; 92 90 }
Note: See TracChangeset
for help on using the changeset viewer.