2#include "AMReX_FArrayBox.H"
7#ifdef REMORA_USE_NETCDF
20 const std::string& fname,
21 FArrayBox& NC_temp_fab, FArrayBox& NC_salt_fab,
22 FArrayBox& NC_xvel_fab, FArrayBox& NC_yvel_fab)
24 amrex::Print() <<
"Loading initial solution data from NetCDF file " << fname << std::endl;
26 Vector<FArrayBox*> NC_fabs;
27 Vector<std::string> NC_names;
28 Vector<enum NC_Data_Dims_Type> NC_dim_types;
36 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
48 const std::string& fname,
49 FArrayBox& NC_zeta_fab)
51 amrex::Print() <<
"Loading initial sea surface height from NetCDF file " << fname << std::endl;
53 Vector<FArrayBox*> NC_fabs;
54 Vector<std::string> NC_names;
55 Vector<enum NC_Data_Dims_Type> NC_dim_types;
60 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
72 const std::string& fname,
75 amrex::Print() <<
"Loading initial bathymetry from NetCDF file " << fname << std::endl;
77 Vector<FArrayBox*> NC_fabs;
78 Vector<std::string> NC_names;
79 Vector<enum NC_Data_Dims_Type> NC_dim_types;
84 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
105 const std::string& fname,
106 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
107 FArrayBox& NC_xr_fab, FArrayBox& NC_yr_fab,
108 FArrayBox& NC_xu_fab, FArrayBox& NC_yu_fab,
109 FArrayBox& NC_xv_fab, FArrayBox& NC_yv_fab,
110 FArrayBox& NC_xp_fab, FArrayBox& NC_yp_fab)
112 amrex::Print() <<
"Loading grid variables from NetCDF file " << fname << std::endl;
114 Vector<FArrayBox*> NC_fabs;
115 Vector<std::string> NC_names;
116 Vector<enum NC_Data_Dims_Type> NC_dim_types;
130 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
141 const std::string& fname,
142 FArrayBox& NC_h_fab, IntVect ngrow)
144 amrex::Print() <<
"Loading high resolution bathymetry from NetCDF file " << fname << std::endl;
146 Vector<FArrayBox*> NC_fabs;
147 Vector<std::string> NC_names;
148 Vector<enum NC_Data_Dims_Type> NC_dim_types;
153 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
166 const std::string& fname,
167 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
170 amrex::Print() <<
"Loading high resolution grid variables from NetCDF file " << fname << std::endl;
172 Vector<FArrayBox*> NC_fabs;
173 Vector<std::string> NC_names;
174 Vector<enum NC_Data_Dims_Type> NC_dim_types;
179 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
191 const std::string& fname,
192 FArrayBox& NC_fcor_fab)
194 amrex::Print() <<
"Loading initial coriolis from NetCDF file " << fname << std::endl;
196 Vector<FArrayBox*> NC_fabs;
197 Vector<std::string> NC_names;
198 Vector<enum NC_Data_Dims_Type> NC_dim_types;
203 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
217 const std::string& fname,
218 FArrayBox& NC_mskr_fab,
219 FArrayBox& NC_msku_fab,
220 FArrayBox& NC_mskv_fab)
222 amrex::Print() <<
"Loading masks from NetCDF file " << fname << std::endl;
224 Vector<FArrayBox*> NC_fabs;
225 Vector<std::string> NC_names;
226 Vector<enum NC_Data_Dims_Type> NC_dim_types;
228 NC_fabs.push_back(&NC_mskr_fab ) ; NC_names.push_back(
"mask_rho") ; NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
233 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
252 const std::string& fname,
253 bool do_m2_clim_nudg,
254 bool do_m3_clim_nudg,
255 bool do_temp_clim_nudg,
256 bool do_salt_clim_nudg,
257 FArrayBox& NC_M2NC_fab,
258 FArrayBox& NC_M3NC_fab,
259 FArrayBox& NC_TempNC_fab,
260 FArrayBox& NC_SaltNC_fab)
262 amrex::Print() <<
"Loading nudging coefficients from NetCDF file " << fname << std::endl;
264 Vector<FArrayBox*> NC_fabs;
265 Vector<std::string> NC_names;
266 Vector<enum NC_Data_Dims_Type> NC_dim_types;
268 if (do_m3_clim_nudg) {
271 if (do_m2_clim_nudg) {
272 NC_fabs.push_back(&NC_M2NC_fab ); NC_names.push_back(
"M2_NudgeCoef"); NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
274 if (do_temp_clim_nudg) {
277 if (do_salt_clim_nudg) {
281 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
291void read_vec_from_netcdf (
int ,
const amrex::Vector<std::string>& fnames,
const std::string& field_name, amrex::Vector<int>& vec_dat)
293 AMREX_ALWAYS_ASSERT(!fnames.empty());
294 const std::string& fname = fnames[0];
296 amrex::Print() <<
"Reading " << field_name <<
" from NetCDF file" << std::endl;
300 amrex::Vector<ARRAY> array_dat(1);
302 if (amrex::ParallelDescriptor::IOProcessor())
304 int n = array_dat[0].get_vshape()[0];
305 for (
int i(0); i < n; i++)
307 vec_dat.push_back((*(array_dat[0].get_data() + i)));
310 int nvals = vec_dat.size();
311 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
312 amrex::ParallelDescriptor::Bcast(&nvals,1,ioproc);
313 if (!(amrex::ParallelDescriptor::IOProcessor())) {
314 vec_dat.resize(nvals);
316 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_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_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_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_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_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
NDArray is the datatype designed to hold any data, including scalars, multidimensional arrays,...