Ignore:
Timestamp:
Feb 11, 2015, 3:08:27 PM (10 years ago)
Author:
msylvestre
Message:

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

Location:
trunk/LMDZ.GENERIC/deftank/def_generic_giants
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/deftank/def_generic_giants/long_run.sh

    r1372 r1374  
    33# In your directory, you need :
    44# - this script
    5 # - launch_128_96_64_ref : a reference script, containing the settings of a job (which .def to use, which executable, Load Leveler settings...)
    6 # - the PROTO_Saturn_Article directory (add the executable inside)
     5# - the reference script for Load Leveler, containing the settings of a job (which .def to use, which executable, Load Leveler settings...).
     6 
    77
    88#!/bin/bash
    99
    10 #MODIFY THIS : 
    11 n=11    #total number of jobs
    12 name='norings'
    13 cd /san/home/sylvestr/simus/bacasable/long_run/norings #your start directory
     10##### MODIFY THIS : 
     11n=3  #total number of jobs
     12ref='launch_128_96_64_ref' #name of the reference script
    1413
    15 # THE REFERENCE SCRIPT IS READ : launch_128_96_64_ref
     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 :
    1624
    1725#we check that the lines about the copy of the startfi.nc follows the one with
    1826#start.nc
    1927
    20 ligne=$(grep -n 'start.nc' launch_128_96_64_ref | cut -d: -f1)
    21 lignefi=$(grep -n 'startfi.nc' launch_128_96_64_ref | cut -d: -f1)
     28ligne="$(grep -n 'cp .*start.nc' ${ref} | cut -d: -f1)"
     29lignefi="$(grep -n 'cp .*startfi.nc' ${ref} | cut -d: -f1)"
    2230
    23 if [ ${lignefi} -ne $(expr ${ligne} \+ 1) ]
     31if [ ${lignefi} -ne "$(expr ${ligne} \+ 1)" ]
    2432then
    2533        echo 'Error :'
    26         echo 'In  launch_128_96_64_ref, the line about startfi.nc must follow the line about start.nc'
     34        echo 'In '${ref}' ,the line about startfi.nc must follow the line about start.nc'
    2735        exit
    2836fi
    2937
    3038#CREATION OF THE 1ST SCRIPT
    31 cp launch_128_96_64_ref launch1_128_96_64
     39cp ${ref} launch1
    3240
    3341#CREATION OF THE LAST SCRIPT
     
    3543#same as the reference script except that its start*.nc files are the restart*.nc files produced by the second to last simulation
    3644 
    37 head -n $(expr ${ligne} \- 1 ) launch1_128_96_64 > launch${n}_128_96_64
    38 echo 'cp -rf zeLAST/restart.nc $LOADL_STEP_INITDIR/${tmpdir}/start.nc' >> launch${n}_128_96_64
    39 echo 'cp -rf zeLAST/restartfi.nc $LOADL_STEP_INITDIR/${tmpdir}/startfi.nc' >> launch${n}_128_96_64
    40 tail -n +$(expr ${lignefi} \+ 1 ) launch1_128_96_64 >> launch${n}_128_96_64
     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}
    4149
    4250
    4351#1ST SCRIPT IS COMPLETED AND THE OTHERS (from 2 to n-1 ARE CREATED)
    4452
    45 # Scripts 2 to n-1 are created from the last script (to start from the restart*.nc).
    46 # Commands are added to Scripts 1 to n-1 to launch the next script.
     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.
    4755
    48 touch outputs_${name}.txt #file to save the names of the jobs composing this run
     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
    4962
    50 for ((i=1 ; i<$n; i+=1))
    51 do     
    52         if [ ${i} -ne 1 ]
    53         then 
    54                 cp launch${n}_128_96_64 launch${i}_128_96_64
    55         fi
     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}
    5669       
    57         #Save the name of the jobs
    58         echo 'echo $LOADL_STEP_INITDIR/${tmpdir} >> $LOADL_STEP_INITDIR/outputs_'${name}'.txt' >> launch${i}_128_96_64
    59         echo ' ' >> launch${i}_128_96_64
    60 
    61         #Launch the next job
    62         echo '#Lancement du job script suivant' >> launch${i}_128_96_64
    63         echo 'cd $LOADL_STEP_INITDIR' >> launch${i}_128_96_64
    64         echo 'llsubmit launch'$(expr $i \+ 1)'_128_96_64' >> launch${i}_128_96_64
    65        
     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
    6677done
    6778
    68  echo 'echo $LOADL_STEP_INITDIR/${tmpdir} >> $LOADL_STEP_INITDIR/outputs_'${name}'.txt' >> launch${n}_128_96_64
     79 
     80#LAST RUN : CREATION OF outputs.txt
     81# concatnc.e < outputs.txt will concatenate all the diagfi.nc
    6982
     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 
    7092#LAUNCH THE 1ST JOB
    71 llsubmit launch1_128_96_64
     93${sub_cmd} launch1
    7294
Note: See TracChangeset for help on using the changeset viewer.