! This is a basic starting shell for your programs MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const ! PROGRAM prog USE const IMPLICIT NONE ! ! HW 15, 1 ! ! Compute mean and geometric mean of set of double precision values ! (need to look at data file to see that the values are doubles). ! INTEGER :: n REAL(kind=dp) :: total1,total2,avg,gavg,rvalue ! Open the data file OPEN(10,file='hw15a.in') ! Set up accumulation vaiables. ! total1 = accumulation for mean ! = 0 ! total2 = accumulation for geometric mean ! = 1 ! n = number of vaules in list total1 = 0 total2 = 1 n = 0 ! Begin main loop DO READ(10,*,END=100) rvalue ! Accumulate total1 and total1, increment n total1 = total1 + rvalue total2 = total2*rvalue n = n + 1 ENDDO 100 CONTINUE ! Compute mean and geometric mean. avg = total1/n gavg = total2**(1/DBLE(n)) WRITE(*,*) 'avg = ',avg WRITE(*,*) 'gavg = ',gavg WRITE(*,*) 'n = ',n ! Close data file and end CLOSE(10) END PROGRAM prog !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! avg = 59.875276904036362 ! gavg = Infinity ! n = 1264