--- MITgcm/tools/genmake 2001/09/10 15:58:26 1.52 +++ MITgcm/tools/genmake 2002/12/05 08:43:03 1.73 @@ -1,6 +1,6 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.52 2001/09/10 15:58:26 cnh Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.73 2002/12/05 08:43:03 dimitri Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -9,7 +9,7 @@ # modified by aja 01/00 # Default lists -set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk ) +set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk flt ptracers seaice therm_seaice bulk_force) set DEFINES = ( ) set ENABLE = ( ) set MODS = ( ) @@ -78,12 +78,20 @@ echo "-enable overrides -disable, ie. a package listed in both is enabled" exit breaksw - case -ieee: - set IEEE - breaksw case -enable=*: set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `) breaksw + case -cpp: + case -cpp=: + echo "To define CPP macros use -cpp=arg" + exit + breaksw + case -cpp=*: + set DEFINES = ( $DEFINES `echo $arg | sed 's/-cpp=//' | sed 's/,/ /g' `) + breaksw + case -ieee: + set IEEE + breaksw case -mpi: echo "Enabling MPI options" set USEMPI @@ -92,6 +100,18 @@ set include_jam_libs echo "Including paths to JAM libraries" breaksw + case -fc: + case -fc=: + echo "To change the compiler (\$FC) you must specify one with -fc=" + echo "eg. -fc=f90 or -fc=g77" + exit + breaksw + case -fc*: + if ($?FC) then + echo Option -fc=... can only be specified once.; exit 1 + endif + set FC = ( `echo $arg | sed 's/-fc=//' `) + breaksw case -help: echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi] [-jam] [-disable=pkg1[,pkg2,...]] [-enable=pkg1[,pkg2,...]] [-mods=dir1[,dir2,...]] [-rootdir=dir]" cat << EOF @@ -133,6 +153,11 @@ # If platform wasn't specified then determine platform type of the host if (! $?platform) then set platform = (`uname`) +# This let's us distinguish between different Linux platforms + if ($platform == Linux) then + set machine = (`uname -m`) + set platform = ($platform'-'$machine) + endif endif # If name of makefile wasn't specified then use default "Makefile" if (! $?mfile) set mfile = ( Makefile ) @@ -222,7 +247,7 @@ end if (! $?PACKAGES) then set PACKAGES=() - foreach pkg (`cd $ROOTDIR/pkg; find . -type d | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`) + foreach pkg (`cd $ROOTDIR/pkg; find . -type d -print | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`) if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg) end endif @@ -252,6 +277,12 @@ echo Adding pkg dir: $adr set SOURCEDIRS = ($SOURCEDIRS $adr) set INCLUDEDIRS = ($INCLUDEDIRS $adr) + switch ($dr) + case ptracers: + set DEFINES = ($DEFINES '-DALLOW_PTRACERS'); breaksw + default: + breaksw + endsw else echo " *" Package \"$dr\" NOT enabled. switch ($dr) @@ -259,6 +290,10 @@ set DEFINES = ($DEFINES '-DDISABLE_MOM_FLUXFORM'); breaksw case mom_vecinv: set DEFINES = ($DEFINES '-DDISABLE_MOM_VECINV'); breaksw + case generic_advdiff: + set DEFINES = ($DEFINES '-DDISABLE_GENERIC_ADVDIFF'); breaksw + case debug: + set DEFINES = ($DEFINES '-DDISABLE_DEBUGMODE'); breaksw default: breaksw endsw @@ -276,14 +311,50 @@ set INCLUDEDIRS = ($INCLUDEDIRS $idr) end +# Find possible compilers +if ($?FC) then + echo "$FC was specified as the compiler" +else + echo " " + switch ($platform) + case Linux*: + set likelysuspects=(g77 ifc pgf77 f77 f90 f95) + breaksw + default: + set likelysuspects=(f77) + breaksw + endsw + foreach fc ($likelysuspects) + set foundfc=`which $fc |& cat - ` + if (-x $foundfc[1]) then + if ($?possiblefc) then + set possiblefc=($possiblefc $fc) + else + set possiblefc=$fc + endif + endif + end + if ($?possiblefc) then + set FC=$possiblefc[1] + echo Found these compilers: $possiblefc. Using \"$FC\" as the compiler + else + echo "No compiler found\!" + echo I tried looking for \"$likelysuspects\" in your \$PATH but found none + echo I will continue anyway and see what happens. + set FC = ( 'f77' ) +# exit 13 + endif +endif + # This is the generic configuration. # Platform specific options are chosen below set LN = ( 'ln -s' ) set CPP = ( '/lib/cpp -P' ) -set S64 = ( '\$(TOOLSDIR)/set64bitConst.sh' ) +set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' ) set KPP = ( ) -set FC = ( 'f77' ) -set LINK = ( 'f77' ) +#set FC = ( 'f77' ) +set LINK = $FC +set MAKEDEPEND = ( 'makedepend' ) set INCLUDES = ( -I. ) set FFLAGS = ( ) set FOPTIM = ( ) @@ -340,9 +411,8 @@ set INCLUDES = ( '-I/usr/local/mpi/include' ) set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' ) set FOPTIM = ( '-O3' ) -# set NOOPTFLAGS = ( '-O0' ) -# set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ -# 'external_fields_load.F' ) + if ($?IEEE) set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -static' ) + if ($?IEEE) set FOPTIM = ( '-O0 -OPT:IEEE_arithmetic=1 -OPT:IEEE_NaN_inf=ON' ) set RMFILES = ( 'rii_files' ) breaksw case o2: @@ -368,11 +438,18 @@ set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set INCLUDES = ( '-I/usr/include' ) set FFLAGS = ( '-n32 -extend_source -bytereclen' ) - set FOPTIM = ( '-O2' ) - set NOOPTFILES = ( 'calc_mom_rhs.F' ) - set NOOPTFLAGS = ( '-O1' ) + set FOPTIM = ( '-O3 -OPT:Olimit=0:roundoff=3:div_split=ON:alias=typed' ) set LIBS = ( '-lmpi -lscs' ) breaksw + case o2k_noopt: + case o2k_noopt+mpi: + echo "Configuring for SGI Origin2000 running IRIX 6.5" + set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) + set INCLUDES = ( '-I/usr/include' ) + set FFLAGS = ( '-n32 -extend_source -bytereclen' ) + set FOPTIM = ( '-O0' ) + set LIBS = ( '-lmpi' ) + breaksw case onyx: case onyx+mpi: echo "Configuring for SGI ONYX running IRIX64" @@ -386,9 +463,9 @@ case SunOS: set LN = ( '/usr/bin/ln -s' ) set CPP = ( '/usr/ccs/lib/cpp -P' ) - set S64 = ( cat ) + set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend ) set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' ) - set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -r8 -i4 -fsimple=0' ) + set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' ) set FOPTIM = ( '-dalign -O3 -xarch=v9' ) set CFLAGS = ( '-dalign -O3 -xarch=v9' ) set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' ) @@ -397,11 +474,10 @@ case SunOS+mpi: set LN = ( '/usr/bin/ln -s' ) set CPP = ( '/usr/ccs/lib/cpp -P' ) - set S64 = ( cat ) set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' ) set INCLUDES = ( '-I/usr/local/mpi/include' ) set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \ - set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -r8 -i4 -fsimple=0' ) + set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' ) set FOPTIM = ( '-dalign -O3 -xarch=v9' ) set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' ) '-lsocket -lnsl' ) @@ -433,20 +509,22 @@ set NOOPTFILES = ( 'barrier.F different_multiple.F' \ 'external_fields_load.F' ) breaksw - case Linux+mpi: + case Linux-alpha+mpi: + echo "Configuring with MPI" set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) set INCLUDES = ( '-I/usr/local/include' ) - case Linux: + case Linux-alpha: + echo "Configuring for " $platform set LN = ( '/bin/ln -s' ) set CPP = ( '/lib/cpp -traditional -P' ) set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' ) set FC = ( 'g77' ) - set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' ) - if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' ) - set FOPTIM = ( '-O3 -malign-double -funroll-loops' ) + set FFLAGS = ( ' ' ) + if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' ) + set FOPTIM = ( '-ffast-math -fexpensive-optimizations -fomit-frame-pointer -O3' ) set LINK = ( 'g77' ) breaksw - case Linux+pgi+mpi: + case Linux*+pgi+mpi: if ($?include_jam_libs) then set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' ) set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' ) @@ -454,7 +532,8 @@ set INCLUDES = ( '-I/usr/local/include' ) set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) endif - case Linux+pgi: + case Linux*+pgi: + echo "Configuring for " $platform set LN = ( '/bin/ln -s' ) set CPP = ( '/lib/cpp -traditional -P' ) set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' ) @@ -463,8 +542,44 @@ set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' ) set LINK = ( 'pgf77' ) breaksw + case Linux*+mpi: + set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) + set INCLUDES = ( '-I/usr/local/include' ) + case Linux*: + echo "Configuring for " $platform + set LN = ( '/bin/ln -s' ) + set CPP = ( '/lib/cpp -traditional -P' ) + switch ($FC) + case g77: + set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' ) + set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' ) + if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' ) + set FOPTIM = ( '-O3 -malign-double -funroll-loops' ) + breaksw + case pgf77: + set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' ) + set FC = ( 'pgf77' ) + set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' ) + set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' ) + breaksw + case ifc: + set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' ) + set FFLAGS = ( '-132 -r8 -i4 -w95 -W0 -WB' ) + if ($?IEEE) set FFLAGS = ( $FFLAGS '-mp' ) + set FOPTIM = ( '-O3 -align' ) +#P3 set FOPTIM = ( $FOPTIM '-tpp6 -xWKM' ) +#P4 set FOPTIM = ( $FOPTIM '-tpp7 -xWKM' ) + set LIBS = ( '-lPEPCF90' ) + breaksw + default: + echo Error: Linux compiler not recognized: \$FC=$FC + exit + breaksw + endsw + breaksw case T3E: case sn6312: + echo "Configuring for T3E" set CPP = ( '/opt/ctl/bin/cpp -P') set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' ) set FC = ( 'f90' ) @@ -473,6 +588,7 @@ breaksw case T90: case sn7113: + echo "Configuring for T90" set FC = ( 'f90' ) set LINK = ( 'f90' ) set LN = ( '/bin/ln -s' ) @@ -495,6 +611,41 @@ set NOOPTFLAGS = ( '-O0' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') breaksw + case cg01+pgi: + set LN = ( '/bin/ln -s' ) + set CPP = ( '/lib/cpp -traditional -P' ) + set INCLUDES = ( '-I/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/include' ) + set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' ) + set FC = ( '/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif77' ) + set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' ) +# set LIBS = ( '-L/home/cnh/src/gm-1.4/libgm') + set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' ) + set LINK = ( '/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif77' ) + breaksw + case SP3: +# originally from A. Biastoch, SIO. + echo "Configuring for IBM SP POWER3" + set SOURCEDIRS = ( ./ $SOURCEDIRS ) + set LN = ( 'ln -s' ) + set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' ) + set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' ) +# set CPP = ( '/lib/cpp' ) + set FC = ( 'mpxlf95' ) + set LINK = ( 'mpxlf95' ) + set FLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \ + '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' ) + set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \ + '-bmaxdata:0x80000000 ' ) + set LDFLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \ + '-bmaxdata:0x80000000' ) + set LIBS = ( ' -L/usr/local/apps/mass -lmass' ) +# set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' ) +# set FOPTIM = ( '-O3' ) +# set NOOPTFLAGS = ( '-O0' ) +# set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ +# 'external_fields_load.F' ) + set RMFILES = ( 'rii_files' ) + breaksw default: echo "Error: platform not recognized: uname -p = " $platform$USEMPI exit @@ -586,6 +737,7 @@ # CPP : C-preprocessor command # INCLUDES : Directories searched for header files # DEFINES : Macro definitions for CPP +# MAKEDEPEND : Dependency generator # KPP : Special preprocessor command (specific to platform) # KFLAGS : Flags for KPP # FC : Fortran compiler command @@ -644,6 +796,8 @@ LN = ${LN} # C preprocessor CPP = cat \$< | ${S64} | ${CPP} +# Dependency generator +MAKEDEPEND = ${MAKEDEPEND} # Special preprocessor (KAP on DECs, FPP on Crays) KPP = ${KPP} # Fortran compiler @@ -689,7 +843,7 @@ \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) depend: @make links - makedepend -o .f \$(INCLUDES) \$(SRCFILES) + \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) @@ -700,7 +854,7 @@ @\$(EXECUTABLE) > \$@ clean: - -rm -rf *.o *.f *.p ${RMFILES} + -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl} Clean: @make clean @make cleanlinks