Assignment 1 Solution

$35.00 $30.80


All commands or code must work on Euler with no modules loaded unless speci ed otherwise.


They may behave di erently on your computer, so be sure to test on Euler before you submit.


For this assignment before we have your git repos set up, submit all responses on Canvas.


Please submit clean code. Consider using a formatter like clang-format.




  1. (a) Read the les mdand slurm from the general directory of the ME759 Resource Repo. These are very important documents of the expectations for your assignments throughout the semester.


  • Read the hw repos.mdle and follow the instructions to create an account. This is very important and must be done in order for you to have a way to turn in HW02.


  • At least skim md. This contains a quick guide for e ectively working between your local computer and Euler.





  1. Write a single line of bash for each of the following (you can use pipes and/or redirects). Pretend that any les or directories mentioned exist (don’t turn them in).


  1. Print the current working directory


  1. Change directories into a directory called somedir


  1. List the names of all  les in the current directory


  1. (Optional) Write a forloop which prints each integer 0 to 10.


  1. (Optional) Print the names of all les ending in .txtin the current directory or any of its subtree


  1. (Optional) Print the last 2 lines of a plain text le in the current directory called txt


  1. (Optional) Print the entire contents of a  le in the current directory called txt




  1. Using Euler and the modulecommand, answer the following questions.


  1. Are there any modules loaded (module list) when you log in?


  1. What version (version number) of gcc is available to you without loading any modules?


  1. List all gcc modules available on Euler.


  1. Which gcc module is loaded when you run module load gccand what version number of gcc is loaded by that module?


  1. List one other piece of software that you know that has a module on Euler and one sentence about what it does. (If you aren’t familiar with any of the other software, look one up and write a sentence about it.)




  1. Write a bash script called shwith a Slurm header which asks for


2 CPU cores


A job name of FirstSlurm


An output le called FirstSlurm.out An error le called FirstSlurm.err


and runs a single command to print the hostname of the machine (compute node) running the job. This job should be submittable by running sbatch on the head node.











  1. Research some useful Slurm tools (one sentence responses):


  1. Explain what SLURM SUBMIT DIRis in the environment of a running Slurm job.


  1. In what directory does a Slurm job on euler begin execution. You should run some jobs to check this?


  1. Explain what SLURM JOB IDis in the environment of a running Slurm job.


  1. Explain what the following script header line speci es: #SBATCH –array=0-9


  1. Explain what SLURM ARRAY TASK IDis in the environment of a running Slurm job with the header from part (d).


  1. Explain what the following script header line speci es: #SBATCH –gres=gpu:1























































  1. Write a C++ program called cppwhich takes a command line argument N, and prints out each integer from 0 to N (including 0 and N) separated by spaces on a single line ending in a newline.


Compile command: g++ task6.cpp -Wall -O3 -o task6


Run command: ./task6 N


Expected output (followed by newline): 0 1 2 3 N


Expected output for N = 6 (followed by newline): 0 1 2 3 4 5 6