Run Fortran code that prompts reading data in jupyter-notebook with python Restart kernel

Asked

Viewed 353 times

1

Jupyter notebook Restart when running a Fortran code requesting data entry, as follows:

inserir a descrição da imagem aqui

note that the variable a must be provided immediately after the call from f1 .However, an error occurs and the Restart kernel :

inserir a descrição da imagem aqui

Note: The code works fine without the declaration snippet from a and reading of a

1 answer

1

Problem happens due to notebook jupyter unable to process standard input (stdin) in sub-processes.

Even if you execute a command shell (run, too, in a sub-process) that uses the standard input, the kernel will "crash" (eventually eminining a message from re-start or not).

Example, if you run the command below on a notebook cell:

in Windows:

!set /p variavel="Digite um valor "

or UNIX / OS X:

!read -p "Digite um valor " variavel

the kernel "hangs", waiting for input.


A possible solution to this problem: read the input values in the Python code and send these values as parameters to the Fortran routine:

x=input("Valor X ")
y=input("Valor Y ")
a=input("Valor A ")
f1(x, y, a)

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.