Steve Lantz, Adam Brazier (revisions)
Cornell Center for Advanced Computing

Revisions: 2/2023, 10/2014, 6/2012 (original)

Fortran has two types of subprograms: functions, and subroutines. Subprograms can reside in the same file as the main program, or in separate files along with other subprograms. Functions and subroutines are essential for giving structure to your source code by creating compartments for logically distinct tasks.

Objectives

After you complete this topic, you should be able to:

  • Define subroutines and functions in source code
  • Call subroutines and functions in source code
  • Pass arrays as arguments to subprograms
  • Create temporary arrays in subprograms
Prerequisites
  • Familiarity with an editor
  • Knowledge of how to execute simple commands on the command line
  • Some basic understanding of what a computer language is
 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement