Subject: summary and a question: compilation error on G98

From: Sérgio Emanuel Galembeck <[email-masked]>
Date: Sun, 17 Jun 2001 00:32:06 -0300

Dear All,

    I received two answers to my question about compilation of G98
on RedHat 7.1 in an Atlhon 800MHz. Thanks to Ben Webb and
Doug Fox!
    The two answers are contained in  Doug's mail, in the end of this mail.
    These suggestions solve my original problem, but there is another one
when some programs where compiled, as in the fragment of bldg98.log
bellow. I tried to use lsblaspii1.2d_12.99.a, lsblaspii1.2f_03.00.a  or
libatlas.a (and libf77atlas.a), but the compilation does not finish in a
good
way.

    Thank you for any advice,

                        Sergio

----------------------------------------------------------------------------
------------
pgf77    -O2 -tp p6  -Munroll -Mvect=cachesize:524288 -o chkchk chkchk.o
util.so
util.so: the use of `tmpnam' is dangerous, better use `mkstemp'
gau-cpp -I/usr/g98 -I/usr/g98s -DGAUSS_PAR -DGAUSS_THPAR  -DDEFMAXSHL=20000 
-DDEFMAXATM=20000 -DDEFMAXNZ=20000 -DDEFNVDIM=257 -DDEFARCREC=1024 -DMERGE_L
OOPS -DUSE_ESSL -D_I386_ -DLITTLE_END -DUSING_F2C -DDEFMAXIOP=100 -DDEFMAXCH
R=1024 -DDEFLMAX=13 -DDEFN3MIN=10 -DDEFMAXHEV=2000 -DDEFCACHE=64 -DDEFMAXLEC
P=10 -DDEFMAXFUNIT=5 -DDEFMAXFFILE=10000 -DDEFMAXFPS=1300 -DDEFMAXINFO=200 -
DDEFMAXOP=120 -DDEFMAXTIT=100 -DDEFMAXRTE=4000 -DDEFMAXOV=500 -D_ALIGN_CORE_
 -DCA1_DGEMM -DCA2_DGEMM -DCAB_DGEMM -DLV_DSP -DO_BKSPEF -DDEFMXTS=1500 -DDE
FMXBAS=500 -DDEFMXOPT=50 -DDEFMXBOND=12 -DDEFMXSPH=250 -DDEFMXINV=1500
pluck.F pluck.f
pgf77    -O2 -tp p6  -Munroll -Mvect=cachesize:524288 -c pluck.f
rm -f pluck.f pluck.c
pgf77    -O2 -tp p6  -Munroll -Mvect=cachesize:524288 -o pluck pluck.o
util.so
util.so: the use of `tmpnam' is dangerous, better use `mkstemp'
gau-cpp -I/usr/g98 -I/usr/g98s -DGAUSS_PAR -DGAUSS_THPAR  -DDEFMAXSHL=20000 
-DDEFMAXATM=20000 -DDEFMAXNZ=20000 -DDEFNVDIM=257 -DDEFARCREC=1024 -DMERGE_L
OOPS -DUSE_ESSL -D_I386_ -DLITTLE_END -DUSING_F2C -DDEFMAXIOP=100 -DDEFMAXCH
R=1024 -DDEFLMAX=13 -DDEFN3MIN=10 -DDEFMAXHEV=2000 -DDEFCACHE=64 -DDEFMAXLEC
P=10 -DDEFMAXFUNIT=5 -DDEFMAXFFILE=10000 -DDEFMAXFPS=1300 -DDEFMAXINFO=200 -
DDEFMAXOP=120 -DDEFMAXTIT=100 -DDEFMAXRTE=4000 -DDEFMAXOV=500 -D_ALIGN_CORE_
 -DCA1_DGEMM -DCA2_DGEMM -DCAB_DGEMM -DLV_DSP -DO_BKSPEF -DDEFMXTS=1500 -DDE
FMXBAS=500 -DDEFMXOPT=50 -DDEFMXBOND=12 -DDEFMXSPH=250 -DDEFMXINV=1500
unfchk.F unfchk.f
pgf77    -O2 -tp p6  -Munroll -Mvect=cachesize:524288 -c unfchk.f
rm -f unfchk.f unfchk.c
pgf77    -O2 -tp p6  -Munroll -Mvect=cachesize:524288 -o unfchk unfchk.o
util.so
util.so: the use of `tmpnam' is dangerous, better use `mkstemp'
endif
----------------------------------------------------------------------------
----------

    The answer of Doug Fox:

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

Prof. Galembeck,

   We do not support G98 on RedHat 7.1 and at present the instability which
is reported on the net has caused us to further delay considering this
version.  At this time my first recommendation would be to move a
precompiled
version from a system using RedHat 6.2 or earlier.  We have tested this
and see no problems.

   I do have a report from another user who saw this and noted that adding

#include <time.h>

is one way of getting past this problem.  Put this line in g98/bsd/mdutil.c
after

#ifdef i386
#include <unistd.h>
#include <errno.h>

  I have also included an updated makefile which resolves some problems
with the loader used with RH 7.1.  Note that you need to test carefully
to make sure that everything works as expected.  This makefile replaces
g98/bsd/i386.make.

