Difference between revisions of "Rocky MATLAB HelloWorld"
From NIMBioS
(Created page with "= Code = '''helloworld.m''' <pre> fprintf("hello world"); </pre> = Batch Script = '''helloworld.run''' <pre> #!/bin/bash #SBATCH --job-name=MATLAB_HELLOWORLD #SBATCH --output=logs/matlab_helloworld_%j.out module load MATLAB/2022b matlab -nojvm -batch "run('helloworld.m');" </pre> = Running Job = <pre> [test_user@rocky7 helloworld]$ pwd /home/test_user/projects/matlab/helloworld </pre> <pre> [test_user@rocky7 helloworld]$ ls helloworld.m helloworld.run logs </p...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
fprintf("hello world"); | fprintf("hello world"); | ||
</pre> | </pre> | ||
= Batch Script = | = Batch Script = | ||
Line 19: | Line 20: | ||
matlab -nojvm -batch "run('helloworld.m');" | matlab -nojvm -batch "run('helloworld.m');" | ||
</pre> | </pre> | ||
= Running Job = | = Running Job = | ||
Line 25: | Line 27: | ||
[test_user@rocky7 helloworld]$ pwd | [test_user@rocky7 helloworld]$ pwd | ||
/home/test_user/projects/matlab/helloworld | /home/test_user/projects/matlab/helloworld | ||
[test_user@rocky7 helloworld]$ ls | [test_user@rocky7 helloworld]$ ls | ||
helloworld.m helloworld.run logs | helloworld.m helloworld.run logs | ||
[test_user@rocky7 helloworld]$ sbatch helloworld.run | [test_user@rocky7 helloworld]$ sbatch helloworld.run | ||
Submitted batch job 3871 | Submitted batch job 3871 | ||
</pre> | </pre> | ||
This job will only take a few seconds to run and then we can check the log file. | |||
<pre> | <pre> | ||
[test_user@rocky7 helloworld]$ ls logs | [test_user@rocky7 helloworld]$ ls logs | ||
matlab_helloworld_3871.out | matlab_helloworld_3871.out | ||
[test_user@rocky7 helloworld]$ cat logs/matlab_helloworld_3871.out | [test_user@rocky7 helloworld]$ cat logs/matlab_helloworld_3871.out | ||
hello world | hello world | ||
</pre> | </pre> |
Latest revision as of 20:09, 28 April 2023
Code
helloworld.m
fprintf("hello world");
Batch Script
helloworld.run
#!/bin/bash #SBATCH --job-name=MATLAB_HELLOWORLD #SBATCH --output=logs/matlab_helloworld_%j.out module load MATLAB/2022b matlab -nojvm -batch "run('helloworld.m');"
Running Job
[test_user@rocky7 helloworld]$ pwd /home/test_user/projects/matlab/helloworld [test_user@rocky7 helloworld]$ ls helloworld.m helloworld.run logs [test_user@rocky7 helloworld]$ sbatch helloworld.run Submitted batch job 3871
This job will only take a few seconds to run and then we can check the log file.
[test_user@rocky7 helloworld]$ ls logs matlab_helloworld_3871.out [test_user@rocky7 helloworld]$ cat logs/matlab_helloworld_3871.out hello world