summaryrefslogtreecommitdiff
path: root/map65/libm65/m65a.f90
diff options
context:
space:
mode:
Diffstat (limited to 'map65/libm65/m65a.f90')
-rw-r--r--map65/libm65/m65a.f90133
1 files changed, 39 insertions, 94 deletions
diff --git a/map65/libm65/m65a.f90 b/map65/libm65/m65a.f90
index ffeb176a..ab2af114 100644
--- a/map65/libm65/m65a.f90
+++ b/map65/libm65/m65a.f90
@@ -1,107 +1,52 @@
-subroutine m65a
+module m65a_mod
+ implicit none
+contains
+
+subroutine m65a()
use timer_module, only: timer
- use timer_impl, only: init_timer !, limtrace
use, intrinsic :: iso_c_binding, only: C_NULL_CHAR
+ use npar_ptrs_mod, only: wsjtx_dir
+ use datcom_ptrs_mod, only: dd,ss,savg
+ use m65_mod
use FFTW3
+ use ftninit_mod
- interface
- function address_m65()
- integer*1, pointer :: address_m65
- end function address_m65
- end interface
+ implicit none
- integer*1 attach_m65
- integer size_m65
- integer*1, pointer :: p_m65
- character*80 cwd
- character wisfile*256
- logical fileExists
-
- call getcwd(cwd)
- call ftninit(trim(cwd))
- call init_timer (trim(cwd)//'/timer.out')
+ character(len=256) cwd
+
+ cwd = trim(wsjtx_dir)
- limtrace=0
- lu=12
- i1=attach_m65()
+ if (len_trim(cwd) == 0) then
+ call get_environment_variable("PWD", cwd)
+ end if
-10 inquire(file=trim(cwd)//'/.lock',exist=fileExists)
- if(fileExists) then
- call sleep_msec(100)
- go to 10
- endif
+ if (len_trim(cwd) == 0) then
+ call get_environment_variable("CD", cwd)
+ end if
- inquire(file=trim(cwd)//'/.quit',exist=fileExists)
- if(fileExists) then
- call timer('decode0 ',101)
- i=detach_m65()
- ! Save FFTW wisdom and free memory
- wisfile=trim(cwd)//'/m65_wisdom.dat'// C_NULL_CHAR
- if(len(trim(wisfile)).gt.0) iret=fftwf_export_wisdom_to_filename(wisfile)
- call four2a(a,-1,1,1,1)
- call filbig(a,-1,1,0.0,0,0,0,0,0) !used for FFT plans
- call fftwf_cleanup_threads()
- call fftwf_cleanup()
- go to 999
- endif
+ if (len_trim(cwd) == 0) then
+ cwd = "."
+ end if
- nbytes=size_m65()
- if(nbytes.le.0) then
- print*,'m65a: Shared memory mem_m65 does not exist.'
- print*,'Program m65a should be started automatically from within map65.'
- go to 999
- endif
- p_m65=>address_m65()
- call m65b(p_m65,nbytes)
- call sleep_msec(500) ! wait for .lock to be recreated
- go to 10
-
-999 return
-end subroutine m65a
-
-subroutine m65b(m65com,nbytes)
- integer*1 m65com(0:nbytes-1)
- kss=4*4*60*96000
- ksavg=kss+4*4*322*32768
- kfcenter=ksavg+4*4*32768
- call m65c(m65com(0),m65com(kss),m65com(ksavg),m65com(kfcenter))
- return
-end subroutine m65b
-
-subroutine m65c(dd,ss,savg,nparams0)
-
- include 'njunk.f90'
- real*4 dd(4,5760000),ss(4,322,32768),savg(4,32768)
- real*8 fcenter
- integer nparams0(NJUNK+2),nparams(NJUNK+2)
- logical ldecoded
- character*12 mycall,hiscall
- character*6 mygrid,hisgrid
- character*20 datetime
- common/npar/fcenter,nutc,idphi,mousedf,mousefqso,nagain, &
- ndepth,ndiskdat,neme,newdat,nfa,nfb,nfcal,nfshift, &
- mcall3,nkeep,ntol,nxant,nrxlog,nfsample,nxpol,nmode, &
- ndop00,nsave,max_drift,nhsym,mycall,mygrid,hiscall,hisgrid, &
- datetime,junk1,junk2
- common/early/nhsym1,nhsym2,ldecoded(32768)
- equivalence (nparams,fcenter)
+ call ftninit(trim(cwd))
+
+ if (.not. associated(savg)) then
+ ! print *, 'ERROR:M65A savg is not associated!'
+ end if
+
+ if (.not. associated(dd)) then
+ ! print *, 'ERROR: M65A dd is not associated!'
+ end if
- nparams=nparams0 !Copy parameters into common/npar/
- npatience=1
- if(nhsym.eq.nhsym1 .and. iand(nrxlog,1).ne.0) then
- write(21,1000) datetime(:17)
-1000 format(/'UTC Date: 'a17/78('-'))
- flush(21)
- endif
- if(iand(nrxlog,2).ne.0) rewind(21)
- if(iand(nrxlog,4).ne.0) then
- if(nhsym.eq.nhsym1) rewind(26)
- if(nhsym.eq.nhsym2) backspace(26)
- endif
+ if (.not. associated(ss)) then
+ ! print *, 'ERROR: M65A ss is not associated!'
+ end if
+
+ call m65c()
+ return
- nstandalone=0
- if(sum(nparams).ne.0) call decode0(dd,ss,savg,nstandalone)
+end subroutine m65a
- return
-end subroutine m65c
+end module m65a_mod