Skip to content

Commit

Permalink
Merge pull request #7 from grimme-lab/integer_overflow_fixed
Browse files Browse the repository at this point in the history
[Integer overflow with lin function (integer*4) when declares as inte…
  • Loading branch information
mdewergi authored Aug 20, 2020
2 parents ad145c5 + 7f395c3 commit 273a41b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 45 deletions.
28 changes: 14 additions & 14 deletions apbtrafo.f
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ subroutine apbtrafo(n,nroot,x,e,xl,yl,zl,xv,yv,zv,xm,ym,zm,xmss
real*8 , intent( out ) :: rvpout(nroot)

integer i,j,k,l,io,iv
integer*8 lin,ij
integer*8 lin8,ij
real*8 de,ef,ak,xp,xlp,ylp,zlp,xvp,yvp,zvp,xmp,ymp,zmp
real*8 xvp2,yvp2,zvp2,xmp2,ymp2,zmp2,efmod
real*8 flp,fvp,rlp,rvp,p23,fact,unew,uold,hilf !,enew(nroot)
Expand Down Expand Up @@ -216,7 +216,7 @@ subroutine apbtrafo(n,nroot,x,e,xl,yl,zl,xv,yv,zv,xm,ym,zm,xmss
iv=iconf(j,2)
unew=dble(xnew(j,i))
uold=dble(x(j,i))
ij=lin(io,iv)
ij=lin8(io,iv)
! A+B transformed stuff
xlp=xlp+xl(ij)*uold
ylp=ylp+yl(ij)*uold
Expand Down Expand Up @@ -332,7 +332,7 @@ subroutine apbtrafo_uks(n,na,nb,nroot,x,e,xla,yla,zla,xva,yva,zva,
real*8, intent( out ) :: rvpout(nroot)
integer i,j,k,l,io,iv
integer*8 ij,lin
integer*8 ij,lin8
real*8 de,ef,xp,xlp,ylp,zlp,xvp,yvp,zvp,xmp,ymp,zmp
real*8 xvp2,yvp2,zvp2,xmp2,ymp2,zmp2,hilf,efmod
real*8 flp,fvp,rlp,rvp,p23,fact,unew,uold !,enew(nroot)
Expand Down Expand Up @@ -468,7 +468,7 @@ subroutine apbtrafo_uks(n,na,nb,nroot,x,e,xla,yla,zla,xva,yva,zva,
iv=iconfa(j,2)
unew=dble(xnew(j,i))
uold=dble(x(j,i))
ij=lin(io,iv)
ij=lin8(io,iv)
! A+B transformed stuff
xlp=xlp+xla(ij)*uold
ylp=ylp+yla(ij)*uold
Expand All @@ -493,7 +493,7 @@ subroutine apbtrafo_uks(n,na,nb,nroot,x,e,xla,yla,zla,xva,yva,zva,
iv=iconfb(j,2)
unew=dble(xnew(k,i))
uold=dble(x(k,i))
ij=lin(io,iv)
ij=lin8(io,iv)
! A+B transformed stuff
xlp=xlp+xlb(ij)*uold
ylp=ylp+ylb(ij)*uold
Expand Down Expand Up @@ -587,7 +587,7 @@ subroutine rtdacorr(nci,ncent,no,nv,mxcnf,iconf,dak,dax
real*8, intent(in) :: dak,dax,ed(mxcnf)
real*4, allocatable :: qj(:),qk(:),bmat(:)
integer i,j,io,iv,jo,jv,ierr,iiv,jjv,iwrk,jwrk
integer*8 ij,lin
integer*8 ij,lin8
real*4 ek,ej,sdot,ak,ax,de,fact
ij=nci
ij=ij*(ij+1)/2
Expand All @@ -609,7 +609,7 @@ subroutine rtdacorr(nci,ncent,no,nv,mxcnf,iconf,dak,dax
iwrk=(io-1)*nv + iiv
qk(1:ncent)=pia(1:ncent,iwrk)
do j=1,i-1
ij=lin(i,j)
ij=lin8(i,j)
jo=iconf(j,1)
jv=iconf(j,2)
jjv=jv-no
Expand All @@ -622,7 +622,7 @@ subroutine rtdacorr(nci,ncent,no,nv,mxcnf,iconf,dak,dax
ek=sdot(ncent,qj,1,qia(1,jwrk),1) ! now ek = (ib|aj), results from Fock-exchange, thus we scale by ax
bmat(ij)=bmat(ij)-fact*ax*ek ! scaled by ax
enddo
ij=lin(i,i)
ij=lin8(i,i)
ek=sdot(ncent,qk,1,qia(1,iwrk),1)
bmat(ij)=fact*(ak*ek-ax*ek) ! diagonal element of 0.5*B
enddo
Expand Down Expand Up @@ -657,7 +657,7 @@ subroutine utdacorr(nexa,nexb,ncent,noa,nva,nob,nvb,mxcnfa,
real*8, intent(in) :: dax
real*4, allocatable :: qj(:),qk(:),bmat(:)
integer i,j,io,iv,jo,jv,ierr,nex,iiv,jjv,iwrk,jwrk
integer*8 lin,ij
integer*8 lin8,ij
real*4 ek,ej,sdot,ax,de,fact
nex=nexa+nexb
ij=nex
Expand All @@ -680,7 +680,7 @@ subroutine utdacorr(nexa,nexb,ncent,noa,nva,nob,nvb,mxcnfa,
iwrk=(io-1)*nva + iiv
qk(1:ncent)=piaa(1:ncent,iwrk)
do j=1,i-1
ij=lin(i,j)
ij=lin8(i,j)
jo=iconfa(j,1)
jv=iconfa(j,2)
jjv=jv-noa
Expand All @@ -693,7 +693,7 @@ subroutine utdacorr(nexa,nexb,ncent,noa,nva,nob,nvb,mxcnfa,
ek=sdot(ncent,qj,1,qiaa(1,jwrk),1) ! now ek = (ib|aj), results from Fock-exchange, thus we scale by ax
bmat(ij)=bmat(ij)-fact*ax*ek
enddo
ij=lin(i,i)
ij=lin8(i,i)
ek=sdot(ncent,qk,1,qiaa(1,iwrk),1)
bmat(ij)=fact*(ek-ax*ek) ! diagonal element of 0.5*B
enddo
Expand All @@ -711,7 +711,7 @@ subroutine utdacorr(nexa,nexb,ncent,noa,nva,nob,nvb,mxcnfa,
qk(1:ncent)=piab(1:ncent,iwrk)
! ...alpha block
do j = 1,nexa
ij=lin(i,j)
ij=lin8(i,j)
jo=iconfa(j,1)
jv=iconfa(j,2)
jjv=jv-noa
Expand All @@ -721,7 +721,7 @@ subroutine utdacorr(nexa,nexb,ncent,noa,nva,nob,nvb,mxcnfa,
enddo
! ...beta block
do j = nexa+1,i-1
ij=lin(i,j)
ij=lin8(i,j)
jo=iconfb(j-nexa,1)
jv=iconfb(j-nexa,2)
jjv=jv-nob
Expand All @@ -734,7 +734,7 @@ subroutine utdacorr(nexa,nexb,ncent,noa,nva,nob,nvb,mxcnfa,
ek=sdot(ncent,qj,1,qiab(1,jwrk),1) ! now ek = (ib|aj), results from Fock-exchange, thus we scale by ax
bmat(ij)=bmat(ij)-fact*ax*ek
enddo
ij=lin(i,i)
ij=lin8(i,i)
ek=sdot(ncent,qk,1,qiab(1,iwrk),1)
bmat(ij)=fact*(ek-ax*ek) ! diagonal element of 0.5*B
enddo
Expand Down
4 changes: 2 additions & 2 deletions intslvm.f
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ subroutine intslvm(ncent,nmo,nbf,nprims)
real*8, allocatable ::r7(:)
real*8, allocatable ::r8(:)
real*8, allocatable ::r9(:)
integer*8 memneed,mp,nrecordlen,k,i1,lin
integer*8 memneed,mp,nrecordlen,k,i1,lin8
common/ prptyp / mprp
common /cema / cen(3),xmolw
common /amass / ams(107)
Expand Down Expand Up @@ -169,7 +169,7 @@ subroutine intslvm(ncent,nmo,nbf,nprims)
ij=0
do i=1,nao
do j=1,i-1
ij=lin(i,j)
ij=lin8(i,j)
r0(ij)=r0(ij)*0.50d0
r1(ij)=r1(ij)*0.50d0
r2(ij)=r2(ij)*0.50d0
Expand Down
46 changes: 23 additions & 23 deletions linear_response.f
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SUBROUTINE lresp(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,no,nv)
integer ::io1,io2,iv1,iv2,iwrk,jwrk
integer ::maxconf,moci,no,nv
integer ::iconf(maxconf,2)
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -111,7 +111,7 @@ SUBROUTINE lresp(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,no,nv)
!$omp do
Do i=1, nci
Do j=1, nci
jk=lin(i,j)
jk=lin8(i,j)
io=iconf(j,1)
iv=iconf(j,2)
idum1=max(io,iv)
Expand Down Expand Up @@ -186,7 +186,7 @@ SUBROUTINE lresp1(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,no,nv)
integer ::counter_A
integer, allocatable :: B_list(:,:)
integer ::counter_B
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -285,7 +285,7 @@ SUBROUTINE lresp1(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,no,nv)
!$omp do
Do i=1, nci
Do j=1, nci
jk=lin(i,j)
jk=lin8(i,j)
io=iconf(j,1)
iv=iconf(j,2)
idum1=max(io,iv)
Expand Down Expand Up @@ -351,7 +351,7 @@ SUBROUTINE lresp1(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,no,nv)
!$omp do
Do i=1,nci
Do j=1,nci
ij=lin(i,j)
ij=lin8(i,j)
Do ix=1,3
XmY(i,ii,jj,ix)=XmY(i,ii,jj,ix)+ dble(omega)
. *dble(inv_amb(ij))*XpY(j,ii,jj,ix)
Expand Down Expand Up @@ -1379,7 +1379,7 @@ Subroutine A_beta1(ix,iy,iz,wx,wy,wz,X,Y,
real*8 ::X(nci,num_freq+1,2,3)
real*8 ::Y(nci,num_freq+1,2,3)
integer ::i,j,k,ij,ii,kk,io1,io2,idum1,idum2
integer*8 ::lin
integer*8 ::lin8
integer ::jwrk
logical ::check

Expand Down Expand Up @@ -1424,7 +1424,7 @@ Subroutine B_beta1(ix,iy,iz,wx,wy,wz,X,Y,
real*8 ::X(nci,num_freq+1,2,3)
real*8 ::Y(nci,num_freq+1,2,3)
integer ::i,j,k,ab,ii,kk,iv1,iv2,idum1,idum2
integer*8 ::lin
integer*8 ::lin8
integer ::jwrk
logical ::check

Expand Down Expand Up @@ -1669,7 +1669,7 @@ SUBROUTINE lresp_2PA(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,
integer ::counter_A
integer, allocatable :: B_list(:,:)
integer ::counter_B
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -1754,7 +1754,7 @@ SUBROUTINE lresp_2PA(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,
!$omp do
Do i=1, nci
Do j=1, nci
jk=lin(i,j)
jk=lin8(i,j)
io=iconf(j,1)
iv=iconf(j,2)
idum1=max(io,iv)
Expand Down Expand Up @@ -1819,7 +1819,7 @@ SUBROUTINE lresp_2PA(nci,apb,amb,iconf,maxconf,xl,yl,zl,moci,
!$omp do
Do i=1,nci
Do j=1,nci
ij=lin(i,j)
ij=lin8(i,j)
Do ix=1,3
XmY(i,ix)=XmY(i,ix)+ dble(omega)
. *dble(inv_amb(ij))*XpY(j,ix)
Expand Down Expand Up @@ -2351,7 +2351,7 @@ Subroutine A_2PA_1(ix,iy,X,Y,Xci,Yci,nroot,
real*8 ::Y(nci,3)
real*4 ::Xci(nci,nroot), Yci(nci,nroot)
integer ::i,j,k,ij,ii,kk,io1,io2,idum1,idum2
integer*8 ::lin
integer*8 ::lin8
integer ::jwrk
logical ::check

Expand Down Expand Up @@ -2397,7 +2397,7 @@ Subroutine A_2PA_2(ix,iy,X,Y,Xci,Yci,nroot,
real*8 ::Y(nci,3)
real*4 ::Xci(nci,nroot), Yci(nci,nroot)
integer ::i,j,k,ij,ii,kk,io1,io2,idum1,idum2
integer*8 ::lin
integer*8 ::lin8
integer ::jwrk
logical ::check

Expand Down Expand Up @@ -2443,7 +2443,7 @@ Subroutine B_2PA_1(ix,iy,X,Y,Xci,Yci,nroot,
real*8 ::Y(nci,3)
real*4 ::Xci(nci,nroot), Yci(nci,nroot)
integer ::i,j,k,ab,ii,kk,iv1,iv2,idum1,idum2
integer*8 ::lin
integer*8 ::lin8
integer ::jwrk
logical ::check

Expand Down Expand Up @@ -2489,7 +2489,7 @@ Subroutine B_2PA_2(ix,iy,X,Y,Xci,Yci,nroot,
real*8 ::Y(nci,3)
real*4 ::Xci(nci,nroot), Yci(nci,nroot)
integer ::i,j,k,ab,ii,kk,iv1,iv2,idum1,idum2
integer*8 ::lin
integer*8 ::lin8
integer ::jwrk
logical ::check

Expand Down Expand Up @@ -2531,7 +2531,7 @@ subroutine pol_sos(nroot,nci,eci,Xci,Yci,xl,yl,zl,moci,
integer ::io1,io2,iv1,iv2,iwrk,jwrk,nroot
integer ::maxconf,moci
integer ::iconf(maxconf,2)
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -2644,7 +2644,7 @@ subroutine lresp_ESA(nci,iconf,maxconf,xl,yl,zl,moci,
integer ::counter_A
integer, allocatable :: B_list(:,:)
integer ::counter_B
integer*8 ::lin
integer*8 ::lin8

real*8 ::xmolw

Expand Down Expand Up @@ -2812,7 +2812,7 @@ subroutine lresp_ESAbis(nci,iconf,maxconf,xl,yl,zl,moci,
integer ::counter_A
integer, allocatable :: B_list(:,:)
integer ::counter_B
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -2974,7 +2974,7 @@ subroutine hyperpol_sos(nroot,nci,eci,Xci,Yci,xl,yl,zl,moci,
integer ::ix,iy,iz,iroot
integer ::maxconf,moci
integer ::iconf(maxconf,2)
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -3088,7 +3088,7 @@ subroutine tpa_sos(nroot,nci,eci,Xci,Yci,xl,yl,zl,moci,
integer ::ix,iy,iz,iroot
integer ::maxconf,moci
integer ::iconf(maxconf,2)
integer*8 ::lin
integer*8 ::lin8

real*8 ::xl(moci*(moci+1)/2)
real*8 ::yl(moci*(moci+1)/2)
Expand Down Expand Up @@ -3168,7 +3168,7 @@ subroutine lresp_ESA_tda(nci,iconf,maxconf,xl,yl,zl,moci,
integer ::counter_A
integer, allocatable :: B_list(:,:)
integer ::counter_B
integer*8 ::lin
integer*8 ::lin8

real*8 ::xmolw

Expand Down Expand Up @@ -3337,7 +3337,7 @@ subroutine ulresp_ESA(nexa,nexb,nci,iconfa,iconfb,maxconfa,
integer ::counter_Ab
integer, allocatable :: B_listb(:,:)
integer ::counter_Bb
integer*8 ::lin
integer*8 ::lin8

real*8 ::xmolw,ak

Expand Down Expand Up @@ -3609,7 +3609,7 @@ subroutine ulresp_ESA_tda(nexa,nexb,nci,iconfa,iconfb,
integer ::counter_Ab
integer, allocatable :: B_listb(:,:)
integer ::counter_Bb
integer*8 ::lin
integer*8 ::lin8

real*8 ::xmolw,ak

Expand Down Expand Up @@ -3859,7 +3859,7 @@ subroutine sf_lresp_ESA(nci,iconf,maxconf,xla,yla,zla,mocia,
integer ::counter_A
integer, allocatable :: B_list(:,:)
integer ::counter_B
integer*8 ::lin
integer*8 ::lin8

real*8 ::xmolw

Expand Down
12 changes: 6 additions & 6 deletions stda-rw.f
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ subroutine rtdacorr_rw(nci,ncent,no,nv,mxcnf,iconf,dak,dax
real*8, intent(in) :: dak,dax,ed(mxcnf)
real*4, allocatable :: q1(:),q2(:),q3(:),bmat(:)
integer i,j,io,iv,jo,jv,ierr,iiv,jjv,iwrk,jwrk,l,k,moci
integer*8 ij,lin
integer*8 ij,lin8
real*4 ek,ej,sdot,ak,ax,de,fact,integral
ij=nci
ij=ij*(ij+1)/2
Expand All @@ -1898,7 +1898,7 @@ subroutine rtdacorr_rw(nci,ncent,no,nv,mxcnf,iconf,dak,dax
open(unit=740,file='pia',form='unformatted',status='old')
Do i=1, no
Do j=1, i
ij=lin(i,j)
ij=lin8(i,j)
read(710)pij(1:ncent,ij)
enddo
enddo
Expand All @@ -1907,10 +1907,10 @@ subroutine rtdacorr_rw(nci,ncent,no,nv,mxcnf,iconf,dak,dax
k=i-no
Do j=no+1, i-1
l=j-no
ij=lin(k,l)
ij=lin8(k,l)
read(73)qab(1:ncent,ij)
enddo
ij=lin(k,k)
ij=lin8(k,k)
read(72)qab(1:ncent,ij)
enddo
close(72)
Expand Down Expand Up @@ -1941,7 +1941,7 @@ subroutine rtdacorr_rw(nci,ncent,no,nv,mxcnf,iconf,dak,dax
iwrk=(io-1)*nv + iiv
q1(1:ncent)=pia(1:ncent,iwrk)
do j=1,i-1
ij=lin(i,j)
ij=lin8(i,j)
jo=iconf(j,1)
jv=iconf(j,2)
jjv=jv-no
Expand All @@ -1956,7 +1956,7 @@ subroutine rtdacorr_rw(nci,ncent,no,nv,mxcnf,iconf,dak,dax
ek=sdot(ncent,q2,1,q3,1) ! now ek = (ib|aj), results from Fock-exchange, thus we scale by ax
bmat(ij)=bmat(ij)-fact*ax*ek ! scaled by ax
enddo
ij=lin(i,i)
ij=lin8(i,i)
q2(1:ncent)=qia(1:ncent,iwrk)
ek=sdot(ncent,q1,1,q2,1)
bmat(ij)=fact*(ak*ek-ax*ek) ! diagonal element of 0.5*B
Expand Down
Loading

0 comments on commit 273a41b

Please sign in to comment.