--- MITgcm/tools/genmake 2001/02/07 16:49:20 1.28 +++ MITgcm/tools/genmake 2001/06/04 19:47:32 1.36 @@ -1,6 +1,7 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.28 2001/02/07 16:49:20 adcroft Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.36 2001/06/04 19:47:32 adcroft Exp $ +# $Name: $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -8,7 +9,7 @@ # modified by aja 01/00 # Default lists -set DISABLE = ( aim ) +set DISABLE = ( aim autodiff cal cost ctrl ecco exf ) set ENABLE = ( ) set MODS = ( ) @@ -50,7 +51,6 @@ echo "***" Command line \"$arg\" will override this. endif set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `) - if (! $?EXEDIR) set EXEDIR = ( . ) breaksw case -mods: case -mods=: @@ -89,7 +89,30 @@ echo "Including paths to JAM libraries" breaksw case -help: - echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi]" + echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi] [-jam] [-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: @@ -113,21 +136,14 @@ 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) then - if (-d ../exe & -d ../model & -d ../eesupp & -d ../pkg) then - set ROOTDIR = ( .. ) - if (! $?EXEDIR) set EXEDIR = ( ../exe ) - else if (-d ../model & -d ../eesupp & -d ../pkg) then - echo In bin with no exe - if (! $?EXEDIR) set EXEDIR = ( . ) - endif + if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then + set ROOTDIR = ( .. ) endif endif # Scan for logical ROOTDIR @@ -135,7 +151,6 @@ foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..) if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then set ROOTDIR = $dr - if (! $?EXEDIR) set EXEDIR = ( . ) echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\" break endif @@ -162,6 +177,14 @@ 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 @@ -171,33 +194,48 @@ 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 directory $adr -end -if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model diags) -foreach dr ($STANDARDDIRS) - set adr=$ROOTDIR/$dr/src - if (! -d $adr) then - echo Source directory $adr not found.; exit 1 - endif - echo Adding source directory $adr - set SOURCEDIRS = ($SOURCEDIRS $adr) - set idr = `echo $adr | sed 's/src/inc/'` - set INCLUDEDIRS = ($INCLUDEDIRS $idr) + echo Adding mods dir: $adr end if (! $?PACKAGES) then - set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`) + set PACKAGES=() + foreach pkg (`cd $ROOTDIR/pkg; find . -type d | 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 @@ -207,13 +245,24 @@ if (! -d $adr) then echo Source directory $adr not found.; exit 1 endif - echo Adding package directory $adr + echo Adding pkg dir: $adr set SOURCEDIRS = ($SOURCEDIRS $adr) set INCLUDEDIRS = ($INCLUDEDIRS $adr) else - echo "*" Package \"$dr\" has not been enabled. + echo " *" Package \"$dr\" NOT enabled. 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 # This is the generic configuration. # Platform specific options are chosen below @@ -275,7 +324,7 @@ 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' ) + set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' ) set FOPTIM = ( '-O3' ) # set NOOPTFLAGS = ( '-O0' ) # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ @@ -327,7 +376,7 @@ set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar') set FOPTIM = ( '-fast -O3' ) set NOOPTFLAGS = ( '-O0' ) - set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F') + set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F ini_spherical_polar_grid.F') breaksw case SunOS+mpi: set LN = ( '/usr/bin/ln -s' ) @@ -339,7 +388,7 @@ set NOOPTFLAGS = ( '-O0' ) set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \ '-lsocket -lnsl' ) - set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F') + set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F ini_spherical_polar_grid.F') breaksw case IRIX32: echo "Configuring for SGI ONYX running IRIX64" @@ -381,8 +430,8 @@ breaksw case Linux+pgi+mpi: if ($?include_jam_libs) then - set INCLUDES = ( '-I/usr/local//mpich-cnh-install/include' ) - set LIBS = ( '-L/usr/local/mpich-cnh-install/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) + 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' ) @@ -544,6 +593,7 @@ # extra stuff for Hyades ............................................ HYADES_DIR = /u/u0/cnh/jam-lib/software HYADES_DIR = /u/u0/cnh/jam-lib-twoproc +HYADES_DIR = /usr/local/jamlib/current/dual_proc WORK_DIR = \$(HYADES_DIR) DEPOSIT_DIR = linux_bin @@ -619,6 +669,7 @@ depend: @make links makedepend -o .f \$(INCLUDES) \$(SRCFILES) + links: \$(SRCFILES) small_f: \$(F77FILES) @@ -627,7 +678,7 @@ -rm -rf *.o *.f *.p ${RMFILES} Clean: @make clean - -find . -type l -exec rm {} \; + @make cleanlinks -rm -f Makefile.bak CLEAN: @make Clean @@ -635,6 +686,11 @@ -find \$(EXEDIR) -name "*.data" -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) > \$@