Changeset 517 for XIOS/trunk/src/output/onetcdf4.cpp
- Timestamp:
- 11/26/14 12:06:21 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/output/onetcdf4.cpp
r501 r517 11 11 12 12 CONetCDF4::CONetCDF4 13 (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile)13 (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 14 14 : path() 15 , useClassicFormat(useClassicFormat) 15 16 { 16 17 this->wmpi = (comm != NULL) && !multifile; 17 this->initialize(filename, exist, comm,multifile);18 this->initialize(filename, exist, useClassicFormat, comm,multifile); 18 19 } 19 20 … … 29 30 30 31 void CONetCDF4::initialize 31 (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 32 { 32 (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 33 { 34 this->useClassicFormat = useClassicFormat; 35 36 int mode = useClassicFormat ? 0 : NC_NETCDF4; 37 if (!multifile) 38 mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO; 39 33 40 if (!exist) 34 41 { 35 42 if (comm != NULL) 36 43 { 37 if (!multifile) (CNetCdfInterface::createPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, (this->ncidp)));38 else (CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp));44 if (!multifile) CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 45 else CNetCdfInterface::create(filename, mode, this->ncidp); 39 46 } 40 else (CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp));47 else CNetCdfInterface::create(filename, mode, this->ncidp); 41 48 } 42 49 else … … 44 51 if (comm != NULL) 45 52 { 46 if (!multifile) (CNetCdfInterface::openPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp));47 else (CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp));53 if (!multifile) CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 54 else CNetCdfInterface::open(filename, mode, this->ncidp); 48 55 } 49 else (CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp)); 50 } 56 else CNetCdfInterface::open(filename, mode, this->ncidp); 57 } 58 59 // If the classic NetCDF format is used, we enable the "no-fill mode" globally. 60 // This is done per variable for the NetCDF4 format. 61 if (useClassicFormat) 62 CNetCdfInterface::setFill(this->ncidp, false); 51 63 } 52 64 … … 264 276 } 265 277 266 (CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &(dimids[0]), varid)); 267 268 // set chunksize : size of one record 269 // but must not be > 2GB (netcdf or HDF5 problem) 270 totalSize=1 ; 271 for(vector<StdSize>::reverse_iterator it=dimsizes.rbegin(); it!=dimsizes.rend();++it) 272 { 273 totalSize*= *it ; 274 if (totalSize>=maxSize) *it=1 ; 275 } 276 277 (CNetCdfInterface::defVarChunking(grpid, varid, NC_CHUNKED, &(dimsizes[0]))); 278 (CNetCdfInterface::defVarFill(grpid, varid, true, NULL)); 278 CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &(dimids[0]), varid); 279 280 // The classic NetCDF format does not support chunking nor fill parameters 281 if (!useClassicFormat) 282 { 283 // set chunksize : size of one record 284 // but must not be > 2GB (netcdf or HDF5 problem) 285 totalSize = 1; 286 for (vector<StdSize>::reverse_iterator it = dimsizes.rbegin(); it != dimsizes.rend(); ++it) 287 { 288 totalSize *= *it; 289 if (totalSize >= maxSize) *it = 1; 290 } 291 292 CNetCdfInterface::defVarChunking(grpid, varid, NC_CHUNKED, &dimsizes[0]); 293 CNetCdfInterface::defVarFill(grpid, varid, true, NULL); 294 } 295 279 296 return (varid); 280 297 }
Note: See TracChangeset
for help on using the changeset viewer.