Skip to content

Commit

Permalink
Merge branch 'dalesteam:main' into to4.4.2_Fredrik_micro_testbed
Browse files Browse the repository at this point in the history
  • Loading branch information
jchylik authored Sep 9, 2024
2 parents 7c932b4 + d45527e commit 0c99029
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
31 changes: 16 additions & 15 deletions src/modfftw.f90
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ module modfftw
integer :: method
integer :: konx, kony
integer :: iony, jonx
integer :: konx_last, kony_last
integer :: iony_last, jonx_last
integer :: konx_me, kony_me
integer :: iony_me, jonx_me
real(pois_r), dimension(:), allocatable :: bufin, bufout
interface fftw_plan_many_r2r_if
procedure :: d_fftw_plan_many_r2r
Expand Down Expand Up @@ -136,10 +136,13 @@ subroutine fftwinit(p, Fp, d, xyrt, ps,pe,qs,qe)
jonx = jonx + 1
endif

konx_last = kmax - konx*(nprocx-1)
kony_last = kmax - kony*(nprocy-1)
iony_last = itot - iony*(nprocy-1)
jonx_last = jtot - jonx*(nprocx-1)
! how many data elements are in use in the current process?
! if the number of elements is not divisible by nprocx or nprocy,
! one process may have fewer elements, and some processes may have *no* elements
konx_me = max(min(konx, kmax - konx*myidx), 0)
kony_me = max(min(kony, kmax - kony*myidy), 0)
iony_me = max(min(iony, itot - iony*myidy), 0)
jonx_me = max(min(jonx, jtot - jonx*myidx), 0)

! Allocate communication buffers for the transpose functions
sz = max( imax * jmax * konx * nprocx, & ! transpose a1
Expand Down Expand Up @@ -258,13 +261,9 @@ subroutine fftwinit(p, Fp, d, xyrt, ps,pe,qs,qe)
allocate(xyrt(iony,jonx))
allocate(d(iony,jonx,kmax))
ps = 1
pe = iony
pe = iony_me
qs = 1
qe = jonx

! special case for final task in x or y, which may have fewer elements
if (myidx == nprocx-1) qe = jonx_last
if (myidy == nprocy-1) pe = iony_last
qe = jonx_me

else if (method == 2) then

Expand Down Expand Up @@ -660,9 +659,11 @@ subroutine fftwf(p, Fp)

call transpose_a2(p210, p201)
! zero the unused part, avoinds SIGFPE from the FFT (Debug mode)
! p201(jtot,konx,iony)
if (myidx == nprocx-1) p201(:,konx_last+1:, :) = 0
if (myidy == nprocy-1) p201(:,:,iony_last+1:) = 0
! indexing: p201(jtot,konx,iony)
if (konx_me < konx) p201(:,konx_me+1:, :) = 0
if (iony_me < iony) p201(:,:,iony_me+1:) = 0


call fftw_execute_r2r_if(plany, p201_flat, p201_flat)

call transpose_a3(p201, Fp)
Expand Down
4 changes: 0 additions & 4 deletions src/modradrrtmg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,6 @@ subroutine setupSlicesFromProfiles(j,npatch_start, &
cloudFrac(i,k) = 1.
B_function = -2 + 0.001 *(273.-layerT(i,k))**1.5 * log10(qci_slice(i,k)/IWC0) !Eq. 14 Wyser 1998
iceRe (i,k) = 377.4 + 203.3 * B_function + 37.91 * B_function**2 + 2.3696 * B_function**3 !micrometer, Wyser 1998, Eq. 35
if (isnan(iceRe(i,k))) then
write (*,*) "B", B_function, "iceRe", iceRe(i,k), "qci_slice", qci_slice(i,k), "layerT", layerT(i,k)
stop "modradrrtmg: iceRe is nan."
end if
if (iceRe(i,k).lt.5.) then
iceRe(i,k) = 5.
endif
Expand Down

0 comments on commit 0c99029

Please sign in to comment.