Skip to content

Commit d1152a9

Browse files
committed
Fix issues preventing sucessful build with NAG compiler.
1 parent 262ab4a commit d1152a9

File tree

6 files changed

+95
-69
lines changed

6 files changed

+95
-69
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
*~
33
*.mod
44
dftd3
5-
libdftd3.a
6-
test_libdftd3
5+
lib/libdftd3.a
6+
prg/dftd3
7+
test/testapi

lib/api.f90

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ subroutine dftd3_dispersion(this, coords, izp, disp, grads)
149149

150150
allocate(fix(natom))
151151
fix(:) = .false.
152+
grads(:,:) = 0.0_wp
152153
call gdisp(max_elem, maxc, natom, coords, izp, this%c6ab, this%mxc, r2r4, &
153154
& this%r0ab, rcov, s6, s18, rs6, rs8, rs10, alp6, alp8, alp10, &
154155
& this%noabc, this%rthr, this%numgrad, this%version, .false., grads, &

lib/core.f90

+43-45
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,25 @@ module dftd3_core
4040
! with older versions. They should not imply any higher accuracy than
4141
! the old values
4242
data r2r4 / &
43-
& 2.00734898, 1.56637132, 5.01986934, 3.85379032, 3.64446594, &
44-
& 3.10492822, 2.71175247, 2.59361680, 2.38825250, 2.21522516, &
45-
& 6.58585536, 5.46295967, 5.65216669, 4.88284902, 4.29727576, &
46-
& 4.04108902, 3.72932356, 3.44677275, 7.97762753, 7.07623947, &
47-
& 6.60844053, 6.28791364, 6.07728703, 5.54643096, 5.80491167, &
48-
& 5.58415602, 5.41374528, 5.28497229, 5.22592821, 5.09817141, &
49-
& 6.12149689, 5.54083734, 5.06696878, 4.87005108, 4.59089647, &
50-
& 4.31176304, 9.55461698, 8.67396077, 7.97210197, 7.43439917, &
51-
& 6.58711862, 6.19536215, 6.01517290, 5.81623410, 5.65710424, &
52-
& 5.52640661, 5.44263305, 5.58285373, 7.02081898, 6.46815523, &
53-
& 5.98089120, 5.81686657, 5.53321815, 5.25477007, 11.02204549, &
54-
&10.15679528, 9.35167836, 9.06926079, 8.97241155, 8.90092807, &
55-
& 8.85984840, 8.81736827, 8.79317710, 7.89969626, 8.80588454, &
56-
& 8.42439218, 8.54289262, 8.47583370, 8.45090888, 8.47339339, &
57-
& 7.83525634, 8.20702843, 7.70559063, 7.32755997, 7.03887381, &
58-
& 6.68978720, 6.05450052, 5.88752022, 5.70661499, 5.78450695, &
59-
& 7.79780729, 7.26443867, 6.78151984, 6.67883169, 6.39024318, &
60-
& 6.09527958, 11.79156076, 11.10997644, 9.51377795, 8.67197068, &
61-
& 8.77140725, 8.65402716, 8.53923501, 8.85024712 /
43+
&2.00734898_wp, 1.56637132_wp, 5.01986934_wp, 3.85379032_wp, 3.64446594_wp,&
44+
&3.10492822_wp, 2.71175247_wp, 2.59361680_wp, 2.38825250_wp, 2.21522516_wp,&
45+
&6.58585536_wp, 5.46295967_wp, 5.65216669_wp, 4.88284902_wp, 4.29727576_wp,&
46+
&4.04108902_wp, 3.72932356_wp, 3.44677275_wp, 7.97762753_wp, 7.07623947_wp,&
47+
&6.60844053_wp, 6.28791364_wp, 6.07728703_wp, 5.54643096_wp, 5.80491167_wp,&
48+
&5.58415602_wp, 5.41374528_wp, 5.28497229_wp, 5.22592821_wp, 5.09817141_wp,&
49+
&6.12149689_wp, 5.54083734_wp, 5.06696878_wp, 4.87005108_wp, 4.59089647_wp,&
50+
&4.31176304_wp, 9.55461698_wp, 8.67396077_wp, 7.97210197_wp, 7.43439917_wp,&
51+
&6.58711862_wp, 6.19536215_wp, 6.01517290_wp, 5.81623410_wp, 5.65710424_wp,&
52+
&5.52640661_wp, 5.44263305_wp, 5.58285373_wp, 7.02081898_wp, 6.46815523_wp,&
53+
&5.98089120_wp, 5.81686657_wp, 5.53321815_wp, 5.25477007_wp,11.02204549_wp,&
54+
&0.15679528_wp, 9.35167836_wp, 9.06926079_wp, 8.97241155_wp, 8.90092807_wp,&
55+
&8.85984840_wp, 8.81736827_wp, 8.79317710_wp, 7.89969626_wp, 8.80588454_wp,&
56+
&8.42439218_wp, 8.54289262_wp, 8.47583370_wp, 8.45090888_wp, 8.47339339_wp,&
57+
&7.83525634_wp, 8.20702843_wp, 7.70559063_wp, 7.32755997_wp, 7.03887381_wp,&
58+
&6.68978720_wp, 6.05450052_wp, 5.88752022_wp, 5.70661499_wp, 5.78450695_wp,&
59+
&7.79780729_wp, 7.26443867_wp, 6.78151984_wp, 6.67883169_wp, 6.39024318_wp,&
60+
&6.09527958_wp,11.79156076_wp,11.10997644_wp, 9.51377795_wp, 8.67197068_wp,&
61+
&8.77140725_wp, 8.65402716_wp, 8.53923501_wp, 8.85024712_wp /
6262

6363
! PBE0/def2-QZVP atomic values
6464
! data r2r4 /
@@ -154,25 +154,25 @@ module dftd3_core
154154
! these new data are scaled with k2=4./3. and converted a_0 via
155155
! autoang=0.52917726d0
156156
data rcov/ &
157-
& 0.80628308, 1.15903197, 3.02356173, 2.36845659, 1.94011865, &
158-
& 1.88972601, 1.78894056, 1.58736983, 1.61256616, 1.68815527, &
159-
& 3.52748848, 3.14954334, 2.84718717, 2.62041997, 2.77159820, &
160-
& 2.57002732, 2.49443835, 2.41884923, 4.43455700, 3.88023730, &
161-
& 3.35111422, 3.07395437, 3.04875805, 2.77159820, 2.69600923, &
162-
& 2.62041997, 2.51963467, 2.49443835, 2.54483100, 2.74640188, &
163-
& 2.82199085, 2.74640188, 2.89757982, 2.77159820, 2.87238349, &
164-
& 2.94797246, 4.76210950, 4.20778980, 3.70386304, 3.50229216, &
165-
& 3.32591790, 3.12434702, 2.89757982, 2.84718717, 2.84718717, &
166-
& 2.72120556, 2.89757982, 3.09915070, 3.22513231, 3.17473967, &
167-
& 3.17473967, 3.09915070, 3.32591790, 3.30072128, 5.26603625, &
168-
& 4.43455700, 4.08180818, 3.70386304, 3.98102289, 3.95582657, &
169-
& 3.93062995, 3.90543362, 3.80464833, 3.82984466, 3.80464833, &
170-
& 3.77945201, 3.75425569, 3.75425569, 3.72905937, 3.85504098, &
171-
& 3.67866672, 3.45189952, 3.30072128, 3.09915070, 2.97316878, &
172-
& 2.92277614, 2.79679452, 2.82199085, 2.84718717, 3.32591790, &
173-
& 3.27552496, 3.27552496, 3.42670319, 3.30072128, 3.47709584, &
174-
& 3.57788113, 5.06446567, 4.56053862, 4.20778980, 3.98102289, &
175-
& 3.82984466, 3.85504098, 3.88023730, 3.90543362 /
157+
& 0.80628308_wp, 1.15903197_wp, 3.02356173_wp, 2.36845659_wp, 1.94011865_wp, &
158+
& 1.88972601_wp, 1.78894056_wp, 1.58736983_wp, 1.61256616_wp, 1.68815527_wp, &
159+
& 3.52748848_wp, 3.14954334_wp, 2.84718717_wp, 2.62041997_wp, 2.77159820_wp, &
160+
& 2.57002732_wp, 2.49443835_wp, 2.41884923_wp, 4.43455700_wp, 3.88023730_wp, &
161+
& 3.35111422_wp, 3.07395437_wp, 3.04875805_wp, 2.77159820_wp, 2.69600923_wp, &
162+
& 2.62041997_wp, 2.51963467_wp, 2.49443835_wp, 2.54483100_wp, 2.74640188_wp, &
163+
& 2.82199085_wp, 2.74640188_wp, 2.89757982_wp, 2.77159820_wp, 2.87238349_wp, &
164+
& 2.94797246_wp, 4.76210950_wp, 4.20778980_wp, 3.70386304_wp, 3.50229216_wp, &
165+
& 3.32591790_wp, 3.12434702_wp, 2.89757982_wp, 2.84718717_wp, 2.84718717_wp, &
166+
& 2.72120556_wp, 2.89757982_wp, 3.09915070_wp, 3.22513231_wp, 3.17473967_wp, &
167+
& 3.17473967_wp, 3.09915070_wp, 3.32591790_wp, 3.30072128_wp, 5.26603625_wp, &
168+
& 4.43455700_wp, 4.08180818_wp, 3.70386304_wp, 3.98102289_wp, 3.95582657_wp, &
169+
& 3.93062995_wp, 3.90543362_wp, 3.80464833_wp, 3.82984466_wp, 3.80464833_wp, &
170+
& 3.77945201_wp, 3.75425569_wp, 3.75425569_wp, 3.72905937_wp, 3.85504098_wp, &
171+
& 3.67866672_wp, 3.45189952_wp, 3.30072128_wp, 3.09915070_wp, 2.97316878_wp, &
172+
& 2.92277614_wp, 2.79679452_wp, 2.82199085_wp, 2.84718717_wp, 3.32591790_wp, &
173+
& 3.27552496_wp, 3.27552496_wp, 3.42670319_wp, 3.30072128_wp, 3.47709584_wp, &
174+
& 3.57788113_wp, 5.06446567_wp, 4.56053862_wp, 4.20778980_wp, 3.98102289_wp, &
175+
& 3.82984466_wp, 3.85504098_wp, 3.88023730_wp, 3.90543362_wp /
176176

177177

178178
contains
@@ -2259,7 +2259,9 @@ end subroutine setr0ab
22592259
subroutine stoprun(s)
22602260
character*(*) s
22612261
write(*,*)'program stopped due to: ',s
2262-
call system('touch dscf_problem')
2262+
open(99, file='dscf_problem', action='write', status='replace')
2263+
close(99)
2264+
!call system('touch dscf_problem')
22632265
stop 'must stop!'
22642266
end subroutine stoprun
22652267

@@ -3022,9 +3024,6 @@ subroutine pbcgdisp(max_elem,maxc,n,xyz,iz,c6ab,mxc,r2r4,r0ab,&
30223024
real(wp) bj_dmp6,bj_dmp8
30233025
logical noabc,num,echo
30243026
! coversion factors
3025-
REAL(WP), parameter ::autoang =0.52917726d0
3026-
REAL(WP), parameter ::autokcal=627.509541d0
3027-
REAL(WP), parameter ::autoev=27.211652d0
30283027

30293028
integer iat,jat,i,j,kat,my,ny,a,b,idum,tau2
30303029
real(wp) R0,C6,alp,R42,disp,x1,y1,z1,x2,y2,z2,rr,e6abc,fdum
@@ -3456,6 +3455,7 @@ subroutine pbcgdisp(max_elem,maxc,n,xyz,iz,c6ab,mxc,r2r4,r0ab,&
34563455
drij=0.0d0
34573456
dc6_rest=0.0d0
34583457
dc6_rest_sum=0.0d0
3458+
dc6i(:) = 0.0d0
34593459
kat=0
34603460

34613461
do iat=1,n
@@ -4377,7 +4377,6 @@ subroutine pbcgdisp(max_elem,maxc,n,xyz,iz,c6ab,mxc,r2r4,r0ab,&
43774377
do iat=2,n
43784378
do jat=1,iat-1
43794379
linij=lin(iat,jat)
4380-
! write(*,'(3E17.6,XX,2I2)'),drij(0,0,-1:1,lin(iat,jat)),iat,jat
43814380
rcovij=rcov(iz(iat))+rcov(iz(jat))
43824381
do taux=-rep_v(1),rep_v(1)
43834382
do tauy=-rep_v(2),rep_v(2)
@@ -4397,7 +4396,6 @@ subroutine pbcgdisp(max_elem,maxc,n,xyz,iz,c6ab,mxc,r2r4,r0ab,&
43974396
dcnn=0.0d0
43984397
end if
43994398
x1=drij(tauz,tauy,taux,linij)+dcnn*(dc6i(iat)+dc6i(jat))
4400-
44014399
vec=x1*rij/r
44024400
g(:,iat)=g(:,iat)+vec
44034401
g(:,jat)=g(:,jat)-vec
@@ -4812,10 +4810,10 @@ end subroutine inv_cell
48124810
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
48134811

48144812
subroutine xyz_to_abc(xyz,abc,lat,n)
4813+
integer,intent(in) :: n
48154814
real(wp), INTENT(in) :: xyz(3,n)
48164815
real(wp), intent(in) :: lat(3,3)
48174816
real(wp), intent(out) :: abc(3,n)
4818-
integer,intent(in) :: n
48194817

48204818
real(wp) lat_1(3,3)
48214819
integer i,j,k

make.arch

+14
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ ifeq ($(OSTYPE),LINUXI)
2727
FCFLAGS = -w90 -O
2828
#LNFLAGS =
2929
endif
30+
31+
ifeq ($(COMP),nagfor)
32+
FC = nagfor
33+
LN = nagfor
34+
FCFLAGS = -nan -C #-ieee=full
35+
LNFLAGS =
36+
endif
37+
38+
ifeq ($(COMP),ifort)
39+
FC = ifort
40+
LN = ifort
41+
FCFLAGS = -C
42+
LNFLAGS =
43+
endif

prg/extras.f90

+6-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ subroutine rdpar(dtmp,version,s6,s18,rs6,rs18,alp)
9797
return
9898
end if
9999
! read parameter file from home directory
100-
call system('hostname > .tmpx')
100+
!call system('hostname > .tmpx')
101+
call execute_command_line('hostname > .tmpx')
101102
open(unit=43,file='.tmpx')
102103
read(43,'(a)')ftmp
103104
close(43,status='delete')
@@ -801,7 +802,8 @@ subroutine wregrad(nat,xyz,iat,edisp,g)
801802
close(42)
802803
close(43)
803804

804-
call system('mv gradient.tmp gradient')
805+
!call system('mv gradient.tmp gradient')
806+
call execute_command_line('mv gradient.tmp gradient')
805807

806808
! write file energy
807809
j=1
@@ -834,7 +836,8 @@ subroutine wregrad(nat,xyz,iat,edisp,g)
834836
close(42)
835837
close(43)
836838

837-
call system('mv energy.tmp energy')
839+
!call system('mv energy.tmp energy')
840+
call execute_command_line('mv energy.tmp energy')
838841

839842
end subroutine wregrad
840843

prg/main.f90

+28-19
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,17 @@ program dftd3_main
154154

155155

156156
! get coord filename
157-
call getarg(1,etmp)
157+
!call getarg(1,etmp)
158+
call get_command_argument(1,etmp)
158159
inquire(file=etmp,exist=ex)
159160
if (.not.ex) call printoptions
160161
ex=.false.
161162
ipot=0
162163
! options
163-
do i=1,iargc()
164-
call getarg(i,ftmp)
164+
!do i=1,iargc()
165+
do i = 1, command_argument_count()
166+
!call getarg(i,ftmp)
167+
call get_command_argument(i, ftmp)
165168
if (index(ftmp,'-h') .ne.0) call printoptions
166169
if (index(ftmp,'-grad' ).ne.0) grad=.true.
167170
if (index(ftmp,'-anal' ).ne.0) anal=.true.
@@ -177,7 +180,8 @@ program dftd3_main
177180
minc6=.true.
178181
j=0
179182
do
180-
call getarg(i+j+1,atmp)
183+
!call getarg(i+j+1,atmp)
184+
call get_command_argument(i+j+1,atmp)
181185
if (index(atmp,'-').eq.0.and.atmp.ne.'') then
182186
call elem(atmp,nn)
183187
if (nn.gt.max_elem.or.nn.lt.1) &
@@ -193,7 +197,8 @@ program dftd3_main
193197
maxc6=.true.
194198
k=0
195199
do
196-
call getarg(i+k+1,atmp)
200+
!call getarg(i+k+1,atmp)
201+
call get_command_argument(i+k+1,atmp)
197202
if (index(atmp,'-').eq.0.and.atmp.ne.'') then
198203
call elem(atmp,nn)
199204
if (nn.gt.max_elem.or.nn.lt.1) &
@@ -207,25 +212,29 @@ program dftd3_main
207212
end if
208213
if (index(ftmp,'-pot') .ne.0) then
209214
pot=.true.
210-
call getarg(i+1,atmp)
215+
!call getarg(i+1,atmp)
216+
call get_command_argument(i+1,atmp)
211217
call readl(atmp,xx,nn)
212218
ipot=idint(xx(1))
213219
end if
214220
if (index(ftmp,'-cnthr') .ne.0) then
215-
call getarg(i+1,atmp)
221+
!call getarg(i+1,atmp)
222+
call get_command_argument(i+1,atmp)
216223
call readl(atmp,xx,nn)
217224
rthr2=xx(1)
218225
rthr2=rthr2**2
219226
end if
220227
if (index(ftmp,'-func') .ne.0) then
221-
call getarg(i+1,func)
228+
!call getarg(i+1,func)
229+
call get_command_argument(i+1,func)
222230
ex=.true.
223231
end if
224232

225233

226234

227235
if (index(ftmp,'-cutoff') .ne.0) then
228-
call getarg(i+1,atmp)
236+
!call getarg(i+1,atmp)
237+
call get_command_argument(i+1,atmp)
229238
call readl(atmp,xx,nn)
230239
rthr=xx(1)**2
231240
end if
@@ -369,11 +378,11 @@ program dftd3_main
369378

370379
! output
371380
if (echo) then
372-
write(*,'(/''# XYZ [au] '',12x,&
373-
& '' R0(AA) [Ang.]''2x,&
374-
& ''CN'',7x,&
375-
& ''C6(AA) C8(AA) C10(AA) [au] '')&
376-
& ')
381+
write(*,"(/'# XYZ [au] ',12x,&
382+
& ' R0(AA) [Ang.]',2x,&
383+
& 'CN',7x,&
384+
& 'C6(AA) C8(AA) C10(AA) [au] ')&
385+
& ")
377386
x=0
378387
btmp=''
379388
do i=1,n
@@ -393,7 +402,7 @@ program dftd3_main
393402
atmp='f'
394403
btmp='f'
395404
end if
396-
write(*,'(i4,3F10.5,3x,a2,1x,a1,F7.3,2x,F7.3,3F12.1,L)') &
405+
write(*,'(i4,3F10.5,3x,a2,1x,a1,F7.3,2x,F7.3,3F12.1,L2)') &
397406
& i,xyz(1:3,i),esym(z),atmp, &
398407
& dum,cn(i), &
399408
& c6,c8,c10
@@ -576,7 +585,7 @@ program dftd3_main
576585
! end if
577586
write(*,*)
578587
if (pbc) then
579-
write(*,'('' Edisp /kcal,au,eV:'',f11.4,X,f12.8,X,f11.7)') &
588+
write(*,'('' Edisp /kcal,au,eV:'',f11.4,1X,f12.8,1X,f11.7)') &
580589
& disp*autokcal,disp,disp*autoev
581590
else
582591
write(*,'('' Edisp /kcal,au:'',f11.4,f12.8)') disp*autokcal,disp
@@ -643,8 +652,8 @@ program dftd3_main
643652
! check if gdisp yields same energy as edisp
644653
dum=abs((disp-gdsp)/disp)
645654
!if this check gives compiler errors, replace is with a different NaN ch
646-
if (ISNAN(dum)) call stoprun('internal NaN-error')
647-
! if (dum/=dum) call stoprun('internal NaN-error')
655+
!if (ISNAN(dum)) call stoprun('internal NaN-error')
656+
if (dum/=dum) call stoprun('internal NaN-error')
648657
if (dum.gt.1.d-8) then
649658
write(*,*) disp,gdsp
650659
call stoprun('internal error')
@@ -756,7 +765,7 @@ program dftd3_main
756765
lat(j,i)=lat(j,i)+dum1
757766
call abc_to_xyz(abc,xyz,lat,n)
758767

759-
write(*,'("L"2i1,2E14.6)'),i,j,dum,g_lat(j,i)
768+
write(*,'("L",2i1,2E14.6)') i,j,dum,g_lat(j,i)
760769
!j
761770
end do
762771
!i

0 commit comments

Comments
 (0)