4f1877c2974ee37a984000e1add2c4c27da0de7b
hiram
  Fri Oct 25 18:48:17 2024 -0700
the TMPDIR needs to be set locally on the para node not where the driver script is making the sub-script refs #34685

diff --git src/hg/utils/automation/doWindowMasker.pl src/hg/utils/automation/doWindowMasker.pl
index 1b8d577..c980898 100755
--- src/hg/utils/automation/doWindowMasker.pl
+++ src/hg/utils/automation/doWindowMasker.pl
@@ -106,34 +106,49 @@
 
 #########################################################################
 # * step: count [workhorse]
 sub doCount {
   my $runDir = "$buildDir";
   &HgAutomate::checkCleanSlate('count', 'mask', "$runDir/windowmasker.counts");
   &HgAutomate::mustMkdir($runDir);
 
   my $whatItDoes = "It does WindowMasker counts step.";
   my $workhorse = &HgAutomate::chooseWorkhorse();
   my $bossScript = new HgRemoteScript("$runDir/doCount.csh", $workhorse,
 				      $runDir, $whatItDoes);
 
   my $tmpDir = &HgAutomate::tmpDir();
   $bossScript->add(<<_EOF_
+if ( -d "/data/tmp" ) then
+  setenv TMPDIR "/data/tmp"
+else if ( -d "/scratch/tmp" ) then
+  setenv TMPDIR "/scratch/tmp"
+else
+  set tmpSz = `df --output=avail -k /tmp | tail -1`
+  set shmSz = `df --output=avail -k /dev/shm | tail -1`
+  if ( "\${shmSz}" > "\${tmpSz}" ) then
+     mkdir -p /dev/shm/tmp
+     chmod 777 /dev/shm/tmp
+     setenv TMPDIR "/dev/shm/tmp"
+  else
+     setenv TMPDIR "/tmp"
+  endif
+endif
 set windowMaskerDir = /cluster/bin/\$MACHTYPE
 set windowMasker = \$windowMaskerDir/windowmasker
 set fa = $db.fa
-set tmpDir = `mktemp -d -p $tmpDir doWindowMasker.XXXXXX`
+set tmpDir = `mktemp -d -p \$TMPDIR doWindowMasker.XXXXXX`
 chmod 775 \$tmpDir
 set inputTwoBit = $unmaskedSeq
 pushd \$tmpDir
 twoBitToFa \$inputTwoBit \$fa
 \$windowMasker -mk_counts true -input \$fa -output windowmasker.counts
 popd
 cp \$tmpDir/windowmasker.counts .
 rm -rf \$tmpDir
 _EOF_
   );
   $bossScript->execute();
 } # doCount
 
 
 #########################################################################
@@ -142,34 +157,49 @@
   printf STDERR "# doMask: obsolete step, no longer needed\n";
   return 0;
 } # doMask
 
 #########################################################################
 # * step: sdust [workhorse]
 sub doSdust {
   my $runDir = "$buildDir";
   &HgAutomate::checkExistsUnlessDebug('mask', 'sdust', "$runDir/windowmasker.counts");
   my $whatItDoes = "It does WindowMasker masking step with -sdust true.";
   my $workhorse = &HgAutomate::chooseWorkhorse();
   my $bossScript = new HgRemoteScript("$runDir/doSdust.csh", $workhorse,
 				      $runDir, $whatItDoes);
   my $tmpDir = &HgAutomate::tmpDir();
   $bossScript->add(<<_EOF_
+if ( -d "/data/tmp" ) then
+  setenv TMPDIR "/data/tmp"
+else if ( -d "/scratch/tmp" ) then
+  setenv TMPDIR "/scratch/tmp"
+else
+  set tmpSz = `df --output=avail -k /tmp | tail -1`
+  set shmSz = `df --output=avail -k /dev/shm | tail -1`
+  if ( "\${shmSz}" > "\${tmpSz}" ) then
+     mkdir -p /dev/shm/tmp
+     chmod 777 /dev/shm/tmp
+     setenv TMPDIR "/dev/shm/tmp"
+  else
+     setenv TMPDIR "/tmp"
+  endif
+endif
 set windowMaskerDir = /cluster/bin/\$MACHTYPE
 set windowMasker = \$windowMaskerDir/windowmasker
 set fa = $db.fa
-set tmpDir = `mktemp -d -p $tmpDir doWindowMasker.XXXXXX`
+set tmpDir = `mktemp -d -p \$TMPDIR doWindowMasker.XXXXXX`
 chmod 775 \$tmpDir
 set inputTwoBit = $unmaskedSeq
 cp windowmasker.counts \$tmpDir
 pushd \$tmpDir
 twoBitToFa \$inputTwoBit \$fa
 \$windowMasker -ustat windowmasker.counts -sdust true -input \$fa -output windowmasker.intervals
 perl -wpe \'if \(s\/^\>lcl\\\|\(\.\*\)\\n\$\/\/\) { \$chr = \$1\; } \\
    if \(\/^\(\\d+\) \- \(\\d+\)\/\) { \\
    \$s=\$1\; \$e=\$2+1\; s\/\(\\d+\) \- \(\\d+\)\/\$chr\\t\$s\\t\$e\/\; \\
    }\' windowmasker.intervals > windowmasker.sdust.bed
 popd
 cp \$tmpDir/windowmasker.sdust.bed .
 rm -rf \$tmpDir
 _EOF_
   );