8#include <AMReX_buildInfo.H>
43#ifdef REMORA_USE_NETCDF
64 BL_PROFILE(
"REMORA::REMORA()");
66 if (ParallelDescriptor::IOProcessor()) {
69 const char* buildgithash = amrex::buildInfoGetBuildGitHash();
70 const char* buildgitname = amrex::buildInfoGetBuildGitName();
72 if (strlen(remora_hash) > 0) {
73 amrex::Print() <<
"\n"
74 <<
"REMORA git hash: " << remora_hash <<
"\n";
76 if (strlen(amrex_hash) > 0) {
77 amrex::Print() <<
"AMReX git hash: " << amrex_hash <<
"\n";
79 if (strlen(buildgithash) > 0) {
80 amrex::Print() << buildgitname <<
" git hash: " << buildgithash <<
"\n";
83 amrex::Print() <<
"\n";
98 int nlevs_max = max_level + 1;
100 istep.resize(nlevs_max, 0);
102 for (
int lev = 1; lev <= max_level; ++lev) {
108 t_new.resize(nlevs_max, 0.0_rt);
109 t_old.resize(nlevs_max, -1.e100_rt);
110 dt.resize(nlevs_max, 1.e100_rt);
126 IntVect cum_ref_ratio = IntVect(1,1,0);
130 for (
int lev = 0; lev < max_level; ++lev)
132 amrex::Print() <<
"Refinement ratio at level " << lev <<
" set to be " <<
133 ref_ratio[lev][0] <<
" " << ref_ratio[lev][1] <<
" " << ref_ratio[lev][2] << std::endl;
135 if (ref_ratio[lev][2] != 1)
137 amrex::Print() <<
"********************************************************************************" << std::endl;
138 amrex::Print() <<
"We don't allow refinement in the vertical -- make sure to set ref_ratio = 1 in z" << std::endl;
139 amrex::Print() <<
"It's possible you set amr.ref_ratio when you meant to set amr.ref_ratio_vect " << std::endl;
140 amrex::Print() <<
"********************************************************************************" << std::endl;
144 cum_ref_ratio[0] *= ref_ratio[lev][0];
145 cum_ref_ratio[1] *= ref_ratio[lev][1];
150REMORA::REMORA (
const amrex::RealBox& rb,
int max_level_in,
const amrex::Vector<int>& n_cell_in,
int coord,
const amrex::Vector<amrex::IntVect>& ref_ratio_in,
const amrex::Array<int,AMREX_SPACEDIM>& is_per, std::string prefix)
151 :
amrex::AmrCore (rb, max_level_in, n_cell_in, coord, ref_ratio_in, is_per)
153 BL_PROFILE(
"REMORA::REMORA(explicit)");
156 if (ParallelDescriptor::IOProcessor()) {
159 const char* buildgithash = amrex::buildInfoGetBuildGitHash();
160 const char* buildgitname = amrex::buildInfoGetBuildGitName();
162 if (strlen(remora_hash) > 0) {
163 amrex::Print() <<
"\n"
164 <<
"REMORA git hash: " << remora_hash <<
"\n";
166 if (strlen(amrex_hash) > 0) {
167 amrex::Print() <<
"AMReX git hash: " << amrex_hash <<
"\n";
169 if (strlen(buildgithash) > 0) {
170 amrex::Print() << buildgitname <<
" git hash: " << buildgithash <<
"\n";
173 amrex::Print() <<
"\n";
183 int nlevs_max = max_level + 1;
185 istep.resize(nlevs_max, 0);
187 for (
int lev = 1; lev <= max_level; ++lev) {
193 t_new.resize(nlevs_max, 0.0_rt);
194 t_old.resize(nlevs_max, -1.e100_rt);
195 dt.resize(nlevs_max, 1.e100_rt);
210 for (
int lev = 0; lev < max_level; ++lev)
212 amrex::Print() <<
"Refinement ratio at level " << lev <<
" set to be " <<
213 ref_ratio[lev][0] <<
" " << ref_ratio[lev][1] <<
" " << ref_ratio[lev][2] << std::endl;
215 if (ref_ratio[lev][2] != 1)
217 amrex::Print() <<
"********************************************************************************" << std::endl;
218 amrex::Print() <<
"We don't allow refinement in the vertical -- make sure to set ref_ratio = 1 in z" << std::endl;
219 amrex::Print() <<
"It's possible you set amr.ref_ratio when you meant to set amr.ref_ratio_vect " << std::endl;
220 amrex::Print() <<
"********************************************************************************" << std::endl;
238 for (
int i = 1; i <
nscalar; ++i) {
239 cons_names.emplace_back(
"tracer_" + std::to_string(i));
246 BL_PROFILE(
"REMORA::Evolve()");
247 Real cur_time =
t_new[0];
253 amrex::Print() <<
"\nCoarse STEP " << step+1 <<
" starts ..." << std::endl;
259 auto dEvolveTime0 = amrex::second();
261 if (max_level == 0) {
270 amrex::Print() <<
"Coarse STEP " << step+1 <<
" ends." <<
" TIME = " << cur_time
271 <<
" DT = " <<
dt[0] << std::endl;
275 auto dEvolveTime = amrex::second() - dEvolveTime0;
276 ParallelDescriptor::ReduceRealMax(dEvolveTime,ParallelDescriptor::IOProcessorNumber());
277 amrex::Print() <<
"Timestep time = " << dEvolveTime <<
" seconds." <<
'\n';
298#ifdef AMREX_MEM_PROFILING
300 std::ostringstream ss;
301 ss <<
"[STEP " << step+1 <<
"]";
302 MemProfiler::report(ss.str());
328 BL_PROFILE(
"REMORA::post_timestep()");
330#ifdef REMORA_USE_PARTICLES
331 particleData.Redistribute();
336 for (
int lev = finest_level-1; lev >= 0; lev--)
360 BL_PROFILE(
"REMORA::InitData()");
390#ifdef REMORA_USE_MOAB
396 for (
int lev = 1; lev <= finest_level; lev++)
398 advflux_reg[lev].reset(
new YAFluxRegister(grids[lev], grids[lev-1],
399 dmap[lev], dmap[lev-1],
400 geom[lev], geom[lev-1],
401 ref_ratio[lev-1], lev,
ncons));
406 for (
int lev = 0; lev <= finest_level; ++lev)
413 FillPatch(lev,
t_new[lev], *
cons_new[lev],
cons_new,
BCVars::cons_bc,
BdyVars::t, 0,
true,
false,0,0,0.0,*
cons_new[lev]);
414 FillPatch(lev,
t_new[lev], *
xvel_new[lev],
xvel_new,
xvel_bc(),
BdyVars::u, 0,
true,
false,0,0,0.0,*
xvel_new[lev]);
415 FillPatch(lev,
t_new[lev], *
yvel_new[lev],
yvel_new,
yvel_bc(),
BdyVars::v, 0,
true,
false,0,0,0.0,*
yvel_new[lev]);
465 BL_PROFILE(
"REMORA::Construct_REMORAFillPatchers()");
466 amrex::Print() <<
":::Construct_REMORAFillPatchers " << lev << std::endl;
468 auto& ba_fine =
cons_new[lev ]->boxArray();
469 auto& ba_crse =
cons_new[lev-1]->boxArray();
470 auto& dm_fine =
cons_new[lev ]->DistributionMap();
471 auto& dm_crse =
cons_new[lev-1]->DistributionMap();
473 BoxList bl2d_fine = ba_fine.boxList();
474 for (
auto& b : bl2d_fine) {
477 BoxArray ba2d_fine(std::move(bl2d_fine));
479 BoxList bl2d_crse = ba_crse.boxList();
480 for (
auto& b : bl2d_crse) {
483 BoxArray ba2d_crse(std::move(bl2d_crse));
487 FPr_c.emplace_back(ba_fine, dm_fine, geom[lev] ,
488 ba_crse, dm_crse, geom[lev-1],
490 FPr_u.emplace_back(convert(ba_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
491 convert(ba_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
493 FPr_v.emplace_back(convert(ba_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
494 convert(ba_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
496 FPr_w.emplace_back(convert(ba_fine, IntVect(0,0,1)), dm_fine, geom[lev] ,
497 convert(ba_crse, IntVect(0,0,1)), dm_crse, geom[lev-1],
500 FPr_ubar.emplace_back(convert(ba2d_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
501 convert(ba2d_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
503 FPr_vbar.emplace_back(convert(ba2d_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
504 convert(ba2d_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
514 BL_PROFILE(
"REMORA::Define_REMORAFillPatchers()");
515 amrex::Print() <<
":::Define_REMORAFillPatchers " << lev << std::endl;
517 auto& ba_fine =
cons_new[lev ]->boxArray();
518 auto& ba_crse =
cons_new[lev-1]->boxArray();
519 auto& dm_fine =
cons_new[lev ]->DistributionMap();
520 auto& dm_crse =
cons_new[lev-1]->DistributionMap();
522 BoxList bl2d_fine = ba_fine.boxList();
523 for (
auto& b : bl2d_fine) {
526 BoxArray ba2d_fine(std::move(bl2d_fine));
528 BoxList bl2d_crse = ba_crse.boxList();
529 for (
auto& b : bl2d_crse) {
532 BoxArray ba2d_crse(std::move(bl2d_crse));
537 FPr_c[lev-1].Define(ba_fine, dm_fine, geom[lev] ,
538 ba_crse, dm_crse, geom[lev-1],
540 FPr_u[lev-1].Define(convert(ba_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
541 convert(ba_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
543 FPr_v[lev-1].Define(convert(ba_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
544 convert(ba_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
546 FPr_w[lev-1].Define(convert(ba_fine, IntVect(0,0,1)), dm_fine, geom[lev] ,
547 convert(ba_crse, IntVect(0,0,1)), dm_crse, geom[lev-1],
550 FPr_ubar[lev-1].Define(convert(ba2d_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
551 convert(ba2d_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
553 FPr_vbar[lev-1].Define(convert(ba2d_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
554 convert(ba2d_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
561 BL_PROFILE(
"REMORA::restart()");
574 BL_PROFILE(
"REMORA::set_zeta()");
580#ifdef REMORA_USE_NETCDF
581 amrex::Print() <<
"Calling init_zeta_from_netcdf on level " << lev << std::endl;
583 amrex::Print() <<
"Sea surface height loaded from netcdf file \n " << std::endl;
586 amrex::Abort(
"Unknown IC_Type");
591 vec_zeta[lev]->FillBoundary(geom[lev].periodicity());
597 Real dummy_time = 0.0_rt;
601 vec_zeta[lev]->FillBoundary(geom[lev].periodicity());
613 BL_PROFILE(
"REMORA::bathymetry()");
625#ifdef REMORA_USE_NETCDF
626 amrex::Print() <<
"Calling init_bathymetry_from_netcdf " << std::endl;
628 amrex::Print() <<
"Bathymetry loaded from netcdf file \n " << std::endl;
629 amrex::Print() <<
"Calling init_grid_vars_from_netcdf " << std::endl;
631 amrex::Print() <<
"Grid variables loaded from netcdf file \n " << std::endl;
634 amrex::Abort(
"Unknown IC_Type");
642 vec_h[lev]->FillBoundary(geom[lev].periodicity());
643 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
649 Real dummy_time = 0.0_rt;
653 vec_h[lev]->FillBoundary(geom[lev].periodicity());
654 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
665 Real dummy_time = 0.0_rt;
682 Real dummy_time = 0.0_rt;
703 0,
false,
false,0,0,0.0,*
vec_zeta[lev]);
718 FillPatch(lev,
t_new[lev], *
cons_new[lev],
cons_new,
BCVars::cons_bc,
BdyVars::t, 0,
true,
false,0,0,0.0,*
cons_new[lev]);
719 FillPatch(lev,
t_new[lev], *
xvel_new[lev],
xvel_new,
xvel_bc(),
BdyVars::u, 0,
true,
false,0,0,0.0,*
xvel_new[lev]);
720 FillPatch(lev,
t_new[lev], *
yvel_new[lev],
yvel_new,
yvel_bc(),
BdyVars::v, 0,
true,
false,0,0,0.0,*
yvel_new[lev]);
728 BL_PROFILE(
"REMORA::set_coriolis()");
734#ifdef REMORA_USE_NETCDF
737 amrex::Print() <<
"Calling init_coriolis_from_netcdf " << std::endl;
739 amrex::Print() <<
"Coriolis loaded from netcdf file \n" << std::endl;
741 Real dummy_time = 0.0_rt;
746 Abort(
"Don't know this coriolis_type!");
751 vec_fcor[lev]->EnforcePeriodicity(geom[lev].periodicity());
757 BL_PROFILE(
"REMORA::init_set_vmix()");
765 Abort(
"Don't know this vertical mixing type");
774 BL_PROFILE(
"REMORA::set_analytic_vmix()");
780 for (
int n = 0; n <
ncons; n++) {
795#ifdef REMORA_USE_NETCDF
797 amrex::Print() <<
"Calling init_masks_from_netcdf level " << lev << std::endl;
799 amrex::Print() <<
"Masks loaded from netcdf file \n " << std::endl;
801 Real dummy_time = 0.0_rt;
817 BL_PROFILE(
"REMORA::set_hmixcoef()");
822 Real lev_scale = 1.0_rt;
825 for (
int l = 0; l < lev; ++l) {
826 rf *= std::sqrt(
static_cast<Real
>(ref_ratio[l][0]) *
static_cast<Real
>(ref_ratio[l][1]));
828 lev_scale = 1.0_rt / rf;
838 for (
int n = 0; n <
ncons; n++) {
871 for (
int n = 0; n <
ncons; n++) {
879 amrex::Gpu::LaunchSafeGuard lsg(
true);
880 Real denom_min = amrex::ReduceMin(*
vec_pm[lev], *
vec_pn[lev], 0,
881 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
882 Array4<Real const>
const& pm,
883 Array4<Real const>
const& pn) -> Real
885 Real local_min = 1.0e200_rt;
886 amrex::Loop(bx, [=,&local_min] (
int i,
int j,
int)
noexcept
888 local_min = amrex::min(local_min, pm(i,j,0) * pn(i,j,0));
893 ParallelDescriptor::ReduceRealMin(denom_min);
894 if (denom_min <= 0.0_rt) {
895 Abort(
"scaled_to_grid: found non-positive pm*pn (grid metrics must be > 0)");
898 Real grdmax = amrex::ReduceMax(*
vec_pm[lev], *
vec_pn[lev], 0,
899 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
900 Array4<Real const>
const& pm,
901 Array4<Real const>
const& pn) -> Real
903 Real local_max = 0.0_rt;
904 amrex::Loop(bx, [=,&local_max] (
int i,
int j,
int)
noexcept
906 Real denom = pm(i,j,0) * pn(i,j,0);
907 if (denom > 0.0_rt) {
908 Real G = std::sqrt(1.0_rt / denom);
909 local_max = amrex::max(local_max, G);
915 ParallelDescriptor::ReduceRealMax(grdmax);
916 if (grdmax <= 0.0_rt) {
917 Abort(
"scaled_to_grid: grdmax <= 0");
926 for (
int l = 0; l < lev; ++l) {
927 rf *= std::sqrt(
static_cast<Real
>(ref_ratio[l][0]) *
static_cast<Real
>(ref_ratio[l][1]));
929 lev_scale = 1.0_rt / rf;
933 Real cff = visc0 / grdmax;
938 amrex::Gpu::DeviceVector<Real> diff0_d(
ncons);
939 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
942 Real
const* diff0_ptr = diff0_d.data();
944 for (MFIter mfi(*
vec_visc2_r[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
946 const Box& bx = mfi.validbox();
947 auto pm =
vec_pm[lev]->const_array(mfi);
948 auto pn =
vec_pn[lev]->const_array(mfi);
952 int ncons_local =
ncons;
953 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
noexcept
955 Real denom = pm(i,j,0) * pn(i,j,0);
956 Real grdscl = (denom > 0.0_rt) ? std::sqrt(1.0_rt / denom) : 0.0_rt;
957 visc2_r(i,j,0) = cff * grdscl;
959 for (
int n = 0; n < ncons_local; n++) {
960 diff2(i,j,0,n) = ((diff0_ptr[n] * lev_scale) / grdmax) * grdscl;
972 for (MFIter mfi(*
vec_visc2_p[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
974 const Box& bx = mfi.validbox();
978 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
noexcept
980 visc2_p(i,j,0) = 0.25_rt * (
997 Real visc_min_all =
vec_visc2_r[lev]->min(0,0,
false);
998 Real visc_max_all =
vec_visc2_r[lev]->max(0,0,
false);
1001 amrex::Gpu::LaunchSafeGuard lsg_diag(
true);
1003 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1004 Array4<Real const>
const& visc2,
1005 Array4<Real const>
const& mskr) -> Real
1007 Real local_min = 1.0e200_rt;
1008 amrex::Loop(bx, [=,&local_min] (
int i,
int j,
int)
noexcept
1010 if (mskr(i,j,0) > 0.0_rt) {
1011 local_min = amrex::min(local_min, visc2(i,j,0));
1016 ParallelDescriptor::ReduceRealMin(visc_min_wet);
1019 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1020 Array4<Real const>
const& visc2,
1021 Array4<Real const>
const& mskr) -> Real
1023 Real local_max = -1.0e200_rt;
1024 amrex::Loop(bx, [=,&local_max] (
int i,
int j,
int)
noexcept
1026 if (mskr(i,j,0) > 0.0_rt) {
1027 local_max = amrex::max(local_max, visc2(i,j,0));
1032 ParallelDescriptor::ReduceRealMax(visc_max_wet);
1036 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1037 Array4<Real const>
const& visc2,
1038 Array4<Real const>
const& mskr) -> Real
1040 Real local_min = 1.0e200_rt;
1041 amrex::Loop(bx, [=,&local_min] (
int i,
int j,
int)
noexcept
1043 const Real v = (mskr(i,j,0) > 0.0_rt) ? visc2(i,j,0) : 0.0_rt;
1044 local_min = amrex::min(local_min, v);
1048 ParallelDescriptor::ReduceRealMin(visc_min_mask0);
1051 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1052 Array4<Real const>
const& visc2,
1053 Array4<Real const>
const& mskr) -> Real
1055 Real local_max = -1.0e200_rt;
1056 amrex::Loop(bx, [=,&local_max] (
int i,
int j,
int)
noexcept
1058 const Real v = (mskr(i,j,0) > 0.0_rt) ? visc2(i,j,0) : 0.0_rt;
1059 local_max = amrex::max(local_max, v);
1063 ParallelDescriptor::ReduceRealMax(visc_max_mask0);
1064 if (ParallelDescriptor::IOProcessor() && lev == 0)
1066 Print() <<
"\nHorizontal mixing scaled by grid metric\n";
1067 Print() <<
"grdmax = " << grdmax <<
"\n";
1069 Print() <<
"AMR scaling (linear) lev_scale = " << lev_scale <<
"\n";
1071 Print() <<
"visc2(all) min/max = "
1072 << visc_min_all <<
" / "
1073 << visc_max_all <<
"\n";
1074 Print() <<
"visc2(wet,k=0) min/max = "
1075 << visc_min_wet <<
" / "
1076 << visc_max_wet <<
"\n";
1077 Print() <<
"visc2(mask->0) min/max = "
1078 << visc_min_mask0 <<
" / "
1079 << visc_max_mask0 <<
"\n";
1083 Abort(
"Don't know this horizontal mixing type");
1090 for (
int n = 0; n <
ncons; n++) {
1102 BL_PROFILE(
"REMORA::init_flat_bathymetry()");
1103 vec_h[lev]->setVal(-geom[0].ProbLo()[2]);
1112 BL_PROFILE(
"REMORA::set_smflux()");
1116#ifdef REMORA_USE_NETCDF
1131 BL_PROFILE(
"REMORA::set_wind()");
1138 if (!(driver_has_uwind && driver_has_vwind)) {
1141 if (
vec_uwind[lev] !=
nullptr) {
vec_uwind[lev]->FillBoundary(geom[lev].periodicity()); }
1142 if (
vec_vwind[lev] !=
nullptr) {
vec_vwind[lev]->FillBoundary(geom[lev].periodicity()); }
1144#ifdef REMORA_USE_NETCDF
1145 if (!driver_has_uwind) {
1150 if (
vec_uwind[lev] !=
nullptr) {
vec_uwind[lev]->FillBoundary(geom[lev].periodicity()); }
1152 if (!driver_has_vwind) {
1157 if (
vec_vwind[lev] !=
nullptr) {
vec_vwind[lev]->FillBoundary(geom[lev].periodicity()); }
1166 vec_Tair[lev]->FillBoundary(geom[lev].periodicity());
1178 vec_qair[lev]->FillBoundary(geom[lev].periodicity());
1181 vec_qair[lev]->FillBoundary(geom[lev].periodicity());
1188 vec_Pair[lev]->FillBoundary(geom[lev].periodicity());
1195 vec_srflx[lev]->FillBoundary(geom[lev].periodicity());
1209 vec_rain[lev]->FillBoundary(geom[lev].periodicity());
1216 vec_cloud[lev]->FillBoundary(geom[lev].periodicity());
1223 vec_EminusP[lev]->FillBoundary(geom[lev].periodicity());
1227 amrex::Abort(
"Unknown wind_type in REMORA::set_wind()");
1238 BL_PROFILE(
"REMORA::init_only()");
1240 t_old[lev] = time - 1.e200_rt;
1251 vec_ru[lev]->setVal(0.0_rt);
1252 vec_rv[lev]->setVal(0.0_rt);
1262#ifdef REMORA_USE_NETCDF
1268 amrex::Error(
"NetCDF climatology file name must be provided via input");
1298 amrex::Print() <<
"Calling init_bdry_from_netcdf at level " << lev << std::endl;
1300 amrex::Print() <<
"Boundary data loaded from netcdf file \n " << std::endl;
1307 amrex::Error(
"NetCDF forcing file name must be provided via input for winds");
1320 amrex::Error(
"NetCDF forcing file name must be provided via input for surface momentum fluxes");
1388 amrex::Error(
"NetCDF forcing file name must be provided via input for longwave radiation");
1402 amrex::Error(
"NetCDF river file name must be provided via input for rivers");
1404 auto dom = geom[0].Domain();
1405 int nz = dom.length(2);
1427 amrex::Print() <<
"Reading high resolution bathymetry and grid data" << std::endl;
1431 amrex::Print() <<
"Done reading in high resolution bathymetry and grid data" << std::endl;
1434 amrex::Print() <<
"Reading high resolution initial data" << std::endl;
1438 amrex::Print() <<
"Done reading in high resolution initial data" << std::endl;
1442 Abort(
"Not compiled with NetCDF, but selected boundary conditions require NetCDF");
1445 Abort(
"Not compiled with NetCDF, but using river sources requires NetCDF");
1472#ifdef REMORA_USE_NETCDF
1473 amrex::Print() <<
"Calling init_data_from_netcdf " << std::endl;
1476 amrex::Print() <<
"Initial data loaded from netcdf file \n " << std::endl;
1479 amrex::Abort(
"Unknown IC_Type");
1507 xvel_new[lev]->OverrideSync(geom[lev].periodicity());
1508 yvel_new[lev]->OverrideSync(geom[lev].periodicity());
1509 zvel_new[lev]->OverrideSync(geom[lev].periodicity());
1528 BL_PROFILE(
"REMORA::ReadParameters()");
1531 bool noprefix_max_step = pp.queryAdd(
"max_step",
max_step);
1532 bool noprefix_stop_time = pp.queryAdd(
"stop_time",
stop_time);
1533 bool remora_max_step = pp.queryAdd(
"remora.max_step",
max_step);
1534 bool remora_stop_time = pp.queryAdd(
"remora.stop_time",
stop_time);
1535 if (remora_max_step and noprefix_max_step) {
1536 Abort(
"remora.max_step and max_step are both specified. Please use only one!");
1538 if (remora_stop_time and noprefix_stop_time) {
1539 Abort(
"remora.stop_time and stop_time are both specified. Please use only one!");
1546 pp.queryAdd(
"nscalar",
nscalar);
1548 amrex::Abort(
"remora.nscalar must be at least 1");
1568 if (pp.contains(
"data_log")) {
1569 int num_datalogs = pp.countval(
"data_log");
1572 pp.queryarr(
"data_log",
datalogname, 0, num_datalogs);
1573 for (
int i = 0; i < num_datalogs; i++)
1579 pp.queryAdd(
"sum_period",
sum_per);
1583 amrex::Abort(
"remora.file_min_digits must be non-negative");
1586 pp.queryAdd(
"cfl",
cfl);
1594 amrex::Abort(
"Dt is over-specfied");
1613 std::string plotfile_type_str =
"amrex";
1614 pp.queryAdd(
"plotfile_type", plotfile_type_str);
1615 if (plotfile_type_str ==
"amrex") {
1617 }
else if (plotfile_type_str ==
"netcdf" || plotfile_type_str ==
"NetCDF") {
1619#ifdef REMORA_USE_NETCDF
1624 auto dom = geom[0].Domain();
1625 int nx = dom.length(0) + 2;
1626 int ny = dom.length(1) + 2;
1627 int nz = dom.length(2);
1631 / (nx * ny * 64.0_rt * (
NC3D*nz +
NC2D)));
1636 amrex::Warning(
"NetCDF output for a single timestep appears to exceed 2GB. NetCDF output may not work. See Documentation for information about tested MPICH versions.");
1642 Real est_hist_file_size =
NCH2D * nx * ny * 64.0_rt + nt_out * nx * ny * 64.0_rt * (
NC3D*nz +
NC2D);
1643 if (est_hist_file_size > 1.6e10) {
1644 amrex::Warning(
"WARNING: NetCDF history file may be larger than 2GB limit. Consider setting remora.chunk_history_file=true");
1648 Print() <<
"NetCDF history files will have " <<
steps_per_history_file <<
" steps per file." << std::endl;
1652 amrex::Print() <<
"User selected plotfile_type = " << plotfile_type_str << std::endl;
1653 amrex::Abort(
"Dont know this plotfile_type");
1655#ifndef REMORA_USE_NETCDF
1658 amrex::Abort(
"Please compile with NetCDF in order to enable NetCDF plotfiles");
1662#ifdef REMORA_USE_NETCDF
1672 for (
int lev = 0; lev <= max_level; lev++)
1674 const std::string nc_file_names = amrex::Concatenate(
"nc_init_file_",lev,1);
1675 const std::string nc_bathy_file_names = amrex::Concatenate(
"nc_grid_file_",lev,1);
1677 if (pp.contains(nc_file_names.c_str()))
1679 int num_files = pp.countval(nc_file_names.c_str());
1680 int num_bathy_files = pp.countval(nc_bathy_file_names.c_str());
1681 if (num_files != num_bathy_files) {
1682 amrex::Error(
"Must have same number of netcdf files for grid info as for solution");
1689 pp.queryarr(nc_file_names.c_str() ,
nc_init_file[lev] ,0,num_files);
1690 pp.queryarr(nc_bathy_file_names.c_str(),
nc_grid_file[lev],0,num_files);
1701 if (pp.contains(
"nc_frc_file")) {
1702 int num_files = pp.countval(
"nc_frc_file");
1704 pp.queryarr(
"nc_frc_file",
nc_frc_file, 0, num_files);
1708 if (pp.contains(
"nc_river_file")) {
1709 int num_files = pp.countval(
"nc_river_file");
1711 pp.queryarr(
"nc_river_file",
nc_riv_file, 0, num_files);
1715 if (pp.contains(
"nc_clim_his_file")) {
1716 int num_files = pp.countval(
"nc_clim_his_file");
1755 amrex::Abort(
"hires_grid_level must be less than or equal to amr.max_level");
1759 amrex::Abort(
"hires_init_level must be less than or equal to amr.max_level");
1761#ifdef REMORA_USE_PARTICLES
1762 readTracersParams();
1766 ParmParse pp_amr(
"amr");
1770 amrex::Abort(
"Time substepping is not yet implemented. amr.do_substep must be 0");
1783 amrex::Abort(
"Cannot do high-resolution initialization for analytic initial conditions. Not yet implemented");
1792 BL_PROFILE(
"REMORA::AverageDown()");
1793 for (
int lev = finest_level-1; lev >= 0; --lev)
1805 BL_PROFILE(
"REMORA::AverageDownTo()");
1807 0,
cons_new[crse_lev]->nComp(), refRatio(crse_lev));
1809 0,
vec_Zt_avg1[crse_lev]->nComp(), refRatio(crse_lev));
1811 Array<MultiFab*,AMREX_SPACEDIM> faces_crse;
1812 Array<MultiFab*,AMREX_SPACEDIM> faces_fine;
1813 faces_crse[0] =
xvel_new[crse_lev];
1814 faces_crse[1] =
yvel_new[crse_lev];
1815 faces_crse[2] =
zvel_new[crse_lev];
1817 faces_fine[0] =
xvel_new[crse_lev+1];
1818 faces_fine[1] =
yvel_new[crse_lev+1];
1819 faces_fine[2] =
zvel_new[crse_lev+1];
1821 average_down_faces(GetArrOfConstPtrs(faces_fine), faces_crse,
1822 refRatio(crse_lev),geom[crse_lev]);
1833 auto const& crsema = vec_mf[crse_lev]->arrays();
1834 auto const& finema = vec_mf[crse_lev+1]->const_arrays();
1835 auto ref_ratio_crse = refRatio(crse_lev);
1836 auto index_type = (vec_mf[crse_lev]->boxArray().ixType()).toIntVect();
1838 if (index_type[0]==0 and index_type[1]==0) {
1839 ParallelFor(*vec_mf[crse_lev], nghost_crse, vec_mf[crse_lev]->nComp(),
1840 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k,
int n)
noexcept
1842 amrex_avgdown(i,j,k,n,crsema[box_no],finema[box_no],0,0,ref_ratio_crse);
1844 }
else if (index_type[0]==1 and index_type[1]==0) {
1845 ParallelFor(*vec_mf[crse_lev], nghost_crse, 1,
1846 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k,
int n)
noexcept
1848 amrex_avgdown_faces(i,j,k,n,crsema[box_no],finema[box_no],0,0,ref_ratio_crse,0);
1850 }
else if (index_type[0]==0 and index_type[1]==1) {
1851 ParallelFor(*vec_mf[crse_lev], nghost_crse, 1,
1852 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k,
int n)
noexcept
1854 amrex_avgdown_faces(i,j,k,n,crsema[box_no],finema[box_no],0,0,ref_ratio_crse,1);
1857 amrex::Abort(
"Unexpected nodality in average_down_with_grow_cells");
1859 Gpu::streamSynchronize();
PlotfileType
plotfile format
std::unique_ptr< ProblemBase > amrex_probinit(const amrex_real *problo, const amrex_real *probhi) AMREX_ATTRIBUTE_WEAK
Function to init the physical bounds of the domain and instantiate a Problem derived from ProblemBase...
A class to hold and interpolate time series data read from a NetCDF file.
static PlotfileType plotfile_type
Native or NetCDF plotfile output.
std::string nc_grid_file_hires
Grid file for high resolution bathymetry.
void FillCoarsePatchPC(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level using the piecewise constant interpol...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_EminusP
evaporation minus precipitation [kg/m^2/s], defined at rho-points
amrex::Vector< std::string > nc_riv_file
NetCDF river file(s)
void set_grid_vars_averaged_down(int lev)
Set pm/pn by averaging down from higher-resolution grid.
std::string riv_time_varname
Name of time field for river time.
int foextrap_periodic_bc() const noexcept
amrex::Vector< std::string > nc_clim_his_file
NetCDF climatology history file(s)
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_full_domain
high resolution initial free surface height (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv2d
v velocity RHS (2D, includes horizontal and vertical advection)
std::string nc_init_file_hires
Init file for high resolution.
static amrex::Real fixed_dt
User specified fixed baroclinic time step.
amrex::Real last_plot_file_time
Simulation time when we last output a plotfile.
int zvel_bc() const noexcept
void init_full_domain_zeta_from_analytic()
Initialize high resolution initial sea surface height from analytic functions.
void init_bathymetry_from_netcdf(int lev)
Bathymetry data initialization from NetCDF file.
void init_bcs()
Read in boundary parameters from input file and set up data structures.
int xvel_bc() const noexcept
void set_zeta_averaged_down(int lev)
Copy over zeta data that has been averaged down from high res.
void calculate_nodal_masks(int lev)
Calculate u-, v-, and psi-point masks based on rho-point masks after analytic initialization.
std::unique_ptr< NCTimeSeries > qair_data_from_file
Data container for specific humidity read from file.
static amrex::Real previousCPUTimeUsed
Accumulator variable for CPU time used thusfar.
amrex::Vector< std::string > cons_names
Names of scalars for plotfile output.
amrex::Vector< std::unique_ptr< amrex::YAFluxRegister > > advflux_reg
array of flux registers for refluxing in multilevel
std::unique_ptr< NCTimeSeries > sustr_data_from_file
Data container for u-component surface momentum flux read from file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_fcor
coriolis factor (2D)
void allocate_init_full_domain()
Allocate multifabs for storing full-domain high resolution initial data.
void init_gls_vmix(int lev, SolverChoice solver_choice)
Initialize GLS variables.
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 set2DPlotVariables(const std::string &pp_plot_var_names_2d)
amrex::Vector< REMORAFillPatcher > FPr_v
Vector over levels of FillPatchers for v (3D)
void init_zeta_full_domain_from_netcdf()
Full-domain high res sea-surface height data initialization from NetCDF file.
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
static bool write_history_file
Whether to output NetCDF files as a single history file with several time steps.
void FillCoarsePatch(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level
void stretch_transform(int lev)
Calculate vertical stretched coordinates.
std::unique_ptr< NCTimeSeries > rain_data_from_file
Data container for precipitation rate read from file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vwind
Wind in the v direction, defined at rho-points.
std::unique_ptr< ProblemBase > prob
Pointer to container of analytical functions for problem definition.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
void Construct_REMORAFillPatchers(int lev)
Construct FillPatchers.
void init_grid_vars_from_netcdf(int lev)
Grid variable initialization from NetCDF file.
static int sum_interval
Diagnostic sum output interval in number of steps.
int history_count
Counter for which time index we are writing to in the netcdf history file.
amrex::Real stop_time
Time to stop.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rain
precipitation rate [kg/m^2/s]
int do_substep
Whether to substep fine levels in time.
void Evolve()
Advance solution to final time.
std::string bdry_time_varname
Default name of time field for boundary data.
amrex::Real plotfile_fill_value
fill value for masked arrays in amrex plotfiles
void ReadCheckpointFile()
read checkpoint file from disk
bool chunk_history_file
Whether to chunk netcdf history file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sustr
Surface stress in the u direction.
amrex::Real get_t_old(int lev) const
Accessor method for t_old to expose to outside classes.
int yvel_bc() const noexcept
std::unique_ptr< NCTimeSeries > longwave_down_data_from_file
Data container for downward longwave radiation flux read from file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru2d
u velocity RHS (2D, includes horizontal and vertical advection)
amrex::Vector< std::string > datalogname
amrex::Vector< amrex::MultiFab * > zvel_new
multilevel data container for current step's z velocities (largely unused; W stored separately)
void init_only(int lev, amrex::Real time)
Init (NOT restart or regrid)
void init_set_vmix(int lev)
Initialize vertical mixing coefficients from file or analytic.
std::unique_ptr< NCTimeSeries > v_clim_data_from_file
Data container for v-velocity climatology data read from file.
std::string clim_u_time_varname
Name of time field for u climatology data.
void set_grid_scale(int lev)
Set pm and pn arrays and x/y coords on level lev.
void set_coriolis(int lev)
Initialize Coriolis factor from file or analytic.
int foextrap_bc() const noexcept
amrex::Vector< REMORAFillPatcher > FPr_u
Vector over levels of FillPatchers for u (3D)
std::string clim_temp_time_varname
Name of time field for temperature climatology data.
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
static amrex::Vector< amrex::AMRErrorTag > ref_tags
Holds info for dynamically generated tagging criteria.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akt
Vertical diffusion coefficient (3D)
std::unique_ptr< NCTimeSeriesRiver > river_source_transportbar
Data container for vertically integrated momentum transport in rivers.
std::array< bool, AtmosState::NumTypes > driver_atmos_state_from_driver
provenance flags for driver-supplied atmospheric forcing lanes
std::string clim_ubar_time_varname
Name of time field for ubar climatology data.
std::unique_ptr< NCTimeSeries > u_clim_data_from_file
Data container for u-velocity climatology data read from file.
std::string check_file
Checkpoint file prefix.
static amrex::Real startCPUTime
Variable for CPU timing.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm_full_domain
horizontal scaling factor: 1 / dx (2D) on whole domain
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
amrex::Real start_time
Time of the start of the simulation, in seconds.
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::Vector< std::unique_ptr< amrex::MultiFab > > vec_uwind
Wind in the u direction, defined at rho-points.
static amrex::Real fixed_fast_dt
User specified fixed barotropic time step.
int regrid_int
how often each level regrids the higher levels of refinement (after a level advances that many time s...
amrex::Real check_int_time
Checkpoint output interval in seconds.
void init_scalar_metadata()
Build runtime scalar names after nscalar is known.
int zeta_bc() const noexcept
void Define_REMORAFillPatchers(int lev)
Define FillPatchers.
amrex::Vector< amrex::IntVect > cum_ref_ratios
Cumulative refinement ratio between level 0 and level i.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_p
Harmonic viscosity defined on the psi points (corners of horizontal grid cells)
amrex::Real plot_int_time
Plotfile output interval in seconds.
amrex::Vector< int > num_files_at_level
how many netcdf input files specified at each level
amrex::Vector< REMORAFillPatcher > FPr_vbar
Vector over levels of FillPatchers for vbar (2D)
void AverageDownTo(int crse_lev)
more flexible version of AverageDown() that lets you average down across multiple levels
int steps_per_history_file
Number of time steps per netcdf history file.
void post_timestep(int nstep, amrex::Real time, amrex::Real dt_lev)
Called after every level 0 timestep.
int max_step
maximum number of steps
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
std::unique_ptr< NCTimeSeries > svstr_data_from_file
Data container for v-component surface momentum flux read from file.
amrex::Vector< std::string > nc_frc_file
NetCDF forcing file(s)
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)
void refinement_criteria_setup()
Set refinement criteria.
int last_check_file_step
Step when we last output a checkpoint file.
void init_beta_plane_coriolis(int lev)
Calculate Coriolis parameters from beta plane parametrization.
std::string clim_vbar_time_varname
Name of time field for vbar climatology data.
amrex::Vector< int > nsubsteps
How many substeps on each level?
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
void ComputeDt()
a wrapper for estTimeStep()
void fill_3d_masks(int lev)
Copy maskr to all z levels.
std::unique_ptr< NCTimeSeries > EminusP_data_from_file
Data container for evaporation minus precipitation read from file.
int plot_int
Plotfile output interval in iterations.
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=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
std::unique_ptr< NCTimeSeries > cloud_data_from_file
Data container for cloud cover fraction read from file.
void InitData()
Initialize multilevel data.
void set3DPlotVariables(const std::string &pp_plot_var_names_3d)
amrex::Vector< int > istep
which step?
void WriteCheckpointFile()
write checkpoint file to disk
std::string nc_clim_coeff_file
NetCDF climatology coefficient file.
void setRecordDataInfo(int i, const std::string &filename)
void set_analytic_vmix(int lev)
Set vertical mixing coefficients from analytic.
void init_flat_bathymetry(int lev)
Initialize flat bathymetry to value from problo.
std::unique_ptr< NCTimeSeries > temp_clim_data_from_file
Data container for temperature climatology data read from file.
amrex::Vector< std::string > bdry_time_name_byvar
Name of time fields for boundary data.
static int file_min_digits
Minimum number of digits in plotfile name or chunked history file.
void init_riv_pos_from_netcdf(int lev)
static amrex::Vector< std::string > nc_bdry_file
NetCDF boundary data.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_r
Harmonic viscosity defined on the rho points (centers)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yvel_full_domain
multilevel data container for high res initial y velocities (v in ROMS)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_svstr
Surface stress in the v direction.
std::unique_ptr< NCTimeSeries > srflx_data_from_file
Data container for shortwave radiation flux read from file.
void set_zeta(int lev)
Initialize zeta from file or analytic.
static amrex::Real change_max
Fraction maximum change in subsequent time steps.
void init_zeta_from_netcdf(int lev)
Sea-surface height data initialization from NetCDF file.
void set_zeta_average(int lev)
Set Zt_avg1 to zeta.
void init_coriolis_from_netcdf(int lev)
Coriolis parameter data initialization from NetCDF file.
std::string pp_prefix
default prefix for input file parameters
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h_full_domain
Bathymetry data on the whole domain at each potential level.
void set_bathymetry(int lev)
Initialize bathymetry from file or analytic.
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
std::unique_ptr< NCTimeSeries > ubar_clim_data_from_file
Data container for ubar climatology data read from file.
void init_full_domain_from_analytic()
Initialize high resolution initial problem data from analytic functions.
void init_data_full_domain_from_netcdf()
High resolution roblem initialization from NetCDF file.
amrex::Vector< REMORAFillPatcher > FPr_c
Vector over levels of FillPatchers for scalars.
int hires_init_level
Which level the high resolution initialization data is at.
std::unique_ptr< NCTimeSeries > Tair_data_from_file
Data container for air temperature read from file.
int nscalar
Number of passive scalars carried in the state.
std::string clim_v_time_varname
Name of time field for v climatology data.
amrex::Vector< REMORAFillPatcher > FPr_w
Vector over levels of FillPatchers for w.
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.
std::string clim_salt_time_varname
Name of time field for salinity climatology data.
std::unique_ptr< NCTimeSeries > Uwind_data_from_file
Data container for u-direction wind read from file.
std::unique_ptr< NCTimeSeries > Pair_data_from_file
Data container for air pressure read from file.
amrex::Vector< amrex::Real > t_new
new time at each level
void init_stretch_coeffs()
initialize and calculate stretch coefficients
void init_bdry_from_netcdf(int lev)
Boundary data initialization from NetCDF file.
static SolverChoice solverChoice
Container for algorithmic choices.
void set_masks(int lev)
Initialize land-sea masks from file or analytic.
amrex::Vector< amrex::Vector< std::unique_ptr< NCTimeSeriesBoundary > > > boundary_series
Vector over BdyVars of boundary series data containers.
int cf_set_width
Width for fixing values at coarse-fine interface.
void ReadParameters()
read in some parameters from inputs file
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru
u velocity RHS (3D, includes horizontal and vertical advection)
void sum_integrated_quantities(amrex::Real time)
Integrate conserved quantities for diagnostics.
static int total_nc_plot_file_step
static int plot_staggered_vels
Whether to write the staggered velocities (not averaged to cell centers)
static amrex::Vector< amrex::Vector< std::string > > nc_grid_file
NetCDF grid file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_longwave_down
Downward longwave radiation.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
void set_zeta_to_Ztavg(int lev)
Set zeta components to be equal to time-averaged Zt_avg1.
bool expand_plotvars_to_unif_rr
whether plotfile variables should be expanded to a uniform refinement ratio
int plot_file_on_restart
Whether to output a plotfile on restart from checkpoint.
void set_2darrays(int lev)
Set 2D momentum arrays from 3D momentum.
void init_analytic(int lev)
Initialize initial problem data from analytic functions.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ubar
barotropic x velocity (2D)
amrex::Vector< amrex::MultiFab * > cons_old
multilevel data container for last step's scalar data: temperature, salinity, passive tracer
std::string frc_time_varname
Name of time field for forcing data.
void set_wind(int lev)
Initialize or calculate wind speed from file or analytic.
amrex::Vector< REMORAFillPatcher > FPr_ubar
Vector over levels of FillPatchers for ubar (2D)
bool is_it_time_for_action(int nstep, amrex::Real time, amrex::Real dt, int action_interval, amrex::Real action_per)
Decide if it is time to take an action.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cons_full_domain
multilevel data container for high res initial data: temperature, salinity, passive tracer
std::unique_ptr< NCTimeSeries > Vwind_data_from_file
Data container for v-direction wind read from file.
void init_bathymetry_full_domain_from_netcdf()
Full domain high-res bathymetry data initialization from NetCDF file.
void set_hmixcoef(int lev)
Initialize horizontal mixing coefficients.
amrex::Vector< std::unique_ptr< NCTimeSeriesRiver > > river_source_cons
Vector of data containers for scalar data in rivers.
void timeStep(int lev, amrex::Real time, int iteration)
advance a level by dt, includes a recursive call for finer levels
std::unique_ptr< NCTimeSeriesRiver > river_source_transport
Data container for momentum transport in rivers.
void init_grid_vars_full_domain_from_netcdf()
Full domain high-res grid variable initialization from NetCDF file.
void AverageDown()
set covered coarse cells to be the average of overlying fine cells
static int fixed_ndtfast_ratio
User specified, number of barotropic steps per baroclinic step.
amrex::Real netcdf_fill_value
fill value for masked arrays in netcdf output
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn_full_domain
horizontal scaling factor: 1 / dy (2D) on whole domain
void timeStepML(amrex::Real time, int iteration)
advance all levels by dt, loops over finer levels
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn
horizontal scaling factor: 1 / dy (2D)
amrex::Vector< std::unique_ptr< std::fstream > > datalog
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
static amrex::Real cfl
CFL condition.
void append3DPlotVariables(const std::string &pp_plot_var_names_3d)
void allocate_bathymetry_grid_vars_full_domain()
Allocate multifabs for storing full-domain bathymetry and grid vars data.
void set_init_data_averaged_down(int lev)
Problem initialization from averaged-down high resolution data.
static int verbose
Verbosity level of output.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cloud
cloud cover fraction [0-1], defined at rho-points
std::string plot_file_name
Plotfile prefix.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Zt_avg1
Average of the free surface, zeta (2D)
std::unique_ptr< NCTimeSeries > salt_clim_data_from_file
Data container for salinity climatology data read from file.
int check_int
Checkpoint output interval in iterations.
void set_smflux(int lev)
Initialize or calculate surface momentum flux from file or analytic.
void WritePlotFile(int istep)
main driver for writing AMReX plotfiles
std::string restart_chkfile
If set, restart from this checkpoint file.
void init_clim_nudg_coeff(int lev)
Wrapper to initialize climatology nudging coefficient.
void init_bathymetry_full_domain_from_analytic()
Full domain bathymetry data initialization from analytic.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv
v velocity RHS (3D, includes horizontal and vertical advection)
int cf_width
Nudging width at coarse-fine interface.
static amrex::Vector< amrex::Vector< std::string > > nc_init_file
NetCDF initialization file.
int last_plot_file_step
Step when we last output a plotfile.
amrex::Vector< amrex::Real > t_old
old time at each level
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_srflx
Shortwave radiation flux [W/m²], defined at rho-points.
amrex::Real last_check_file_time
Simulation time when we last output a checkpoint file.
void append2DPlotVariables(const std::string &pp_plot_var_names_2d)
void set_bathymetry_averaged_down(int lev)
Copy over bathymetry data that has been averaged down from high resolution input netcdf file.
amrex::Vector< amrex::Real > dt
time step at each level
static amrex::Real sum_per
Diagnostic sum output interval in time.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Pair
Air pressure [mb], defined at rho-points.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_qair
Specific humidity [kg/kg], defined at rho-points.
int hires_grid_level
Which level the high resolution bathymetry is at.
std::unique_ptr< NCTimeSeries > vbar_clim_data_from_file
Data container for vbar climatology data read from file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Tair
Air temperature [°C], defined at rho-points.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_diff2
Harmonic diffusivity for temperature / salinity.
static constexpr int cons_bc
static constexpr int Temp_bc_comp
const char * buildInfoGetGitHash(int i)
HorizMixingType horiz_mixing_type
bool longwave_down_from_netcdf
amrex::Vector< amrex::Real > tnu2
std::string longwave_netcdf_varname
amrex::Vector< int > do_rivers_cons
ScaledToGridAMRScaling scaled_to_grid_amr_scaling
bool boundary_from_netcdf
void init_params(int ncons)
read in and initialize parameters
VertMixingType vert_mixing_type
CouplingType coupling_type