program tsd_hr_read c c Feb 1999 c c This program reads TAO anonymous FTP ascii-format temp, sal, and den c files, for example 8n110w.tmp. It creates an array called tsd, c which is evenly spaced in time, and an array called iqual c which contains the data quality for each depth. c c You can easily adapt this program to your needs. c c Programmed by Dai McClurg, NOAA/PMEL/OCRD, April 1999 c integer nz, nt parameter(nz = 50, nt = 100000) c integer k, n, m c integer nblock, nk, ndep, nn, nday, n1, n2 c integer kdep(nz), iqual(nz,nt), idate(nt), ihour(nt), idep(nz) c real flag, depth(nz), tsd(nz,nt) c character infile*80, header*132 c c ....................................................................... c write(*,*) ' Enter the input hourly tmp file name ' read(*,'(a)') infile c open(1,file=infile,status='old',form='formatted') c c Read total number of days, depths and blocks of data. c read(1,10) nday, ndep, nblock 10 format(63x,i7,7x,i3,8x,i3) c write(*,*) nday, ndep, nblock c idot = index(infile,'.') c c Read the missing data flag c if(infile(idot+1:idot+3) .eq. 'tmp') then read(1,20) flag else if(infile(idot+1:idot+3) .eq. 'den') then read(1,21) flag else if(infile(idot+1:idot+3) .eq. 'sal') then read(1,22) flag endif c 20 format(40x,f7.2) 21 format(47x,f7.2) 22 format(39x,f7.2) c write(*,*) flag c c Initialize tsd array to flag and iqual array to 5. c do k = 1, nz do n = 1, nt tsd(k,n) = flag iqual(k,n) = 5 enddo enddo c c Read the data c do m = 1, nblock read(1,30) n1, n2, nn, nk read(1,140) (kdep(k),k=1,nk) read(1,150) (idep(kdep(k)),k=1,nk) do k = 1, nk depth(kdep(k)) = real(idep(kdep(k))) enddo read(1,'(a)') header do n = n1, n2 read(1,160) idate(n), ihour(n), (tsd(kdep(k),n),k=1,nk), . (iqual(kdep(k),n),k=1,nk) enddo enddo c 30 format(54x,i8,3x,i8,x,i8,7x,i3) c 140 format(17x,i7) 150 format(17x,i7) c 160 format(x,i8,x,i6,x,f7.3,x,i1) c close(1) c c Write out the depth, temperature, and quality arrays to the c standard output. c write(*,*) 'depth = ', (depth(k),k=1,ndep) c c Redefine nk to be ndep so we can use format 60 above. c c For some files this statement may be too long for your max output c record length on your terminal. If so, comment out these lines. c nk = ndep c do n = 1, nday write(*,70) idate(n), ihour(n),(tsd(k,n),k=1,ndep), . (iqual(k,n),k=1,ndep), n enddo c 70 format(x,i8,x,i6,x,f7.3,x,i1,i7) c end