program make_ram_sum_list c c Sontek data summary file generation c program to read ram format flagged data (*.flg) and create a summary file. c This summary file has notes and statistics which need to be copied to c the summary file for the deployment in the $drum/ram/pm*** directory. c The date that this program was run is automatically in output sum file. c Sontek notes are included in lines typed into make_ram_sum_list.in c This allows rerunning statistics without having to reenter notes c fins or nofins is specified in the input run file: make_ram_sum_list.in c c f77 -o make_ram_sum_list make_ram_sum_list.f deldt3p.f -lhpf -lmst c c c make_ram_sum_list.in: c 'datpm238/curr238a.flg' 'datpm238/pm238a.sum' fins c Sontek notes: c 10m 3.5 deg resid tilt in pitch and roll c 120m mounting clamps off 135 deg c data set bad because of low intensity and poor agreement with adcp c $exit c $pprog/make_ram_sum_list < make_ram_sum_list.in c c c program assumes that delta_t of all depths the same c determines delta-t by differencing the 1st and 2nd times c c statistics for each depth totaled by reading the quality values c for speed and dir in the curr***a.flg file c % gd for speed and dir is total of qual1+qual2+qual3+qual4 c qual 0 means data missing due to no instrument c qual 5 with 1e33 means data set bad (low intensity, drifting, pulls, etc) c qual 5 with 1e35 means data bad because no data due to instrument failure c such as battery failure c c program automatically determines the number of depths from the c length of line 3 in the *.flg file c c assumes that in line 1: deployment number is in spaces 8-10, c anchor drop is in spaces 26-38, anchor release is in spaces 40-52 character*52 line1 character*45 line2,formin character*175 line character*61 lineout2,lineout3 character*16 linejnk character*40 inname,outname integer in,out,deplym,ifirst(6),isecond(6),ilast(6) character*6 fix integer drop(6),rec(6),iq(2,6),dropjd,recjd integer ngood(2,6),n_0_iq(2,6),n_1_iq(2,6),n_2_iq(2,6) integer n_3_iq(2,6),n_4_iq(2,6),n_5_iq(2,6),n_6_iq(2,6) dimension percgd(2,6),perc0(2,6),perc1(2,6),perc2(2,6) dimension perc3(2,6),perc4(2,6),perc5(2,6),perc6(2,6) character*180 lineq,sumline character*8 acode(2,6),a33,a35 CHARACTER*24 returned_date a33 = ' 1e33' a35 = ' 1e35' out = 2 in = 3 read(5,*,err=900) inname,outname,fix write(6,'(a,a/a,a)') 1 ' Input file: ',inname,' Output file: ',outname CALL FDATE(returned_date) write(6,'(/a,a/)') ' Processed ',returned_date call fopen(in,inname,'old') call fopen(out,outname,'new') read(in,'(a)') line1 read(in,'(a)') line2 read(in,'(a)') line do i=1,40 ! get spacing of file name from inname if (inname(i:i).eq.'/') go to 7 enddo 7 nb1 = i do i=1,40 if (inname(i:i).eq.'.') go to 8 enddo 8 nb2 = i c read deployment and recovery times with julian day in curr***a.ram file read(line1,'(7x,i3,15x,2i2,i3,3i2,1x,2i2,i3,3i2)') 1 deplym,iyeardrop,drop(6),dropjd,drop(1),drop(2),drop(3), 1 iyearrec,rec(6),recjd,rec(1),rec(2),rec(3) write(out,'(a,i3,a)') 1 'Deployment ',deplym,' processed by PEP' write(out,'(5x,a,a)') ' Summary file for ',inname(nb1+1:nb2-1) write(out,'(5x,a)') line2 write(out,'(/5x,a,3x,3a,1x,5a,1x,a,3x,3a,1x,5a)') 1 ' Depl/Rec from ',line1(26:29),'/',line1(30:32),line1(33:34), 1 ':',line1(35:36),':',line1(37:38), 1 'to',line1(40:43),'/',line1(44:46), 1 line1(47:48),':',line1(49:50),':',line1(51:52) call julian(dropjd,drop(4),drop(5),drop(6),1) call julian(recjd,rec(4),rec(5),rec(6),1) write(out,'(6x,a,i2,a,i2,a,a,1x,5a,1x,a,1x, 1 i2,a,i2,a,a,1x,5a/)') 1 'Depl/Rec m/d/y:',drop(5),'/',drop(4),'/',line1(26:29), 1 line1(33:34),':',line1(35:36),':',line1(37:38),'to', 1 rec(5),'/',rec(4),'/',line1(40:43), 1 line1(47:48),':',line1(49:50),':',line1(51:52) read(in,'(a)') linejnk read(in,'(a)') linejnk c determine number of depths by length of line, each depth has 30 spaces nb=notbnk(line,175) ny = nb/29 write(6,'(a,i3/a,i3)') ' length of line3: ',nb, 1 ' no. of depths: ',ny c number of depths (ny) range from 1 to 6, with different formats c reading date/time, sp and dir for 1e33/35, and qualities if (ny.eq.1) then formin = '(2x,i4,i3,3i2,1x,16x,a8,a8,1x,2i1)' elseif (ny.eq.2) then formin = '(2x,i4,i3,3i2,1x,2(16x,a8,a8),1x,4i1)' elseif (ny.eq.3) then formin = '(2x,i4,i3,3i2,1x,3(16x,a8,a8),1x,6i1)' elseif (ny.eq.4) then formin = '(2x,i4,i3,3i2,1x,4(16x,a8,a8),1x,8i1)' elseif (ny.eq.5) then formin = '(2x,i4,i3,3i2,1x,5(16x,a8,a8),1x,10i1)' elseif (ny.eq.6) then formin = '(2x,i4,i3,3i2,1x,6(16x,a8,a8),1x,12i1)' endif nv = 2 n=0 do iy = 1,ny do iv = 1,nv n_0_iq(iv,iy)=0 n_1_iq(iv,iy)=0 n_2_iq(iv,iy)=0 n_3_iq(iv,iy)=0 n_4_iq(iv,iy)=0 n_5_iq(iv,iy)=0 n_6_iq(iv,iy)=0 enddo enddo c read flg file data: date,time,1e33 or 1e35 codes,quality codes c nv = number of variables = 2 sp and dir 100 read(in,formin,end=200) 1 iyear,jd,ih,im,is,((acode(iv,iy),iv=1,2),iy=1,ny), 1 ((iq(iv,iy),iv=1,2),iy=1,ny) n=n+1 !counter for number of data lines read c get first and second date/time to compute delta_t for later writing out if c data are averaged from original file if (n.eq.1) then ifirst(6)=iyear jd1=jd ifirst(1)=ih ifirst(2)=im ifirst(3)=is endif if (n.eq.2) then ! remember to change this to 2 isecond(6)=iyear jd2=jd isecond(1)=ih isecond(2)=im isecond(3)=is endif c increment each quality code counter 0 thru 5 do iy = 1,ny do iv = 1,nv if (iq(iv,iy).eq.0) then ! quality = 0 no instrument n_0_iq(iv,iy) = n_0_iq(iv,iy) +1 endif if (iq(iv,iy).eq.1) then ! quality = 1 highest n_1_iq(iv,iy) = n_1_iq(iv,iy) +1 endif if (iq(iv,iy).eq.2) then ! quality = 2 default n_2_iq(iv,iy) = n_2_iq(iv,iy) +1 endif if (iq(iv,iy).eq.3) then ! quality = 3 adjusted n_3_iq(iv,iy) = n_3_iq(iv,iy) +1 endif if (iq(iv,iy).eq.4) then ! quality = 4 poor n_4_iq(iv,iy) = n_4_iq(iv,iy) +1 endif if (iq(iv,iy).eq.5) then ! quality = 5 failed ! set bad due to drifting, low intensity, etc ! or no data due to battery failure if (acode(iv,iy).eq.a35) then n_6_iq(iv,iy) = n_6_iq(iv,iy) +1 ! no data: bat failure elseif (acode(1,iy).eq.a33) then n_5_iq(iv,iy) = n_5_iq(iv,iy) +1 ! data set bad: int,pull,drift else write(6,'(a)') ' Error, qual 5 without 1e33 or 1e35' endif endif enddo enddo go to 100 200 continue c write out start and stop date/time of data file, first in regular time ilast(6)=iyear jdlast=jd ilast(1)=ih ilast(2)=im ilast(3)=is call julian(jdlast,ilast(4),ilast(5),ilast(6),1) call julian(jd1,ifirst(4),ifirst(5),ifirst(6),1) c write start and stop times with julian day write(lineout2,'(1x,a,i4,a,i3,1x,i2,a,i2,a,i2,a, 1 i4,a,i3,1x,i2,a,i2,a,i2)') 1 'Data file from ',ifirst(6),'/',jd1, 1 ifirst(1),':',ifirst(2),':',ifirst(3),' to ', 1 ilast(6),'/',jdlast, 1 ilast(1),':',ilast(2),':',ilast(3) if (lineout2(24:24).eq.' ') then lineout2(24:24) = '0' endif if (lineout2(25:25).eq.' ') then lineout2(25:25) = '0' endif if (lineout2(31:31).eq.' ') then lineout2(31:31) = '0' endif if (lineout2(34:34).eq.' ') then lineout2(34:34) = '0' endif if (lineout2(47:47).eq.' ') then lineout2(47:47) = '0' endif if (lineout2(48:48).eq.' ') then lineout2(48:48) = '0' endif if (lineout2(54:54).eq.' ') then lineout2(54:54) = '0' endif if (lineout2(57:57).eq.' ') then lineout2(57:57) = '0' endif write(6,'(5x,a)') lineout2 write(out,'(5x,a)') lineout2 write(lineout3,'(1x,a,i2,a,i2,a,i4,1x,i2,a,i2,a,i2,a, 1 i2,a,i2,a,i4,1x,i2,a,i2,a,i2)') 1 'Data m/d/y: ',ifirst(5),'/',ifirst(4),'/', 1 ifirst(6), 1 ifirst(1),':',ifirst(2),':',ifirst(3),' to ', 1 ilast(5),'/',ilast(4),'/',ilast(6), 1 ilast(1),':',ilast(2),':',ilast(3) c fill in zeros for times if (lineout3(31:31).eq.' ') then lineout3(31:31) = '0' endif if (lineout3(34:34).eq.' ') then lineout3(34:34) = '0' endif if (lineout3(54:54).eq.' ') then lineout3(54:54) = '0' endif if (lineout3(57:57).eq.' ') then lineout3(57:57) = '0' endif write(6,'(5x,a/)') lineout3 write(out,'(5x,a/)') lineout3 c compare original data delta_t with delta_t of this file c if times different write out statement of difference call julian(jd1,ifirst(4),ifirst(5),ifirst(6),1) call julian(jd2,isecond(4),isecond(5),isecond(6),1) dd3 = 1440. * deldt3p(ifirst,isecond) ! in minutes read(line,'(16x,f7.1)') ddin ! assumes original delta_t here if (abs(dd3-ddin).gt..006) then ! diff greater than 10min -> averaged write(6,'(a,f7.1,a,f7.1,a)') 1 ' Original data at ',ddin,' minutes averaged to ',dd3,' minutes' endif write(6,'(a,f7.1,a,i8)') 1 ' Total number of ',dd3,' minute data lines in file:',n c get number of minutes in deployment for possible data collection c from file/data start time to anchor release dd_deploy = 1440. * deldt3p(ifirst,rec) ! in minutes c get number of possible data values assuming all depths have same deltat if (MOD(dd_deploy,dd3).eq.0) then ! total time evenly divided by deltat ipossible = dd_deploy/dd3 ! time int and release match exactly else ipossible = dd_deploy/dd3+1 ! integer truncates endif write(6,'(a,f7.1,a/a,i8)') 1 ' Number of ',dd3,' minute data lines possible in ', 1 ' deployment from start of data to anchor release:',ipossible write(6,'(a)') 1 ' Percents computed using number of data possible.' do iy = 1,ny do iv = 1,nv ! compute and write statistics for sp and dir ngood(iv,iy) = n_1_iq(iv,iy) + n_2_iq(iv,iy) + 1 n_3_iq(iv,iy) + n_4_iq(iv,iy) ! add up qual 1 thru 4 for total gd percgd(iv,iy) = 100.*ngood(iv,iy)/ipossible perc0(iv,iy) = 100.*n_0_iq(iv,iy)/ipossible perc1(iv,iy) = 100.*n_1_iq(iv,iy)/ipossible perc2(iv,iy) = 100.*n_2_iq(iv,iy)/ipossible perc3(iv,iy) = 100.*n_3_iq(iv,iy)/ipossible perc4(iv,iy) = 100.*n_4_iq(iv,iy)/ipossible perc5(iv,iy) = 100.*n_5_iq(iv,iy)/ipossible perc6(iv,iy) = 100.*n_6_iq(iv,iy)/ipossible enddo enddo c note .05 rounds up to 0.1%, .04999 is 0.0% if (fix(1:4).eq.'fins') then write(out,'(//a,a,a/)') 1 'Sontek Argonauts with fins (PEP ',returned_date,')' elseif (fix.eq.'nofins') then write(out,'(//a,a,a/)') 1 'Sontek Argonauts without fins (PEP ',returned_date,')' else write(6,'(a)') ' Error, fins or nofins must be specified' endif write(out,'(1x,a,a,i8,a)') 1 lineout2(1:5),lineout2(11:58),ipossible,' data lines' do iy = 1,ny ! cycle through depths iarg1=(iy-1)*29 + 1 iarg2=iy*29 write(out,'(/3x,a,a,2x,a,2x,a,f7.1,a,f7.1,a/)') line(iarg1+8:iarg1+17), 1 line(iarg1+2:iarg1+4),line(iarg1+5:iarg1+8), 1 line(iarg1+20:iarg1+27),percgd(1,iy),'% Speed', 1 percgd(2,iy),'% Dir' c note .05 rounds up to 0.1%, .04999 is 0.0%, check for .ge.0.05 to write do iv = 1,nv if (iv.eq.1) then write(lineq(1:13),'(5x,a)') ' Speed: ' else write(lineq(1:13),'(5x,a)') ' Dir: ' endif nb = 14 if (perc1(iv,iy).ge.0.05) then write(lineq(nb:nb+20),'(f5.1,a)') 1 perc1(iv,iy),'% qual 1, ' nb=nb+18 endif if (perc2(iv,iy).ge.0.05) then write(lineq(nb:nb+17),'(f5.1,a)') 1 perc2(iv,iy),'% qual 2, ' nb=nb+18 endif if (perc3(iv,iy).ge.0.05) then write(lineq(nb:nb+17),'(f5.1,a)') 1 perc3(iv,iy),'% qual 3, ' nb=nb+18 endif if (perc4(iv,iy).ge.0.05) then write(lineq(nb:nb+17),'(f5.1,a)') 1 perc4(iv,iy),'% qual 4, ' nb=nb+18 endif if (perc0(iv,iy).ge.0.05) then write(lineq(nb:nb+17),'(f5.1,a)') 1 perc0(iv,iy),'% no inst, ' nb=nb+18 endif if (perc5(iv,iy).ge.0.05) then write(lineq(nb:nb+17),'(f5.1,a)') 1 perc5(iv,iy),'% set bad, ' nb=nb+18 endif if (perc6(iv,iy).ge.0.05) then write(lineq(nb:nb+17),'(f5.1,a)') 1 perc6(iv,iy),'% bat fail, ' nb=nb+18 endif write(out,'(a)') lineq(1:nb-3) enddo ! iv for writing statistics for sp and dir enddo ! iy for cycling through depths 400 continue write(out,'(/)') n = 0 450 read(5,'(a180)',err=900,end=900) sumline nbsumline=notbnk(sumline,180) if (sumline(1:5).eq.'$exit') go to 900 write(out,'(3x,a)') sumline(1:nbsumline) go to 450 900 close(in) close(out) stop end