Passing a variable to #BSUB -n in a LSF file

Hi There!

I'm writing this LSF script to make it easier to send jobs to a cluster when varying certain parameters. At one point I'd like to do something like:

set NPROC = 10

and later on call BSUB using something like:

#BSUB -n $NPROC

unfortunately for me, this throws an error:

Bad argument for option -n. Job not submitted.

Anyone with an idea on how to pass BSUB a variable? With this example it sounds sort of roundabout, but sometimes you want to do some arithmetic with $NPROC before passing it to #BSUB and then being able to do it this way may be something very useful.

Thanks!:slight_smile:

---------- Post updated at 06:01 PM ---------- Previous update was at 05:57 PM ----------

Sorry, I read the post back and I wanted to make sure the problem is clear, this works straight away:

#BSUB -n 10

This doesn't work

set NPROC = 10
#BSUB -n $NPROC

Thanks

What is your system? What is your shell?

Most shells don't allow whitespace wherever you want like that.

VAR = "stuff"
VAR="stuff"
1 Like

Thanks for your help Corona688, I'm sorry, using -tcsh on RedHat.

I think the problem is more related with #BSUB itself, because in some other part of the code I have things like:

#! bin/tcsh -f

set VAR_1 = 5
set VAR_1 = 10

@ sum = VAR_1 + VAR_2

and that works alright

---------- Post updated 08-16-11 at 10:05 AM ---------- Previous update was 08-15-11 at 07:32 PM ----------

I can't post links yet, but if you google bsub you'll find its man page straight away.

It can accept commands through the command line like:

>bsub -n 10

or through standard input doing

>bsub < myscript.lsf

they way bsub reads commands from standard input is by including the keyword #BSUB on the file, so you would have to write on it:

#! /bin/tcsh -f
#BSUB -n 10

I think that the problem is that when I write inside myfile.lsf:

#! /bin/tcsh -f
set NPROC = 10
#BSUB -n $NPROC

The variable $NPROC is being read as a string on standard input, instead of as a variable.

anyone with an idea of how to solve this? I'm running red had linux and TC shell

Thanks!

There are lots of very good reasons not to program in TCSH. If you're not being forced to use it, I'd suggest learning the Bourne shell.

But meanwhile, this syntax works both in BASH and TCSH:

./command <<EOF
stuff to feed into command's stdin
This can include $VARIABLES and `commands`
EOF

The final EOF must be at the beginning of the line with NO spaces in front.

Thanks again.

I do not think I have understood your suggestion properly enough to apply it.

Should I do something like:

>set NPROC = 10
>bsub <<$NPROC < base.lsf

and then in base.lsf just do something like:

#! /bin/tcsh

#BSUB -n $NPROC

That doesn't even make sense to me. If you could please be more explicit on your suggestion so I can understand it that would be very helpful. Thanks!