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);
52 const std::string& fname,
53 FArrayBox& NC_temp_fab, FArrayBox& NC_salt_fab,
54 FArrayBox& NC_xvel_fab, FArrayBox& NC_yvel_fab,
57 amrex::Print() <<
"Loading initial solution data from NetCDF file " << fname << std::endl;
59 Vector<FArrayBox*> NC_fabs;
60 Vector<std::string> NC_names;
61 Vector<enum NC_Data_Dims_Type> NC_dim_types;
69 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
81 const std::string& fname,
82 FArrayBox& NC_zeta_fab)
84 amrex::Print() <<
"Loading initial sea surface height from NetCDF file " << fname << std::endl;
86 Vector<FArrayBox*> NC_fabs;
87 Vector<std::string> NC_names;
88 Vector<enum NC_Data_Dims_Type> NC_dim_types;
93 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
106 const std::string& fname,
107 FArrayBox& NC_zeta_fab,
110 amrex::Print() <<
"Loading initial sea surface height from NetCDF file " << fname << std::endl;
112 Vector<FArrayBox*> NC_fabs;
113 Vector<std::string> NC_names;
114 Vector<enum NC_Data_Dims_Type> NC_dim_types;
119 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
131 const std::string& fname,
134 amrex::Print() <<
"Loading initial bathymetry from NetCDF file " << fname << std::endl;
136 Vector<FArrayBox*> NC_fabs;
137 Vector<std::string> NC_names;
138 Vector<enum NC_Data_Dims_Type> NC_dim_types;
143 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
164 const std::string& fname,
165 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
166 FArrayBox& NC_xr_fab, FArrayBox& NC_yr_fab,
167 FArrayBox& NC_xu_fab, FArrayBox& NC_yu_fab,
168 FArrayBox& NC_xv_fab, FArrayBox& NC_yv_fab,
169 FArrayBox& NC_xp_fab, FArrayBox& NC_yp_fab)
171 amrex::Print() <<
"Loading grid variables from NetCDF file " << fname << std::endl;
173 Vector<FArrayBox*> NC_fabs;
174 Vector<std::string> NC_names;
175 Vector<enum NC_Data_Dims_Type> NC_dim_types;
189 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
200 const std::string& fname,
201 FArrayBox& NC_h_fab, IntVect ngrow)
203 amrex::Print() <<
"Loading high resolution bathymetry from NetCDF file " << fname << std::endl;
205 Vector<FArrayBox*> NC_fabs;
206 Vector<std::string> NC_names;
207 Vector<enum NC_Data_Dims_Type> NC_dim_types;
212 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
225 const std::string& fname,
226 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
229 amrex::Print() <<
"Loading high resolution grid variables from NetCDF file " << fname << std::endl;
231 Vector<FArrayBox*> NC_fabs;
232 Vector<std::string> NC_names;
233 Vector<enum NC_Data_Dims_Type> NC_dim_types;
238 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs,
false, 0, ngrow);
250 const std::string& fname,
251 FArrayBox& NC_fcor_fab)
253 amrex::Print() <<
"Loading initial coriolis from NetCDF file " << fname << std::endl;
255 Vector<FArrayBox*> NC_fabs;
256 Vector<std::string> NC_names;
257 Vector<enum NC_Data_Dims_Type> NC_dim_types;
262 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
276 const std::string& fname,
277 FArrayBox& NC_mskr_fab,
278 FArrayBox& NC_msku_fab,
279 FArrayBox& NC_mskv_fab)
281 amrex::Print() <<
"Loading masks from NetCDF file " << fname << std::endl;
283 Vector<FArrayBox*> NC_fabs;
284 Vector<std::string> NC_names;
285 Vector<enum NC_Data_Dims_Type> NC_dim_types;
287 NC_fabs.push_back(&NC_mskr_fab ) ; NC_names.push_back(
"mask_rho") ; NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
292 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
311 const std::string& fname,
312 bool do_m2_clim_nudg,
313 bool do_m3_clim_nudg,
314 bool do_temp_clim_nudg,
315 bool do_salt_clim_nudg,
316 FArrayBox& NC_M2NC_fab,
317 FArrayBox& NC_M3NC_fab,
318 FArrayBox& NC_TempNC_fab,
319 FArrayBox& NC_SaltNC_fab)
321 amrex::Print() <<
"Loading nudging coefficients from NetCDF file " << fname << std::endl;
323 Vector<FArrayBox*> NC_fabs;
324 Vector<std::string> NC_names;
325 Vector<enum NC_Data_Dims_Type> NC_dim_types;
327 if (do_m3_clim_nudg) {
330 if (do_m2_clim_nudg) {
331 NC_fabs.push_back(&NC_M2NC_fab ); NC_names.push_back(
"M2_NudgeCoef"); NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
333 if (do_temp_clim_nudg) {
336 if (do_salt_clim_nudg) {
340 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
350void read_vec_from_netcdf (
int ,
const amrex::Vector<std::string>& fnames,
const std::string& field_name, amrex::Vector<int>& vec_dat)
352 AMREX_ALWAYS_ASSERT(!fnames.empty());
353 const std::string& fname = fnames[0];
355 amrex::Print() <<
"Reading " << field_name <<
" from NetCDF file" << std::endl;
359 amrex::Vector<ARRAY> array_dat(1);
361 if (amrex::ParallelDescriptor::IOProcessor())
363 int n = array_dat[0].get_vshape()[0];
364 for (
int i(0); i < n; i++)
366 vec_dat.push_back((*(array_dat[0].get_data() + i)));
369 int nvals = vec_dat.size();
370 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
371 amrex::ParallelDescriptor::Bcast(&nvals,1,ioproc);
372 if (!(amrex::ParallelDescriptor::IOProcessor())) {
373 vec_dat.resize(nvals);
375 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_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_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 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,...