Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bddc2c6
modified ush\wave_extractvars.sh
AntonMFernando-NOAA Feb 20, 2025
8e39933
modified ush\ocnice_extractvars.sh
AntonMFernando-NOAA Feb 20, 2025
4335d73
updated atmos and wave extractvars ush
AntonMFernando-NOAA Feb 20, 2025
d214243
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 20, 2025
fca50a1
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 21, 2025
fe38d9f
added elif-> then
AntonMFernando-NOAA Feb 24, 2025
f75e6bd
Merge branch 'bug/NCO-extractvars' of https://github.com/AntonMFernan…
AntonMFernando-NOAA Feb 24, 2025
1548657
modified ush\atmos_extractvars.sh
AntonMFernando-NOAA Feb 24, 2025
976ca51
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 25, 2025
02d9cdb
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 25, 2025
6fa38af
Merge branch 'develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 26, 2025
eb84696
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 27, 2025
ca2fb16
modified ush\atmos_extractvars.sh
AntonMFernando-NOAA Feb 27, 2025
ea6cf86
Merge branch 'bug/NCO-extractvars' of https://github.com/AntonMFernan…
AntonMFernando-NOAA Feb 27, 2025
80a5c25
typo
AntonMFernando-NOAA Feb 27, 2025
2fe63ae
modified ush\ocnice_extractvars.sh
AntonMFernando-NOAA Feb 27, 2025
27abc91
typo
AntonMFernando-NOAA Feb 27, 2025
efcbb85
modified ush\wave_extractvars.sh
AntonMFernando-NOAA Feb 27, 2025
cee64e4
removed else block
AntonMFernando-NOAA Feb 27, 2025
bb48ed9
modified files
AntonMFernando-NOAA Feb 27, 2025
20c1f8c
Merge branch 'develop' into bug/NCO-extractvars
AntonMFernando-NOAA Feb 28, 2025
0cfb50b
modified files
AntonMFernando-NOAA Feb 28, 2025
7830405
Merge branch 'bug/NCO-extractvars' of https://github.com/AntonMFernan…
AntonMFernando-NOAA Feb 28, 2025
53031aa
modifed if statements
AntonMFernando-NOAA Feb 28, 2025
5ff2309
removed extra cpfs
AntonMFernando-NOAA Feb 28, 2025
c4ce4a4
Merge branch 'develop' into bug/NCO-extractvars
AntonMFernando-NOAA Mar 3, 2025
73aa985
Apply suggestions from code review
aerorahul Mar 3, 2025
109cf03
Update ush/atmos_extractvars.sh
aerorahul Mar 3, 2025
a81f092
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Mar 3, 2025
8e17d89
added exist 1
AntonMFernando-NOAA Mar 4, 2025
74ccb11
Merge branch 'develop' into bug/NCO-extractvars
AntonMFernando-NOAA Mar 4, 2025
baad82f
Merge branch 'develop' into bug/NCO-extractvars
AntonMFernando-NOAA Mar 5, 2025
3836228
Merge branch 'NOAA-EMC:develop' into bug/NCO-extractvars
AntonMFernando-NOAA Mar 6, 2025
21bfc21
Merge branch 'develop' into bug/NCO-extractvars
AntonMFernando-NOAA Mar 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions ush/atmos_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ for outtype in "f2d" "f3d"; do

for infile in "${infile1}" "${infile2}"; do
if [[ -f "${infile}" ]]; then # check if input file exists before extraction
new_infile="${outdirpre}/$(basename "${infile}")_ext"
cpfs "${infile}" "${new_infile}"
Comment thread
AntonMFernando-NOAA marked this conversation as resolved.
Outdated
# shellcheck disable=SC2312
${WGRIB2} "${infile}" | grep -F -f "${varlist}" | ${WGRIB2} -i "${infile}" -append -grib "${outfile}"
else
echo "WARNING: ${infile} does not exist."
${WGRIB2} "${new_infile}" | grep -F -f "${varlist}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}"
elif [[ -f "${infile}" ]]; then
echo "WARNING: ${infile} does not exist in ${com_dir}."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The infile existence check has already been performed on line 74.

