{"id":46,"date":"2020-06-02T17:52:53","date_gmt":"2020-06-02T16:52:53","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf4\/?page_id=46"},"modified":"2025-04-30T12:35:43","modified_gmt":"2025-04-30T11:35:43","slug":"modules","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/software\/modules\/","title":{"rendered":"Modules"},"content":{"rendered":"<h2>Overview<\/h2>\n<p><em>Modules<\/em> is the system by which most software is made available. Modules allow, via a simple interface, the update of various paths (and other <em>environment settings<\/em>) that allow access to software. <\/p>\n<p>The use of modules also provides a convenient way to switch between different versions of the same software (such as compilers or applications such as matlab which are updated frequently). <\/p>\n<div class=\"hint\">Note: We now recommend loading modulefiles within your jobscript so that you have a full record of how the job was run.<\/p>\n<p>Alternatively, you may load modulefiles on the login node and let the job inherit these settings (which it will do by default). See <a href=\"#inherit\">below<\/a> for more information about these two methods.<\/div>\n<h2>Module Commands<\/h2>\n<p>Your <em>environment<\/em> is controlled using the <code>module<\/code> command with various arguments. The most commonly used command is:<\/p>\n<pre>\r\nmodule load <em>name<\/em>\/<em>1.2.3<\/em>\r\n<\/pre>\n<p>These commands can be used directly on the login node or in your jobscripts.<\/p>\n<p>You may wish to <em>search<\/em> for modules on the login node while writing your jobscript AND do the actual loading of the modulefile inside the jobscript so that your jobs always use the same version of the application.<\/p>\n<p>The full list of module commands is given below.<\/p>\n<table class=\"striped\">\n<thead>\n<tr>\n<th width=\"30%\">Command<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>module avail <em>pattern<\/em><\/code><\/td>\n<td>Lists all modules that have <em>pattern<\/em> in their name. For example: <code>module avail para<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>module avail<\/code><\/td>\n<td>Lists all available modules for use on the CSF (this shows what software has been installed).<\/td>\n<\/tr>\n<tr>\n<td><code>module list<\/code><\/td>\n<td>Lists all of the modules that you have currently loaded in your environment, if any.<\/td>\n<\/tr>\n<tr>\n<td><code>module list <em>pattern<\/em><\/code><\/td>\n<td>Lists modules that you have currently loaded in your environment that have <em>pattern<\/em> in their name. For example <code>module avail slu<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>module load <em>modulename<\/em><\/code><\/td>\n<td>Loads module <em>modulename<\/em><\/td>\n<\/tr>\n<tr>\n<td><code>ml<\/code><\/td>\n<td>Lists all of the modules that you have currently loaded in your environment.<\/td>\n<\/tr>\n<tr>\n<td><code>ml <em>modulename<\/em><\/code><\/td>\n<td>Loads module <em>modulename<\/em><\/td>\n<\/tr>\n<tr>\n<td><code>module unload <em>modulename<\/em><\/code><\/td>\n<td>Unloads module <em>modulename<\/em> and clears any settings made by the module from your environment<\/td>\n<\/tr>\n<tr>\n<td><code>module switch <em>oldmodulename<\/em> <em>newmodulename<\/em><\/code><\/td>\n<td>Switches between two modules, unloading one and loading the other<\/td>\n<\/tr>\n<tr>\n<td><code>module purge<\/code><\/td>\n<td>Unload all modules from your environment. Very useful for starting with a clean environment (alternatively just log out and back in again). Note the the <code>slurm<\/code> modulefile (needed to submit batch jobs) will NOT be purged.<\/td>\n<\/tr>\n<tr>\n<td><code>module help <em>modulename<\/em><\/code><\/td>\n<td>May show longer description of the module if present in the modulefile<\/td>\n<\/tr>\n<tr>\n<td><code>module help<\/code><br \/><code>module -H<\/code><\/td>\n<td>Show help about the <code>module<\/code> command<\/td>\n<\/tr>\n<tr>\n<td><code>module show <em>modulename<\/em><\/code><\/td>\n<td>Shows all of the settings that would be made by the module if you were to load it. Very useful to see what the module does.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a name=\"inherit\"><\/a><\/p>\n<h2>Module environment settings in batch<\/h2>\n<p>Modulefiles can be loaded:<\/p>\n<ul>\n<li>on the login node <em>before<\/em> you submit a batch job<\/li>\n<li>or from the jobscript when the job actually <em>runs<\/em><\/li>\n<\/ul>\n<p>There are pros and cons to each method but which method you choose is up to you &#8211; both are valid.<\/p>\n<h3>Loading a modulefile on the login node<\/h3>\n<p>The advantages of loading a modulefile on the login node <em>before<\/em> you submit the job are that you can check the name of the modulefile is correct (any spelling mistakes and the modulefile won&#8217;t be loaded). You could also check the settings the modulefile makes (e.g., an environment variable) and then use that in your jobscript. The disadvantage is that the particular modulefile name used is not recorded in your jobscript. If you wish to run the job again (perhaps in a few months time) you may have forgotten which version of a modulefile you used.<\/p>\n<h3>Loading a modulefile in the jobscript<\/h3>\n<p>The key advantage of loading a modulefile in the jobscript is that the names of any modulefiles used by your job are recorded &#8211; this helps with reproducibility (you might want to run the job again in 6 months time so having the modulefiles written in the jobscript shows exactly which apps were used by the job.) However, if you spell a modulefile name incorrectly the mistake will only be detected when the job <em>runs<\/em>. Your job will probably fail and you&#8217;ll have to resubmit the job, waiting in the queue again.<\/p>\n<h3>Example of each method<\/h3>\n<p>You should write your jobscripts for the modulefile method you prefer:<\/p>\n<h2>Using your own Modulefiles<\/h2>\n<p>You can write you own modulefiles, using either TCL or LUA scripting languages. These should be stored in a folder named <code>~\/modulefiles<\/code> (i.e. the folder is in you home dir.)<\/p>\n<p>For example<\/p>\n<pre>\r\nmkdir -p ~\/modulefiles\/myapp\r\ncd ~\/modulefiles\/myapp\r\ngedit 1.2.3.lua\r\n  #\r\n  # Write the LUA script modulefile\r\n\r\n# OR, write a TCL modulefile\r\ngedit 1.2.3\r\n  #\r\n  # Ensure the first line of the file is:\r\n#%Module#\r\n\r\n# Now, when you wish to use this module file, do:\r\nmodule load use.own\r\nmodule laod myapp\/1.2.3\r\n<\/pre>\n<p>Note that if you&#8217;ve previously written your own modulefiles on CSF3 then they are stored at:<\/p>\n<pre>\r\n~\/privatemodules\r\n<\/pre>\n<p>So to make these available on CSF4, you should do:<\/p>\n<pre>\r\n#either\r\nmodule load use.own.csf3\r\n#or\r\nmodule use ~\/privatemodules\r\n\r\n#and then\r\nmodule load &lt;your_privatemodule&gt;\r\n<\/pre>\n<p>However, note that if your own CSF3 modulefiles try to load CSF3 system-wide modulefiles (e.g., a CSF3 compiler) then it will fail to load on CSF4.<br \/>\nAlso, if the program\/code compiled in CSF3 uses any specific version of library that is not available in CSF4, the module will load okay, but the program\/code will crash when run.<br \/>\nIt is better to re-compile your software\/code in CSF4 and place their module files in <strong>~\/modulefiles<\/strong> instead.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Modules is the system by which most software is made available. Modules allow, via a simple interface, the update of various paths (and other environment settings) that allow access to software. The use of modules also provides a convenient way to switch between different versions of the same software (such as compilers or applications such as matlab which are updated frequently). Note: We now recommend loading modulefiles within your jobscript so that you have.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/software\/modules\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":39,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-46","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/pages\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":14,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/pages\/46\/revisions"}],"predecessor-version":[{"id":1422,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/pages\/46\/revisions\/1422"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/pages\/39"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf4\/wp-json\/wp\/v2\/media?parent=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}