Merge branch 'feat-map65-integration' of bitbucket.org:k1jt/wsjtx into feat-map65-integration

This commit is contained in:
Joe Taylor 2021-05-13 08:16:57 -04:00
commit 7407dc6332
8 changed files with 47 additions and 22 deletions

View File

@ -20,7 +20,7 @@ program jt9
real*8 TRperiod real*8 TRperiod
character c character c
character(len=500) optarg, infile character(len=500) optarg, infile
character wisfile*80 character wisfile*256
!### ndepth was defined as 60001. Why??? !### ndepth was defined as 60001. Why???
integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, & integer :: arglen,stat,offset,remain,mode=0,flow=200,fsplit=2700, &
fhigh=4000,nrxfreq=1500,ndepth=1,nexp_decode=0,nQSOProg=0 fhigh=4000,nrxfreq=1500,ndepth=1,nexp_decode=0,nQSOProg=0

View File

@ -48,7 +48,7 @@ add_subdirectory (libm65)
qt5_wrap_ui (map65_GENUISRCS ${map65_UISRCS}) qt5_wrap_ui (map65_GENUISRCS ${map65_UISRCS})
add_executable (map65 ${map65_CXXSRCS} ${map65_CSRCS} ${map65_GENUISRCS} map65.rc) add_executable (map65 ${map65_CXXSRCS} ${map65_CSRCS} ${map65_GENUISRCS} map65.rc)
target_include_directories (map65 PRIVATE ${CMAKE_SOURCE_DIR}) target_include_directories (map65 PRIVATE ${CMAKE_SOURCE_DIR} ${FFTW3_INCLUDE_DIRS})
target_link_libraries (map65 wsjt_qt m65impl ${FFTW3_LIBRARIES} Qt5::Widgets Qt5::Network Portaudio::Portaudio Usb::Usb) target_link_libraries (map65 wsjt_qt m65impl ${FFTW3_LIBRARIES} Qt5::Widgets Qt5::Network Portaudio::Portaudio Usb::Usb)
install ( install (

View File

@ -1,9 +1,11 @@
subroutine ftninit(appd) subroutine ftninit(appd)
use timer_module, only: timer use timer_module, only: timer
use, intrinsic :: iso_c_binding, only: C_NULL_CHAR
use FFTW3
character*(*) appd character*(*) appd
character firstline*30
character addpfx*8 character addpfx*8
character wisfile*256
common/pfxcom/addpfx common/pfxcom/addpfx
addpfx=' ' addpfx=' '
@ -14,20 +16,14 @@ subroutine ftninit(appd)
open(26,file=appd//'/tmp26.txt',status='unknown') open(26,file=appd//'/tmp26.txt',status='unknown')
! Import FFTW wisdom, if available: ! Import FFTW wisdom, if available:
open(28,file=appd//'/fftwf_wisdom.dat',status='old',err=30) iret=fftwf_init_threads() !Initialize FFTW threading
read(28,1000,err=30,end=30) firstline ! Default to 1 thread, but use nthreads for the big ones
1000 format(a30) call fftwf_plan_with_nthreads(1)
rewind 28 ! Import FFTW wisdom, if available
call import_wisdom_from_file(isuccess,28) wisfile=trim(appd)//'/m65_wisdom.dat'// C_NULL_CHAR
close(28) iret=fftwf_import_wisdom_from_filename(wisfile)
if(isuccess.ne.0) write(13,1010) firstline
1010 format('Imported FFTW wisdom: ',a30)
30 flush(13)
return return
920 write(0,*) '!Error opening timer.out'
stop
950 write(0,*) '!Error opening ALL65.TXT' 950 write(0,*) '!Error opening ALL65.TXT'
stop stop

View File

@ -3,7 +3,6 @@ subroutine ftnquit
! Destroy the FFTW plans ! Destroy the FFTW plans
call four2a(a,-1,1,1,1) call four2a(a,-1,1,1,1)
call filbig(id,-1,1,f0,newdat,nfsample,c4a,c4b,n4) call filbig(id,-1,1,f0,newdat,nfsample,c4a,c4b,n4)
stop
return return
end subroutine ftnquit end subroutine ftnquit

View File

@ -22,8 +22,6 @@ program m65
! 24 ! 24
! 25 ! 25
! 26 tmp26.txt ! 26 tmp26.txt
! 27
! 28 fftw_wisdom.dat
use timer_module, only: timer use timer_module, only: timer
use timer_impl, only: init_timer, fini_timer use timer_impl, only: init_timer, fini_timer
@ -58,7 +56,6 @@ program m65
call getarg(1,arg) call getarg(1,arg)
if(arg(1:2).eq.'-s') then if(arg(1:2).eq.'-s') then
call m65a call m65a
call ftnquit
go to 999 go to 999
endif endif
n=1 n=1
@ -181,6 +178,5 @@ program m65
print*,infile print*,infile
999 call fini_timer() 999 call fini_timer()
call ftnquit
end program m65 end program m65

View File

@ -2,6 +2,8 @@ subroutine m65a
use timer_module, only: timer use timer_module, only: timer
use timer_impl, only: init_timer !, limtrace use timer_impl, only: init_timer !, limtrace
use, intrinsic :: iso_c_binding, only: C_NULL_CHAR
use FFTW3
interface interface
function address_m65() function address_m65()
@ -13,6 +15,7 @@ subroutine m65a
integer size_m65 integer size_m65
integer*1, pointer :: p_m65 integer*1, pointer :: p_m65
character*80 cwd character*80 cwd
character wisfile*256
logical fileExists logical fileExists
common/tracer/limtrace,lu common/tracer/limtrace,lu
@ -33,8 +36,14 @@ subroutine m65a
inquire(file=trim(cwd)//'/.quit',exist=fileExists) inquire(file=trim(cwd)//'/.quit',exist=fileExists)
if(fileExists) then if(fileExists) then
call timer('decode0 ',101) call timer('decode0 ',101)
call ftnquit
i=detach_m65() 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 go to 999
endif endif

View File

@ -1,3 +1,4 @@
#include <fftw3.h>
#ifdef QT5 #ifdef QT5
#include <QtWidgets> #include <QtWidgets>
#else #else
@ -8,6 +9,11 @@
#include "revision_utils.hpp" #include "revision_utils.hpp"
#include "mainwindow.h" #include "mainwindow.h"
extern "C" {
// Fortran procedures we need
void four2a_ (_Complex float *, int * nfft, int * ndim, int * isign, int * iform, int len);
}
static QtMessageHandler default_message_handler; static QtMessageHandler default_message_handler;
void my_message_handler (QtMsgType type, QMessageLogContext const& context, QString const& msg) void my_message_handler (QtMsgType type, QMessageLogContext const& context, QString const& msg)
@ -28,5 +34,19 @@ int main(int argc, char *argv[])
a.setApplicationVersion ("3.0.0-devel"); a.setApplicationVersion ("3.0.0-devel");
MainWindow w; MainWindow w;
w.show (); w.show ();
return a.exec (); auto result = a.exec ();
// clean up lazily initialized FFTW3 resources
{
int nfft {-1};
int ndim {1};
int isign {1};
int iform {1};
// free FFT plan resources
four2a_ (nullptr, &nfft, &ndim, &isign, &iform, 0);
}
fftwf_forget_wisdom ();
fftwf_cleanup ();
return result;
} }

View File

@ -1,5 +1,7 @@
//------------------------------------------------------------------ MainWindow //------------------------------------------------------------------ MainWindow
#include "mainwindow.h" #include "mainwindow.h"
#include <fftw3.h>
#include <QDir>
#include "revision_utils.hpp" #include "revision_utils.hpp"
#include "widgets/MessageBox.hpp" #include "widgets/MessageBox.hpp"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
@ -193,6 +195,8 @@ MainWindow::MainWindow(QWidget *parent) :
} }
memset(to,0,size); //Zero all decoding params in shared memory memset(to,0,size); //Zero all decoding params in shared memory
fftwf_import_wisdom_from_filename (QDir {m_appDir}.absoluteFilePath ("map65_wisdom.dat").toLocal8Bit ());
PaError paerr=Pa_Initialize(); //Initialize Portaudio PaError paerr=Pa_Initialize(); //Initialize Portaudio
if(paerr!=paNoError) { if(paerr!=paNoError) {
msgBox("Unable to initialize PortAudio."); msgBox("Unable to initialize PortAudio.");
@ -312,6 +316,7 @@ MainWindow::~MainWindow()
soundOutThread.wait(3000); soundOutThread.wait(3000);
} }
Pa_Terminate(); Pa_Terminate();
fftwf_export_wisdom_to_filename (QDir {m_appDir}.absoluteFilePath ("map65_wisdom.dat").toLocal8Bit ());
if(!m_decoderBusy) { if(!m_decoderBusy) {
QFile lockFile(m_appDir + "/.lock"); QFile lockFile(m_appDir + "/.lock");
lockFile.remove(); lockFile.remove();