Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

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


Hi,

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);
         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_at_bmi-opt2-04:~/thesis/CS/Samples/changejob> mpiexec -np 4 --
prefix /usr/local/openmpi-1.2.4 ./pbs
prakash_at_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_at_bmi-opt2-04:~/thesis/CS/Samples/changejob> echo $PBS_JOBID
18.fructose.cchmc.org

Any ideas why?

Thanks,
Prakash