  ! This software MAIN.F90 is part of the Visual Fortran kit.
  ! 
  ! This software is provided as an example that demonstrates a particular
  ! feature/function of the licensed product. The software is not intended to
  ! provide a complete solution to any application problem but rather is provided
  ! as a teaching mechanism.
  ! 
  ! Users may incorporate any part of this sample into their own source after 
  ! making appropriate changes to make it suitable for the intended application.
       
  ! This example calculates the average of five numbers.
  ! It shows a sample Fortran 90 main program that uses free source form.
  ! This main program uses a module and an external subprogram. When you compile
  ! a source file that contains a MODULE block, the compiler creates
  ! a module file (extension .mod), whose file name is the name of the module.
  !
  ! The function CALC_AVERAGE is contained in a separately created file and
  ! depends on the module ARRAY_CALCULATOR for its interface block.
  !
  ! Notes:
  !
  !   1  The USE statement accesses the module array_calculator.mod. This
  !      module contains the function declaration for CALC_AVERAGE
  !      (use association).
  !
  !   2  The 5-element array is passed to the function CALC_AVERAGE, which
  !      returns the value to the variable AVERAGE for printing.

  PROGRAM MAIN

    USE ARRAY_CALCULATOR                            ! See note 1
    REAL, DIMENSION(5) :: A = 0
    REAL :: AVERAGE
    PRINT *, 'Type five numbers: '
    READ  (*,'(F10.3)') A
    AVERAGE = CALC_AVERAGE(A)                       ! See note 2
    PRINT *, 'Average of the five numbers is: ', AVERAGE

  END PROGRAM MAIN