Suggested change
elif [[ -f "${infile}" ]]; then
echo "WARNING: ${infile} does not exist in ${com_dir}."
else
echo "WARNING: ${infile} does not exist in ${com_dir}."

elif [[ -f "${new_infile}" ]]; then
echo "WARNING: ${new_infile} does not exist in ${subdata}. Copying skipped."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new_infile is defined inside the first if block, so I do not believe this elif condition will ever be met. I think you can check for the existance of new_infile immediately after the cpfs operation.

else
echo "WARNING: ${infile} and ${new_infile} do not exist."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the existence of infile and new_infile has already been checked, this part is not needed.

Suggested change
else
echo "WARNING: ${infile} and ${new_infile} do not exist."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EricSinsky-NOAA I’ve made the suggested changes. Please disregard my previous comments. I now understand what you meant.

fi
done

Expand All @@ -87,10 +93,16 @@ for outtype in "f2d" "f3d"; do
outfile=${subdata}/vartmp_raw_vari_ldy${dcnt}.grib2
for infile in "${infile1}" "${infile2}"; do
if [[ -f "${infile}" ]]; then # check if input file exists before extraction
new_infile="${outdirpre}/$(basename "${infile}")_ext"
cpfs "${infile}" "${new_infile}"
Comment thread
AntonMFernando-NOAA marked this conversation as resolved.
Outdated
# shellcheck disable=SC2312
${WGRIB2} "${infile}" | grep -F -f "${varlist_d}" | ${WGRIB2} -i "${infile}" -append -grib "${outfile}"
${WGRIB2} "${new_infile}" | grep -F -f "${varlist_d}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}"
elif [[ -f "${infile}" ]]; then
echo "WARNING: ${infile} does not exist in ${com_dir}."
elif [[ -f "${new_infile}" ]]; then
echo "WARNING: ${new_infile} does not exist in ${subdata}. Copying skipped."
else
echo "WARNING: ${infile} does not exist."
echo "WARNING: ${infile} and ${new_infile} do not exist."
fi
Comment on lines 95 to 108

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my earlier comments. I think the same logic applies here as well.

done
if [[ ${fcnt} -eq 4 ]]; then
Expand Down
35 changes: 24 additions & 11 deletions ush/ocnice_extractvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,62 @@ for (( nh = FHMIN_GFS + fhout_ocnice; nh <= FHMAX_GFS; nh = nh + fhout_ocnice ))

if [[ ${component_name} == "ocn" ]]; then
if [[ "${datares}" == "native" ]]; then
infile="${COMIN_OCEAN_HISTORY}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc"
com_dir=${COMIN_OCEAN_HISTORY}
infile="${com_dir}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc"
new_infile=${subdata}/${RUN}.ocean.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}_ext.nc
else
infile="${COMIN_OCEAN_NETCDF}/${datares}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}.nc"
com_dir=${COMIN_OCEAN_NETCDF}
infile="${com_dir}/${datares}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}.nc"
new_infile=${subdata}/${RUN}.ocean.t${cyc}z.${datares}.f${fnh}_ext.nc
fi
# For ocean products, add an argument to extract a subset of levels
otherargs=(-d "${depthvar_name},""${zmin},""${zmax}")
elif [[ ${component_name} == "ice" ]]; then
if [[ "${datares}" == "native" ]]; then
infile="${COMIN_ICE_HISTORY}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc"
com_dir=${COMIN_ICE_HISTORY}
infile="${com_dir}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}.nc"
new_infile=${subdata}/${RUN}.ice.t${cyc}z.${fhout_ocnice}hr_avg.f${fnh}_ext.nc
else
infile="${COMIN_ICE_NETCDF}/${datares}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}.nc"
com_dir=${COMIN_ICE_NETCDF}
infile="${com_dir}/${datares}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}.nc"
new_infile=${subdata}/${RUN}.ice.t${cyc}z.${datares}.f${fnh}_ext.nc
fi
otherargs=()
fi
outfile=${subdata}/${RUN}.${component_name}.t${cyc}z.${datares}.f${fnh}.nc

