1

I want to run C++ simulations from a jupyter notebook. The program needs three values in input, i.e. 10, 0.2 and 0.6.

This what I am doing now and it works fine:

## Compile
! mpicxx -o main main.cpp Node.cpp Agent.cpp -std=gnu++11
## Run
! mpirun -np 1 ./main 10 0.2 0.6

But if try to declare those values before, it does not recognizes them.

a = 10
b = 0.2
c = 0.6
! mpirun -np 1 ./main a b c
2

3 Answers 3

2

you need to type it like this

a = 10
b = 0.2
c = 0.6
! mpirun -np 1 ./main {a} {b} {c}
Sign up to request clarification or add additional context in comments.

Comments

2

It looks like (from this document) you can wrap your Python variables in curly braces or else prefix them with the $ to get the to expand for the shell. E.g., ! mpirun -np 1 ./main {a} {b} {c}

Comments

1
! mpirun -np 1 ./main {a} {b} {c}

! mpirun -np 1 ./main $a $b $c

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.