WRITE_VECTOR_DATA writes vector data to a file, for plotting by GNUPLOT.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*) | :: | data_file_name | ||||
integer | :: | n | ||||
real | :: | x(n) | ||||
real | :: | y(n) | ||||
real | :: | dx(n) | ||||
real | :: | dy(n) | ||||
integer | :: | ierror |
subroutine write_vector_data ( data_file_name, n, x, y, dx, dy, ierror ) ! !******************************************************************************* ! !! WRITE_VECTOR_DATA writes vector data to a file, for plotting by GNUPLOT. ! ! ! Discussion: ! ! Each vector is described by 4 values, X, Y, dX, dY, indicating that ! a vector is to be drawn from (X,Y) to (X+dX,Y+dY). ! ! Modified: ! ! 22 February 2001 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, character ( len = * ) DATA_FILE_NAME, the name of the data file. ! ! Input, integer N, the number of vectors. ! ! Input, real X(N), Y(N), DX(N), DY(N), the vector data. ! ! Output, integer IERROR, nonzero if an error occurred. ! implicit none ! integer n ! character ( len = * ) data_file_name real dx(n) real dy(n) 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_VECTOR_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_VECTOR_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), dx(i), dy(i) end do close ( unit = file_unit ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'WRITE_VECTOR_DATA:' write ( *, '(a)' ) ' Wrote the GNUPLOT vector data file "' // & trim ( data_file_name ) // '"' return endsubroutine write_vector_data