Skip to content

Commit

Permalink
Metgrid interpolator (#1630)
Browse files Browse the repository at this point in the history
* Porting init_type="metgrid" updates into a clean branch of development. This includes,\n * an updated vertical interpolator used when interpolating met_em files onto the ERF vertical grid.\n * option to either interpolate potential temperature or interpolate pressure and temperature then calculate potential temperature.\n * debugging runtime options to overwrite incoming met_em data with idealized hard-coded values.

* Updated documentation for init_type="metgrid" options. Made interp_theta an input parameter.

* Changed temporary FABs used in init_type="metgrid" from a vector of FABs for each met_em timestamp to a single FAB since we only ever need access to these FABs for whatever met_em time is currently being worked on. Minor clean up of the metgrid initialization code.

* Fixed a bug introduced when cleaning up code for init_type="metgrid"

* Undoing the recent switch from dynamically sized vectors to Array1D in the vertical interpolation scheme used for met_em data

* Make this GPU compatible.

* Fix remaining issues with bounds and unused vars.

* Remove size var since we went to fixed length GpuArrays.

* Reduce memory overhead and fix GPU warning.

* Added assertions during initialization for init_type of "metgrid" and "real" that there are sufficient points in a relaxation zone for computing the laplacian.

---------

Co-authored-by: Aaron M. Lattanzi <[email protected]>
Co-authored-by: AMLattanzi <[email protected]>
Co-authored-by: Aaron Lattanzi <[email protected]>
  • Loading branch information
4 people authored Dec 6, 2024
1 parent a490777 commit 41f6533
Show file tree
Hide file tree
Showing 8 changed files with 1,418 additions and 526 deletions.
110 changes: 110 additions & 0 deletions Docs/sphinx_doc/Inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,107 @@ List of Parameters
| **erf.project_initial_velocity** | project initial | true or false | true if anelastic; |
| | velocity? | | false if compressible |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.real_width** | Lateral boundary | Integer | 0 |
| | total width if | | |
| | use_real_bcs is | | |
| | true | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.real_set_width** | Lateral boundary | Integer | 0 |
| | specified zone | | |
| | width if | | |
| | use_real_bcs is | | |
| | true | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_debug_quiescent** | If init_type is | true or false | false |
| | metgrid, overwrite| | |
| | initial conditions| | |
| | and boundary | | |
| | conditions to be | | |
| | quiescent. | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_debug_isothermal** | If init_type is | true or false | false |
| | metgrid, overwrite| | |
| | theta to be 300 in| | |
| | initial conditions| | |
| | and boundary | | |
| | conditions. | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_debug_dry** | If init_type is | true or false | false |
| | metgrid, overwrite| | |
| | qv to be dry in | | |
| | initial conditions| | |
| | and boundary | | |
| | conditions. | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_debug_msf** | If init_type is | true or false | false |
| | metgrid, overwrite| | |
| | map scale factors | | |
| | to be 1. | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_debug_psfc** | If init_type is | true or false | false |
| | metgrid, overwrite| | |
| | surface pressure | | |
| | to be 10**5. | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_interp_theta** | If init_type is | true or false | false |
| | metgrid, calculate| | |
| | theta on origin | | |
| | model vertical | | |
| | levels and then | | |
| | interpolate onto | | |
| | the ERF vertical | | |
| | levels. | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_basic_linear** | If init_type is | true or false | false |
| | metgrid, use | | |
| | linear vertical | | |
| | interpolation and | | |
| | no quality | | |
| | control? | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_use_below_sfc** | If init_type is | true or false | true |
| | metgrid, use the | | |
| | origin data levels| | |
| | below the surface?| | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_use_sfc** | If init_type is | true or false | true |
| | metgrid, use the | | |
| | origin data level | | |
| | at the surface? | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_retain_sfc** | If init_type is | true or false | false |
| | metgrid, assign | | |
| | the lowest level | | |
| | directly using the| | |
| | surface value from| | |
| | the origin data? | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_proximity** | If init_type is | Real | 1000. |
| | metgrid, pressure | | |
| | differential for | | |
| | detecting origin | | |
| | levels that are | | |
| | problematically | | |
| | close together | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_order** | If init_type is | Integer | 2 |
| | metgrid, order of | | |
| | the Lagrange | | |
| | polynomial | | |
| | interpolation | | |
| | scheme for | | |
| | vertical | | |
| | interpolation | | |
+----------------------------------+-------------------+--------------------+-----------------------+
| **erf.metgrid_force_sfc_k** | If init_type is | Integer | 0 |
| | metgrid, force the| | |
| | origin data | | |
| | surface level to | | |
| | be included in the| | |
| | interpolation for | | |
| | this many ERF | | |
| | vertical levels | | |
+----------------------------------+-------------------+--------------------+-----------------------+

Notes
-----------------
Expand All @@ -1233,6 +1334,15 @@ The extent of the relaxation zone may be controlled with ``erf.real_width`` (cor
and ``erf.real_set_width`` (corresponding to WRF's **spec_zone**, typically set to 1), which corresponds to a relaxation zone with a
width of **real_width - real_set_width**.

If **erf.init_type = metgrid**, the problem is initialized with data
contained in the first NetCDF file provided via ``erf.nc_init_file_0``.
Lateral boundary conditions are derived from the sequence of NetCDF
files provided via ``erf.nc_init_file_0``. The sequence of
``erf.nc_init_file_0`` should be output from the WRF Preprocessing
System (WPS) listed chronologically starting with the earliest
timestamp. A minimum of two files are required to derive lateral
boundary conditions.

If **erf.init_type = input_sounding**, a WRF-style input sounding is read from
``erf.input_sounding_file``. This text file includes any set of levels that
goes at least up to the model top height. The first line includes the surface
Expand Down
15 changes: 15 additions & 0 deletions Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,21 @@ private:
// used with init_type == InitType::Input_Sounding
static bool init_sounding_ideal;

// Options for vertical interpolation of met_em*.nc data.
bool metgrid_debug_quiescent{false};
bool metgrid_debug_isothermal{false};
bool metgrid_debug_dry{false};
bool metgrid_debug_psfc{false};
bool metgrid_debug_msf{false};
bool metgrid_interp_theta{false};
bool metgrid_basic_linear{false};
bool metgrid_use_below_sfc{true};
bool metgrid_use_sfc{true};
bool metgrid_retain_sfc{false};
amrex::Real metgrid_proximity{1000.0};
int metgrid_order{2};
int metgrid_force_sfc_k{0};

// 1D CDF output (for ingestion in AMR-Wind)
static int output_1d_column;
static int column_interval;
Expand Down
15 changes: 15 additions & 0 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,21 @@ ERF::ReadParameters ()
// Flag to trigger initialization from input_sounding like WRF's ideal.exe
pp.query("init_sounding_ideal", init_sounding_ideal);

// Options for vertical interpolation of met_em*.nc data.
pp.query("metgrid_debug_quiescent", metgrid_debug_quiescent);
pp.query("metgrid_debug_isothermal", metgrid_debug_isothermal);
pp.query("metgrid_debug_dry", metgrid_debug_dry);
pp.query("metgrid_debug_psfc", metgrid_debug_psfc);
pp.query("metgrid_debug_msf", metgrid_debug_msf);
pp.query("metgrid_interp_theta", metgrid_interp_theta);
pp.query("metgrid_basic_linear", metgrid_basic_linear);
pp.query("metgrid_use_below_sfc", metgrid_use_below_sfc);
pp.query("metgrid_use_sfc", metgrid_use_sfc);
pp.query("metgrid_retain_sfc", metgrid_retain_sfc);
pp.query("metgrid_proximity", metgrid_proximity);
pp.query("metgrid_order", metgrid_order);
pp.query("metgrid_force_sfc_k", metgrid_force_sfc_k);

// Set default to FullState for now ... later we will try Perturbation
interpolation_type = StateInterpType::FullState;
pp.query_enum_case_insensitive("interpolation_type" ,interpolation_type);
Expand Down
Loading

0 comments on commit 41f6533

Please sign in to comment.