<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I run into this problem occasionally. In my organization, most
accounts are created with tcsh as the default shell, and then
users copy my bash submission script example from my online
documentation, or copy someone else's submission script written in
bash. And then when the job runs, it fails with an error about the
module command not being found. <br>
</p>
<p>The problem you are describing is because the module command is
defined differently in bash and tcsh. In bash it's a function, but
in tcsh it is an alias. Slurm jobs inherit the environment of the
shell submitting the script, but when one of those shells is tcsh
and the other is bash, or vice-versa, the definition of the
command 'module' doesn't survive. <br>
</p>
<p>On RHEL-based systems, if your using the environment modules
RPM, the module command itself is defined in the the files
/etc/profile.d/modules.{sh,csh}</p>
<p>One easy fix to this problem is that if someone is using tcsh but
is using a bash submission script, they can make the interpreter
of their bash submission script a login shell, which will process
/etc/profile.d/*.sh by adding a -l to the interpreter line of
their script: <br>
</p>
<p>#!/bin/bash -l</p>
<p>I imagine that this will work with someone using bash as their
login shell, but writing their sbatch script in tcsh, but I've
never come across that scenario. <br>
</p>
<p>Prentice<br>
</p>
<div class="moz-cite-prefix">On 1/22/21 9:34 AM, Thomas M. Payerle
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAHJ2ZQ_aJrbG0UTti8m==Ahd1QgmtdS6SAKPsrTf1DX5Dr55gw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>On our clusters, we typically find that an explicit source
of the initialization dot files is need IF the default shell
of</div>
<div>the user submitting the job does _not_ match the shell
being used to run the script. I.e., for sundry historical and
other reasons, <br>
</div>
<div>the "default" login shell for users on our cluster is tcsh,
so if an user with login shell of tcsh submits a bash job
script, they generally</div>
<div>need to do an explicit "source ~/.profile".</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, Jan 22, 2021 at 5:42
AM Gestió Servidors <<a href="mailto:sysadmin.caos@uab.cat"
moz-do-not-send="true">sysadmin.caos@uab.cat</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;" lang="ES">
<div class="gmail-m_-9060440556045174870WordSection1">
<p class="MsoNormal">Hello,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I use “Environment Modules” (<a
href="http://modules.sourceforge.net/" target="_blank"
moz-do-not-send="true">http://modules.sourceforge.net/</a>)
in my SLURM cluster. In my scripts I do need to add an
explicit “source
/soft/modules-3.2.10/Modules/3.2.10/init/bash”. However,
in several examples I have read about SLURM scripts,
nobody comments that. So, have I forgotten a parameter
in SLURM to “capture” environment variables into the
script or is it a problem due to my distribution
(CentOS-7)???</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Thanks.</p>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<br>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">Tom Payerle <br>
DIT-ACIGS/Mid-Atlantic Crossroads <a
href="mailto:payerle@umd.edu" target="_blank"
moz-do-not-send="true">payerle@umd.edu</a><br>
</div>
<div>5825 University Research Park (301)
405-6135<br>
</div>
<div dir="ltr">University of Maryland<br>
College Park, MD 20740-3831<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Prentice Bisbal
Lead Software Engineer
Research Computing
Princeton Plasma Physics Laboratory
<a class="moz-txt-link-freetext" href="http://www.pppl.gov">http://www.pppl.gov</a></pre>
</body>
</html>