Skip to content
Snippets Groups Projects
Commit 3ebc2b91 authored by Felix Kleinert's avatar Felix Kleinert
Browse files

cdo helper script

parent 804a0994
No related branches found
No related tags found
No related merge requests found
Pipeline #91867 failed
#!/bin/sh
# This scipt uses cdo mergetime to combine hourly files into two files per month
# example file: wrfout_d01_2009-02-03_07:00:00.nc
for i in "$@"; do
case $i in
-s=*|--startyear=*)
startyear="${i#*=}"
shift # past argument=value
;;
-e=*|--endyear=*)
endyear="${i#*=}"
shift # past argument=value
;;
-f=*|--filestarter=*)
filestarter="${i#*=}"
shift # past argument=value
;;
-p=*|--datapath=*)
datapath="${i#*=}"
shift # past argument=value
;;
-n=*|--newpath=*)
newpath="${i#*=}"
shift # past argument=value
;;
--default)
DEFAULT=YES
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
# source mergetime_cdo_files.sh -s=2009 -e=2009 -f=wrfout_d01_
# source mergetime_cdo_files.sh -s=2009 -e=2009 -f=wrfout_d01_ -p=hourly/ -n=monthly/
for year in $(seq "$startyear" "$endyear")
do
echo "$year"
for month in $(seq -w 1 12)
do
echo "##########################################"
echo "Processing: cdo mergetime ${datapath}${filestarter}${year}-${month}-[0-1][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_first_part.nc &"
# cdo mergetime ${datapath}${filestarter}${year}-${month}-[0-1][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_first_part.nc &
echo "Processing: cdo mergetime ${datapath}${filestarter}${year}-${month}-[2-3][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_second_part.nc &"
# cdo mergetime ${datapath}${filestarter}${year}-${month}-[2-3][0-9]_??:??:??.nc ${newpath}${filestarter}${year}-${month}_second_part.nc &
done
done
echo "############ YOUR OPTIONS ############"
echo "startyear: $startyear"
echo "endyear: $endyear"
echo "filestarter: $filestarter"
echo "datapath: $datapath"
echo "newpath: $newpath"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment