0

Does anyone know how to run a Python matplotlib routine from Fortran? The way I am currently doing it is with:

            call system('python plottingV.py')

However, I'd like to be able to interact with the script (I want to give the python routine a different input file on each iteration of a do loop. Any ideas?

2
  • You could manipulate the argument to system to provide an argument to your script... Commented Jul 9, 2015 at 18:32
  • 1
    See e.g. here. This might also be of interest. Commented Jul 9, 2015 at 18:34

2 Answers 2

2

The simplest thing would be to give your python script a command line parameter, namely the input file name. Something like:

call system ('python plottingV.py myInputFile1.dat')

You can then use sys.argv[1] to obtain the input file name in your python script.

Sign up to request clarification or add additional context in comments.

3 Comments

Is there any reason to recommend system over Fortran's execute_command_line?
execute_command_line would be better, since it is standard, but it is not yet supported by all compilers
Notably Intel Fortran did not recently support execute_command_line yet.
-1

Here is a basic pyplot-fortran interface that might be useful.

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.