-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkfiles.sh
executable file
·76 lines (73 loc) · 2.08 KB
/
linkfiles.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash --
#title :linkfiles.sh
#description :linkfile
#author :CEMAC - Helen
#date :20210415
#version :1
#usage :./linkfiles.sh
#notes : link the 1st of each following month for WRF to generate 1st month restart files
#bash_version :4.2.46(2)-release
#============================================================================
# example year
year1=2021
print_usage() {
echo "
linkfiles.sh
A CEMAC script to link the 1st of each following month wrf intermediate files
for WRF to generate 1st month restart files
Usage:
.\linkfile.sh -y
Options:
-y year start
-h HELP: prints this message!
**
**
version: 0.4 (beta un-released)
------------------------------------------------
"
}
while getopts 'y:z:r:e:h' flag; do
case "${flag}" in
y) year="${OPTARG}" ;;
h) print_usage
exit 1 ;;
*) print_usage
exit 1 ;;
esac
done
cd OUTPUT
# assign the year for dec
year2=$(($year+1))
# get absolute filepath
cd $year2
filepath2=$(pwd)
# get absolute file path for wrf intermediate files
cd ../$year1
filepath=$(pwd)
# for each month link absolute file paths
cd 01
ln -sf ${filepath}/02/"Hadgemes2_r2i1p1_rcp85:"${year1}"-02-01_00" .
cd ../02
ln -sf ${filepath}/03/"Hadgemes2_r2i1p1_rcp85:"${year1}"-03-01_00" .
cd ../03
ln -sf ${filepath}/04/"Hadgemes2_r2i1p1_rcp85:"${year1}"-04-01_00" .
cd ../04
ln -sf ${filepath}/05/"Hadgemes2_r2i1p1_rcp85:"${year1}"-05-01_00" .
cd ../05
ln -sf ${filepath}/06/"Hadgemes2_r2i1p1_rcp85:"${year1}"-06-01_00" .
cd ../06
ln -sf ${filepath}/07/"Hadgemes2_r2i1p1_rcp85:"${year1}"-07-01_00" .
cd ../07
ln -sf ${filepath}/08/"Hadgemes2_r2i1p1_rcp85:"${year1}"-08-01_00" .
cd ../08
ln -sf ${filepath}/09/"Hadgemes2_r2i1p1_rcp85:"${year1}"-09-01_00" .
cd ../09
ln -sf ${filepath}/10/"Hadgemes2_r2i1p1_rcp85:"${year1}"-10-01_00" .
cd ../10
ln -sf ${filepath}/11/"Hadgemes2_r2i1p1_rcp85:"${year1}"-11-01_00" .
cd ../11
ln -sf ${filepath}/12/"Hadgemes2_r2i1p1_rcp85:"${year1}"-12-01_00" .
cd ../12
ln -sf ${filepath2}/01/"Hadgemes2_r2i1p1_rcp85:"${year2}"-01-01_00" .
cd ../../
echo "files linked"