write_xyy_plots Subroutine

public subroutine write_xyy_plots(command_file_name, data_file_name, add_lines, title, ncol, ierror)

WRITE_XYY_PLOTS writes GNUPLOT commands to make multiple (X,Y) plots.

Arguments

Type IntentOptional Attributes Name
character(len=*) :: command_file_name
character(len=*) :: data_file_name
character(len=*), optional :: add_lines
character(len=*), dimension(1:ncol) :: title
integer :: ncol
integer :: ierror

Calls

proc~~write_xyy_plots~~CallsGraph proc~write_xyy_plots write_xyy_plots proc~get_unit get_unit proc~write_xyy_plots->proc~get_unit

Called by

proc~~write_xyy_plots~~CalledByGraph proc~write_xyy_plots write_xyy_plots proc~test02 test02 proc~test02->proc~write_xyy_plots program~test_gnufor test_gnufor program~test_gnufor->proc~test02

Source Code

subroutine write_xyy_plots ( command_file_name, data_file_name, add_lines, title, &
  ncol, ierror )
!
!*******************************************************************************
!
!! WRITE_XYY_PLOTS writes GNUPLOT commands to make multiple (X,Y) plots.
!
!
!  Discussion:
!
!    The first column of data is assumed to be the independent variable, X.
!    Separate plots are made of X versus all the other columns of data.
!
!  Modified:
!
!    23 February 2001
!
!  Author:
!
!    John Burkardt
!
!  Parameters:
!
!    Input, character ( len = * ) COMMAND_FILE_NAME, the name of the
!    command file.
!
!    Input, character ( len = * ) DATA_FILE_NAME, the name of the data file.
!
!    Input, integer NCOL, the number of columns of data.
!
!    Output, integer IERROR, nonzero if an error occurred.
!
  implicit none
!
  character ( len = * ) command_file_name
  character ( len = * ) data_file_name
  character ( len = * ), optional :: add_lines
  integer file_unit
  integer i
  integer ierror
  integer ios
  integer ncol
  character ( len = * ), dimension(1:ncol) :: title

!
!  Write the data file.
!
  ierror = 0

  call get_unit ( file_unit )

  if ( file_unit == 0 ) then
    ierror = 1
    write ( *, '(a)' ) ' '
    write ( *, '(a)' ) 'WRITE_XYY_PLOTS - Fatal error!'
    write ( *, '(a)' ) '  Could not get a free FORTRAN unit.'
    return
  end if

  open ( unit = file_unit, file = command_file_name, status = 'replace', &
    iostat = ios )

  if ( ios /= 0 ) then
    ierror = 2
    write ( *, '(a)' ) ' '
    write ( *, '(a)' ) 'WRITE_XYY_PLOTS - Fatal error!'
    write ( *, '(a)' ) '  Could not open the output file.'
    return
  end if

  write ( file_unit, '(a)' ) 'set title "GNUFOR plot"'
  write ( file_unit, '(a)' ) 'set xlabel "x"'
  write ( file_unit, '(a)' ) 'set ylabel "y"'

  if (present(add_lines)) then
   write ( file_unit, '(a)' ) trim(add_lines)
  endif

  do i = 1, 1
    write ( file_unit, '(a,i2,a)' ) 'plot "' // trim ( data_file_name ) // '" using 1:', i+1, ' with lines title "' // trim(title(i)) // '", \'
  end do
  do i = 2, ncol-2
    write ( file_unit, '(a,i2,a)' )       '"'// trim ( data_file_name ) // '" using 1:', i+1, ' with lines title "' // trim(title(i)) // '", \'
  end do
  do i = ncol-1, ncol-1
    write ( file_unit, '(a,i2,a)' )       '"'// trim ( data_file_name ) // '" using 1:', i+1, ' with lines title "' // trim(title(i)) // '"'
  end do
  write ( file_unit, '(a)' ) 'pause -1  "Hit return to continue"'
  write ( file_unit, '(a)' ) 'q'

  close ( unit = file_unit )

  write ( *, '(a)' ) ' '
  write ( *, '(a)' ) 'WRITE_XYY_PLOTS:'
  write ( *, '(a)' ) '  Wrote the GNUPLOT XYY plots command file "' // &
    trim ( command_file_name ) // '"'

  return
endsubroutine write_xyy_plots