#! /bin/csh # # Job script to submit mksrc to IBM system. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # To submit: # 1. Set env vars below (JOB,OUTPUT,REMOTE) # 2. Include namelist input file (see "$input" below) # 3. Set class (queue) for loadleveler (see "class" below) # 4. Use the "submit" command to submit the job to an IBM system. # # JOB : Arbitrary job name # OUTPUT: File name of stdout output file. # REMOTE: Machine:path 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 OUTPUT $JOB.$$.out setenv REMOTE vishnu.hao:ntwk setenv POSTCLEAN 0 # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # 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" 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." exit endif else echo "NOTE: tmpdir $tmpdir already exists." endif setenv SUBMITDIR $tmpdir # echo " " echo "OS = $os" echo "HOST = $HOST" echo "SUBMITDIR = $SUBMITDIR" # cd $SUBMITDIR echo "Moved to submit dir $SUBMITDIR" # # Make loadleveler command file: # cat << 'EOF_LL0' >! loadlev.job # # @ job_name = mksrc # @ step_name = exec # @ class = share # @ wall_clock_limit = 00:15:00 # @ job_type = serial # @ environment = COPY_ALL ## @ output = $(job_name).out ## @ error = $(job_name).out 'EOF_LL0' # echo "# @ output = $OUTPUT" >> loadlev.job echo "# @ error = $OUTPUT" >> loadlev.job # cat << 'EOF_LL1' >> loadlev.job # @ executable = $(job_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 # @ output = $(job_name).cleanup.out # @ error = $(job_name).cleanup.out # @ executable = $(step_name).csh # @ notification = complete # @ requirements = (Machine == "$(hostname)") # @ dependency = (exec == 0) || (exec != 0) # @ queue # 'EOF_LL1' # - - - - - - - - - - - - - - - - - - - - - - - - - - - - cat << 'EXEC_STEP' >! $JOB.csh #! /bin/csh # cd $SUBMITDIR echo " " echo "Host = $HOST" echo "OS = $OS" echo "Current working directory = $SUBMITDIR" 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' # # Build executable: # perl mkdep set err = 0 if ($OS == 'SUN') then gnumake $JOB || set err = 1 else gmake $JOB || set err = 1 endif if ($err == 0) then echo "Successful gnu make." else echo "Error from gnu make." exit endif # # Execute: # set err = 0 $JOB < $JOB.inp || set err = 1 if ($err == 0) then echo "Successful execution of $JOB." else echo "Error executing $JOB. endif 'EXEC_STEP' # - - - - - - - - - - - - - - - - - - - - - - - - - - - - cat << 'EOF_CLEANUP' >! cleanup.csh #! /bin/csh # # rcp output: # cd $SUBMITDIR set err = 0 rcp $OUTPUT $REMOTE || set err = 1 if ($err == 0) then echo "Successful rcp of output $OUTPUT to $REMOTE" else echo ">>> WARNING: error from rcp of output $OUTPUT to $REMOTE" endif # # Clean submit directory: # if ($POSTCLEAN == 1) then cd echo "Removing SUBMITDIR directory $SUBMITDIR..." rm -r $SUBMITDIR else echo "Saving SUBMITDIR directory $SUBMITDIR" endif echo "Cleanup step completed." exit 'EOF_CLEANUP' # # Submit the job to loadleveler: # llsubmit loadlev.job