Question: The subroutine contained in the sort.f08 given below: SUBROUTINE Sort(x,n) REAL,INTENT(INOUT) :: x(n) INTEGER,INTENT(IN) :: n INTEGER :: i,j DO i=1,n-1 smallest = x(i) location

 The subroutine contained in the sort.f08 given below: SUBROUTINE Sort(x,n) REAL,INTENT(INOUT) :: x(n) INTEGER,INTENT(IN) :: n INTEGER :: i,j DO i=1,n-1 smallest = The subroutine contained in the sort.f08 given below: x(i) location = i DO j=i+1,n IF (x(j) Given a list of

SUBROUTINE Sort(x,n) REAL,INTENT(INOUT) :: x(n) INTEGER,INTENT(IN) :: n INTEGER :: i,j

DO i=1,n-1 smallest = x(i) location = i DO j=i+1,n IF (x(j) Given a list of positive real values, 11, 12, ..., In, the central tendency of the list can be measured by the arithmetic mean, the geometric mean, or the harmonic mean. These three means are defined as follows: 1 arithmetic mean I =- (21 +22+...+in) = n n i=1 n + 11 1 22 + geometric mean Vr1.12.In (ie. the nth root). harmonic mean = + The median is the value in the list that has half of the numbers larger than it, and half of the numbers smaller than it. Two additional statistical measures of data are the variance and the standard deviation. The variance is the average of the squares of the deviations of the numbers from the mean, variance = ? (tz )2 72 n where 1 is the arithmetic mean. The standard deviation is the square root of the variance. The variance and standard deviation provide a description of the spread of the data. (a) Write a Fortran program to create a data file of random values between 1 and 100. The number of values contained in this file should also be random, between 10 and 100. You can use the built-in random number generation subroutines to generate the values required (see Example 4 in Lecture 12). (b) Using the data file created above as input, write a Fortran program to com- pute and display the arithmetic mean, geometric mean, harmonic mean, median, variance, and standard deviation of the values. Ask the user for the name of the data file, and have your program read to the end of the file. Your program should include a separate external function for each of the 6 measures calculated. Be sure to include an interface within your program. You can use the code from Lecture 14 as a starting point for your solution. To calculate the product for the geometric mean you may need to store a value that is larger than can be stored in a 32-bit floating point variable. To use double precision in Fortran, replace REAL in your declaration with REAL (KIND=8). To calculate the median value you will need to sort the data, for which you can make use of the subroutine contained in the sort.f08 file available with this Problem Set. This subroutine can be included in your source code file as an external subroutine. SUBROUTINE Sort(x,n) REAL, INTENT (INOUT) :: x(n) INTEGER, INTENT(IN) :: n INTEGER :: 1, DO 1=1, n-1 smallest = x(1) location = i DO j=i+1,n IF (x(i)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!