fortran - How to let gnuplot window persist and the main program not freeze -


i have program in fortran calculates file, say, named wvfunc3d.dat want visualize gnuplot in real time during execution of program. after code creates file, put in program string

jret=system('gnuplot wf3d.plt') 

the script file wf3d.plt has string , looks like:

splot 'wvfunc3d.dat' w l 

all of draws plot want see, but, known, disappears. know, there option avoid closing of window,

jret=system('gnuplot -persist wf3d.plt') 

that lets plot not disappear, execution of fortran program freezes until close window graph.

so, want plot persist until have new data, automatically updated after new call of command in fortran, need program run calculations! there way solve problem? use windows xp.

i think may able use execute_command_line instead of system achieve want. allows include wait option when set .false. allows fortran code keep running. can add sleep , reread gnuplot script (e.g. sleep 1 , reread) suggested in post.

if doesn't work, consider multi-threaded strategy ( openmp or mpi in fortran). personally, run gnuplot @ same time , trigger update of plotted data pressing a key. use linux cannot test windows minimal example works me is,

program gnuplot     implicit none      logical :: gnuplot_open = .false.     integer :: i,t,n,redraw     real(kind(0.d0)),dimension(:),allocatable  :: x,y     real(kind(0.d0)),parameter:: pi=4.d0*atan(1.d0)      n = 1000     allocate(x(n),y(n))      redraw = 100     t = 1,300000         i=1,n             x(i) = 6.d0*i/n*pi             y(i) = sin(x(i)+t*0.2)         enddo         if (mod(t,redraw) .eq. 0)             open(1,file='./tempout',status='replace')             i=1,n                 write(1,*) x(i),y(i)             enddo             close(1,status='keep')         endif         if (.not. gnuplot_open)             call execute_command_line('gnuplot --persist plot_tempout', wait=.false.)              gnuplot_open = .true.         endif      enddo  end program gnuplot 

and plot_tempout is,

plot 'tempout' u 1:2 w l pause 0.1 reread 

Comments