c----------------------------------------------------------- c Returns two double precision vectors 'v1', 'v2' c read from file 'fname' (two numbers per line). c If 'fname' is the string '-', the vectors are read c from standard input. c----------------------------------------------------------- subroutine dvvfrom(fname,v1,v2,n,maxn) implicit none integer indlnb, getu character*(*) fname integer n, maxn real*8 v1(maxn), v2(n) integer ustdin parameter ( ustdin = 5 ) real*8 v1n, v2n integer ufrom, rc c----------------------------------------------------------- c Intialize c----------------------------------------------------------- n = 0 c----------------------------------------------------------- c Read from stdin? c----------------------------------------------------------- if( fname .eq. '-' ) then c----------------------------------------------------------- c Set unit number to stdin default c----------------------------------------------------------- ufrom = ustdin else c----------------------------------------------------------- c Get an available unit number c----------------------------------------------------------- ufrom = getu() c----------------------------------------------------------- c Open the file for formatted I/O c----------------------------------------------------------- open(ufrom,file=fname(1:indlnb(fname)), & form='formatted',iostat=rc) if( rc .ne. 0 ) then c----------------------------------------------------------- c Couldn't open the file, print error message c and return. c----------------------------------------------------------- write(0,*) 'dvvfrom: Error opening ', & fname(1:indlnb(fname)) return end if end if c----------------------------------------------------------- c Input numbers into vectors (two per line) until c EOF or maximum allowable number read c----------------------------------------------------------- 100 continue read(ufrom,*,iostat=rc,end=200) v1n, v2n if( rc .eq. 0 ) then n = n + 1 if( n .gt. maxn ) then write(0,*) 'dvfrom: Read maximum of ', & maxn, ' from ', & fname(1:indlnb(fname)) n = maxn return end if v1(n) = v1n v2(n) = v2n end if go to 100 200 continue c----------------------------------------------------------- c If we are reading from a file, close the file. c This releases the unit number for subsequent use. c----------------------------------------------------------- if( ufrom .ne. ustdin ) then close(ufrom) end if return end