12#ifdef REMORA_USE_NETCDF
17 FArrayBox& NC_temp_fab, FArrayBox& NC_salt_fab,
18 FArrayBox& NC_xvel_fab, FArrayBox& NC_yvel_fab);
23 FArrayBox& NC_temp_fab, FArrayBox& NC_salt_fab,
24 FArrayBox& NC_xvel_fab, FArrayBox& NC_yvel_fab,
30 FArrayBox& NC_mskr_fab, FArrayBox& NC_msku_fab,
31 FArrayBox& NC_mskv_fab);
36 Vector<Vector<FArrayBox>>& bdy_data_xlo,
37 Vector<Vector<FArrayBox>>& bdy_data_xhi,
38 Vector<Vector<FArrayBox>>& bdy_data_ylo,
39 Vector<Vector<FArrayBox>>& bdy_data_yhi,
40 int& width, amrex::Real& start_bdy_time,
41 std::string bdry_time_varname,
47 FArrayBox& temp_fab, FArrayBox& salt_fab,
48 FArrayBox& x_vel_fab, FArrayBox& y_vel_fab,
49 const Vector<FArrayBox>& NC_temp_fab,
50 const Vector<FArrayBox>& NC_salt_fab,
51 const Vector<FArrayBox>& NC_xvel_fab,
52 const Vector<FArrayBox>& NC_yvel_fab);
62 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
63 FArrayBox& NC_xr_fab, FArrayBox& NC_yr_fab,
64 FArrayBox& NC_xu_fab, FArrayBox& NC_yu_fab,
65 FArrayBox& NC_xv_fab, FArrayBox& NC_yv_fab,
66 FArrayBox& NC_xp_fab, FArrayBox& NC_yp_fab);
71 FArrayBox& NC_lonp_fab, FArrayBox& NC_latp_fab);
76 FArrayBox& NC_h_fab, IntVect ngrow);
81 FArrayBox& NC_pm_fab, FArrayBox& NC_pn_fab,
91 FArrayBox& NC_zeta_fab);
96 FArrayBox& NC_zeta_fab, IntVect ngrow);
101 bool do_m2_clim_nudg,
102 bool do_m3_clim_nudg,
103 bool do_temp_clim_nudg,
104 bool do_salt_clim_nudg,
105 FArrayBox& NC_M2NC_fab,
106 FArrayBox& NC_M3NC_fab,
107 FArrayBox& NC_TempNC_fab,
108 FArrayBox& NC_SaltNC_fab);
111void read_vec_from_netcdf (
int lev,
const amrex::Vector<std::string>& fnames,
const std::string& field_name, amrex::Vector<int>& vec_dat);
128 NC_temp_fab[idx], NC_salt_fab[idx],
129 NC_xvel_fab[idx], NC_yvel_fab[idx]);
137#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
141 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
144 FArrayBox &temp_fab = mf_temp[mfi];
145 FArrayBox &salt_fab = mf_salt[mfi];
146 FArrayBox &xvel_fab = (*
xvel_new[lev])[mfi];
147 FArrayBox &yvel_fab = (*
yvel_new[lev])[mfi];
151 NC_temp_fab, NC_salt_fab,
152 NC_xvel_fab, NC_yvel_fab);
165 Vector<FArrayBox> NC_temp_fab ; NC_temp_fab.resize(1);
166 Vector<FArrayBox> NC_salt_fab ; NC_salt_fab.resize(1);
167 Vector<FArrayBox> NC_xvel_fab ; NC_xvel_fab.resize(1);
168 Vector<FArrayBox> NC_yvel_fab ; NC_yvel_fab.resize(1);
171 NC_temp_fab[0], NC_salt_fab[0],
172 NC_xvel_fab[0], NC_yvel_fab[0],
179#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
183 for ( MFIter mfi(mf_temp,
false); mfi.isValid(); ++mfi )
186 FArrayBox &temp_fab = mf_temp[mfi];
187 FArrayBox &salt_fab = mf_salt[mfi];
193 NC_temp_fab, NC_salt_fab,
194 NC_xvel_fab, NC_yvel_fab);
227#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
231 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
233 FArrayBox &zeta_fab = (*
vec_zeta[lev])[mfi];
240 zeta_fab.template copy<RunOn::Device>(NC_zeta_fab[idx],0,0,1);
245 vec_zeta[lev]->FillBoundary(geom[lev].periodicity());
246 (*
physbcs[lev])(*
vec_zeta[lev],*
vec_mskr[lev].get(),0,1,
vec_zeta[lev]->nGrowVect(),
t_new[lev],
zeta_bc(),0,*
vec_zeta[lev],*
vec_msku[lev],*
vec_mskv[lev]);
251 Real told =
t_new[lev];
267 Vector<FArrayBox> NC_zeta_fab ; NC_zeta_fab.resize(1);
273#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
286 zeta_fab.template copy<RunOn::Device>(NC_zeta_fab[0],0,0,1);
320 bool have_spherical_psi =
true;
325 NC_pm_fab[idx], NC_pn_fab[idx],
326 NC_xr_fab[idx], NC_yr_fab[idx],
327 NC_xu_fab[idx], NC_yu_fab[idx],
328 NC_xv_fab[idx], NC_yv_fab[idx],
329 NC_xp_fab[idx], NC_yp_fab[idx]);
335 NC_lonp_fab[idx], NC_latp_fab[idx]) && have_spherical_psi;
338 if (have_spherical_psi &&
vec_lonp[lev] ==
nullptr) {
340 1,
vec_xp[lev]->nGrowVect()));
342 1,
vec_xp[lev]->nGrowVect()));
346#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
350 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
352 FArrayBox &pm_fab = (*
vec_pm[lev])[mfi];
353 FArrayBox &pn_fab = (*
vec_pn[lev])[mfi];
354 FArrayBox &xr_fab = (*
vec_xr[lev])[mfi];
355 FArrayBox &yr_fab = (*
vec_yr[lev])[mfi];
356 FArrayBox &xu_fab = (*
vec_xu[lev])[mfi];
357 FArrayBox &yu_fab = (*
vec_yu[lev])[mfi];
358 FArrayBox &xv_fab = (*
vec_xv[lev])[mfi];
359 FArrayBox &yv_fab = (*
vec_yv[lev])[mfi];
360 FArrayBox &xp_fab = (*
vec_xp[lev])[mfi];
361 FArrayBox &yp_fab = (*
vec_yp[lev])[mfi];
368 pm_fab.template copy<RunOn::Device>(NC_pm_fab[idx]);
369 pn_fab.template copy<RunOn::Device>(NC_pn_fab[idx]);
371 xr_fab.template copy<RunOn::Device>(NC_xr_fab[idx]);
372 yr_fab.template copy<RunOn::Device>(NC_yr_fab[idx]);
373 xu_fab.template copy<RunOn::Device>(NC_xu_fab[idx]);
374 yu_fab.template copy<RunOn::Device>(NC_yu_fab[idx]);
375 xv_fab.template copy<RunOn::Device>(NC_xv_fab[idx]);
376 yv_fab.template copy<RunOn::Device>(NC_yv_fab[idx]);
377 xp_fab.template copy<RunOn::Device>(NC_xp_fab[idx]);
378 yp_fab.template copy<RunOn::Device>(NC_yp_fab[idx]);
380 if (have_spherical_psi) {
381 (*
vec_lonp[lev])[mfi].
template copy<RunOn::Device>(NC_lonp_fab[idx]);
382 (*
vec_latp[lev])[mfi].
template copy<RunOn::Device>(NC_latp_fab[idx]);
389 if (!have_spherical_psi) {
394 Real dummy_time =
zero;
405 int ng =
vec_pm[lev]->nGrow();
407 const auto& dom_lo = amrex::lbound(geom[lev].Domain());
408 const auto& dom_hi = amrex::ubound(geom[lev].Domain());
417 vec_pm[lev]->FillBoundary(geom[lev].periodicity());
418 vec_pn[lev]->FillBoundary(geom[lev].periodicity());
420 vec_xr[lev]->FillBoundary(geom[lev].periodicity());
421 vec_yr[lev]->FillBoundary(geom[lev].periodicity());
422 vec_xu[lev]->FillBoundary(geom[lev].periodicity());
423 vec_yu[lev]->FillBoundary(geom[lev].periodicity());
424 vec_xv[lev]->FillBoundary(geom[lev].periodicity());
425 vec_yv[lev]->FillBoundary(geom[lev].periodicity());
426 vec_xp[lev]->FillBoundary(geom[lev].periodicity());
427 vec_yp[lev]->FillBoundary(geom[lev].periodicity());
429 vec_lonp[lev]->FillBoundary(geom[lev].periodicity());
430 vec_latp[lev]->FillBoundary(geom[lev].periodicity());
451#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
455 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
457 FArrayBox &h_fab = (*
vec_h[lev])[mfi];
465 h_fab.template copy<RunOn::Device>(NC_h_fab[idx],0,0,1);
466 h_fab.template copy<RunOn::Device>(NC_h_fab[idx],0,1,1);
471 const double dummy_time =
zero;
481 vec_h[lev]->FillBoundary(geom[lev].periodicity());
499#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
503 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
505 FArrayBox &fcor_fab = (*
vec_fcor[lev])[mfi];
512 fcor_fab.template copy<RunOn::Device>(NC_fcor_fab[idx]);
516 vec_fcor[lev]->FillBoundary(geom[lev].periodicity());
533 NC_mskr_fab[idx],NC_msku_fab[idx],
537#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
541 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
543 FArrayBox &mskr_fab = (*
vec_mskr[lev])[mfi];
544 FArrayBox &msku_fab = (*
vec_msku[lev])[mfi];
545 FArrayBox &mskv_fab = (*
vec_mskv[lev])[mfi];
552 mskr_fab.template copy<RunOn::Device>(NC_mskr_fab[idx]);
553 msku_fab.template copy<RunOn::Device>(NC_msku_fab[idx]);
554 mskv_fab.template copy<RunOn::Device>(NC_mskv_fab[idx]);
560 vec_mskr[lev]->FillBoundary(geom[lev].periodicity());
561 vec_msku[lev]->FillBoundary(geom[lev].periodicity());
562 vec_mskv[lev]->FillBoundary(geom[lev].periodicity());
563 vec_mskp[lev]->FillBoundary(geom[lev].periodicity());
573 amrex::Error(
"NetCDF boundary file name must be provided via input");
576 amrex::Vector<std::string> field_name = {
"u",
"v",
"temp",
"salt",
"ubar",
"vbar",
"zeta"};
577 amrex::Vector<IntVect > index_types = {IntVect(1,0,0), IntVect(0,1,0),
578 IntVect(0,0,0), IntVect(0,0,0),
579 IntVect(1,0,0), IntVect(0,1,0),
581 std::vector<bool > is_2d = {
false,
false,
false,
false,
true,
true,
true};
583 amrex::Print() <<
"DOING INIT AT LEVEL " << lev << std::endl;
584 int rx = 1;
int ry = 1;
586 for (
int k = lev-1; k >= 0; k--) {
587 rx *= ref_ratio[k][0];
588 ry *= ref_ratio[k][1];
616 FArrayBox& temp_fab, FArrayBox& salt_fab,
617 FArrayBox& x_vel_fab, FArrayBox& y_vel_fab,
618 const Vector<FArrayBox>& NC_temp_fab,
619 const Vector<FArrayBox>& NC_salt_fab,
620 const Vector<FArrayBox>& NC_xvel_fab,
621 const Vector<FArrayBox>& NC_yvel_fab)
623 int nboxes = NC_xvel_fab.size();
624 for (
int idx = 0; idx < nboxes; idx++)
630 temp_fab.template copy<RunOn::Device>(NC_temp_fab[idx]);
631 salt_fab.template copy<RunOn::Device>(NC_salt_fab[idx]);
632 x_vel_fab.template copy<RunOn::Device>(NC_xvel_fab[idx]);
633 y_vel_fab.template copy<RunOn::Device>(NC_yvel_fab[idx]);
656 NC_M2NC_fab[idx],NC_M3NC_fab[idx],
657 NC_TempNC_fab[idx],NC_SaltNC_fab[idx]);
660#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
664 for ( MFIter mfi(*
cons_new[lev],
false); mfi.isValid(); ++mfi )
668 ubarNC_fab.template copy<RunOn::Device>(NC_M2NC_fab[idx]);
670 vbarNC_fab.template copy<RunOn::Device>(NC_M2NC_fab[idx]);
674 uNC_fab.template copy<RunOn::Device>(NC_M3NC_fab[idx]);
676 vNC_fab.template copy<RunOn::Device>(NC_M3NC_fab[idx]);
680 TempNC_fab.template copy<RunOn::Device>(NC_TempNC_fab[idx]);
684 SaltNC_fab.template copy<RunOn::Device>(NC_SaltNC_fab[idx]);
719 amrex::Vector<int> river_pos_x;
720 amrex::Vector<int> river_pos_y;
721 amrex::Vector<int> river_direction_tmp;
723 std::string river_x_name =
"river_Xposition";
724 std::string river_y_name =
"river_Eposition";
725 std::string river_dir_name =
"river_direction";
731 if (river_pos_x.empty() ||
732 river_pos_y.size() != river_pos_x.size() ||
733 river_direction_tmp.size() != river_pos_x.size())
735 amrex::Abort(
"River metadata arrays must be nonempty and have matching lengths: " +
736 river_x_name +
"=" + std::to_string(river_pos_x.size()) +
", " +
737 river_y_name +
"=" + std::to_string(river_pos_y.size()) +
", " +
738 river_dir_name +
"=" + std::to_string(river_direction_tmp.size()));
741 int nriv = river_pos_x.size();
742 amrex::Gpu::DeviceVector<int> xpos_d(nriv);
743 amrex::Gpu::DeviceVector<int> ypos_d(nriv);
751 amrex::Vector<int> river_pos_x_lev(nriv);
752 amrex::Vector<int> river_pos_y_lev(nriv);
753 for (
int iriv = 0; iriv < nriv; ++iriv) {
754 int x0 = river_pos_x[iriv] - 1;
755 int y0 = river_pos_y[iriv] - 1;
757 if (river_direction_tmp[iriv] == 0) {
759 river_pos_x_lev[iriv] = x0 *
rrx;
760 river_pos_y_lev[iriv] = y0 *
rry + (
rry - 1) / 2;
763 river_pos_x_lev[iriv] = x0 *
rrx + (
rrx - 1) / 2;
764 river_pos_y_lev[iriv] = y0 *
rry;
768 Gpu::htod_memcpy(xpos_d.data(), river_pos_x_lev.data(),
sizeof(
int)*nriv);
769 Gpu::htod_memcpy(ypos_d.data(), river_pos_y_lev.data(),
sizeof(
int)*nriv);
770 Gpu::htod_memcpy(
river_direction.data(), river_direction_tmp.data(),
sizeof(
int)*nriv);
772 std::memcpy(xpos_d.data(), river_pos_x_lev.data(),
sizeof(
int)*nriv);
773 std::memcpy(ypos_d.data(), river_pos_y_lev.data(),
sizeof(
int)*nriv);
774 std::memcpy(
river_direction.data(), river_direction_tmp.data(),
sizeof(
int)*nriv);
776 const int* xpos_ptr = xpos_d.data();
777 const int* ypos_ptr = ypos_d.data();
779 for (amrex::MFIter mfi(*(
vec_river_position[lev]).get(),
true); mfi.isValid(); ++mfi) {
780 amrex::Box bx = mfi.growntilebox(amrex::IntVect(
NGROW,
NGROW,0));
782 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int ) {
783 for (
int iriv=0; iriv < nriv; iriv++) {
784 int xriv = xpos_ptr[iriv];
785 int yriv = ypos_ptr[iriv];
786 if (i==xriv && j==yriv) {
787 river_pos(i,j,0) = iriv;
794 amrex::Print() <<
"[river-debug] lev=" << lev
795 <<
" ref_ratio=(" <<
rrx <<
"," <<
rry <<
")"
796 <<
" nriv=" << nriv <<
'\n';
797 for (
int iriv = 0; iriv < nriv; ++iriv) {
798 amrex::Print() <<
"[river-debug] river " << iriv
799 <<
" dir=" << river_direction_tmp[iriv]
800 <<
" nc=(" << river_pos_x[iriv] <<
"," << river_pos_y[iriv] <<
")"
801 <<
" lev=(" << river_pos_x_lev[iriv] + 1 <<
"," << river_pos_y_lev[iriv] + 1 <<
")"
812 Real inv_days_to_inv_s =
one / (Real(3600.0) * Real(24.0));
814 for ( MFIter mfi(*mf, TilingIfNotGPU()); mfi.isValid(); ++mfi )
816 Array4<Real>
const& arr = mf->array(mfi);
817 Box bx = mfi.growntilebox(IntVect(
NGROW,
NGROW,0));
818 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
819 arr(i,j,k) *= inv_days_to_inv_s;
829 Abort(
"Must specify high-resolution grid file when initializing from NetCDF and hires_grid_level > 0");
831 Vector<FArrayBox> NC_h_fab ; NC_h_fab.resize(1);
838 h_fab.template copy<RunOn::Device>(NC_h_fab[0]);
852 Abort(
"Must specify high-resolution grid file when initializing from NetCDF and hires_grid_level > 0");
854 Vector<FArrayBox> NC_pm_fab ; NC_pm_fab.resize(1);
855 Vector<FArrayBox> NC_pn_fab ; NC_pn_fab.resize(1);
858 NC_pm_fab[0], NC_pn_fab[0],
866 pm_fab.template copy<RunOn::Device>(NC_pm_fab[0]);
867 pn_fab.template copy<RunOn::Device>(NC_pn_fab[0]);
876 int rrx = ref_ratio[lev][0];
877 int rry = ref_ratio[lev][1];
879 for ( MFIter mfi(*
vec_h_full_domain[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
883 Box ubx = mfi.growntilebox(
cum_ref_ratios[lev] - IntVect(1,0,0));;
884 Box vbx = mfi.growntilebox(
cum_ref_ratios[lev] - IntVect(0,1,0));;
885 ParallelFor(makeSlab(ubx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int ) {
886 pm(i,j,0) = pm(i,j,0) / Real(
rrx);
888 ParallelFor(makeSlab(vbx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int ) {
889 pn(i,j,0) = pn(i,j,0) / Real(
rry);
907 const IntVect ng = mf.nGrowVect();
909 const auto& dom_lo = amrex::lbound(geom.Domain());
910 const auto& dom_hi = amrex::ubound(geom.Domain());
912 for ( MFIter mfi(mf); mfi.isValid(); ++mfi )
914 Box bx = mfi.tilebox();
916 auto mf_arr = mf.array(mfi);
918 Box gbx_lox = adjCellLo(bx,0,ng[0]); gbx_lox.grow(1,ng[1]); gbx_lox.setBig (0,dom_lo.x-2);
919 Box gbx_hix = adjCellHi(bx,0,ng[0]); gbx_hix.grow(1,ng[1]); gbx_hix.setSmall(0,dom_hi.x+2);
920 Box gbx_loy = adjCellLo(bx,1,ng[1]); gbx_loy.grow(0,ng[0]); gbx_loy.setBig (1,dom_lo.y-2);
921 Box gbx_hiy = adjCellHi(bx,1,ng[1]); gbx_hiy.grow(0,ng[0]); gbx_hiy.setSmall(1,dom_hi.y+2);
924 ParallelFor(gbx_lox, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
926 mf_arr(i,j,k,0) = mf_arr(dom_lo.x-1,j,k,0);
930 ParallelFor(gbx_hix, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
932 mf_arr(i,j,k,0) = mf_arr(dom_hi.x+1,j,k,0);
936 ParallelFor(gbx_loy, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
938 mf_arr(i,j,k,0) = mf_arr(i,dom_lo.y-1,k,0);
942 ParallelFor(gbx_hiy, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
944 mf_arr(i,j,k,0) = mf_arr(i,dom_hi.y+1,k,0);
constexpr amrex::Real one
constexpr amrex::Real zero
void read_vec_from_netcdf(int lev, 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_coriolis_from_netcdf(int lev, const Box &domain, const std::string &fname, FArrayBox &NC_fcor_fab)
helper function to read coriolis factor from netcdf
void read_grid_vars_from_netcdf(int lev, 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_zeta_from_netcdf(int lev, const Box &domain, const std::string &fname, FArrayBox &NC_zeta_fab)
helper function to read sea surface height from netcdf
Real read_bdry_from_netcdf(const Box &domain, const std::string &fname, Vector< Vector< FArrayBox > > &bdy_data_xlo, Vector< Vector< FArrayBox > > &bdy_data_xhi, Vector< Vector< FArrayBox > > &bdy_data_ylo, Vector< Vector< FArrayBox > > &bdy_data_yhi, int &width, amrex::Real &start_bdy_time, std::string bdry_time_varname, amrex::GpuArray< amrex::GpuArray< bool, AMREX_SPACEDIM *2 >, BdyVars::NumTypes+1 > &)
helper function for reading boundary data from netcdf
void read_bathymetry_from_netcdf(int lev, const Box &domain, const std::string &fname, FArrayBox &NC_h_fab)
helper function to read bathymetry 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 init_state_from_netcdf(int lev, FArrayBox &temp_fab, FArrayBox &salt_fab, FArrayBox &x_vel_fab, FArrayBox &y_vel_fab, const Vector< FArrayBox > &NC_temp_fab, const Vector< FArrayBox > &NC_salt_fab, const Vector< FArrayBox > &NC_xvel_fab, const Vector< FArrayBox > &NC_yvel_fab)
helper function to initialize state 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_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_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_zeta_full_domain_from_netcdf(int lev, 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
bool read_spherical_grid_vars_from_netcdf(int lev, const Box &domain, const std::string &fname, FArrayBox &NC_lonp_fab, FArrayBox &NC_latp_fab)
helper function to read optional spherical psi coordinates 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
void read_clim_nudg_coeff_from_netcdf(int lev, 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
A class to hold and interpolate time series data read from a NetCDF file.
std::string nc_grid_file_hires
Grid file for high resolution bathymetry.
amrex::Vector< std::string > nc_riv_file
NetCDF river file(s)
int foextrap_periodic_bc() const noexcept
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_full_domain
high resolution initial free surface height (2D)
std::string nc_init_file_hires
Init file for high resolution.
void init_bathymetry_from_netcdf(int lev)
Bathymetry data initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_fcor
coriolis factor (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xvel_full_domain
multilevel data container for high res initial x velocities (u in ROMS)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h
multilevel data container for current step's z velocities (largely unused; W stored separately)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm
horizontal scaling factor: 1 / dx (2D)
void init_zeta_full_domain_from_netcdf()
Full-domain high res sea-surface height data initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yv
y_grid on v-points (2D)
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
void init_grid_vars_from_netcdf(int lev)
Grid variable initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yp
y_grid on psi-points (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xr
x_grid on rho points (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xv
x_grid on v-points (2D)
void fill_from_bdyfiles(int lev, amrex::MultiFab &mf_to_fill, const amrex::MultiFab &mf_mask, const amrex::Real time, const int bccomp, const int bdy_var_type, const int icomp_to_fill, const int icomp_calc=0, const amrex::MultiFab &mf_calc=amrex::MultiFab(), const amrex::Real=zero)
Fill boundary data from netcdf file.
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku
land/sea mask at x-faces (2D)
void extrapolate_metric_to_physical_boundaries(amrex::MultiFab &mf, const amrex::Geometry &geom)
Extrapolate grid metrics to edge of MultiFab.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm_full_domain
horizontal scaling factor: 1 / dx (2D) on whole domain
void init_data_from_netcdf(int lev)
Problem initialization from NetCDF file.
void init_masks_from_netcdf(int lev)
Mask data initialization from NetCDF file.
amrex::Vector< amrex::MultiFab * > yvel_new
multilevel data container for current step's y velocities (v in ROMS)
amrex::Box nc_hires_init_box
Box for the full domain at nc_hires_init_level.
int zeta_bc() const noexcept
amrex::Vector< amrex::IntVect > cum_ref_ratios
Cumulative refinement ratio between level 0 and level i.
amrex::Vector< int > num_boxes_at_level
how many boxes specified at each level by tagging criteria
amrex::Vector< amrex::MultiFab * > xvel_new
multilevel data container for current step's x velocities (u in ROMS)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskp
land/sea mask at cell corners (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lonp
longitude on psi-points (2D, degrees east); only filled when the grid NetCDF file carries lon_psi
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
std::string nc_clim_coeff_file
NetCDF climatology coefficient file.
amrex::Vector< std::string > bdry_time_name_byvar
Name of time fields for boundary data.
void init_riv_pos_from_netcdf(int lev)
static amrex::Vector< std::string > nc_bdry_file
NetCDF boundary data.
void update_mskp(int lev)
Set psi-point mask to be consistent with rho-point mask.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yvel_full_domain
multilevel data container for high res initial y velocities (v in ROMS)
void init_zeta_from_netcdf(int lev)
Sea-surface height data initialization from NetCDF file.
void init_coriolis_from_netcdf(int lev)
Coriolis parameter data initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h_full_domain
Bathymetry data on the whole domain at each potential level.
void init_data_full_domain_from_netcdf()
High resolution roblem initialization from NetCDF file.
int hires_init_level
Which level the high resolution initialization data is at.
int nscalar
Number of passive scalars carried in the state.
void average_down_with_grow_cells(int lev, amrex::Vector< std::unique_ptr< amrex::MultiFab > > &mf)
Average down from level lev+1 to lev in mf, including grow cells.
amrex::Vector< amrex::Real > t_new
new time at each level
void init_bdry_from_netcdf(int lev)
Boundary data initialization from NetCDF file.
static SolverChoice solverChoice
Container for algorithmic choices.
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > vec_river_position
iMultiFab for river positions; contents are indices of rivers
amrex::Vector< amrex::Vector< std::unique_ptr< NCTimeSeriesBoundary > > > boundary_series
Vector over BdyVars of boundary series data containers.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xp
x_grid on psi-points (2D)
static amrex::Vector< amrex::Vector< std::string > > nc_grid_file
NetCDF grid file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
amrex::Gpu::DeviceVector< int > river_direction
Vector over rivers of river direction: 0: u-face; 1: v-face; 2: w-face.
amrex::Box nc_hires_grid_box
Box for the full domain at nc_hires_grid_level.
void init_clim_nudg_coeff_from_netcdf(int lev)
Climatology nudging coefficient initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cons_full_domain
multilevel data container for high res initial data: temperature, salinity, passive tracer
void FillPatch(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=false, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab())
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
void init_bathymetry_full_domain_from_netcdf()
Full domain high-res bathymetry data initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yu
y_grid on u-points (2D)
void init_grid_vars_full_domain_from_netcdf()
Full domain high-res grid variable initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xu
x_grid on u-points (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn_full_domain
horizontal scaling factor: 1 / dy (2D) on whole domain
amrex::GpuArray< amrex::GpuArray< bool, AMREX_SPACEDIM *2 >, BdyVars::NumTypes+1 > phys_bc_need_data
These are flags that indicate whether we need to read in boundary data from file.
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > vec_nudg_coeff
Climatology nudging coefficients.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn
horizontal scaling factor: 1 / dy (2D)
static int verbose
Verbosity level of output.
static amrex::Vector< amrex::Vector< std::string > > nc_init_file
NetCDF initialization file.
amrex::Vector< amrex::Real > t_old
old time at each level
int hires_grid_level
Which level the high resolution bathymetry is at.
void convert_inv_days_to_inv_s(amrex::MultiFab *)
Convert data in a multifab from inverse days to inverse seconds.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yr
y_grid on rho points (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_latp
latitude on psi-points (2D, degrees north); only filled when the grid NetCDF file carries lat_psi
bool boundary_from_netcdf