Skip to content

Commit

Permalink
Update of PBL code.
Browse files Browse the repository at this point in the history
  • Loading branch information
lars2015 committed Jan 8, 2025
1 parent 44e9a8c commit 2167444
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ else ifeq ($(COMPILER),icx)
else ifeq ($(COMPILER),nvc)
FC=nvfortran
FCFLAGS=-Wall -fopenmp -g -traceback -mcmodel=medium -Mlarge_arrays $(OPTI) -Mdclchk -Mstandard -Mbounds -Mchkptr -Mchkstk -Minfo
else
$(error Compiler $(COMPILER) not supported)
else ifeq ($(COMPILER),clang)
$(warning Compiler $(COMPILER) does not support Fortran wrapper)
endif

# Compile for GPUs...
Expand Down
23 changes: 14 additions & 9 deletions src/mptrac.c
Original file line number Diff line number Diff line change
Expand Up @@ -5373,17 +5373,17 @@ void read_ctl(
if (ctl->met_cape < 0 || ctl->met_cape > 1)
ERRMSG("Set MET_CAPE to 0 or 1!");
ctl->met_pbl =
(int) scan_ctl(filename, argc, argv, "MET_PBL", -1, "2", NULL);
if (ctl->met_pbl < 0 || ctl->met_pbl > 2)
ERRMSG("Set MET_PBL = 0 ... 2!");
(int) scan_ctl(filename, argc, argv, "MET_PBL", -1, "3", NULL);
if (ctl->met_pbl < 0 || ctl->met_pbl > 3)
ERRMSG("Set MET_PBL to 0 ... 3!");
ctl->met_pbl_min =
scan_ctl(filename, argc, argv, "MET_PBL_MIN", -1, "0.1", NULL);
ctl->met_pbl_max =
scan_ctl(filename, argc, argv, "MET_PBL_MAX", -1, "5.0", NULL);
ctl->met_tropo =
(int) scan_ctl(filename, argc, argv, "MET_TROPO", -1, "3", NULL);
if (ctl->met_tropo < 0 || ctl->met_tropo > 5)
ERRMSG("Set MET_TROPO = 0 ... 5!");
ERRMSG("Set MET_TROPO to 0 ... 5!");
ctl->met_tropo_pv =
scan_ctl(filename, argc, argv, "MET_TROPO_PV", -1, "3.5", NULL);
ctl->met_tropo_theta =
Expand Down Expand Up @@ -7422,8 +7422,8 @@ void read_met_pbl(
SELECT_TIMER("READ_MET_PBL", "METPROC", NVTX_READ);
LOG(2, "Calculate planetary boundary layer...");

/* Get PBL from meteo file... */
if (ctl->met_pbl == 0) {
/* Convert PBL height from meteo file to pressure... */
if (ctl->met_pbl == 1) {

/* Loop over grid points... */
#pragma omp parallel for default(shared) collapse(2)
Expand All @@ -7440,7 +7440,7 @@ void read_met_pbl(
}

/* Determine PBL based on Richardson number... */
else if (ctl->met_pbl == 1) {
else if (ctl->met_pbl == 2) {

/* Parameters used to estimate the height of the PBL
(e.g., Vogelezang and Holtslag, 1996; Seidel et al., 2012)... */
Expand Down Expand Up @@ -7498,7 +7498,7 @@ void read_met_pbl(
}

/* Determine PBL based on potential temperature... */
if (ctl->met_pbl == 2) {
if (ctl->met_pbl == 3) {

/* Parameters used to estimate the height of the PBL
(following HYSPLIT model)... */
Expand Down Expand Up @@ -8086,10 +8086,15 @@ void read_met_surface(

/* Read PBL... */
if (ctl->met_pbl == 0)
if (!read_met_nc_2d
(ncid, "blp", "BLP", NULL, NULL, NULL, NULL, ctl, met, met->pbl,
0.01f, 1))
WARN("Cannot read planetary boundary layer pressure!");
if (ctl->met_pbl == 1)
if (!read_met_nc_2d
(ncid, "blh", "BLH", NULL, NULL, NULL, NULL, ctl, met, met->pbl,
0.001f, 1))
ERRMSG("Cannot read planetary boundary layer!");
WARN("Cannot read planetary boundary layer height!");

/* Read CAPE... */
if (ctl->met_cape == 0)
Expand Down
41 changes: 23 additions & 18 deletions src/mptrac.h
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ typedef struct {
/*! Convective available potential energy data (0=file, 1=calculate). */
int met_cape;

/*! Planetary boundary layer data (0=file, 1=Richardson, 2=theta). */
/*! Planetary boundary layer data (0=file, 1=z2p, 2=Richardson, 3=theta). */
int met_pbl;

/*! Minimum depth of planetary boundary layer [km]. */
Expand Down Expand Up @@ -6776,42 +6776,47 @@ int read_met_nc_3d(
const float scl);

/**
* @brief Computes the planetary boundary layer (PBL) height based on meteorological data.
* @brief Computes the planetary boundary layer (PBL) pressure based on meteorological data.
*
* This function calculates the PBL height for each grid point using one of three methods:
* 1. From precomputed values in the meteorological data file.
* 2. Based on the bulk Richardson number criterion.
* 3. Based on potential temperature difference.
* This function determines the PBL pressure for each grid point using one of four methods:
* 0. Read PBL pressure from meteo data file.
* 1. Read PBL heights from meteo data file and convert to pressure.
* 2. Determine PBL pressure based on bulk Richardson number criterion.
* 3. Determine PBL pressure Based on potential temperature difference.
* The calculated PBL height is constrained by user-defined minimum and maximum limits.
*
* @param[in] ctl Pointer to the control structure (`ctl_t`), which contains
* parameters controlling the PBL calculation.
* @param[in,out] met Pointer to the meteorological data structure (`met_t`),
* which contains grid and atmospheric data.
* The `met->pbl` array is updated with the calculated PBL heights.
* The `met->pbl` array is updated with the calculated PBL pressure.
*
* Method 0 (Precomputed PBL height from file):
* - Interpolates the PBL height using the pressure at the top of the PBL and
* the meteorological vertical profile.
* Method 0 (Precomputed PBL pressure from file):
* - Read PBL pressure from meteo data file.
*
* Method 1 (Richardson number criterion):
* - Implements a method based on the bulk Richardson number (critical value: 0.25).
* Method 1 (Precomputed PBL height from file):
* - Read PBL height from meteo data file.
* - Interpolates the PBL pressure using the geopotential heights from the meteo file.
*
* Method 2 (Richardson number criterion):
* - Implements a method based on the bulk Richardson number (critical value: Ri = 0.25).
* - Iteratively evaluates vertical levels, calculating wind shear, and thermal gradients,
* until the Richardson number exceeds the critical threshold.
* - Interpolates the PBL height at the critical Richardson number.
* - Interpolates between levels to find the precise height.
*
* Method 2 (Potential temperature difference):
* Method 3 (Potential temperature difference):
* - Computes the PBL height as the altitude where the potential temperature exceeds
* the surface value by 2 K.
* - Interpolates between levels to find the precise height.
*
* Final Adjustments:
* - Ensures the PBL height respects user-defined minimum and maximum thresholds.
*
* @note Method 1 is a standard method for estimating PBL depths, but the current implementation
* seems to significantly underestimate PBL depths compared to ECMWF data or Method 2. Therefore,
* Method 2, is selected by default. If PBL data are available from the meteo data files,
* it is recommended to select Method 0.
* @note Method 2 is a standard method for estimating PBL depths, but
* the current implementation seems to underestimate PBL depths
* compared to ECMWF PBL data or Method 3. Therefore, Method 3, is
* selected by default. If PBL heights are available from the meteo
* data files, it is recommended to select Method 1.
*
* @author Lars Hoffmann
*/
Expand Down

0 comments on commit 2167444

Please sign in to comment.