subroutine plotit(step)
character(len=*),intent(in),optional :: step
character(len=10) :: step_local
character(len=80) :: line
character(len=*),parameter :: g='(*(g0,1x))'
integer :: ierr
integer :: i
if(present(step))then
select case(step)
case('start')
call process_open_write('gnuplot --persist',fp,ierr)
write(stdout,*)'WRITETEST: process is opened with status ',ierr
call process_writeline( [character(len=80) :: &
'set terminal X11',&
'set nokey',&
'set title " example of gnuplot data and command file generation"'],&
fp,ierr)
case('stop')
call process_close(fp,ierr)
write(*,*)'WRITETEST: process closed with status ',ierr
end select
else
call process_writeline( '$set1 <<eod' ,fp,ierr)
ierr=0
do i = 1 , n
write (line,g)' ', x(i) , y(i) !x! write the x,y array as coordinates to be plotted.
call process_writeline(trim(line),fp,ierr)
if(ierr.lt.0)then
write(*,*)'WRITETEST: ierr is ',ierr
exit
endif
enddo
call process_writeline('eod',fp,ierr)
call process_writeline('plot $set1 with lines lw 4',fp,ierr)
endif
end subroutine plotit