#
# Makefile for Gaussian 98.
#
#     Copyright (c) 1988,1990,1992,1993,1995,1998 Gaussian, Inc.
#
#     This is part of the Gaussian(R) 98 program. It is based on the
#     the Gaussian 94(TM) system (copyright 1995 Gaussian, Inc.),
#     the Gaussian 92(TM) system (copyright 1992 Gaussian, Inc.),
#     the Gaussian 90(TM) system (copyright 1990 Gaussian, Inc.),
#     the Gaussian 88(TM) system (copyright 1988 Gaussian, Inc.),
#     the Gaussian 86(TM) system (copyright 1986 Carnegie Mellon
#     University), and the Gaussian 82(TM) system (copyright 1983
#     Carnegie Mellon University). Gaussian is a federally registered
#     trademark of Gaussian, Inc.
#
#     This software contains proprietary and confidential information,
#     including trade secrets, belonging to Gaussian, Inc.
#
#     This software is provided under written license and may be
#     used, copied, transmitted, or stored only in accord with that
#     written license.
#
#     The following legend is applicable only to US Government contracts
#     under DFARS:
#
#                        RESTRICTED RIGHTS LEGEND
#
#     Use, duplication or disclosure by the US Government is subject to
#     restrictions as set forth in subparagraph (c)(1)(ii) of the Rights
#     in Technical Data and Computer Software clause at DFARS
#     252.227-7013.
#
#     Gaussian, Inc., Carnegie Office Park, Building 6, Pittsburgh, PA 15106
USA
#
#     The following legend is applicable only to US Government contracts
#     under FAR:
#
#                        RESTRICTED RIGHTS LEGEND
#
#     Use, reproduction and disclosure by the US Government is subject
#     to restrictions as set forth in subparagraph (c) of the Commercial
#     Computer Software - Restricted Rights clause at FAR 52.227-19.
#
#     Gaussian, Inc., Carnegie Office Park, Building 6, Pittsburgh, PA 15106
USA
#
# Where to find this file when making executables:
#
#
# switch the following two lines if the optimized blas library is not
available.  This
# library is highly recommended
# BLAS = blas.a
BLAS = /usr/local/lib/blas-opt.a /usr/local/lib/blas-f2c.a
BLASFLAG = -DCA1_DGEMM -DCA2_DGEMM -DCAB_DGEMM -DLV_DSP
# switch the following two lines if compilation for the pentium is desired
instead
# of for the P6/Pentium-II
MACH = -tp p6
# MACH = -tp p5
#
BSDDIR = bsd
MAKELOC = -f $(BSDDIR)/g98.make
BSDDIR1 = ../bsd
MAKELOC1 = -f $(BSDDIR1)/g98.make
UTILDIR = ..
HLIBDIR = $(g98root)/hermes/lib
HSRC = $(g98root)/hermes/gxinterface
HINC = $(g98root)/hermes/include
HLIBS = $(HLIBDIR)/libdbapi.a $(HLIBDIR)/libsupp.a $(HLIBDIR)/libisam.a \
$(HLIBDIR)/libcbt.a $(HLIBDIR)/libutils.a $(HLIBDIR)/libgxchm.a
HFLAGS = $(CFLAGS) -I$(HINC) -D_POSIX_SOURCE
#
# The utility library:
#
GAULIBA = util.a
#GAULIB = $(GAULIBA) $(BLAS)
GAULIB = util.so
#
# Directory pointers only used for linking the profiling version:
#
GSDIR = .
GDIR = ../g98
#
# Standard dimensioning definitions.
#
PCMDIM
= -DDEFMXTS=1500 -DDEFMXBAS=500 -DDEFMXOPT=50 -DDEFMXBOND=12 -DDEFMXSPH=250 
-DDEFMXINV=1500
INCDIR = -I$(g98root)/g98
PARFLAG = -DGAUSS_PAR -DGAUSS_THPAR
DIMENSX = $(INCDIR) -I$(g98root)/g98s $(PARFLAG)
$(DEBUGP) -DDEFMAXSHL=20000 -DDEFMAXATM=20000 \
  -DDEFMAXNZ=20000 -DDEFNVDIM=257 \
  -DDEFARCREC=1024 -DMERGE_LOOPS -DUSE_ESSL -D_I386_ -DLITTLE_END -DUSING_F2
C \
  -DDEFMAXIOP=100 -DDEFMAXCHR=1024 -DDEFLMAX=13 -DDEFN3MIN=10 -DDEFMAXHEV=20
00 -DDEFCACHE=64 \
  -DDEFMAXLECP=10 -DDEFMAXFUNIT=5 -DDEFMAXFFILE=10000 -DDEFMAXFPS=1300 -DDEF
MAXINFO=200 \
  -DDEFMAXOP=120 -DDEFMAXTIT=100 -DDEFMAXRTE=4000 -DDEFMAXOV=500 -D_ALIGN_CO
RE_ \
  $(BLASFLAG) -DO_BKSPEF $(PCMDIM)
#
# These commands are converted to "on machine command" for remote-
# control compilation.
#
RUNF2C = f2c -kr -T. -R -Nx400 -Nn1604 -NL800
RUNCC = cc -g
RUNAR  = ar
RUNRAN = ranlib
RUNCPP = gau-cpp
RUNFSP = gau-fsplit
RUNMAKE = make#
OPTFLAGO
= -malign-double -m486 -fexpensive-optimizations -O3 -ffast-math -funroll-lo
ops
# Flags for portland compiler.
#
RUNF77 = pgf77
F2CLIB =
LIBS =
UNROLL = -Munroll
VECTOR = -Mvect=cachesize:524288
TWOH =
PC64 = -pc 64 -Kieee
#
# Standard compilation flags:
#
DIMENS = $(DIMENSX) $(TWOH)
FNOOPT = $(PROFFLAG) -O0 $(MACH) $(TIME)
FNOOPT64 = $(FNOOPT) $(PC64)
FOPT1 = $(PROFFLAG) -O1 $(MACH)
FOPT2 = $(PROFFLAG) -O2 $(MACH)
FOPT2UN = $(FOPT2) $(UNROLL)
FOPT2VC = $(FOPT2) $(VECTOR)
OPTFLAG = $(FOPT2) $(UNROLL) $(VECTOR)
FFLAGS = $(PROFFLAG) $(OPTFLAG)
CFLAGS = $(DIMENS) $(OPTFLAGO) $(PROFFLAG)
EXTOBJ =
TESTRTO =
#
# Default suffixes:
#
.SUFFIXES:
.SUFFIXES: .exel .exe .a .o .lo .f .fl .c .F .prj

#
# Rules for Fortran and C compilation, possible including "on machine"
#
#.F.o:
%.o : %.F
$(RUNCPP) $(DIMENS) $*.F $*.f
$(RUNF77) $(FFLAGS) -c $*.f
rm -f $*.f $*.c

#.F.f:
%.f : %.F
$(RUNCPP) $(DIMENS) $*.F $*.f

#.F.c:
#%.c : %.F
# $(RUNCPP) $(DIMENS) $*.F $*.f
# $(RUNF2C) $*.f
# rm -f $*.f

