source: trunk/LMDZ.GENERIC/deftank/def_generic_giants/long_run.sh @ 2468

Last change on this file since 2468 was 1374, checked in by msylvestre, 10 years ago

long_run.sh is now easier to adapt to user's local settings and to the job schedulers available on the different clusters

  • Property svn:executable set to *
File size: 3.1 KB
Line 
1###Script to launch several successive jobs on Gnome
2
3# In your directory, you need :
4# - this script
5# - the reference script for Load Leveler, containing the settings of a job (which .def to use, which executable, Load Leveler settings...).
6 
7
8#!/bin/bash
9
10##### MODIFY THIS : 
11n=3  #total number of jobs
12ref='launch_128_96_64_ref' #name of the reference script
13
14
15#Following commands are specific to Load Leveler : change them if you use another batch scheduling system
16ini_dir='$LOADL_STEP_INITDIR'           # Absolute path to the submission directory, as named in the reference script
17run_dir='$LOADL_STEP_INITDIR/${tmpdir}' #Generic absolute path to the run directory, as named in the reference script (eg. job_name.job_id etc...)
18
19sub_cmd=llsubmit                        #command to submit a job
20
21##############################################################################################################################
22
23# THE REFERENCE SCRIPT IS READ :
24
25#we check that the lines about the copy of the startfi.nc follows the one with
26#start.nc
27
28ligne="$(grep -n 'cp .*start.nc' ${ref} | cut -d: -f1)"
29lignefi="$(grep -n 'cp .*startfi.nc' ${ref} | cut -d: -f1)"
30
31if [ ${lignefi} -ne "$(expr ${ligne} \+ 1)" ]
32then
33        echo 'Error :'
34        echo 'In '${ref}' ,the line about startfi.nc must follow the line about start.nc'
35        exit
36fi
37
38#CREATION OF THE 1ST SCRIPT
39cp ${ref} launch1
40
41#CREATION OF THE LAST SCRIPT
42
43#same as the reference script except that its start*.nc files are the restart*.nc files produced by the second to last simulation
44 
45head -n $(expr ${ligne} \- 1 ) launch1 > launch${n}
46echo 'cp -rf ' ${ini_dir}'/zeLAST/restart.nc ' ${run_dir}'/start.nc' >> launch${n} 
47echo 'cp -rf ' ${ini_dir}'/zeLAST/restartfi.nc ' ${run_dir}'/startfi.nc' >> launch${n}
48tail -n +$(expr ${lignefi} \+ 1 ) launch1 >> launch${n}
49
50
51#1ST SCRIPT IS COMPLETED AND THE OTHERS (from 2 to n-1 ARE CREATED)
52
53# Scripts 2 to n-1 are created from the last script (as jobs 2 to n-1 must start from restart*.nc produced by the previous job).
54# Commands are added to Scripts 1 to n-1 to launch the next job.
55
56for ((i=1 ; i<=${n}; i+=1))
57do     
58        if [ ${i} -ne 1 ] && [ ${i} -ne ${n} ]
59        then 
60                cp launch${n} launch${i}
61        fi 
62
63        #Link toward the repertory of the last simulation
64        echo 'cd ' ${ini_dir} >> launch${i}
65        echo 'rm -f zeLAST' >> launch${i}
66        echo 'lastdir=`ls -ltrd */ | awk' "'{print" '$NF}'"'" '| tail -n 1 `' >> launch${i}     
67        echo 'ln -sf ${lastdir} zeLAST' >> launch${i}
68        echo >> launch${i}
69       
70        if [ ${i} -ne ${n} ]
71        then 
72                #Launch the next job
73                echo '#Lancement du job script suivant' >> launch${i}
74                echo 'cd' ${ini_dir} >> launch${i}
75                echo ${sub_cmd}' launch'$(expr $i \+ 1) >> launch${i}
76        fi
77done
78
79 
80#LAST RUN : CREATION OF outputs.txt
81# concatnc.e < outputs.txt will concatenate all the diagfi.nc
82
83echo 'cd '${ini_dir} >> launch${n}
84echo 'find . -maxdepth 2 -name "diagfi.nc" >> outputs.txt' >> launch${n}
85
86echo 'echo >> '${ini_dir}'/outputs.txt'  >> launch${n}
87echo 'echo 0 >> '${ini_dir}'/outputs.txt' >> launch${n}
88echo 'echo ls >> '${ini_dir}'/outputs.txt' >> launch${n}
89echo 'echo all >> '${ini_dir}'/outputs.txt'  >> launch${n}
90echo 'echo >> '${ini_dir}'/outputs.txt'  >> launch${n}
91 
92#LAUNCH THE 1ST JOB
93${sub_cmd} launch1
94
Note: See TracBrowser for help on using the repository browser.