program shipint c c This program reads the ron brown ship motion data files c and interpolates them to the pofiler moment times. c Output contains speed over ground, course over ground, and c gyro heading, i.e. the variables needed to correct c the profiler moments for ship motion. c implicit real*8 (a-h,o-z) real*8 ptim(9000),stimg(200000),spd(200000),crs(200000), x hed(200000),tdming(9000),stimn(200000),tdminn(9000) integer ibm(9000),iphr(9000),ipm(9000),ips(9000) character pjday*3,shipfn*100,atxt*100,ctime*8 c c read input information c open(unit=1,file='mom.inp') read(1,*) read(1,*) ibeg read(1,4) shipfn 4 format(a100) nb = len_trim(shipfn) close(unit=1) c write(pjday(1:3),7) ibeg 7 format(i3.3) open(unit=1,err=998,file='times'//pjday//'.dat') open(unit=2,err=998,file=shipfn(1:nb)) c c read the profiler moment times c NOTE: time marks beginning of dwell time c do 199 i = 1,9000 read(1,*,end=200) ibm(i),ipyr,ipday,iphr(i), x ipm(i),ips(i) ptim(i) = float(ipday)+float(iphr(i))/24.+ x float(ipm(i))/(60.*24.)+float(ips(i))/(24.*3600.) 199 continue 200 ict = i-1 c close(unit=1,status='delete') close(unit=1) c c read the ship motion data file and extract day's data. c include the hour before and hour after selected day. c nshp = 0 do 299 i = 1,200000 read(2,*,end=300) fjdayg,fjdayn,x1,x2,x3 c bad data check if(x1.gt.998.or.(x2.gt.998.or.x3.gt.998.)) go to 298 c nshp = nshp+1 stimg(nshp) = fjdayg stimn(nshp) = fjdayn crs(nshp) = x2 c convert speed from knots to m/s spd(nshp) = x3*0.5148 hed(nshp) = x1 298 continue 299 continue 300 continue close(unit=2) c print *, nshp c c find ship motion time closest to moment time c NOTE: assuming that ship time is at beginning of c sampling period (i.e., like profiler) c write output to file c open(unit=3,file='shipcr'//pjday//'.dat') c open(unit=3,file='shipcr.dat') c do 399 i = 1,ict spduse = -99.9999 heduse = -99.9999 crsuse = -99.9999 tdming(i) = 0.04167 tdminn(i) = 0.04167 if(nshp.gt.0) then do 349 j = 1,nshp tdifg = dabs(stimg(j)-ptim(i)) tdifn = dabs(stimn(j)-ptim(i)) if(tdifg.lt.tdming(i)) then tdming(i) = tdifg spduse = spd(j) crsuse = crs(j) endif if(tdifn.lt.tdminn(i)) then tdminn(i) = tdifn heduse = hed(j) endif 349 continue endif c print *, nshp,i,tdif,spduse write(3,350) ibm(i),iphr(i),ipm(i),ips(i), x spduse,heduse,crsuse,tdming(i) 350 format(i1,3(1x,i2.2),3(1x,f8.4),1x,f7.4) 399 continue close(unit=3) 998 continue c stop end