{"id":315,"date":"2017-09-14T14:12:37","date_gmt":"2017-09-14T13:12:37","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/htccondor\/?page_id=315"},"modified":"2025-02-21T12:06:38","modified_gmt":"2025-02-21T12:06:38","slug":"matlab","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/software\/matlab\/","title":{"rendered":"Matlab"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>Matlab is the computational software package developed by <a href=\"https:\/\/uk.mathworks.com\/\">The MathWorks<\/a>.<\/p>\n<h2>Restrictions on use<\/h2>\n<p>Matlab may not be used for commercial purposes including being used by consultants or subcontractors. A detailed list of the license restrictions is available on the <a href=\"https:\/\/www.applications.itservices.manchester.ac.uk\/show_product.php?id=98&amp;tab=licensing\">IT Services Applications website<\/a>.<\/p>\n<h2>Versions installed<\/h2>\n<table border = \"1\" align=\"center\">\n<tr>\n<th align=\"center\">Version installed<\/th>\n<th align=\"center\">HTCondor ClassAd<\/th>\n<th align=\"center\">Location of Matlab runtimes<\/th>\n<\/tr>\n<tr>\n<td align=\"center\">2019a<\/td>\n<td align=\"center\">HAS_MATLAB_2019<\/td>\n<td>\/opt\/MATLAB\/MATLAB_Compiler_Runtime\/v96<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">2021a<\/td>\n<td align=\"center\">HAS_MATLAB_2021<\/td>\n<td>\/opt\/MATLAB\/MATLAB_Compiler_Runtime\/v910<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">2024a<\/td>\n<td align=\"center\">HAS_MATLAB_2024<\/td>\n<td>\/opt\/MATLAB\/MATLAB_Compiler_Runtime\/R2024a<\/td>\n<\/tr>\n<\/table>\n<h2>Set up procedure on submit node<\/h2>\n<p>To access the software you must first run the command:<\/p>\n<pre>\r\nmodule load matlab\/&lt;version&gt;\r\n<\/pre>\n<h2>Running the application<\/h2>\n<p>In order to run Matlab jobs on HTCondor, it is first necessary to compile the Matlab script file using the <a href=\"https:\/\/uk.mathworks.com\/products\/compiler.html\">Matlab compiler<\/a>. Whilst this has the advantage that compiled Matlab programs do not use any Matlab licenses when running, <a href=\"https:\/\/uk.mathworks.com\/products\/compiler\/supported\/compiler_support.html\">some Matlab toolbox functionality may be unavailable<\/a>.<\/p>\n<p><strong>Step 1 &#8211; Compiling your Matlab script file<\/strong><\/p>\n<p>To ensure that your compiled Matlab code will run on HTCondor, it is <em>essential<\/em> that you compile your Matlab code on the HTCondor submit node. <\/p>\n<p>From a linux terminal prompt, run the command <\/p>\n<pre>\r\nmcc -R -singleCompThread -m &lt;script.m&gt;\r\n<\/pre>\n<p>where<\/p>\n<ul>\n<li><strong>mcc<\/strong> is the name of the Matlab compiler command.<\/li>\n<li><strong>-R -singleCompThread<\/strong> tells the compiler to produce a single-threaded executable.<\/li>\n<li><strong>-m &lt;script.m&gt;<\/strong> specifies the name of the Matlab script file to compile.<\/li>\n<\/ul>\n<p>The reason for the <strong>-R -singleCompThread<\/strong> flag is to avoid problems with Matlab trying to use multiple threads. By default Matlab will detect the number of CPU cores on a PC and then attempt to use that many threads. This can cause problems unless your HTCondor submit file has requested to use all the available cores on the compute node. The maximum number of threads can be specified in your Matlab script file using the <tt><a href=\"http:\/\/uk.mathworks.com\/help\/matlab\/ref\/maxnumcompthreads.html\">maxNumCompThreads<\/a><\/tt> command.<\/p>\n<p>After successful compilation, a shell script <tt>run_&lt;script&gt;.sh<\/tt> and executable file <tt>&lt;script&gt;<\/tt> should exist in the current directory.<\/p>\n<p><strong>Step 2 &#8211; Submitting your job to run on HTCondor<\/strong><\/p>\n<p>The following lines are the contents of a simple generic HTCondor submit text file:<\/p>\n<pre>\r\nUniverse = vanilla\r\n\r\nRequirements = (Target.Opsys == \"LINUX\" && Target.Arch == \"X86_64\" && &lt;HTCondor ClassAd&gt;=?=True)\r\nRequest_memory = 1000\r\n\r\nLog = matlab.log\r\nOutput = matlab.out\r\nError = matlab.error\r\nNotification = Error\r\n\r\nShould_Transfer_Files = Yes\r\nWhen_To_Transfer_Output = On_Exit\r\n\r\nExecutable = run_&lt;script&gt;.sh\r\nTransfer_Executable = True\r\nArguments = &lt;Location of Matlab runtimes&gt; &lt;input arguments&gt;\r\nTransfer_Input_Files = &lt;script&gt;\r\n\r\nQueue\r\n<\/pre>\n<p>If your submit file is called <tt>submit.txt<\/tt> then your job can be submitted to HTCondor using the command <tt>condor_submit submit.txt<\/tt>.<\/p>\n<h2>Using MEX files with compiled Matlab<\/h2>\n<p>Whilst it is possible to use MEX files in compiled Matlab codes, each version of Matlab supports a very limited range of the GNU compiler suite. The <a href=\"https:\/\/uk.mathworks.com\/support\/requirements\/previous-releases.html\">supported versions<\/a> are listed in the following table:<\/p>\n<table border = \"1\" align=\"center\">\n<tr>\n<th align=\"center\">Matlab version<\/th>\n<th align=\"center\">GNU C\/C++ version<\/th>\n<th align=\"center\">GNU gfortran version<\/th>\n<\/tr>\n<tr>\n<td align=\"center\">2019a<\/td>\n<td align=\"center\">6.3.x<\/td>\n<td align=\"center\">6.3.x<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">2021a<\/td>\n<td align=\"center\">7.x\/8.x\/9.x<\/td>\n<td align=\"center\">8.x<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">2024a<\/td>\n<td align=\"center\">8.x\/9.x\/10.x\/11.x<\/td>\n<td align=\"center\">10.x<\/td>\n<\/tr>\n<\/table>\n<p><em>Please be aware that even if the <tt>mex<\/tt> command produces a MEX file, this does not necessarily mean that it will work with the Matlab compiler unless it was compiled using a supported version of the GNU compiler suite.<\/em><\/p>\n<h2>Sample Matlab HTCondor jobs<\/h2>\n<ol>\n<li><a href=\"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/software\/matlab_calculate_pi\/\">Matlab code for calculating Pi using <em>n<\/em> terms of the Gregory series.<\/a><\/li>\n<li><a href=\"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/software\/matlab_parameter_sweep\/\">Matlab code demonstrating one way to conduct a 1-D parameter sweep.<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Overview Matlab is the computational software package developed by The MathWorks. Restrictions on use Matlab may not be used for commercial purposes including being used by consultants or subcontractors. A detailed list of the license restrictions is available on the IT Services Applications website. Versions installed Version installed HTCondor ClassAd Location of Matlab runtimes 2019a HAS_MATLAB_2019 \/opt\/MATLAB\/MATLAB_Compiler_Runtime\/v96 2021a HAS_MATLAB_2021 \/opt\/MATLAB\/MATLAB_Compiler_Runtime\/v910 2024a HAS_MATLAB_2024 \/opt\/MATLAB\/MATLAB_Compiler_Runtime\/R2024a Set up procedure on submit node To access the software you must.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/software\/matlab\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":17,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-315","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/pages\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":20,"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/pages\/315\/revisions"}],"predecessor-version":[{"id":1242,"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/pages\/315\/revisions\/1242"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/pages\/17"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/htccondor\/wp-json\/wp\/v2\/media?parent=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}