Fortran Style Guide
Contents
3. Fortran Style Guide#
I am trying to write code that is easy to follow. That means I am partitioning the code into blocks that are small and focused on one task. The result is a large number of small modules. This is not necessarily a bad thing considering that this project is being developed for folks who are not seasoned programmers. Hopefully the names of routines and modules will help the reader figure out the purpose of each routine.
This page will detail the coding conventions I am using.
3.1. Naming Conventions#
We will use two basic types of modules. One will contain code and internally defined variables. The other is data only, intended to be used only by modules that need access to those data items. We do need to pay attention to name collisions when multiple data modules are used in the same code module. Rather than use huge lists of arguments to subroutines in this code, we will pass data round using data only modules, focused on one aspect of the program only.
code modules: file name begins with “m_”
data modules: file name begins with “d_”
3.2. Subroutine Arguments#
All arguments are written with an explict intent.
Subroutine parameters that are arrays are declared in the subroutine as follows:
character(len=*), intent(in) :: param
3.3. Array Dimensions#
All arrays with specified sizes will be declared using a named constant integer to make modifying that size easy if needed.