debug1.f
program debug1
c
c John Mahaffy, Penn State University, CmpSc 201 Example
c 1/26/96
c
c
c Program to demonstrate debugging process
c
c John Mahaffy, 1/23/96
c
implicit none
real mass1, mass2, vel1,vel2
real avmass, ketot , avvel
data mass1,mass2,vel1,vel2 /1.0,1.0,1.0,1.0/
c
c mass1, and mass2 are the masses of two objects
c vel1 and vel2 are there respective velocities
c avmass and avvel are the mean values of mass and velocity respectively
c ketot is the total kinetic energy of the two objects
c
c
c calulate the mean value of system masses
c
call meanval(2,mass1,mass2,vel1,vel2,avmass,avvel)
c
c calculate the total kinetic energy
c
ketot= (mass1*vel1**2+mass2*vel2**2)/2.0
print *, 'Mean mass is: ', avmass
print *, 'Mean velocity is: ', avvel
print *, 'Total Kinetic Energy is: ', ketot
stop
end
subroutine meanval(rwf,x1,x2,y1,y2,xmean,ymean)
c
c calculate a weighted mean for two pairs of numbers based
c on a reciprocal weighting factor
c
c John Mahaffy 6/07/95
c
implicit none
real rwf,x1,x2,y1,y2,xmean,ymean
c
c rwf - reciprocal weighting factor converted to standard weighting factor
c x1,x2 - first pair of numbers
c xmean - weighted mean of first pair of numbers
c y1,y2 - second pair of numbers
c ymean - weighted mean of second pair of numbers
c
rwf=1./rwf
xmean=rwf*x1+(1.-rwf)*x2
ymean=rwf*y1+(1.-rwf)*y2
return
end