2#include "AMReX_FArrayBox.H"
7#ifdef REMORA_USE_NETCDF
20 const std::string&
fname,
24 amrex::Print() <<
"Loading initial solution data from NetCDF file " <<
fname << std::endl;
52 const std::string&
fname,
57 amrex::Print() <<
"Loading initial solution data from NetCDF file " <<
fname << std::endl;
82 const std::string&
fname,
90 amrex::Print() <<
"Loading initial biology data from NetCDF file " <<
fname << std::endl;
115 const std::string&
fname,
124 amrex::Print() <<
"Loading high resolution biology data from NetCDF file " <<
fname << std::endl;
156 const IntVect&
ngrow)
160 const long need_x =
static_cast<long>(domain.length(0)) + 2L *
ngrow[0];
161 const long need_y =
static_cast<long>(domain.length(1)) + 2L *
ngrow[1];
165 if (amrex::ParallelDescriptor::IOProcessor() &&
ncf.has_var(
var_name))
168 const std::vector<MPI_Offset> shape =
ncf.var(
var_name).shape();
169 if (shape.size() >= 2) {
170 found_y =
static_cast<long>(shape[shape.size()-2]);
171 found_x =
static_cast<long>(shape[shape.size()-1]);
177 const int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
183 amrex::Abort(
"High-resolution file " +
fname +
" is too small: " +
var_name +
" is "
185 +
" (xi x eta) but covering the refined domain ("
186 + std::to_string(domain.length(0)) +
" x " + std::to_string(domain.length(1))
187 +
" cells) with " + std::to_string(
ngrow[0]) +
" x " + std::to_string(
ngrow[1])
188 +
" grow cells requires at least " + std::to_string(
need_x) +
" x "
189 + std::to_string(
need_y) +
". Regenerate the file with the grow cells the "
190 "cumulative refinement ratio implies, or lower the refinement ratio.");
218 const std::string&
fname,
248 amrex::Print() <<
"Initial file " <<
fname <<
" does not contain";
249 for (
const auto& name :
missing) { amrex::Print() <<
" " << name; }
250 amrex::Print() <<
"; those passive scalars start at zero" << std::endl;
256 amrex::Print() <<
"Loading " << (
full_domain ?
"high resolution " :
"initial ")
257 <<
"passive scalar data from NetCDF file " <<
fname << std::endl;
280 const std::string&
fname,
286 false, IntVect(0,0,0));
301 const std::string&
fname,
320 const std::string&
fname,
323 amrex::Print() <<
"Loading initial sea surface height from NetCDF file " <<
fname << std::endl;
345 const std::string&
fname,
349 amrex::Print() <<
"Loading initial sea surface height from NetCDF file " <<
fname << std::endl;
370 const std::string&
fname,
373 amrex::Print() <<
"Loading initial bathymetry from NetCDF file " <<
fname << std::endl;
403 const std::string&
fname,
410 amrex::Print() <<
"Loading grid variables from NetCDF file " <<
fname << std::endl;
448 const std::string&
fname,
456 amrex::Print() <<
"Grid file " <<
fname <<
" has no lon_psi/lat_psi; "
457 <<
"spherical psi coordinates unavailable" << std::endl;
461 amrex::Print() <<
"Loading spherical psi coordinates from NetCDF file " <<
fname << std::endl;
481 const std::string&
fname,
484 amrex::Print() <<
"Loading high resolution bathymetry from NetCDF file " <<
fname << std::endl;
506 const std::string&
fname,
510 amrex::Print() <<
"Loading high resolution grid variables from NetCDF file " <<
fname << std::endl;
531 const std::string&
fname,
534 amrex::Print() <<
"Loading initial coriolis from NetCDF file " <<
fname << std::endl;
557 const std::string&
fname,
562 amrex::Print() <<
"Loading masks from NetCDF file " <<
fname << std::endl;
593 const std::string&
fname,
594 bool do_m2_clim_nudg,
595 bool do_m3_clim_nudg,
596 const amrex::Vector<int>& do_cons_clim_nudg,
597 const amrex::Vector<std::string>& cons_names,
603 amrex::Print() <<
"Loading nudging coefficients from NetCDF file " <<
fname << std::endl;
605 const int l_ncons = do_cons_clim_nudg.size();
611 if (do_m3_clim_nudg) {
614 if (do_m2_clim_nudg) {
624 if (!do_cons_clim_nudg[
icomp]) {
continue; }
634 amrex::Print() <<
"Nudging coefficient file " <<
fname <<
" does not contain";
635 for (
const auto& name :
missing) { amrex::Print() <<
" " << name; }
636 amrex::Print() <<
"; those tracers will use the constant coefficient from remora.tnudg"
656 amrex::Print() <<
"Reading " << field_name <<
" from NetCDF file" << std::endl;
662 if (amrex::ParallelDescriptor::IOProcessor())
665 for (
int i(0);
i < n;
i++)
671 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
673 if (!(amrex::ParallelDescriptor::IOProcessor())) {
mf_h setVal(geomdata.ProbHi(2))
AMREX_ALWAYS_ASSERT(!NSPeriodic||!EWPeriodic)
void ReadNetCDFFile(const std::string &fname, amrex::Vector< std::string > names, amrex::Vector< NDArray< DType > > &arrays, bool one_time=false, int fill_time=0)
Read in data from netcdf file and save to data arrays.
bool QueryNetCDFHasVars(const std::string &fname, const amrex::Vector< std::string > &var_names)
Helper function for testing whether a file carries every named variable.
void read_zeta_full_domain_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_zeta_fab, IntVect ngrow)
helper function to read high-resolution full-domain sea surface height from netcdf
void read_bathymetry_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_h_fab)
helper function to read bathymetry from netcdf
void read_vec_from_netcdf(int, const amrex::Vector< std::string > &fnames, const std::string &field_name, amrex::Vector< int > &vec_dat)
helper function to read in vector of data from netcdf
void read_scalars_full_domain_from_netcdf(int, const Box &domain, const std::string &fname, const Vector< std::string > &scalar_names, Vector< FArrayBox > &NC_scalar_fab, Vector< int > &scalar_in_file, IntVect ngrow)
helper function for reading in full domain high-resolution initial passive (dye) scalar data from net...
void read_data_full_domain_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_temp_fab, FArrayBox &NC_salt_fab, FArrayBox &NC_xvel_fab, FArrayBox &NC_yvel_fab, IntVect ngrow)
helper function for reading in full domain high-resolution initial state data from netcdf
void check_hires_dims_from_netcdf(const std::string &fname, const std::string &var_name, const Box &domain, const IntVect &ngrow)
helper function checking that a high-resolution file covers the refined domain plus grow cells
void read_grid_vars_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_pm_fab, FArrayBox &NC_pn_fab, FArrayBox &NC_xr_fab, FArrayBox &NC_yr_fab, FArrayBox &NC_xu_fab, FArrayBox &NC_yu_fab, FArrayBox &NC_xv_fab, FArrayBox &NC_yv_fab, FArrayBox &NC_xp_fab, FArrayBox &NC_yp_fab)
helper function to read grid variables from netcdf
void read_biology_from_netcdf(int, const Box &domain, const std::string &fname, const Vector< std::string > &biology_names, Vector< FArrayBox > &NC_biology_fab)
helper function for reading in initial biology data from netcdf
void read_bathymetry_full_domain_from_netcdf(const Box &domain, const std::string &fname, FArrayBox &NC_h_fab, IntVect ngrow)
helper function to read full-domain high resolution bathymetry from netcdf
void read_clim_nudg_coeff_from_netcdf(int, const Box &domain, const std::string &fname, bool do_m2_clim_nudg, bool do_m3_clim_nudg, const amrex::Vector< int > &do_cons_clim_nudg, const amrex::Vector< std::string > &cons_names, FArrayBox &NC_M2NC_fab, FArrayBox &NC_M3NC_fab, amrex::Vector< FArrayBox > &NC_ConsNC_fab, amrex::Vector< int > &cons_coeff_in_file)
helper function to read climatology nudging from netcdf
void read_coriolis_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_fcor_fab)
helper function to read coriolis factor from netcdf
void read_masks_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_mskr_fab, FArrayBox &NC_msku_fab, FArrayBox &NC_mskv_fab)
helper function for reading in land-sea masks from netcdf
void read_biology_full_domain_from_netcdf(int, const Box &domain, const std::string &fname, const Vector< std::string > &biology_names, Vector< FArrayBox > &NC_biology_fab, IntVect ngrow)
helper function for reading in full domain high-resolution initial biology data from netcdf
void read_zeta_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_zeta_fab)
helper function to read sea surface height from netcdf
bool read_spherical_grid_vars_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_lonp_fab, FArrayBox &NC_latp_fab)
helper function to read optional spherical psi coordinates from netcdf
void read_data_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_temp_fab, FArrayBox &NC_salt_fab, FArrayBox &NC_xvel_fab, FArrayBox &NC_yvel_fab)
helper function for reading in initial state data from netcdf
void read_scalars_from_netcdf(int, const Box &domain, const std::string &fname, const Vector< std::string > &scalar_names, Vector< FArrayBox > &NC_scalar_fab, Vector< int > &scalar_in_file)
helper function for reading in initial passive (dye) scalar data from netcdf
void read_grid_vars_full_domain_from_netcdf(const Box &domain, const std::string &fname, FArrayBox &NC_pm_fab, FArrayBox &NC_pn_fab, IntVect ngrow)
helper function to read full-domain high resolution grid variables from netcdf
static NCFile open(const std::string &name, const int cmode=NC_NOWRITE, MPI_Comm comm=MPI_COMM_WORLD, MPI_Info info=MPI_INFO_NULL)
Open an existing file.
NDArray is the datatype designed to hold any data, including scalars, multidimensional arrays,...