Skip to content

Commit ef6fa92

Browse files
Increasing CaSR efficiency
1 parent 4de3255 commit ef6fa92

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

etc/clusters/ucalgary-arc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"scheduler": "slurm",
33
"specs": {
4-
"cpus": 1,
4+
"cpus": 4,
55
"time": "04:00:00",
66
"nodes": 1,
7-
"partition": "cpu2023",
7+
"partition": "",
88
"account": "",
99
"mem": "8000M"
1010
},

extract-dataset.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,15 @@ case "${dataset,,}" in
728728
"era_5" | "era5" | "era-5" | "era 5")
729729
call_processing_func "$recipePath/ecmwf-era5/era5_simplified.sh" "2years"
730730
;;
731-
731+
732732
# ECCC RDRS
733733
"rdrs" | "rdrsv2.1")
734734
call_processing_func "$recipePath/eccc-rdrs/rdrs.sh" "6months"
735735
;;
736-
736+
737737
# ECCC RDRS
738738
"casr" | "casrv3.1")
739-
call_processing_func "$recipePath/eccc-casr/casr.sh" "6months"
739+
call_processing_func "$recipePath/eccc-casr/casr.sh" "3months"
740740
;;
741741

742742
# ====================

var/repos/builtin/recipes/eccc-casr/casr.sh

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -343,24 +343,39 @@ while [[ "$toDateUnix" -le "$endDateIterUnix" ]]; do
343343
fileEndDateUnix="$(unix_epoch "$fileEndDate")"
344344
fi
345345

346-
# Why the date is generated her?
347346
# If fileEndDate goes beyond fileStartDate; continue
348347
if [[ "$fileEndDateUnix" -lt "$fileStartDateUnix" ]]; then
349348
break 1
350349
fi
351350

352-
# Extracting spatial extents and variables
353-
until cdo -z zip \
354-
-s -L \
355-
-sellonlatbox,"$lonLims","$latLims" \
356-
-selvar,"$variables" \
357-
-seldate,"${fileStartDate}","${fileEndDate}" \
358-
"${datasetDir}/${file}" \
359-
"${cache}/${file}"; do
360-
echo "$(logDate)$(basename $0): Process killed: restarting process in 10 sec" >&2
361-
echo "CDO [...] failed" >&2
362-
sleep 10;
363-
done # until ncks
351+
# If the filestartDate equals startDate, or if fileEndDate equals
352+
# endDate then subset time as well, otherwise, no need for time
353+
# subsetting (to save computational time)
354+
if [[ ${fileStartDateUnix} == ${startDateUnix} ]] ||
355+
[[ ${fileEndDateUnix} == ${endDateUnix} ]]; then
356+
until cdo -z zip \
357+
-s -L \
358+
-sellonlatbox,"$lonLims","$latLims" \
359+
-selvar,"$variables" \
360+
-seldate,"${fileStartDate}","${fileEndDate}" \
361+
"${datasetDir}/${file}" \
362+
"${cache}/${file}"; do
363+
echo "$(logDate)$(basename $0): Process killed: restarting process in 10 sec" >&2
364+
echo "CDO [...] failed" >&2
365+
sleep 10;
366+
done # until ncks
367+
else
368+
until cdo -z zip \
369+
-s -L \
370+
-sellonlatbox,"$lonLims","$latLims" \
371+
-selvar,"$variables" \
372+
"${datasetDir}/${file}" \
373+
"${cache}/${file}"; do
374+
echo "$(logDate)$(basename $0): Process killed: restarting process in 10 sec" >&2
375+
echo "CDO [...] failed" >&2
376+
sleep 10;
377+
done # until ncks
378+
fi
364379

365380
# Remove any left-over .tmp file
366381
if [[ -e ${cache}/${file}*.tmp ]]; then
@@ -372,15 +387,23 @@ while [[ "$toDateUnix" -le "$endDateIterUnix" ]]; do
372387

373388
# Change lon values so the extents are from ~-180 to 0
374389
# assuring the process finished using an `until` loop
375-
until ncap2 -O -s 'where(lon>0) lon=lon-360' \
390+
until ncap2 -A -s 'where(lon>0) lon=lon-360' \
376391
"${cache}/${file}" \
377-
"${outputDir}/${prefix}${file}"; do
392+
"${cache}/${prefix}${file}"; do
378393
rm "${outputDir}/${prefix}${file}"
379394
echo "$(logDate)$(basename $0): Process killed: restarting process in 10 sec" >&2
380395
echo "$(logDate)$(basename $0): NCAP2 -s [...] failed" >&2
381396
sleep 10;
382397
done
383398

399+
# Check to see if the final file exists in the $outputDir
400+
if [[ -f "${outputDir}/${prefix}${file}" ]]; then
401+
ncrcat -O "${cache}/${prefix}${file}" "${outputDir}/${prefix}${file}" \
402+
"${outputDir}/${prefix}${file}";
403+
else
404+
cp "${cache}/${prefix}${file}" "${outputDir}/${prefix}${file}"
405+
fi
406+
384407
# Remove any left-over .tmp file
385408
if [[ -e ${cache}/${file}*.tmp ]]; then
386409
rm -r "${cache}/${file}*.tmp"

0 commit comments

Comments
 (0)