#.c.o:
%.o : %.c
$(RUNCC) $(CFLAGS) -c $*.c

#
# Utility routines under development:
EXTRAS =
#
# Default is to make the whole thing:
#
all:    util.a exe

#
# Here is the list of executables:
#
exe: gau-machine gau-fsplit gau-cpp $(GAULIBA) $(GAULIB) \
exe1 exe3 exe5 \
        exe7 exe9 exe10 exe11 utils

#
# Everything includes the non-distributed code.
#
everything: exe extrasx localx

exe1:         g98      l1.exe    l101.exe    l102.exe    l103.exe \
l105.exe    l106.exe    l107.exe    l108.exe    l109.exe \
l110.exe    l111.exe    l113.exe    l114.exe    l115.exe \
l116.exe    l117.exe    l118.exe    l120.exe    l202.exe

exe3:    l301.exe    l302.exe    l303.exe    \
l307.exe    l308.exe    l310.exe    l311.exe \
l314.exe    l315.exe    l316.exe    l317.exe    l318.exe \
l319.exe    l320.exe

exe5:    l401.exe    l402.exe    l405.exe    l502.exe    \
l503.exe    l504.exe    l506.exe    l508.exe    \
l510.exe    l601.exe    l602.exe    l604.exe    \
l607.exe    l608.exe    l609.exe    l610.exe

exe7:    l701.exe    l702.exe    l703.exe    \
l716.exe    l801.exe    l802.exe    l803.exe \
         l804.exe    l811.exe

exe9:    l901.exe    l902.exe    l903.exe    l905.exe    l906.exe
l908.exe\
l909.exe    l913.exe \
l914.exe    l915.exe    l916.exe    l918.exe   \
l9999.exe

exe10:  l1002.exe   l1003.exe   l1014.exe

exe11:  l1101.exe   l1102.exe   l1110.exe   l1111.exe   l1112.exe

utils:     gauopt       ghelp     newzmat      testrt      \
      cubegen cubman       c8698     ham506 \
   cktoig     rwfdump     chkmove     freqchk     freqmem    formchk \
           demofc      chkchk     pluck        unfchk

#
# Which links use direct code:
#
DIREXES = l117.exe l302.exe l303.exe l308.exe l319.exe l320.exe \
  l401.exe l502.exe l506.exe l508.exe l510.exe l601.exe l602.exe \
  l608.exe l701.exe l703.exe l716.exe l804.exe l811.exe l906.exe \
  l908.exe l909.exe l913.exe l914.exe l916.exe l1002.exe l1003.exe l1014.exe
l1101.exe l1102.exe \
          l1110.exe l1111.exe l1112.exe

deldirexe:
rm -f $(DIREXES) *.exel

direxe: $(DIREXES)

ARCHEXES = l9999.exe arctmp browse crendx reform

delarchexe:
rm -f $(ARCHEXES)

archexe: $(ARCHEXES)

