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);
126 const std::string& fname,
127 FArrayBox& NC_fcor_fab)
129 amrex::Print() <<
"Loading initial coriolis from NetCDF file " << fname << std::endl;
131 Vector<FArrayBox*> NC_fabs;
132 Vector<std::string> NC_names;
133 Vector<enum NC_Data_Dims_Type> NC_dim_types;
138 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
152 const std::string& fname,
153 FArrayBox& NC_mskr_fab,
154 FArrayBox& NC_msku_fab,
155 FArrayBox& NC_mskv_fab)
157 amrex::Print() <<
"Loading masks from NetCDF file " << fname << std::endl;
159 Vector<FArrayBox*> NC_fabs;
160 Vector<std::string> NC_names;
161 Vector<enum NC_Data_Dims_Type> NC_dim_types;
163 NC_fabs.push_back(&NC_mskr_fab ) ; NC_names.push_back(
"mask_rho") ; NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
168 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
187 const std::string& fname,
188 bool do_m2_clim_nudg,
189 bool do_m3_clim_nudg,
190 bool do_temp_clim_nudg,
191 bool do_salt_clim_nudg,
192 FArrayBox& NC_M2NC_fab,
193 FArrayBox& NC_M3NC_fab,
194 FArrayBox& NC_TempNC_fab,
195 FArrayBox& NC_SaltNC_fab)
197 amrex::Print() <<
"Loading nudging coefficients from NetCDF file " << fname << std::endl;
199 Vector<FArrayBox*> NC_fabs;
200 Vector<std::string> NC_names;
201 Vector<enum NC_Data_Dims_Type> NC_dim_types;
203 if (do_m3_clim_nudg) {
206 if (do_m2_clim_nudg) {
207 NC_fabs.push_back(&NC_M2NC_fab ); NC_names.push_back(
"M2_NudgeCoef"); NC_dim_types.push_back(
NC_Data_Dims_Type::SN_WE);
209 if (do_temp_clim_nudg) {
212 if (do_salt_clim_nudg) {
216 BuildFABsFromNetCDFFile<FArrayBox,Real>(domain, fname, NC_names, NC_dim_types, NC_fabs);
226void read_vec_from_netcdf (
int ,
const std::string& fname,
const std::string& field_name, amrex::Vector<int>& vec_dat)
228 amrex::Print() <<
"Reading " << field_name <<
" from NetCDF file" << std::endl;
232 amrex::Vector<ARRAY> array_dat(1);
234 if (amrex::ParallelDescriptor::IOProcessor())
236 int n = array_dat[0].get_vshape()[0];
237 for (
int i(0); i < n; i++)
239 vec_dat.push_back((*(array_dat[0].get_data() + i)));
242 int nvals = vec_dat.size();
243 int ioproc = amrex::ParallelDescriptor::IOProcessorNumber();
244 amrex::ParallelDescriptor::Bcast(&nvals,1,ioproc);
245 if (!(amrex::ParallelDescriptor::IOProcessor())) {
246 vec_dat.resize(nvals);
248 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_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
void read_vec_from_netcdf(int, const std::string &fname, const std::string &field_name, amrex::Vector< int > &vec_dat)
helper function to read in vector of data from netcdf
NDArray is the datatype designed to hold any data, including scalars, multidimensional arrays,...