From 82831924544d3e7d0cf4434a33298f8aa6200c4c Mon Sep 17 00:00:00 2001 From: Ed Safford <62339196+EdwardSafford-NOAA@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:59:24 -0500 Subject: [PATCH] Add regional data extraction capability to ConMon (#117) * Ref #110 Add DE for regional (nam), fix bug in conmon_read_diag.F90. * Ref #110 Update for hera. * Ref #110 Update error checking. * Ref #110 Final clean up. * Ref #110 Final clean up. * Ref #110 Fix area assignment in DE script. --- .../data_extract/ush/ConMon_DE_rgn.sh | 283 ++++++++++++++++++ .../conmon_grads_lev.fd/conmon_read_diag.F90 | 10 +- .../conmon_read_diag.F90 | 10 +- .../conmon_grads_sfc.fd/conmon_read_diag.F90 | 10 +- .../sorc/conmon_grads_sfc.fd/grads_sfc.f90 | 6 +- .../conmon_read_diag.F90 | 10 +- .../sorc/conmon_time.fd/conmon_read_diag.F90 | 10 +- .../conmon_shared/ush/clean_tankdir_rgn.sh | 38 +++ .../conmon_shared/ush/diag2grad_ps_case.sh | 4 +- .../conmon_shared/ush/diag2grad_q_case.sh | 2 +- .../conmon_shared/ush/diag2grad_t_case.sh | 5 +- .../conmon_shared/ush/diag2grad_uv_case.sh | 2 +- .../nwprod/conmon_shared/ush/horz_hist.sh | 58 ++-- .../nwprod/conmon_shared/ush/time_vert.sh | 12 +- .../nam_conmon/fix/nam_regional_convinfo.txt | 207 +++++++++++++ .../nwprod/nam_conmon/jobs/JNAM_CONMON | 111 +++++++ .../nwprod/nam_conmon/scripts/exnam_conmon.sh | 114 +++++++ src/Conventional_Monitor/parm/ConMon_config | 15 +- ush/rgn_find_cycle.pl | 232 +++----------- 19 files changed, 875 insertions(+), 264 deletions(-) create mode 100755 src/Conventional_Monitor/data_extract/ush/ConMon_DE_rgn.sh create mode 100755 src/Conventional_Monitor/nwprod/conmon_shared/ush/clean_tankdir_rgn.sh create mode 100755 src/Conventional_Monitor/nwprod/nam_conmon/fix/nam_regional_convinfo.txt create mode 100755 src/Conventional_Monitor/nwprod/nam_conmon/jobs/JNAM_CONMON create mode 100755 src/Conventional_Monitor/nwprod/nam_conmon/scripts/exnam_conmon.sh diff --git a/src/Conventional_Monitor/data_extract/ush/ConMon_DE_rgn.sh b/src/Conventional_Monitor/data_extract/ush/ConMon_DE_rgn.sh new file mode 100755 index 00000000..479cf2cc --- /dev/null +++ b/src/Conventional_Monitor/data_extract/ush/ConMon_DE_rgn.sh @@ -0,0 +1,283 @@ +#!/bin/bash + +#-------------------------------------------------------------------- +# +# ConMon_DE_rgn.sh +# +# This is the top level data extraction script for the Conventional +# Data Monitor (ConMon) package for regional sources. +# +# C_DATDIR and C_GDATDIR (source directories for the cnvstat files) +# point to the operational data (NAM). They can be overriden +# to process data from another source. +#-------------------------------------------------------------------- + +#-------------------------------------------------------------------- +# usage +#-------------------------------------------------------------------- +function usage { + echo "Usage: ConMon_DE_rgn.sh suffix [-p|--pdate pdate -c|-cnv /path/to/cnvstat/dir" + echo " Suffix is the indentifier for this data source." + echo " -p | --pdate yyyymmddcc to specify the cycle to be processed" + echo " if unspecified the last available date will be processed" + echo " -c | --cnv location of the cnvstat and other essential files" + echo " " +} + +#------------------------------------------------------------------------------ +# set_hr_tm() assigns the rgnTM and rgnHH vars which are file name components +# in the rapid refresh scheme the nam uses. +#------------------------------------------------------------------------------ +function set_hr_tm(){ + + case $hr in + 00) rgnHH=t00z + rgnTM=tm00;; + 01) rgnHH=t06z + rgnTM=tm05;; + 02) rgnHH=t06z + rgnTM=tm04;; + 03) rgnHH=t06z + rgnTM=tm03;; + 04) rgnHH=t06z + rgnTM=tm02;; + 05) rgnHH=t06z + rgnTM=tm01;; + 06) rgnHH=t06z + rgnTM=tm00;; + 07) rgnHH=t12z + rgnTM=tm05;; + 08) rgnHH=t12z + rgnTM=tm04;; + 09) rgnHH=t12z + rgnTM=tm03;; + 10) rgnHH=t12z + rgnTM=tm02;; + 11) rgnHH=t12z + rgnTM=tm01;; + 12) rgnHH=t12z + rgnTM=tm00;; + 13) rgnHH=t18z + rgnTM=tm05;; + 14) rgnHH=t18z + rgnTM=tm04;; + 15) rgnHH=t18z + rgnTM=tm03;; + 16) rgnHH=t18z + rgnTM=tm02;; + 17) rgnHH=t18z + rgnTM=tm01;; + 18) rgnHH=t18z + rgnTM=tm00;; + 19) rgnHH=t00z # This is where the day changes. + rgnTM=tm05 + use_next_day=1;; + 20) rgnHH=t00z + rgnTM=tm04 + use_next_day=1;; + 21) rgnHH=t00z + rgnTM=tm03 + use_next_day=1;; + 22) rgnHH=t00z + rgnTM=tm02 + use_next_day=1;; + 23) rgnHH=t00z + rgnTM=tm01 + use_next_day=1;; + esac +} + + +#-------------------------------------------------------------------- +# ConMon_DE.sh begins here +#-------------------------------------------------------------------- + +echo "Begin ConMon_DE_rgn.sh" +exit_value=0 + +export AREA='rgn' +nargs=$# +if [[ ${nargs} -lt 1 || ${nargs} -gt 7 ]]; then + usage + exit 1 +fi + + +#----------------------------------------------- +# Process command line arguments +# + +pdate="" +cnvstat_location="" + +while [[ $# -ge 1 ]] +do + key="$1" + echo ${key} + + case ${key} in + -p|--pdate) + pdate="$2" + shift # past argument + ;; + -c|--cnv) + cnvstat_location="$2" + shift # past argument + ;; + *) + #any unspecified key is CONMON_SUFFIX + export CONMON_SUFFIX=${key} + ;; + esac + + shift +done + +this_file=`basename $0` +this_dir=`dirname $0` + +nam_ver=v4.2 + +echo CONMON_SUFFIX = ${CONMON_SUFFIX} +echo cnvstat_location = ${cnvstat_location} +echo pdate = ${pdate} + +top_parm=${this_dir}/../../parm + +conmon_config=${conmon_config:-${top_parm}/ConMon_config} +if [[ -s ${conmon_config} ]]; then + . ${conmon_config} + echo "able to source ${conmon_config}" +else + echo "Unable to source ${conmon_config} file" + exit 3 +fi + + + +#-------------------------------------------------------------------- +# Create any missing directories + +if [[ ! -d ${C_TANKDIR} ]]; then + mkdir -p ${C_TANKDIR} +fi +if [[ ! -d ${C_LOGDIR} ]]; then + mkdir -p ${C_LOGDIR} +fi +if [[ ! -d ${C_IMGNDIR} ]]; then + mkdir -p ${C_IMGNDIR} +fi + + +#-------------------------------------------------------------------- +# Get date of cycle to process and/or previous cycle processed. +# +echo "C_TANKDIR: ${C_TANKDIR}" +ldate="" +if [[ ${#pdate} -le 0 ]]; then + ldate=`${MON_USH}/rgn_find_cycle.pl --cyc 1 --dir ${C_TANKDIR} --mon conmon` + pdate=`${NDATE} +01 ${ldate}` +fi + +export PDY=`echo ${pdate}|cut -c1-8` +export CYC=`echo ${pdate}|cut -c9-10` + +hr=${CYC} + +rgnHH='' +rgnTM='' +use_next_day=0 + +set_hr_tm + + +if [[ ${#cnvstat_location} -le 0 ]]; then + export cnvstat_location=${COMROOT}/nam/${nam_ver} +fi +export CNVSTAT_LOCATION=${cnvstat_location} +echo cnvstat_location = ${cnvstat_location} + +export C_DATDIR=${C_DATDIR:-${CNVSTAT_LOCATION}/${CONMON_SUFFIX}.${PDY}} +export C_COMIN=${C_DATDIR} +export CONMON_WORK_DIR=${CONMON_WORK_DIR:-${C_STMP_USER}/${CONMON_SUFFIX}}/conmon + + +#---------------------------------------------------------------------- +# cnvstat file +# +# If processing one of the last 5 cycles for the day, look for +# them in the next day's directory. The $use_next_day variable, set +# in set_hr_tm() flags this condition. +#---------------------------------------------------------------------- +cnvstat="" +pdate06="" +day=${PDY} + +if [[ $use_next_day == 1 ]]; then + pdate06=`${NDATE} +6 ${PDY}${CYC}` + day=`echo ${pdate06} | cut -c1-8` +fi +export cnvstat=${cnvstat_location}/${CONMON_SUFFIX}.${day}/${CONMON_SUFFIX}.${rgnHH}.cnvstat.${rgnTM} + +if [[ -e ${cnvstat} ]]; then + echo "cnvstat exists" +else + echo "cnvstat is a no-go" +fi + +#------------------------------------------------------------ +# These definitions are intentionally commented out. Error +# checking for regional data sources is not yet enabled, but +# when it is, these definitions will become relevent. +##--------------------------------------------- +## override the default convinfo definition +## if there's a copy in C_TANKDIR/info +## +#if [[ -e ${C_TANKDIR}/info/global_convinfo.txt ]]; then +# echo " overriding convinfo definition" +# export convinfo=${C_TANKDIR}/info/global_convinfo.txt +#fi +# +##--------------------------------------------- +## override the default conmon_base definition +## if there's a copy in C_TANKDIR/info +## +#if [[ -e ${C_TANKDIR}/info/gdas_conmon_base.txt ]]; then +# echo " overriding conmon_base definition" +# export conmon_base=${C_TANKDIR}/info/gdas_conmon_base.txt +#fi + +jobname=CM_RDE_${CONMON_SUFFIX} + +if [[ -e ${cnvstat} ]]; then + + #------------------------------------------------------------------ + # Submit data extraction job. + #------------------------------------------------------------------ + logfile=${C_LOGDIR}/DE.${PDY}.${CYC}.log + if [[ -e ${logfile} ]]; then + rm -f ${logfile} + fi + + if [[ ${MY_MACHINE} = "hera" || ${MY_MACHINE} = "s4" || ${MY_MACHINE} = "orion" ]]; then + ${SUB} -A ${ACCOUNT} --ntasks=1 --time=00:30:00 \ + -p ${SERVICE_PARTITION} -J ${jobname} -o ${C_LOGDIR}/DE.${PDY}.${CYC}.log \ + ${HOMEnam_conmon}/jobs/JNAM_CONMON + + elif [[ ${MY_MACHINE} = "jet" ]]; then + ${SUB} -A ${ACCOUNT} -ntasks=1 --time=00:30:00 --mem=5000 \ + -p ${SERVICE_PARTITION} -J ${jobname} -o ${C_LOGDIR}/DE.${PDY}.${CYC}.log \ + ${HOMEnam_conmon}/jobs/JNAM_CONMON + + elif [[ ${MY_MACHINE} = "wcoss2" ]]; then + ${SUB} -V -q ${JOB_QUEUE} -A ${ACCOUNT} -o ${logfile} -e ${logfile} -l walltime=30:00 \ + -N ${jobname} -l select=1:mem=5000M ${HOMEnam_conmon}/jobs/JNAM_CONMON + fi + +else + echo "data not available -- missing $cnvstat file" + exit_value=7 +fi + +echo "End ConMon_DE_rgn.sh" +exit ${exit_value} diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 index add99d17..bb02641b 100644 --- a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 +++ b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_lev.fd/conmon_read_diag.F90 @@ -1738,18 +1738,18 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr exit endif + !--- read diag info + allocate(cdiag(ii),rdiag(file_nreal,ii)) + read(lunin,IOSTAT=iflag) cdiag,rdiag + !--------------------------------------------- ! skip to next iteration if types don't match ! if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + deallocate(cdiag, rdiag) cycle endif - - !--- read diag info - allocate(cdiag(ii),rdiag(file_nreal,ii)) - read(lunin,IOSTAT=iflag) cdiag,rdiag - !--- exit loop on read error if( iflag /= 0 ) then deallocate( cdiag,rdiag ) diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 index add99d17..bb02641b 100644 --- a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 +++ b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd/conmon_read_diag.F90 @@ -1738,18 +1738,18 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr exit endif + !--- read diag info + allocate(cdiag(ii),rdiag(file_nreal,ii)) + read(lunin,IOSTAT=iflag) cdiag,rdiag + !--------------------------------------------- ! skip to next iteration if types don't match ! if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + deallocate(cdiag, rdiag) cycle endif - - !--- read diag info - allocate(cdiag(ii),rdiag(file_nreal,ii)) - read(lunin,IOSTAT=iflag) cdiag,rdiag - !--- exit loop on read error if( iflag /= 0 ) then deallocate( cdiag,rdiag ) diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 index add99d17..bb02641b 100644 --- a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 +++ b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/conmon_read_diag.F90 @@ -1738,18 +1738,18 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr exit endif + !--- read diag info + allocate(cdiag(ii),rdiag(file_nreal,ii)) + read(lunin,IOSTAT=iflag) cdiag,rdiag + !--------------------------------------------- ! skip to next iteration if types don't match ! if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + deallocate(cdiag, rdiag) cycle endif - - !--- read diag info - allocate(cdiag(ii),rdiag(file_nreal,ii)) - read(lunin,IOSTAT=iflag) cdiag,rdiag - !--- exit loop on read error if( iflag /= 0 ) then deallocate( cdiag,rdiag ) diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 index acec4a60..323bc7d6 100644 --- a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 +++ b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfc.fd/grads_sfc.f90 @@ -20,8 +20,8 @@ subroutine grads_sfc(fileo,ifileo,nobs,nreal,iscater,igrads,isubtype,subtype,lis real(4),allocatable,dimension(:,:) :: rdiag_m2 character(8),allocatable,dimension(:) :: cdiag character(8) :: stid - character(ifileo) :: fileo, file_nobs - character(30) :: files,filein,filegrads + character(ifileo) :: fileo + character(30) :: files,filein,filegrads, file_nobs character(3) :: subtype,run integer nobs,nreal,nlfag,nflg0,nlev,nlev0,iscater,igrads real(4) rtim,xlat0,xlon0,rlat,rlon @@ -92,7 +92,7 @@ subroutine grads_sfc(fileo,ifileo,nobs,nreal,iscater,igrads,isubtype,subtype,lis ! write the horiz data file ! if (igrads ==1 .AND. nobs > 0) then - filegrads=trim(fileo)//'_'//trim(subtype)//'.grads.'//run + filegrads=trim(fileo)//'_'//trim(subtype)//'.grads.'//trim(run) write(6,*) 'filegrads = ', filegrads open(21,file=filegrads,form='unformatted',status='new') ! open output file diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 index add99d17..bb02641b 100644 --- a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 +++ b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd/conmon_read_diag.F90 @@ -1738,18 +1738,18 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr exit endif + !--- read diag info + allocate(cdiag(ii),rdiag(file_nreal,ii)) + read(lunin,IOSTAT=iflag) cdiag,rdiag + !--------------------------------------------- ! skip to next iteration if types don't match ! if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + deallocate(cdiag, rdiag) cycle endif - - !--- read diag info - allocate(cdiag(ii),rdiag(file_nreal,ii)) - read(lunin,IOSTAT=iflag) cdiag,rdiag - !--- exit loop on read error if( iflag /= 0 ) then deallocate( cdiag,rdiag ) diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 index add99d17..bb02641b 100644 --- a/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 +++ b/src/Conventional_Monitor/nwprod/conmon_shared/sorc/conmon_time.fd/conmon_read_diag.F90 @@ -1738,18 +1738,18 @@ subroutine read_diag_file_bin( input_file, return_all, ctype, intype,expected_nr exit endif + !--- read diag info + allocate(cdiag(ii),rdiag(file_nreal,ii)) + read(lunin,IOSTAT=iflag) cdiag,rdiag + !--------------------------------------------- ! skip to next iteration if types don't match ! if(( return_all .eqv. .false. ) .AND. ( trim( dtype ) /= trim( ctype ))) then + deallocate(cdiag, rdiag) cycle endif - - !--- read diag info - allocate(cdiag(ii),rdiag(file_nreal,ii)) - read(lunin,IOSTAT=iflag) cdiag,rdiag - !--- exit loop on read error if( iflag /= 0 ) then deallocate( cdiag,rdiag ) diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/clean_tankdir_rgn.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/clean_tankdir_rgn.sh new file mode 100755 index 00000000..32070df9 --- /dev/null +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/clean_tankdir_rgn.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +#------------------------------------------------------------------ +# +# clean_tankdir_rgn.sh +# +#------------------------------------------------------------------ + + older_than=30 + + #----------------------------------------------- + # Get list of conmon directories in $C_TANKDIR + # + dirs=`ls ${C_TANKDIR} | grep conmon` + + #----------------------------------------------- + # Determine number of days from $PDATE for all + # directories. + # + for dir in $dirs; do + file_name="${dir##*/}" + dir_extension="${file_name##*.}" + + #-------------------------------------------------- + # Determine number of days from $PDATE. Note + # that time difference is calculated in seconds, + # hence the division by the number of seconds/day. + # + days=$(( ($(date --date=${PDY} +%s) - $(date --date=${dir_extension} +%s) )/(60*60*24) )) + + if [ $days -gt ${older_than} ]; then + echo "removing ${C_TANKDIR}/${dir}" + rm -rf ${C_TANKDIR}/${dir} + fi + done + +exit + diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_ps_case.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_ps_case.sh index b10233b9..5d9e7c06 100755 --- a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_ps_case.sh +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_ps_case.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -xa #------------------------------------------------------- @@ -38,7 +38,7 @@ set -xa nreal2_ps=`expr $nreal - 2` ### the data items in the grads files - if [ "$mtype" = 'ps180' -o "$mtype" = 'ps181' -o "$mtype" = 'ps183' -o "$mtype" = 'ps187' ]; then + if [ "$mtype" = 'ps180' -o "$mtype" = 'ps181' -o "$mtype" = 'ps183' -o "$mtype" = 'ps187' -o "$mtype" = 'ps132' ]; then rm -f diag2grads cp $EXECconmon/conmon_grads_sfctime.x ./diag2grads rm -f input diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_q_case.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_q_case.sh index 8a51b344..072b0646 100755 --- a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_q_case.sh +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_q_case.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -xa #------------------------------------------------------------ diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_t_case.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_t_case.sh index 18e2c72e..2c1c1f1d 100755 --- a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_t_case.sh +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_t_case.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -xa #----------------------------------------------------- @@ -33,9 +33,6 @@ echo "--> diag2grad_t_case.sh" ctype=`echo ${mtype} | cut -c2-4` nreal2=`expr $nreal - 2` - if [[ $VERBOSE = "YES" ]]; then - echo ctype, nreal2 = $ctype, nreal2 - fi card=alllev run_exe=1 diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_uv_case.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_uv_case.sh index af0116a6..80dc09f8 100755 --- a/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_uv_case.sh +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/diag2grad_uv_case.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -xa #---------------------------------------------------------- diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/horz_hist.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/horz_hist.sh index 9e93fc6c..02d03ecf 100755 --- a/src/Conventional_Monitor/nwprod/conmon_shared/ush/horz_hist.sh +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/horz_hist.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #------------------------------------------------------------------ # @@ -20,7 +20,6 @@ #---------------------------------------------------------- ps_TYPE=`${USHconmon}/get_typelist.pl --file $convinfo --type ps --mon` q_TYPE=`${USHconmon}/get_typelist.pl --file $convinfo --type q --mon` - t_TYPE=`${USHconmon}/get_typelist.pl --file $convinfo --type t --mon` uv_TYPE=`${USHconmon}/get_typelist.pl --file $convinfo --type uv --mon` @@ -30,10 +29,15 @@ mkdir -p ${TANKDIR_conmon}/horz_hist/ges mkdir -p ${TANKDIR_conmon}/horz_hist/anl - export nreal_ps=${nreal_ps:-19} - export nreal_q=${nreal_q:-20} - export nreal_t=${nreal_t:-24} - export nreal_uv=${nreal_uv:-23} +# export nreal_ps=${nreal_ps:-19} +# export nreal_q=${nreal_q:-20} +# export nreal_t=${nreal_t:-24} +# export nreal_uv=${nreal_uv:-23} + + export nreal_ps=${nreal_ps:-20} + export nreal_q=${nreal_q:-21} + export nreal_t=${nreal_t:-20} + export nreal_uv=${nreal_uv:-25} for type in ps q t uv; do @@ -51,11 +55,6 @@ mtype=`echo ${dtype} | cut -f1 -d_ | xargs` subtype=`echo ${dtype} | cut -f2 -d_ | xargs` - if [[ "$VERBOSE" = "YES" ]]; then - echo "DEBUG: dtype = $dtype" - echo "mtype, subtype = $mtype, $subtype" - fi - for run in ges anl; do #------------------------------------------------------------- @@ -74,10 +73,6 @@ echo "INPUT_FILE = ${INPUT_FILE}" - if [[ "$VERBOSE" = "YES" ]]; then - echo "run = $run" - fi - ${USHconmon}/diag2grad_${type}_case.sh done #### done with run @@ -99,35 +94,38 @@ mv -f ${stdout_tar}.${Z} ${dest_dir}/. cat *nobs.${run} > nobs.${run}.${PDATE} - cp nobs.${run}.${PDATE} ${dest_dir}/. + mv nobs.${run}.${PDATE} ${dest_dir}/. #--------------------------------- # run the mk_low_cnt.pl script #--------------------------------- - ${USHconmon}/mk_low_cnt.pl --net ${CONMON_SUFFIX} \ + if [[ ${DO_DATA_RPT} -eq 1 && ${CONMON_AREA} == 'glb' ]]; then + ${USHconmon}/mk_low_cnt.pl --net ${CONMON_SUFFIX} \ --run ${RUN} --cyc ${PDATE} \ --nobsf ${TANKDIR_conmon}/horz_hist/${run}/nobs.${run}.${PDATE} \ --lcntf ${TANKDIR_conmon}/horz_hist/${run}/low_cnt.${run}.${PDATE} \ --basef ${conmon_base} - #-------------------------------- - # run the mk_err_rpt.pl script - #-------------------------------- - low_cnt_file=${TANKDIR_conmon}/horz_hist/${run}/low_cnt.${run}.${PDATE} - if [[ -e ${low_cnt_file}.gz ]]; then - $UNCOMPRESS ${low_cnt_file}.gz - fi + #-------------------------------- + # run the mk_err_rpt.pl script + #-------------------------------- + low_cnt_file=${TANKDIR_conmon}/horz_hist/${run}/low_cnt.${run}.${PDATE} + if [[ -e ${low_cnt_file}.gz ]]; then + $UNCOMPRESS ${low_cnt_file}.gz + fi - prev_low_cnt_file=${TANKDIR_prev_conmon}/horz_hist/${run}/low_cnt.${run}.${GDATE} - if [[ -e ${prev_low_cnt_file}.gz ]]; then - $UNCOMPRESS ${prev_low_cnt_file}.gz - fi + gdate=`${NDATE} -6 ${PDATE}` + prev_low_cnt_file=${TANKDIR_prev_conmon}/horz_hist/${run}/low_cnt.${run}.${gdate} + if [[ -e ${prev_low_cnt_file}.gz ]]; then + $UNCOMPRESS ${prev_low_cnt_file}.gz + fi - ${USHconmon}/mk_err_rpt.pl --net ${CONMON_SUFFIX} --run ${RUN} \ + ${USHconmon}/mk_err_rpt.pl --net ${CONMON_SUFFIX} --run ${RUN} \ --lcf ${low_cnt_file} --plcf ${prev_low_cnt_file} \ - --cyc0 ${PDATE} --cyc1 ${GDATE} \ + --cyc0 ${PDATE} --cyc1 ${gdate} \ --errf ${TANKDIR_conmon}/horz_hist/${run}/err_rpt.${run}.${PDATE} + fi done echo "<-- horz_hist.sh" diff --git a/src/Conventional_Monitor/nwprod/conmon_shared/ush/time_vert.sh b/src/Conventional_Monitor/nwprod/conmon_shared/ush/time_vert.sh index 220a6f73..e9fe54a4 100755 --- a/src/Conventional_Monitor/nwprod/conmon_shared/ush/time_vert.sh +++ b/src/Conventional_Monitor/nwprod/conmon_shared/ush/time_vert.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -xa #---------------------------------------------------- @@ -14,7 +14,7 @@ echo "--> time_vert.sh" echo " $CWD" rc=0 - export nregion=10 + nregion=10 echo "CONMON_NETCDF = ${CONMON_NETCDF}" netcdf=".false." @@ -24,16 +24,13 @@ echo "--> time_vert.sh" fi echo "netcdf = $netcdf" - #------------------------------------------ # set up TANKDIR (output) sub-directories # echo TANKDIR_conmon = $TANKDIR_conmon - export savedir=$TANKDIR_conmon/time_vert + savedir=$TANKDIR_conmon/time_vert mkdir -p ${savedir} - - echo "convinfo = $convinfo" # defined in calling script cp ${convinfo} ./convinfo export execfile=${EXECconmon}/conmon_time.x @@ -49,8 +46,6 @@ echo "--> time_vert.sh" if [ $CONMON_NETCDF -eq 0 ]; then for run in ges anl; do - - echo " cycle = $cycle " ${UNCOMPRESS} ./diag_conv_${run}.${PDATE}.${Z} @@ -168,7 +163,6 @@ EOF fi - echo "<-- time_vert.sh" exit ${rc} diff --git a/src/Conventional_Monitor/nwprod/nam_conmon/fix/nam_regional_convinfo.txt b/src/Conventional_Monitor/nwprod/nam_conmon/fix/nam_regional_convinfo.txt new file mode 100755 index 00000000..ff48686b --- /dev/null +++ b/src/Conventional_Monitor/nwprod/nam_conmon/fix/nam_regional_convinfo.txt @@ -0,0 +1,207 @@ +! otype = observation type (a7, t, uv, q, etc.) +! type = prepbufr observation type (if available) +! sub = prepbufr subtype (not yet available) +! iuse = flag if to use/not use / monitor data +! = 1 use data +! = 0 do not use data +! = -1 monitor data +! twindow = time window (+/- hours) +! numgrp = cross validation parameter - number of groups +! ngroup = cross validation parameter - group to remove from data use +! nmiter = cross validation parameter - external iteration to introduce removed data +! gross = gross error parameter - gross error +! ermax = gross error parameter - max error +! ermin = gross error parameter - min error +! var_b = variational quality control parameter - b parameter +! var_pg = variational quality control parameter - pg parameter +! ib,ip: new nonlinear qc parameter, ib:betta, ip:kappa +!otype type sub iuse twindow numgrp ngroup nmiter gross ermax ermin var_b var_pg ithin rmesh pmesh npred pmot ptime ib ip + ps 111 0 -1 1.5 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 120 0 1 1.5 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 132 0 -1 1.5 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 180 0 1 1.5 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 181 0 1 0.25 0 0 0 3.6 3.0 1.0 3.6 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 182 0 1 1.5 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 183 0 -1 0.25 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 187 0 1 0.25 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + ps 188 0 1 0.25 0 0 0 4.0 3.0 1.0 4.0 0.000300 0 0. 0. 0 0. 0. 0 0 + t 120 0 1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.000001 0 0. 0. 0 0. 0. 0 0 + t 126 0 1 0.1 0 0 0 5.0 5.6 1.3 5.0 0.001000 0 0. 0. 0 0. 0. 0 0 + t 130 0 1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.001000 0 0. 0. 0 0. 0. 0 0 + t 131 0 1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.001000 0 0. 0. 0 0. 0. 0 0 + t 132 0 1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.001000 0 0. 0. 0 0. 0. 0 0 + t 133 0 1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 134 0 -1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 135 0 1 1.5 0 0 0 7.0 5.6 1.3 7.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 180 0 1 1.5 0 0 0 7.0 3.0 1.0 7.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 181 0 1 0.25 0 0 0 5.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 182 0 1 1.5 0 0 0 5.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 183 0 1 0.25 0 0 0 5.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 187 0 1 0.25 0 0 0 5.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 188 0 1 0.25 0 0 0 5.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 192 0 1 0.25 0 0 0 4.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 193 0 1 0.25 0 0 0 4.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 194 0 1 1.5 0 0 0 4.0 3.0 1.0 7.0 0.004000 0 0. 0. 0 0. 0. 0 0 + t 195 0 1 0.25 0 0 0 4.0 3.0 1.0 5.0 0.004000 0 0. 0. 0 0. 0. 0 0 + q 111 0 -1 1.5 0 0 0 7.0 75.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 120 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 130 0 -1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 131 0 -1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 132 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 133 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 134 0 -1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 135 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 180 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 181 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 182 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 183 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 187 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 188 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + q 192 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 193 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 194 0 1 1.5 0 0 0 7.0 50.0 5.0 7.0 0.000500 0 0. 0. 0 0. 0. 0 0 + q 195 0 1 0.25 0 0 0 7.0 50.0 5.0 7.0 0.000600 0 0. 0. 0 0. 0. 0 0 + pw 152 0 -1 1.5 0 0 0 7.0 8.0 2.0 7.0 0.000 0 0. 0. 0 0. 0. 0 0 + pw 153 0 -1 1.5 0 0 0 7.0 8.0 2.0 7.0 0.000 0 0. 0. 0 0. 0. 0 0 + pw 156 0 -1 1.5 0 0 0 7.0 8.0 2.0 7.0 0.000 0 0. 0. 0 0. 0. 0 0 + pw 157 0 -1 1.5 0 0 0 7.0 8.0 2.0 7.0 0.000 0 0. 0. 0 0. 0. 0 0 + pw 158 0 -1 1.5 0 0 0 7.0 8.0 2.0 7.0 0.000 0 0. 0. 0 0. 0. 0 0 + pw 159 0 -1 1.5 0 0 0 7.0 8.0 2.0 7.0 0.000 0 0. 0. 0 0. 0. 0 0 + sst 120 0 -1 1.5 0 0 0 2.0 2.0 0.2 2.0 0.000 0 0. 0. 0 0. 0. 0 0 + sst 180 0 -1 1.5 0 0 0 2.0 2.0 0.2 2.0 0.000 0 0. 0. 0 0. 0. 0 0 + sst 181 0 -1 0.25 0 0 0 2.0 2.0 0.2 2.0 0.000 0 0. 0. 0 0. 0. 0 0 + sst 183 0 -1 0.25 0 0 0 2.0 2.0 0.2 2.0 0.000 0 0. 0. 0 0. 0. 0 0 + sst 187 0 -1 0.25 0 0 0 2.0 2.0 0.2 2.0 0.000 0 0. 0. 0 0. 0. 0 0 + uv 210 0 1 1.5 0 0 0 7.0 6.1 1.4 7.0 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 220 0 1 1.5 0 0 0 8.0 6.1 1.4 8.0 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 221 0 1 1.5 0 0 0 8.0 6.1 1.4 8.0 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 223 0 1 1.5 0 0 0 7.5 6.1 1.4 7.5 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 224 0 1 1.5 0 0 0 6.5 6.1 1.4 6.5 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 227 0 1 0.1 0 0 0 6.5 6.1 1.4 6.5 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 228 0 -1 1.5 0 0 0 6.5 6.1 1.4 6.5 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 229 0 1 1.5 0 0 0 6.5 6.1 1.4 6.5 0.000001 0 0. 0. 0 0. 0. 0 0 + uv 230 0 1 1.5 0 0 0 6.0 6.1 1.4 6.0 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 231 0 1 1.5 0 0 0 6.5 6.1 1.4 6.5 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 232 0 1 1.5 0 0 0 7.0 6.1 1.4 7.0 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 233 0 1 1.5 0 0 0 7.5 6.1 1.4 7.5 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 234 0 -1 1.5 0 0 0 7.5 6.1 1.4 7.5 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 235 0 1 1.5 0 0 0 7.5 6.1 1.4 7.5 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 240 0 -1 1.5 0 0 0 2.5 6.1 1.4 2.5 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 240 257 -1 1.5 0 0 0 2.5 6.1 1.4 2.5 0.000100 0 100. 50. 0 0. 0. 0 0 + uv 240 259 -1 1.5 0 0 0 2.5 6.1 1.4 2.5 0.000100 0 100. 50. 0 0. 0. 0 0 + uv 241 0 -1 1.5 0 0 0 2.5 6.1 1.4 2.5 0.000100 0 0. 0. 0 0. 0. 0 0 + uv 242 0 -1 1.5 0 0 0 2.5 15.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 242 171 1 1.5 0 0 0 2.5 15.0 1.4 2.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 242 172 1 1.5 0 0 0 2.5 15.0 1.4 2.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 242 173 1 1.5 0 0 0 2.5 15.0 1.4 2.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 242 174 1 1.5 0 0 0 2.5 15.0 1.4 2.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 243 0 -1 1.5 0 0 0 1.5 15.0 1.4 1.5 0.055000 0 0. 0. 0 0. 0. 0 0 + uv 243 54 1 1.5 0 0 0 1.5 15.0 1.4 1.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 243 55 -1 1.5 0 0 0 1.5 15.0 1.4 1.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 243 56 -1 1.5 0 0 0 1.5 15.0 1.4 1.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 243 57 -1 1.5 0 0 0 1.5 15.0 1.4 1.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 243 70 1 1.5 0 0 0 1.5 15.0 1.4 1.5 0.055000 1 200. 100. 0 0. 2. 0 0 + uv 244 0 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 244 3 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 244 4 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 244 206 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 244 207 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 244 209 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 244 223 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 245 0 -1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.005000 0 200. 100. 0 0. 0. 0 0 + uv 245 257 1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.005000 0 200. 100. 0 0. 0. 0 0 + uv 245 259 1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.005000 0 200. 100. 0 0. 0. 0 0 + uv 246 0 -1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.005000 0 200. 100. 0 0. 0. 0 0 + uv 246 257 1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.005000 0 200. 100. 0 0. 0. 0 0 + uv 246 259 1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.005000 0 200. 100. 0 0. 0. 0 0 + uv 247 0 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 247 257 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 247 259 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.005000 0 0. 0. 0 0. 0. 0 0 + uv 248 0 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 248 224 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 249 0 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050500 0 0. 0. 0 0. 0. 0 0 + uv 250 0 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050500 0 0. 0. 0 0. 0. 0 0 + uv 250 171 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 250 172 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 250 173 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 250 174 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 251 0 -1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.050500 0 0. 0. 0 0. 0. 0 0 + uv 251 257 -1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.050500 0 0. 0. 0 0. 0. 0 0 + uv 251 259 -1 1.5 0 0 0 1.3 20.0 1.4 1.3 0.050050 0 0. 0. 0 0. 0. 0 0 + uv 252 0 -1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050050 0 0. 0. 0 0. 0. 0 0 + uv 252 171 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050050 1 200. 100. 0 0. 2. 0 0 + uv 252 172 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050050 1 200. 100. 0 0. 2. 0 0 + uv 252 173 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050050 1 200. 100. 0 0. 2. 0 0 + uv 252 174 1 1.5 0 0 0 2.5 20.0 1.4 2.5 0.050050 1 200. 100. 0 0. 2. 0 0 + uv 253 0 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 0 200. 100. 0 0. 2. 0 0 + uv 253 54 1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 253 55 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 253 56 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 253 57 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 253 70 1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 254 0 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 0 0. 0. 0 0. 0. 0 0 + uv 254 54 1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 254 55 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 0 0. 0. 0 0. 2. 0 0 + uv 254 56 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 0 200. 100. 0 0. 2. 0 0 + uv 254 57 -1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 254 70 1 1.5 0 0 0 1.5 20.0 1.4 1.5 0.050500 1 200. 100. 0 0. 2. 0 0 + uv 256 0 -1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 257 0 -1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 257 783 1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 257 784 1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 258 0 -1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 258 783 1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 258 784 1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 259 0 -1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 259 783 1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 259 784 1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.005500 0 0. 0. 0 0. 0. 0 0 + uv 260 0 -1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 260 224 -1 1.5 0 0 0 2.5 20.1 1.4 2.5 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 261 0 -1 1.5 0 0 0 7.0 5.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + uv 280 0 1 1.5 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 281 0 1 0.25 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 282 0 1 1.5 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 284 0 1 1.5 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 285 0 -1 1.5 0 0 0 5.0 5.0 1.0 5.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 286 0 -1 1.5 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 287 0 1 0.25 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 288 0 1 0.25 0 0 0 6.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 289 0 1 1.5 0 0 0 5.0 5.0 1.0 5.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 290 4 1 1.5 0 0 0 5.0 5.0 1.0 5.0 0.000500 1 100. 1200. 0 0. 0. 0 0 + uv 290 3 -1 1.5 0 0 0 5.0 5.0 1.0 5.0 0.000500 1 100. 1200. 0 0. 0. 0 0 + uv 290 5 -1 1.5 0 0 0 5.0 5.0 1.0 5.0 0.000500 1 100. 1200. 0 0. 0. 0 0 + uv 292 0 1 0.25 0 0 0 5.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 293 0 1 0.25 0 0 0 5.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 294 0 1 1.5 0 0 0 5.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + uv 295 0 1 0.25 0 0 0 5.0 5.0 1.0 6.0 0.000500 0 0. 0. 0 0. 0. 0 0 + spd 283 0 -1 1.5 0 0 0 5.0 5.0 1.0 5.0 0.000000 0 0. 0. 0 0. 0. 0 0 + spd 260 0 -1 1.5 0 0 0 7.0 5.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + dw 999 0 -1 1.5 0 0 0 7.0 10.0 2.0 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + srw 999 0 -1 1.5 0 0 0 7.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + rw 999 0 1 0.5 0 0 0 5.0 10.0 2.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 004 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 041 0 -1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 722 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 723 0 -1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 740 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 741 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 742 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 743 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 744 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 745 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 820 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 042 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 043 0 -1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + gps 786 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gps 421 0 -1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + gps 003 0 1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + gps 821 0 -1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + gps 440 0 -1 1.5 0 0 0 10.0 10.0 1.0 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + pm2_5 102 0 -1 1.0 0 0 0 100.0 1.5 0.75 10.0 0.000000 0 0. 0. 0 0. 0. 0 0 + mta_cld 181 0 1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + mta_cld 183 0 1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + mta_cld 187 0 1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + gos_ctp 151 0 1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + rad_ref 999 0 -1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + larccld 999 0 1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 + lghtn 999 0 1 1.5 0 0 0 7.0 5.6 1.3 10.0 0.000 0 0. 0. 0 0. 0. 0 0 diff --git a/src/Conventional_Monitor/nwprod/nam_conmon/jobs/JNAM_CONMON b/src/Conventional_Monitor/nwprod/nam_conmon/jobs/JNAM_CONMON new file mode 100755 index 00000000..9e5124ea --- /dev/null +++ b/src/Conventional_Monitor/nwprod/nam_conmon/jobs/JNAM_CONMON @@ -0,0 +1,111 @@ +#!/bin/bash + +######################################################### +# Set up environment for GDAS Conventional Monitor job +######################################################### +echo "--> JNAM_CONMON" + +set -xa + +echo `date` $0 `date -u` begin +export PS4='$SECONDS + ' + +########################################################### +# set up temp working directory space +########################################################### +export CONMON_WORK_DIR=${CONMON_WORK_DIR:-/tmpnwprd} + + +##################### +# Specify NET value +##################### +export NET=${NET:-nam} +version=${version:-v4.2} + +export CONMON_AREA=rgn + +export VERBOSE=${VERBOSE:-YES} +export CLEAN_TANKDIR=${CLEAN_TANKDIR:-YES} + + +################################################################### +# C_COMIN - WHERE NAM DATA (input data to this job) RESIDES +# TANKDIR_conmon - WHERE OUTPUT DATA WILL RESIDE +################################################################### +export CONMON_SUFFIX=${CONMON_SUFFIX:-${NET}} +export C_TANKDIR=${C_TANKDIR:-/com/verf/prod/${NET}} +export TANKDIR_conmon=${C_TANKDIR}/conmon.${PDY} + +export COM_IN=${COM_IN:-${COMROOT}/${NET}/${version}} +export C_COMIN=${C_COMIN:-$COM_IN/${CONMON_SUFFIX}.${PDY}} + +case $CYC in + 00) export rgnHH=t00z + export rgnTM=tm00;; + 01) export rgnHH=t06z + export rgnTM=tm05;; + 02) export rgnHH=t06z + export rgnTM=tm04;; + 03) export rgnHH=t06z + export rgnTM=tm03;; + 04) export rgnHH=t06z + export rgnTM=tm02;; + 05) export rgnHH=t06z + export rgnTM=tm01;; + 06) export rgnHH=t06z + export rgnTM=tm00;; + 07) export rgnHH=t12z + export rgnTM=tm05;; + 08) export rgnHH=t12z + export rgnTM=tm04;; + 09) export rgnHH=t12z + export rgnTM=tm03;; + 10) export rgnHH=t12z + export rgnTM=tm02;; + 11) export rgnHH=t12z + export rgnTM=tm01;; + 12) export rgnHH=t12z + export rgnTM=tm00;; + 13) export rgnHH=t18z + export rgnTM=tm05;; + 14) export rgnHH=t18z + export rgnTM=tm04;; + 15) export rgnHH=t18z + export rgnTM=tm03;; + 16) export rgnHH=t18z + export rgnTM=tm02;; + 17) export rgnHH=t18z + export rgnTM=tm01;; + 18) export rgnHH=t18z # dayfile changes here + export rgnTM=tm00;; + 19) export rgnHH=t00z + export rgnTM=tm05;; + 20) export rgnHH=t00z + export rgnTM=tm04;; + 21) export rgnHH=t00z + export rgnTM=tm03;; + 22) export rgnHH=t00z + export rgnTM=tm02;; + 23) export rgnHH=t00z + export rgnTM=tm01;; +esac + +export cnvstat=${cnvstat:-${C_COMIN}/${CONMON_SUFFIX}.${rgnHH}.cnvstat.${rgnTM}} + + +######################################################## +# Execute the script. +# +${CONMONSH:-$HOMEnam_conmon/scripts/exnam_conmon.sh} +######################################################## + +################################ +# Remove the Working Directory +################################ +KEEPDATA=${KEEPDATA:-YES} +cd ${CONMON_WORK_DIR} +if [ ${KEEPDATA} = NO ] ; then + rm -rf ${CONMON_WORK_DIR} +fi + +echo "<-- JNAM_CONMON" diff --git a/src/Conventional_Monitor/nwprod/nam_conmon/scripts/exnam_conmon.sh b/src/Conventional_Monitor/nwprod/nam_conmon/scripts/exnam_conmon.sh new file mode 100755 index 00000000..6b533d41 --- /dev/null +++ b/src/Conventional_Monitor/nwprod/nam_conmon/scripts/exnam_conmon.sh @@ -0,0 +1,114 @@ +#/bin/bash +######################################################################## +# +# exnam_conmon.sh +# +# Run data extract/validation for regional conventional diag data +# +######################################################################## + + echo start exnam_conmon.sh + + err=0 + + #------------------------- + # confirm $cnvstat exists + if [[ ! -s ${cnvstat} ]]; then + echo "unable to locate cnvstat: ${cnvstat}" + err=1 + fi + + #----------------------- + # Locate convinfo file + export convinfo=${convinfo:-${HOMEnam_conmon}/fix/nam_regional_convinfo.txt} + if [[ ! -s ${convinfo} ]]; then + echo "unable to locate convinfo: ${convinfo}" + err=2 + fi + + + ##################################################################### + + if [[ ${err} -eq 0 ]]; then + export PDATE=${PDY}${CYC} + + if [[ ! -d ${TANKDIR_conmon} ]]; then + mkdir -p ${TANKDIR_conmon} + fi + + ############################################### + # Expand C_DATA (stmp work space) and cd to it + # + export CONMON_WORK_DIR=$CONMON_WORK_DIR/DE.${PDATE} + + #------------------------------------------------------------- + # Ensure necessary work and TANKDIR directories are in place + #------------------------------------------------------------- + if [[ ! -d ${CONMON_WORK_DIR} ]]; then + mkdir -p $CONMON_WORK_DIR + mkdir -p ${TANKDIR_conmon}/horz_hist/anl + mkdir -p ${TANKDIR_conmon}/horz_hist/ges + mkdir -p ${TANKDIR_conmon}/time_vert + fi + cd $CONMON_WORK_DIR + + #------------------------------------------------------------------ + # Copy data files file to local data directory. + # Untar cnvstat file. + #------------------------------------------------------------------ + $NCP $cnvstat ./cnvstat.$PDATE + + tar -xvf ./cnvstat.$PDATE + rm cnvstat.$PDATE + + netcdf=0 + count=`ls diag* | grep ".nc4" | wc -l` + if [ $count -gt 0 ] ; then + netcdf=1 + for filenc4 in `ls diag*nc4.gz`; do + file=`echo $filenc4 | cut -d'.' -f1-2`.gz + mv $filenc4 $file + done + fi + + echo "netcdf: $netcdf" + export CONMON_NETCDF=${netcdf} + $UNCOMPRESS ./*.${Z} + + + #--------------------------------------- + # run the time-vert extraction script + # + ${USHconmon}/time_vert.sh + rc_time_vert=$? + echo "rc_time_vert = $rc_time_vert" + + #--------------------------------------- + # run the horz-hist extraction script + # + ${USHconmon}/horz_hist.sh + rc_horz_hist=$? + echo "rc_horz_hist = $rc_horz_hist" + + #-------------------------------------- + # optionally run clean_tankdir script + # + if [[ ${CLEAN_TANKDIR} -eq 1 ]]; then + ${USHconmon}/clean_tankdir_rgn.sh + rc_clean_tankdir=$? + echo "rc_clean_tankdir = $rc_clean_tankdir" + fi + fi + + if [[ $rc_horz_hist -ne 0 ]]; then + echo "ERROR repored from horz_hist.sh: $rc_horz_hist" + err=$rc_horz_hist + elif [[ $rc_time_vert -ne 0 ]]; then + echo "ERROR repored from time_vert.sh: $rc_time_vert" + err=$rc_time_vert + fi + + echo "end exgdas_conmon.sh, exit value = ${err}" + +exit ${err} + diff --git a/src/Conventional_Monitor/parm/ConMon_config b/src/Conventional_Monitor/parm/ConMon_config index 25954a25..1ef5b686 100644 --- a/src/Conventional_Monitor/parm/ConMon_config +++ b/src/Conventional_Monitor/parm/ConMon_config @@ -15,6 +15,7 @@ MON_CONFIG=$dir_root/../../parm/Mon_config source $MON_CONFIG export MONITOR=conmon +export AREA=${AREA:-glb} export RUN=${RUN:-gdas} export WEBDIR=${WEBDIR:-/home/people/emc/www/htdocs/gmb/gdas/es_conv} @@ -22,10 +23,16 @@ export WEBDIR=${WEBDIR:-/home/people/emc/www/htdocs/gmb/gdas/es_conv} #--------------------------------------------------------------------------- # TANKDIR is the location for the extracted data files and # the control files used for image plotting. -# -export C_TANKDIR=${TANKDIR}/stats/${CONMON_SUFFIX} -export C_IMGNDIR=${TANKDIR}/imgn/${CONMON_SUFFIX}/${RUN}/conmon +if [[ $AREA == 'rgn' ]]; then + export C_TANKDIR=${TANKDIR}/stats/regional/${CONMON_SUFFIX} + export C_IMGNDIR=${TANKDIR}/imgn/regional/${CONMON_SUFFIX}/conmon + export C_LOGDIR=${MON_LOGDIR}/${CONMON_SUFFIX}/conmon +else + export C_TANKDIR=${TANKDIR}/stats/${CONMON_SUFFIX} + export C_IMGNDIR=${TANKDIR}/imgn/${CONMON_SUFFIX}/${RUN}/conmon + export C_LOGDIR=${MON_LOGDIR}/${CONMON_SUFFIX}/${RUN}/conmon +fi #----------------------------------------------------- @@ -84,7 +91,6 @@ export MY_CONMON=${MY_GSI_MONITOR}/src/Conventional_Monitor export C_STMP_USER=${C_STMP_USER:-${MON_STMP}} export C_PTMP_USER=${C_PTMP_USER:-${MON_PTMP}} -export C_LOGDIR=${MON_LOGDIR}/${CONMON_SUFFIX}/${RUN}/conmon export CONMON_IMAGE_GEN=${CONMON_IMAGE_GEN:-${MY_CONMON}/image_gen} export C_IG_GSCRIPTS=${C_IG_GSCRIPTS:-${CONMON_IMAGE_GEN}/gscripts} @@ -94,6 +100,7 @@ export C_IG_FIX=${C_IG_FIX:-${CONMON_IMAGE_GEN}/fix} export HOMEconmon_shared=${HOMEconmon_shared:-${MY_CONMON}/nwprod/conmon_shared} export HOMEgdas_conmon=${HOMEgdas_conmon:-${MY_CONMON}/nwprod/gdas_conmon} export HOMEgfs_conmon=$HOMEgdas_conmon +export HOMEnam_conmon=${HOMEnam_conmon:-${MY_CONMON}/nwprod/nam_conmon} export USHconmon=${USHconmon:-${HOMEconmon_shared}/ush} export EXECconmon=${EXECconmon:-${GSI_MON_BIN}} diff --git a/ush/rgn_find_cycle.pl b/ush/rgn_find_cycle.pl index 1c5ef6b9..b5f1284f 100755 --- a/ush/rgn_find_cycle.pl +++ b/ush/rgn_find_cycle.pl @@ -1,40 +1,43 @@ #! /usr/bin/perl -#----------------------------------------------------------------------- -# rgn_find_cycle.pl +#------------------------------------------------------------------------ +# rgn_find_latest_cycle.pl # -# Return the requested cycle time or nothing if none of the expected -# data files are found. +# Return the latest cycle time or nothing if no data files are found. # # Arguments: # --dir : Required string value containing $TANKdir/$SUFFIX. -# --cyc : Optional integer value: -# 1 = last cycle (default) -# 2 = 2nd to last cycle -# 0 = first cycle -# --run : Optional run name, generally 'gdas' or 'gfs'. -# This should be used if $TANK_USE_RUN is set to 1. +# --mon : Optional monitor name, default is conmon. # -# NOTE: This version has been modified to add case 2 returning -# the 2nd to latest cycle time. This is to counter a timing -# problem we've encountered on the crays. -#----------------------------------------------------------------------- +#------------------------------------------------------------------------ - use strict; - use warnings; - use Getopt::Long; - use Scalar::Util qw(looks_like_number); + use strict; + use warnings; + use Getopt::Long; + use Scalar::Util qw(looks_like_number); + use File::Find; - #------------------------------------------------------------------- + my $latest_date; + + #--------------------------------------- + # Define the file processing subroutine # - # Subroutine uniq - # - # Given an input array, return all unique values in an array. - # - #------------------------------------------------------------------- - sub uniq { - my %seen; - return grep { !$seen{$_}++ } @_; + sub process_file { + + my $file = $_; + + # Define the regular expression to match 10-digit date strings + my $date_regex = qr/\b(\d{10})\b/; + + # Extract date string from the file name using the regex + if ($file =~ $date_regex) { + my $date_string = $1; + + # Compare the current date string with the latest found + if (!$latest_date || $date_string > $latest_date) { + $latest_date = $date_string; + } + } } @@ -46,176 +49,35 @@ ##------------------------------------------------------------------ ##------------------------------------------------------------------ - my $run = 'gdas'; my $dir = ''; - my $lcm = 'radmon'; - my $cyc = '1'; + my $mon = 'conmon'; - GetOptions( 'cyc:i' => \$cyc, - 'run:s' => \$run, - 'dir=s' => \$dir, - 'lcm:s' => \$lcm ); + GetOptions( 'dir=s' => \$dir, + 'mon:s' => \$mon ); - my $target = $cyc; my $dirpath = $dir; - my @alldirs; + my @mondirs; - # Get list of radmon.* sub-directories - # opendir(DIR, $dirpath) or die "Cannot open directory $!"; - while (my $file = readdir(DIR)) { - next unless (-d "$dirpath/$file"); - push( @alldirs, $file ); - } - closedir DIR; + while (my $entry = readdir(DIR)) { + next if $entry =~ /^\./; # Skip '.' and '..' entries - my @raddirs = grep { /radmon/ } @alldirs; - if( $#raddirs < 0 ) { - @raddirs = grep { /gdas/ } @alldirs; - } - - # If there are no radmon.* subdirectories, then exit without - # returning any date string. - # - if( $#raddirs < 0 ) { - print "exiting with 0 raddirs\n"; - exit; + # Check if the entry is a directory and contains the target string + if (-d "$dirpath/$entry" && $entry =~ $mon) { + push @mondirs, "$dirpath/$entry"; + } } - - - # Sort the raddirs array and loop through it from end to beginning - # - if( $target == 1 || $target == 2 ){ # search is for latest date/time - - my @sortrad = sort( @raddirs ); - my $ctr = $#sortrad + 1; - - my $found_cycle = 0; - my @times; - - do { - - $ctr--; - - - # In each subdirectory build a list of time.*ieee_d* files - # and parse out all unique date values. The oldest is the answer - # we're looking for. - # - # If there are no time.*ieee_d* files, step to the next iteration. - # - my $newdir; - my @tfiles; - my @timefiles; - if( -d "${dirpath}/${sortrad[$ctr]}/radmon" ){ - $newdir = "${dirpath}/${sortrad[$ctr]}/radmon"; - opendir DIR, $newdir; - - @tfiles = grep { /time/ } readdir DIR; - @timefiles = grep { /ieee_d/ } @tfiles; - } - elsif( -d "${dirpath}/${sortrad[$ctr]}" ){ - $newdir = "${dirpath}/${sortrad[$ctr]}"; - opendir DIR, $newdir; - @tfiles = grep { /time/ } readdir DIR; - @timefiles = grep { /ieee_d/ } @tfiles; - } - if( $#timefiles >= 0 ) { - my @sorttime = sort( @timefiles ); - my $idx = 0; - - # Find the first string of 10 digits; that's the date. Use that $idx - # number to process all files. - # - my @vals = split( '\.', $timefiles[0] ); - for ( my $ii=$#vals; $ii >= 0; $ii-- ) { - if( looks_like_number( $vals[$ii] ) && length($vals[$ii] ) == 10 ){ - $idx = $ii; - } - } - - for ( my $ii=$#sorttime; $ii >= 0; $ii-- ) { - my $teststr = $sorttime[$ii]; - - my @values = split( '\.', $teststr ); - if( looks_like_number( $values[$idx] ) && length( $values[$idx] ) == 10 ) { - push( @times, $values[$idx] ); - } - } - - #------------------------------------------------------------------ - # Added a check on $ctr < $#sortrad to ensure we look - # at least 2 directories. In order to potentially rerturn the 2nd - # to the last time here on the crays. - #------------------------------------------------------------------ - if ( $#times >= 0 && $ctr <= $#sortrad ) { - $found_cycle = 1; - my @utimes = sort( uniq( @times ) ); - if ( $target == 2 ) { # 2nd to last time - print "$utimes[$#utimes -1]"; - } - else { - print "$utimes[$#utimes]"; # last time - } - } - } + closedir DIR; - } while $found_cycle == 0 && $ctr > 0; + # Traverse @mondirs and process files + foreach my $directory (@mondirs) { + find(\&process_file, $directory); } - else { # search is for earliest date/time - - my @sortrad = sort( @raddirs ); - my $ctr = -1; - - my $found_cycle = 0; - do { - - $ctr++; - - - # In each subdirectory build a list of time.*ieee_d* files - # and parse out all unique date values. The oldest is the answer - # we're looking for. - # - # If there are no time.*ieee_d* files, step to the next iteration. - # - my $newdir; - my @tfiles; - my @timefiles; - - if( -d "${dirpath}/${sortrad[$ctr]}" ){ - $newdir = "${dirpath}/${sortrad[$ctr]}"; - opendir DIR, $newdir or die "Cannot open the current directory: $!"; - @tfiles = grep { /time/ } readdir DIR; - @timefiles = grep { /ieee_d/ } @tfiles; - } - elsif( -d "${dirpath}/${sortrad[$ctr]}/radmon" ){ - $newdir = "${dirpath}/${sortrad[$ctr]}/radmon"; - opendir DIR, $newdir or die "Cannot open the current directory: $!"; - @tfiles = grep { /time/ } readdir DIR; - @timefiles = grep { /ieee_d/ } @tfiles; - } - - if( $#timefiles >= 0 ) { - my @sorttime = sort( @timefiles ); - my @times; - - for ( my $ii=0; $ii <= $#sorttime; $ii++ ) { - my $teststr = $sorttime[$ii]; - - my @values = split( '\.', $sorttime[$ii] ); - push( @times, $values[2] ); - } - - if ( $#times >= 0 ) { - $found_cycle = 1; - my @utimes = sort( uniq( @times ) ); - print "$utimes[0]"; - } - } - } while $found_cycle == 0 && $ctr < $#sortrad ; + # Print the latest date string + if ($latest_date) { + print "$latest_date"; } exit;