diff --git a/plrs.f90 b/plrs.f90 index c46dd254f..63ce564aa 100644 --- a/plrs.f90 +++ b/plrs.f90 @@ -15,24 +15,26 @@ program plrs integer fd integer open,read,close integer nm(11) - character*8 fname,arg - logical fast + character*8 fname,arg,cjunk*1 + logical fast,pause real*8 center_freq,dmsec,dtmspacket,tmsec common/plrscom/center_freq,msec2,fsample,iptr,nblock,userx_no,iusb,buf8(174) ! 8 4 4 4 2 1 1 1392 data nm/45,46,48,50,52,54,55,56,57,58,59/ - data nblock/0/,fast/.false./ + data nblock/0/,fast/.false./,pause/.false./ nargs=iargc() - if(nargs.ne.1 .and. nargs.ne.2) then - print*,'Usage: plrs [-f] ' + if(nargs.ne.3) then + print*,'Usage: plrs ' go to 999 endif + call getarg(1,arg) - if(arg(1:2).eq.'-f') then - fast=.true. - call getarg(2,arg) - endif + if(arg(1:1).eq.'f' .or. arg(1:1).eq.'p') fast=.true. + if(arg(1:1).eq.'p') pause=.true. + call getarg(2,arg) + read(arg,*) nfiles + call getarg(3,arg) read(arg,*) iters fname="all.tf2"//char(0) @@ -50,7 +52,7 @@ program plrs dmsec=-dtmspacket nsec0=time() - do ifile=1,11 + do ifile=1,nfiles print*,'Reading file',ifile ns0=0 tmsec=1000*(3600*7 + 60*nm(ifile))-dtmspacket @@ -85,6 +87,10 @@ program plrs 1010 format('npkt:',i10,' ns:',i6,' t:',f10.3,' nwait:',i8) ns0=ns enddo + if(pause) then + print*,'Type anything to continue:' + read(*,*) cjunk + endif enddo i=close(fd) enddo diff --git a/pulsar.f90 b/pulsar.f90 new file mode 100644 index 000000000..a19be7d45 --- /dev/null +++ b/pulsar.f90 @@ -0,0 +1,50 @@ +program pulsar + +! Receives timf2 data from Linrad and saves it for pulsar processing. + + parameter (NSPP=174) + logical first + integer*1 userx_no,iusb + integer*2 id + integer*2 nblock,nblock0 + integer*2 id2(1000) + real*8 center_freq + common/plrscom/center_freq,msec,fselect,iptr,nblock,userx_no,iusb,id(4,NSPP) +! 8 4 4 4 2 1 1 1392 + data first/.true./,nblock0/0/,sqave/0.0/,u/0.001/ + save + + call setup_rsocket + + k=0 + +10 call recv_pkt(center_freq) + lost=nblock-nblock0-1 + if(lost.ne.0 .and. .not.first) print*,'Lost packets:',lost,nblock,nblock0 + nblock0=nblock + + sq=0. + do i=1,NSPP + sq=sq + float(id(1,i))**2 + float(id(2,i))**2 + & + float(id(3,i))**2 + float(id(4,i))**2 + enddo + sqave=sqave + u*(sq-sqave) + rxnoise=10.0*log10(sqave) - 48.0 + + k=k+1 + id2(k)=0.001*sq + if(k.eq.1000) then + write(*,1000) center_freq,0.001*msec,sqave,rxnoise,id2(1) + write(13,1000) center_freq,0.001*msec,sqave,rxnoise,id2(1) +1000 format(f7.3,f11.3,f10.0,f8.2,i8) + write(12) center_freq,msec1,id2 + call flush(12) + call flush(13) + k=0 + endif + + go to 10 + +end program pulsar + +! To compile: % gfortran -o pulsar pulsar.f90 plrr_subs.c