reading environment variables in (parallel) neuron

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
ubartsch
Posts: 34
Joined: Thu May 19, 2005 11:02 am
Location: CTCN, University of Plymouth
Contact:

reading environment variables in (parallel) neuron

Post by ubartsch »

Hi,
I have a hopefully simple question:

I would like to run multiple versions of my parallel(!) network with different parameter sets. Therefore a started intance of nrn would need some kind of awareness which process it is.
Multiple ideas how to realise that:

Is there any way to read MPI environment variables directly from nrn?
(Which would be most handy!)

Is there a way to read shell environment variables?

Is there any other way apart from here documents to pass variables to neuron.
(The qeue managing software on our cluster doest doesn't deem to like this type of scripting?!)

Many thanks for some hints
Cheers
Ullrich
hines
Site Admin
Posts: 1692
Joined: Wed May 18, 2005 3:32 pm

Post by hines »

Do you mean you are simultaneously running distinct mpiexec or mpirun commands with nrniv as the program along with a -mpi argument?

If there is only one mpiexec then everyone can figure out what to do based on their ParallelContext.id rank value.

But in the first case, sounds like what is really needed is a

Code: Select all

-e "statements"
so every rank of a given mpiexec nrniv instance has the same statement but they are different for different mpiexec groups. Anyway, for now you can work around the absence of -e and the strange limitations of your queue system, by using environment variables that you read from a mod file. ie. wrap getenv to make it available to the hoc interpreter.

Actually, perhaps your queue system is not strange and the reason that here scripts don't work is because mpiexec nrniv does not give a stdin to nrniv. I see

Code: Select all

[hines@localhost ~]$ mpiexec -help

usage:
...
mpiexec [global args] [local args] executable [args]
   where global args may be
...
      -s <spec>                    # direct stdin to "all" or 1,2 or 2-4,6
...
hines
Site Admin
Posts: 1692
Joined: Wed May 18, 2005 3:32 pm

Post by hines »

A -c "statement" option has been added.
See https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=234
ubartsch
Posts: 34
Joined: Thu May 19, 2005 11:02 am
Location: CTCN, University of Plymouth
Contact:

Post by ubartsch »

Thanks, very much!
I spoke to our admin and the new Neuron version will be installed "soon".

But in the mean time I would need a quick hack to run my programs.
This is the mod file I've written:

Code: Select all

TITLE getenv

COMMENT
get environment vars for parallel batch simulation
ENDCOMMENT

NEURON {
	GLOBAL jobid
	GLOBAL taskid
}

ASSIGNED{
	jobid
	taskid
}

VERBATIM
#include <stdio.h>
#include <stdlib.h>

//static double jobid, taskid;
static loadenv() 
{
char *j, *t;
  j = getenv("JOB_ID");
  //printf ("%s \n", j);
  jobid=atof(j);
  t = getenv("SGE_TASK_ID");
  taskid=atof(t); 
}

loadenv();

ENDVERBATIM

And it compiles fine, but Neuron doesn't seem to read the variables.
I've put that mech in dummy_cell template and after creating the cell the value of jobid_getenv is still the standard value from definition (0).
I couldn't figure out how to make these variables availbale to hoc.
The nrnivmodl generated c file suggest they are declared as global varibales and pointer have been set but something is missing I guess.

Many thanks for a final hint.

Cheers
Ullrich
Post Reply