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

Last change on this file since 2613 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
RevLine 
[1372]1###Script to launch several successive jobs on Gnome
2
3# In your directory, you need :
4# - this script
[1374]5# - the reference script for Load Leveler, containing the settings of a job (which .def to use, which executable, Load Leveler settings...).
6 
[1372]7
8#!/bin/bash
9
[1374]10##### MODIFY THIS : 
11n=3  #total number of jobs
12ref='launch_128_96_64_ref' #name of the reference script
[1372]13
14
[1374]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
[1372]25#we check that the lines about the copy of the startfi.nc follows the one with
26#start.nc
27
[1374]28ligne="$(grep -n 'cp .*start.nc' ${ref} | cut -d: -f1)"
29lignefi="$(grep -n 'cp .*startfi.nc' ${ref} | cut -d: -f1)"
[1372]30
[1374]31if [ ${lignefi} -ne "$(expr ${ligne} \+ 1)" ]
[1372]32then
33        echo 'Error :'
[1374]34        echo 'In '${ref}' ,the line about startfi.nc must follow the line about start.nc'
[1372]35        exit
36fi
37
38#CREATION OF THE 1ST SCRIPT
[1374]39cp ${ref} launch1
[1372]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 
[1374]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}
[1372]49
50
51#1ST SCRIPT IS COMPLETED AND THE OTHERS (from 2 to n-1 ARE CREATED)
52
[1374]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.
[1372]55
[1374]56for ((i=1 ; i<=${n}; i+=1))
[1372]57do     
[1374]58        if [ ${i} -ne 1 ] && [ ${i} -ne ${n} ]
[1372]59        then 
[1374]60                cp launch${n} launch${i}
[1372]61        fi 
62
[1374]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}
[1372]69       
[1374]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
[1372]77done
78
[1374]79 
80#LAST RUN : CREATION OF outputs.txt
81# concatnc.e < outputs.txt will concatenate all the diagfi.nc
[1372]82
[1374]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 
[1372]92#LAUNCH THE 1ST JOB
[1374]93${sub_cmd} launch1
[1372]94
Note: See TracBrowser for help on using the repository browser.