-
Notifications
You must be signed in to change notification settings - Fork 0
Home
rank_run is a light-weight MPI tool for running commands/scripts in different MPI ranks so that we execute serial jobs in parallel.
For example, we can process 24 hours of grib2 files in 24 ranks using wgrib2, each rank processing a given hour;
or we can convert GDAS 80 ensembles to WPS intermediate binary files in 80 ranks using Python tools, each rank processing one member.
The availability of C compiler and MPI library is enough to compile rank_run
mkdir build; cd build
cmake ..
make
${MPI_CMD} rank_run.x <cmdfile|'script_pattern'>
Here is an example cmdfile:
# cmdfile contains lines of commands, each line runs in a different rank
# Uncomment this line to simulate an error exit from rank_run
echo "I am #0" > 0.txt
echo "I am #1" > 1.txt
echo "I am #2" > 2.txt
echo "I am #3" > 3.txt
echo "I am #4" > 4.txt
echo "I am #5" > 5.txt
echo "I am #6" > 6.txt
To run commands in parallel using different ranks:
${MPI_CMD} rank_run.x cmdfile
Note:
(1) If the number of commands is less than the number of ranks, extra cores will be idle and do nothing.
(2) If the number of commands is more than the number of ranks, extra commands will be ignored.
(3) If cmdfile is missing, rank_run will exit with an error.
(4) cmdfile is NOT a keyword, you can use any file name, such as commands.txt, ensmean.txt, etc.
(5) MPI rank index starts at 0.
Use * as a wildcard to tell rank_run to replace it with a rank number at runtime.
For example, 'wgrib_*.sh' will expand to wgrib_0.sh, wgrib_1.sh, ...., wgrib_10.sh, ..., wgrib_99.sh, ..., wgrib_999.sh, etc inside rank_run and each rank will run one corresponding script.
To run these scripts in parallel using different ranks:
${MPI_CMD} rank_run.x 'wgrib_*.sh'
Note:
(1). Each rank will find its corresponding script file; if found, run it; otherwise output information like [INFO] script not found: wgrib_20.sh.
(2). We have to use the single quote ' to bound the 'script_pattern' to avoid the command line parameter expansion.
(3). We can include the path information in 'script_pattern', such as 'ioda_post/ioda_post_*.sh'. The scripts will execute at current directory and rank_run does not change it (of course, one may change the current directory inside the scripts).
(4) MPI rank index starts at 0.