From bdc0e290797f0966656b80b255fc7225b46bcd1a Mon Sep 17 00:00:00 2001 From: Eric Sinsky - NOAA <48259628+EricSinsky-NOAA@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:12:33 -0500 Subject: [PATCH] Fix mod_icec bug in atmos_prod (#3167) The purpose of this PR is to fix a bug that causes the ensstat task to occasionally produce a segmentation fault error. This segmentation fault error is due to undefined values not being skipped in the ensemble spread and mean calculations in the ensstat program. The reason undefined values were not being skipped is because variables with undefined values were not using bitmap in the pgrb files. Ensstat expects undefined variables to use bitmap, otherwise ensstat will not skip those undefined values. The undefined variables were not using bitmap because of a bug in the atmos_prod task, where the mod_icec function was not being skipped for grib2 files that did not contain the LAND and ICEC variables. In the [offline UPP](https://github.com/NOAA-EMC/UPP/blob/develop/ush/fv3gfs_dwn_nems.sh), the mod_icec functionality was being executed when LAND and ICEC variables existed in the grib2 file. This same condition has been applied in this PR for mod_icec. Resolves #3150 --- ush/interp_atmos_master.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ush/interp_atmos_master.sh b/ush/interp_atmos_master.sh index 4c4ee4b03c..3a3edc470b 100755 --- a/ush/interp_atmos_master.sh +++ b/ush/interp_atmos_master.sh @@ -53,7 +53,11 @@ export err=$?; err_chk # trim and mask for all grids for grid in "${grids[@]}"; do trim_rh "${output_file_prefix}_${grid}"; export err=$?; err_chk - mod_icec "${output_file_prefix}_${grid}"; export err=$?; err_chk + # shellcheck disable=SC2312 + var_count=$(${WGRIB2} "${output_file_prefix}_${grid}" -match "LAND|ICEC" |wc -l) + if [[ "${var_count}" -eq 2 ]]; then + mod_icec "${output_file_prefix}_${grid}"; export err=$?; err_chk + fi done exit 0