Skip to content
Snippets Groups Projects
Commit f91ec498 authored by Berk Silemek's avatar Berk Silemek
Browse files

The Fortran code to program ADC cards with an RMS filter

parent 4806fda0
No related branches found
No related tags found
No related merge requests found
c gfortran rec_m4i_tdfilter_rms.f m4iset_extrig_rms.c /usr/lib64/libspcm_linux.so -o rec_m4i_tdfilter_rms
c copy the line above to create and executable file
implicit real*8 (a-h,o-z)
integer*2 fid1(20000000)
complex*16 f0(20000000)
complex*16 fmix0(1000001)
complex*16 chelp0,offset0
pi=4.d0*datan(1.d0)
dt=1.d0/500.d6
nfit2=1000
nfit=2*nfit2
fsig=0.d0
ndp=12800000+2000000
nposttr=ndp-1000000
aread=m4iset(fid1,ndp,nposttr)
c -----------------------------------------------
do i=1,ndp
f0(i)=dcmplx(dfloat(fid1(i)),0.d0)
enddo
c -----------------------------------------------
windi0=0.d0
do i=1,2*nfit+1
x=dfloat(i-1)/dfloat(nfit)-1.d0
fmix0(i)=cdexp((0.d0,2.d0)*pi*fsig*dfloat(i-1)*dt)
windi0=windi0+wind(x)
fmix0(i)=fmix0(i)*wind(x)
enddo
c -----------------------------------------------
do i=1,ndp-2*nfit-1,nfit
time=dfloat(i-1)*dt
chelp0=(0.d0,0.d0)
do ii=2,2*nfit
chelp0=chelp0+f0(i-1+ii)*fmix0(ii)
enddo
chelp0=2.d0*chelp0*cdexp((0.d0,2.d0)*pi*fsig*time)/windi0
print *,time+2*nfit2*dt,cdabs(chelp0)
enddo
end
c--------------------------------------------------------------------
real*8 function wind(x)
implicit real*8 (a-h,o-z)
pi=4.d0*datan(1.d0)
if(dabs(x).le.1.d0) then
if(dabs(x).ne.0.d0) then
wind=dexp(-1.d0/(1.d0-x*x))*dsin(2.073d0*pi*x)/x
else
wind=dexp(-1.d0/(1.d0-x*x))*2.073d0*pi
endif
else
wind=0.d0
endif
end
c--------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment