You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document describes the Fortran 90 compiler support added to the cons build system.
4
+
5
+
## Overview
6
+
7
+
The cons build system in the `mgr/` directory now supports compilation and linking of Fortran 90 source files (.f90 and .F90). This extends the existing Fortran 77 support (.f and .F).
8
+
9
+
## Compiler Configuration
10
+
11
+
The Fortran 90 compiler uses the same compiler binary as the Fortran 77 compiler (typically `gfortran`), which supports both Fortran 77 and Fortran 90 standards.
12
+
13
+
### Build Variables
14
+
15
+
The following build variables have been added to `ConsDefs.pm`:
16
+
17
+
-**F90**: The Fortran 90 compiler command (defaults to the value of FC, typically gfortran)
18
+
-**F90FLAGS**: Compiler flags for Fortran 90 compilation
19
+
-**F90DEBUG**: Debug flags for Fortran 90 (defaults to FDEBUG value)
20
+
-**F90PATH**: Include paths for Fortran 90 modules
21
+
-**EXTRA_F90PATH**: Additional include paths for Fortran 90 modules
22
+
-**F90PPFLAGS**: Preprocessor flags for Fortran 90
23
+
-**EXTRA_F90PPFLAGS**: Additional preprocessor flags for Fortran 90
24
+
-**F90COM**: The complete compilation command for Fortran 90 files
25
+
26
+
### Default Compiler Flags
27
+
28
+
The default F90FLAGS are compatible with Fortran 77 flags and include:
29
+
-`-fd-lines-as-comments` or `-fd-lines-as-code`: Handle debug lines (depending on NODEBUG setting)
30
+
-`-fno-second-underscore`: Disable second underscore for symbol names
31
+
-`-fno-automatic`: Variables are static by default
-`-fPIC`: Generate position-independent code for shared libraries
34
+
35
+
Note: The `-std=legacy` flag used for Fortran 77 is intentionally excluded as it's F77-specific.
36
+
37
+
## File Extensions
38
+
39
+
The build system now recognizes the following Fortran 90 file extensions:
40
+
41
+
-**.f90**: Free-form Fortran 90 source files
42
+
-**.F90**: Free-form Fortran 90 source files with preprocessing
43
+
44
+
Both extensions are mapped to the `build::command::f90` builder in the cons system.
45
+
46
+
## Usage
47
+
48
+
To use Fortran 90 in your project:
49
+
50
+
1. Create your Fortran 90 source files with `.f90` or `.F90` extensions in your source directory
51
+
2. The cons build system will automatically discover these files when scanning the directory
52
+
3. The build system will automatically use the Fortran 90 compiler for these files
53
+
54
+
**Note**: The build system uses the `find_sources` function to automatically discover source files. The following Fortran file extensions are recognized for automatic discovery:
55
+
-`.F` - Fortran 77 fixed-form with preprocessing
56
+
-`.f90` - Fortran 90 free-form
57
+
-`.F90` - Fortran 90 free-form with preprocessing
58
+
59
+
**Important**: `.f` files (Fortran 77 fixed-form without preprocessing) use a separate preprocessing compilation mechanism and are not included in automatic source file discovery. They are handled through a different build path.
60
+
61
+
Example directory structure:
62
+
```
63
+
MyPackage/
64
+
├── mycode.cxx
65
+
├── myfortran.F # Fortran 77 with preprocessing (auto-discovered)
└── preprocessed.F90 # Fortran 90 with preprocessing (auto-discovered)
68
+
```
69
+
70
+
The build system will automatically find all these files and compile them appropriately.
71
+
72
+
## Differences from Fortran 77
73
+
74
+
The key differences in how Fortran 90 files are handled:
75
+
76
+
1.**Free-form source**: Fortran 90 uses free-form source format by default (no column restrictions)
77
+
2.**Module support**: The compiler will generate .mod files for Fortran 90 modules
78
+
3.**Include paths**: Use F90PATH instead of FCPATH for Fortran 90-specific include directories
79
+
80
+
## Notes
81
+
82
+
- The same linker and libraries are used for both Fortran 77 and Fortran 90 code
83
+
- Fortran 90 modules can be used (via `USE`) from other Fortran 90 code; Fortran 77 code can call procedures compiled from Fortran 90 sources when interfaces are compatible, but cannot `USE` modules directly
84
+
- The gfortran compiler supports mixing Fortran 77 and Fortran 90 code in the same project
0 commit comments