#!/usr/bin/perl if (scalar(@ARGV) == 0 || $ARGV[0] eq "-h" || $ARGV[0] eq "--help") { print "\n"; print "Gaussian 16 revision A03 running on the \"Cub\" nodes.\n"; print "Details at https://mgcf.cchem.berkeley.edu\n"; print "Normal usage is: \n"; print "run_g16_cub jobname\n"; print "\n"; print "jobname is your com file name, with or without the .com extension. \n"; print "\n"; print "The number of cpus is 1 unless the com file has a line: \%nproc=value. \n"; print "Sensible values for nproc are: 1,2,3,4,6,12. \n"; print "\n"; print "Track your jobs. You will be charged for any unattended calculations. \n"; print "\n"; exit; } $rev = "g16.revA03_legacy"; $input = $ARGV[0]; $input =~ s/.com$|.gjf$//; #next line is to strip out everything before the final / #needed for Gaussview $input =~ s/^.*\///; $comname = $input . ".com"; unless (-e $comname ) { $gjfname = $input . ".gjf"; unless (-e $gjfname ) { print "There is no input file! \n"; exit; } `/bin/mv $gjfname $comname`; print "Renamed $gjfname to $comname\n"; } `/usr/bin/dos2unix -q -n $comname $comname`; $directory = `/bin/pwd`; $myname= `/usr/bin/whoami`; chomp $directory; chomp $myname; $jobname = $input . ".job"; $pe = ""; $sharedcheck = ""; $mem = ""; #should expand to check if there are mupltiple nprocs $sharedcheck = `/bin/grep -i -m 1 "%nproc" $comname`; $sharedcheck =~ s/\D//g; if ($sharedcheck == "") { $sharedcheck = 1; } if ($sharedcheck > 12) { print "Your nproc requested more than 12 core. This has been replaced by 12.\n"; $sharedcheck = 12; } if ($sharedcheck > 1) { $pe = "#\$ -pe shared $sharedcheck"; } # print "sharecheck $sharedcheck \n"; $mem = (int($sharedcheck * 3.5)) . "GB"; #print "mem $mem \n"; `sed -i 's/^%nproc.*/%nproc=$sharedcheck/Ig' $comname`; `sed -i 's/^%mem.*/%mem=$mem/Ig' $comname`; local *FILE; open (FILE, ">$jobname") || die "Can't open create file named $jobname"; print FILE "#\!/bin/tcsh -f","\n"; print FILE "#\$ -cwd","\n"; print FILE "#\$ -o $jobname.o\$JOB_ID","\n"; print FILE "#\$ -j y","\n"; print FILE "#\$ -N g-$input","\n"; print FILE "#\$ -q cubs.q","\n"; print FILE "$pe","\n"; print FILE "\n"; print FILE "/bin/hostname","\n"; print FILE "/usr/bin/env","\n"; print FILE "cd $directory","\n"; print FILE "/bin/mkdir -p /scr/$myname/\$JOB_ID","\n"; print FILE "\n"; print FILE "setenv g16root /usr/software/gaussian16/$rev","\n"; print FILE "setenv GAUSS_SCRDIR /scr/$myname/\$JOB_ID","\n"; print FILE "setenv PATH /usr/software/nbo6_g16/bin:\${PATH}","\n"; print FILE "source /usr/software/gaussian16/$rev/g16/bsd/g16.login","\n"; print FILE "echo Job submitted to: > $input.out","\n"; print FILE "/bin/hostname >> $input.out","\n"; #print FILE "which gaunbo6 >> $input.out","\n"; print FILE "/usr/software/gaussian16/$rev/g16/g16 < $input.com >> $input.out","\n"; print FILE "rm -rf /scr/$myname/\$JOB_ID" ,"\n"; print FILE "rmdir --ignore-fail-on-non-empty /scr/$myname" ,"\n"; $command1 = "cd $directory\; qsub $jobname &/dev/null &"; $command2 = "/usr/bin/ssh tiger \"$command1\""; #print $command2, "\n"; $hostname = `/bin/hostname`; if ( $hostname eq "tiger.cchem.berkeley.edu" ) { print "Your job has been submitted on Tiger on the Cub nodes. Use qstat to follow the progress. \n"; exec $command1; } else { #print "$hostname\n"; print "Your job has been submitted to Tiger on the Cub nodes. Use qstat to follow the progress. \n"; exec $command2; }