f90 makefile for middlepark / winterpark
# =============================================================================
# makefile (DESCRIPTION FILE)
#
# Somewhat generic f90 makefile for use on middlepark / winterpark. Use this as
# an example and modify it to suit your needs.
#
# David Stepaniak (CGD/CAS)
# 27, 30 June 1997
#
# NOTES:
#
# 0) Does not cover recursive make. Source code must exist in same directory
# as object code and executable. The simplest way to achieve this is to
# make symbolic links to source code from directory in which you want to
# build executable.
# 1) Prefixes PROGRAM_ refers to main program file, MOD_ to module files, FUN_
# to function files(not shown in this example), & SUB_ to subroutine files.
# Your naming conventions may be different.
# 2) A tab must begin a command line. In this makefile command lines are sig-
# nificantly indented and begin with f${FORTRAN_VER}. Use cat -v -t -e
# makefile to see tabs (appear as ^I) and returns (appear as $ at the end
# of a line).
# 3) Continuation of a line is denoted by \ and there must be no space after
# it.
# 4) In order for modules contained in separate files to be properly referenced
# by other source code, the modules must be compiled first so that their
# module_name.kmo files and their object files are created before any other
# object files. This step is performed only during initial make or when
# module files are modified.
# 5) Recommended use of this makefile ( a > means from command line):
# a) Make sure that compiler options are the ones you want in COMPILER
# MACROS section.
# b) Check which library paths, library names, and include file paths are
# needed and modify PATH AND LIB MACROS section accordingly.
# c) Enter desired name of executable file in PROGRAM TARGET section.
# d) Enter all source file names, replacing (.f90,.f) extension with .o
# extension in TARGETS OF PREREQUISITE (.f90,.f) SOURCE FILES section.
# e) Modify the last section which is a SPECIAL TARGET for compiling mod-
# ules first. Enter the appropriate wild card specification of module
# files to match your own convention of naming module files. (It is rec-
# commended that modules files have at least a .f90 extension.)
# f) To 'precompile' separate files containing modules:
# > make MODULES
# (If source code does not contain separate files for modules this step
# does not have to be performed.)
# g) Then to compile and link all source code:
# > make `name of program'
# (In the example below `name of program' is f90_netcdf) Thereafter,
# only step (g) needs to be implemented except when module files are
# modified after a given make.
#
# =============================================================================
# Significant suffixes [assuming Fortran 90 (.f90) and possibly Fortran 77
# (.f) source code]:
.SUFFIXES : .o .f90 .f
# -----------------------------------------------------------------------------
# (a) Set Fortran version and compiler options: (COMPILER MACROS)
FORTRAN_VER = 90
MEM_ADDRESS = 64
INST_SET = mips4
OPTMZN_LEV = 3
REAL_BYTES = 4
COMPILER_OPTS = -${MEM_ADDRESS} -${INST_SET} -O${OPTMZN_LEV} -r${REAL_BYTES}
# -----------------------------------------------------------------------------
# (b) Set library paths & names, and include file paths: (PATH AND LIB MACROS)
MIPS4_R4_LPATH = /usr/local/lib_mips4_r4
MIPS4_R8_LPATH = /usr/local/lib_mips4_r8
MSS_LIB = mss
NETCDF_LIB = netcdf
NCARU_LIB = ncaru
NETCDF_IPATH = /usr/local/include
LIBRARY_PATHS = -L${MIPS4_R4_LPATH}
LIBRARY_NAMES = -l${NETCDF_LIB}
INCLUDE_PATHS = -I${NETCDF_IPATH}
#------------------------------------------------------------------------------
# (c) Set program (executable file) name: (PROGRAM TARGET)
PROGRAM = f90_netcdf
# -----------------------------------------------------------------------------
# (d) Create expected object file list, with .o extension: [TARGETS OF PRE-
# REQUISITE (.f90,.f) SOURCE FILES]
#
# Example `prerequisite' (.f90,.f) source files:
#
# PROGRAM_f90_netcdf.f90
# MOD_math_constants.f90
# SUB_f77_netcdf.f
#
# In this example SUB_f77_netcdf.f is a stand-alone f77 subroutine which
# utilizes the netcdf.inc file and various netcdf functions. Notice how it
# is compiled with ${INCLUDE_PATHS} below. It is callable by f90 routines.
OBJECT_FILES = PROGRAM_f90_netcdf.o \
MOD_math_constants.o \
SUB_f77_netcdf.o
# -----------------------------------------------------------------------------
# (g) Assign dependents to target on dependency line & link options on command
# line. Command line is initiated with a tab. ($@ is an internal macro for
# the current target.)
${PROGRAM} : ${OBJECT_FILES}
f${FORTRAN_VER} -o $@ ${OBJECT_FILES} ${COMPILER_OPTS} \
${LIBRARY_PATHS} ${LIBRARY_NAMES}
# -----------------------------------------------------------------------------
# Individual compilation using significant suffix. (`make' uses the suffix rule
# .f90.o: f90 -c ... $< to compile .f90 prerequisite files into their .o target
# files if any of the .f90 files were modified since the last make. Same for
# .f.o: f90 -c ... $<.)
.f90.o :
f${FORTRAN_VER} -c ${COMPILER_OPTS} $<
.f.o :
f${FORTRAN_VER} -c ${COMPILER_OPTS} ${INCLUDE_PATHS} $<
# -----------------------------------------------------------------------------
# (e, f) SPECIAL TARGET for compiling files containing modules so that
# module_name.kmo files and associated object files are created or
# updated before all other source code object files. Also, a target
# is provided for removing object files and the executable. Invoke
# this target as make CLEAN. (A tab must proceed the /bin/rm.)
MODULES :
f${FORTRAN_VER} -c ${COMPILER_OPTS} MOD_*.f90
CLEAN :
/bin/rm *.o ${PROGRAM}
# =============================================================================
# End makefile.
# =============================================================================