1 | #!/bin/bash |
---|
2 | # script pour lancer un cycle antarctique |
---|
3 | |
---|
4 | # name of the run (7 char + iteration number): |
---|
5 | namerun="noresm1-m_rcp8.5_medium_ISMIP6_Ant16_relax_inv5" #"noresm1-m_rcp8.5_medium_ISMIP6_Ant16_relax_inv5" |
---|
6 | |
---|
7 | tmodelend="106." # 105. 305 |
---|
8 | tmodelbegin="20." # 20. 20 |
---|
9 | tmodellength="86." # 85 285 |
---|
10 | betacfile="beta-run-12S-inv5.grd" #"beta-run-12S-inv4.grd" #"beta-run-9-S-inv4.grd" # |
---|
11 | Umagbilfile="vitbil-run-MIP-SBT5.grd" |
---|
12 | parallel="yes" # "yes or no?" |
---|
13 | iteration="1" |
---|
14 | |
---|
15 | |
---|
16 | echo "-------------------------------------" |
---|
17 | echo " Now launching run: " $namerun |
---|
18 | echo " ------------------------- " |
---|
19 | |
---|
20 | #-------------------------------------------------- |
---|
21 | # Check if times are ok: |
---|
22 | #-------------------------------------------------- |
---|
23 | |
---|
24 | tcheck=`echo "$tmodelbegin + $tmodellength" | bc -l` |
---|
25 | tcheckbis=`echo "$tmodelend + 0" | bc -l` |
---|
26 | if [ $tcheck != $tcheckbis ]; then |
---|
27 | echo "The times provided are wrong!" |
---|
28 | echo $tcheck $tcheckbis |
---|
29 | echo "Tbegin:" $tmodelbegin ", Tend:" $tmodelend ", length:" $tmodellength |
---|
30 | exit 0 |
---|
31 | else |
---|
32 | echo "The times provided are correct." |
---|
33 | fi |
---|
34 | |
---|
35 | #-------------------------------------------------- |
---|
36 | # The different directories: |
---|
37 | #-------------------------------------------------- |
---|
38 | LAUNCHING_DIR=`pwd` |
---|
39 | GRISLI_DIR=${LAUNCHING_DIR%%/launching_area} |
---|
40 | RUNDIR=${GRISLI_DIR}"/RUNS/"${namerun} |
---|
41 | MODELMASTER=${GRISLI_DIR}"/SOURCES" |
---|
42 | MODEL=${RUNDIR}"/SOURCES" |
---|
43 | |
---|
44 | if [ -d $RUNDIR ]; then |
---|
45 | echo "This run exists, do you really want to overwrite?" |
---|
46 | echo "You have 7 sec. to do a ctr+c..." |
---|
47 | sleep 7 |
---|
48 | echo "Ok, your choice." |
---|
49 | else |
---|
50 | mkdir $RUNDIR |
---|
51 | echo " Run will be in:" |
---|
52 | echo " " $RUNDIR |
---|
53 | fi |
---|
54 | |
---|
55 | if [ -d $MODEL ]; then |
---|
56 | echo "model dir already created, cleaning up before copying files" |
---|
57 | rm -rf $MODEL"/"* |
---|
58 | else |
---|
59 | mkdir $MODEL |
---|
60 | fi |
---|
61 | |
---|
62 | cp -R $MODELMASTER"/"* $MODEL"/." |
---|
63 | svn status $MODELMASTER > $MODEL"/svn.status.txt" |
---|
64 | svn diff $MODELMASTER > $MODEL"/svn.diff.txt" |
---|
65 | |
---|
66 | if [ -d $RUNDIR"/bin" ]; then |
---|
67 | echo "exe in bin/" |
---|
68 | else |
---|
69 | mkdir $RUNDIR"/bin" |
---|
70 | fi |
---|
71 | |
---|
72 | if [ -d $RUNDIR"/RESULTATS" ]; then |
---|
73 | echo "exe in RESULTATS/" |
---|
74 | else |
---|
75 | mkdir $RUNDIR"/RESULTATS" |
---|
76 | fi |
---|
77 | |
---|
78 | if [ -d $RUNDIR"/INPUT" ]; then |
---|
79 | echo "inputs are linked to model master" |
---|
80 | else |
---|
81 | echo "inputs will be linked to model master" |
---|
82 | mkdir $RUNDIR"/INPUT" |
---|
83 | fi |
---|
84 | |
---|
85 | |
---|
86 | echo "Now copying master files to the working directory:" |
---|
87 | echo $RUNDIR |
---|
88 | echo "And to the model directory:" |
---|
89 | echo $MODEL |
---|
90 | |
---|
91 | |
---|
92 | cp "../Param/ant16km_param_list.dat" $RUNDIR"/bin/ant16km_param_list.dat" |
---|
93 | |
---|
94 | |
---|
95 | if [ $parallel = "yes" ]; then |
---|
96 | cp "Master-files/grisli.run.openmp_ant16" $RUNDIR"/bin/grisli.run" |
---|
97 | else |
---|
98 | cp "Master-files/grisli.run_ant16" $RUNDIR"/bin/grisli.run" |
---|
99 | fi |
---|
100 | |
---|
101 | cd $RUNDIR"/INPUT" |
---|
102 | ln -sf ${GRISLI_DIR}"/INPUT/ANT16km" . |
---|
103 | ln -sf ${GRISLI_DIR}"/INPUT/Forcage" . |
---|
104 | ln -sf ${GRISLI_DIR}"/INPUT/tracer.dat" . |
---|
105 | |
---|
106 | #-------------------------------------------------- |
---|
107 | # Replacing key words: |
---|
108 | #-------------------------------------------------- |
---|
109 | |
---|
110 | # run spec.: |
---|
111 | sed -i "s/RUNNAME/${namerun}1/" $RUNDIR"/bin/ant16km_param_list.dat" |
---|
112 | sed -i "s/RUNTBEGIN/$tmodelbegin/" $RUNDIR"/bin/ant16km_param_list.dat" |
---|
113 | sed -i "s/RUNTEND/$tmodelend/" $RUNDIR"/bin/ant16km_param_list.dat" |
---|
114 | |
---|
115 | # submission script: |
---|
116 | sed -i "s|SOURCESREP|$MODEL|" $RUNDIR"/bin/grisli.run" |
---|
117 | sed -i "s|EXEREP|$RUNDIR\/bin|" $RUNDIR"/bin/grisli.run" |
---|
118 | sed -i "s|_RUNNAME_|$namerun|" $RUNDIR"/bin/grisli.run" |
---|
119 | sed -i "s|_RUNTBEGIN_|$tmodelbegin|" $RUNDIR"/bin/grisli.run" |
---|
120 | sed -i "s|_RUNTEND_|$tmodelend|" $RUNDIR"/bin/grisli.run" |
---|
121 | sed -i "s|_ITERATION_|$iteration|" $RUNDIR"/bin/grisli.run" |
---|
122 | sed -i "s|USERNAME|$USER|" $RUNDIR"/bin/grisli.run" |
---|
123 | |
---|
124 | # Makefile: |
---|
125 | if [ $parallel = "yes" ]; then |
---|
126 | sed -i "s/Makefile.tof-lsce3130.inc/Makefile.tof-asterix-parallel.inc/" $RUNDIR"/SOURCES/Makefile" |
---|
127 | else |
---|
128 | sed -i "s/Makefile.tof-lsce3130.inc/Makefile.tof-asterix-sequential.inc/" $RUNDIR"/SOURCES/Makefile" |
---|
129 | fi |
---|
130 | |
---|
131 | # param values: |
---|
132 | sed -i "s/NOMBETAC/$betacfile/" $RUNDIR"/bin/ant16km_param_list.dat" |
---|
133 | sed -i "s/NOMVITBIL/$Umagbilfile/" $RUNDIR"/bin/ant16km_param_list.dat" |
---|
134 | |
---|
135 | #-------------------------------------------------- |
---|
136 | # Submitting the job: |
---|
137 | #-------------------------------------------------- |
---|
138 | cd $RUNDIR"/bin" |
---|
139 | echo "submitting the job" |
---|
140 | qsub grisli.run |
---|
141 | echo "-------------------------------------" |
---|
142 | |
---|