========================================================================= File: NQS3.txt Last modified: 11/12-97 ------------------------------------------------------------------------- The following is a sample NQS script written by Jacques Richer, and translated by Mark E. Casida. It is written for a particular user (khouideb). ========================================================================= The following script may appear complicated, but it really isn't. Rather it is relatively linear. Note that the NQS options are very important as is the way of choosing the directory. The name of the queue is already included in the script (here, schubert_exec1). Consequently it suffices to type 'qsub ce_script.nqs' (provided, of course, that the script was saved under the name "ce_script.nqs" and that you run it from Schubert.) #! /bin/ksh # ################################################################### # Example of a header file for submitting tasks # ################################################################### # # All the options defined here may also be specified directly on the # command line at the time you call 'qsub'. The options given # on the command line have precidence over the options given in the # script file. # # Do 'man qsub' for an exhaustive list of options. # # The following lines show how the most used options may be implemented. # # NB : You need only add a '@' before the '$' to activate the option. # # - This option determines the time at which the task will be executed: # $-a"23:00:00" # or # $-a"tomorrow 01:00:00" # # - This option specifies the file for writing error messages (stderr) : # NB: The system default is to use a specific different file for each task. # @$-e myjob.NQS.ERR # # - This option specifies the file to use for output (stdout) : # NB: The system default is to use a specific different file for each task. # @$-o myjob.NQS.OUT # # - You will receive e-mail when your job has finished when you use this # option: # @$-me # # - This option specifies the priority of your NQS task with respect to # that of other NQS tasks. A task with a higher priority will be # executed before the other tasks (provided the others haven't yet started.) # The allowed values are between 0 and 63, with 0 the lowest and 63 the # highest. # $-p30 # # - This option defines the queue to which the task is submitted. # There are 3 ways to specify this queue: (in increasing order of # preference). # [1] by using the default, i.e. 'local' # [2] with an environment variable 'QSUB_QUEUE' # [3] with the option -q of 'qsub' # @$-q schubert_exec1 # # ********* You must have the following options: **************** # # - This option specifies that the output file should be kept on the # machine where the job was submitted. Given that your HOME is # NFS mounted, your results will be on eht machine where you made # the request. # $-ke # $-ko # # - This option specifies the export of environment variables. # @$-x # # - This option specifies the SHELL to use for executing the command. # You may change the shell according to your preference. # @$-s /bin/ksh # # - This option gives a name to the NQS request. This name will appear # when you do 'qstat -a'. It is optional. # @$-r 'Name_Given_to_the_Job_NQS' # # ----------------------------------------------------------------- # # The commands actually executed by the script may be found below. # NB: References such as /usagers/chouinar/... are INVALIDES # References such as ~/..., ${HOME}/... are valid. # echo "SHELL=${SHELL}" PATH="${PATH}:/usr/bsd/:/usr/sbin/:${HOME}/bin" # The previous line is needed because my .profile is not adjusted correctly # to access the BSD shell commands. This can be fixed. # The environment variable QSUB_WORKDIR defined by NQS contains the # name of the directory from which 'qsub' qs invoked. echo "qsub_workdir=$QSUB_WORKDIR" MAILTO=khouider@cerca.umontreal.ca MAILFROM="Mon Beau Programme" MACHINE=`hostname` echo "MACHINE=$MACHINE" if [ `hostname -s` = schubert ] then MAILER=/usr/sbin/mailx else MAILER=/usr/sbin/Mail fi GROUPDIR=/UDEM/group SCRATCHDIR=/UDEM/Scratch/tmp # Name given to the temporary directory in the directory $SCRATCHDIR/khouideb # which will be created below. UNIQID=MyJob_$$ # Name of the initial directory, where we would also like to put the outputs # when the job is done. SAVEDIR=$QSUB_WORKDIR # Name of whatever directory contains the necessary input to run the program. # Here I just assume some generic data base. DATADIR=$GROUPDIR/gbourlia/data <<<<<< I just made up a group name! # Name of another directory containing necessary input files. # This one contains parameters specific to the job. PARMDIR=$GROUPDIR/gbourlia/run # The program (binary, executable): CODE=$GROUPDIR/gbourlia/monprog_run/F/monprog_F # The name that we will give to the job. This is the job which will appear # when you run 'top'. PROGNAME=myprog_M$MASSE # Create a subdirectory for temporary work: mkdir -p $SCRATCHDIR/khouideb cd $SCRATCHDIR/khouideb WORKDIR=$SCRATCHDIR/khouideb/$UNIQID if [ ! -d "$UNIQID" ] then mkdir $UNIQID else echo "Temporary directory $WORKDIR already exists. Job aborted." exit 1 fi # Our temporary work directory cd $WORKDIR # In order to make following this job easier, it is useful to create # a pointer in the directory from which the job is launched, indicating # the name of the temporary work directory (the temporary directory will # have a complicated name, including a random number.) ln -s `pwd` $SAVEDIR/workdir.link # In the directory where the job is run, you now have a symbolic link # with the name 'workdir.link'. If you simply do 'cd wo*' you will # find yourself in this temporary directory, no matter what its real name # is. This is especially useful when you run several jobs at the same # time but from different directories. # Place in the work directory the code and different data files copied # from the various source and work directories. cp $CODE ./$PROGNAME cp $SAVEDIR/par . # Now put lots of 'zcat' in order to place the different files which will # be opened by the program (here these files are compressed; zcat # decompresses them and copies them under another name in the current # working directory.) zcat $DATADIR/autres/nivtr.elem.parm > niveaux zcat $DATADIR/autres/Li >> niveaux zcat $DATADIR/autres/energies.Z > energies zcat $DATADIR/autres/g_rad.phipsi > input_amt zcat $DATADIR/autres/fedkdx.Z > fedkdx zcat $DATADIR/autres/grille.tot.sol > grille.tot.sol . . . . . zcat $DATADIR/opacites/opacHK > opacHK zcat $DATADIR/opacites/el0001 > el0001 zcat $DATADIR/opacites/hzox > hzox # Run the program, writing the date and time at the beginning and end of the # file. Here I suppose that the program needs to read a standard # input file 'par' and writes to a standard output file ${PROGNAME}.stdout . echo "`date`, ${PROGNAME}: debut du calcul" >> dat ${PROGNAME} < par > ${PROGNAME}.stdout echo "`date`, ${PROGNAME}: fin" >> dat # Compress some of the outputs which are to be saved (not including the # standard output.) compress -f fort.* *.out # Clean up: remove the input files. rm -f niveaux rm -f energies rm -f input_amt rm -f fedkdx rm -f grille.tot.sol rm -f grille.tot.sol+0.3 rm -f grille.tot.sol+0.6 . . . . rm -f kurtab rm -f zmix rm -f atmg.87 rm -f paq rm -f engfit2 rm -f atm rm -f opacLAK rm -f opacHK rm -f el0001 rm -f hzox rm -f eospar # Remove the executable. rm -f ${PROGNAME} # Recopy all of the remaining files where you would like to save the results. cp * $SAVEDIR # Now erase. rm -f * # And eliminate the temporary directory for this job. cd $SCRATCHDIR/khouideb rmdir $UNIQID # We will keep $SCRATCHDIR/khouideb, in case other jobs are to be run. # Anyway, it doesn't take a significant amount of space. # Return to the starting directory and remove the symbolic link which # now points to nothing at all. cd $SAVEDIR rm -f workdir.link # Make a few minor ajustments if needed. chmod ug+rw * # And finally, send a pretty little message concerning the output. # The message can be different depending upon whether the job ran # correctly or not. $MAILER -s "$MAILFROM: Job finished" $MAILTO <