1
c*****************************************************************************
2
subroutine wefgfile(rtdb,
9
c*****************************************************************************
11
c>>> Purpose of routine:
13
c>>> This subroutine reads information from the runtime database
14
c>>> and prints it out to a file, name=nbo_fname, which is used
15
c>>> as input to the standalone version of the natural bond orbital
16
c>>> (NBO) analysis program, gennbo.
18
c>>> Dependencies/Effects:
20
c The rtdb is read only and not modified.
21
c No common blocks are created.
22
c A file, (lfn=25, name=nbo_fname), is created.
23
c All variables except for rtdb are local.
27
c>>> Eventually, it may be desirable to have the NBO analysis executed
28
c>>> as a subroutine of NWchem rather than as a separate stand alone
29
c>>> program. To do this one will have to make a subroutine similar
30
c>>> to the one here, but instead of writing the data to an input file
31
c>>> it will need to be passed to NBO interface subroutines, (see the
32
c>>> NBO programmers manual for details). The current strategy was
33
c>>> chosen to reduce the binary size of NWchem (the size of the NBO
34
c>>> executable is not negligible), and to take advantage of the fact
35
c>>> that gennbo already exists and has been ported to a number of
39
* $Id: wefgfile.F 21401 2011-11-04 18:22:41Z bert $
46
#include "mafdecls.fh"
49
#include "zora.fh" ! FA-04-24-10
50
c Using g_Ci defined in zora.fh, computed in dft_zora_scale() from dft_zora_utils.F
56
integer lbasis, lchg, lcoef,lcoord, leval, lexp, lgeom, lind1,
57
$ lind2, locc, lprim, lptr, lscr, ltags, ltype,
59
integer g_bo(2), g_fock(2), g_movecs(2), g_over, g_scr
63
integer ichg, icoef, icoord, ieval, iexp, iind1, iind2, iocc,
64
$ iprim, iptr, iscr, itags, itype,
67
c>>> basis set objects
69
integer atn, charge, maxL, nat, nbf, ncont, ngeno, nmo,
70
$ nprim, sphcart, type
72
character*255 name, title, trans
74
c>>> things related to the NBO input file
77
character*255 nbo_fname
79
c>>> MO vector and calculation-type objects
82
character*255 bas_vecs, movecs_in, title_vecs
83
character*20 scftype_vecs
84
integer lenocc, nbf_vecs, nset, nmo_vecs(2)
90
logical movecs_read, restricted, movecs_read_header
91
integer inp_strlen, ga_create_atom_blocked
93
external int_normalize
94
external inp_strlen, ga_create_atom_blocked, movecs_read,
98
c>>> miscellaneous variables
101
integer i,iat,iat1,icol,icont,
102
& ilo,ihi,index,ix,iy,iz,j,
104
logical sshell, pshell, dshell, fshell, gshell
105
data cname / 'CS = ', 'CP = ', 'CD = ', 'CF = ', 'CG = ' /
107
integer l_Ci,k_Ci, ! FA-scaling-zora
108
& l_qscal,k_qscal,noc(2),indq,count_qscal,indx_inc
109
integer ipol,noc1,nocc,nelec
111
c Assuming noc1=noc2 not true if (total spin .ne. 0)
112
c (noc_alpha = noc_beta)
113
character*11 fname_efg
114
integer nocc_a,nocc_b,idir,jlo,jhi
115
integer l_buf,k_buf,indx
116
integer g_munu_rot,nlst,
117
& Ndir_munu,Natoms_munu,Nel,
118
& atmnr_munu(Natoms_munu)
119
double precision threshold4data
120
data threshold4data /1e-40/ ! Threshhold for output data
121
if (ga_nodeid().eq.0)
122
& write(*,*) 'Using data threshold :',threshold4data
123
c --> To store ONLY munu principal components xx,yy,zz
124
c Structure of g_munu_rot:
125
c n=nbf Nr. of basis functions
126
c val_11_1_1 val_22_1_1 ... val_nn_1_1 val_21_1_1
127
c val_31_1_1 val_32_1_1
128
c val_41_1_1 val_42_1_1 val_43_1_1
130
c val_11_2_1 val_22_2_1 ... val_nn_2_1 val_21_2_1
131
c val_31_2_1 val_32_2_1
132
c val_41_2_1 val_42_2_1 val_43_2_1
135
c val_11_1_2 val_22_1_2 ... val_nn_1_2 val_21_1_2
136
c val_31_1_2 val_32_1_2
137
c val_41_1_2 val_42_1_2 val_43_1_2
139
c val_11_2_2 val_22_2_2 ... val_nn_2_2 val_21_2_2
140
c val_31_2_2 val_32_2_2
141
c val_41_2_2 val_42_2_2 val_43_2_2
143
c Notation.- val_PQ_R_S
144
c PQ, unique munu indices
145
c R, direction index = 1,2,3 (in this order)
146
c S, atom number R=1,nlist
147
c Correspondence with EFG eigenvalues:
149
c -> If multiplied with corresponding
150
c scaling density matrix it produces
151
c the total EFG eigenvalues in the same order
152
c as NWChem standard output.
153
c nlist total number of atoms selected in
154
c keyword of input script: efieldgradZ4 [nlist] ...
157
c ======= reading from rtdb (nocc_a,nocc_b) === START
158
if (.not. rtdb_get(rtdb, 'prop:Nocc_a',mt_int,
160
$ call errquit('prop_input-EFGZ4-Nocc_a: rtdb_put failed',
162
if (.not. rtdb_get(rtdb, 'prop:Nocc_b',mt_int,
164
$ call errquit('prop_input-EFGZ4-Nocc_b: rtdb_put failed',
166
c ======= reading from rtdb (nocc_a,nocc_b) === END
167
c ------ Lines below are not necessary ------ START
169
c if(ga_nodeid().eq.0) then
170
c call util_file_name('hyp', .false., .false., nbo_fname)
171
c open(lfn,file=nbo_fname,status='unknown')
172
c len = inp_strlen(nbo_fname)
173
c write(LUout,9250) nbo_fname(1:len)
175
c ------ Lines below are not necessary ------ END
177
c ... Fredy: read EFG option key fron RTDB.
179
if (.not.rtdb_get(rtdb, 'prop:efgopt', mt_int, 1,efgopt))
180
& call errquit('wefgfile: efgopt RTDB failed',0, RTDB_ERR)
183
c>>> load geometry and symmetry info
185
if (.not. geom_create(lgeom, 'geometry'))
186
$ call errquit('wnbofile: geom_create?', 0, GEOM_ERR)
187
if (.not. geom_rtdb_load(rtdb, lgeom, 'geometry'))
188
$ call errquit('wnbofile: no geometry ', 0, RTDB_ERR)
190
c>>> load the basis set and get info about it
192
if (.not. bas_create(lbasis, 'mo basis'))
193
$ call errquit('prop: bas_create?', 0, BASIS_ERR)
194
if (.not. bas_rtdb_load(rtdb, lgeom, lbasis, 'ao basis')) then
195
if (.not. bas_rtdb_load(rtdb, lgeom, lbasis, 'mo basis'))
196
$ call errquit('wnbofile: no mo or ao basis set', 0,
199
if (.not. bas_name(lbasis, name, trans))
200
$ call errquit('wnbofile: bas_name?', 0, BASIS_ERR)
202
c>>> Create ga_array for movecs.
204
if ( .not. bas_numbf(lbasis,nbf) )
205
$ call errquit('wnbofile: bas_numbf failed', 1, BASIS_ERR)
207
c>>> For now simply set nmo = nbf.
211
c>>> Get information on molecular orbital vectors.
213
call util_file_name('movecs', .false., .false., movecs_in)
214
if(.not.movecs_read_header(movecs_in, title_vecs, bas_vecs,
215
$ scftype_vecs, nbf_vecs, nset, nmo_vecs, 2))
216
$ call errquit('wnbofile: failed on movecs_read_header',0,
227
c>>> Extract title, geometry, nuclear charges, and label info.
228
if (.not. geom_ncent(lgeom, nat))
229
$ call errquit('wnbofile: geom_ncent failed',1, GEOM_ERR)
231
c>>> Begin $GENNBO and $NBO keylist data.
232
c ++++++++++++++++++++++++++++++++++++++++++
233
c ++++++++++++ EFG printout ++++++++++ START
243
if (do_zora .and. so_term.eq.0 .and.
244
& .not.(not_zora_scale)) lzora=.true.
245
if (lzora) then ! spin-free-zora
246
if (.not.ma_alloc_get(mt_dbl,nset*nocc,'Ci',l_Ci,k_Ci))
247
& call errquit('wefgfile: ma failed',0,MA_ERR)
248
if (.not.ma_alloc_get(mt_dbl,nocc,'qscal',l_qscal,k_qscal))
249
& call errquit('wefgfile: ma failed',0,MA_ERR)
251
if (ga_nodeid().eq.0)
252
& write(*,*) '-------g_Ci---------- START'
254
if (ga_nodeid().eq.0)
255
& write(*,*) '-------g_Ci---------- END'
257
call ga_get(g_Ci,1,nset,1,nocc,dbl_mb(k_Ci),nset)
260
else if (nset.eq.2) then
263
write(*,*) "ERROR in wefgfile:: nset=1 or 2 ..."
268
indx=i ! =1 for alpha (ODD nrs) =2 for beta (even nrs)
270
indq=k_qscal+count_qscal-1
271
dbl_mb(indq)=dbl_mb(k_Ci+indx-1)
273
if (dbl_mb(indq) .ne. 0.0d0)
274
& dbl_mb(indq)=dbl_mb(indq)-1.0d0
276
if (ga_nodeid().eq.0) then
278
& dbl_mb(indq),1.0d0/(1.0d0+dbl_mb(indq)),
279
& 1.0d0/(1.0d0+dbl_mb(indq))**0.5d0
280
7 format('wefgfile::qscal(',i4,',',i4,')=(',f15.8,',',
281
& f15.8,',',f15.8,')')
283
count_qscal=count_qscal+1
289
if( ga_nodeid().eq.0) then ! ------- nodeid0----- START
290
c ... now a loop over the EFG components, idir = 1,3.
291
c number of components was given in namelist
292
c ==> nlst=nbf*(nbf+1)
293
if (.not.ma_alloc_get(mt_dbl,nlst,'buf',
295
& call errquit('wefgfile-buf: ma failed',0,MA_ERR)
296
do iat1=1,Natoms_munu
298
c=====================================
299
c ==== Generate filename per atom here
300
c ====================================
301
write (fname_efg,1) iat
302
1 format('efgdata.',i0)
303
write(*,*) 'Writing filename=',fname_efg
304
open (lfn, file=fname_efg, status='unknown')
306
& '(a,i10,a,i10,a,i10,/a,i10,a,i10,a,i10,a,i10,/a,l3,a/a)')
307
& '&inputdata nbasis=',nbf,
310
& ', nocc_a=',nocc_a,
311
& ', nocc_b=',nocc_b,
314
& ', threshold = 0.0, lzora=',lzora,
315
& ', spinorbit= F , label=''EFG'', components=3',
316
& ', nbofile=''nbodata'', antisym = F, fullmat = F /'
317
if (lzora) then ! spin-free-zora
318
c ----move down: g_Ci scaling factors
319
write (lfn,'(a)') 'ZORA MO scaling factors'
320
write (lfn, '(3e25.16)' ) (dbl_mb(k_qscal+i-1), i = 1,nocc)
323
jlo=nlst*Ndir_munu*(iat1-1)+
326
call dcopy(nlst,0.0d0,0,dbl_mb(k_buf),1)
327
call ga_get(g_munu_rot,1,1,jlo,jhi,
330
if (abs(dbl_mb(k_buf+i)) .lt. threshold4data)
331
& dbl_mb(k_buf+i)=0.0d0
333
write (lfn,'(a,i1)') 'h1mat for direction ',idir
334
write (lfn,'(3e25.16)' )
335
& (dbl_mb(k_buf+i), i = 0,nlst-1)
336
enddo ! end-loop-directions
337
close(lfn) ! close efgdata
338
enddo ! end-loop-atoms
339
if (.not.ma_free_heap(l_buf)) call
340
& errquit('munu4nbo: ma_free_heap l_buf',0, MA_ERR)
342
if (.not.ma_free_heap(l_Ci)) call
343
& errquit('wshldfile: ma_free_heap l_Ci',0, MA_ERR)
344
if (.not.ma_free_heap(l_qscal)) call
345
& errquit('wgshiftfile: ma_free_heap l_qscal',0, MA_ERR)
347
endif ! ------- nodeid0----- START
349
if (ga_nodeid().eq.0) then ! ------ if-ga_nodeid-1--- START
350
if(.not. rtdb_cget(rtdb, 'title', 1, title)) title = ' '
351
if(.not.Ma_Push_Get(MT_Dbl, nat*3, 'coordinates',
353
$ call errquit('wnbofile: push_get failed',2, MA_ERR)
354
if(.not.Ma_Push_Get(MT_Dbl, nat, 'charges', lchg, ichg))
355
$ call errquit('wnbofile: push_get failed',3, MA_ERR)
356
if(.not.Ma_Push_Get(MT_Byte, nat*16, 'center tags',
358
$ call errquit('wnbofile: push_get failed',4, MA_ERR)
359
if(.not.geom_cart_get(lgeom, nat, Byte_MB(itags),
360
& Dbl_MB(icoord),Dbl_MB(ichg)))
361
$ call errquit('wnbofile: geom_cart_get failed',5, GEOM_ERR)
364
if (.not. ga_create(MT_DBL, nbf, nmo, 'wnbofile: MOs',
365
$ 0, 0, g_movecs(1))) call errquit('wnbofile: MOs', 0,
367
call ga_zero(g_movecs(1))
370
if (.not. ga_create(MT_DBL, nbf, nmo, 'wnbofile: alpha MOs',
371
$ 0, 0, g_movecs(1))) call errquit('wnbofile: alpha MOs', 0,
373
call ga_zero(g_movecs(1))
375
if (.not. ga_create(MT_DBL, nbf, nmo, 'wnbofile: beta MOs',
376
$ 0, 0, g_movecs(2))) call errquit('wnbofile: beta MOs', 0,
378
call ga_zero(g_movecs(2))
381
open (lfn, file='nbodata.f47_extra', status='unknown')
382
c ++++++++++++ EFG printout ++++++++++ END
383
c ++++++++++++++++++++++++++++++++++++++++
384
write(lfn,9000) nat, nbf, spintype
385
9000 format('$GENNBO UPPER BODM BOHR NATOMS=',i5,
386
$ ' NBAS=',i5,2x,a4,' $END')
388
c ... Fredy: here we write more detailed NBO input if requested.
389
if (efgopt.eq.0) then ! default
390
write(lfn,'(a)')'$NBO $END'
391
else if (efgopt.eq.1) then ! generate NLMOs, too, and dump info to files
392
write(lfn,'(a/a)')'$NBO BNDIDX NBONLMO=W AONBO=W AONLMO=W ',
393
$ ' NLMOMO=W STERIC FILE=nbodata $END'
394
else if (efgopt.eq.2) then ! generate even more info, incl AO overlap etc.
395
write(lfn,'(a/a)')'$NBO BNDIDX NBONLMO=W AONBO=W AONLMO=W ',
396
$ ' NLMOMO=W AOMO=W SAO=W STERIC FILE=nbodata $END'
397
else ! other options not supported. Fall back to default
398
write(lfn,'(a)')'$NBO $END'
401
endif ! ------ if-ga_nodeid-1--- END
402
c ------- Destroy ga arrays -----------
403
c if (.not. ga_destroy(g_Ci)) call errquit( ! destroy GA - FA
404
c & 'wefgfile: ga_destroy failed ',0, GA_ERR)
406
c>>> End $GENNBO and $NBO keylist data.
408
c>>> Begin $COORD keylist.
409
if( ga_nodeid().eq.0)then
410
write(lfn,9100)title(1:80)
411
9100 format('$COORD',/,a)
415
ix = 3*(iat-1) + icoord
418
index = itags+(iat-1)*16
420
if(.not.geom_tag_to_element(Byte_MB(index),sym,elem,atn))
421
cedo $ call errquit('wnbofile: geom_tag_to_element failed',1)
427
charge = Dbl_MB(ichg+iat-1)
428
write(lfn,9150)atn, charge, Dbl_MB(ix), Dbl_MB(iy), Dbl_MB(iz)
432
9150 format(i3,2x,i3,2x,3f20.10)
436
c>>> End $COORD keylist.
438
c>>> Begin $BASIS keylist.
441
if(.not.bas_numcont(lbasis,ncont))
442
$ call errquit('wnbofile: bas_numcont failed',0, BASIS_ERR)
444
if(.not.MA_Push_Get(MT_INT,ncont,'prim/shell',lprim,iprim))
445
$ call errquit('wnbofile: lprim memory alloc. failed',0,
448
if(.not.MA_Push_Get(MT_INT,ncont+1,'contraction pointer',lptr,
450
$ call errquit('wnbofile: lptr memory alloc. failed',0,
453
if(.not.MA_Push_Get(MT_INT,ncont,'contraction type',ltype,
455
$ call errquit('wnbofile: ltype memory alloc. failed',0,
458
if(.not.MA_Push_Get(MT_INT,ncont,'contraction/shell size',lncomp,
460
$ call errquit('wnbofile: lncomp memory alloc. failed',0,
463
if(ga_nodeid().eq.0)then
464
write(lfn,'(a)')'$BASIS'
465
if(.not.MA_Alloc_Get(MT_Int,nbf,'scratch',lscr,iscr))
466
$ call errquit('wnbofile: lscr memory alloc. failed',0,
469
if(.not.bas_bf2ce(lbasis,i,int_mb(iscr+i-1)))
470
$ call errquit('wnbofile: bas_bf2ce failed',0, BASIS_ERR)
473
write(lfn,'(1x,a)')'CENTER = '
474
write(lfn,'(5x,10i6)') (int_mb(iscr+i-1),i=1,nbf)
483
if(.not.bas_continfo(lbasis,icont,type,int_mb(iprim+icont-1),
485
$ call errquit('wnbofile: bas_continfo failed',0,
487
INT_mb(itype+icont-1) = type
488
maxL = max(maxL,type)
489
nprim = nprim + int_mb(iprim+icont-1)
491
$ int_mb(iptr+icont-1) + int_mb(iprim+icont-1)
498
int_mb(index+1) = 101
499
int_mb(index+2) = 102
500
int_mb(index+3) = 103
502
if( sphcart.eq.0)then
503
int_mb(index+4) = 201
504
int_mb(index+5) = 202
505
int_mb(index+6) = 203
506
int_mb(index+7) = 204
507
int_mb(index+8) = 205
508
int_mb(index+9) = 206
510
int_mb(incomp+icont-1) = 10
511
elseif(sphcart.eq.1)then
512
int_mb(index+4) = 251
513
int_mb(index+5) = 252
514
int_mb(index+6) = 253
515
int_mb(index+7) = 254
516
int_mb(index+8) = 255
518
int_mb(incomp+icont-1) = 10
521
elseif(type.eq.-1) then
526
int_mb(index+1) = 101
527
int_mb(index+2) = 102
528
int_mb(index+3) = 103
530
int_mb(incomp+icont-1) = 4
532
elseif(type.eq.0) then
538
int_mb(incomp+icont-1) = 1
540
elseif(type.eq.1) then
545
int_mb(index+j) = 101+j
548
int_mb(incomp+icont-1) = 3
550
elseif(type.eq.2) then
554
if( sphcart.eq.0)then
556
int_mb(index+j) = 201+j
559
int_mb(incomp+icont-1) = 6
560
elseif(sphcart.eq.1)then
563
int_mb(index+j) = 251+j
566
int_mb(incomp+icont-1) = 5
569
elseif(type.eq.3) then
575
int_mb(index+j) = 301+j
578
int_mb(incomp+icont-1) = 10
579
elseif(sphcart.eq.1)then
582
int_mb(index+j) = 351+j
585
int_mb(incomp+icont-1) = 7
588
elseif(type.eq.4) then
594
int_mb(index+j) = 401+j
597
int_mb(incomp+icont-1) = 15
598
elseif(sphcart.eq.1)then
600
int_mb(index+j) = 451+j
603
int_mb(incomp+icont-1) = 9
606
elseif(type.gt.4) then
607
write(6,*)' only up to g functions allowed '
608
call errquit('wnbofile: max angular momentum exceeded',0,
614
write(lfn,'(2x,a)')'LABEL = '
615
write(lfn,'(5x,10i6)') (int_mb(iscr+i-1),i=1,nbf)
618
if (.not. ma_free_heap(lscr))
619
$ call errquit('wnbofile: lscr free heap failed',0, MA_ERR)
623
c>>> End $BASIS keylist.
626
c>>> Begin $CONTRACT keylist.
627
if (ga_nodeid().eq.0) then
628
if(.not.MA_Alloc_Get(MT_dbl,nprim,'exponents',lexp,iexp))
629
$ call errquit('wnbofile: lexp memory alloc. failed',0,
631
if(.not.MA_Alloc_Get(MT_dbl,nprim,'coefs',lcoef,icoef))
632
$ call errquit('wnbofile: lcoef memory alloc failed',0,
637
if(.not.bas_get_exponent(lbasis,icont,dbl_mb(iexp+index)))
638
$ call errquit('wnbofile: failed bas_get_exp',0, BASIS_ERR)
639
if(.not.bas_get_coeff(lbasis,icont,dbl_mb(icoef+index)))
640
$ call errquit('wnbofile: failed bas_get_coeff',0,
642
index = index + int_mb(iprim+icont-1)
645
write(lfn,'(a)') '$CONTRACT'
646
write(lfn,'(1x,a10,i5)') 'NSHELLS = ', ncont
647
write(lfn,'(1x,a10,i5)') ' NEXP = ', nprim
648
write(lfn,'(1x,a10)') ' NCOMP = '
649
write(lfn,'(5x,10i6)') (int_mb(incomp+i),i=0,(ncont-1))
650
write(lfn,'(1x,a10)') ' NPRIM = '
651
write(lfn,'(5x,10i6)') (int_mb(iprim+i-1),i=1,ncont)
652
write(lfn,'(1x,a10)') ' NPTR = '
653
write(lfn,'(5x,10i6)') (int_mb(iptr+i-1),i=1,ncont)
654
write(lfn,'(1x,a10)') ' EXP = '
655
write(lfn,'(5x,4f20.10)') (dbl_mb(iexp+i-1),i=1,nprim)
658
write(lfn,'(5x,a)') cname(l+1)
660
c>>> Reuse array space pointed to by iexp to print out
661
c>>> s, p, d, f and g coefficients.
663
call dcopy(nprim,0.0d0,0,dbl_mb(iexp),1)
667
type=int_mb(itype+icont-1)
669
sshell = (l.eq.0).and.(type.le.0)
670
pshell = (l.eq.1).and.((type.eq.1).or.(type.le.-1))
671
dshell = (l.eq.2).and.((type.eq.2).or.(type.le.-2))
672
fshell = (l.eq.3).and.(type.eq.3)
673
gshell = (l.eq.4).and.(type.eq.4)
675
ilo = int_mb(iptr+icont-1)
676
ihi = int_mb(iptr+icont)-1
678
c>>> S-type coefficients.
682
dbl_mb(iexp+i-1)=dbl_mb(icoef+i-1)
686
c>>> P-type coefficients.
690
dbl_mb(iexp+i-1)=dbl_mb(icoef+i-1)
694
c>>> D-type coefficients.
698
dbl_mb(iexp+i-1)=dbl_mb(icoef+i-1)
702
c>>> F-type coefficients.
706
dbl_mb(iexp+i-1)=dbl_mb(icoef+i-1)
710
c>>> G-type coefficients.
714
dbl_mb(iexp+i-1)=dbl_mb(icoef+i-1)
720
write(lfn,'(5x,4f20.10)') (dbl_mb(iexp+i-1),i=1,nprim)
725
if (.not. ma_free_heap(lcoef))
726
$ call errquit('wnbofile: lcoef free heap failed',0, MA_ERR)
728
if (.not. ma_free_heap(lexp))
729
$ call errquit('wnbofile: lexp free heap failed',0, MA_ERR)
732
c>>> End $CONTRACT keylist.
734
c>>> Read in molecular orbital vectors and occupation numbers.
737
if (.not. ma_push_get(mt_dbl, lenocc, 'wnbofile: mo evals',
738
$ leval, ieval)) call errquit
739
$ ('wnbofile: insufficient memory?', lenocc, MA_ERR)
741
if (.not. ma_push_get(mt_dbl, lenocc, 'wnbofile: mo occ',
742
$ locc, iocc)) call errquit
743
$ ('wnbofile: mo occ insufficient memory?', lenocc, MA_ERR)
745
if (.not. movecs_read(movecs_in, 1, dbl_mb(iocc), dbl_mb(ieval),
747
$ call errquit('scf_movecs_read failed',0, DISK_ERR)
749
if(.not.restricted)then
750
if (.not. movecs_read(movecs_in, 2,
751
$ dbl_mb(iocc+nbf), dbl_mb(ieval+nbf),
753
call ga_copy(g_movecs(1), g_movecs(2))
754
call dcopy(nbf,dbl_mb(iocc),1,dbl_mb(iocc+nbf),1)
755
call dcopy(nbf,dbl_mb(ieval),1,dbl_mb(ieval+nbf),1)
759
c>>> Begin $LCAOMO keylist.
761
if( ga_nodeid().eq.0)then
762
if(.not.MA_Alloc_Get(MT_Dbl,nbf,'scratch',lscr,iscr))
763
$ call errquit('wnbofile: lscr memory alloc. failed',0,
766
write(lfn,'(a)')'$LCAOMO'
769
call ga_get(g_movecs(1),1,nmo,icol,icol,Dbl_MB(iscr),1)
770
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,nbf-1)
774
if(.not. restricted) then
776
call ga_get(g_movecs(2),1,nmo,icol,icol,Dbl_MB(iscr),1)
777
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,nbf-1)
782
if (.not. ma_free_heap(lscr))
783
$ call errquit('wnbofile: lscr free heap failed',0, MA_ERR)
786
c>>> End LCAOMO keylist.
789
c>>> Create bond order matrix from movecs array for density keylist.
792
c rho(r,r') = N*SUM SUM C C chi(r) chi(r')
796
c bond order matrix, gamma = | N*SUM C C |
801
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: bond order',
802
$ 0, 0, g_bo(1))) call errquit('wnbofile: g_bo(1)', 0, GA_ERR)
803
call ga_zero(g_bo(1))
807
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: a bond order',
808
$ 0, 0, g_bo(1))) call errquit('wnbofile: g_bo(1)', 0, GA_ERR)
809
call ga_zero(g_bo(1))
810
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: b bond order',
811
$ 0, 0, g_bo(2))) call errquit('wnbofile: g_bo(2)', 0, GA_ERR)
812
call ga_zero(g_bo(2))
816
c>>> Create the density matrix in the MO representation,
817
c>>> a square matrix with orbital occupation
818
c>>> numbers on the diagonals and 0 elsewhere. Store the matrix
819
c>>> temporarily in the matrix reserved for the bond order matrix.
822
if(.not.MA_push_get(MT_INT, nmo, 'indices 1', lind1, iind1))
823
$ call errquit('wnbofile: lind1',0, MA_ERR)
824
if(.not.MA_push_get(MT_INT, nmo, 'indices 2', lind2, iind2))
825
$ call errquit('wnbofile: lind2',0, MA_ERR)
827
if (ga_nodeid().eq.0)then
830
int_mb( iind1+i-1 ) = i
831
int_mb( iind2+i-1 ) = i
834
* write(6,*)' g_bo B4 zero'
835
* call ga_print(g_bo(1))
836
* call ga_zero (g_bo(1))
837
* write(6,*)' g_bo after zero/B4 scatter'
838
* call ga_print(g_bo(1))
839
call ga_scatter ( g_bo(1), dbl_mb(iocc), int_mb(iind1),
840
$ int_mb(iind2), nmo )
842
* write(6,*)' g_bo after scatter'
843
* call ga_print(g_bo(1))
847
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: scratch',
848
$ 0, 0, g_scr)) call errquit('wnbofile: scratch', 0, GA_ERR)
851
c>>> Form the product (Movecs)(Gamma_mo)(Movecs) = Bond order matrix.
853
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_movecs(1),
854
$ g_bo(1), 0.0d0, g_scr)
855
call ga_dgemm('n', 't', nmo, nmo, nmo, 1.0d0, g_scr,
856
$ g_movecs(1), 0.0d0, g_bo(1))
858
if(.not. restricted) then
860
if (ga_nodeid().eq.0)then
863
int_mb( iind1+i-1 ) = i
864
int_mb( iind2+i-1 ) = i
867
call ga_scatter ( g_bo(2), dbl_mb(iocc+nmo), int_mb(iind1),
868
$ int_mb(iind2), nmo )
872
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_movecs(2),
873
$ g_bo(2), 0.0d0, g_scr)
874
call ga_dgemm('n', 't', nmo, nmo, nmo, 1.0d0, g_scr,
875
$ g_movecs(2), 0.0d0, g_bo(2))
878
c>>> Begin $DENSITY keylist.
880
if( ga_nodeid().eq.0)then
881
if(.not.MA_Alloc_Get(MT_Dbl,nbf,'scratch',lscr,iscr))
882
$ call errquit('wnbofile: lscr memory alloc. failed',0,
885
write(lfn,'(a)')'$DENSITY'
887
c>>> Write out lower triangular section of alpha density matrix.
891
call ga_get(g_bo(1),1,nmo,icol,icol,Dbl_MB(iscr),1)
892
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,icol-1)
896
if(.not. restricted) then
898
call ga_get(g_bo(2),1,nmo,icol,icol,Dbl_MB(iscr),1)
899
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,icol-1)
904
if (.not. ma_free_heap(lscr))
905
$ call errquit('wnbofile: lscr free heap failed',0, MA_ERR)
908
c>>> End $DENSITY keylist.
911
c>>> Create overlap matrix.
913
call int_init(rtdb,1,lbasis)
914
if (.not.int_normalize(rtdb,lbasis)) call errquit
915
& ('wnbofile: int_normalize failed',911, INT_ERR)
916
g_over = ga_create_atom_blocked(lgeom, lbasis,'Overlap')
919
call int_1e_ga(lbasis, lbasis, g_over, 'overlap', .false.)
921
c>>> Begin $OVERLAP keylist.
923
if( ga_nodeid().eq.0)then
924
if(.not.MA_Alloc_Get(MT_Dbl,nbf,'scratch',lscr,iscr))
925
$ call errquit('wnbofile: lscr memory alloc. failed',0,
928
write(lfn,'(a)')'$OVERLAP'
930
c>>> Write out lower triangular section of overlap matrix.
933
call ga_get(g_over,1,nmo,icol,icol,Dbl_MB(iscr),1)
934
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,icol-1)
938
if (.not. ma_free_heap(lscr))
939
$ call errquit('wnbofile: lscr free heap failed',0, MA_ERR)
943
c>>> End $OVERLAP keylist.
946
c>>> Create Fock matrix in AO basis.
950
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: Fock matrix',
951
$ 0, 0, g_fock(1))) call errquit('wnbofile: g_fock(1)', 0,
953
call ga_zero(g_fock(1))
957
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: alpha Fock',
958
$ 0, 0, g_fock(1))) call errquit('wnbofile: g_fock(1)', 0,
960
call ga_zero(g_fock(1))
962
if (.not. ga_create(MT_DBL, nmo, nmo, 'wnbofile: beta Fock',
963
$ 0, 0, g_fock(2))) call errquit('wnbofile: g_fock(2)', 0,
965
call ga_zero(g_fock(2))
969
c>>> Create Fock matrix in MO representation,
970
c>>> a square matrix with oribital energies
971
c>>> on the diagonals and 0 elsewhere.
973
if (ga_nodeid().eq.0)then
976
int_mb( iind1+i-1 ) = i
977
int_mb( iind2+i-1 ) = i
980
call ga_scatter ( g_fock(1), dbl_mb(ieval), int_mb(iind1),
981
$ int_mb(iind2), nmo )
985
c>>> Create Fock Matrix in AO representation.
987
c>>> Fock_ao = S*Movecs*Fock_mo*Movecs *S
989
call ga_dgemm('n', 't', nmo, nmo, nmo, 1.0d0, g_fock(1),
990
$ g_movecs(1), 0.0d0, g_scr)
991
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_movecs(1),
992
$ g_scr, 0.0d0, g_fock(1))
993
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_fock(1),
994
$ g_over, 0.0d0, g_scr)
995
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_over,
996
$ g_scr, 0.0d0, g_fock(1))
998
if(.not. restricted) then
1000
if (ga_nodeid().eq.0)then
1003
int_mb( iind1+i-1 ) = i
1004
int_mb( iind2+i-1 ) = i
1007
call ga_scatter ( g_fock(2), dbl_mb(ieval+nmo), int_mb(iind1),
1008
$ int_mb(iind2), nmo )
1012
call ga_dgemm('n', 't', nmo, nmo, nmo, 1.0d0, g_fock(2),
1013
$ g_movecs(2), 0.0d0, g_scr)
1014
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_movecs(2),
1015
$ g_scr, 0.0d0, g_fock(2))
1016
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_fock(2),
1017
$ g_over, 0.0d0, g_scr)
1018
call ga_dgemm('n', 'n', nmo, nmo, nmo, 1.0d0, g_over,
1019
$ g_scr, 0.0d0, g_fock(2))
1023
c>>> Begin $FOCK keylist.
1025
if( ga_nodeid().eq.0)then
1026
if(.not.MA_Alloc_Get(MT_Dbl,nbf,'scratch',lscr,iscr))
1027
$ call errquit('wnbofile: lscr memory alloc. failed',0,
1030
write(lfn,'(a)')'$FOCK'
1032
c>>> Write out lower triangular section of AO Fock matrix.
1035
call ga_get(g_fock(1),1,nmo,icol,icol,Dbl_MB(iscr),1)
1036
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,icol-1)
1039
if(.not. restricted) then
1041
call ga_get(g_fock(2),1,nmo,icol,icol,Dbl_MB(iscr),1)
1042
write(lfn,'(5f20.10)')(Dbl_MB(iscr+i),i=0,icol-1)
1047
if (.not. ma_free_heap(lscr))
1048
$ call errquit('wnbofile: lscr free heap failed',0, MA_ERR)
1052
c>>> End $FOCK keylist.
1055
c>>> Print this out for debugging purposes.
1059
c>>> Free handles and destroy arrays.
1061
if (restricted) then
1062
if (.not. ga_destroy(g_scr))
1063
$ call errquit('wnbofile: destroy g_scr',0, GA_ERR)
1064
if (.not. ga_destroy(g_movecs(1)))
1065
$ call errquit('wnbofile: destroy g_movecs',0, GA_ERR)
1066
if (.not. ga_destroy(g_bo(1)))
1067
$ call errquit('wnbofile: destroy g_bo',0, GA_ERR)
1068
if (.not. ga_destroy(g_over))
1069
$ call errquit('wnbofile: destroy g_over',0, GA_ERR)
1070
if (.not. ga_destroy(g_fock(1)))
1071
$ call errquit('wnbofile: destroy g_fock',0, GA_ERR)
1073
if (.not. ga_destroy(g_scr))
1074
$ call errquit('wnbofile: destroy g_scr',0, GA_ERR)
1075
if (.not. ga_destroy(g_movecs(2)))
1076
$ call errquit('wnbofile: destroy beta MOs', 0, GA_ERR)
1077
if (.not. ga_destroy(g_movecs(1)))
1078
$ call errquit('wnbofile: destroy alpha MOs', 0, GA_ERR)
1079
if (.not. ga_destroy(g_over))
1080
$ call errquit('wnbofile: destroy g_over',0, GA_ERR)
1081
if (.not. ga_destroy(g_bo(2)))
1082
$ call errquit('wnbofile: destroy beta BO matrix', 0, GA_ERR)
1083
if (.not. ga_destroy(g_bo(1)))
1084
$ call errquit('wnbofile: destroy alpha BO matrix', 0,
1086
if (.not. ga_destroy(g_fock(1)))
1087
$ call errquit('wnbofile: destroy g_fock',0, GA_ERR)
1088
if (.not. ga_destroy(g_fock(2)))
1089
$ call errquit('wnbofile: destroy g_fock',0, GA_ERR)
1092
if (.not. ma_pop_stack(lind2))
1093
$ call errquit('wnbofile: lind2 pop stack failed',0, MA_ERR)
1095
if (.not. ma_pop_stack(lind1))
1096
$ call errquit('wnbofile: lind1 pop stack failed',0, MA_ERR)
1098
if (.not. ma_pop_stack(locc))
1099
$ call errquit('wnbofile: locc pop stack failed',0, MA_ERR)
1101
if (.not. ma_pop_stack(leval))
1102
$ call errquit('wnbofile: leval pop stack failed',0, MA_ERR)
1104
if (.not. ma_pop_stack(lncomp))
1105
$ call errquit('wnbofile: lncomp pop stack failed',0, MA_ERR)
1107
if (.not. ma_pop_stack(ltype))
1108
$ call errquit('wnbofile: ltype pop stack failed',0, MA_ERR)
1110
if (.not. ma_pop_stack(lptr))
1111
$ call errquit('wnbofile: lptr pop stack failed',0, MA_ERR)
1113
if (.not. ma_pop_stack(lprim))
1114
$ call errquit('wnbofile: lprim pop stack failed',0, MA_ERR)
1116
if (.not. ma_pop_stack(ltags))
1117
$ call errquit('wnbofile: ltags pop stack failed',0, MA_ERR)
1119
if (.not. ma_pop_stack(lchg))
1120
$ call errquit('wnbofile: lchg pop stack failed',0, MA_ERR)
1122
if (.not. ma_pop_stack(lcoord))
1123
$ call errquit('wnbofile: lcoord pop stack failed',0, MA_ERR)
1124
c ------ Deallocate memory ----------
1125
call int_terminate()
1129
if (.not. bas_destroy(lbasis)) call errquit
1130
$ ('wnbofile: basis destroy failed',0, BASIS_ERR)
1132
if (.not. geom_destroy(lgeom)) call errquit
1133
$ ('wnbofile: geom destroy failed', 0, GEOM_ERR)
1138
9250 format(/,1x,'Input for gennbo program written to file ',a,'.')