Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help please

Status
Not open for further replies.

mbajusair

MIS
May 6, 2015
1
GB
Hi,,
I have afortran program for calculating density and when I execute it gives me zero and error.
program density
implicit none
integer :: r,IDm,n,m,i,j
real :: xm,ym,zm,p,p0,k,pi,s,ri,rj,l
real, dimension(1000) :: x,y,z,ID
p0=0.17
k=0.0
L=4.33
pi=3.1415927
do n=1,3000
open(unit=5,file='/home/toshiba/Desktop/urqmd-3.3p2/format1.dat')
read(5,*) l,l,l,l
do m=1,400
read(5,*) xm,ym,zm,IDm
if(xm==400) exit
r=m
x(r)=xm
y(r)=ym
z(r)=zm
ID(r)=IDm
write(*,*) xm, ym, zm, IDm

end do

do i=1,r-1
x(i)=xm
y(i)=ym
z(i)=zm
do j=i+1,r
x(j)=x(i+1)
y(j)=y(i+1)
z(j)=z(i+1)
s=ri-rj
s=sqrt((x(i)-x(j))**2 + (y(i)-y(j))**2 + (z(i)-z(j))**2)
K=K+s
end do
end do
p=(1/394)*(1/(2*pi*L)**1.5)*exp(-(K)**2/(2*L))*p0
write(*,*) p/p0

end do

end program density
can any one help me..
 
have you heard of integral division?

In computer programs, if you type 2 is a 2 and not a 2.0; without decimal point a number is an integer. When dividing two integers you only get the quotient...6/3=2, 7/3=2 ...and when the denominator is greater, you get the quotient of zero: 1/2=0, 1/394=0

If you do not desire integral division, you need to make sure one of the operands is a REAL number, i.e., has a decimal point or is a variable declared accordingly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top