#! /bin/csh # # Resources for SGI (e.g., dataproc): # QSUB -s /bin/csh # QSUB -lT 60:00 # time limit # QSUB -q ded_1 # ded_1 # # Job script to submit mksrc to IBM system. # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # To submit: # 1. Set env vars below (JOB,EXEC,OUTPUT,REMOTE,POSTCLEAN) # 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) # 5. Use the "submit" command to submit the job to an IBM system. # # 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. # POSTCLEAN: Set to 1 to remove execution directory after job completion, # or set to 0 to save execution directory. # setenv JOB mksrc setenv EXEC mksrc setenv REMOTE vishnu.hao:tiegcm/mksrc setenv OUTPUT $JOB.$$.out setenv POSTCLEAN 1 # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Determine operating system: # setenv HOST `uname -n` set os = `uname -s` if ($os =~ *'IRIX'*) then set os = IRIX else if ($os =~ *'AIX'*) then set os = AIX else if ($os =~ *'SunOS'*) then set os = SUN 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: # if ($os == 'AIX') then set tmpdir = /ptmp/$user/$JOB.$$ else if ($os == 'IRIX') then set tmpdir = /tmp/$user/$JOB.$$ else # sun set tmpdir = /e/$user/$JOB.$$ endif if (! -e $tmpdir) then echo "Making tmpdir $tmpdir" set err = 0 mkdir -p $tmpdir || set err = 1 if ($err == 1) then echo "Error making tmpdir $tmpdir." echo "Job $JOB NOT submitted." exit endif else echo "NOTE: tmpdir $tmpdir already exists." endif setenv EXECDIR $tmpdir # echo " " echo "OS = $os" echo "HOST = $HOST" echo "EXECDIR = $EXECDIR" # cd $EXECDIR echo "Moved to submit dir $EXECDIR" if ($OS == 'AIX') then # # Make loadleveler command file: # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cat << 'EOF_LL' >! loadlev.job # # @ job_name = mksrc # @ step_name = exec # @ class = share # @ wall_clock_limit = 00:15:00 # @ job_type = serial # @ environment = COPY_ALL # @ executable = $(step_name).csh # @ notification = error # @ queue # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Loadleveler step 2: clean up and send output (interactive) # # @ 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_LL' endif # make loadleveler script for AIX system #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cat << 'EXEC_STEP' >! exec.csh #! /bin/csh # # Shell script for loadleveler execution step: # Build and execute mksrc. # cd $EXECDIR echo " " echo "Host = $HOST" echo "OS = $OS" echo "Current working directory = $EXECDIR" echo " " # # Get source and Makefile: # INCLUDE -h /home/tgcm/mksrc/*.F /home/tgcm/mksrc/*.h INCLUDE -h /home/tgcm/mksrc/Makefile /home/tgcm/mksrc/mkdep # # Include user's input file: # set input = $JOB.inp cat << 'EOFINP' >! $input INCLUDE mksrc.inp 'EOFINP' # # Init output file: # touch $OUTPUT # # Build executable: # perl mkdep >& /dev/null set err = 0 if ($OS == 'SUN') then gnumake $EXEC >>& $OUTPUT || set err = 1 else gmake $EXEC >>& $OUTPUT || set err = 1 endif if ($err == 0) then echo "Successful gnu make." >> $OUTPUT else echo "Error from gnu make." >> $OUTPUT exit endif # # Execute: # set err = 0 $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 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cat << 'EOF_CLEANUP' >! cleanup.csh #! /bin/csh # # Shell script for loadleveler cleanup step: # Remote copy output and remove submitdir. # echo " " >> $OUTPUT echo "Execution directory submitdir = $EXECDIR" >> $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 # cd $EXECDIR set err = 0 rcp $OUTPUT $REMOTE || set err = 1 if ($err != 0) then echo " " >> $OUTPUT echo ">>> WARNING: error from rcp of output $OUTPUT to $REMOTE" >> $OUTPUT endif # # Clean submit directory: # if ($POSTCLEAN == 1) then cd rm -r $EXECDIR endif exit 'EOF_CLEANUP' chmod u+x exec.csh #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Submit the job to loadleveler, if AIX job, otherwise execute # the shell scripts: # if ($OS == 'AIX') then llsubmit loadlev.job else if ($OS == 'SUN') then echo " " echo "Executing on $OS system in directory $EXECDIR" exec.csh & else echo " " echo "Executing on $OS system in directory $EXECDIR" exec.csh cleanup.csh endif