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:
    1. ssh cray, your passwd should be astudentnum
    2. 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)
    3. Starter program for vectors in Fortran 90: vectors1.f90
    4. Compile these with: "f90 prog.f90" (generates a.out as an executable)
      or "f90 -o prog prog.f90 (generates "prog" as an executable)
    5. ARRAY ELEMENTS START ON INDEX 1!
    6. This program demonstrates printing with do loops and also with "implied do loops"
    7. 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...
    1. extremes.f90: read in n values into an array from the keyboard, find the min and max

    2. addarrays.f90: Initializes two arrays, adds the array elements together into a new array

    3. arrayio.f90: demonstrates various kinds of indexing

    4. checkarray.f90: demonstrates some fortran built in functions for arrays

    5. sort.f90: reads numbers into an array from a file, sorts the numbers with selection sort.
      input data file

    6. matrix.f90: assigns values into a matrix, prints them out with DO loops

    7. logs.f90: reads values into a matrix from a file, finds the log of each value
      using a Fortran intrinsic function
      inputlogs sample datafile

    8. sort3.f90: reads numbers into an array from a file, sorts the numbers with selection sort.
      USES A SUBROUTINE!

    9. 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