/[MITgcm]/MITgcm/tools/genmake
ViewVC logotype

Diff of /MITgcm/tools/genmake

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.22.2.3 by adcroft, Thu Jan 25 17:56:33 2001 UTC revision 1.38 by heimbach, Fri Jul 13 15:16:48 2001 UTC
# Line 1  Line 1 
1  #!/bin/csh -f  #!/bin/csh -f
2  #  #
3  # $Header$  # $Header$
4    # $Name$
5  #  #
6  # Makefile generator for MITgcm UV codes  # Makefile generator for MITgcm UV codes
7  #   created by cnh 03/98  #   created  by cnh 03/98
8  #   adapted by aja 06/98  #   adapted  by aja 06/98
9    #   modified by aja 01/00
10    
11    # Default lists
12    set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk )
13    set ENABLE  = ( )
14    set MODS  = ( )
15    
16    # Grab variables/lists from .genmakerc
17    if (-r .genmakerc) source .genmakerc
18    
19  # Process command-line arguments  # Process command-line arguments
20  set allargs=( $argv )  set allargs=( $argv )
# Line 24  while ($#allargs) Line 34  while ($#allargs)
34     exit     exit
35     breaksw     breaksw
36   case -platform*:   case -platform*:
37       if ($?platform) then
38        echo Option -platform=dir can only be specified once.; exit 1
39       endif
40     set platform = ( `echo $arg | sed 's/-platform=//' `)     set platform = ( `echo $arg | sed 's/-platform=//' `)
41     breaksw     breaksw
42     case -rootdir:
43     case -rootdir=:
44       echo "To specify root directory you must specify one with -rootdir=dir"
45       echo "with NO space eg. -rootdir=../../..  or  -rootdir=/usr/people/joe/src"
46       exit
47       breaksw
48   case -rootdir=*:   case -rootdir=*:
49       if ($?ROOTDIR) then
50        echo "***" Warning: variable \$ROOTDIR is already set to $ROOTDIR
51        echo "***" Command line \"$arg\" will override this.
52       endif
53     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)
54     breaksw     breaksw
55   case -mymods=*:   case -mods:
56     set MYMODS = ( `echo $arg | sed 's/-mymods=//' `)   case -mods=:
57       echo "To specify an additional source directory you must specify one with -mods=dir"
58       echo "with NO space eg. -mods=../code  or  -mods=/usr/people/joe/src"
59       exit
60       breaksw
61     case -mods=*:
62       set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `)
63       breaksw
64     case -disable:
65     case -disable=:
66       echo "To disable packages from compilation use -disable=pkg1,pkg2"
67       echo "with NO spaces eg. -disable=kpp,gmredi or -disable=all (to enable all packages)"
68       exit
69       breaksw
70     case -disable=*:
71       set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `)
72       breaksw
73     case -enable:
74     case -enable=:
75       echo "To enable packages from compilation use -enable=pkg1,pkg2"
76       echo "with NO spaces eg. -enable=aim or -enable=all (to enable all packages)"
77       echo "-enable overrides -disable, ie. a package listed in both is enabled"
78       exit
79       breaksw
80     case -enable=*:
81       set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `)
82     breaksw     breaksw
83   case -mpi:   case -mpi:
84     echo "Enabling MPI options"     echo "Enabling MPI options"
# Line 41  while ($#allargs) Line 89  while ($#allargs)
89     echo "Including paths to JAM libraries"     echo "Including paths to JAM libraries"
90     breaksw     breaksw
91   case -help:   case -help:
92     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]"
93    cat << EOF
94    
95    $0 is used to generate the Makefile in the current directory.
96    
97    Typical invocations are:
98     o from "bin":   ../tools/genmake
99     o from "verification/expt/code": ../../../tools/genmake
100     o from "verification/expt/input": ../../../tools/genmake -mods=../code
101     o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm
102       or  ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods
103    
104    Packages (collected modules of code)  can be disabled to avoid unnecessary
105    compilation of unused code. For instance if you know you will not
106    use GM/Redi, KPP and OBCS and they are appropriate turned-off in the
107    configuration:
108       .../tools/genmake -disable=gmredi,kpp,obcs
109    
110    If you add some source files you can re-call the previous instance of
111    genmake with "make makefile".
112    
113    genmake also reads the file .genmakerc which can be used to configure
114    options (primarily the command-line options above) for particular experiments.
115    EOF
116     exit     exit
117     breaksw     breaksw
118   default:   default:
# Line 56  end Line 127  end
127  # Default actions/options  # Default actions/options
128    
129  # If platform wasn't specified then determine platform type of the host  # If platform wasn't specified then determine platform type of the host
130  if ($?platform == 0) then  if (! $?platform) then
131   set platform = (`uname`)   set platform = (`uname`)
132  endif  endif
133  # If name of makefile wasn't specified then use default "Makefile"  # If name of makefile wasn't specified then use default "Makefile"
134  if ($?mfile == 0) set mfile = ( Makefile )  if (! $?mfile) set mfile = ( Makefile )
135    
136  set mach  = ( `uname -a` )  set mach  = ( `uname -a` )
137  echo Operating system: $mach  echo Operating system: $mach
138    
   
139  # Directories for source, includes, binaries and executables  # Directories for source, includes, binaries and executables
 # Note  
 # o If you prefer/need everything under a single directory  
 #   copy everything in ../eesupp/src, ../model/src,  
 #   ../eesupp/inc and ../model/inc into a directory and then  
 #   edit the paths below to ./  
140  #  #
141  # If -rootdir wasn't specified then assume script is being run from bin  # If -rootdir wasn't specified then assume script is being run from bin
142  # but if it was supplied then we should place the executable in the build dir  # but if it was supplied then we should place the executable in the build dir
143  if ($?ROOTDIR == 0) then  if (! $?ROOTDIR) then
144    set ROOTDIR = ( .. )    set pwd=`pwd`
145  else    if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then
146    if ($?EXEDIR == 0) set EXEDIR = ( ./ )      set ROOTDIR = ( .. )
147      endif
148    endif
149    # Scan for logical ROOTDIR
150    if (! $?ROOTDIR) then
151      foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
152        if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
153          set ROOTDIR = $dr
154          echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
155          break
156        endif
157      end
158    endif
159    if (! $?ROOTDIR) then
160      echo Root directory was not specified and could not be determined.
161      echo Specify the root location of the model source with -rootdir=dir
162      exit 1
163  endif  endif
164  if ($?MYMODS == 0) then  if (! -d $ROOTDIR) then
165   set SOURCEDIRS  = ( $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )    echo Root directory $ROOTDIR not found.;exit 1
166   set INCLUDEDIRS = ( ./ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )  endif
167    # If -mods wasn't specified then we will assume that we can find all the
168    # source code in the standard directories
169    if (! $?MODS) then
170     set SOURCEDIRS  = ( )
171     set INCLUDEDIRS = ( . )
172  else  else
173   set SOURCEDIRS  = ( $MYMODS/ $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )   set SOURCEDIRS  = ( $MODS )
174   set INCLUDEDIRS = ( ./ $MYMODS/ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )   set INCLUDEDIRS = ( . $MODS )
175    endif
176    if (! $?BUILDDIR) set BUILDDIR = ( . )
177    if (! -d $BUILDDIR) then
178      echo Build directory $BUILDDIR not found.;exit 1
179    endif
180    if (! $?EXEDIR) then
181      set pwd=`pwd`
182      if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then
183       set EXEDIR = ( ../exe )
184      else
185       set EXEDIR = ( . )
186      endif
187    endif
188    if (! -d $EXEDIR) then
189      echo Executable directory $EXEDIR not found.;exit 1
190    endif
191    if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools )
192    if (! -d $TOOLSDIR) then
193      echo Tools directory $TOOLSDIR not found.;exit 1
194  endif  endif
195  if ($?BUILDDIR == 0) set BUILDDIR = ( ./ )  if (! $?EXECUTABLE) set EXECUTABLE  = ( mitgcmuv )
196  if ($?EXEDIR == 0) set EXEDIR = ( $ROOTDIR/exe/ )  
197  if ($?EXECUTABLE == 0) set EXECUTABLE  = ( mitgcmuv )  # We have a special set of source files in eesupp/src which
198  if ($?TOOLSDIR == 0) set TOOLSDIR = ( $ROOTDIR/tools/ )  # are generated from some template source files. We'll make them
199    # first so the appear as regular source code
200    if (-r $ROOTDIR/eesupp/src/Makefile) then
201     echo Making source files in eesupp from templates...
202     (cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs
203     if ($status == 0) then
204       rm -f make_eesupp.errs
205     else
206       cat make_eesupp.errs
207       exit 2
208     endif
209    endif
210    
211    # Now scan the standard source code tree
212    foreach dr ($SOURCEDIRS)
213      set adr=$dr
214      if (! -d $adr) then
215        echo mods directory $adr not found.; exit 1
216      endif
217      echo Adding mods dir: $adr
218    end
219    if (! $?PACKAGES) then
220      set PACKAGES=()
221      foreach pkg (`cd $ROOTDIR/pkg; find . -type d | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`)
222       if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg)
223      end
224    endif
225    foreach dr ($PACKAGES)
226      set enable
227      foreach p ($DISABLE)
228       if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then
229         echo Specified package \"$p\" does not exist.
230         exit 1
231       endif
232       if ($dr == $p) unset enable
233       if ($p == 'all') unset enable
234    #  The following allows entire trees to be disabled
235       if ($dr:h == $p) unset enable
236       if ($dr:h:h == $p) unset enable
237       if ($dr:h:h:h == $p) unset enable
238       if ($dr:h:h:h:h == $p) unset enable
239      end
240      foreach p ($ENABLE)
241       if ($dr == $p) set enable
242      end
243      if ($?enable) then
244        set adr=$ROOTDIR/pkg/$dr
245        if (! -d $adr) then
246          echo Source directory $adr not found.; exit 1
247        endif
248        echo Adding pkg dir: $adr
249        set SOURCEDIRS = ($SOURCEDIRS $adr)
250        set INCLUDEDIRS = ($INCLUDEDIRS $adr)
251      else
252        echo "                                      *" Package \"$dr\" NOT enabled.
253      endif
254    end
255    if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model)
256    foreach dr ($STANDARDDIRS)
257      set adr=$ROOTDIR/$dr/src
258      if (! -d $adr) then
259        echo Source directory $adr not found.; exit 1
260      endif
261      echo Adding src dir: $adr
262      set SOURCEDIRS = ($SOURCEDIRS $adr)
263      set idr = `echo $adr | sed 's/src/inc/'`
264      set INCLUDEDIRS = ($INCLUDEDIRS $idr)
265    end
266    
267  # This is the generic configuration.  # This is the generic configuration.
268  # Platform specific options are chosen below  # Platform specific options are chosen below
# Line 131  switch ($platform$USEMPI) Line 303  switch ($platform$USEMPI)
303      set KPPFILES   = ( 'main.F' )      set KPPFILES   = ( 'main.F' )
304      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )
305      set FC         = ( 'f77' )      set FC         = ( 'f77' )
306      set FFLAGS     = ( '-convert big_endian -r8 -extend_source -u -automatic -call_shared -notransform_loops -align dcommons' )      set FFLAGS     = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )
307      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )
308      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
309      set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )      set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
# Line 152  switch ($platform$USEMPI) Line 324  switch ($platform$USEMPI)
324      echo "Configuring for SGI Mips"      echo "Configuring for SGI Mips"
325      set DEFINES    = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )      set DEFINES    = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
326      set INCLUDES   = ( '-I/usr/local/mpi/include' )      set INCLUDES   = ( '-I/usr/local/mpi/include' )
327      set FFLAGS     = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )      set FFLAGS     = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' )
328      set FOPTIM     = ( '-O3' )      set FOPTIM     = ( '-O3' )
329  #   set NOOPTFLAGS = ( '-O0' )  #   set NOOPTFLAGS = ( '-O0' )
330  #   set NOOPTFILES = ( 'barrier.F different_multiple.F ' \  #   set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
# Line 204  switch ($platform$USEMPI) Line 376  switch ($platform$USEMPI)
376      set FFLAGS     = ( '-stackvar -explicitpar -vpara -e -u -noautopar')      set FFLAGS     = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
377      set FOPTIM     = ( '-fast -O3' )      set FOPTIM     = ( '-fast -O3' )
378      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
379      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')
380      breaksw      breaksw
381    case SunOS+mpi:    case SunOS+mpi:
382      set LN         = ( '/usr/bin/ln -s' )      set LN         = ( '/usr/bin/ln -s' )
# Line 216  switch ($platform$USEMPI) Line 388  switch ($platform$USEMPI)
388      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
389      set LIBS       = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \      set LIBS       = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
390                         '-lsocket -lnsl' )                         '-lsocket -lnsl' )
391      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')
392      breaksw      breaksw
393    case IRIX32:    case IRIX32:
394      echo "Configuring for SGI ONYX running IRIX64"      echo "Configuring for SGI ONYX running IRIX64"
# Line 258  switch ($platform$USEMPI) Line 430  switch ($platform$USEMPI)
430      breaksw      breaksw
431    case Linux+pgi+mpi:    case Linux+pgi+mpi:
432      if ($?include_jam_libs) then      if ($?include_jam_libs) then
433       set INCLUDES   = ( '-I/usr/local//mpich-cnh-install/include' )       set INCLUDES   = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
434       set LIBS       = ( '-L/usr/local/mpich-cnh-install/lib/LINUX/ch_p4/ -lfmpich -lmpich' )       set LIBS       = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' )
435      else      else
436       set INCLUDES   = ( '-I/usr/local/include' )       set INCLUDES   = ( '-I/usr/local/include' )
437       set LIBS       = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )       set LIBS       = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
# Line 269  switch ($platform$USEMPI) Line 441  switch ($platform$USEMPI)
441      set CPP        = ( '/lib/cpp -traditional -P' )      set CPP        = ( '/lib/cpp -traditional -P' )
442      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )
443      set FC         = ( 'pgf77' )      set FC         = ( 'pgf77' )
444      set FFLAGS     = ( '-byteswapio' )      set FFLAGS     = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
445      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
446      set LINK       = ( 'pgf77' )      set LINK       = ( 'pgf77' )
447      breaksw      breaksw
# Line 361  foreach dr ($SOURCEDIRS) Line 533  foreach dr ($SOURCEDIRS)
533   if ($#deplist != 0) then   if ($#deplist != 0) then
534    echo "# These files are linked from $dr" >> srclinks.tmp    echo "# These files are linked from $dr" >> srclinks.tmp
535    echo $deplist':' >> srclinks.tmp    echo $deplist':' >> srclinks.tmp
536    echo '\t$(LN) '$dr'$@ $@' >> srclinks.tmp    echo '        $(LN) '$dr'/$@ $@' >> srclinks.tmp
537   endif   endif
538  end  end
539  rm -rf .links.tmp  rm -rf .links.tmp
# Line 373  set THISHOSTNAME = ( `hostname` ) Line 545  set THISHOSTNAME = ( `hostname` )
545  set THISCWD = ( `pwd` )  set THISCWD = ( `pwd` )
546  set THISDATE = ( `date` )  set THISDATE = ( `date` )
547    
548    if (-r $mfile) mv -f $mfile $mfile.bak
549  ###########################################  ###########################################
550  ## This is the template for the makefile ##  ## This is the template for the makefile ##
551  ###########################################  ###########################################
552  echo Creating makefile: $mfile  echo Creating makefile: $mfile
553  echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}  echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
554  echo "# This makefile was generated automatically pn" >> ${mfile}  echo "# This makefile was generated automatically on" >> ${mfile}
555  echo "#    $THISDATE" >> ${mfile}  echo "#    $THISDATE" >> ${mfile}
556  echo "# by the command:" >> ${mfile}  echo "# by the command:" >> ${mfile}
557  echo "#    ${0} $argv" >> ${mfile}  echo "#    ${0} $argv" >> ${mfile}
# Line 408  BUILDDIR    = ${BUILDDIR} Line 581  BUILDDIR    = ${BUILDDIR}
581  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
582  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
583  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
584  EXECUTABLE  = \$(EXEDIR)${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
585  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
586    
587  EOF  EOF
# Line 420  cat >> ${mfile} <<EOF Line 593  cat >> ${mfile} <<EOF
593  # extra stuff for Hyades ............................................  # extra stuff for Hyades ............................................
594  HYADES_DIR = /u/u0/cnh/jam-lib/software  HYADES_DIR = /u/u0/cnh/jam-lib/software
595  HYADES_DIR = /u/u0/cnh/jam-lib-twoproc  HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
596    HYADES_DIR = /usr/local/jamlib/current/dual_proc
597  WORK_DIR   = \$(HYADES_DIR)  WORK_DIR   = \$(HYADES_DIR)
598  DEPOSIT_DIR = linux_bin  DEPOSIT_DIR = linux_bin
599    
# Line 495  all: \$(EXECUTABLE) Line 669  all: \$(EXECUTABLE)
669  depend:  depend:
670          @make links          @make links
671          makedepend -o .f \$(INCLUDES) \$(SRCFILES)          makedepend -o .f \$(INCLUDES) \$(SRCFILES)
672    
673  links: \$(SRCFILES)  links: \$(SRCFILES)
674    
675  small_f: \$(F77FILES)  small_f: \$(F77FILES)
# Line 503  clean: Line 678  clean:
678          -rm -rf *.o *.f *.p ${RMFILES}          -rm -rf *.o *.f *.p ${RMFILES}
679  Clean:  Clean:
680          @make clean          @make clean
681          -find . -type l -exec rm {} \;          @make cleanlinks
682          -rm Makefile.bak          -rm -f Makefile.bak
683  CLEAN:  CLEAN:
684          @make Clean          @make Clean
685          -find \$(ROOTDIR)/verification/*/input/ -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
686          -find \$(ROOTDIR)/verification/*/input/ -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
687          -rm \$(EXECUTABLE)          -rm -f \$(EXECUTABLE)
688    
689    makefile:
690            ${0} $argv
691    cleanlinks:
692            -find . -type l -exec rm {} \;
693    
694  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .f - .o  )
695  .F.f:  .F.f:

Legend:
Removed from v.1.22.2.3  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.22