program aver implicit double precision (a-h,o-z) parameter (IBmax=10000) real esub(IBmax), egg(IBmax),etot(IBmax) integer nmol(IBmax) open(5,file='mc_ene.dat', status='old') open(6,file='ene_inter.dat', status='unknown') i = 1 1122 read(5,*,end=9999)nbin,nm,eg,et nmol(i) = nm egg(i) = eg etot(i) = et esub(i) = et-eg write(6,*)nbin,nmol(i),esub(i) if(i.eq.IBmax) go to 9999 i = i + 1 go to 1122 9999 close(5) close(6) indx = i ibin = i Eaves = 0.0 Eave = 0. Eaves = 0.0 Gave = 0. GNave = 0. GNave = 0. aNave = 0. aNNave = 0. E2ave = 0. EENNave = 0. indx = indx do i = 1,ibin * print *,i Eaves = Eaves + etot(i)*nmol(i)/indx ! total energy Eave = Eave + etot(i)/indx ! energy per atom ENave = ENave + etot(i)*nmol(i)*nmol(i)/indx ! EENNave = EENNave + (etot(i)*nmol(i))**2/indx E2ave = E2ave + etot(i)**2/indx ! Gaves = Gaves + egg(i)*nmol(i)/indx ! total energy Gave = Gave + egg(i)/indx ! energy per atom GNave = GNave + egg(i)*nmol(i)*nmol(i)/indx ! aNave = aNave + float(nmol(i))/indx ! aNNave = aNNave + float(nmol(i)*nmol(i))/indx ! enddo print *, 'Finished' flu = aNNave-aNave*aNave if(flu.lt.0.0) print *, 'flu negative', flu fluN = abs(flu) qiso = -(ENave - Eaves*aNave)/fluN !enthalpy of adsorption qisg = -(GNave - Gaves*aNave)/fluN !enthalpy of adsorption (wall) capv = (E2ave- Eave*Eave) !- cv = (EENNave - Eaves*Eaves)/(aNave) open(7,file='aver.dat',status='unknown') sqn = sqrt(fluN) write(7,1010)aNave ,sqn,'Mean particles number and fluctuation' write(7,'(a)') write(7,1010)-qiso, Eave,'Enthalpy of adsorption and energy' write(7,'(a)') write(7,1010)-qisg, Gave,'Enthalpy and energy (wall interaction co &mponent)' write(7,'(a)') write(7,1010)capv, sqrt(capv), 'Energy fluctuation' close(7) 1010 format(2(1x,f10.2),3x,a) call str_rasmol(nbin) end