|
!Output .pqr files |
|
if (ioutatmpqr==1) then |
|
open(10,file="atmint_tot.pqr",status="replace") |
|
write(10,"('REMARK Generated by Multiwfn, totally',i10,' atoms')") ncenter |
|
do i=1,ncenter |
|
write(10,"(a6,i5,1x,a4,1x,a3, 1x,a1,i4,4x,3f8.3,f13.4,f9.4,a2)") & |
|
"HETATM",i,' '//ind2name_up(a(i)%index)//' ',"MOL",'A',1,a(i)%x*b2a,a(i)%y*b2a,a(i)%z*b2a,totatm(i),vdwr(a(i)%index)*b2a,adjustr(ind2name_up(a(i)%index)) |
|
end do |
|
write(10,"('END')") |
|
open(10,file="atmint_ele.pqr",status="replace") |
|
write(10,"('REMARK Generated by Multiwfn, totally',i10,' atoms')") ncenter |
|
do i=1,ncenter |
|
write(10,"(a6,i5,1x,a4,1x,a3, 1x,a1,i4,4x,3f8.3,f13.4,f9.4,a2)") & |
|
"HETATM",i,' '//ind2name_up(a(i)%index)//' ',"MOL",'A',1,a(i)%x*b2a,a(i)%y*b2a,a(i)%z*b2a,eleatm(i),vdwr(a(i)%index)*b2a,adjustr(ind2name_up(a(i)%index)) |
|
end do |
|
write(10,"('END')") |
|
open(10,file="atmint_rep.pqr",status="replace") |
|
write(10,"('REMARK Generated by Multiwfn, totally',i10,' atoms')") ncenter |
|
do i=1,ncenter |
|
write(10,"(a6,i5,1x,a4,1x,a3, 1x,a1,i4,4x,3f8.3,f13.4,f9.4,a2)") & |
|
"HETATM",i,' '//ind2name_up(a(i)%index)//' ',"MOL",'A',1,a(i)%x*b2a,a(i)%y*b2a,a(i)%z*b2a,repatm(i),vdwr(a(i)%index)*b2a,adjustr(ind2name_up(a(i)%index)) |
|
end do |
|
write(10,"('END')") |
|
open(10,file="atmint_disp.pqr",status="replace") |
|
write(10,"('REMARK Generated by Multiwfn, totally',i10,' atoms')") ncenter |
|
do i=1,ncenter |
|
write(10,"(a6,i5,1x,a4,1x,a3, 1x,a1,i4,4x,3f8.3,f13.4,f9.4,a2)") & |
|
"HETATM",i,' '//ind2name_up(a(i)%index)//' ',"MOL",'A',1,a(i)%x*b2a,a(i)%y*b2a,a(i)%z*b2a,dispatm(i),vdwr(a(i)%index)*b2a,adjustr(ind2name_up(a(i)%index)) |
|
end do |
|
write(10,"('END')") |
|
open(10,file="atmint_vdW.pqr",status="replace") |
|
write(10,"('REMARK Generated by Multiwfn, totally',i10,' atoms')") ncenter |
|
do i=1,ncenter |
|
write(10,"(a6,i5,1x,a4,1x,a3, 1x,a1,i4,4x,3f8.3,f13.4,f9.4,a2)") & |
|
"HETATM",i,' '//ind2name_up(a(i)%index)//' ',"MOL",'A',1,a(i)%x*b2a,a(i)%y*b2a,a(i)%z*b2a,repatm(i)+dispatm(i),vdwr(a(i)%index)*b2a,adjustr(ind2name_up(a(i)%index)) |
|
end do |
|
write(10,"('END')") |
|
write(*,*) |
|
write(*,"(a)") " atmint_tot.pqr, atmint_ele.pqr, atmint_rep.pqr, atmint_disp.pqr, atmint_vdW.pqr have been exported to current folder. & |
|
&Their atomic charge fields record atom contribution to total/electrostatic/repulsive/dispersion/vdW interaction energy between all fragments, & |
|
&respectively. the radius column corresponds to Bondi vdW radii" |
|
close(10) |
Global scan provenance
This issue was found by the Codex global repository scan of non-unit-test files in
Stardust0831/Multiwfn, pinned to commitd2b770a531eb7039153198d04520b5992f15c49d.Problem
When EDA-FF atom-contribution output is enabled, the code opens
atmint_tot.pqron unit 10, writes it, and then reconnects the still-open unit to four different filenames. Only the final file is closed.Multiwfn/EDA.f90
Lines 365 to 406 in d2b770a
Standard Fortran does not permit changing the
FILE=connection of an already connected unit this way. Runtime behavior is compiler-dependent: strict runtimes can reject the secondOPEN, while permissive runtimes may implicitly close files and hide the portability defect.Impact
The documented option to export five PQR contribution files can stop after the first file or produce an incomplete set, particularly in GNU Fortran cross-platform builds. Buffered output and error handling also become runtime-dependent.
Suggested direction
newunit=values with scoped open/write/close handling.iostat/iomsgchecks so filesystem failures identify the specific target file.END, and contain the expected number of atoms.