From 93c9f7b9560336f340c44a7fe0c1cf4ffbfbe04e Mon Sep 17 00:00:00 2001 From: hertneky <39317287+hertneky@users.noreply.github.com> Date: Thu, 26 Mar 2020 13:04:43 -0600 Subject: [PATCH] Add HWRF fix for running copygb from James Frimmel (#14) * Add HWRF fix for running copygb from James Frimmel * Change default to compile all libraries Co-authored-by: Tracy Co-authored-by: Michael Kavulich, Jr --- make_ncep_libs.sh | 2 +- src/w3nco/v2.0.6/src/instrument.f | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/make_ncep_libs.sh b/make_ncep_libs.sh index 00d4000..0e1d8f1 100755 --- a/make_ncep_libs.sh +++ b/make_ncep_libs.sh @@ -65,7 +65,7 @@ if [ -z $COMPILER ] ; then echo "ERROR: compiler argument is required"; echo""; if [ -z $NCEPLIBS_DST_DIR ] ; then echo "ERROR: installdir argument is required"; echo""; usage; fi if [ -z $OPENMP ] ; then echo "ERROR: openmp argument is required"; echo""; usage; fi if [ -z $MPI ] ; then MPI=1; fi -if [ -z $APP ] ; then APP=0; fi #APP is an optional argument +if [ -z $APP ] ; then APP=1; fi #APP is an optional argument # For back compatability, allow APP to be 0 (global) or 1 (all) if [ "$APP" == "0" ]; then diff --git a/src/w3nco/v2.0.6/src/instrument.f b/src/w3nco/v2.0.6/src/instrument.f index 0c936f9..245afc8 100644 --- a/src/w3nco/v2.0.6/src/instrument.f +++ b/src/w3nco/v2.0.6/src/instrument.f @@ -12,6 +12,8 @@ SUBROUTINE INSTRUMENT(K,KALL,TTOT,TMIN,TMAX) ! ! PROGRAM HISTORY LOG: ! 1998-07-16 IREDELL +! 2019-09-17 FRIMEL and KALINA +! DECOMPOSE RETURN STATISTCS IF STATEMENT ! ! USAGE: CALL INSTRUMENT(K,KALL,TTOT,TMIN,TMAX) ! INPUT ARGUMENT LIST: @@ -94,11 +96,27 @@ SUBROUTINE INSTRUMENT(K,KALL,TTOT,TMIN,TMAX) ENDIF ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! RETURN STATISTICS - IF(KA.GE.1.AND.KA.LE.KMAX.AND.KALLS(KA).GT.0) THEN - KALL=KALLS(KA) - TTOT=TTOTS(KA) - TMIN=TMINS(KA) - TMAX=TMAXS(KA) + +! FRIMEL and KALINA, DECOMPOSE THE IF STATEMENT, SAFER FOR SOME +! COMPILERS. Since No Guarantee on order of evaluation, and when +! evaluation will stop. +! MAKE SURE KA.GE.1 BEFORE TESTING IF KALLS(KA).GT.0, ELSE +! MAY ENCOUNTER A RUNTIME SIGSEGV SEGEMENTATION FAULT. +! Since Subscript #1 of the array KALLS can have value 0 which +! is less than the lower bound of 1 +! IF(KA.GE.1.AND.KA.LE.KMAX.AND.KALLS(KA).GT.0) THEN + IF(KA.GE.1.AND.KA.LE.KMAX) THEN + IF(KALLS(KA).GT.0) THEN + KALL=KALLS(KA) + TTOT=TTOTS(KA) + TMIN=TMINS(KA) + TMAX=TMAXS(KA) + ELSE + KALL=0 + TTOT=0 + TMIN=0 + TMAX=0 + ENDIF ELSE KALL=0 TTOT=0