#!/bin/csh -f # # $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.89 2003/10/23 04:41:41 edhill dead $ # $Name: $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 # adapted by aja 06/98 # modified by aja 01/00 # Default lists if (! $?DISABLE) set DISABLE = ( aim aim_v23 autodiff cal cost ctrl ecco exf grdchk flt land ptracers seaice therm_seaice bulk_force dic gchem cfc ) if (! $?ENABLE) set ENABLE = ( ) if (! $?DEFINES) set DEFINES = ( ) if (! $?MODS) set MODS = ( ) # Grab variables/lists from .genmakerc if (-r .genmakerc) source .genmakerc # Process command-line arguments set allargs=( $argv ) while ($#allargs) set arg = $allargs[1] switch ($arg) case -makefile: set mfile = ( Makefile ) breaksw case -makefile=*: set mfile = ( `echo $arg | sed 's/-makefile=//' `) breaksw case -platform: case -platform=: echo "To change platform you must specify one with -platform=" echo "eg. -platform=sparc or -platform=mips" exit breaksw case -platform*: if ($?platform) then echo Option -platform=dir can only be specified once.; exit 1 endif set platform = ( `echo $arg | sed 's/-platform=//' `) breaksw case -rootdir: case -rootdir=: echo "To specify root directory you must specify one with -rootdir=dir" echo "with NO space eg. -rootdir=../../.. or -rootdir=/usr/people/joe/src" exit breaksw case -rootdir=*: if ($?ROOTDIR) then echo "***" Warning: variable \$ROOTDIR is already set to $ROOTDIR echo "***" Command line \"$arg\" will override this. endif set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `) breaksw case -mods: case -mods=: echo "To specify an additional source directory you must specify one with -mods=dir" echo "with NO space eg. -mods=../code or -mods=/usr/people/joe/src" exit breaksw case -mods=*: set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `) breaksw case -disable: case -disable=: echo "To disable packages from compilation use -disable=pkg1,pkg2" echo "with NO spaces eg. -disable=kpp,gmredi or -disable=all (to enable all packages)" exit breaksw case -disable=*: set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `) breaksw case -enable: case -enable=: echo "To enable packages from compilation use -enable=pkg1,pkg2" echo "with NO spaces eg. -enable=aim or -enable=all (to enable all packages)" echo "-enable overrides -disable, ie. a package listed in both is enabled" exit 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 breaksw case -jam: set include_jam_libs echo "Including paths to JAM libraries" breaksw case -arpack: echo "Enabling ARPACK libraries" set USEARPACK 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] [-arpack] [-disable=pkg1[,pkg2,...]] [-enable=pkg1[,pkg2,...]] [-mods=dir1[,dir2,...]] [-rootdir=dir]" cat << EOF $0 is used to generate the Makefile in the current directory. Typical invocations are: o from "bin": ../tools/genmake o from "verification/expt/code": ../../../tools/genmake o from "verification/expt/input": ../../../tools/genmake -mods=../code o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm or ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods Packages (collected modules of code) can be disabled to avoid unnecessary compilation of unused code. For instance if you know you will not use GM/Redi, KPP and OBCS and they are appropriate turned-off in the configuration: .../tools/genmake -disable=gmredi,kpp,obcs If you add some source files you can re-call the previous instance of genmake with "make makefile". genmake also reads the file .genmakerc which can be used to configure options (primarily the command-line options above) for particular experiments. EOF exit breaksw default: echo "Unknown command-line option: " $arg echo $0 "-help to show usage" exit breaksw endsw shift allargs end # Default actions/options # 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 ) set mach = ( `uname -a` ) echo Operating system: $mach # Directories for source, includes, binaries and executables # # If -rootdir wasn't specified then assume script is being run from bin # but if it was supplied then we should place the executable in the build dir if (! $?ROOTDIR) then set pwd=`pwd` if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then set ROOTDIR = ( .. ) endif endif # Scan for logical ROOTDIR if (! $?ROOTDIR) then foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..) if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then set ROOTDIR = $dr echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\" break endif end endif if (! $?ROOTDIR) then echo Root directory was not specified and could not be determined. echo Specify the root location of the model source with -rootdir=dir exit 1 endif if (! -d $ROOTDIR) then echo Root directory $ROOTDIR not found.;exit 1 endif # If -mods wasn't specified then we will assume that we can find all the # source code in the standard directories if (! $?MODS) then set SOURCEDIRS = ( ) set INCLUDEDIRS = ( ) else set SOURCEDIRS = ( $MODS ) set INCLUDEDIRS = ( $MODS ) endif if (! $?BUILDDIR) set BUILDDIR = ( . ) if (! -d $BUILDDIR) then echo Build directory $BUILDDIR not found.;exit 1 endif if (! $?EXEDIR) then set pwd=`pwd` if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then set EXEDIR = ( ../exe ) else set EXEDIR = ( . ) endif endif if (! -d $EXEDIR) then echo Executable directory $EXEDIR not found.;exit 1 endif if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools ) if (! -d $TOOLSDIR) then echo Tools directory $TOOLSDIR not found.;exit 1 endif if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv ) # We have a special set of source files in eesupp/src which # are generated from some template source files. We'll make them # first so the appear as regular source code if (-r $ROOTDIR/eesupp/src/Makefile) then echo Making source files in eesupp from templates... (cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs if ($status == 0) then rm -f make_eesupp.errs else cat make_eesupp.errs exit 2 endif endif # Now scan the standard source code tree foreach dr ($SOURCEDIRS) set adr=$dr if (! -d $adr) then echo mods directory $adr not found.; exit 1 endif echo Adding mods dir: $adr end if (! $?PACKAGES) then set PACKAGES=() 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 foreach dr ($PACKAGES) set enable foreach p ($DISABLE) if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then echo Specified package \"$p\" does not exist. exit 1 endif if ($dr == $p) unset enable if ($p == 'all') unset enable # The following allows entire trees to be disabled if ($dr:h == $p) unset enable if ($dr:h:h == $p) unset enable if ($dr:h:h:h == $p) unset enable if ($dr:h:h:h:h == $p) unset enable end foreach p ($ENABLE) if ($dr == $p) set enable end if ($?enable) then set adr=$ROOTDIR/pkg/$dr if (! -d $adr) then echo Source directory $adr not found.; exit 1 endif 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) case mom_fluxform: 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 endif end if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model) foreach dr ($STANDARDDIRS) set adr=$ROOTDIR/$dr/src if (! -d $adr) then echo Source directory $adr not found.; exit 1 endif echo Adding src dir: $adr set SOURCEDIRS = ($SOURCEDIRS $adr) set idr = `echo $adr | sed 's/src/inc/'` 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 KPP = ( ) #set FC = ( 'f77' ) set LINK = $FC set MAKEDEPEND = ( 'makedepend' ) set INCLUDES = ( -I. ) set FFLAGS = ( ) set FOPTIM = ( ) set CFLAGS = ( ) set KFLAGS1 = ( ) set KFLAGS2 = ( ) set LIBS = ( ) set KPPFILES = ( ) if (! $?NOOPTFILES ) set NOOPTFILES = ( ) if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) set RMFILES = ( ) # We often want to use different compile/link options is using MPI if ($?USEMPI) then set USEMPI = ( '+mpi' ) set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' ) else set USEMPI # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' ) endif if ($?USEARPACK) then set USEARPACK = ( '+arpack' ) set LIBS = ( '-L/usr/lib -larpack -llapack' ) else set USEARPACK endif # Platform specific options switch ($platform$USEMPI$USEARPACK) case OSF1+mpi: #ph: e.g. halem.gsfc.nasa.gov echo "Configuring for DEC Alpha with MPI" set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) #ph: -lkmp_osfp10 not needed on some/many platforms case OSF1: echo "Configuring for DEC Alpha" set CPP = ( '/usr/bin/cpp -P' ) set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' ) set MAKEDEPEND = ( mkdep -f depend.out ) #ph: makedepend not available on some/many DEC Alpha's; use mkdep instead set KPP = ( ) set KPPFILES = ( ) set KFLAGS1 = ( ) set FC = ( 'f77' ) set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' ) set FOPTIM = ( '-O5 -fast -tune host -inline all' ) #ph: -O5 probably too aggressive in conjunction with adjoint code set NOOPTFLAGS = ( '-O0' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') set RMFILES = ( '*.p.out' ) breaksw case IRIX64+mpi: echo "Configuring for SGI Mips with MPI" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set INCLUDES = ( '-I/usr/local/mpi/include' ) set FC = ( 'mpif77' ) set LINK = ( 'mpif77' ) set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) set FOPTIM = ( '-O3' ) set RMFILES = ( 'rii_files' ) breaksw case IRIX64: echo "Configuring for SGI Mips" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set INCLUDES = ( '-I/usr/local/mpi/include' ) set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' ) set FOPTIM = ( '-O3' ) 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: case IRIX: echo "Configuring for SGI O2 running IRIX 6.5" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) set FOPTIM = ( '-O2' ) set NOOPTFLAGS = ( '-O0' ) breaksw case o2+mpi: case IRIX+mpi: echo "Configuring for SGI O2 running IRIX 6.5 with MPI" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) set FOPTIM = ( '-O2' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' ) set NOOPTFLAGS = ( '-O0' ) set LIBS = ( '-lmpi' ) breaksw case o2k+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 = ( '-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 ames_dbg+mpi: echo "Configuring for SGI Origin2000 running IRIX 6.5" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set INCLUDES = ( '-I/usr/include -I/opt/mpt/1.6.1.beta/usr/include' ) set FFLAGS = ( '-n32 -extend_source -bytereclen' ) set LIBS = ( '-lmpi -lscs' ) set FC = ( 'f90' ) set LINK = ( 'f90' ) breaksw case ames_opt+mpi: echo "Configuring for SGI Origin2000 running IRIX 6.5" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set INCLUDES = ( '-I/usr/include -I/opt/mpt/1.6.1.beta/usr/include' ) set FFLAGS = ( '-n32 -extend_source -bytereclen' ) set FOPTIM = ( '-O3 -OPT:Olimit=0:roundoff=3:div_split=ON:alias=typed' ) set LIBS = ( '-lmpi -lscs' ) set FC = ( 'f90' ) set LINK = ( 'f90' ) breaksw case onyx: case onyx+mpi: echo "Configuring for SGI ONYX running IRIX64" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' ) set FOPTIM = ( '-O2' ) set NOOPTFLAGS = ( '-O0' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' ) set LIBS = ( '-lmpi' ) breaksw case SunOS: set LN = ( '/usr/bin/ln -s' ) set CPP = ( '/usr/ccs/lib/cpp -P' ) set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend ) set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' ) 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' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F ini_spherical_polar_grid.F ini_cori.F mon_printstats_rl.F mon_printstats_rs.F aim_aim2dyn.F aim_dyn2aim.F aim_aim2dyn_exchanges.F aim_external_fields_load.F aim_calc_diags.F aim_external_forcing.F aim_do_atmos_physics.F aim_write_diags.F aim_do_inphys.F ') breaksw case SunOS+mpi: set LN = ( '/usr/bin/ln -s' ) set CPP = ( '/usr/ccs/lib/cpp -P' ) 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 -xtypemap=real:64,double:64,integer:32 -fsimple=0' ) set FOPTIM = ( '-dalign -O3 -xarch=v9' ) set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' ) '-lsocket -lnsl' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F ini_spherical_polar_grid.F ini_cori.F mon_printstats_rl.F mon_printstats_rs.F') breaksw case SunFire+mpi: set FC = ( 'mpf77' ) set LINK = ( 'mpf77' ) set LN = ( '/usr/bin/ln -s' ) set CPP = ( '/usr/ccs/lib/cpp -P' ) set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend ) set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' ) set INCLUDES = ( '-I/opt/SUNWhpc/include' ) set LIBS = ( '-lmpi -lthread -lsocket -lnsl' ) set FFLAGS = ( '-e -u -noautopar ' \ '-xtypemap=real:64,double:64,integer:32 -fsimple=0' ) set FOPTIM = ( '-dalign -O4 -xarch=native' ) set CFLAGS = ( '-dalign -xO4 -xarch=native' ) set NOOPTFLAGS = ( '-dalign -O0 -xarch=native' ) breaksw case IRIX32: echo "Configuring for SGI ONYX running IRIX64" set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set INCLUDES = ( '-I/usr/include' ) set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' ) set FOPTIM = ( '-O2' ) set NOOPTFLAGS = ( '-O0' ) set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ 'external_fields_load.F' ) set LIBS = ( '-lmpi' ) breaksw case HP-UX+mpi: set FC = ( 'mpif77' ) set LINK = ( 'mpif77' ) set INCLUDES = ( '-I/opt/mpi/include' ) case HP-UX: echo "Configuring for HP Exemplar" set CPP = ( '/usr/ccs/lbin/cpp -P' ) set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' ) set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \ '+Okernel_threads' ) set FOPTIM = ( '+O2' ) set NOOPTFLAGS = ( '+O0' ) set NOOPTFILES = ( 'barrier.F different_multiple.F' \ 'external_fields_load.F' ) breaksw case Linux-ia64+mpi: echo "Configuring with MPI" case Linux-ia64: echo "Configuring for " $platform set LN = ( '/bin/ln -s' ) set CPP = ( '/lib/cpp -traditional -P' ) set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' ) set FC = ( 'efc' ) # set FFLAGS = ( '-WB -Vaxlib -u -w' ) # set FOPTIM = ( '-O2 -ftz' ) set FFLAGS = ( '-132 -i4 -w95 -W0 -WB' ) set FOPTIM = ( '-O3 -mp' ) set LINK = ( 'efc' ) # set LIBS = ( '-lmpi -lscs -lpthread' ) set LIBS = ( '-lPEPCF90 -lmpi' ) breaksw 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-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 = ( ' ' ) 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: 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' ) else set INCLUDES = ( '-I/usr/local/include' ) set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) endif case Linux*+pgi: echo "Configuring for " $platform set LN = ( '/bin/ln -s' ) set CPP = ( '/lib/cpp -traditional -P' ) 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' ) 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' ) set NOOPTFLAGS = ( '-O0' ) 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 = ( ${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' ) set LINK = ( 'f90' ) set FFLAGS = ( '-O 2,fusion' ) breaksw case T90: case sn7113: echo "Configuring for T90" set FC = ( 'f90' ) set LINK = ( 'f90' ) set LN = ( '/bin/ln -s' ) set CPP = ( '/opt/ctl/bin/cpp -N -P' ) set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' ) set FFLAGS = ( '-m3 -Rabc -N 132') set FOPTIM = ( '-O0' ) set NOOPTFLAGS = ( '-O0' ) set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') breaksw case SV1: case sn3002: set FC = ( 'f90' ) set LINK = ( 'f90' ) set LN = ( '/bin/ln -s' ) set CPP = ( '/opt/ctl/bin/cpp -N -P' ) set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' ) set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132') set FOPTIM = ( '-O0' ) 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. # e.g. horizon.npaci.edu 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 case SP4: #ph: e.g. bluesky.ucar.edu, marcellus.navo.hpc.mil echo "Configuring for IBM SP POWER4" 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=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \ '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' ) set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \ '-bmaxdata:0x80000000 ' ) set LDFLAGS = ( '-O3 -qarch=pwr4 -qtune=pwr4 -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 case aer-linux-cluster+mpi echo "Configuring for " $platform set LN = ( '/bin/ln -s' ) set CPP = ( '/lib/cpp -traditional -P' ) set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' ) set FC = ( '/opt/mpich/bin/mpif77' ) set LINK = ( '/opt/mpich/bin/mpif77' ) set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' ) set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' ) set LIBS = ( '-L/opt/mpich/lib/ -lfmpich -lmpich' ) set INCLUDES = ( '-I/opt/mpich/include' ) breaksw case gfdl-sgi-o3k echo "Configuring for " $platform set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) set FFLAGS = ( 'extend_source -mp -mpio -bytereclen -mips4 -r8 -static' ) set FOPTIM = ( '-O3' ) set LIBS = ( '-lmpi' ) set INCLUDES = ( '-I/opt/mpt/1510/usr/include' ) breaksw default: echo "Error: platform not recognized: uname -p = " $platform$USEMPI exit breaksw default: echo "Error: platform not recognized: uname -p = " $platform$USEMPI exit breaksw endsw ############################################################################### ## ## ## Everything below here should not need to be changed. Platform specific ## ## changes and code specific changes should be configured above this line. ## ## ## ############################################################################### # Convert lists of directories into command-line options foreach inc ($INCLUDEDIRS) set INCLUDES = ($INCLUDES -I$inc) end # Search for source code rm -rf .links.tmp;mkdir .links.tmp echo "# This section creates symbolic links" > srclinks.tmp echo "" >> srclinks.tmp echo -n 'SRCFILES = ' > srclist.inc echo -n 'CSRCFILES = ' > csrclist.inc echo -n 'HEADERFILES = ' > hlist.inc foreach dr ($SOURCEDIRS $INCLUDEDIRS .) set deplist=( ) foreach srcfile (`cd $dr; ls *.[hcF]`) if (! -r .links.tmp/$srcfile) then if (-f $dr/$srcfile) then switch ($srcfile:e) case F: touch .links.tmp/$srcfile set deplist=($deplist $srcfile) echo ' \' >> srclist.inc echo -n " " $srcfile >> srclist.inc breaksw case c: touch .links.tmp/$srcfile set deplist=($deplist $srcfile) echo ' \' >> csrclist.inc echo -n " " $srcfile >> csrclist.inc breaksw case h: touch .links.tmp/$srcfile set deplist=($deplist $srcfile) echo ' \' >> hlist.inc echo -n " " $srcfile >> hlist.inc breaksw endsw endif endif end if ($#deplist != 0) then echo "# These files are linked from $dr" >> srclinks.tmp echo $deplist':' >> srclinks.tmp echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp endif end rm -rf .links.tmp echo "" >> srclist.inc echo "" >> csrclist.inc echo "" >> hlist.inc set THISHOSTNAME = ( `hostname` ) set THISCWD = ( `pwd` ) set THISDATE = ( `date` ) if (-r $mfile) mv -f $mfile $mfile.bak ########################################### ## This is the template for the makefile ## ########################################### echo Creating makefile: $mfile echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile} echo "# This makefile was generated automatically on" >> ${mfile} echo "# $THISDATE" >> ${mfile} echo "# by the command:" >> ${mfile} echo "# ${0} $argv" >> ${mfile} echo "# executed by:" >> ${mfile} echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile} cat >> ${mfile} <> ${mfile} <> ${mfile} <> ${mfile} cat csrclist.inc >> ${mfile} cat hlist.inc >> ${mfile} echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile} echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile} rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp cat >> ${mfile} < \$@ clean: -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl} Clean: @make clean @make cleanlinks -rm -f Makefile.bak CLEAN: @make Clean -find \$(EXEDIR) -name "*.meta" -exec rm {} \; -find \$(EXEDIR) -name "*.data" -exec rm {} \; -find \$(EXEDIR) -name "fort.*" -exec rm {} \; -rm -f \$(EXECUTABLE) makefile: ${0} $argv cleanlinks: -find . -type l -exec rm {} \; # The normal chain of rules is ( .F - .f - .o ) .F.f: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ .f.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< .c.o: \$(CC) \$(CFLAGS) -c \$< # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain .F.p: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ .p.f: \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< EOF # Make list of "exceptions" that need ".p" files foreach sf ($KPPFILES) set fname=( ${sf:t} ) echo "${fname:r}.f: ${fname:r}.p" >> ${mfile} end foreach sf ($NOOPTFILES) set fname=( ${sf:t} ) echo "${fname:r}.o: ${fname:r}.f" >> ${mfile} echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile} end echo "" >> ${mfile} # Add rules for links cat srclinks.tmp >> ${mfile} rm -f srclinks.tmp echo "" >> ${mfile} echo "# DO NOT DELETE" >> ${mfile} exit