--- MITgcm/tools/genmake 2001/02/06 04:22:36 1.25 +++ MITgcm/tools/genmake 2001/07/13 15:16:48 1.38 @@ -1,6 +1,7 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.25 2001/02/06 04:22:36 cnh Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.38 2001/07/13 15:16:48 heimbach 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 grdchk ) set ENABLE = ( ) set MODS = ( ) @@ -88,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: @@ -112,15 +136,30 @@ 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 ROOTDIR = ( .. ) -else - if (! $?EXEDIR) set EXEDIR = ( . ) + 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 @@ -138,7 +177,14 @@ if (! -d $BUILDDIR) then echo Build directory $BUILDDIR not found.;exit 1 endif -if (! $?EXEDIR) set EXEDIR = ( $ROOTDIR/exe ) +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 @@ -148,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 @@ -184,12 +245,23 @@ 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. @@ -252,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 ' \ @@ -304,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 ini_cori.F') breaksw case SunOS+mpi: set LN = ( '/usr/bin/ln -s' ) @@ -316,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 ini_cori.F') breaksw case IRIX32: echo "Configuring for SGI ONYX running IRIX64" @@ -358,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' ) @@ -521,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 @@ -596,6 +669,7 @@ depend: @make links makedepend -o .f \$(INCLUDES) \$(SRCFILES) + links: \$(SRCFILES) small_f: \$(F77FILES) @@ -604,14 +678,19 @@ -rm -rf *.o *.f *.p ${RMFILES} Clean: @make clean - -find . -type l -exec rm {} \; + @make cleanlinks -rm -f Makefile.bak CLEAN: @make Clean - -find \$(ROOTDIR) -name "*.meta" -exec rm {} \; - -find \$(ROOTDIR) -name "*.data" -exec rm {} \; + -find \$(EXEDIR) -name "*.meta" -exec rm {} \; + -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) > \$@