From f91ec498a9e8125919cb2c7859815a41ee754492 Mon Sep 17 00:00:00 2001 From: Berk Silemek <berk.silemek@gmail.com> Date: Mon, 14 Nov 2022 14:06:50 +0000 Subject: [PATCH] The Fortran code to program ADC cards with an RMS filter --- Software/ADC/rec_m4i_tdfilter_rms.f | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Software/ADC/rec_m4i_tdfilter_rms.f diff --git a/Software/ADC/rec_m4i_tdfilter_rms.f b/Software/ADC/rec_m4i_tdfilter_rms.f new file mode 100644 index 0000000..1fe1763 --- /dev/null +++ b/Software/ADC/rec_m4i_tdfilter_rms.f @@ -0,0 +1,83 @@ +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-------------------------------------------------------------------- -- GitLab