#
# How to delete the executables:
#
delexe:
rm -fr *.exe gauopt ghelp newzmat testrt arctmp arc browse \
   crendx reform cubman ham506 g98 gau-machine gau-fsplit gau-cpp \
   g98all c8698 rwfdump rwftrunc chkchk cktoig chkmove freqchk g98se \
   freqmem formchk demofc pluck unfchk $(LFILES) local/*.exe gau-worker
- (cd extras ; make -f extras.make delexe)

clean: delexe
rm -f util.so cubegen *.a *.o *.lo local/*.a local/*.o local/rpac/*.a \
  local/rpac/*.o bsd/g98.make local/rpac/rpac.make
- (cd extras ; make -f extras.make clean)
#
# How to make the library:
#
util.a:
$(BSDDIR)/bldg98 nolink

# How to update the library:
update: $(EXTRAS)
(ar lrv util.a $(EXTRAS); $(RUNRAN) util.a)

#
# The generic command line for making a link from its library:
#
#.F.exe:
%.exe : %.F
$(RUNFSP) -e m$* $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.o
$(RUNF77) $(FFLAGS) -o $*.exe m$*.o $(EXTOBJ) $*.a $(EXTRAS) $(GAULIB)
$(LIBS)
rm -f m$*.*

#
#
# The generic command for making a link library from source:
#
#.F.a:
%.a : %.F
rm -f -r temp-$*
mkdir temp-$*
(cd temp-$* ; $(RUNFSP) ../$*.F ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[a-l]*.F ; \
  ($(RUNAR) rlv ../$*.a [a-l]*.o; exit 0); \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[m-z]*.F ; \
  ($(RUNAR) rlv ../$*.a [m-z]*.o; exit 0))
rm -f -r temp-$*
$(RUNRAN) $*.a

#
# How to make a .prj file from source.
#
.F.prj:
$(RUNCPP) $(DIMENS) $*.F $*.f
forchek $(FCHEKFLAGS) $*.f
rm -f $*.f

#
# l1 library has two source files:
#
l1.a: l1.F bsd/mdl1.F ertgen.inc
rm -f -r temp-l1
mkdir temp-l1
(cd temp-l1 ; $(RUNFSP) ../l1.F ; $(RUNFSP) ../bsd/mdl1.F ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB *.F
; \
  $(RUNAR) rlv ../l1.a *.o)
rm -f -r temp-l1
$(RUNRAN) l1.a

lapack.a: lapack.F
rm -f -r temp-lapack
mkdir temp-lapack
(cd temp-lapack ; $(RUNFSP) ../lapack.F  ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[a-c]*.F ; \
  $(RUNAR) rlv lapack.a [a-c]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
d[a-k]*.F ; \
  $(RUNAR) rlv lapack.a d[a-k]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
dl*.F ; \
  $(RUNAR) rlv lapack.a dl*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
d[m-r]*.F ; \
  $(RUNAR) rlv lapack.a d[m-r]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
d[s-z]*.F ; \
  $(RUNAR) rlv lapack.a d[s-z]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[e-y]*.F ; \
  $(RUNAR) rlv lapack.a [e-y]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
z[a-k]*.F ; \
  $(RUNAR) rlv lapack.a z[a-k]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
zl*.F ; \
  $(RUNAR) rlv lapack.a zl*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
z[m-r]*.F ; \
  $(RUNAR) rlv lapack.a z[m-r]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
z[s-z]*.F ; \
  $(RUNAR) rlv lapack.a z[s-z]*.o ; \
  mv lapack.a ..)
rm -f -r temp-lapack
$(RUNRAN) lapack.a

#
# Exceptional link commands:
#

g98: $(GAULIB) $(EXTRAS)
$(RUNFSP) -e ml0 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml0.o
$(RUNF77) $(FFLAGS) -o g98 ml0.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)
rm -f ml0.*

#l302.exe l307.exe l314.exe l701.exe l703.exe l1101.exe l1110.exe: $(EXTRAS)
# ar x $(GAULIBA) bdrys.o
# $(RUNFSP) -e m$* $(BSDDIR)/main.F
# $(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.o
# $(RUNF77) $(FFLAGS) -o $*.exe m$*.o $(EXTOBJ) $*.a bdrys.o $(EXTRAS)
$(GAULIB) $(LIBS)
# rm -f m$*.* bdrys.o

#l402.exe: $(EXTRAS) l402.a
# $(RUNFSP) -e m$* $(BSDDIR)/main.F
# $(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.o
# ar x l402.a bd0402.o
# $(RUNF77) $(FFLAGS) -o $*.exe m$*.o $(EXTOBJ) $*.a bd0402.o $(EXTRAS)
$(GAULIB) $(LIBS)
# rm -f m$*.* bd0402.o

#l609.exe: $(EXTRAS) l609.a
# $(RUNFSP) -e m$* $(BSDDIR)/main.F
# $(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.o
# ar x l609.a bd0609.o
# $(RUNF77) $(FFLAGS) -o $*.exe m$*.o $(EXTOBJ) $*.a bd0609.o $(EXTRAS)
$(GAULIB) $(LIBS)
# rm -f m$*.* bd0609.o

l705.exe: $(EXTRAS) l306.a l705.a
$(RUNFSP) -e ml705 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml705.o
$(RUNF77) $(FFLAGS) -o l705.exe ml705.o $(EXTOBJ) l705.a l306.a $(EXTRAS)
$(GAULIB) $(LIBS)
rm -f ml705.*

l709.exe: $(EXTRAS) l309.a l709.a
$(RUNFSP) -e ml709 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml709.o
$(RUNF77) $(FFLAGS) -o l709.exe ml709.o $(EXTOBJ) l709.a l309.a $(EXTRAS)
$(GAULIB) $(LIBS)
rm -f ml709.*

#l806.exe: $(EXTRAS) l806.a
# $(RUNFSP) -e m$* $(BSDDIR)/main.F
# $(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.o
# ar x l806.a bd0806.o
# $(RUNF77) $(FFLAGS) -o $*.exe m$*.o $(EXTOBJ) $*.a bd0806.o $(EXTRAS)
$(GAULIB) $(LIBS)
# rm -f m$*.* bd0806.o

l1003.exe: $(EXTRAS) l510.a l1003.a
$(RUNFSP) -e ml1003 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml1003.o
$(RUNF77) $(FFLAGS) -o l1003.exe ml1003.o $(EXTOBJ) l1003.a l510.a $(EXTRAS)
$(GAULIB) $(LIBS)
rm -f ml1003.*

l1004.exe: $(EXTRAS) l1112.a l1004.a
$(RUNFSP) -e ml1004 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml1004.o
$(RUNF77) $(FFLAGS) -o l1004.exe ml1004.o $(EXTOBJ) l1004.a l1112.a
$(EXTRAS) $(GAULIB) $(LIBS)
rm -f ml1004.*

l1014.exe: $(EXTRAS) l1112.a l1014.a l914.a
$(RUNFSP) -e ml1014 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml1014.o
$(RUNF77) $(FFLAGS) -o l1014.exe ml1014.o $(EXTOBJ) l1014.a l1112.a l914.a
$(EXTRAS) $(GAULIB) $(LIBS)
rm -f ml1014.*

l9999.exe: $(EXTRAS) l9999.a dummy.o dummy-narch.o
$(RUNFSP) -e ml9999 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml9999.o
$(RUNF77) $(FFLAGS) -o l9999.exe ml9999.o $(EXTOBJ) $(EXTRAS) l9999.a \
   dummy.o $(GAULIB) dummy-narch.o $(LIBS)
rm -f ml9999.*

l9999-hermes: $(EXTRAS) l9999.a archlib.a mdarch.a $(HLIBS) gxxlnk.o
$(RUNFSP) -e ml9999 $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ml9999.o
$(RUNF77) $(FFLAGS) -o l9999.exe ml9999.o $(EXTOBJ) $(EXTRAS) \
  gxxlnk.o l9999.a archlib.a mdarch.a $(GAULIB) dummy-narch.o \
  $(HLIBS) $(LIBS)
rm -f ml9999.*

gxxlnk.o: $(HINC)/gdb.h $(HINC)/cberr.h $(HSRC)/gxxlnk.c
$(RUNCC) $(HFLAGS) -c $(HSRC)/gxxlnk.c

arc:
ln -sf browse arc

arctmp: arctmp.o $(GAULIB) $(EXTRAS) archlib.a mdarch.a
$(RUNF77) $(FFLAGS) -o arctmp arctmp.o $(EXTOBJ) $(EXTRAS) archlib.a \
  mdarch.a $(GAULIB) $(LIBS)

browse: $(EXTRAS) archlib.a mdarch.a l101.a l202.a l716.a ghelp.o
$(RUNFSP) -e mbrowse $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) mbrowse.o
$(RUNF77) $(FFLAGS) -o browse mbrowse.o $(EXTOBJ) ghelp.o archlib.a \
  mdarch.a l101.a l202.a l716.a l9999.a $(EXTRAS) $(GAULIB) $(LIBS)
rm -f mbrowse.*

c8698: $(EXTRAS) c8698.o
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) c8698.o
$(RUNF77) $(FFLAGS) -o c8698 c8698.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

chkchk: $(EXTRAS) chkchk.o
$(RUNF77) $(FFLAGS) -o chkchk chkchk.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

cktoig: $(EXTRAS) cktoig.o
$(RUNF77) $(FFLAGS) -o cktoig cktoig.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

crendx: crendx.o crendxmfl.o $(GAULIB) $(EXTRAS) archlib.a mdarch.a
$(RUNF77) $(FFLAGS) -o crendx crendx.o crendxmfl.o $(EXTOBJ) $(EXTRAS) \
   archlib.a mdarch.a $(GAULIB) $(LIBS)

chkmove: chkmove.o
$(RUNFSP) -e mchkmov $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' mchkmov.o
$(RUNF77) $(FFLAGS) -o chkmove mchkmov.o chkmove.o \
  $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)
rm mchkmov.*

cubman: cubman.o
$(RUNF77) $(FFLAGS) -o cubman cubman.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

cubegen: cubegen.o
$(RUNF77) $(FFLAGS) -o cubegen cubegen.o $(EXTOBJ) $(EXTRAS) $(GAULIB)
$(LIBS)

freqchk: freqchk.o l716.a newzmat.a
$(RUNF77) $(FFLAGS) -o freqchk freqchk.o l716.a newzmat.a $(EXTOBJ)
$(EXTRAS) $(GAULIB) $(LIBS)

freqmem: freqmem.o
$(RUNF77) $(FFLAGS) -o freqmem freqmem.o $(EXTOBJ) $(EXTRAS) $(GAULIB)
$(LIBS)

formchk: formchk.o
$(RUNF77) $(FFLAGS) -o formchk formchk.o $(EXTOBJ) $(EXTRAS) $(GAULIB)
$(LIBS)

demofc: demofc.o
$(RUNF77) $(FFLAGS) -o demofc demofc.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

gauopt: $(EXTRAS) gauopt.o
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) gauopt.o
$(RUNF77) $(FFLAGS) -o gauopt gauopt.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

ghelp: $(EXTRAS) ghelp.o
$(RUNFSP) -e mghelp $(BSDDIR)/main.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) ghelp.o mghelp.o
$(RUNF77) $(FFLAGS) -o ghelp mghelp.o ghelp.o l9999.a $(EXTOBJ) $(EXTRAS)
$(GAULIB) $(LIBS)
rm -f mghelp.*

ham506: ham506.o
$(RUNF77) $(FFLAGS) -o ham506 ham506.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

newzmat: $(EXTRAS) newzmat.a newzmat-bsd.o l101.a l716.a
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) newzmat.a newzmat-bsd.o
$(RUNF77) $(FFLAGS) -o newzmat newzmat-bsd.o newzmat.a $(EXTOBJ) \
    l101.a l401.a l716.a $(EXTRAS) $(GAULIB) $(LIBS)

pluck: pluck.o
$(RUNF77) $(FFLAGS) -o pluck pluck.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

unfchk: unfchk.o
$(RUNF77) $(FFLAGS) -o unfchk unfchk.o $(EXTOBJ) $(EXTRAS) $(GAULIB) $(LIBS)

reform: reform.o $(GAULIB) $(EXTRAS) archlib.a mdarch.a
$(RUNF77) $(FFLAGS) -o reform reform.o $(EXTOBJ) $(EXTRAS) archlib.a \
   mdarch.a $(GAULIB) $(LIBS)

rwfdump: rwfdump.o
$(RUNF77) $(FFLAGS) -o rwfdump rwfdump.o $(EXTOBJ) $(EXTRAS) $(GAULIB)
$(LIBS)

testrt: $(EXTRAS) testrt.o l1.a $(TESTRTO)
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) testrt.o $(TESTRTO)
$(RUNF77) $(FFLAGS) -o testrt testrt.o $(TESTRTO) $(EXTOBJ) l1.a l9999.a
$(EXTRAS) $(GAULIB) $(LIBS)

gau-cpp: $(BSDDIR)/cpp.c $(BSDDIR)/cpp.h
$(RUNCC) -o gau-cpp -DHOST=SYS_UNIX -Dstrchr=index -Dstrrchr=rindex \
  $(BSDDIR)/cpp.c

gau-fsplit: $(BSDDIR)/fsplit.c
$(RUNCC) $(CFLAGS) -o gau-fsplit $(BSDDIR)/fsplit.c

gau-machine: $(BSDDIR)/machine.c
$(RUNCC) -o gau-machine $(BSDDIR)/machine.c

gau-worker.o: $(BSDDIR)/gau-worker.F
$(RUNCPP) $(DIMENS) $(BSDDIR)/gau-worker.F ./gau-worker.f
$(RUNF77) $(FFLAGS) -c gau-worker.f
rm -f gau-worker.f gau-worker.c

gau-worker: gau-worker.o
$(RUNF77) $(FFLAGS) -o gau-worker gau-worker.o $(EXTOBJ) \
  $(EXTRAS) $(GAULIB) $(LIBS)

#
# How to build the profiling version (all linked together in one image):
#
# extras $(GDIR)/l105.a $(GDIR)/l304.a $(GDIR)/l312.a $(GDIR)/l505.a
#        $(GDIR)/l317.a
g98all:
$(RUNFSP) -e ml0 $(BSDDIR)/main.F
$(RUNFSP) -e argnames -e chain -e drum $(BSDDIR)/mdutil.F
$(RUNFSP) -e l1init $(BSDDIR)/mdl1.F
$(RUNMAKE) $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS)
DIMENS='$(DIMENS) -DONEPROG' \
  dummy-links.a chain.o drum.o l1init.o argnames.o ml0.o
$(RUNF77) $(FFLAGS) -o g98all ml0.o chain.o drum.o l1init.o \
    argnames.o $(EXTOBJ) $(EXTRAS) $(GSDIR)/l1.a \
    $(GSDIR)/l101.a $(GDIR)/l102.a $(GSDIR)/l103.a \
    $(GDIR)/l106.a $(GDIR)/l107.a $(GDIR)/l108.a $(GDIR)/l109.a \
    $(GDIR)/l110.a $(GDIR)/l111.a $(GDIR)/l112.a $(GDIR)/l113.a \
    $(GDIR)/l114.a $(GSDIR)/l115.a $(GSDIR)/l202.a \
    $(GSDIR)/l301.a $(GDIR)/l302.a $(GDIR)/l303.a \
    $(GDIR)/l305.a $(GSDIR)/l306.a $(GDIR)/l307.a $(GDIR)/l308.a \
    $(GDIR)/l310.a $(GSDIR)/l311.a $(GSDIR)/l314.a \
    $(GDIR)/l315.a $(GDIR)/l316.a \
    $(GSDIR)/l401.a $(GSDIR)/l402.a $(GSDIR)/l405.a \
    $(GSDIR)/l501.a $(GSDIR)/l502.a $(GSDIR)/l503.a $(GDIR)/l504.a \
    $(GSDIR)/l508.a $(GSDIR)/l509.a $(GSDIR)/l510.a \
    $(GSDIR)/l601.a $(GDIR)/l602.a $(GDIR)/l603.a $(GSDIR)/l604.a \
    $(GSDIR)/l701.a $(GSDIR)/l702.a $(GSDIR)/l703.a $(GSDIR)/l705.a \
    $(GSDIR)/l707.a $(GSDIR)/l715.a $(GSDIR)/l716.a \
    $(GDIR)/l801.a $(GSDIR)/l802.a $(GDIR)/l803.a \
    $(GSDIR)/l901.a $(GDIR)/l902.a $(GDIR)/l903.a $(GDIR)/l905.a \
    $(GSDIR)/l906.a $(GSDIR)/l913.a $(GSDIR)/l914.a $(GSDIR)/l918.a \
    $(GSDIR)/l1001.a $(GSDIR)/l1002.a \
    $(GDIR)/l1101.a $(GDIR)/l1102.a $(GSDIR)/l1110.a \
    $(GSDIR)/l1111.a $(GSDIR)/l9999.a \
    $(GSDIR)/archlib.a $(GSDIR)/mdarch.a $(GAULIB) \
    $(GSDIR)/archlib.a $(GSDIR)/mdarch.a $(GAULIB) $(LIBS) \
    dummy-links.a
rm -f ml0.* chain.* drum.* l1init.* argnames.*

#
# A linked-together version which just does AM1.
#
OPOBJ = chain.o chainx.o drum.o l1init.o argnames.o ml0.o frstl1.o
OPLINKS = l1.a l101.a l103.a l202.a l301.a l401.a l402.a l601.a l716.a
l914.a l9999.a dummy-links.a

g98se: $(OPLINKS)
$(RUNFSP) -e ml0 $(BSDDIR)/main.F
$(RUNFSP) -e argnames -e chain -e chainx -e drum $(BSDDIR)/mdutil.F
$(RUNFSP) -e l1init -e frstl1 $(BSDDIR)/mdl1.F
make $(MAKELOC) OPTFLAG='$(OPTFLAG)' DEBUGP='-DONEPROG' $(OPOBJ)
ar xv l402.a bd0402.o
$(RUNF77) $(FFLAGS) -o g98se $(OPOBJ) $(EXTRAS) $(EXTOBJ) bd0402.o
$(OPLINKS) \
    archlib.a mdarch.a $(GAULIBA) archlib.a mdarch.a $(GAULIBA) $(ESSLLIB)
dummy-narch.o
rm -f $(OPOBJ) $(OPOBJ:.o=.F) bd0402.o

#
# Special commands for certain libraries:
#
archlib.a:
rm -f -r temp-archlib
mkdir temp-archlib
(cd temp-archlib ; $(RUNFSP) ../archlib.F ; cp ../*.inc . ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[a-c]*.F ; \
  $(RUNAR) rlv archlib.a [a-c]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[d-g]*.F ; \
  $(RUNAR) rlv archlib.a [d-f]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[h-l]*.F ; \
  $(RUNAR) rlv archlib.a [g-l]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[m-o]*.F ; \
  $(RUNAR) rlv archlib.a [m-o]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[p-q]*.F ; \
  $(RUNAR) rlv archlib.a [p-q]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[r-s]*.F ; \
  $(RUNAR) rlv archlib.a [r-s]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[t-z]*.F ; \
  $(RUNAR) rlv archlib.a [t-z]*.o ; \
  mv archlib.a ..)
rm -f -r temp-archlib
$(RUNRAN) archlib.a

dummy-links.a:
rm -f -r temp-dummy-links
mkdir temp-dummy-links
(cd temp-dummy-links ; $(RUNFSP) ../dummy-links.F ; \
  $(RUNFSP) -e ishdup -e sinfo ../l311.F ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB *.F
; \
  rm ishdup.o sinfo.o ; \
  $(RUNAR) rlv dummy-links.a *.o ; mv dummy-links.a ..)
rm -f -r temp-dummy-links
$(RUNRAN) dummy-links.a

dummy-archlib.a:
rm -f -r temp-dummy-archlib
mkdir temp-dummy-archlib
(cd temp-dummy-archlib ; $(RUNFSP) ../dummy-archlib.F ; \
$(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB *.F ;
\
$(RUNAR) rlv dummy-archlib.a *.o ; mv dummy-archlib.a ..)
rm -f -r temp-dummy-archlib
$(RUNRAN) dummy-archlib.a

l301.a:
rm -f -r temp-l301
mkdir temp-l301
(cd temp-l301 ; $(RUNFSP) ../l301.F  ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[a-l]*.F ; \
  $(RUNAR) rlv l301.a [a-l]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[m-o]*.F ; \
  $(RUNAR) rlv l301.a [m-o]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[p-z]*.F ; \
  $(RUNAR) rlv l301.a [p-z]*.o ; \
  mv l301.a ..)
rm -f -r temp-l301
$(RUNRAN) l301.a

l510.a:
rm -f -r temp-l510
mkdir temp-l510
(cd temp-l510 ; $(RUNFSP) ../l510.F  ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[a-g]*.F ; \
  $(RUNAR) rlv l510.a [a-g]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[h-m]*.F ; \
  $(RUNAR) rlv l510.a [h-m]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[n-r]*.F ; \
  $(RUNAR) rlv l510.a [n-r]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[s-z]*.F ; \
  $(RUNAR) rlv l510.a [s-z]*.o ; \
  mv l510.a ..)
rm -f -r temp-l510
$(RUNRAN) l510.a

l607.a:
rm -f -r temp-l607
mkdir temp-l607
(cd temp-l607 ; $(RUNFSP) ../l607.F  ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[a-e]*.F ; \
  $(RUNAR) rlv l607.a [a-e]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[f-k]*.F ; \
  $(RUNAR) rlv l607.a [f-k]*.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB
[l-z]*.F ; \
  $(RUNAR) rlv l607.a [l-z]*.o ; \
  mv l607.a ..)
rm -f -r temp-l607
$(RUNRAN) l607.a

mdarch.a: $(BSDDIR)/mdarch.F
rm -f -r temp-mdarch
mkdir temp-mdarch
(cd temp-mdarch ; $(RUNFSP) $(BSDDIR1)/mdarch.F ; cp ../*.inc . ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB *.F
; \
  $(RUNAR) rlv mdarch.a *.o ; mv mdarch.a ..)
rm -f -r temp-mdarch
$(RUNRAN) mdarch.a

newzmat.a: newzmat.F $(BSDDIR)/cmpdst.c
rm -f -r temp-newzmat
mkdir temp-newzmat
(cd temp-newzmat ; $(RUNFSP) ../newzmat.F ; \
  make $(MAKELOC1) OPTFLAG='$(OPTFLAG)' cmpdst.o ; \
  $(BSDDIR1)/updatelink1 $(BSDDIR1)/g98.make OPTFLAG='$(OPTFLAG)' DO-LIB *.F
; \
  $(RUNAR) rlv ../newzmat.a *.o)
rm -f -r temp-newzmat
$(RUNRAN) newzmat.a

# crendx:

crendxmfl.o: $(BSDDIR)/crendxmfl.F
$(RUNCPP) $(DIMENS) $(BSDDIR)/crendxmfl.F crendxmfl.f
$(RUNF77) $(FFLAGS) -c crendxmfl.f
rm -f crendxmfl.f crendxmfl.c

# newzmat:

cmpdst.o: $(BSDDIR1)/cmpdst.c
$(RUNCC) $(CFLAGS) -c $(BSDDIR1)/cmpdst.c

newzmat-bsd.o: $(BSDDIR)/newzmat-bsd.F
$(RUNCPP) $(DIMENS) $(BSDDIR)/newzmat-bsd.F newzmat-bsd.f
$(RUNF77) $(FFLAGS) -c newzmat-bsd.f
rm -f newzmat-bsd.f newzmat-bsd.c

# testrt:

testrt.o: $(BSDDIR)/testrt.F
$(RUNCPP) $(DIMENS) $(BSDDIR)/testrt.F testrt.f
$(RUNF77) $(FFLAGS) -c testrt.f
rm -f testrt.f testrt.c

#
# Exceptional compilation commands for utility and md routines.:
#

mdutil.o:
$(RUNCC) $(CFLAGS) -c $(BSDDIR)/mdutil.c

captlz.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FFLAGS) -fargument-alias -c $(@:o=f)
rm -f $(@:o=c) $(@:o=f)

fillel.o: fillel.F
cp fillel.F fillel.f
$(RUNF77) $(FFLAGS) -c fillel.f
rm -f fillel.f fillel.c

getrep.o putbas.o:
sed -e '1,9999s/????/####/' <$(@:o=F) | sed -e '1,9999s/??/##/' >$(@:o=FF)
$(RUNCPP) $(DIMENS) $(@:o=FF) $(@:o=ff)
sed -e '1,9999s/####/????/' <$(@:o=ff) | sed -e '1,9999s/##/??/' >$(@:o=f)
$(RUNF77) $(FFLAGS) -c $(@:o=f)
rm -f $(@:o=c) $(@:o=f) $(@:o=ff)

#
# How to built links which are not distributed to other sites:
#
localx:
(cd local ; make -f local.make ESSLLOC='$(ESSLLOC)' OPTFLAG='$(OPTFLAG)')

extrasx:
(cd extras ; make -f extras.make ESSLLOC='$(ESSLLOC)' OPTFLAG='$(OPTFLAG)')

rpac.make:
ln -s i386.make rpac.make

UTILS = cphfutil.F osutil.F putil.F utilam.F utilnz.F $(BSDDIR)/mdutil.F

util.prj: $(UTILS)
cat $(UTILS) >util.F
$(RUNCPP) $(DIMENS) util.F util.f
forchek $(FCHEKFLAGS) util.f
rm -f util.f util.F

aim.o golden.o svd.o svd1.o svdnao.o svdsol.o symaim.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FNOOPT64) -c $*.f
rm -f $(@:o=f) $(@:o=c)

aintgs.o anlyze.o bd0402.o bintgs.o dencor.o dmat2.o dntaim.o epseta.o
eroute.o \
  fact.o gcona.o glpint.o gparse.o intaim.o lmoanl.o prtloc.o proorb.o
putcpu.o rxirc.o ss.o \
  trspn2.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FNOOPT) -c $*.f
rm -f $(@:o=f) $(@:o=c)

as4.o cortbl.o ellaim.o erfcin.o icosa.o locmo.o maktrn.o putchr.o putcst.o
qcscal.o scat20.o symscl.o valtbl.o ztab.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FOPT1) -c $*.f
rm -f $(@:o=f) $(@:o=c)

cntr07.o cnvg.o dhc.o dsadsb.o dwful1.o fixraf.o fixreg.o mndomo.o pulay.o
qcde.o recur1.o recur2.o recurf.o smlujn.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FOPT2) -c $*.f
rm -f $(@:o=f) $(@:o=c)

calc0m.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FOPT2UN) -c $*.f
rm -f $(@:o=f) $(@:o=c)

omltlv.o:
$(RUNCPP) $(DIMENS) $(@:o=F) $(@:o=f)
$(RUNF77) $(FOPT2VC) -c $*.f
rm -f $(@:o=f) $(@:o=c)

MARCHOBJ = dummy.o
util.so: $(GAULIBA) dummy.o $(BLAS)
ld -shared -o util.so dummy.o --whole-archive util.a \
  --no-whole-archive $(BLAS)

#
# Here are rules specific to the Gaussian/Linda parallel version:
#
RUNFLC = flc
EXELS = l302.exel l502.exel l506.exel l508.exel l510.exel l602.exel
l701.exel l703.exel l906.exel \
        l913.exel l914.exel l1002.exel l1014.exel l1101.exel l1110.exel
l1112.exel
LOBJMD = chain.lo drum.lo
LOBJOS = lindev.lo prlin1.lo prlin3.lo prrfsu.lo prsmsu.lo
LOBJAM = caldsu.lo cdlin1.lo glinin.lo glinlo.lo glinre.lo
LOBJNZ = tplchk.lo
LOBJ906 = d2lin1.lo linde2.lo on4mp2.lo
OBJLS = $(LOBJMD) $(LOBJOS) $(LOBJAM) $(LOBJNZ) mdutil-linda.o
LFILES= $(EXELS) linda-dummy linda-exe

.F.lo:
$(RUNCPP) $(DIMENS) -DGAUSS_LINDA $*.F $*.fl
$(RUNFLC) -linda compile_args "$(FFLAGS)" -c $*.fl
rm -f $*.fl

.F.fl:
$(RUNCPP) $(DIMENS) -DGAUSS_LINDA $*.F $*.fl

linda: $(LFILES)

linda-dummy: linda-dummy.o
$(RUNCC) $(LFLAGS) $(PARSWITCH) -o linda-dummy linda-dummy.o \
  $(EXTOBJ) $(EXTRAS) $(GAULIB) $(ESSLLIB)
/usr/pgi/linux86/lib/libpgftnrtl.a \
  /usr/pgi/linux86/lib/libpgc.a -lm

linda-dummy.o: $(BSDDIR)/linda-dummy.c
$(RUNCC) $(CFLAGS) -c $(BSDDIR)/linda-dummy.c

linda-exe:
rm -fr linda-exe
mkdir linda-exe
(cd linda-exe ; $(BSDDIR1)/linda-ln .. linda-dummy $(EXELS))

.F.exel:
$(RUNFSP) -e m$* $(BSDDIR)/main.F
make $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.lo $(OBJLS)
$(RUNFLC) -linda link_args "$(LFLAGS) $(PARSWITCH) $(ESSLLIB)" \
  -o $*.exel m$*.lo $(OBJLS) $(EXTOBJ) $*.a $(EXTRAS) $(GAULIB) \
  $(EXTRALIB)
rm -f m$*.*

l906.exel: l906.a $(LOBJ906)
$(RUNFSP) -e m$* $(BSDDIR)/main.F
make $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.lo $(OBJLS)
$(RUNFLC) -linda link_args "$(LFLAGS) $(ESSLLIB)" -o $*.exel m$*.lo \
  $(LOBJ906) $(OBJLS) $(EXTOBJ) $*.a $(EXTRAS) $(GAULIB)
rm -f m$*.*

l1014.exel: l1014.a l914.a l1112.a
$(RUNFSP) -e m$* $(BSDDIR)/main.F
make $(MAKELOC) OPTFLAG='$(OPTFLAG)' $(EXTRAS) $*.a m$*.lo $(OBJLS)
$(RUNFLC) -linda link_args "$(LFLAGS) $(ESSLLIB)" -o $*.exel m$*.lo \
  $(OBJLS) $(EXTOBJ) $*.a l1112.a l914.a $(EXTRAS) $(GAULIB)
rm -f m$*.*

$(LOBJ906): l906.F
$(RUNFSP) -e $(@:.lo=) l906.F
$(RUNCPP) $(DIMENS) -DGAUSS_LINDA $(@:.lo=.F) $(@:.lo=.fl)
$(RUNFLC) -linda compile_args "$(FFLAGS)" -c $(@:.lo=.fl)
rm -f $(@:.lo=.F) $(@:.lo=.fl)

$(LOBJAM): utilam.F
$(RUNFSP) -e $(@:.lo=) utilam.F
$(RUNCPP) $(DIMENS) -DGAUSS_LINDA $(@:.lo=.F) $(@:.lo=.fl)
$(RUNFLC) -linda compile_args "$(FFLAGS)" -c $(@:.lo=.fl)
rm -f $(@:.lo=.F) $(@:.lo=.fl)

$(LOBJNZ): utilnz.F
$(RUNFSP) -e $(@:.lo=) utilnz.F
$(RUNCPP) $(IBMDEF) -DGAUSS_LINDA $(@:.lo=.F) $(@:.lo=.fl)
$(RUNFLC) -linda compile_args "$(FFLAGS)" -c $(@:.lo=.fl)
rm -f $(@:.lo=.F) $(@:.lo=.fl)

$(LOBJMD): bsd/mdutil.F
$(RUNFSP) -e $(@:.lo=) bsd/mdutil.F
$(RUNCPP) $(DIMENS) -DGAUSS_LINDA $(@:.lo=.F) $(@:.lo=.fl)
$(RUNFLC) -linda compile_args "$(FFLAGS)" -c $(@:.lo=.fl)
rm -f $(@:.lo=.F) $(@:.lo=.fl)

$(LOBJOS): osutil.F
$(RUNFSP) -e $(@:.lo=) osutil.F
$(RUNCPP) $(DIMENS) -DGAUSS_LINDA $(@:.lo=.F) $(@:.lo=.fl)
$(RUNFLC) -linda compile_args "$(FFLAGS)" -c $(@:.lo=.fl)
rm -f $(@:.lo=.F) $(@:.lo=.fl)

mdutil-linda.o: bsd/mdutil.c
ln -s bsd/mdutil.c $(@:.o=.c)
$(RUNCC) $(CFLAGS) -DGAUSS_LINDA -c mdutil-linda.c
rm -f $(@:.o=.c)

# Rule for making generic utilities:
GENERIC = x
$(GENERIC): $(GENERIC).o
$(RUNF77) $(FFLAGS) -o $(GENERIC) $(GENERIC).o $(EXTOBJ) $(EXTRAS) $(GAULIB)
$(ESSLLIB)