diff --git a/epochX/cudacpp/pp_dy3j.mad/Source/dsample.f b/epochX/cudacpp/pp_dy3j.mad/Source/dsample.f index 94ac4d6d5e..98f35352fa 100644 --- a/epochX/cudacpp/pp_dy3j.mad/Source/dsample.f +++ b/epochX/cudacpp/pp_dy3j.mad/Source/dsample.f @@ -1250,7 +1250,20 @@ subroutine sample_get_x(wgt, x, j, ipole, xmin, xmax) c Local c integer im, ip,ij,icount,it_warned - double precision xbin_min,xbin_max,ddum(maxdim),xo,y + double precision xbin_min,xbin_max,ddum(maxdim),xo,y +c +c Local (performance optimization #969) +c + integer xbinarraydim + parameter (xbinarraydim=maxdim*lmaxconfigs) + double precision xbin_min0_array(maxdim, lmaxconfigs) + double precision xbin_max1_array(maxdim, lmaxconfigs) + logical xbin_min0_saved(maxdim, lmaxconfigs) + logical xbin_max1_saved(maxdim, lmaxconfigs) + save xbin_min0_array, xbin_max1_array + save xbin_min0_saved, xbin_max1_saved + data xbin_min0_saved/xbinarraydim*.false./ + data xbin_max1_saved/xbinarraydim*.false./ c c External c @@ -1301,10 +1314,28 @@ subroutine sample_get_x(wgt, x, j, ipole, xmin, xmax) endif if (ituple .eq. 1) then c write(*,*) 'Getting variable',ipole,j,minvar(j,ipole) - xbin_min = xbin(xmin,minvar(j,ipole)) - xbin_max = xbin(xmax,minvar(j,ipole)) - if (xbin_min .gt. xbin_max-1) then - xbin_min = min(xbin_min, xbin_max) + + if(xmax.ne.1 .or. .not.xbin_max1_saved(j,ipole)) then + xbin_max = xbin(xmax, minvar(j,ipole)) + if(xmax.eq.1) then + xbin_max1_array(j,ipole) = xbin_max + xbin_max1_saved(j,ipole) = .true. + endif + else + xbin_max = xbin_max1_array(j,ipole) + endif + + if(xmin.ne.0 .or. .not.xbin_min0_saved(j,ipole)) then + xbin_min = xbin(xmin, minvar(j,ipole)) + if (xbin_min .gt. xbin_max-1) then + xbin_min = min(xbin_min, xbin_max) + endif + if(xmin.eq.0) then + xbin_min0_array(j,ipole) = xbin_min + xbin_min0_saved(j,ipole) = .true. + endif + else + xbin_min = xbin_min0_array(j,ipole) endif c c Line which allows us to keep choosing same x