[comp.lang.fortran] Using cpp, m4 for macro substitutions in Fortran. CORRECTION.

quinlan@physics.utoronto.ca (Gerald Quinlan) (07/08/90)

Sorry, but there was an error in my last posting.  The correct file listings
are given below.

----------------------------- Makefile -----------------------------------
# Tell make how to make .f files from .F files.
.SUFFIXES: .F .f
.F.f:
	/lib/cpp -P $(CPPFLAGS) $*.F  | m4 > $*.f

----------------------------- swap.F  -----------------------------------

#ifdef INLINE_SWAP
define(CALL_SWAP,`dummy=$1
      $1=$2
      $2=dummy')
#endif
      program swap
      a=3.0
      b=4.0
#ifdef INLINE_SWAP
      CALL_SWAP(A,B)
#else
      call swap(a,b)
#endif
      stop
      end

------------------------ make swap.f ------------------------------------



      program swap
      a=3.0
      b=4.0

      call swap(a,b)

      stop
      end

--------------- make "CPPFLAGS=-DINLINE_SWAP" swap.f ------------------------



      program swap
      a=3.0
      b=4.0

      dummy=A
      A=B
      B=dummy

      stop
      end

-----------------------------------------------------------------------------