diff --git a/idev b/idev index e0cb25f..074b765 100755 --- a/idev +++ b/idev @@ -1,7 +1,7 @@ #!/bin/bash -#set -x -# User is forces to use either SGE or SLURM options, except -# -p and -q can both be used for either batch system +# set -x +# User is forced to use either SGE or SLURM options, except +# -p and -q can both be used for either batch system. # # For Stampede the system startup file /etc/profile.d/z95_idev. # takes care of sourcing /tmp/idev__env. if the file @@ -55,16 +55,18 @@ #Hidden grace-serial queue # Added -p option to squeue (to see queue) # Allow -n 1 for default for grace-serial queue -# Changed format from 9 to 15 chars for queue name (grace-serial is 12 chars) -# Abort if -N is used in grace-serial queue. -# 01/21/2016 KentM -# +# Changed format from 9 to 15 for queue name (grace-serial is 12 chars) +# grace-serial queue users are allowed only 1 interactive job +# 01/29/2016 KentM +# TODO +# Update version number. #------------------------------------------------------------------------------ # # Versions Number IDEV_VER=1.00 IDEV_SETUP_VER=1.00 +#NOTE: use hostname -f #Determine the system myhostname=`hostname -f` if [[ $myhostname =~ nid ]] ; then @@ -73,13 +75,14 @@ MY_SYS=`echo $myhostname | awk 'BEGIN { FS = "." } ; { print $2 }'` fi - +#800 comment her 800_Wfix srun=off # Don't use srun on Stampede # trap ctrl-c and call ctrl_c() trap ctrl_c INT EXIT did_exit=no exit_msg="" +#800 comment for 900_Wfix # Trap Function. Deletes job on exit of this script function ctrl_c() { #Job submitted, and job id available. @@ -696,7 +699,7 @@ fi fi if [[ $known_option == "no" ]]; then - echo -e "\n ERROR: **The $1 option is not know." + echo -e "\n ERROR: **The $1 option is not known." echo -e " To see options, execute: idev -help." do_exit=yes; OPT_ERR=2 @@ -749,6 +752,35 @@ if [[ $total_tasks_set == no && $nodes_set == yes ]] ; then fi +# if grace-serial queue +if [[ $MY_QUEUE =~ grace-serial ]]; then + + squeue -p $MY_QUEUE "$squeue_opts" -u $USER | \ + awk '$3 ~ /idv[0-9][0-9][0-9][0-9][0-9]/' | \ + awk '{print $5}' | grep R >/dev/null + if [ $? = 0 ]; then + using_node=`squeue -p $MY_QUEUE "$squeue_opts" -u $USER | \ + awk '$3 ~ /idv[0-9][0-9][0-9][0-9][0-9]/' | \ + awk '{print $8}' ` + echo "" + echo " ERROR: Only one ONE idev interactive session allowed in $MY_QUEUE queue." + echo "" + echo " You are executing idev again in the $MY_QUEUE queue." + echo " In this queue only 1 idev interactive job is allowed." + echo " You may have multiple windows open to the job (node) for an active" + echo " IDEV session by opening a new window on a login node, and SSHing" + echo " to the node of the job with the command:" + echo "" + echo " ssh -Y $using_node " + echo "" + echo " In a new window you can customize your environment if" + echo " you want to work interactively on different projects." + echo "" + do_exit=yes; OPT_ERR=2 + fi +fi + + ############################################end Dependent options @@ -1395,6 +1427,7 @@ $MY_RESERVATION $idev_pwd_cmd $idev_rm_perl5 +# Remove old files (needed for grace-serial queue). rm -rf /tmp/idev_${USER}_${idev_login_shell}_env.[0-9]* $DIR/idev_utils env_replication ${idev_login_shell} \$SLURM_JOB_ID $CREATE_NODE_LIST_CMD @@ -1495,7 +1528,7 @@ fi ##### while [ $found_env_file == 1 ]; do - ssh -o "StrictHostKeyChecking no" $node "ls /tmp/idev_${idev_login_shell}_env.${JOBID}" >& /dev/null + ssh -o "StrictHostKeyChecking no" $node "ls /tmp/idev_${USER}_${idev_login_shell}_env.${JOBID}" >& /dev/null if [[ $? == 0 ]]; then found_env_file=0 if [[ $time_waited_env_file > 0 ]]; then @@ -1534,7 +1567,8 @@ fi fi fi +#http://github.com/milfeld2/idivx #trapping #http://rimuhosting.com/knowledgebase/linux/misc/trapping-ctrl-c-in-bash #http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files - +#http://github.com/milfeld/idivx diff --git a/idev_utils b/idev_utils index f723dd3..d557e66 100755 --- a/idev_utils +++ b/idev_utils @@ -157,7 +157,8 @@ sub env_replication(@){ ## Changed for 9.2 my_... --> idev_... ## $myenv_filename = "/tmp/idev_${my_shell}_env.${my_idev}"; - $myenv_filename = "/tmp/idev_${USER}_${my_shell}_env.${my_idev}"; +## $myenv_filename = "/tmp/idev_${USER}_${my_shell}_env.${my_idev}"; + $myenv_filename = "/tmp/idev_$ENV{USER}_${my_shell}_env.${my_idev}"; if ( $my_shell eq "bash" ){ $CMD = "export "; $UNCMD = "unset ";