/[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.39 by adcroft, Tue Jul 31 15:22:12 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 245  endif Line 294  endif
294    
295  # Platform specific options  # Platform specific options
296  switch ($platform$USEMPI)  switch ($platform$USEMPI)
   case OSF1:  
297    case OSF1+mpi:    case OSF1+mpi:
298        echo "Configuring for DEC Alpha with MPI"
299        set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
300      case OSF1:
301      echo "Configuring for DEC Alpha"      echo "Configuring for DEC Alpha"
302      set CPP        = ( '/usr/bin/cpp -P' )      set CPP        = ( '/usr/bin/cpp -P' )
303      set DEFINES    = ( ${DEFINES}  '-DTARGET_DEC -DWORDLENGTH=1' )      set DEFINES    = ( ${DEFINES}  '-DTARGET_DEC -DWORDLENGTH=1' )
304      set KPP        = ( 'kapf' )      set KPP        = ( )
305      set KPPFILES   = ( 'main.F' )      set KPPFILES   = ( )
306      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )      set KFLAGS1    = ( )
307      set FC         = ( 'f77' )      set FC         = ( 'f77' )
308      set FFLAGS     = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )      set FFLAGS     = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )
309      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )
310      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
     set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )  
311      set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')      set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
312      set RMFILES    = ( '*.p.out' )      set RMFILES    = ( '*.p.out' )
313      breaksw      breaksw
# Line 275  switch ($platform$USEMPI) Line 325  switch ($platform$USEMPI)
325      echo "Configuring for SGI Mips"      echo "Configuring for SGI Mips"
326      set DEFINES    = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )      set DEFINES    = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
327      set INCLUDES   = ( '-I/usr/local/mpi/include' )      set INCLUDES   = ( '-I/usr/local/mpi/include' )
328      set FFLAGS     = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )      set FFLAGS     = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' )
329      set FOPTIM     = ( '-O3' )      set FOPTIM     = ( '-O3' )
330  #   set NOOPTFLAGS = ( '-O0' )  #   set NOOPTFLAGS = ( '-O0' )
331  #   set NOOPTFILES = ( 'barrier.F different_multiple.F ' \  #   set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
# Line 327  switch ($platform$USEMPI) Line 377  switch ($platform$USEMPI)
377      set FFLAGS     = ( '-stackvar -explicitpar -vpara -e -u -noautopar')      set FFLAGS     = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
378      set FOPTIM     = ( '-fast -O3' )      set FOPTIM     = ( '-fast -O3' )
379      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
380      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')
381      breaksw      breaksw
382    case SunOS+mpi:    case SunOS+mpi:
383      set LN         = ( '/usr/bin/ln -s' )      set LN         = ( '/usr/bin/ln -s' )
# Line 339  switch ($platform$USEMPI) Line 389  switch ($platform$USEMPI)
389      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
390      set LIBS       = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \      set LIBS       = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
391                         '-lsocket -lnsl' )                         '-lsocket -lnsl' )
392      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')
393      breaksw      breaksw
394    case IRIX32:    case IRIX32:
395      echo "Configuring for SGI ONYX running IRIX64"      echo "Configuring for SGI ONYX running IRIX64"
# Line 381  switch ($platform$USEMPI) Line 431  switch ($platform$USEMPI)
431      breaksw      breaksw
432    case Linux+pgi+mpi:    case Linux+pgi+mpi:
433      if ($?include_jam_libs) then      if ($?include_jam_libs) then
434       set INCLUDES   = ( '-I/usr/local//mpich-cnh-install/include' )       set INCLUDES   = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
435       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' )
436      else      else
437       set INCLUDES   = ( '-I/usr/local/include' )       set INCLUDES   = ( '-I/usr/local/include' )
438       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 594  cat >> ${mfile} <<EOF
594  # extra stuff for Hyades ............................................  # extra stuff for Hyades ............................................
595  HYADES_DIR = /u/u0/cnh/jam-lib/software  HYADES_DIR = /u/u0/cnh/jam-lib/software
596  HYADES_DIR = /u/u0/cnh/jam-lib-twoproc  HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
597    HYADES_DIR = /usr/local/jamlib/current/dual_proc
598  WORK_DIR   = \$(HYADES_DIR)  WORK_DIR   = \$(HYADES_DIR)
599  DEPOSIT_DIR = linux_bin  DEPOSIT_DIR = linux_bin
600    
# Line 619  all: \$(EXECUTABLE) Line 670  all: \$(EXECUTABLE)
670  depend:  depend:
671          @make links          @make links
672          makedepend -o .f \$(INCLUDES) \$(SRCFILES)          makedepend -o .f \$(INCLUDES) \$(SRCFILES)
673    
674  links: \$(SRCFILES)  links: \$(SRCFILES)
675    
676  small_f: \$(F77FILES)  small_f: \$(F77FILES)
# Line 627  clean: Line 679  clean:
679          -rm -rf *.o *.f *.p ${RMFILES}          -rm -rf *.o *.f *.p ${RMFILES}
680  Clean:  Clean:
681          @make clean          @make clean
682          -find . -type l -exec rm {} \;          @make cleanlinks
683          -rm -f Makefile.bak          -rm -f Makefile.bak
684  CLEAN:  CLEAN:
685          @make Clean          @make Clean
# Line 635  CLEAN: Line 687  CLEAN:
687          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
688          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE)
689    
690    makefile:
691            ${0} $argv
692    cleanlinks:
693            -find . -type l -exec rm {} \;
694    
695  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .f - .o  )
696  .F.f:  .F.f:
697          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@

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

  ViewVC Help
Powered by ViewVC 1.1.22