## Description

### Introduction

## Simple Program to Compute Positive and Negative Averages

## Program Run - Simple Program to Compute Positive and Negative Averages

## Program - Simple Program to Calculate Integrals via Trapezoidal Sums

Download integrate.f95 code

## Program Run - Simple Program to Calculate Integrals via Trapezoidal Sums

http://www.eclipse.org/

## Program Simple Program to Calculate Area of Circle Using Module Files

### Main File

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | program circle use math_module implicit none real, parameter :: radius = 2.2 real :: area area = pi * radius ** 2 print *, "The area is: ", area end program circle |

### Module File

1 2 3 4 5 6 7 8 9 10 11 | module math_module implicit none private real, public, parameter :: pi = 3.141592653 real, public, parameter :: e = 2.7182818284 real, public, parameter :: gamma = 0.577215664 end module math_module |

[mark@ubermentch Fortran Programs]$ gfortran math_module.f08 circle.f08

The program is run by entering **./a.out** into the command prompt.

[mark@ubermentch Fortran Programs]$ ./a.out

The area is: 15.2053089

[mark@ubermentch Fortran Programs]$

## Program to calculate the value of the natural logarithm base, also known as e

### Exercise 2.6.8

## Program to calculate the median of three entered numbers.

### Exercise 3.6.1

This program ask the user to enter three numbers and finds the median. It uses a contains block, rather than putting the functions and procedures in a module. This is done to be proficient in both methods of function incorporation into programs.

First, in order to facilitate sorting, a subrouting "swap" is written. Its arguments have the attributes "in out", so they are passed by reference, so they are directly modified within the subroutine. Basically the subroutine swaps the arguments a with b.

The subroutine "sort" essentially uses the swap subroutine to perform a selection sort, by swapping the minimum value to the front of the list.

Finally, the function medianOf3 makes use of the sort subroutine to find the middle value and return it. The arguments to sort are passed by reference, and the names or the arguments with respect to the sort subroutine are named explicitly in the subroutine call.