COMPARATIVE LANGUAGES
Fall 2005
Fortran 90
Starter program for vectors in Fortran 90:
vectors1.f90
This version uses a randomizer to change the random sequence each run:
random.f90
F90 version using subroutines (procedures/functions)
Fortran 90 assignment 1: dot product (vectors), addition (matrices), multiplication (matrices)
Currently we have Fortran 90 only on the Cray.
(Two versions for the workstations are gfortran or g95)
To use the Cray SV1:
- ssh cray, your passwd should be astudentnum
- The only editor is vim. If you want to use the workstation's editor,
use gftp (with SSH) to connect to the Cray and copy files back and forth)
- Starter program for vectors in Fortran 90:
vectors1.f90
- Compile these with: "f90 prog.f90" (generates a.out as an executable)
or "f90 -o prog prog.f90 (generates "prog" as an executable)
- ARRAY ELEMENTS START ON INDEX 1!
- This program demonstrates printing with do loops and also with "implied do loops"
- Complete coding the program for:
- dot product of two vectors
- addition of two matrices
- multiplication of two matrices
- you can use square matrices
Other example Fortran 90 programs to look through if you'd like...
- extremes.f90: read in n values into an array from the keyboard, find the min and max
- addarrays.f90: Initializes two arrays, adds the array elements together into a new array
- arrayio.f90: demonstrates various kinds of indexing
- checkarray.f90: demonstrates some fortran built in functions for arrays
- sort.f90: reads numbers into an array from a file, sorts the numbers with selection sort.
input data file
- matrix.f90: assigns values into a matrix, prints them out with DO loops
- logs.f90: reads values into a matrix from a file, finds the log of each value
using a Fortran intrinsic function
inputlogs sample datafile
- sort3.f90: reads numbers into an array from a file, sorts the numbers with selection sort.
USES A SUBROUTINE!
- generate.f90: reads in "electrical" data from a file into a matrix, computes total and average power
for rows/columns of the matrix
inputgenerate, sample data file