#! /bin/csh # # Job script to run "tgcmproc" on IBM system. # # 10/20/04 btf: adapted to handle either AIX or IRIX64. # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # To submit: # 1. Set env vars below (JOB,EXEC,OUTPUT,REMOTE,POSTCLEAN) # (REMOTE might be the only one you have to change) # 2. Include namelist input file (see "$input" below) # 3. Optionally change path to source and Makefile (see INCLUDEs below) # 4. Set class (queue) for loadleveler (see "# @ class" below) # (optionally set other loadleveler commands for IBM job) # 5. Use the "submit" command (/home/tgcm/bld/submit) to submit the job. # # JOB : Job name (will be used in tmpdir name, input file name, etc) # EXEC : Name of executable built by make (see Makefile). # OUTPUT: File name of stdout output file. # REMOTE: Machine:path directory where OUTPUT is to be sent via rcp. # (typically on the local workstation from which this script was submitted) # POSTCLEAN: Set to 1 to remove execution directory after job completion, # or set to 0 to save execution directory. # setenv JOB tgcmproc setenv EXEC tgcmproc setenv REMOTE vishnu.hao:/home/foster/ntwk setenv OUTPUT $JOB.$$.out # setenv POSTCLEAN 0 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Determine operating system (AIX is only OS for this script): # setenv HOST `uname -n` set os = `uname -s` #if ($os =~ *'AIX'*) then # set os = AIX #else # echo " " # echo ">>> Unknown OS: uname -s = $os" # echo "Job $JOB NOT submitted." # exit #endif setenv OS $os # # Set up a tmpdir and go there: # set tmpdir = /ptmp/$user/$JOB.$$ if (! -e $tmpdir) then echo "Making tmpdir $tmpdir" set err = 0 mkdir -p $tmpdir || set err = 1 if ($err == 1) then echo " " echo "WARNING Error making tmpdir $tmpdir." echo "Job $JOB NOT submitted." echo " " endif else echo "NOTE: tmpdir $tmpdir already exists." endif setenv EXECDIR $tmpdir cd $EXECDIR echo "Moved to submit dir $EXECDIR" # # Init output file: # touch $OUTPUT # echo " " echo "JOB = $JOB" echo "OS = $os" echo "HOST = $HOST" echo "EXECDIR = $EXECDIR" echo "DATE = `date`" # echo " " >> $OUTPUT echo "JOB = $JOB" >> $OUTPUT echo "OS = $os" >> $OUTPUT echo "HOST = $HOST" >> $OUTPUT echo "EXECDIR = $EXECDIR" >> $OUTPUT echo "POSTCLEAN = $POSTCLEAN" >> $OUTPUT echo "DATE = `date`" >> $OUTPUT echo " " >> $OUTPUT # # Set some env vars for AIX parallel job: # setenv MP_LABELIO YES setenv MP_PGMMODEL SPMD setenv MP_SHARED_MEMORY YES # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if ($os == 'AIX') then # # Make loadleveler command file: # cat << 'EOF_BATCH' >! batch.job # # Loadleveler job step to build and execute: # # Example: With total_tasks=32, node=8, and DYNAMO=2, a 1-day run at # STEP=180 (480 iters) takes about 9 mins wallclock, NOT including # mss access, and without secondary histories. # # # @ job_name = tgcmproc ## @ account_no = 28103032 # @ step_name = exec ## @ class = share # @ class = dv_reg # @ wall_clock_limit = 03:00:00 # @ environment = COPY_ALL # @ requirements = (Machine == "$(hostname)") # @ executable = $(step_name).csh # @ notification = error # @ queue # # Loadleveler job step for cleanup: # # @ step_name = cleanup # @ class = interactive # @ wall_clock_limit = 00:00:30 # @ job_type = serial # @ executable = $(step_name).csh # @ notification = complete # @ requirements = (Machine == "$(hostname)") # @ dependency = (exec == 0) || (exec != 0) # @ queue # 'EOF_BATCH' #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else if ($os == 'IRIX64') then # # Make NQE job: # cat << 'EOF_BATCH' >! batch.job # # QSUB -s /bin/csh # QSUB -lt 1:00:00 # per-process cpu time limit (hr:min:sec) # QSUB -q ded_1 # 1 proc for serial job # QSUB -eo # merge stdout and stderr # QSUB -J m # Appends the job log to stdout # QSUB # 'EOF_BATCH' else write(6,"('>>> Error: do not recognize os = $os)") stop 'os' endif #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Build make and exec script: # cat << 'EXEC_STEP' >! exec.csh #! /bin/csh # # Shell script for loadleveler execution step: # Build and execute tgcmproc. # cd $EXECDIR echo " " echo "Host = $HOST" echo "OS = $OS" echo "Current working directory = $EXECDIR" echo " " # # Get source and Makefile: # (INCLUDE statements are resolved by "submit" script (hao:/home/tgcm/bld/submit)) # INCLUDE -h ~/tgcmvis/tgcmproc/tgcmproc_f90/*.F INCLUDE -h ~/tgcmvis/tgcmproc/tgcmproc_f90/*.h INCLUDE -h ~/tgcmvis/tgcmproc/tgcmproc_f90/*.c INCLUDE -h ~/tgcmvis/tgcmproc/tgcmproc_f90/Makefile INCLUDE -h ~/tgcmvis/tgcmproc/tgcmproc_f90/mkdep INCLUDE -h ~/tgcmvis/tgcmproc/tgcmproc_f90/gfac_coeffs.dat # # Overlay mods (-ignore dups means these mods will override previously # INCLUDEd files with the same names): # INCLUDE -h -ignore_dups modsrc_dinos/*.F # # Include user's input file: #INCLUDE ~/tgcmvis/tgcmproc/tgcmproc1/tiegcm1.inp #INCLUDE ~/tgcmvis/tgcmproc/gang_tgcm24.inp #INCLUDE ~/tgcmvis/tgcmproc/proc.diag.zmhist.inp # set input = $JOB.inp cat << 'EOFINP' >! $input INCLUDE ~/tgcmvis/tgcmproc/dinos.glbminteg.inp 'EOFINP' # # Build executable: # perl mkdep >& /dev/null set err = 0 gmake $EXEC >>& $OUTPUT || set err = 1 if ($err == 0) then echo "Successful gnu make." >> $OUTPUT else echo "Error from gnu make." >> $OUTPUT exit $err endif # # Execute: # set err = 0 timex $EXEC < $JOB.inp >>& $OUTPUT || set err = 1 if ($err == 0) then echo "Completed execution of $EXEC." >> $OUTPUT else echo ">>> Error executing $EXEC." >> $OUTPUT endif 'EXEC_STEP' chmod u+x exec.csh #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Build cleanup script: # cat << 'EOF_CLEANUP' >! cleanup.csh #! /bin/csh # # Shell script for loadleveler cleanup step: # # Run mklogs to separate tasks stdout, and send output from task 0: # echo "cleanup: EXECDIR=$EXECDIR OUTPUT=$OUTPUT" cd $EXECDIR set err = 0 chmod u+x mklogs perl mklogs $OUTPUT || set err = 1 if ($err == 1) then echo ">>> Error from mklogs -- will return full output $OUTPUT" >> $OUTPUT else cp *task0.out $OUTPUT echo "Completed mklogs, sending output from task 0." >> $OUTPUT endif # # Remote copy output and remove submitdir. # echo " " >> $OUTPUT echo "Execution directory submitdir = $EXECDIR" >> $OUTPUT ls -l $OUTPUT >> $OUTPUT echo "Preparing to rcp output $OUTPUT from submitdir to remote $REMOTE" >> $OUTPUT if ($POSTCLEAN == 1) then echo "NOTE: submitdir and its contents will be removed after the rcp" endif # set err = 0 rcp $OUTPUT $REMOTE >>& $OUTPUT || set err = 1 #/usr/bsd/rcp $OUTPUT $REMOTE || set err = 1 if ($err != 0) then echo " " >> $OUTPUT echo ">>> WARNING: error from rcp of output $OUTPUT to $REMOTE" >> $OUTPUT echo " Will save $OUTPUT to /home/$user" cp $OUTPUT /home/$user || \ echo ">>> WARNING: error copying $OUTPUT to /home/$user" endif # # Clean submit directory: # if ($POSTCLEAN == 1) then cd rm -r $EXECDIR endif exit 'EOF_CLEANUP' chmod u+x cleanup.csh #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Submit the job: # if ($os == 'AIX') then llsubmit batch.job else if ($os == 'IRIX64') then echo "setenv EXECDIR $tmpdir" >! envvars echo "setenv HOST $HOST" >> envvars echo "setenv OS $OS" >> envvars echo "setenv JOB $JOB" >> envvars echo "setenv EXEC $EXEC" >> envvars echo "setenv REMOTE $REMOTE" >> envvars echo "setenv OUTPUT $OUTPUT" >> envvars echo "setenv POSTCLEAN $POSTCLEAN" >> envvars echo "setenv MP_LABELIO $MP_LABELIO" >> envvars echo "setenv MP_PGMMODEL $MP_PGMMODEL" >> envvars echo "setenv MP_SHARED_MEMORY $MP_SHARED_MEMORY" >> envvars cat envvars >> batch.job cat exec.csh >> batch.job qsub batch.job else echo ">>> unrecognized os = $os -- job not submitted." endif