Skip to content

Commit

Permalink
Use different exclude lists for cleanup
Browse files Browse the repository at this point in the history
Changes the exclude list into a configurable variable as a comma-
separated string. This allows for the use of different strings for
ensemble and deterministic.

Refs #583
Refs #1872
  • Loading branch information
WalterKolczynski-NOAA committed Oct 19, 2023
1 parent 69d24d6 commit 88d9b11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions parm/config/gfs/config.cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ export CLEANUP_COM="YES" # NO=retain ROTDIR. YES default in cleanup.sh
export RMOLDSTD=144
export RMOLDEND=24

# Specify the list of files to exclude from the first stage of cleanup
# Because arrays cannot be exported, list is a single string of comma-
# separated values. This string is split to form an array at runtime.
case ${RUN} in
gdas | gfs) exclude_string="*prepbufr*, *cnvstat*, *atmanl.nc" ;;
enkf*) exclude_string="*f006.ens*" ;;
*) exclude_string="" ;;
esac
export exclude_string

echo "END: config.cleanup"
12 changes: 6 additions & 6 deletions scripts/exglobal_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ function remove_files() {
echo "No directory ${directory} to remove files from, skiping"
return
fi
local exclude_string=""
local find_exclude_string=""
for exclude in "$@"; do
exclude_string+="${exclude_string} -name ${exclude} -or"
find_exclude_string+="${find_exclude_string} -name ${exclude} -or"
done
# Chop off any trailing or
exclude_string="${exclude_string[*]/%-or}"
find_exclude_string="${find_exclude_string[*]/%-or}"
# Remove all regular files that do not match
# shellcheck disable=SC2086
find "${directory}" -type f -not \( ${exclude_string} \) -delete
find "${directory}" -type f -not \( ${find_exclude_string} \) -delete
# Remove all symlinks that do not match
# shellcheck disable=SC2086
find "${directory}" -type l -not \( ${exclude_string} \) -delete
find "${directory}" -type l -not \( ${find_exclude_string} \) -delete
# Remove any empty directories
find "${directory}" -type d -empty -delete
}
Expand All @@ -61,7 +61,7 @@ for (( current_date=first_date; current_date <= last_date; \
if [[ $(tail -n 1 "${rocotolog}") =~ "This cycle is complete: Success" ]]; then
YMD="${current_PDY}" HH="${current_cyc}" generate_com COM_TOP
if [[ -d "${COM_TOP}" ]]; then
exclude_list=("*prepbufr*" "*cnvstat*" "*atmanl.nc")
IFS=", " read -r -a exclude_list <<< "${exclude_string:-}"
remove_files "${COM_TOP}" "${exclude_list[@]:-}"
fi
if [[ -d "${rtofs_dir}" ]] && (( current_date < last_rtofs )); then rm -rf "${rtofs_dir}" ; fi
Expand Down

0 comments on commit 88d9b11

Please sign in to comment.