MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / write

Method write

src/sys/options/options_netcdf.cxx:714–738  ·  view source on GitHub ↗

Write options to file

Source from the content-addressed store, hash-verified

712
713/// Write options to file
714void OptionsNetCDF::write(const Options& options, const std::string& time_dim) {
715 Timer timer("io");
716
717 // Check the file mode to use
718 auto ncmode = NcFile::replace;
719 if (file_mode == FileMode::append) {
720 // NetCDF doesn't have a "read-write, create if exists" mode, so
721 // we need to check ourselves if the file already exists; if it
722 // doesn't, tell NetCDF to create it
723 std::ifstream file(filename);
724 ncmode = file.good() ? NcFile::FileMode::write : NcFile::FileMode::newFile;
725 }
726
727 if (not data_file) {
728 data_file = std::make_unique<netCDF::NcFile>(filename, ncmode);
729 }
730
731 if (data_file->isNull()) {
732 throw BoutException("Could not open NetCDF file '{:s}' for writing", filename);
733 }
734
735 writeGroup(options, *data_file, time_dim);
736
737 data_file->sync();
738}
739
740} // namespace bout
741

Callers

nothing calls this directly

Calls 1

writeGroupFunction · 0.70

Tested by

no test coverage detected