Note that there are some explanatory texts on larger screens.

plurals
  1. POBASH scripts for generating inputs to parallel C++ jobs
    primarykey
    data
    text
    <p>I'm an amateur C++ programmer trying to learn about basic shell scripting. I have a complex C++ program that currently reads in different parameter values from <code>Parameters.h</code> and then executes one or more simulations with each parameter value sequentially. These simulations take a long time to run. Since I have a cluster available, I'd like to effectively parallelize this job, running the simulations for each parameter value on a separate processor. I'm assuming it's easier to learn shell scripting techniques for this purpose than OpenMPI. My cluster runs on the LSF platform.</p> <p>How can I write my input parameters in Bash so that they are distributed among multiple processors, each executing the program with that value? I'd like to avoid interactive submission. Ideally, I'd have the inputs in a text file that Bash reads, and I'd be passing two parameters to each job: an actual parameter value and a parameter ID.</p> <p>Thanks in advance for any leads and suggestions.</p> <hr> <p><strong>my solution</strong></p> <p>GNU Parallel does look slick, but I ended up (with the help of an IT admin) writing a simple bash script that echos to screen three inputs (a treatment identifier, treatment/parameter value, and a simulation identifier):</p> <p><pre><code>#!/bin/bash j=1 for treatment in <code>cat treatments.txt</code>; do for experiment in <code>cat simulations.txt</code>; do bsub -oo <code>tr_${j}_sim_${experiment}_screen</code> -eo <code>tr_${j}_sim_${experiment}_err</code> -q short_serial "echo \"$j $treatment $experiment\" | ./a.out" done let j=$j+1 done </pre></code></p> <p>The file <code>treatments.txt</code> contains a list of the values I'd like to vary, <code>simulations.txt</code> contains a list of all the simulation identifiers I'd like to run (currently just 1,...,s, where s is the total number of simulations I want for each treatment), and the treatments are indexed 1...<code>j</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload