I am preparing some C++ code to be run on a cluster, managed by SLURM. The cluster takes one compiled file: a.out. It will then execute it on 500 different nodes via the JOB_ARRAY. When executing each copy of the file, it will need to read one input parameter, say double parameter
. My idea was to prepare a .txt file which would hold one value of the parameter
at each line. What is the best strategy for implementing the reading of these parameter
values?
a.out will read the value from the first line and immediately delete it. If this is the right strategy, how to ensure that two copies of a.out are not doing the same thing at the same time?
a.out will read the value from the n-th line. How to let the copy of a.out know which n is it working with?
Is there any better implementation strategy then the two above? If so, how to do this? Is C++ fstream the way to go, or shall I try something completely different.
Thank you for any ideas. I would appreciate if you also left some very simple code for how a.out shall look like.