<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>That flow is fairly common.</p>
    <p>Basically, you need to get the environment alias 'module' to be
      defined so you need your script to source things.</p>
    <p>The common thing is to:</p>
    <p>    source ~/.bash_profile</p>
    <p>On default RHEL-based systems this will also call ~/.bashrc which
      in turn calls ~/etc/bashrc</p>
    <p>The net effect is that the environment gets setup the same as if
      the user had opened a shell console.</p>
    <p>Brian Andrus<br>
    </p>
    <div class="moz-cite-prefix">On 1/26/2021 2:13 AM, Gestió Servidors
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:VI1PR0701MB2895394FEFB3866B0D081F50F2BC0@VI1PR0701MB2895.eurprd07.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}span.EstiloCorreo17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}ol
        {margin-bottom:0cm;}ul
        {margin-bottom:0cm;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Hi,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">My environment is this:<o:p></o:p></p>
        <ul style="margin-top:0cm" type="disc">
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l2 level1 lfo1">Users are
            using “bash” as the default shell<o:p></o:p></li>
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l2 level1 lfo1">A sample of
            one of my environment modules is this:<o:p></o:p></li>
        </ul>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">#%Module1.0<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">##<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">## modules modulefile<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">##<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">## modulefiles/modules.  Generated
            from modules.in by configure.<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">##<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">set ModulesVersion      "3.2.10"<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">proc ModulesHelp { } {<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">        global version prefix<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">        puts stderr "\tOpenMPI -
            $version"<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">        puts stderr "\n\tThis adds
            $prefix/* to several of the"<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">        puts stderr "\tenvironment
            variables."<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">        puts stderr "\n\tVersion
            $version\n"<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">}<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">module-whatis   "Loads OpenMPI
            3.0.0 environment"<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"># for Tcl script use only<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">set     version         3.0.0<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">set     prefix         
            /soft/openmpi-${version}<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">set     exec_prefix     ${prefix}<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">set     datarootdir    
            ${prefix}/share<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">prepend-path    PATH           
            ${exec_prefix}/bin<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">prepend-path    LD_LIBRARY_PATH
            ${prefix}/lib<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">prepend-path    INCLUDE_PATH   
            ${prefix}/include<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <ul style="margin-top:0cm" type="disc">
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l1 level1 lfo3">“module”
            command itself is processed in /etc/profile.d/modules.sh
            with this script:<o:p></o:p></li>
        </ul>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">#----------------------------------------------------------------------#<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"># system-wide
            profile.modules                                          #<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"># Initialize modules for all
            sh-derivative shells                      #<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">#----------------------------------------------------------------------#<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">trap "" 1 2 3<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">MODULES=/soft/modules-3.2.10/Modules/3.2.10/init/<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">case "$0" in<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">    -bash|bash|*/bash) .
            $MODULES/bash ;;<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">       -ksh|ksh|*/ksh) .
            $MODULES/ksh ;;<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">          -sh|sh|*/sh) .
            $MODULES/sh ;;<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">                    *) .
            $MODULES/sh ;;         # default for scripts<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">esac<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"># Update MODULESPATH environment.
            /usr/share/modules/init/.modulepath<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">MMODS=/soft/modules-3.2.10<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">module use $MMODS/compilers
            $MMODS/parallel<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">module use $MMODS/libraries
            $MMODS/applications $MMODS/tools<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">#module unuse /usr/share/modules
            /usr/share/modulefiles<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"># load site specific modules<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">module load modules<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"># source .modules in the user's
            home directory, if it exists<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">if [ -r ~/.modules ]; then<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">. ~/.modules<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">fi<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt">trap - 1 2 3<o:p></o:p></span></p>
        <p class="MsoListParagraph" style="margin-left:70.8pt"><span
            style="font-size:10.0pt"><o:p> </o:p></span></p>
        <ul style="margin-top:0cm" type="disc">
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l1 level1 lfo3">In the SLURM
            submit scripts, users have to add an explicit “<i>source
              /soft/modules-3.2.10/Modules/3.2.10/init/bash</i>”, and
            after this line, users can load modules in the way “module
            load foo/version”<o:p></o:p></li>
        </ul>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Is there any bad configuration??<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Thanks.<span
            style="font-size:12.0pt;mso-fareast-language:ES">
            <o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
      </div>
    </blockquote>
  </body>
</html>