From dca00a3d446af1abeb116cdf2c85a2281b5bf71c Mon Sep 17 00:00:00 2001 From: Larissa Reames <52886575+LarissaReames-NOAA@users.noreply.github.com> Date: Thu, 2 Feb 2023 12:30:32 -0600 Subject: [PATCH] Detect duplicate vertical levels in chgres_cube. (#767) Quit with an error message when a GRIB2 file contains duplicate vertical levels. Fixes #763. --- sorc/chgres_cube.fd/atm_input_data.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sorc/chgres_cube.fd/atm_input_data.F90 b/sorc/chgres_cube.fd/atm_input_data.F90 index cb9b1e87c..bf5494b72 100644 --- a/sorc/chgres_cube.fd/atm_input_data.F90 +++ b/sorc/chgres_cube.fd/atm_input_data.F90 @@ -2154,13 +2154,19 @@ subroutine read_input_atm_grib2_file(localpet) call quicksort(rlevs,1,lev_input) - do i = 1, lev_input + do i = 1, lev_input if (isnative) then write(slevs(i), '(i6)') nint(rlevs(i)) slevs(i) = trim(slevs(i)) // " hybrid" + if (i>1) then + if (any(slevs(1:i-1)==slevs(i))) call error_handler("Duplicate vertical level entries found.",1) + endif else write(slevs(i), '(f11.2)') rlevs(i) slevs(i) = trim(slevs(i)) // " Pa" + if (i>1) then + if (any(slevs(1:i-1)==slevs(i))) call error_handler("Duplicate vertical level entries found.",1) + endif endif enddo