The GNU Fortran compiler, g77, has been installed on all Sun workstations (i.e., flat-rock, hendersonville, marshall, and brevard) as well as the Linux boxes.
To run the compiler simply type "g77" at the command line prompt.
Below is a list of on-line Fortran 77 resources that you may find helpful in working your assignment.
Type (or cut and paste) the following program into a file. The file name should end in the extension ".f". Next, compile the program using the g77 compiler. If any compiler errors are reported, edit the program and fix them and repeat until you get a clean compilation.
Program Demo
implicit none
" This program generates a table of the square roots of integers
" in a user-specified range.
integer*2 start, finish, i
" ----------------------------------------------Prompt and Input
print*, "Enter the range (two integers) ..."
read*, start, finish
" ----------------------------------------------Validation & Processing
if (start .GT. finish) then
print*, "Invalid: the start must be less than the end value!"
else if (start .LT. 0) then
print*, "Invalid: the range must not have negative values!"
else
do i = start, finish
write(*,*) i, sqrt(i*1.)
end do
end if
" ----------------------------------------------
end
A scientist is interested in the behavior of the function y = f(x), in the range x=1 to x=3. The function does not have a closed-form formula but is an infinite sum of terms with the following pattern:
Develop a FORTRAN program which computes this sum for a given value of x (a real*4 variable). Your program should keep adding terms until the absolute value of the term to be added becomes less than 1.E-4. To test your program, supply the value x = 2.5 and insure that the computed value of y is about 0.22.