Commit dac10510 authored by Modellers Operational's avatar Modellers Operational

Bug fix and tidy up archive WRF code (for putting together multiple days from the WRF archive)

parent 6eb45489
[command]
default = cd ${ROSE_DATAC}; set -eu; ulimit -s unlimited; module purge; module load netcdf/intelmpi-4.4.4;
wrf_to_fvcom_ceto -i raw_wrf_*.nc -o ${GRID_NAME}_wnd.nc -latitude 55.0;
rm raw_wrf_*.nc;
...@@ -22,12 +22,12 @@ echo 5 ...@@ -22,12 +22,12 @@ echo 5
echo ${ROSE_DATAC} echo ${ROSE_DATAC}
d= d_comp=0
n=0 n=0
until [ "$d_comp" = "$END_DAY" ] until [ "$d_comp" = "$END_DAY" ]
do do
((n++)) ((n++))
d=$(date -d "$START_DAY + $n days" +${WRF_ARCHIVE_DATEFMT}) d=$(date -d "$START_DAY + $n days" +${WRF_ARCHIVE_DATEFMT})
d_comp=$(date -d "$START_DAY + $n days" +%Y-%m-%d) d_comp=$(date -d "$START_DAY + $n days" +%Y-%m-%d)
cp /pml${WRF_ARCHIVE_DIR}/*${d}*/wrfout_d03_* ${ROSE_DATAC}/raw_wrf_file_${n}.nc cp /pml${WRF_ARCHIVE_DIR}/*${d}*/wrfout_d03_* raw_wrf_file_${n}.nc
done done
#!/bin/bash
# Script to merge the individual runs into month long chunks ready for
# conversion with wrf_to_fvcom.
module purge
module load nco
set -eu
files=($(\ls raw_wrf_file*))
# Now convert to FVCOM forcing files. These files have all had their first
# time step removed as that's just the initial condition. So, you'd need to
# add a -dTime,1,, to the ncrcat command to drop the first time step if
# that's not been done. Once they're all converted, ncrcat them all
# together into a single file for this month.
n=0
for this_file in "${files[@]}"; do
((n++))
echo ${this_file}
./wrf_to_fvcom_ceto -i ${this_file} -o wnd_file_${n}.nc -latitude 55.0
ncrcat -O -h wnd_file_${n}.nc wnd_file_trim_${n}.nc
rm ${this_file}
rm wnd_file_${n}.nc
done
ncrcat -O -h $(\ls -1 wnd_file_trim*.nc | sort -u) wnd_file.nc
rm wnd_file_trim* || true
#!/bin/bash --login
# Script to merge the individual runs into month long chunks ready for
# conversion with wrf_to_fvcom.
module purge
module load nco
set -eu
# Make sure any symbolic links are resolved to absolute path.
PBS_O_WORKDIR=$(pwd)
export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)
# Change to the directory from which the job was submitted.
cd $PBS_O_WORKDIR
year=${year:-2017}
srcdir=$(readlink -f $PBS_O_WORKDIR/output/)
binary=$PBS_O_WORKDIR/bin/wrf_to_fvcom_ceto
start_hour=18 # hour at which the outputs are generated
wrfnest=${wrfnest:-d03}
for rawmonth in {1..12}; do
# Sort out our time bracket.
yearbefore=$year
yearafter=$year
before=$(printf %02d $((rawmonth - 1)))
month=$(printf %02d $rawmonth)
after=$(printf %02d $((rawmonth + 1)))
# If we're in January or December, reset the before and after month and
# year to the appropriate values.
if [ $rawmonth -eq 1 ]; then
yearbefore=$((year - 1))
before=12
elif [ $rawmonth -eq 12 ]; then
yearafter=$((year + 1))
after=01
fi
# We need all the files from the current month plus a couple of days either
# side for the FVCOM runs. We need to use an extra pattern of
# $year/wrfout_${wrfnest}_$yearbefore-$before* for the start of a given year as
# that may have actually been run as the last day of the previous year. In
# that instance, the output file will be in the $year directory but will
# actually be named $yearbefore. Limit that search to the last few days to
# not include the whole month in a non-year-boundary month (i.e. not
# January).
files=($(\ls -1 $srcdir/$yearbefore/wrfout_${wrfnest}_$yearbefore-$before-{26,27,28,29,30,31}_${start_hour}?00?00 \
$srcdir/$year/wrfout_${wrfnest}_$yearbefore-$before-{26,27,28,29,30,31}_${start_hour}?00?00 \
$srcdir/$year/wrfout_${wrfnest}_$year-$month-??_${start_hour}?00?00 \
$srcdir/$yearafter/wrfout_${wrfnest}_$year-$month-??_${start_hour}?00?00 \
$srcdir/$yearafter/wrfout_${wrfnest}_$yearafter-$after-{01,02,03}_${start_hour}?00?00 2> /dev/null | sort -u))
# Now convert to FVCOM forcing files. These files have all had their first
# time step removed as that's just the initial condition. So, you'd need to
# add a -dTime,1,, to the ncrcat command to drop the first time step if
# that's not been done. Once they're all converted, ncrcat them all
# together into a single file for this month.
parallel \(ln -s {} current_{/.}.nc \|\| true\) \&\& $binary -i current_{/.}.nc -o /var/tmp/out_{/.}.nc -latitude 50.0 -hindcast \> \/dev\/null ::: "${files[@]}"
parallel rm current_{/.}.nc ::: "${files[@]}"
parallel ncrcat -O -h /var/tmp/out_{/.}.nc /var/tmp/trim_{/.}.nc ::: "${files[@]}"
parallel rm /var/tmp/out_{/.}.nc ::: "${files[@]}"
rm $srcdir/$year/wrfout_${wrfnest}_${year}-${month}.nc || true
ncrcat -O -h $(\ls -1 /var/tmp/trim_wrfout_${wrfnest}_{${yearbefore},${year},${yearafter}}-{${before},${month},${after}}-??_*.nc | sort -u) $srcdir/$year/wrfout_${wrfnest}_${year}-${month}.nc
parallel rm /var/tmp/trim_{/.}.nc ::: "${files[@]}"
done
[command] [command]
default = bash ./get_wrf_files.sh ${START_DAY} ${END_DAY} ${WRF_ARCHIVE_DATEFMT} ${WRF_ARCHIVE_DIR} ${ROSE_DATAC} default = bash ./get_wrf_files.sh ${START_DAY} ${END_DAY} ${WRF_ARCHIVE_DATEFMT} ${WRF_ARCHIVE_DIR} ${ROSE_DATAC}; bash ./merge_files.sh;
ln -sf wnd_file.nc ${ROSE_DATAC}/${GRID_NAME}_wnd.nc
[command]
default = echo "Run WRF convert"
...@@ -14,6 +14,9 @@ FINAL_CYCLE_POINT='NONE' ...@@ -14,6 +14,9 @@ FINAL_CYCLE_POINT='NONE'
HINDCAST_DAYS=1 HINDCAST_DAYS=1
FORECAST_DAYS=2 FORECAST_DAYS=2
ARCHIVE_DIR='data/sthenno1/scratch/modop/Model/FVCOM_rosa/output'
REMOTE_ARCHIVE_DIR='/gpfs1/users/modellers/modop/Output/FVCOM_rosa_rolling'
## Grid properties and files ## Grid properties and files
GRID_NAME='aqua_v16' GRID_NAME='aqua_v16'
COMMON_FILES_PATH='/users/modellers/modop/Models/FVCOM_rosa_common/' COMMON_FILES_PATH='/users/modellers/modop/Models/FVCOM_rosa_common/'
...@@ -79,3 +82,4 @@ SALT_TEMP_OUT='T' ...@@ -79,3 +82,4 @@ SALT_TEMP_OUT='T'
TURBULENCE_OUT='T' TURBULENCE_OUT='T'
WIND_OUT='F' WIND_OUT='F'
HEAT_RAIN_OUT='F' HEAT_RAIN_OUT='F'
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
{% elif WIND_ON == 'T' or HEATING_ON == 'T' or PRECIPITATION_ON == 'T' or AIR_PRESSURE_ON == 'T' %} {% elif WIND_ON == 'T' or HEATING_ON == 'T' or PRECIPITATION_ON == 'T' or AIR_PRESSURE_ON == 'T' %}
start_cycle => get_archive_wrf_file => convert_wrf_file => write_run_namelist start_cycle => get_archive_wrf_file => write_run_namelist
{% endif %} {% endif %}
...@@ -272,8 +272,6 @@ ...@@ -272,8 +272,6 @@
execution retry delays = 3*PT15M execution retry delays = 3*PT15M
[[get_archive_wrf_file]] [[get_archive_wrf_file]]
inherit = remote_job inherit = remote_job
[[convert_wrf_file]]
inherit = slurm_job_1
[[adjust_namelist_met]] [[adjust_namelist_met]]
inherit = remote_job inherit = remote_job
script = """ script = """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment