subroutine gtws(fnwin,nwin,ier) c c open window_file and get time windows c a.tento 04/02 v.1.0 c a.tento 06/02 v.1.1 --> beginning and end of windows in #samples c format index (mandatory) & station name (optional) c a.tento 10/02 v.1.2 --> back tp beg. and end of windows in seconds c a.tento 02/04 v.1.3 --> call split4: blank in file_names allowed c provided that they are inside " " c a.tento 02/04 v.1.4 --> SAF default format c controlled error if window file is incorrect c c implicit none character*200 fnwin integer ier, nwin c include 'main.h' include 'window.h' c character row*1000, argout(20)*200 integer nunit, ierint, i, nw, j real wl c c call glun(nunit,ierint) if ( ierint .ne. 0 ) goto 99 open(unit=nunit,file=fnwin,status='old',err=98) c rmaxwl = 0.0 rminwl = 1.0e+12 nwin = 0 n_windows = 0 c do 1 i = 1, 1000000 read(nunit,100,end=10,err=97)row if(row(1:1) .eq. '#' ) goto 1 c do 15 j = 1, 8 argout(j) = ' ' 15 continue call split4(row,argout,nw,ier) if ( ier .ne. 0 ) then write(*,*)' ERROR' write(*,*)' file_name incorrectly specified in window_file', # ' at line: ', i return endif c if ( nw .eq. 0 ) goto 1 if ( nw .lt. 3 ) then ier = 1 write(*,*)' ERROR' write(*,*)' missing item(s) in window_file at line: ', i return endif c nwin = nwin + 1 n_windows = nwin data_file(nwin) = argout(1) read(argout(2),*) start_time(nwin) read(argout(3),*) end_time(nwin) c SAF : default format if ( nw .gt. 3 ) then read(argout(4),*) idfor(nwin) else idfor(nwin) = 2 endif idV(nwin) = argout(5) idN(nwin) = argout(6) idE(nwin) = argout(7) idsta(nwin) = argout(8) wl = end_time(nwin) - start_time(nwin) c.. wl = number of points / if wl in sec check in main when dt available c.. NOW wl is in second c if ( wl .lt. 1 ) goto 96 c if ( wl .gt. maxwinlen ) goto 95 rmaxwl = amax1(rmaxwl, wl) rminwl = amin1(rminwl, wl) if ( nwin .eq. maxnwin ) goto 20 1 continue 20 close(nunit) c c ... read in maximun number of windows write(*,*)' WARNING' write(*,*)' Number of windows greater than allowed dimension' write(*,*)' Only the first ',nwin,' windows are used' ier = 2 return c c 10 continue close(nunit) c ier = 0 return c c ... error in getting an unused fortran file unit 99 write(*,*)' GTWS : this error should be impossible' write(*,*)' no logical unit available' ier = 1 return c c ... error in opening window_file 98 write(*,*)' GTWS : error in opening window_file' ier = 3 return c c ... error in reading window_file 97 write(*,*)' GTWS : error in reading window_file' ier = 5 return c c ... window exceeding dimension c95 write(*,*)' Requested window exceeds current dimension ' c write(*,*)' requested # point : ', wl, ' current dimension', c # maxwinlen c write(*,200)data_file(nwin) c ier = 7 c return c c ... start time less then end time c96 write(*,*)' Start sample or end sample incorrectly specified ', c # ' Window number : ', nwin c write(*,*)' Start sample : ',start_time(nwin), c # ' End sample :', end_time(nwin) c write(*,200)data_file(nwin) c ier = 9 c return c c c 100 format(a1000) 200 format(1x,a200) c end