Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] getenv issue
From: Prakash Velayutham (prakash.velayutham_at_[hidden])
Date: 2008-01-05 03:48:53


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

prakash_at_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);
         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

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

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_at_bmi-opt2-04:~/thesis/CS/Samples/changejob> echo $PBS_JOBID

Any ideas why?