How to pass environment variable in Sun Grid Engine?

I am trying to imagine a (series) of assignments for SGE (FWIW, this is the sequence of modeling molecular dynamics of Gromacs) in which all assignments are identical except for the suffix such as input01 , input02 , etc. I wrote the commands to run in such a way that the suffix is ​​correctly processed by the sequence of commands.

However, I cannot find a way to get the exec environment to get this variable. According to the qsub man page, -v var should do this.

 $ export i=19 $ export | grep ' i=' declare -xi="19" $ env | grep '^i=' i=19 

Then send the following script ( run.sh ) to find out if it is received:

 if [ "x" == "x$i" ]; then echo "ERROR: \$i not set" else echo "SUCCESS: \$i is set" fi 

I submit the job as follows (in the same session as the export command above):

 $ qsub -N "test_env" -cwd -vi run.sh Your job 4606 ("test_env") has been submitted 

The error stream is empty, and the output stream has:

 $ cat test_env.o4606 ERROR: $i not set 

I also unsuccessfully tried the following commands:

 $ qsub -N "test_env" -cwd -vi -V run.sh $ qsub -N "test_env" -cwd -V run.sh $ qsub -N "test_env" -cwd -vi=19 -V run.sh $ qsub -N "test_env" -cwd -vi=19 run.sh 

If I add the line i=19 to the beginning of run.sh , the output will be as follows:

 $ cat test_env.o4613 SUCCESS: $i is set as 19 

Now I am considering the possibility of creating one file per task, which will be essentially the same, but will have the line i=xx as the first. It does not look very practical, but it will be a solution.

Would there be a better solution?

+4
source share
3 answers

What I always did is the following:

 ##send.sh export a=10 qsub ./run.sh 

and script run.sh:

 ##run.sh #$ -V echo $a 

when I call send.sh, .o has an output of 10.

+6
source

Assuming your variable is just an incremental counter: you can use Array Jobs to achieve this. This will set the environment variable $SGE_TASK_ID to a counter, which can then be copied to $i or used directly.

If the variable is something else, then I think you will have to create several work scenarios and send them each; that the "solution" I use when I have many tasks with different parameters.

+1
source

I'm not sure if you can pass variables by name via qsub. I had success with missing values ​​(you probably should write the front of the script for this, and not do it interactively):

 $ export ii=19 $ qsub -N "test_env" -cwd -vi=$ii run.sh 
+1
source

Source: https://habr.com/ru/post/1401585/


All Articles