c c----------------------------------------------------------------------- c c ****** Program to read a 2D field from a text file. c c----------------------------------------------------------------------- c implicit none integer :: ndim,nt,np,ifscales real, dimension(:), allocatable :: t,p real, dimension(:,:), allocatable :: f character(256) :: fname c c----------------------------------------------------------------------- c write (*,*) write (*,'(a,$)') 'Enter input file name: ' read (*,'(a)') fname c open (1,file=fname,status='old') c write (*,*) write (*,*) '### Reading file: ',trim(fname) c c ****** Read the number of dimensions. c read (1,*) ndim c if (ndim.ne.2) then write (*,*) write (*,*) '### ERROR: This is not a 2D file!' write (*,*) 'NDIM = ',ndim stop end if c c ****** Read the dimensions. c read (1,*) nt,np c write (*,*) write (*,*) '### Read in the dimensions:' write (*,*) 'NT = ',nt write (*,*) 'NP = ',np c c ****** Check if scales are present. c read (1,*) ifscales c if (ifscales.eq.0) then write (*,*) write (*,*) '### ERROR: scales are not present!' stop end if c allocate (t(nt)) allocate (p(np)) allocate (f(nt,np)) c c ****** Read the scales. c read (1,*) t read (1,*) p c c ****** Read the 2D data. c read (1,*) f c write (*,*) write (*,*) '### Data read successfully:' write (*,*) 'Field (min) = ',minval(f) write (*,*) 'Field (max) = ',maxval(f) c close (1) c end