program chargeTINKER implicit none character (len=100) file1 character (len=100) file2 integer natoms integer i,j integer a,b, aa, aaa, aaabis real*8 aaaa, bb character (len=3) c character (len=9) d real*8 x,y,z real*8 tot_charge logical ok character (len=12) ch1 character (len=16) ch2 integer compt natoms = 16436 file1 = "5u1c-solvated-140.xyz" file2 = "A18_multipoles.prm" ! Opening of the two files open(1,file=file1,action="read") ! Charge calculation tot_charge = 0.0d0 compt=1 read (1,*) do i = 1, natoms read (1,*) a, c, x, y, z, b open(2,file=file2,action="read",position="rewind") do j = 1, 431 read (2,fmt='(a)',advance='NO') ch1 read (2,fmt='(i3)',advance='NO') a read (2,fmt='(a)',advance='NO') ch2 read (2,*) aaaa read (2,*) bb read (2,*) bb read (2,*) bb read (2,*) bb if (a == b) then tot_charge = tot_charge + aaaa print *, compt, a, b, aaaa, tot_charge compt = compt + 1 goto 20 end if end do 20 continue close(2) end do print *, "Charge totale du systeme = ", tot_charge close(1) end