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
Program: Fortran module dependency analyzer and topologic build order printer.
Usage:
-d DIRS Comma-separated list of directories to scan non-recursively.
-D DIRS Comma-separated list of directories to scan recursively.
-m Print a Makefile dependency list instead of build order.
-h Show this help message.
Description:
Scans .f90 files in given directories to detect Fortran modules and their
'use' dependencies, then computes a topologic order for building modules.
Can output either the ordered list of files to build or a Makefile
dependency list suitable for build systems.
Notes:
- Repeated use of -d or -D flags is an error.
- Directories in the flags are comma-separated and will be scanned in the order given
- If neither -d nor -D is specified, defaults to scanning 'src' non-recursively.
Author:
Drake Gates
Example makefile to use this progam for all FORTRAN projects
# Example makefile to use this progam for all FORTRAN projects
# Compiler and flags
FF = gfortran
FFLAGS = -cpp -fno-align-commons -O3 -ffpe-trap=zero,invalid,underflow,overflow \
-std=legacy -ffixed-line-length-none -fall-intrinsics \
-Wno-unused-variable -Wno-unused-function -Wno-conversion -fopenmp
FMOD = -Jmod -Imod
PROGRAM = program
# Directories
SRC_DIR = src
OBJ_DIR = obj
MOD_DIR = mod
# Topologically sorted module sources looking recursively through a source directory
TOPOLOGIC_SRC = $(shell maketopologicf90 -D $(SRC_DIR))
# Corresponding object files
OBJECTS = $(patsubst $(SRC_DIR)/%.f90, $(OBJ_DIR)/%.o, \
$(patsubst $(SRC_DIR)/%.for, $(OBJ_DIR)/%.o, $(TOPOLOGIC_SRC)))
# Link target
all: $(PROGRAM)
# Build the program
$(PROGRAM): $(OBJECTS)
$(FF) $(FFLAGS) -o $@ $^
# Generic pattern rule for both .f90 and .for files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.f90
@mkdir -p $(dir $@) $(MOD_DIR)
$(FF) $(FFLAGS) $(FMOD) -c $< -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.for
@mkdir -p $(dir $@) $(MOD_DIR)
$(FF) $(FFLAGS) $(FMOD) -c $< -o $@
# Clean rule
clean:
rm -rf $(OBJ_DIR)/*.o $(MOD_DIR)/*.mod $(PROGRAM)
Program for use with Make for FORTRAN projects. Outputs a topologically sorted dependency list of files that make can ingest to build the FORTRAN program.