subroutine deffre(npts,freq,nf,ier) c c Definition of frequency vector c a.tento 04/02 v.1.0 c a.tento 04/03 v.1.1 c c rem. npts = number of window samples c implicit none include 'main.h' include 'parameters.h' include 'times.h' integer nf, ier, npts real freq dimension freq(*) integer nw character*200 argout(20) c integer i, i1, i2, nfo, maxfft real df, dff, fmin, fmax, fminl, fny, freqh character sep2*1 parameter (sep2 = ':') c maxfft = mbig c ier = 1 c fny= 1.0/(2.0*sampling_rate) df= 1.0/(float(npts)*sampling_rate) fny = df * float(npts/2) c call split3(freq_spacing,argout,sep2,nw) c if( argout(1) .eq. 'fft' ) then dff= df nf = npts/2 if ( nf .gt. maxfft ) goto 99 do 1 i = 1, nf freq(i) = float(i) * dff 1 continue ier = 0 return endif c c if( argout(1) .eq. 'fft_red' ) then if( nw .ne. 3 ) then write(*,*)' incorrect option(s) for ''frequency spacing'':' write(*,100)freq_spacing ier = 1 else read(argout(2),*)fmin read(argout(3),*)fmax if( fmax .gt. fny ) fmax = fny if( fmin .lt. df ) fmin = df dff= df c df*i (.not. df*(i-1)) i1 = nint(fmin/dff) i2 = nint(fmax/dff) do 2 i = i1, i2 nf = i - i1 + 1 if ( nf .gt. maxfft ) goto 99 freq(nf) = float(i) * dff 2 continue ier = 0 endif return endif c c if( argout(1) .eq. 'linear' ) then if( nw .ne. 4 ) then write(*,*)' incorrect option(s) for ''frequency spacing'':' write(*,100)freq_spacing ier = 1 else read(argout(2),*)fmin read(argout(3),*)fmax read(argout(4),*)nfo if ( nfo .gt. maxfft ) goto 99 dff = (fmax - fmin)/float(nfo -1) nf = 0 do 3 i = 1, nfo freqh = fmin + float(i-1) * dff if ( freqh .lt. df ) goto 3 if ( freqh .gt. fny ) goto 5 nf = nf + 1 if ( nf .gt. maxfft ) goto 99 freq(nf) = freqh 3 continue 5 continue ier = 0 endif return endif c c if( argout(1) .eq. 'log' ) then if( nw .ne. 4 ) then write(*,*)' incorrect option(s) for ''frequency spacing'':' write(*,100)freq_spacing ier = 1 else read(argout(2),*)fmin read(argout(3),*)fmax read(argout(4),*)nfo if ( nfo .gt. maxfft ) goto 99 fminl=alog(fmin) dff = (alog(fmax) - fminl)/float(nfo -1) nf = 0 do 4 i = 1, nfo freqh = fminl + float(i-1) * dff freqh = exp(freqh) if ( freqh .lt. df ) goto 4 if ( freqh .gt. fny ) goto 6 nf = nf + 1 if ( nf .gt. maxfft ) goto 99 freq(nf) = freqh 4 continue 6 continue ier = 0 endif return endif c write(*,*)' ERROR : ''frequency spacing'' option wrongly set :' write(*,100)freq_spacing ier = 1 return c 99 write(*,*)' Frequency spacing option : ' write(*,100)freq_spacing write(*,*)' Number of frequencies (requested or computed)', # ' greater than dimension',maxfft ier = 1 return c 100 format(1x,a78) c end