Cpp example array job
#include
#include
#include
int main()
{
char *envv = std::getenv("SLURM_ARRAY_TASK_ID");
int task_id = std::atoi(envv);
int numsamples = 10 * std::pow(2, task_id);
if(envv)
{
std::cout << "I am array job # " << task_id <<
" and generated a number 10*pow(2, $SLURM_ARRAY_TASK_ID) : " <<
numsamples << std::endl;
}
return 0;
}
Cut and paste the above code into a file named cpp_example.cpp
, and
compile it with the following command:
make cpp_example