Hi,

I am trying to start a simple MPI code below using Open MPI 1.2.4 and Torque 2.2.1.

prakash@bmi-opt2-04:~/thesis/CS/Samples/changejob> cat pbs.c
#include <stdio.h>
#include "mpi.h"

int gdb_var;

void main(argc, argv)
int argc;
char **argv;
{
    int rank, size, ret;
    gdb_var = 0;
    char *jobid;
    ret = MPI_Init(&argc, &argv);
    if (ret != 0) printf("ERROR with MPI initialization\n");
    ret = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    if (ret != 0) printf("ERROR with MPI ranking\n");
    ret = MPI_Comm_size(MPI_COMM_WORLD, &size);
    if (ret != 0) printf("ERROR with MPI sizes\n");
    if (0 == rank) {
        printf("Host %d ready to attach\n",rank);
        fflush(stdout);
        while (0 == gdb_var) sleep(5);
        jobid = getenv("PBS_JOBID");
        printf("Job id is %s\n", *jobid);
        if (!jobid)
error("PBS_JOBID not set in environment. Code must be run from a\n" " PBS script, perhaps interactively using \"qsub -I \"");
    }
    MPI_Finalize();
}

prakash@bmi-opt2-04:~/thesis/CS/Samples/changejob> mpiexec -np 4 -- prefix /usr/local/openmpi-1.2.4 ./pbs
prakash@bmi-opt2-04:~/thesis/CS/Samples/changejob>

As shown above, for some reason, PBS_JOBID is not getting set in the MPI's environment, even though it is available at the shell level.

prakash@bmi-opt2-04:~/thesis/CS/Samples/changejob> echo $PBS_JOBID
18.fructose.cchmc.org

Any ideas why?

Thanks,
Prakash

Reply via email to