--- MITgcm/tools/genmake 2001/11/26 16:04:00 1.58 +++ MITgcm/tools/genmake 2002/10/29 19:38:07 1.67 @@ -1,6 +1,6 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.58 2001/11/26 16:04:00 adcroft Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.67 2002/10/29 19:38:07 adcroft 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 flt ) +set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk flt ptracers ) 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 @@ -227,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 @@ -257,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) @@ -266,6 +292,8 @@ 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 @@ -283,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=(ifc g77 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 KPP = ( ) -set FC = ( 'f77' ) -set LINK = ( 'f77' ) +#set FC = ( 'f77' ) +set LINK = $FC +set MAKEDEPEND = ( 'makedepend' ) set INCLUDES = ( -I. ) set FFLAGS = ( ) set FOPTIM = ( ) @@ -393,9 +457,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' ) @@ -404,11 +468,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' ) @@ -480,12 +543,33 @@ 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 LINK = ( 'g77' ) + 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: @@ -537,7 +621,7 @@ '-bmaxdata:0x80000000 ' ) set LDFLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \ '-bmaxdata:0x80000000' ) - set LIBS = ( ' timer_stats.o -L/usr/local/apps/mass -lmass' ) + set LIBS = ( ' -L/usr/local/apps/mass -lmass' ) # set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' ) # set FOPTIM = ( '-O3' ) # set NOOPTFLAGS = ( '-O0' ) @@ -636,6 +720,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 @@ -694,6 +779,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 @@ -739,7 +826,7 @@ \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) depend: @make links - makedepend -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) + \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) @@ -750,7 +837,7 @@ @\$(EXECUTABLE) > \$@ clean: - -rm -rf *.o *.f *.p ${RMFILES} + -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl} Clean: @make clean @make cleanlinks