Skip to content

Commit

Permalink
Add proper spacing in comments and loops
Browse files Browse the repository at this point in the history
  • Loading branch information
EricSinsky-NOAA committed Jul 20, 2024
1 parent 97c2f8f commit 5aa68a7
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
8 changes: 4 additions & 4 deletions jobs/JGLOBAL_EXTRACTVARS
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ YMD="${PDY}" HH="${cyc}" declare_from_tmpl -rx \
"COMIN_ICE_NETCDF:COM_ICE_NETCDF_TMPL" \
"COMIN_WAVE_GRID:COM_WAVE_GRID_TMPL"

if [[ "${DO_ATM}" == "YES" ]];then
if [[ "${DO_ATM}" == "YES" ]]; then
if [[ ! -d "${ARC_RFCST_PROD_ATMOS_F2D}" ]]; then mkdir -p "${ARC_RFCST_PROD_ATMOS_F2D}"; fi
if [[ ! -d "${ARC_RFCST_PROD_ATMOS_F3D}" ]]; then mkdir -p "${ARC_RFCST_PROD_ATMOS_F3D}"; fi
fi
if [[ "${DO_OCN}" == "YES" ]];then
if [[ "${DO_OCN}" == "YES" ]]; then
if [[ ! -d "${ARC_RFCST_PROD_OCN}" ]]; then mkdir -p "${ARC_RFCST_PROD_OCN}"; fi
fi
if [[ "${DO_ICE}" == "YES" ]];then
if [[ "${DO_ICE}" == "YES" ]]; then
if [[ ! -d "${ARC_RFCST_PROD_ICE}" ]]; then mkdir -p "${ARC_RFCST_PROD_ICE}"; fi
fi
if [[ "${DO_WAVE}" == "YES" ]];then
if [[ "${DO_WAVE}" == "YES" ]]; then
if [[ ! -d "${ARC_RFCST_PROD_WAV}" ]]; then mkdir -p "${ARC_RFCST_PROD_WAV}"; fi
fi

Expand Down
30 changes: 15 additions & 15 deletions parm/config/gefs/config.extractvars
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ echo "BEGIN: config.extractvars"

export COMPRSCMD=${COMPRSCMD:-bzip2}

export compress_ocn=0 #1: compress extracted ocean product, 0: do not compress extracted ocean product
export compress_ice=0 #1: compress extracted ice product, 0: do not compress extracted ice product
export compress_ocn=0 #1: Compress extracted ocean product, 0: Do not compress extracted ocean product
export compress_ice=0 #1: Compress extracted ice product, 0: Do not compress extracted ice product

export ocnres="5p00" #Resolution of ocean products
export iceres="5p00" #Resolution of ice products
export wavres="5p00" #Resolution of wave products
export ocnres="5p00" # Resolution of ocean products
export iceres="5p00" # Resolution of ice products
export wavres="5p00" # Resolution of wave products

export depthvar_name="z_l" #name of depth variable in NetCDF ocean products
export zmin="0." #Minimum depth to extract from NetCDF ocean products
export zmax="300." #Maximum depth to extract from NetCDF ocean products
export depthvar_name="z_l" # Name of depth variable in NetCDF ocean products
export zmin="0." # Minimum depth to extract from NetCDF ocean products
export zmax="300." # Maximum depth to extract from NetCDF ocean products

export FHOUT_WAV_EXTRACT=6 #Frequency of wave output to be saved on disk
export FHOUT_WAV_EXTRACT=6 # Frequency of wave output to be saved on disk

