Skip to content
Kyle Mandli edited this page Mar 19, 2015 · 5 revisions

Run-Time and Compile-Time Option Handling for Fortran Code

Status Accepted
Author Kyle Mandli <kyle.mandli@gmail.com>
Created March 19th, 2015
Updated March 19th, 2015
Discussion Issue #59
Implementation

Motivation

Currently options in the Fortran codes are handled in two ways, via inputting run-time parameters (e.g. output_format) through the Python interface or ASCII files or by modifying the Makefiles to include the appropriate source (e.g. the storm surge capabilities in GeoClaw). This proposal aims to do two things:

  1. encourage the use of run-time options as much as possible, and
  2. use pre-processor directives to control compile-time options.

The first of these does require some forethought as to how to implement run-time options and not bog down the run-time by checking option conditions all the time. The second of these would replace modifying the source list in the Makefiles with compile-time flags such as -DSTORM_SURGE. There are a couple of advantages to this approach over the previous one:

  1. Reduction of source replication since a single source file can include pre-processor directives that only leave source in that is needed (e.g. the inclusion of NetCDF modules if it is requested rather than having multiple source files that implements different output formats), and
  2. This is a widely accepted means to specify compile-time options and could allow a user to avoid modifying Makefiles to control the compile-time options.

The largest draw-back to this approach is that it is possible to loose record of what pre-processor directives were used if the user uses the $PFLAGS environment variable rather than modifying the Makefile to add the flags and perhaps suggests that we encourage this practice in general.

Specification

General developer guidelines will be drawn up to direct new options to be implemented as run-time options and as a last resort use compile-time options. If compile-time options are needed then use pre-processor directives.

Backwards Compatibility

This should be fully backward compatible and may actually help in some cases that were previously not.