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?

naomig
  • 271
  • 1
  • 7
  • 12
  • You could manipulate the argument to `system` to provide an argument to your script... – Alexander Vogt Jul 09 '15 at 18:32
  • 1
    See e.g. [here](https://stackoverflow.com/questions/6146516/writing-multiple-output-files-in-fortran). [This](https://stackoverflow.com/questions/30643905/converting-integer-to-character-in-fortran90/30646472) might also be of interest. – Alexander Vogt Jul 09 '15 at 18:34

2 Answers2

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.

Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
-1

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

Time Laird
  • 169
  • 1
  • 3