diff --git a/components/omega/configs/Default.yml b/components/omega/configs/Default.yml index 620f790cdc65..24524c17613d 100644 --- a/components/omega/configs/Default.yml +++ b/components/omega/configs/Default.yml @@ -19,7 +19,7 @@ Omega: IOStride: 1 IOBaseTask: 0 IORearranger: box - IODefaultFormat: NetCDF4 + IODefaultFormat: pnetcdf State: NTimeLevels: 2 Advection: @@ -114,7 +114,7 @@ Omega: - Restart History: UsePointerFile: false - Filename: ocn.hist.$SimTime + Filename: ocn.hist.$Y-$M-$D_$h.$m.$s Mode: write IfExists: replace Precision: double diff --git a/components/omega/src/base/IO.cpp b/components/omega/src/base/IO.cpp index ac523904d914..c7d5dd3a2914 100644 --- a/components/omega/src/base/IO.cpp +++ b/components/omega/src/base/IO.cpp @@ -189,11 +189,11 @@ void init(const MPI_Comm &InComm // [in] MPI communicator to use CHECK_ERROR_ABORT(Err, "IO: IO group not found in input Config"); // Read default file format - std::string InFileFmt = "netcdf4c"; // set default value + std::string InFileFmt = "pnetcdf"; // set default value Err = IOConfig.get("IODefaultFormat", InFileFmt); CHECK_ERROR_WARN(Err, "IO: DefaultFileFmt not found in Config - using {}", InFileFmt); - FileFmt DefaultFileFmt = FileFmtFromString(InFileFmt); + DefaultFileFmt = FileFmtFromString(InFileFmt); // Read parallel IO settings - default to single-task if config // values do not exist @@ -249,6 +249,7 @@ void openFile( int PIOErr = 0; // internal SCORPIO/PIO return call int Format = InFormat; // coerce to integer for PIO calls + int IsCDF5 = (InFormat == PIO_IOTYPE_PNETCDF) ? PIO_64BIT_DATA : 0; switch (InMode) { @@ -269,7 +270,7 @@ void openFile( // file exists, we use create and fail with an error case IfExists::Fail: PIOErr = PIOc_createfile(SysID, &FileID, &Format, Filename.c_str(), - NC_NOCLOBBER | InMode); + NC_NOCLOBBER | IsCDF5 | InMode); if (PIOErr != PIO_NOERR) ABORT_ERROR("IO::openFile: PIO error opening file {} for writing", Filename); @@ -279,7 +280,7 @@ void openFile( // we use create with the CLOBBER option case IfExists::Replace: PIOErr = PIOc_createfile(SysID, &FileID, &Format, Filename.c_str(), - NC_CLOBBER | InMode); + NC_CLOBBER | IsCDF5 | InMode); if (PIOErr != PIO_NOERR) ABORT_ERROR("IO::openFile: PIO error opening file {} for writing", Filename); @@ -291,10 +292,10 @@ void openFile( case IfExists::Append: if (std::filesystem::exists(Filename)) { PIOErr = PIOc_openfile(SysID, &FileID, &Format, Filename.c_str(), - InMode); + IsCDF5 | InMode); } else { PIOErr = PIOc_createfile(SysID, &FileID, &Format, Filename.c_str(), - InMode); + IsCDF5 | InMode); } if (PIOErr != PIO_NOERR) diff --git a/components/omega/src/base/IO.h b/components/omega/src/base/IO.h index e06c9629dbf8..044228676b50 100644 --- a/components/omega/src/base/IO.h +++ b/components/omega/src/base/IO.h @@ -74,7 +74,7 @@ enum FileFmt { FmtHDF5 = PIO_IOTYPE_HDF5, ///< native HDF5 format FmtADIOS = PIO_IOTYPE_ADIOS, ///< ADIOS format FmtUnknown = -1, ///< Unknown or undefined - FmtDefault = PIO_IOTYPE_NETCDF4C, ///< NetCDF4 is default + FmtDefault = PIO_IOTYPE_PNETCDF, ///< PNETCDF is default }; /// File operations diff --git a/components/omega/src/infra/IOStream.cpp b/components/omega/src/infra/IOStream.cpp index 114853d878a1..2eaf41181d16 100644 --- a/components/omega/src/infra/IOStream.cpp +++ b/components/omega/src/infra/IOStream.cpp @@ -2285,7 +2285,7 @@ Error IOStream::readStream( // Open input file int InFileID; - IO::openFile(InFileID, InFileName, Mode, IO::FmtDefault, ExistAction); + IO::openFile(InFileID, InFileName, Mode, IO::DefaultFileFmt, ExistAction); // Read any requested global metadata for (auto Iter = ReqMetadata.begin(); Iter != ReqMetadata.end(); ++Iter) { @@ -2438,7 +2438,8 @@ void IOStream::writeStream( // Open output file int OutFileID; - IO::openFile(OutFileID, OutFileName, Mode, IO::FmtDefault, ExistAction); + IO::openFile(OutFileID, OutFileName, Mode, IO::DefaultFileFmt, ExistAction); + bool NeedEndDef = false; // check if we need to call end-define-mode // For files with multiple frames or time slices, we need to determine the // default Frame number for time-dependent fields. If the frame/time already @@ -2491,6 +2492,7 @@ void IOStream::writeStream( if (Frame < 1) { writeFieldMeta(CodeMeta, OutFileID, IO::GlobalID); writeFieldMeta(SimMeta, OutFileID, IO::GlobalID); + NeedEndDef = true; } // Create and write a field for any global data that is file or time @@ -2506,6 +2508,10 @@ void IOStream::writeStream( FileField->addMetadata(SimTimeName, SimTimeStr); } // Write and then destroy temporary field + if (!NeedEndDef) { // in data-mode, need to redef + PIOc_redef(OutFileID); + NeedEndDef = true; + } writeFieldMeta("FileField", OutFileID, IO::GlobalID); Field::destroy("FileField"); @@ -2557,8 +2563,12 @@ void IOStream::writeStream( // Now we can write the field metadata if (Frame < 1) { // only write if it's the first time writeFieldMeta(FieldName, OutFileID, FieldID); + NeedEndDef = true; } } + if (NeedEndDef) { + IO::endDefinePhase(OutFileID); + } // Now write data arrays for all fields in contents for (auto IFld = Contents.begin(); IFld != Contents.end(); ++IFld) { diff --git a/externals/scorpio b/externals/scorpio index 8b8450444c0e..9df851035a89 160000 --- a/externals/scorpio +++ b/externals/scorpio @@ -1 +1 @@ -Subproject commit 8b8450444c0e6f900042f57d93813065443bb5b5 +Subproject commit 9df851035a89ba1ca0581ccdbb88fcfc0ec38992