From e6e81fbeb33c7ebdb552886c7c0353692ce57d92 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 30 Sep 2016 23:32:01 +0000 Subject: [PATCH] Fix a crash which appears to be a stack size limitation This issue was probably triggered by OpenMP forcing some large arrays onto the stack where Fortran might normally make them static. The change that seemed to make the difference was putting cdat2 in msk144_freq_search into static storage. I am not convinced that the problem is really solved but it works for now. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7130 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 4 ++-- lib/msk144_freq_search.f90 | 1 + lib/msk144decodeframe.f90 | 6 +++--- lib/msk144sync.f90 | 5 ++--- lib/mskrtd.f90 | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b24289388..ccbc900e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -775,8 +775,8 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11 -fexceptions - if (NOT APPLE) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pragmas") if (${OPENMP_FOUND}) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") endif () set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fdata-sections -ffunction-sections") set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -fdata-sections -ffunction-sections") diff --git a/lib/msk144_freq_search.f90 b/lib/msk144_freq_search.f90 index 4bd4474e5..5e0baebb2 100644 --- a/lib/msk144_freq_search.f90 +++ b/lib/msk144_freq_search.f90 @@ -12,6 +12,7 @@ subroutine msk144_freq_search(cdat,fc,if1,if2,delf,nframes,navmask,cb, & real xcc(0:NSPM-1) real xccs(0:NSPM-1) integer navmask(nframes) ! defines which frames to average + save cdat2 navg=sum(navmask) n=nframes*NSPM diff --git a/lib/msk144decodeframe.f90 b/lib/msk144decodeframe.f90 index 3e74cccbd..68abb1e8c 100644 --- a/lib/msk144decodeframe.f90 +++ b/lib/msk144decodeframe.f90 @@ -8,7 +8,7 @@ subroutine msk144decodeframe(c,msgreceived,nsuccess) complex c(NSPM) integer*1 decoded(80) integer s8(8),hardbits(144) - real*8 dt, df, fs, pi, twopi + real*8 dt, fs, pi, twopi real cbi(42),cbq(42) real pp(12) real softbits(144) @@ -16,7 +16,7 @@ subroutine msk144decodeframe(c,msgreceived,nsuccess) logical first data first/.true./ data s8/0,1,1,1,0,0,1,0/ - save df,first,cb,fs,pi,twopi,dt,s8,pp + save first,cb,fs,pi,twopi,dt,s8,pp if(first) then ! define half-sine pulse and raised-cosine edge window @@ -24,7 +24,6 @@ subroutine msk144decodeframe(c,msgreceived,nsuccess) twopi=8d0*datan(1d0) fs=12000.0 dt=1.0/fs - df=fs/NFFT do i=1,12 angle=(i-1)*pi/12.0 @@ -103,5 +102,6 @@ subroutine msk144decodeframe(c,msgreceived,nsuccess) nsuccess=1 endif endif + return end subroutine msk144decodeframe diff --git a/lib/msk144sync.f90 b/lib/msk144sync.f90 index 35c1b827b..0204d52c7 100644 --- a/lib/msk144sync.f90 +++ b/lib/msk144sync.f90 @@ -60,9 +60,8 @@ subroutine msk144sync(cdat,nframes,ntol,delf,navmask,npeaks,fc,fest, & nthreads=1 !$ nthreads=min(8,int(OMP_GET_MAX_THREADS(),4)) nstep=nfreqs/nthreads - !$ call OMP_SET_NUM_THREADS(nthreads) -!$OMP PARALLEL PRIVATE(id,if1,if2) + !$OMP PARALLEL NUM_THREADS(nthreads) PRIVATE(id,if1,if2) id=1 !$ id=OMP_GET_THREAD_NUM() + 1 !Thread id = 1,2,... if1=-nint(ntol/delf) + (id-1)*nstep @@ -72,7 +71,7 @@ subroutine msk144sync(cdat,nframes,ntol,delf,navmask,npeaks,fc,fest, & xm(id),bf(id),cs(1,id),xccs(1,id)) ! write(73,3002) id,if1,if2,nfreqs,nthreads,bf(id),xm(id) !3002 format(5i5,2f10.3) -!$OMP END PARALLEL + !$OMP END PARALLEL xmax=xm(1) fest=fc+bf(1) diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index 291f4482e..11cfae85c 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -37,7 +37,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,line) 1,1,1,1,1,1,1,0/ data xmc/2.0,4.5,2.5,3.5/ !Used to label decode with time at center of averaging mask - save first,tsec0,nutc00,pnoise,nsnrlast,msglast + save first,tsec0,nutc00,pnoise,nsnrlast,msglast,cdat if(first) then tsec0=tsec