diff --git a/Source/BoundaryConditions/ERF_FillPatch.cpp b/Source/BoundaryConditions/ERF_FillPatch.cpp index 3ae8182cf..dc32173d9 100644 --- a/Source/BoundaryConditions/ERF_FillPatch.cpp +++ b/Source/BoundaryConditions/ERF_FillPatch.cpp @@ -92,8 +92,8 @@ ERF::FillPatch (int lev, Real time, const Vector& mfs, bool fillset) #ifdef ERF_USE_NETCDF // We call this here because it is an ERF routine - if (init_type == "real" && lev==0) fill_from_wrfbdy(mfs,time); - if (init_type == "metgrid" && lev==0) fill_from_metgrid(mfs,time); + if (init_type == "real" && lev==0) fill_from_wrfbdy (mfs,time,false,0,ncomp_cons); + if (init_type == "metgrid" && lev==0) fill_from_metgrid(mfs,time,false,0,ncomp_cons); #endif if (m_r2d) fill_from_bndryregs(mfs,time); diff --git a/Source/ERF.H b/Source/ERF.H index 8e3735709..122cb0116 100644 --- a/Source/ERF.H +++ b/Source/ERF.H @@ -302,12 +302,12 @@ public: #ifdef ERF_USE_NETCDF void fill_from_wrfbdy (const amrex::Vector& mfs, amrex::Real time, - bool cons_only = false, + bool cons_only, int icomp_cons, int ncomp_cons); void fill_from_metgrid (const amrex::Vector& mfs, amrex::Real time, - bool cons_only = false, + bool cons_only, int icomp_cons, int ncomp_cons); #endif diff --git a/Source/IO/NCCheckpoint.cpp b/Source/IO/NCCheckpoint.cpp index 7ba17e7e2..24df09c6c 100644 --- a/Source/IO/NCCheckpoint.cpp +++ b/Source/IO/NCCheckpoint.cpp @@ -100,8 +100,9 @@ ERF::WriteNCCheckpointFile () const // Here we make copies of the MultiFab with no ghost cells for (int lev = 0; lev <= finest_level; ++lev) { - MultiFab cons(grids[lev],dmap[lev],Cons::NumVars,0); - MultiFab::Copy(cons,vars_new[lev][Vars::cons],0,0,Cons::NumVars,0); + int nc_cons = vars_new[lev][Vars::cons].nComp(); + MultiFab cons(grids[lev],dmap[lev],nc_cons,0); + MultiFab::Copy(cons,vars_new[lev][Vars::cons],0,0,nc_cons,0); WriteNCMultiFab(cons, amrex::MultiFabFileFullPrefix(lev, checkpointname, "Level_", "Cell")); MultiFab xvel(convert(grids[lev],IntVect(1,0,0)),dmap[lev],1,0); @@ -138,8 +139,10 @@ ERF::ReadNCCheckpointFile () const std::string nstep_name = "num_istep"; const std::string ntime_name = "num_newtime"; - const int nvar = static_cast(ncf.dim(nvar_name).len()); - AMREX_ALWAYS_ASSERT(nvar == Cons::NumVars); + const int nvar = static_cast(ncf.dim(nvar_name).len()); + const int nc_cons = vars_new[0][Vars::cons].nComp(); + + AMREX_ALWAYS_ASSERT(nvar == nc_cons); const int ndt = static_cast(ncf.dim(ndt_name).len()); const int nstep = static_cast(ncf.dim(nstep_name).len()); @@ -190,14 +193,11 @@ ERF::ReadNCCheckpointFile () SetBoxArray(lev, ba); SetDistributionMap(lev, dm); - // build MultiFab data - int ncomp = Cons::NumVars; - auto& lev_old = vars_old[lev]; auto& lev_new = vars_new[lev]; - lev_new[Vars::cons].define(grids[lev], dmap[lev], ncomp, ngrow_state); - lev_old[Vars::cons].define(grids[lev], dmap[lev], ncomp, ngrow_state); + lev_new[Vars::cons].define(grids[lev], dmap[lev], nc_cons, ngrow_state); + lev_old[Vars::cons].define(grids[lev], dmap[lev], nc_cons, ngrow_state); //!don: get the ghost cells right here lev_new[Vars::xvel].define(convert(grids[lev], IntVect(1,0,0)), dmap[lev], 1, ngrow_vels); @@ -214,9 +214,9 @@ ERF::ReadNCCheckpointFile () for (int lev = 0; lev <= finest_level; ++lev) { - MultiFab cons(grids[lev],dmap[lev],Cons::NumVars,0); + MultiFab cons(grids[lev],dmap[lev],nc_cons,0); WriteNCMultiFab(cons, amrex::MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "Cell")); - MultiFab::Copy(vars_new[lev][Vars::cons],cons,0,0,Cons::NumVars,0); + MultiFab::Copy(vars_new[lev][Vars::cons],cons,0,0,nc_cons,0); MultiFab xvel(convert(grids[lev],IntVect(1,0,0)),dmap[lev],1,0); WriteNCMultiFab(xvel, amrex::MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "Cell")); @@ -231,7 +231,7 @@ ERF::ReadNCCheckpointFile () MultiFab::Copy(vars_new[lev][Vars::zvel],zvel,0,0,1,0); // Copy from new into old just in case - MultiFab::Copy(vars_old[lev][Vars::cons],vars_new[lev][Vars::cons],0,0,Cons::NumVars,0); + MultiFab::Copy(vars_old[lev][Vars::cons],vars_new[lev][Vars::cons],0,0,nc_cons,0); MultiFab::Copy(vars_old[lev][Vars::xvel],vars_new[lev][Vars::xvel],0,0,1,0); MultiFab::Copy(vars_old[lev][Vars::yvel],vars_new[lev][Vars::yvel],0,0,1,0); MultiFab::Copy(vars_old[lev][Vars::zvel],vars_new[lev][Vars::zvel],0,0,1,0); diff --git a/Source/TimeIntegration/ERF_slow_rhs_post.cpp b/Source/TimeIntegration/ERF_slow_rhs_post.cpp index 7160cbaae..bba64d6f9 100644 --- a/Source/TimeIntegration/ERF_slow_rhs_post.cpp +++ b/Source/TimeIntegration/ERF_slow_rhs_post.cpp @@ -172,6 +172,9 @@ void erf_slow_rhs_post (int level, int finest_level, int ncomp = S_data[IntVar::cons].nComp(); + int start_comp; + int num_comp; + for ( MFIter mfi(S_data[IntVar::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi) { const Box& tbx = mfi.tilebox(); @@ -272,8 +275,6 @@ void erf_slow_rhs_post (int level, int finest_level, vert_adv_type = EfficientAdvType(nrk,ac.dryscal_vert_adv_type); } - int start_comp; - int num_comp; if (l_use_deardorff) { start_comp = RhoKE_comp; num_comp = 1; @@ -393,14 +394,14 @@ void erf_slow_rhs_post (int level, int finest_level, } #if defined(ERF_USE_NETCDF) if (solverChoice.moisture_type != MoistureType::None) + { // Zero moist RHS in set region if (moist_zero) { Box bx_xlo, bx_xhi, bx_ylo, bx_yhi; compute_interior_ghost_bxs_xy(tbx, domain, width, 0, bx_xlo, bx_xhi, bx_ylo, bx_yhi); - int icomp; - icomp = RhoQ1_comp; + int icomp = RhoQ1_comp; wrfbdy_zero_rhs_in_set_region(icomp, 1, bx_xlo, bx_xhi, bx_ylo, bx_yhi, cell_rhs); } // moist_zero } // moisture_type