8#include <AMReX_buildInfo.H>
46#ifdef REMORA_USE_NETCDF
67 BL_PROFILE(
"REMORA::REMORA()");
69 if (ParallelDescriptor::IOProcessor()) {
72 const char* buildgithash = amrex::buildInfoGetBuildGitHash();
73 const char* buildgitname = amrex::buildInfoGetBuildGitName();
75 if (strlen(remora_hash) > 0) {
76 amrex::Print() <<
"\n"
77 <<
"REMORA git hash: " << remora_hash <<
"\n";
79 if (strlen(amrex_hash) > 0) {
80 amrex::Print() <<
"AMReX git hash: " << amrex_hash <<
"\n";
82 if (strlen(buildgithash) > 0) {
83 amrex::Print() << buildgitname <<
" git hash: " << buildgithash <<
"\n";
86 amrex::Print() <<
"\n";
95 Vector<IntVect> blocking_factor_vec = Vector<IntVect>();
96 blocking_factor_vec.resize(max_level+1);
97 for (
int lev = 0; lev <= max_level; ++lev) {
98 blocking_factor_vec[lev] = blockingFactor(lev);
99 blocking_factor_vec[lev][2] = 4096;
101 SetBlockingFactor(blocking_factor_vec);
113 int nlevs_max = max_level + 1;
115 istep.resize(nlevs_max, 0);
117 for (
int lev = 1; lev <= max_level; ++lev) {
141 IntVect cum_ref_ratio = IntVect(1,1,0);
145 for (
int lev = 0; lev < max_level; ++lev)
147 amrex::Print() <<
"Refinement ratio at level " << lev <<
" set to be " <<
148 ref_ratio[lev][0] <<
" " << ref_ratio[lev][1] <<
" " << ref_ratio[lev][2] << std::endl;
150 if (ref_ratio[lev][2] != 1)
152 amrex::Print() <<
"********************************************************************************" << std::endl;
153 amrex::Print() <<
"We don't allow refinement in the vertical -- make sure to set ref_ratio = 1 in z" << std::endl;
154 amrex::Print() <<
"It's possible you set amr.ref_ratio when you meant to set amr.ref_ratio_vect " << std::endl;
155 amrex::Print() <<
"********************************************************************************" << std::endl;
159 cum_ref_ratio[0] *= ref_ratio[lev][0];
160 cum_ref_ratio[1] *= ref_ratio[lev][1];
165REMORA::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)
166 :
amrex::AmrCore (rb, max_level_in, n_cell_in, coord, ref_ratio_in, is_per)
168 BL_PROFILE(
"REMORA::REMORA(explicit)");
171 if (ParallelDescriptor::IOProcessor()) {
174 const char* buildgithash = amrex::buildInfoGetBuildGitHash();
175 const char* buildgitname = amrex::buildInfoGetBuildGitName();
177 if (strlen(remora_hash) > 0) {
178 amrex::Print() <<
"\n"
179 <<
"REMORA git hash: " << remora_hash <<
"\n";
181 if (strlen(amrex_hash) > 0) {
182 amrex::Print() <<
"AMReX git hash: " << amrex_hash <<
"\n";
184 if (strlen(buildgithash) > 0) {
185 amrex::Print() << buildgitname <<
" git hash: " << buildgithash <<
"\n";
188 amrex::Print() <<
"\n";
198 int nlevs_max = max_level + 1;
200 istep.resize(nlevs_max, 0);
202 for (
int lev = 1; lev <= max_level; ++lev) {
225 for (
int lev = 0; lev < max_level; ++lev)
227 amrex::Print() <<
"Refinement ratio at level " << lev <<
" set to be " <<
228 ref_ratio[lev][0] <<
" " << ref_ratio[lev][1] <<
" " << ref_ratio[lev][2] << std::endl;
230 if (ref_ratio[lev][2] != 1)
232 amrex::Print() <<
"********************************************************************************" << std::endl;
233 amrex::Print() <<
"We don't allow refinement in the vertical -- make sure to set ref_ratio = 1 in z" << std::endl;
234 amrex::Print() <<
"It's possible you set amr.ref_ratio when you meant to set amr.ref_ratio_vect " << std::endl;
235 amrex::Print() <<
"********************************************************************************" << std::endl;
253 for (
int i = 1; i <
nscalar; ++i) {
254 cons_names.emplace_back(
"tracer_" + std::to_string(i));
261 BL_PROFILE_VAR(
"REMORA::Evolve()",evolve);
262 Real cur_time =
t_new[0];
268 amrex::Print() <<
"\nCoarse STEP " << step+1 <<
" starts ..." << std::endl;
274 auto dEvolveTime0 = amrex::second();
276 if (max_level == 0) {
285 amrex::Print() <<
"Coarse STEP " << step+1 <<
" ends." <<
" TIME = " << cur_time
286 <<
" DT = " <<
dt[0] << std::endl;
290 auto dEvolveTime = amrex::second() - dEvolveTime0;
291 ParallelDescriptor::ReduceRealMax(dEvolveTime,ParallelDescriptor::IOProcessorNumber());
292 amrex::Print() <<
"Timestep time = " << dEvolveTime <<
" seconds." <<
'\n';
299#ifdef AMREX_MEM_PROFILING
301 std::ostringstream ss;
302 ss <<
"[STEP " << step+1 <<
"]";
303 MemProfiler::report(ss.str());
310 BL_PROFILE_VAR_STOP(evolve);
358 BL_PROFILE(
"REMORA::post_timestep()");
360#ifdef REMORA_USE_PARTICLES
361 particleData.Redistribute();
366 for (
int lev = finest_level-1; lev >= 0; lev--)
390 BL_PROFILE(
"REMORA::InitData()");
392 amrex::Print() <<
"REMORA InitData: driver-managed atm2ocn coupling enabled"
394 <<
" active_contract="
427#ifdef REMORA_USE_MOAB
433 for (
int lev = 1; lev <= finest_level; lev++)
435 advflux_reg[lev].reset(
new YAFluxRegister(grids[lev], grids[lev-1],
436 dmap[lev], dmap[lev-1],
437 geom[lev], geom[lev-1],
438 ref_ratio[lev-1], lev,
ncons));
443 for (
int lev = 0; lev <= finest_level; ++lev)
450 FillPatch(lev,
t_new[lev], *
cons_new[lev],
cons_new,
BCVars::cons_bc,
BdyVars::t, 0,
true,
false,0,0,
zero,*
cons_new[lev]);
451 FillPatch(lev,
t_new[lev], *
xvel_new[lev],
xvel_new,
xvel_bc(),
BdyVars::u, 0,
true,
false,0,0,
zero,*
xvel_new[lev]);
452 FillPatch(lev,
t_new[lev], *
yvel_new[lev],
yvel_new,
yvel_bc(),
BdyVars::v, 0,
true,
false,0,0,
zero,*
yvel_new[lev]);
502 BL_PROFILE(
"REMORA::Construct_REMORAFillPatchers()");
503 amrex::Print() <<
":::Construct_REMORAFillPatchers " << lev << std::endl;
505 auto& ba_fine =
cons_new[lev ]->boxArray();
506 auto& ba_crse =
cons_new[lev-1]->boxArray();
507 auto& dm_fine =
cons_new[lev ]->DistributionMap();
508 auto& dm_crse =
cons_new[lev-1]->DistributionMap();
510 BoxList bl2d_fine = ba_fine.boxList();
511 for (
auto& b : bl2d_fine) {
514 BoxArray ba2d_fine(std::move(bl2d_fine));
516 BoxList bl2d_crse = ba_crse.boxList();
517 for (
auto& b : bl2d_crse) {
520 BoxArray ba2d_crse(std::move(bl2d_crse));
524 FPr_c.emplace_back(ba_fine, dm_fine, geom[lev] ,
525 ba_crse, dm_crse, geom[lev-1],
527 FPr_u.emplace_back(convert(ba_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
528 convert(ba_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
530 FPr_v.emplace_back(convert(ba_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
531 convert(ba_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
533 FPr_w.emplace_back(convert(ba_fine, IntVect(0,0,1)), dm_fine, geom[lev] ,
534 convert(ba_crse, IntVect(0,0,1)), dm_crse, geom[lev-1],
537 FPr_ubar.emplace_back(convert(ba2d_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
538 convert(ba2d_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
540 FPr_vbar.emplace_back(convert(ba2d_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
541 convert(ba2d_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
551 BL_PROFILE(
"REMORA::Define_REMORAFillPatchers()");
552 amrex::Print() <<
":::Define_REMORAFillPatchers " << lev << std::endl;
554 auto& ba_fine =
cons_new[lev ]->boxArray();
555 auto& ba_crse =
cons_new[lev-1]->boxArray();
556 auto& dm_fine =
cons_new[lev ]->DistributionMap();
557 auto& dm_crse =
cons_new[lev-1]->DistributionMap();
559 BoxList bl2d_fine = ba_fine.boxList();
560 for (
auto& b : bl2d_fine) {
563 BoxArray ba2d_fine(std::move(bl2d_fine));
565 BoxList bl2d_crse = ba_crse.boxList();
566 for (
auto& b : bl2d_crse) {
569 BoxArray ba2d_crse(std::move(bl2d_crse));
574 FPr_c[lev-1].Define(ba_fine, dm_fine, geom[lev] ,
575 ba_crse, dm_crse, geom[lev-1],
577 FPr_u[lev-1].Define(convert(ba_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
578 convert(ba_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
580 FPr_v[lev-1].Define(convert(ba_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
581 convert(ba_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
583 FPr_w[lev-1].Define(convert(ba_fine, IntVect(0,0,1)), dm_fine, geom[lev] ,
584 convert(ba_crse, IntVect(0,0,1)), dm_crse, geom[lev-1],
587 FPr_ubar[lev-1].Define(convert(ba2d_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
588 convert(ba2d_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
590 FPr_vbar[lev-1].Define(convert(ba2d_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
591 convert(ba2d_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
598 BL_PROFILE(
"REMORA::restart()");
611 BL_PROFILE(
"REMORA::set_zeta()");
617#ifdef REMORA_USE_NETCDF
618 amrex::Print() <<
"Calling init_zeta_from_netcdf on level " << lev << std::endl;
620 amrex::Print() <<
"Sea surface height loaded from netcdf file \n " << std::endl;
623 amrex::Abort(
"Unknown IC_Type");
628 vec_zeta[lev]->FillBoundary(geom[lev].periodicity());
634 Real dummy_time =
zero;
638 vec_zeta[lev]->FillBoundary(geom[lev].periodicity());
650 BL_PROFILE(
"REMORA::bathymetry()");
662#ifdef REMORA_USE_NETCDF
663 amrex::Print() <<
"Calling init_bathymetry_from_netcdf " << std::endl;
665 amrex::Print() <<
"Bathymetry loaded from netcdf file \n " << std::endl;
666 amrex::Print() <<
"Calling init_grid_vars_from_netcdf " << std::endl;
668 amrex::Print() <<
"Grid variables loaded from netcdf file \n " << std::endl;
671 amrex::Abort(
"Unknown IC_Type");
679 vec_h[lev]->FillBoundary(geom[lev].periodicity());
680 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
686 Real dummy_time =
zero;
690 vec_h[lev]->FillBoundary(geom[lev].periodicity());
691 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
702 Real dummy_time =
zero;
719 Real dummy_time =
zero;
755 FillPatch(lev,
t_new[lev], *
cons_new[lev],
cons_new,
BCVars::cons_bc,
BdyVars::t, 0,
true,
false,0,0,
zero,*
cons_new[lev]);
756 FillPatch(lev,
t_new[lev], *
xvel_new[lev],
xvel_new,
xvel_bc(),
BdyVars::u, 0,
true,
false,0,0,
zero,*
xvel_new[lev]);
757 FillPatch(lev,
t_new[lev], *
yvel_new[lev],
yvel_new,
yvel_bc(),
BdyVars::v, 0,
true,
false,0,0,
zero,*
yvel_new[lev]);
765 BL_PROFILE(
"REMORA::set_coriolis()");
771#ifdef REMORA_USE_NETCDF
774 amrex::Print() <<
"Calling init_coriolis_from_netcdf " << std::endl;
776 amrex::Print() <<
"Coriolis loaded from netcdf file \n" << std::endl;
778 Real dummy_time =
zero;
783 Abort(
"Don't know this coriolis_type!");
788 vec_fcor[lev]->EnforcePeriodicity(geom[lev].periodicity());
794 BL_PROFILE(
"REMORA::init_set_vmix()");
802 Abort(
"Don't know this vertical mixing type");
811 BL_PROFILE(
"REMORA::set_analytic_vmix()");
817 for (
int n = 0; n <
ncons; n++) {
832#ifdef REMORA_USE_NETCDF
834 amrex::Print() <<
"Calling init_masks_from_netcdf level " << lev << std::endl;
836 amrex::Print() <<
"Masks loaded from netcdf file \n " << std::endl;
838 Real dummy_time =
zero;
854 BL_PROFILE(
"REMORA::set_hmixcoef()");
859 Real lev_scale =
one;
862 for (
int l = 0; l < lev; ++l) {
863 rf *= std::sqrt(
static_cast<Real
>(ref_ratio[l][0]) *
static_cast<Real
>(ref_ratio[l][1]));
865 lev_scale =
one / rf;
875 for (
int n = 0; n <
ncons; n++) {
908 for (
int n = 0; n <
ncons; n++) {
916 amrex::Gpu::LaunchSafeGuard lsg(
true);
917 Real denom_min = amrex::ReduceMin(*
vec_pm[lev], *
vec_pn[lev], 0,
918 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
919 Array4<Real const>
const& pm,
920 Array4<Real const>
const& pn) -> Real
923 amrex::Loop(bx, [=,&local_min] (
int i,
int j,
int)
noexcept
925 local_min = amrex::min(local_min, pm(i,j,0) * pn(i,j,0));
930 ParallelDescriptor::ReduceRealMin(denom_min);
931 if (denom_min <=
zero) {
932 Abort(
"scaled_to_grid: found non-positive pm*pn (grid metrics must be > 0)");
935 Real grdmax = amrex::ReduceMax(*
vec_pm[lev], *
vec_pn[lev], 0,
936 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
937 Array4<Real const>
const& pm,
938 Array4<Real const>
const& pn) -> Real
940 Real local_max =
zero;
941 amrex::Loop(bx, [=,&local_max] (
int i,
int j,
int)
noexcept
943 Real denom = pm(i,j,0) * pn(i,j,0);
945 Real G = std::sqrt(
one / denom);
946 local_max = amrex::max(local_max, G);
952 ParallelDescriptor::ReduceRealMax(grdmax);
953 if (grdmax <=
zero) {
954 Abort(
"scaled_to_grid: grdmax <= 0");
963 for (
int l = 0; l < lev; ++l) {
964 rf *= std::sqrt(
static_cast<Real
>(ref_ratio[l][0]) *
static_cast<Real
>(ref_ratio[l][1]));
966 lev_scale =
one / rf;
970 Real cff = visc0 / grdmax;
975 amrex::Gpu::DeviceVector<Real> diff0_d(
ncons);
976 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
979 Real
const* diff0_ptr = diff0_d.data();
981 for (MFIter mfi(*
vec_visc2_r[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
983 const Box& bx = mfi.validbox();
984 auto pm =
vec_pm[lev]->const_array(mfi);
985 auto pn =
vec_pn[lev]->const_array(mfi);
989 int ncons_local =
ncons;
990 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
noexcept
992 Real denom = pm(i,j,0) * pn(i,j,0);
993 Real grdscl = (denom >
zero) ? std::sqrt(
one / denom) :
zero;
994 visc2_r(i,j,0) = cff * grdscl;
996 for (
int n = 0; n < ncons_local; n++) {
997 diff2(i,j,0,n) = ((diff0_ptr[n] * lev_scale) / grdmax) * grdscl;
1009 for (MFIter mfi(*
vec_visc2_p[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
1011 const Box& bx = mfi.validbox();
1013 auto visc2_r =
vec_visc2_r[lev]->const_array(mfi);
1015 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
noexcept
1017 visc2_p(i,j,0) =
fourth * (
1018 visc2_r(i-1,j-1,0) +
1034 Real visc_min_all =
vec_visc2_r[lev]->min(0,0,
false);
1035 Real visc_max_all =
vec_visc2_r[lev]->max(0,0,
false);
1038 amrex::Gpu::LaunchSafeGuard lsg_diag(
true);
1040 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1041 Array4<Real const>
const& visc2,
1042 Array4<Real const>
const& mskr) -> Real
1045 amrex::Loop(bx, [=,&local_min] (
int i,
int j,
int)
noexcept
1047 if (mskr(i,j,0) >
zero) {
1048 local_min = amrex::min(local_min, visc2(i,j,0));
1053 ParallelDescriptor::ReduceRealMin(visc_min_wet);
1056 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1057 Array4<Real const>
const& visc2,
1058 Array4<Real const>
const& mskr) -> Real
1061 amrex::Loop(bx, [=,&local_max] (
int i,
int j,
int)
noexcept
1063 if (mskr(i,j,0) >
zero) {
1064 local_max = amrex::max(local_max, visc2(i,j,0));
1069 ParallelDescriptor::ReduceRealMax(visc_max_wet);
1073 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1074 Array4<Real const>
const& visc2,
1075 Array4<Real const>
const& mskr) -> Real
1078 amrex::Loop(bx, [=,&local_min] (
int i,
int j,
int)
noexcept
1080 const Real v = (mskr(i,j,0) >
zero) ? visc2(i,j,0) :
zero;
1081 local_min = amrex::min(local_min, v);
1085 ParallelDescriptor::ReduceRealMin(visc_min_mask0);
1088 [=] AMREX_GPU_HOST_DEVICE (Box
const& bx,
1089 Array4<Real const>
const& visc2,
1090 Array4<Real const>
const& mskr) -> Real
1093 amrex::Loop(bx, [=,&local_max] (
int i,
int j,
int)
noexcept
1095 const Real v = (mskr(i,j,0) >
zero) ? visc2(i,j,0) :
zero;
1096 local_max = amrex::max(local_max, v);
1100 ParallelDescriptor::ReduceRealMax(visc_max_mask0);
1101 if (ParallelDescriptor::IOProcessor() && lev == 0)
1103 Print() <<
"\nHorizontal mixing scaled by grid metric\n";
1104 Print() <<
"grdmax = " << grdmax <<
"\n";
1106 Print() <<
"AMR scaling (linear) lev_scale = " << lev_scale <<
"\n";
1108 Print() <<
"visc2(all) min/max = "
1109 << visc_min_all <<
" / "
1110 << visc_max_all <<
"\n";
1111 Print() <<
"visc2(wet,k=0) min/max = "
1112 << visc_min_wet <<
" / "
1113 << visc_max_wet <<
"\n";
1114 Print() <<
"visc2(mask->0) min/max = "
1115 << visc_min_mask0 <<
" / "
1116 << visc_max_mask0 <<
"\n";
1120 Abort(
"Don't know this horizontal mixing type");
1127 for (
int n = 0; n <
ncons; n++) {
1139 BL_PROFILE(
"REMORA::init_flat_bathymetry()");
1140 vec_h[lev]->setVal(-geom[0].ProbLo()[2]);
1149 BL_PROFILE(
"REMORA::set_smflux()");
1153#ifdef REMORA_USE_NETCDF
1168 BL_PROFILE(
"REMORA::set_surface_state()");
1174 amrex::Abort(
"Reached set_surface_state() but variables have already been specified from driver!");
1205#ifdef REMORA_USE_NETCDF
1206 auto update_from_netcdf = [&](std::unique_ptr<NCTimeSeries>& data_from_file,
1207 Vector<std::unique_ptr<MultiFab>>& mf_vec) {
1208 data_from_file->update_interpolated_to_time(
t_old[lev], lev, mf_vec[lev].get(), geom, ref_ratio);
1226 vec_qair[lev]->mult(amrex::Real(0.01));
1250 amrex::Abort(
"NetCDF bulk-flux forcing requires building with NetCDF");
1275 if (analytic_uwind !=
nullptr || analytic_vwind !=
nullptr ||
1276 analytic_Tair !=
nullptr || analytic_qair !=
nullptr || analytic_Pair !=
nullptr ||
1277 analytic_srflx !=
nullptr || analytic_lwrad !=
nullptr || analytic_rain !=
nullptr ||
1278 analytic_cloud !=
nullptr || analytic_EminusP !=
nullptr) {
1280 *analytic_uwind, *analytic_vwind,
1281 *analytic_Tair, *analytic_qair, *analytic_Pair,
1282 *analytic_srflx, *analytic_lwrad, *analytic_rain,
1283 *analytic_cloud, *analytic_EminusP);
1286 if (
vec_uwind[lev] !=
nullptr) {
vec_uwind[lev]->FillBoundary(geom[lev].periodicity()); }
1287 if (
vec_vwind[lev] !=
nullptr) {
vec_vwind[lev]->FillBoundary(geom[lev].periodicity()); }
1288 if (
vec_Tair[lev] !=
nullptr) {
vec_Tair[lev]->FillBoundary(geom[lev].periodicity()); }
1289 if (
vec_qair[lev] !=
nullptr) {
vec_qair[lev]->FillBoundary(geom[lev].periodicity()); }
1290 if (
vec_Pair[lev] !=
nullptr) {
vec_Pair[lev]->FillBoundary(geom[lev].periodicity()); }
1291 if (
vec_srflx[lev] !=
nullptr) {
vec_srflx[lev]->FillBoundary(geom[lev].periodicity()); }
1293 if (
vec_rain[lev] !=
nullptr) {
vec_rain[lev]->FillBoundary(geom[lev].periodicity()); }
1294 if (
vec_cloud[lev] !=
nullptr) {
vec_cloud[lev]->FillBoundary(geom[lev].periodicity()); }
1305 BL_PROFILE(
"REMORA::init_only()");
1329#ifdef REMORA_USE_NETCDF
1335 amrex::Error(
"NetCDF climatology file name must be provided via input");
1365 amrex::Print() <<
"Calling init_bdry_from_netcdf at level " << lev << std::endl;
1367 amrex::Print() <<
"Boundary data loaded from netcdf file \n " << std::endl;
1374 amrex::Error(
"NetCDF forcing file name must be provided via input for surface momentum fluxes");
1388 bool any_bulk_netcdf =
false;
1393 amrex::Error(
"NetCDF forcing file name must be provided via input for bulk-flux atmospheric forcing");
1475 amrex::Error(
"NetCDF river file name must be provided via input for rivers");
1477 auto dom = geom[0].Domain();
1478 int nz = dom.length(2);
1500 amrex::Print() <<
"Reading high resolution bathymetry and grid data" << std::endl;
1504 amrex::Print() <<
"Done reading in high resolution bathymetry and grid data" << std::endl;
1507 amrex::Print() <<
"Reading high resolution initial data" << std::endl;
1511 amrex::Print() <<
"Done reading in high resolution initial data" << std::endl;
1515 Abort(
"Not compiled with NetCDF, but selected boundary conditions require NetCDF");
1518 Abort(
"Not compiled with NetCDF, but using river sources requires NetCDF");
1545#ifdef REMORA_USE_NETCDF
1546 amrex::Print() <<
"Calling init_data_from_netcdf " << std::endl;
1549 amrex::Print() <<
"Initial data loaded from netcdf file \n " << std::endl;
1552 amrex::Abort(
"Unknown IC_Type");
1580 xvel_new[lev]->OverrideSync(geom[lev].periodicity());
1581 yvel_new[lev]->OverrideSync(geom[lev].periodicity());
1582 zvel_new[lev]->OverrideSync(geom[lev].periodicity());
1601 BL_PROFILE(
"REMORA::ReadParameters()");
1604 bool noprefix_max_step = pp.queryAdd(
"max_step",
max_step);
1605 bool noprefix_stop_time = pp.queryAdd(
"stop_time",
stop_time);
1606 bool remora_max_step = pp.queryAdd(
"remora.max_step",
max_step);
1607 bool remora_stop_time = pp.queryAdd(
"remora.stop_time",
stop_time);
1608 if (remora_max_step and noprefix_max_step) {
1609 Abort(
"remora.max_step and max_step are both specified. Please use only one!");
1611 if (remora_stop_time and noprefix_stop_time) {
1612 Abort(
"remora.stop_time and stop_time are both specified. Please use only one!");
1619 pp.queryAdd(
"nscalar",
nscalar);
1621 amrex::Abort(
"remora.nscalar must be at least 1");
1641 if (pp.contains(
"data_log")) {
1642 int num_datalogs = pp.countval(
"data_log");
1645 pp.queryarr(
"data_log",
datalogname, 0, num_datalogs);
1646 for (
int i = 0; i < num_datalogs; i++)
1652 pp.queryAdd(
"sum_period",
sum_per);
1656 amrex::Abort(
"remora.file_min_digits must be non-negative");
1659 pp.queryAdd(
"cfl",
cfl);
1667 amrex::Abort(
"Dt is over-specfied");
1687 std::string plotfile_type_str =
"amrex";
1688 pp.queryAdd(
"plotfile_type", plotfile_type_str);
1689 if (plotfile_type_str ==
"amrex") {
1691 }
else if (plotfile_type_str ==
"netcdf" || plotfile_type_str ==
"NetCDF") {
1693#ifdef REMORA_USE_NETCDF
1698 auto dom = geom[0].Domain();
1699 int nx = dom.length(0) + 2;
1700 int ny = dom.length(1) + 2;
1701 int nz = dom.length(2);
1702 Real two_gb = Real(1.6e10);
1703 Real double_bits = Real(64.0);
1707 / (nx * ny * double_bits * (
NC3D*nz +
NC2D)));
1712 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.");
1718 Real est_hist_file_size =
NCH2D * nx * ny * double_bits + nt_out * nx * ny * double_bits * (
NC3D*nz +
NC2D);
1719 if (est_hist_file_size > two_gb) {
1720 amrex::Warning(
"WARNING: NetCDF history file may be larger than 2GB limit. Consider setting remora.chunk_history_file=true");
1724 Print() <<
"NetCDF history files will have " <<
steps_per_history_file <<
" steps per file." << std::endl;
1728 amrex::Print() <<
"User selected plotfile_type = " << plotfile_type_str << std::endl;
1729 amrex::Abort(
"Dont know this plotfile_type");
1731#ifndef REMORA_USE_NETCDF
1734 amrex::Abort(
"Please compile with NetCDF in order to enable NetCDF plotfiles");
1738#ifdef REMORA_USE_NETCDF
1748 for (
int lev = 0; lev <= max_level; lev++)
1750 const std::string nc_file_names = amrex::Concatenate(
"nc_init_file_",lev,1);
1751 const std::string nc_bathy_file_names = amrex::Concatenate(
"nc_grid_file_",lev,1);
1753 if (pp.contains(nc_file_names.c_str()))
1755 int num_files = pp.countval(nc_file_names.c_str());
1756 int num_bathy_files = pp.countval(nc_bathy_file_names.c_str());
1757 if (num_files != num_bathy_files) {
1758 amrex::Error(
"Must have same number of netcdf files for grid info as for solution");
1765 pp.queryarr(nc_file_names.c_str() ,
nc_init_file[lev] ,0,num_files);
1766 pp.queryarr(nc_bathy_file_names.c_str(),
nc_grid_file[lev],0,num_files);
1777 if (pp.contains(
"nc_frc_file")) {
1778 int num_files = pp.countval(
"nc_frc_file");
1780 pp.queryarr(
"nc_frc_file",
nc_frc_file, 0, num_files);
1784 if (pp.contains(
"nc_river_file")) {
1785 int num_files = pp.countval(
"nc_river_file");
1787 pp.queryarr(
"nc_river_file",
nc_riv_file, 0, num_files);
1791 if (pp.contains(
"nc_clim_his_file")) {
1792 int num_files = pp.countval(
"nc_clim_his_file");
1831 amrex::Abort(
"hires_grid_level must be less than or equal to amr.max_level");
1835 amrex::Abort(
"hires_init_level must be less than or equal to amr.max_level");
1837#ifdef REMORA_USE_PARTICLES
1838 readTracersParams();
1842 ParmParse pp_amr(
"amr");
1846 amrex::Abort(
"Time substepping is not yet implemented. amr.do_substep must be 0");
1859 amrex::Abort(
"Cannot do high-resolution initialization for analytic initial conditions. Not yet implemented");
1868 BL_PROFILE(
"REMORA::AverageDown()");
1869 for (
int lev = finest_level-1; lev >= 0; --lev)
1881 BL_PROFILE(
"REMORA::AverageDownTo()");
1883 0,
cons_new[crse_lev]->nComp(), refRatio(crse_lev));
1885 0,
vec_Zt_avg1[crse_lev]->nComp(), refRatio(crse_lev));
1887 Array<MultiFab*,AMREX_SPACEDIM> faces_crse;
1888 Array<MultiFab*,AMREX_SPACEDIM> faces_fine;
1889 faces_crse[0] =
xvel_new[crse_lev];
1890 faces_crse[1] =
yvel_new[crse_lev];
1891 faces_crse[2] =
zvel_new[crse_lev];
1893 faces_fine[0] =
xvel_new[crse_lev+1];
1894 faces_fine[1] =
yvel_new[crse_lev+1];
1895 faces_fine[2] =
zvel_new[crse_lev+1];
1897 average_down_faces(GetArrOfConstPtrs(faces_fine), faces_crse,
1898 refRatio(crse_lev),geom[crse_lev]);
1909 auto const& crsema = vec_mf[crse_lev]->arrays();
1910 auto const& finema = vec_mf[crse_lev+1]->const_arrays();
1911 auto ref_ratio_crse = refRatio(crse_lev);
1912 auto index_type = (vec_mf[crse_lev]->boxArray().ixType()).toIntVect();
1914 if (index_type[0]==0 and index_type[1]==0) {
1915 ParallelFor(*vec_mf[crse_lev], nghost_crse, vec_mf[crse_lev]->nComp(),
1916 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k,
int n)
noexcept
1918 amrex_avgdown(i,j,k,n,crsema[box_no],finema[box_no],0,0,ref_ratio_crse);
1920 }
else if (index_type[0]==1 and index_type[1]==0) {
1921 ParallelFor(*vec_mf[crse_lev], nghost_crse, 1,
1922 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k,
int n)
noexcept
1924 amrex_avgdown_faces(i,j,k,n,crsema[box_no],finema[box_no],0,0,ref_ratio_crse,0);
1926 }
else if (index_type[0]==0 and index_type[1]==1) {
1927 ParallelFor(*vec_mf[crse_lev], nghost_crse, 1,
1928 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k,
int n)
noexcept
1930 amrex_avgdown_faces(i,j,k,n,crsema[box_no],finema[box_no],0,0,ref_ratio_crse,1);
1933 amrex::Abort(
"Unexpected nodality in average_down_with_grow_cells");
1935 Gpu::streamSynchronize();
constexpr amrex::Real bogus_large_value
constexpr amrex::Real one
constexpr amrex::Real fourth
constexpr amrex::Real zero
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.
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.
static bool plot_staggered_vels
Whether to write the staggered velocities (not averaged to cell centers)
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.
bool running_with_coupling_driver
True once REMORA has received forcing through the coupling driver.
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 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 set_surface_state(int lev)
Initialize or calculate wind speed and other surface state vars from file or analytic.
void WriteAtIntermediateTime(int step, amrex::Real cur_time)
Write checkpoint and plotfiles at intermediate point of simulation, if needed.
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 bool plot_nodal_data
Whether to write nodal data (Nu_nd) to plotfiles.
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.
DriverAtmosForcingMode driver_atmos_forcing_mode
Active atmosphere-to-ocean forcing contract on the most recent driver apply.
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.
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=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level
int plot_int
Plotfile output interval in iterations.
std::unique_ptr< NCTimeSeries > cloud_data_from_file
Data container for cloud cover fraction read from file.
void WriteAtFinalTime()
Write checkpoint and plotfiles at end of simulation.
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.
bool driver_uses_two_way_coupling
Driver-level direction flag copied in before InitData.
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 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 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=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level using the piecewise constant interpol...
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.
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
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.
std::unique_ptr< NCTimeSeries > Vwind_data_from_file
Data container for v-direction wind read from file.
static constexpr bool DriverUsesStateForcing(DriverAtmosForcingMode mode) noexcept
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.
@ Pair
atmospheric pressure [Pa from driver, mb in REMORA]
@ Vwind
10-m meridional wind [m/s]
@ Qair
specific humidity [kg/kg]
@ SWrad
downward shortwave radiation [W/m^2]
@ LWrad
downward longwave radiation [W/m^2]
@ Uwind
10-m zonal wind [m/s]
@ Rain
precipitation rate [kg/m^2/s]
@ Cloud
cloud fraction [0-1]
@ Tair
air temperature [K from driver, degC in REMORA]
static constexpr int cons_bc
static constexpr int Temp_bc_comp
@ Vwind
10-m meridional wind [m/s]
@ Pair
atmospheric pressure [mb]
@ Uwind
10-m zonal wind [m/s]
@ LWrad
longwave radiation [W/m^2]
@ Tair
air temperature [degC]
@ Qair
specific humidity or relative humidity [kg/kg or fraction]
@ Cloud
cloud fraction [0-1]
@ SWrad
downward shortwave radiation [W/m^2]
@ Rain
precipitation rate [kg/m^2/s]
@ EminusP
evaporation minus precipitation [m/s]
const char * buildInfoGetGitHash(int i)
HorizMixingType horiz_mixing_type
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
std::array< BulkForcingType, BulkFlux::NumTypes > bulk_flux_type
CouplingType coupling_type