write_polar_data Subroutine

private subroutine write_polar_data(data_file_name, n, x, y, ierror)

Arguments

Type IntentOptional Attributes Name
character(len=*) :: data_file_name
integer :: n
real :: x(n)
real :: y(n)
integer :: ierror

Calls

proc~~write_polar_data~~CallsGraph proc~write_polar_data write_polar_data proc~get_unit get_unit proc~write_polar_data->proc~get_unit

Source Code

subroutine write_polar_data ( data_file_name, n, x, y, ierror )
  implicit none
!
  integer n
!
  character ( len = * ) data_file_name
  integer file_unit
  integer i
  integer ierror
  integer ios
  real x(n)
  real y(n)
!
  ierror = 0

  call get_unit ( file_unit )

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

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

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

  do i = 1, n
    write ( file_unit, * ) x(i), y(i)
  end do

  close ( unit = file_unit )

  write ( *, '(a)' ) ' '
  write ( *, '(a)' ) 'WRITE_POLAR_DATA:'
  write ( *, '(a)' ) '  Wrote the GNUPLOT POLAR data file "' // &
    trim ( data_file_name ) // '"'

  return
endsubroutine write_polar_data