4#include "AMReX_ParallelDescriptor.H"
8#ifdef REMORA_USE_NETCDF
32 amrex::Print() <<
"Loading " <<
field_name <<
" from rivers NetCDF file(s)" << std::endl;
46 if (amrex::ParallelDescriptor::IOProcessor())
48 if (
unit_str.find(
"days") == std::string::npos) {
49 amrex::Print() <<
"Units of river_time given as: " <<
unit_str << std::endl;
50 amrex::Abort(
"Units must be in days.");
58 if (amrex::ParallelDescriptor::IOProcessor())
64 river_times.push_back((*(
array_ts[0].get_data() + nt)) * amrex::Real(60.0) * amrex::Real(60.0) * amrex::Real(24.0));
72 if (amrex::ParallelDescriptor::IOProcessor()) {
75 amrex::Error(
"River data must be given at at least two times");
78 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
80 if (!(amrex::ParallelDescriptor::IOProcessor())) {
90 if (amrex::ParallelDescriptor::IOProcessor())
93 if (shape.size() == 2) {
96 }
else if (shape.size() == 3) {
100 amrex::Abort(
"River field shape not 2 or 3");
103 amrex::ParallelDescriptor::Bcast(&
has_z, 1,
ioproc);
104 amrex::ParallelDescriptor::Bcast(&
nriv, 1,
ioproc);
110 amrex::Print() <<
"Warning: " <<
field_name <<
" has no s_rho dimension in "
111 <<
file_names[0] <<
"; the same value will be used at every "
112 <<
"vertical level. ROMS expects river tracers to be given as "
113 <<
"(river_time, s_rho, river)." << std::endl;
118 amrex::Vector<amrex::FArrayBox*>
NC_fabs;
119 amrex::Vector<std::string>
NC_names;
121 amrex::Print() <<
"Reading in river_Vshape from " <<
file_names[0] << std::endl;
184 amrex::Vector<amrex::FArrayBox*>
NC_fabs;
185 amrex::Vector<std::string>
NC_names;
192 amrex::Print() <<
"Reading in " <<
field_name <<
" at time index " <<
itime
203 amrex::Box
riv_domain(amrex::IntVect(0,0,0), amrex::IntVect(
nriv-1,0,
nz-1));
mf_h setVal(geomdata.ProbHi(2))
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.
std::string ReadNetCDFVarAttrStr(const std::string &fname, const std::string &var_name, const std::string &attr_name)
Helper function for reading a single variable attribute.
NCTimeSeriesRiver(const amrex::Vector< std::string > &a_file_names, const std::string a_field_name, const std::string a_time_name, const int a_nz, const int a_use_vert_integ=0, const int a_is_transport=0)
int nriv
Number of rivers.
amrex::Real time_before
Time in ocean_time immediately before the last time interpolated to.
int nzbox
How many vertical cells there are in the data fabs.
void update_interpolated_to_time(amrex::Real time)
Calculate.
amrex::Vector< int > file_itime_offset
Offset to access a particular time within its file.
amrex::Vector< std::string > file_names
File names to read from.
std::string time_name
Field name for time series in netcdf file.
amrex::Vector< amrex::Real > river_times
Time points in netcdf file.
std::string field_name
Field name in netcdf file.
amrex::FArrayBox * fab_vshape
Vshape data if needed.
amrex::FArrayBox * fab_after
int i_time_before
Time index immediately before the last time interpolated to.
void read_in_at_time(amrex::FArrayBox *vec, int itime)
amrex::FArrayBox * fab_before
FABs to pointers of river data.
int nz
Number of vertical points.
amrex::Vector< int > file_for_time
File index to access a particular time.
amrex::FArrayBox * fab_interp
Container for interpolated data; Only used if save_interpolated == true.
int has_z
Whether the field is specified in the z-dimension.
amrex::Real time_after
Time in ocean_time immediately after the last time interpolated to.
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,...