Run fortran code requesting data read on jupyter-notebook with python restart kernel

1

Jupyter notebook restart when you run a fortran code that requests data entry, as follows:

Notethattheavariableshouldbeprovidedsoonafterthef1call.However,anerroroccursandthekernelrestart:

Note: The code works fine without the statement excerpt of a and reading a

    
asked by anonymous 17.09.2016 / 14:46

1 answer

1

The problem happens because the jupyter notebook can not process the standard stdin in sub-processes.

Even if you run a shell command (also executed in a subprocess) that uses the default input, the kernel will "hang" (eventually emitting a restart message or not).

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

on 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 workaround for this problem: read the input values in the Python code and send these values as parameters for the Fortran routine:

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

    
22.09.2016 / 06:40