1 #ifndef ERF_INPUT_SOUNDING_DATA_H_
2 #define ERF_INPUT_SOUNDING_DATA_H_
7 #include <AMReX_ParmParse.H>
8 #include <AMReX_Print.H>
10 #include <AMReX_Geometry.H>
26 amrex::ParmParse
pp(
"erf");
78 const amrex::Vector<amrex::Real>& zlevels_stag,
82 const int khi = geom.Domain().bigEnd()[AMREX_SPACEDIM-1];
83 const int Nz = geom.Domain().size()[AMREX_SPACEDIM-1];
84 const amrex::Real dz = geom.CellSize()[AMREX_SPACEDIM-1];
86 const bool use_terrain = (zlevels_stag.size() > 0);
87 const amrex::Real zbot = (use_terrain) ? zlevels_stag[klo] : geom.ProbLo(AMREX_SPACEDIM-1);
88 const amrex::Real ztop = (use_terrain) ? zlevels_stag[khi+1] : geom.ProbHi(AMREX_SPACEDIM-1);
97 amrex::Print() <<
"input_sounding file location : " <<
input_sounding_file[itime] << std::endl;
99 if(!input_sounding_reader.is_open()) {
100 amrex::Error(
"Error opening the input_sounding file\n");
104 amrex::Print() <<
"Successfully opened the input_sounding file. Now reading... " << std::endl;
109 amrex::Vector<amrex::Real> z_inp_sound_tmp, theta_inp_sound_tmp, qv_inp_sound_tmp,
110 U_inp_sound_tmp, V_inp_sound_tmp;
113 std::getline(input_sounding_reader, line);
114 std::istringstream iss(line);
120 z_inp_sound_tmp.push_back(zbot);
123 U_inp_sound_tmp.push_back(0);
124 V_inp_sound_tmp.push_back(0);
128 while(std::getline(input_sounding_reader, line)) {
129 std::istringstream iss_z(line);
132 AMREX_ALWAYS_ASSERT(
theta == theta_inp_sound_tmp[0]);
133 AMREX_ALWAYS_ASSERT(
qv*0.001 == qv_inp_sound_tmp[0]);
134 U_inp_sound_tmp[0] =
U;
135 V_inp_sound_tmp[0] =
V;
137 AMREX_ALWAYS_ASSERT(
z > z_inp_sound_tmp[z_inp_sound_tmp.size()-1]);
138 z_inp_sound_tmp.push_back(
z);
139 theta_inp_sound_tmp.push_back(
theta);
140 qv_inp_sound_tmp.push_back(
qv*0.001);
141 U_inp_sound_tmp.push_back(
U);
142 V_inp_sound_tmp.push_back(
V);
143 if (
z >= ztop)
break;
149 const int Ninp = z_inp_sound_tmp.size();
155 for (
int k=0; k < Nz; ++k) {
156 z_inp_sound[itime][k+1] = (use_terrain) ? 0.5 * (zlevels_stag[k] + zlevels_stag[k+1])
157 : zbot + (k + 0.5) * dz;
170 amrex::Print() <<
"Successfully read the " << itime <<
"th input_sounding file..." << std::endl;
171 input_sounding_reader.close();
183 const amrex::Real tol = 1.0e-12;
184 const int Ninp =
size(itime);
195 amrex::Print() <<
"ideal sounding init: surface density of moist air = "
206 amrex::Print() <<
"z p_m rho_d theta qv U V" << std::endl;
218 amrex::Real dz,
F, C;
219 amrex::Real rho_tot_hi, rho_tot_lo;
220 for (
int k=1; k <
size(itime); ++k)
263 const int Ninp =
size(itime);
270 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
273 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
276 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
279 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
282 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
291 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
294 amrex::Gpu::copy(amrex::Gpu::hostToDevice,
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:12
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:21
constexpr amrex::Real R_d
Definition: ERF_Constants.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress(const amrex::Real theta, const amrex::Real p, const amrex::Real rdOcp, const amrex::Real qv=0.0)
Definition: ERF_EOS.H:89
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real interpolate_1d(const amrex::Real *alpha, const amrex::Real *beta, const amrex::Real alpha_interp, const int alpha_size)
Definition: ERF_Interpolation_1D.H:12
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_Microphysics_Utils.H:203
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Newton_Raphson_hse(const Real &m_tol, const Real &RdOCp, const Real &dz, const Real &g, const Real &C, const Real &T, const Real &qt, const Real &qv, Real &P, Real &rd, Real &F)
Definition: ERF_HSE_utils.H:35
@ theta
Definition: ERF_MM5.H:20
@ qv
Definition: ERF_Kessler.H:36
@ U
Definition: ERF_IndexDefines.H:97
@ V
Definition: ERF_IndexDefines.H:98