In this example, we will create a convertor of N .bmp files to .jpg using an array job. First, we will test our code interactively on a qshr session and then, we will create a script to submit to the cluster. Obviously, we will show you the last one because it is the way to do the array job.
This file will be called script.sh, and will contain specific commands that you will need to convert N file formats.
The default shell is /bin/bash. On the other hand, we will limit the memory to 1 G and will set the name of the job (Convert BMP to JPG). –t flag establishes that it will execute 1 to 2000 image files incrementing 3 each time, -tc indicates maximum 20 simultaneously.
We will define the variable num with SGE_TASK_ID, this parameter indicates the integer at the end of each .bmp files (total number of images). To know if the script runs well, it prints a message.
It will need to copy the .bmp files (testing.bmp) that we have created previously in /homedtic/cocana/ (user’s home path) to /scratch/ (this path is in nodes, for this reason you will initiate a qshr session if you will test it).
Then, we will convert the .bmp images to .jpg with the command convert. To do this, we will use ImageMagick (software suitable to create, edit, compose and convert bitmap images).
The official ImageMagick web site is: http://www.imagemagick.org/
Continuously, we will copy the outputs (.jpg files) in the scratch.
Finally we will delete all the .bmp and .jpg files generated in /scratch/.
Submit the array job with qsub command:
For more information, see Documentation / Manuals / 4.3.Submitting advanced jobs: http://hpc.dtic.upf.edu/documentation/43-submitting-advanced-jobs