F. Valenti
F. Valenti

Reputation: 11

Passing command line arguments to gnuplot in Windows

I have a Fortran 90 program that outputs some data to a .txt file. The data is to be plotted with gnuplot.

I was able to launch gnuplot with

CALL SYSTEM("start wgnuplot")

which is equivalent to type

start gnuplot 

in the Windows command line prompt.

But then, I would like to have the program telling gnuplot what to do next, i.e., changing directory to the right one, and plotting my file.txt.

All in all this boils down to a simpler question:

How do I pass a command line in Windows that launches gnuplot and gives it some additional commands?

I tried to do that with something even easier like plotting y=x. In a normal gnuplot windows this is just plot x.

From the cmd.exe (which is what is called by Fortran's CALL SYSTEM() )I've tried:

start wgnuplot plot x
start wgnuplot plot x -pause
start wgnuplot plot x -persist
start wgnuplot plot x -noend
start wgnuplot plot x /noend

And others, including every possible variant with or without quotation marks, for instance

start wgnuplot "plot x -persist" 

etc.

So far the only one that works is the basic

start gnuplot

Which starts gnuplot indeed. But then I don't know how to add the next commands. Once I have a working command line input I believe I will just have to plop it into the CALL SYSTEM argument to have my Fortran program doing all the work.

I could only find instructions on how to achieve this on a UNIX-like machine, but not on Windows. Any help would be appreciated.

Background info: Windows 8, Code::Blocks, gnuplot 5.0 patchlevel 1

Upvotes: 1

Views: 2702

Answers (1)

bibi
bibi

Reputation: 3765

you need to use named pipes which are very easy in C and unix:

http://tldp.org/LDP/lpg/node11.html and see this answer: https://stackoverflow.com/a/14027358/2743307

in Fortran and UNIX you can use the shell mkfifo command: https://genomeek.wordpress.com/2012/05/07/tips-reading-compressed-file-with-fortran-and-named-pipe/

Upvotes: 1

Related Questions