if [[ -f "${infile}" ]]; then #check if input file exists before extraction
cpfs "${infile}" "${new_infile}" #copy infile to the subdata directory
Comment thread
AntonMFernando-NOAA marked this conversation as resolved.
Outdated
varsrequested=$(paste -s "${varlist}")
varsinfile=$(cdo -showname "${infile}")
varsinfile=$(cdo -showname "${new_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.
if [[ ${varsinfile} == *"${i}"* ]]; then
varsavailable+="${i},"
else
echo "WARNING: ${i} is not available in ${infile}."
echo "WARNING: ${i} is not available in ${new_infile}."
fi
done
if [[ -z "${varsavailable}" ]]; then
echo "WARNING: No variables from parm file ${varlist} are available in netcdf file ${infile}."
echo "WARNING: No variables from parm file ${varlist} are available in netcdf file ${new_infile}."
else
ocnice_vars=${varsavailable::-1}
ncks -v "${ocnice_vars}" "${otherargs[@]}" "${infile}" "${outfile}"
ncks -v "${ocnice_vars}" "${otherargs[@]}" "${new_infile}" "${outfile}"
fi
if [[ ${datacompress} -eq 1 ]]; then
${COMPRSCMD} "${outfile}"
copy_to_comout "${outfile}.bz2" "${comout_rfcst_prod_ocnice}"
else
copy_to_comout "${outfile}" "${comout_rfcst_prod_ocnice}"
fi
fi
elif [[ -f "${infile}" ]]; then
echo "WARNING: ${infile} does not exist in ${com_dir}."
elif [[ -f "${new_infile}" ]]; then
echo "WARNING: ${new_infile} does not exist in ${subdata}. Copying skipped."
else
echo "WARNING: ${infile} does not exist."
echo "WARNING: ${infile} and ${new_infile} do not exist."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my earlier comments in ush/atmos_extractvars.sh. I think the same logic applies here.

fi
done # nh

exit 0
exit 0
18 changes: 12 additions & 6 deletions ush/wave_extractvars.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env bash
#! /usr/bin/env bash

################################################################################
## UNIX Script Documentation Block
Expand All @@ -24,16 +24,22 @@ for (( nh = FHOUT_WAV_EXTRACT; nh <= FHMAX_WAV; nh = nh + FHOUT_WAV_EXTRACT ));
fnh=$(printf "%3.3d" "${nh}")

infile=${com_dir}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2
new_infile=${subdata}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}_ext.grib2
outfile=${subdata}/${RUN}wave.t${cyc}z.global.${wavres}.f${fnh}.grib2
rm -f "${outfile}" # Remove outfile if it already 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}"
cpfs "${infile}" "${new_infile}" # Copy infile to the subdata directory
Comment thread
AntonMFernando-NOAA marked this conversation as resolved.
Outdated
# shellcheck disable=SC2312
${WGRIB2} "${new_infile}" | grep -F -f "${varlist_wav}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}"
elif [[ -f "${infile}" ]]; then
echo "WARNING: ${infile} does not exist in ${com_dir}."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infile was already checked in the previous if-block (line 31). Please see my comments in ush/atmos_extractvars.sh.

elif [[ -f "${new_infile}" ]]; then
echo "WARNING: ${new_infile} does not exist in ${subdata}. Copying skipped."
else
echo "WARNING: ${infile} does not exist."
fi
echo "WARNING: ${infile} and ${new_infile} do not exist."
fi
copy_to_comout "${outfile}" "${ARC_RFCST_PROD_WAV}"
done # nh

exit 0
exit 0