2#include "AMReX_FArrayBox.H"
7#ifdef REMORA_USE_NETCDF
22 const std::string& fname,
23 FArrayBox& NC_temp_fab, FArrayBox& NC_salt_fab,
24 FArrayBox& NC_xvel_fab, FArrayBox& NC_yvel_fab,
25 FArrayBox& NC_ubar_fab, FArrayBox& NC_vbar_fab)
27 amrex::Print() <<
"Loading initial solution data from NetCDF file " << fname << std::endl;
29 Vector<FArrayBox*> NC_fabs;
30 Vector<std::string> NC_names;
31 Vector<enum NC_Data_Dims_Type> NC_dim_types;
41 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
53 const std::string& fname,
54 FArrayBox& NC_zeta_fab)
56 amrex::Print() <<
"Loading initial sea surface height from NetCDF file " << fname << std::endl;
58 Vector<FArrayBox*> NC_fabs;
59 Vector<std::string> NC_names;
60 Vector<enum NC_Data_Dims_Type> NC_dim_types;
65 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
87 const std::string& fname,
89 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
90 FArrayBox& NC_xr_fab, FArrayBox& NC_yr_fab,
91 FArrayBox& NC_xu_fab, FArrayBox& NC_yu_fab,
92 FArrayBox& NC_xv_fab, FArrayBox& NC_yv_fab,
93 FArrayBox& NC_xp_fab, FArrayBox& NC_yp_fab)
95 amrex::Print() <<
"Loading initial bathymetry from NetCDF file " << fname << std::endl;
97 Vector<FArrayBox*> NC_fabs;
98 Vector<std::string> NC_names;
99 Vector<enum NC_Data_Dims_Type> NC_dim_types;
114 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
125 const std::string& fname,
126 FArrayBox& NC_h_fab, IntVect ngrow)
128 amrex::Print() <<
"Loading high resolution bathymetry from NetCDF file " << fname << std::endl;
130 Vector<FArrayBox*> NC_fabs;
131 Vector<std::string> NC_names;
132 Vector<enum NC_Data_Dims_Type> NC_dim_types;
137 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
149 const std::string& fname,
150 FArrayBox& NC_fcor_fab)
152 amrex::Print() <<
"Loading initial coriolis from NetCDF file " << fname << std::endl;
154 Vector<FArrayBox*> NC_fabs;
155 Vector<std::string> NC_names;
156 Vector<enum NC_Data_Dims_Type> NC_dim_types;
161 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
175 const std::string& fname,
176 FArrayBox& NC_mskr_fab,
177 FArrayBox& NC_msku_fab,
178 FArrayBox& NC_mskv_fab)
180 amrex::Print() <<
"Loading masks from NetCDF file " << fname << std::endl;
182 Vector<FArrayBox*> NC_fabs;
183 Vector<std::string> NC_names;
184 Vector<enum NC_Data_Dims_Type> NC_dim_types;
186 NC_fabs.push_back(&NC_mskr_fab ) ; NC_names.push_back(
"mask_rho") ; NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
191 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
210 const std::string& fname,
211 bool do_m2_clim_nudg,
212 bool do_m3_clim_nudg,
213 bool do_temp_clim_nudg,
214 bool do_salt_clim_nudg,
215 FArrayBox& NC_M2NC_fab,
216 FArrayBox& NC_M3NC_fab,
217 FArrayBox& NC_TempNC_fab,
218 FArrayBox& NC_SaltNC_fab)
220 amrex::Print() <<
"Loading nudging coefficients from NetCDF file " << fname << std::endl;
222 Vector<FArrayBox*> NC_fabs;
223 Vector<std::string> NC_names;
224 Vector<enum NC_Data_Dims_Type> NC_dim_types;
226 if (do_m3_clim_nudg) {
229 if (do_m2_clim_nudg) {
230 NC_fabs.push_back(&NC_M2NC_fab ); NC_names.push_back(
"M2_NudgeCoef"); NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
232 if (do_temp_clim_nudg) {
235 if (do_salt_clim_nudg) {
239 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
249void read_vec_from_netcdf (
int ,
const amrex::Vector<std::string>& fnames,
const std::string& field_name, amrex::Vector<int>& vec_dat)
251 AMREX_ALWAYS_ASSERT(!fnames.empty());
252 const std::string& fname = fnames[0];
254 amrex::Print() <<
"Reading " << field_name <<
" from NetCDF file" << std::endl;
258 amrex::Vector<ARRAY> array_dat(1);
260 if (amrex::ParallelDescriptor::IOProcessor())
262 int n = array_dat[0].get_vshape()[0];
263 for (
int i(0); i < n; i++)
265 vec_dat.push_back((*(array_dat[0].get_data() + i)));
268 int nvals = vec_dat.size();
269 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
270 amrex::ParallelDescriptor::Bcast(&nvals,1,ioproc);
271 if (!(amrex::ParallelDescriptor::IOProcessor())) {
272 vec_dat.resize(nvals);
274 amrex::ParallelDescriptor::Bcast(vec_dat.data(), vec_dat.size(), ioproc);
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.
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, bool do_temp_clim_nudg, bool do_salt_clim_nudg, FArrayBox &NC_M2NC_fab, FArrayBox &NC_M3NC_fab, FArrayBox &NC_TempNC_fab, FArrayBox &NC_SaltNC_fab)
helper function to read climatology nudging 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, FArrayBox &NC_ubar_fab, FArrayBox &NC_vbar_fab)
helper function for reading in initial state data 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_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_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_zeta_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_zeta_fab)
helper function to read sea surface height from netcdf
void read_bathymetry_from_netcdf(int, const Box &domain, const std::string &fname, FArrayBox &NC_h_fab, 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 bathymetry from netcdf
NDArray is the datatype designed to hold any data, including scalars, multidimensional arrays,...