#Paramater Tables used
export varlist_2d="${PARMgfs}/product/gefs_shortparmlist_2d.parm" #Parameter table for surface variables
export varlist_3d="${PARMgfs}/product/gefs_shortparmlist_3d_h.parm" #Parameter table for upper air instantaneous variables
export varlist_3d_d="${PARMgfs}/product/gefs_shortparmlist_3d_d.parm" #Parameter table for upper air daily-averaged variables
export varlist_wav="${PARMgfs}/product/gefs_wav_shortparmlist.parm" #Parameter table for wave variables
export varlist_ocn_netcdf="${PARMgfs}/product/gefs_ocn_shortparmlist.parm" #Parameter table for ocean netcdf variables
export varlist_ice_netcdf="${PARMgfs}/product/gefs_ice_shortparmlist.parm" #Parameter table for ice netcdf variables
export varlist_2d="${PARMgfs}/product/gefs_shortparmlist_2d.parm" # Parameter table for surface variables
export varlist_3d="${PARMgfs}/product/gefs_shortparmlist_3d_h.parm" # Parameter table for upper air instantaneous variables
export varlist_3d_d="${PARMgfs}/product/gefs_shortparmlist_3d_d.parm" # Parameter table for upper air daily-averaged variables
export varlist_wav="${PARMgfs}/product/gefs_wav_shortparmlist.parm" # Parameter table for wave variables
export varlist_ocn_netcdf="${PARMgfs}/product/gefs_ocn_shortparmlist.parm" # Parameter table for ocean netcdf variables
export varlist_ice_netcdf="${PARMgfs}/product/gefs_ice_shortparmlist.parm" # Parameter table for ice netcdf variables

#Directory to save extracted variables
export ARC_RFCST_PROD="${ARCDIR}/rfcst/${PDY:0:4}/${PDY:0:6}/${PDY:0:8}/mem${ENSMEM}"
Expand Down
8 changes: 4 additions & 4 deletions scripts/exglobal_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ if (( FHOUT_WAV_EXTRACT % FHOUT_WAV != 0 )); then
fi

# Extract variables for atmosphere
if [[ "${DO_ATM}" == "YES" ]];then
if [[ "${DO_ATM}" == "YES" ]]; then
${EXTRCTVARA} "${DATA}/atmos"
fi

# Extract variables for ocean
if [[ "${DO_OCN}" == "YES" ]];then
if [[ "${DO_OCN}" == "YES" ]]; then
export component_name="ocn"
${EXTRCTVARO} "${DATA}/ocn" "${varlist_ocn_netcdf}" "${ocnres}" "${compress_ocn}" "${FHOUT_OCN_GFS}" "${ARC_RFCST_PROD_OCN}"
fi

# Extract variables for ice
if [[ "${DO_ICE}" == "YES" ]];then
if [[ "${DO_ICE}" == "YES" ]]; then
export component_name="ice"
${EXTRCTVARO} "${DATA}/ice" "${varlist_ice_netcdf}" "${iceres}" "${compress_ice}" "${FHOUT_ICE_GFS}" "${ARC_RFCST_PROD_ICE}"
fi

# Extract variables for wave
if [[ "${DO_WAVE}" == "YES" ]];then
if [[ "${DO_WAVE}" == "YES" ]]; then
export component_name="wav"
${EXTRCTVARW} "${DATA}/wav"
fi
Expand Down
10 changes: 5 additions & 5 deletions ush/atmos_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ for outtype in "f2d" "f3d"; do
check_atmos "${infile1}" "${infile2}" "${varlist}" "${fnh}"
copy_to_comout "${outfile}" "${ARC_RFCST_PROD_ATMOS}"

#Compute daily average for a subset of variables
# Compute daily average for a subset of variables
if (( nh % 6 == 0 )) && (( nh != 0 )) && [[ "${outtype}" == "f3d" ]]; then
outfile=${subdata}/vartmp_raw_vari_ldy${dcnt}.grib2
for infile in "${infile1}" "${infile2}"; do
Expand All @@ -87,12 +87,12 @@ for outtype in "f2d" "f3d"; do
dcnt=$(( dcnt + 1 ))
else
fcnt=$(( fcnt + 1 ))
fi #If at final lead hour of a given day
fi #if lead hour is divisible by 6 and outtype is f3d
fi # If at final lead hour of a given day
fi # if lead hour is divisible by 6 and outtype is f3d

nh=$(( nh + outfreq ))
done #fhr
done # nh

done #f2d,f3d
done # f2d,f3d

exit 0
8 changes: 4 additions & 4 deletions ush/extractvars_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ daily_avg_atmos() {
${WGRIB2} "${davgtmp}" | ${WGRIB2} -i "${davgtmp}" -append -grib "${davg_file}"
rm -f "${davgtmp}"
vcnt=$(( vcnt + 1 ))
done <"${varlist_d}" #variable
done <"${varlist_d}" # variable
}

