program ts_hr_read c c This program reads ascii-format temperature and salinity c files, for example t15n38w_10m.ascii. It creates an array called c ts, 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, August 1999 c implicit none c integer nz, nt parameter(nz = 20, nt = 1000000) c integer k, n, m c integer nblock, nk, ndep, nn, ntime, n1, n2 c integer kdep(nz), idep(nz) integer iqual(nz,nt), idate(nt), ihms(nt) c real flag, depth(nz), ts(nz,nt) c character infile*80, header*132 c c ....................................................................... c write(*,*) ' Enter the input temperature or salinity 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) ntime, ndep, nblock 10 format(63x,i7,7x,i3,8x,i3) c write(*,*) ntime, ndep, nblock c c Read the missing data flag c if(infile(1:1) .eq. 't') then read(1,20) flag else if(infile(1:1) .eq. 's') then read(1,21) flag else write(*,*) ' Error: cannot identify file type' stop endif c 20 format(40x,f7.3) 21 format(39x,f8.3) c write(*,*) flag c c Initialize ts array to flag and iqual array to 5. c do k = 1, nz do n = 1, nt ts(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), ihms(n), (ts(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) 140 format(17x,i7) 150 format(17x,i7) 160 format(x,i8,x,i6,x,f7.3,x,i1) c close(1) c c Write out the depth, data, and quality arrays to the c standard output. c write(*,*) 'depth = ', (depth(k),k=1,ndep) 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, ntime write(*,70) idate(n), ihms(n),(ts(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