subroutine itw(iwin,icomp,mw,win,npts,ier) c c identify time window to process c a.tento 04/02 v.1.0 c a.tento 06/02 v.1.1 -> start & end --> samples c a.tento 10/02 v.1.2 -> back to start & end in seconds c a.tento 05/03 v.1.3 -> no static max_window_length (maxwinlen in c main.h) needed. --> mw (dynamic) c changed argument list c -> offset_rem:r_mean:win c c implicit none include 'main.h' include 'window.h' include 'times.h' include 'parameters.h' c integer iwin, icomp, mw, npts, ier real win dimension win(*) c integer i, ibegin, iend, k, nw real dt, ave character argout(20)*200, sep2*1 parameter (sep2 = ':') c ier = 0 dt = sampling_rate c write(*,*)' itw --------------' c write(*,*)iwin c write(*,*)dt c write(*,*)n_samples c write(*,*)start_time(iwin) c write(*,*)end_time(iwin) iend = int(end_time(iwin)/dt+0.5) + 1 ibegin = int(start_time(iwin)/dt+0.5) + 1 if ( iend .gt. n_samples ) goto 99 if ( ibegin .gt. n_samples ) goto 99 if ( ibegin .lt. 1 ) goto 99 npts = iend - ibegin + 1 c write(*,*)ibegin c write(*,*)iend c write(*,*)npts c write(*,*)' itw --------------' ccccccccccccccccccccccccccc bug chase c if ( icomp .eq. 1) then c write(*,*)' window #',iwin, ' start, end, istart, iend, npts' c write(*,*)start_time(iwin),end_time(iwin),dt c write(*,*)ibegin, iend c write(*,*)npts c endif ccccccccccccccccccccccccccc bug chase if ( npts .lt. 1 ) goto 99 if ( npts .gt. mw ) goto 98 c call split3(offset_rem,argout,sep2,nw) c if (argout(1) .eq. 'r_mean' .and. argout(2) .eq. 'win') then c ave=0.0 do 2 i = ibegin, iend ave = ave + datath(i,icomp) 2 continue ave = ave/float(iend - ibegin +1) k = 0 do 3 i = ibegin, iend k = k + 1 win(k) = datath(i,icomp)-ave 3 continue c else c k = 0 do 1 i = ibegin, iend k = k + 1 win(k) = datath(i,icomp) 1 continue c endif c return c c ... incorrect start time or end time 99 write(*,*)' Start sample or end sample incorrectly specified ' write(*,*)' Number of points of time history : ', n_samples, # ' Window number : ', iwin write(*,*)' Start sample : ',ibegin,' End sample :', iend write(*,100)data_file(iwin) ier = 1 return c c ... window exceeding dimension 98 write(*,*)' Requested window exceeds current dimension ' write(*,*)' requested # point : ', npts, ' current dimension', # mw write(*,100)data_file(iwin) ier = 3 return c c 100 format(1x,a200) c end