/[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.28 by adcroft, Wed Feb 7 16:49:20 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
# Line 8  Line 9 
9  #   modified by aja 01/00  #   modified by aja 01/00
10    
11  # Default lists  # Default lists
12  set DISABLE = ( aim )  set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk )
13  set ENABLE  = ( )  set ENABLE  = ( )
14  set MODS  = ( )  set MODS  = ( )
15    
# Line 50  while ($#allargs) Line 51  while ($#allargs)
51      echo "***" Command line \"$arg\" will override this.      echo "***" Command line \"$arg\" will override this.
52     endif     endif
53     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)
    if (! $?EXEDIR) set EXEDIR = ( . )  
54     breaksw     breaksw
55   case -mods:   case -mods:
56   case -mods=:   case -mods=:
# Line 89  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 113  if (! $?mfile) set mfile = ( Makefile ) Line 136  if (! $?mfile) set mfile = ( Makefile )
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
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) then  if (! $?ROOTDIR) then
144    set pwd=`pwd`    set pwd=`pwd`
145    if ($pwd:t == bin) then    if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then
146      if (-d ../exe & -d ../model & -d ../eesupp & -d ../pkg) then      set ROOTDIR = ( .. )
       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  
147    endif    endif
148  endif  endif
149  # Scan for logical ROOTDIR  # Scan for logical ROOTDIR
# Line 135  if (! $?ROOTDIR) then Line 151  if (! $?ROOTDIR) then
151    foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)    foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
152      if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then      if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
153        set ROOTDIR = $dr        set ROOTDIR = $dr
       if (! $?EXEDIR) set EXEDIR = ( . )  
154        echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"        echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
155        break        break
156      endif      endif
# Line 162  if (! $?BUILDDIR) set BUILDDIR = ( . ) Line 177  if (! $?BUILDDIR) set BUILDDIR = ( . )
177  if (! -d $BUILDDIR) then  if (! -d $BUILDDIR) then
178    echo Build directory $BUILDDIR not found.;exit 1    echo Build directory $BUILDDIR not found.;exit 1
179  endif  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  if (! -d $EXEDIR) then
189    echo Executable directory $EXEDIR not found.;exit 1    echo Executable directory $EXEDIR not found.;exit 1
190  endif  endif
# Line 171  if (! -d $TOOLSDIR) then Line 194  if (! -d $TOOLSDIR) then
194  endif  endif
195  if (! $?EXECUTABLE) set EXECUTABLE  = ( mitgcmuv )  if (! $?EXECUTABLE) set EXECUTABLE  = ( mitgcmuv )
196    
197    # We have a special set of source files in eesupp/src which
198    # 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  # Now scan the standard source code tree
212  foreach dr ($SOURCEDIRS)  foreach dr ($SOURCEDIRS)
213    set adr=$dr    set adr=$dr
214    if (! -d $adr) then    if (! -d $adr) then
215      echo mods directory $adr not found.; exit 1      echo mods directory $adr not found.; exit 1
216    endif    endif
217    echo Adding mods directory $adr    echo Adding mods dir: $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)  
218  end  end
219  if (! $?PACKAGES) then  if (! $?PACKAGES) then
220    set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`)    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  endif
225  foreach dr ($PACKAGES)  foreach dr ($PACKAGES)
226    set enable    set enable
227    foreach p ($DISABLE)    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     if ($dr == $p) unset enable
233     if ($p == 'all') unset enable     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    end
240    foreach p ($ENABLE)    foreach p ($ENABLE)
241     if ($dr == $p) set enable     if ($dr == $p) set enable
# Line 207  foreach dr ($PACKAGES) Line 245  foreach dr ($PACKAGES)
245      if (! -d $adr) then      if (! -d $adr) then
246        echo Source directory $adr not found.; exit 1        echo Source directory $adr not found.; exit 1
247      endif      endif
248      echo Adding package directory $adr      echo Adding pkg dir: $adr
249      set SOURCEDIRS = ($SOURCEDIRS $adr)      set SOURCEDIRS = ($SOURCEDIRS $adr)
250      set INCLUDEDIRS = ($INCLUDEDIRS $adr)      set INCLUDEDIRS = ($INCLUDEDIRS $adr)
251    else    else
252      echo "*" Package \"$dr\" has not been enabled.      echo "                                      *" Package \"$dr\" NOT enabled.
253    endif    endif
254  end  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 275  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 327  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 339  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 381  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 544  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 619  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 627  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 -f Makefile.bak          -rm -f Makefile.bak
683  CLEAN:  CLEAN:
684          @make Clean          @make Clean
# Line 635  CLEAN: Line 686  CLEAN:
686          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
687          -rm -f \$(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:
696          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@

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

  ViewVC Help
Powered by ViewVC 1.1.22