WRITE_XYZGRID_DATA writes a file of XYZ grid data.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*) | :: | data_file_name | ||||
integer | :: | nx | ||||
integer | :: | ny | ||||
real | :: | xyz(3,nx,ny) | ||||
integer | :: | ierror |
subroutine write_xyzgrid_data ( data_file_name, nx, ny, xyz, ierror ) ! !******************************************************************************* ! !! WRITE_XYZGRID_DATA writes a file of XYZ grid data. ! ! ! Discussion: ! ! It is assumed that values of Z are available on a regular NX by NY grid ! of (X,Y) points. ! ! The form of the data file requires that all the data for a given value ! of Y be listed, followed by a blank line, followed by the data for ! another value of Y. ! ! Example: ! ! Here is a grid data file for a 3 by 3 grid, with Z = X + Y. ! ! 0.0 0.0 0.0 ! 1.0 0.0 1.0 ! 2.0 0.0 2.0 ! ! 0.0 1.0 1.0 ! 1.0 1.0 2.0 ! 2.0 1.0 3.0 ! ! 0.0 2.0 2.0 ! 1.0 2.0 3.0 ! 2.0 2.0 4.0 ! ! Modified: ! ! 23 February 2001 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, character ( len = * ) DATA_FILE_NAME, the name of the data file. ! ! Input, integer NX, NY, the dimensions of the grid. ! ! Input, real XYZ(3,NX,NY), the XYZ grid data to be written. ! ! Output, integer IERROR, nonzero if an error occurred. ! implicit none ! integer nx integer ny ! character ( len = * ) data_file_name integer file_unit integer i integer ierror integer ios integer j real xyz(3,nx,ny) ! ierror = 0 call get_unit ( file_unit ) if ( file_unit == 0 ) then ierror = 1 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'WRITE_XYZGRID_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_XYZGRID_DATA - Fatal error!' write ( *, '(a)' ) ' Could not open the output file.' return end if do j = 1, ny do i = 1, nx write ( file_unit, * ) xyz(1:3,i,j) end do write ( file_unit, '(a)' ) end do close ( unit = file_unit ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'WRITE_XYZGRID_DATA:' write ( *, '(a)' ) ' Wrote the GNUPLOT XYZ grid data file "' // & trim ( data_file_name ) // '"' return endsubroutine write_xyzgrid_data