copy_to_comout() {
# Function to copy the output file with the extracted product variables to a user-defined destination directory
rundir_outfile=$1 #output data file generated in RUNDIR
comout_dir=$2 #destination directory to which to copy the data file
if [[ -f "${rundir_outfile}" ]];then
rundir_outfile=$1 # output data file generated in RUNDIR
comout_dir=$2 # destination directory to which to copy the data file
if [[ -f "${rundir_outfile}" ]]; then
cpfs "${rundir_outfile}" "${comout_dir}"
else
echo "FATAL ERROR: Output file (${rundir_outfile}) does not exist."
Expand Down
12 changes: 6 additions & 6 deletions ush/ocnice_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ comout_rfcst_prod_ocnice=${6}
for (( nh = FHMIN_GFS; nh <= FHMAX_GFS; nh = nh + fhout_ocnice )); do
fnh=$(printf "%3.3d" "${nh}")

if [[ ${component_name} == "ocn" ]];then
if [[ ${component_name} == "ocn" ]]; then
infile=${COMIN_OCEAN_NETCDF}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}.nc
# For ocean products, add an argument to extract a subset of levels
otherargs=(-d "${depthvar_name},""${zmin},""${zmax}")
elif [[ ${component_name} == "ice" ]];then
elif [[ ${component_name} == "ice" ]]; then
infile=${COMIN_ICE_NETCDF}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}.nc
otherargs=()
fi
Expand All @@ -39,20 +39,20 @@ for (( nh = FHMIN_GFS; nh <= FHMAX_GFS; nh = nh + fhout_ocnice )); do
varsinfile=$(cdo -showname "${infile}")
varsavailable=""
for i in ${varsrequested}; do
#check if variable from parm file is available in netcdf file. If variable is not in netcdf file, do not try to extract that variable.
# Check if variable from parm file is available in netcdf file. If variable is not in netcdf file, do not try to extract that variable.
if [[ ${varsinfile} == *"${i}"* ]]; then
varsavailable+="${i},"
else
echo "WARNING: ${i} is not available in ${infile}."
fi
done
if [[ -z "${varsavailable}" ]];then
if [[ -z "${varsavailable}" ]]; then
echo "WARNING: No variables from parm file ${varlist} are available in netcdf file ${infile}."
else
ocnice_vars=${varsavailable::-1}
ncks -v "${ocnice_vars}" "${otherargs[@]}" "${infile}" "${outfile}"
fi
if [[ ${datacompress} -eq 1 ]];then
if [[ ${datacompress} -eq 1 ]]; then
${COMPRSCMD} "${outfile}"
copy_to_comout "${outfile}.bz2" "${comout_rfcst_prod_ocnice}"
else
Expand All @@ -61,6 +61,6 @@ for (( nh = FHMIN_GFS; nh <= FHMAX_GFS; nh = nh + fhout_ocnice )); do
else
echo "WARNING: ${infile} does not exist."
fi
done
done # nh

exit 0
6 changes: 3 additions & 3 deletions ush/wave_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ for (( nh = FHOUT_WAV_EXTRACT; nh <= FHMAX_WAV; nh = nh + FHOUT_WAV_EXTRACT ));

infile=${COMIN_WAVE_GRID}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2
outfile=${subdata}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2
rm -f "${outfile}" #remove outfile if it already exists before extraction
rm -f "${outfile}" # Remove outfile if it already exists before extraction

if [[ -f "${infile}" ]]; then #check if input file exists before extraction
if [[ -f "${infile}" ]]; then # Check if input file exists before extraction
# shellcheck disable=SC2312
${WGRIB2} "${infile}" | grep -F -f "${varlist_wav}" | ${WGRIB2} -i "${infile}" -append -grib "${outfile}"
else
echo "WARNING: ${infile} does not exist."
fi
copy_to_comout "${outfile}" "${ARC_RFCST_PROD_WAV}"
done #fhr
done # nh

exit 0

0 comments on commit 5aa68a7

Please sign in to comment.