dear friends,
here is the full code that is creating the problem!!!
!===========================================
! This is the main driver routine
! of the reverse monte carlo program
program rmonte
!===========================================
implicit none
integer::i,j
integer:: seed,tr,rmcs
integer::ntyp,nap,ntot,it1,it2,atnm
real(selected_real_kind(8))::rmin,rmax,boxl,dr
real(selected_real_kind(8))::rr,rdf
real(selected_real_kind(8)),dimension(100)::x,y,z
real(selected_real_kind(8)),dimension(100):: gr,rrl
real(selected_real_kind(8)):: dx,dy,dz,dist,rcut
character(2)::elmnt
!
real::t1,t2
t1=secnds(t1)
!
seed=12345
BOXL=20
RCUT=1.5
DR=5.0
RMCS=1000
ntot=100
tr=1
write(*,*) &
"===============Creating Initial Configuration=============="
write(*,&
'(1x,"Minimum distance between any two particle is",1x,f6.4)'),
&
rcut
!-----------------------------------------------
! INITIALISE POSITION
!-----------------------------------------------
10 do i=1,ntot
x(i)=boxl*(ran(seed)-0.0)
y(i)=boxl*(ran(seed)-0.0)
z(i)=boxl*(ran(seed)-0.0)
call pbc(x,y,z,boxl)
end do
!- - - - - - - - - - - - - - - - - - - - - - - -
! KEEPING MINIMUM DIST. BETWEEN ANY TWO
! ATOM GREATER THEN RCUT
!- - - - - - - - - - - - - - - - - - - - - - - -
do i=1,ntot-1
do j=i+1,ntot
dx=x(i)-x(j)
dy=y(i)-y(j)
dz=z(i)-z(j)
dist=dsqrt(dx*dx+dy*dy+dz*dz)
tr=tr+1
! write(*,*) tr
if (dist<rcut)go to 10
end do
end do
write(*,'(1x,"Success after",1x,i0,1x,"try")')tr
call mindist(x,y,z)
write(*,*) &
"==========================================================="
write(*,*) ""
!-----------------------------------------------
! INITIAL CONFIGURATION DONE
!-----------------------------------------------
t2=secnds(t1)
write(*,'("Elapsed Time =",1x,f10.4)'), t2
end
!===========================================
! Subroutine to apply periodic
! boundary value
!===========================================
subroutine pbc(xx,yy,zz,boxl)
implicit none
real(selected_real_kind(4))::xx,yy,zz,boxl
if(xx.gt. boxl)xx=xx-boxl
if(xx.lt.-boxl)xx=xx+boxl
if(yy.gt. boxl)yy=yy-boxl
if(yy.lt.-boxl)yy=yy+boxl
if(zz.gt. boxl)zz=zz-boxl
if(zz.lt.-boxl)zz=zz+boxl
return
end
!==============================================
! Subroutine to calculate minimum
! distance between two atom
subroutine mindist(x,y,z)
!==============================================
implicit none
integer::i,j,p1,p2
real(selected_real_kind(8)),dimension(100):: x,y,z
real(selected_real_kind(8)):: dist,dx,dy,dz,dmini,dmin
write(*, &
'(" Calculating minimum distance between atoms....",$)')
dx=x(1)-x(2)
dy=y(1)-y(2)
dz=z(1)-z(2)
dmini=dsqrt(dx*dx+dy*dy+dz*dz)
do i=1,99
do j=i+1,100
dx=x(i)-x(j)
dy=y(i)-y(j)
dz=z(i)-z(j)
dmin=dsqrt(dx*dx+dy*dy+dz*dz)
if (dmini>dmin)then
dmini=dmin
p1=i
p2=j
end if
end do
end do
write(*,*) "DONE"
write &
(*,'(1x,"Shortest distance between to atom is",2x,f8.6)')dmini
write(*,'(1x,"between particle pair",1x,i0," - ",i0)') p1,p2
return
end
while running with ifort, its prompting:
$ ./a.out
===============Creating Initial Configuration==============
Minimum distance between any two particle is 1.5000
Success after 1680724 try
Calculating minimum distance between atoms.... DONE
Shortest distance between to atom is 1.626997
between particle pair 40 - 92
===========================================================
Elapsed Time = 0.0623
but while running with gfortran, its never success...why?


|