From 81ad76cacc871d24e733da5317068094e144c8ac Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 29 Aug 2016 17:01:38 +0000 Subject: [PATCH] Produce a warning message if the WSPR .c2 file cannot be written Thanks to Mike W9MDB for this patch. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7039 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/savec2.f90 | 15 ++++++++------- mainwindow.cpp | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/savec2.f90 b/lib/savec2.f90 index 55b4ff476..d1cafec92 100644 --- a/lib/savec2.f90 +++ b/lib/savec2.f90 @@ -1,4 +1,4 @@ -subroutine savec2(c2name,ntrseconds,f0m1500) +integer function savec2(c2name,ntrseconds,f0m1500) ! Array c0() has complex samples at 1500 Hz sample rate. ! WSPR-2: downsample by 1/4 to produce c2, centered at 1500 Hz @@ -46,9 +46,10 @@ subroutine savec2(c2name,ntrseconds,f0m1500) ! Write complex time-domain data to disk. i1=index(c2name,'.c2') outfile=c2name(i1-11:i1+2) - open(18,file=c2name,status='unknown',access='stream') - write(18) outfile,ntrminutes,f0m1500,c2(0:45000-1) - close(18) - - return -end subroutine savec2 + open(18,file=c2name,status='unknown',access='stream', iostat=ioerr) + if (ioerr.ne.0) then + write(18) outfile,ntrminutes,f0m1500,c2(0:45000-1) + close(18) + endif + savec2 = ioerr +end function savec2 diff --git a/mainwindow.cpp b/mainwindow.cpp index 4a2442839..54a96fb6c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -102,7 +102,7 @@ extern "C" { int ptt_(int nport, int ntx, int* iptt, int* nopen); void wspr_downsample_(short int d2[], int* k); - void savec2_(char* fname, int* TR_seconds, double* dial_freq, int len1); + int savec2_(char* fname, int* TR_seconds, double* dial_freq, int len1); void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1, float* level, float* sigdb, float* snr, float* dfreq, @@ -1177,7 +1177,8 @@ void MainWindow::dataSink(qint64 frames) int nsec=120; int nbfo=1500; double f0m1500=m_freqNominal/1000000.0 + nbfo - 1500; - savec2_(c2name,&nsec,&f0m1500,len1); + int err = savec2_(c2name,&nsec,&f0m1500,len1); + if (err!=0) MessageBox::warning_message (this, tr ("Error saving c2 file"), c2name); } }