/[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.4 by adcroft, Thu Jan 25 18:41:18 2001 UTC revision 1.33 by jmc, Tue Mar 6 16:12:45 2001 UTC
# Line 3  Line 3 
3  # $Header$  # $Header$
4  #  #
5  # Makefile generator for MITgcm UV codes  # Makefile generator for MITgcm UV codes
6  #   created by cnh 03/98  #   created  by cnh 03/98
7  #   adapted by aja 06/98  #   adapted  by aja 06/98
8    #   modified by aja 01/00
9    
10    # Default lists
11    set DISABLE = ( aim )
12    set ENABLE  = ( )
13    set MODS  = ( )
14    
15    # Grab variables/lists from .genmakerc
16    if (-r .genmakerc) source .genmakerc
17    
18  # Process command-line arguments  # Process command-line arguments
19  set allargs=( $argv )  set allargs=( $argv )
# Line 24  while ($#allargs) Line 33  while ($#allargs)
33     exit     exit
34     breaksw     breaksw
35   case -platform*:   case -platform*:
36       if ($?platform) then
37        echo Option -platform=dir can only be specified once.; exit 1
38       endif
39     set platform = ( `echo $arg | sed 's/-platform=//' `)     set platform = ( `echo $arg | sed 's/-platform=//' `)
40     breaksw     breaksw
41     case -rootdir:
42     case -rootdir=:
43       echo "To specify root directory you must specify one with -rootdir=dir"
44       echo "with NO space eg. -rootdir=../../..  or  -rootdir=/usr/people/joe/src"
45       exit
46       breaksw
47   case -rootdir=*:   case -rootdir=*:
48       if ($?ROOTDIR) then
49        echo "***" Warning: variable \$ROOTDIR is already set to $ROOTDIR
50        echo "***" Command line \"$arg\" will override this.
51       endif
52     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)
53     breaksw     breaksw
54   case -mymods=*:   case -mods:
55     set MYMODS = ( `echo $arg | sed 's/-mymods=//' `)   case -mods=:
56       echo "To specify an additional source directory you must specify one with -mods=dir"
57       echo "with NO space eg. -mods=../code  or  -mods=/usr/people/joe/src"
58       exit
59       breaksw
60     case -mods=*:
61       set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `)
62       breaksw
63     case -disable:
64     case -disable=:
65       echo "To disable packages from compilation use -disable=pkg1,pkg2"
66       echo "with NO spaces eg. -disable=kpp,gmredi or -disable=all (to enable all packages)"
67       exit
68       breaksw
69     case -disable=*:
70       set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `)
71       breaksw
72     case -enable:
73     case -enable=:
74       echo "To enable packages from compilation use -enable=pkg1,pkg2"
75       echo "with NO spaces eg. -enable=aim or -enable=all (to enable all packages)"
76       echo "-enable overrides -disable, ie. a package listed in both is enabled"
77       exit
78       breaksw
79     case -enable=*:
80       set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `)
81     breaksw     breaksw
82   case -mpi:   case -mpi:
83     echo "Enabling MPI options"     echo "Enabling MPI options"
# Line 56  end Line 103  end
103  # Default actions/options  # Default actions/options
104    
105  # If platform wasn't specified then determine platform type of the host  # If platform wasn't specified then determine platform type of the host
106  if ($?platform == 0) then  if (! $?platform) then
107   set platform = (`uname`)   set platform = (`uname`)
108  endif  endif
109  # If name of makefile wasn't specified then use default "Makefile"  # If name of makefile wasn't specified then use default "Makefile"
110  if ($?mfile == 0) set mfile = ( Makefile )  if (! $?mfile) set mfile = ( Makefile )
111    
112  set mach  = ( `uname -a` )  set mach  = ( `uname -a` )
113  echo Operating system: $mach  echo Operating system: $mach
114    
115    
116  # 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 ./  
117  #  #
118  # 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
119  # 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
120  if ($?ROOTDIR == 0) then  if (! $?ROOTDIR) then
121    set ROOTDIR = ( .. )    set pwd=`pwd`
122  else    if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then
123    if ($?EXEDIR == 0) set EXEDIR = ( ./ )      set ROOTDIR = ( .. )
124      endif
125    endif
126    # Scan for logical ROOTDIR
127    if (! $?ROOTDIR) then
128      foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
129        if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
130          set ROOTDIR = $dr
131          echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
132          break
133        endif
134      end
135    endif
136    if (! $?ROOTDIR) then
137      echo Root directory was not specified and could not be determined.
138      echo Specify the root location of the model source with -rootdir=dir
139      exit 1
140    endif
141    if (! -d $ROOTDIR) then
142      echo Root directory $ROOTDIR not found.;exit 1
143  endif  endif
144  if ($?MYMODS == 0) then  # If -mods wasn't specified then we will assume that we can find all the
145   set SOURCEDIRS  = ( $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )  # source code in the standard directories
146   set INCLUDEDIRS = ( ./ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )  if (! $?MODS) then
147     set SOURCEDIRS  = ( )
148     set INCLUDEDIRS = ( . )
149  else  else
150   set SOURCEDIRS  = ( $MYMODS/ $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )   set SOURCEDIRS  = ( $MODS )
151   set INCLUDEDIRS = ( ./ $MYMODS/ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )   set INCLUDEDIRS = ( . $MODS )
152  endif  endif
153  if ($?BUILDDIR == 0) set BUILDDIR = ( ./ )  if (! $?BUILDDIR) set BUILDDIR = ( . )
154  if ($?EXEDIR == 0) set EXEDIR = ( $ROOTDIR/exe/ )  if (! -d $BUILDDIR) then
155  if ($?EXECUTABLE == 0) set EXECUTABLE  = ( mitgcmuv )    echo Build directory $BUILDDIR not found.;exit 1
156  if ($?TOOLSDIR == 0) set TOOLSDIR = ( $ROOTDIR/tools/ )  endif
157    if (! $?EXEDIR) then
158      set pwd=`pwd`
159      if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then
160       set EXEDIR = ( ../exe )
161      else
162       set EXEDIR = ( . )
163      endif
164    endif
165    if (! -d $EXEDIR) then
166      echo Executable directory $EXEDIR not found.;exit 1
167    endif
168    if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools )
169    if (! -d $TOOLSDIR) then
170      echo Tools directory $TOOLSDIR not found.;exit 1
171    endif
172    if (! $?EXECUTABLE) set EXECUTABLE  = ( mitgcmuv )
173    
174    # Now scan the standard source code tree
175    foreach dr ($SOURCEDIRS)
176      set adr=$dr
177      if (! -d $adr) then
178        echo mods directory $adr not found.; exit 1
179      endif
180      echo Adding mods directory $adr
181    end
182    if (! $?PACKAGES) then
183      set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`)
184    endif
185    foreach dr ($PACKAGES)
186      set enable
187      foreach p ($DISABLE)
188       if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then
189         echo Specified package \"$p\" does not exist.
190         exit 1
191       endif
192       if ($dr == $p) unset enable
193       if ($p == 'all') unset enable
194      end
195      foreach p ($ENABLE)
196       if ($dr == $p) set enable
197      end
198      if ($?enable) then
199        set adr=$ROOTDIR/pkg/$dr
200        if (! -d $adr) then
201          echo Source directory $adr not found.; exit 1
202        endif
203        echo Adding package directory $adr
204        set SOURCEDIRS = ($SOURCEDIRS $adr)
205        set INCLUDEDIRS = ($INCLUDEDIRS $adr)
206      else
207        echo "*" Package \"$dr\" has not been enabled.
208      endif
209    end
210    if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model)
211    foreach dr ($STANDARDDIRS)
212      set adr=$ROOTDIR/$dr/src
213      if (! -d $adr) then
214        echo Source directory $adr not found.; exit 1
215      endif
216      echo Adding source directory $adr
217      set SOURCEDIRS = ($SOURCEDIRS $adr)
218      set idr = `echo $adr | sed 's/src/inc/'`
219      set INCLUDEDIRS = ($INCLUDEDIRS $idr)
220    end
221    
222  # This is the generic configuration.  # This is the generic configuration.
223  # Platform specific options are chosen below  # Platform specific options are chosen below
# Line 131  switch ($platform$USEMPI) Line 258  switch ($platform$USEMPI)
258      set KPPFILES   = ( 'main.F' )      set KPPFILES   = ( 'main.F' )
259      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )
260      set FC         = ( 'f77' )      set FC         = ( 'f77' )
261      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' )
262      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )
263      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
264      set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )      set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
# Line 269  switch ($platform$USEMPI) Line 396  switch ($platform$USEMPI)
396      set CPP        = ( '/lib/cpp -traditional -P' )      set CPP        = ( '/lib/cpp -traditional -P' )
397      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )
398      set FC         = ( 'pgf77' )      set FC         = ( 'pgf77' )
399      set FFLAGS     = ( '-byteswapio' )      set FFLAGS     = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
400      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
401      set LINK       = ( 'pgf77' )      set LINK       = ( 'pgf77' )
402      breaksw      breaksw
# Line 361  foreach dr ($SOURCEDIRS) Line 488  foreach dr ($SOURCEDIRS)
488   if ($#deplist != 0) then   if ($#deplist != 0) then
489    echo "# These files are linked from $dr" >> srclinks.tmp    echo "# These files are linked from $dr" >> srclinks.tmp
490    echo $deplist':' >> srclinks.tmp    echo $deplist':' >> srclinks.tmp
491    echo '\t$(LN) '$dr'$@ $@' >> srclinks.tmp    echo '        $(LN) '$dr'/$@ $@' >> srclinks.tmp
492   endif   endif
493  end  end
494  rm -rf .links.tmp  rm -rf .links.tmp
# Line 373  set THISHOSTNAME = ( `hostname` ) Line 500  set THISHOSTNAME = ( `hostname` )
500  set THISCWD = ( `pwd` )  set THISCWD = ( `pwd` )
501  set THISDATE = ( `date` )  set THISDATE = ( `date` )
502    
503    if (-r $mfile) mv -f $mfile $mfile.bak
504  ###########################################  ###########################################
505  ## This is the template for the makefile ##  ## This is the template for the makefile ##
506  ###########################################  ###########################################
# Line 408  BUILDDIR    = ${BUILDDIR} Line 536  BUILDDIR    = ${BUILDDIR}
536  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
537  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
538  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
539  EXECUTABLE  = \$(EXEDIR)${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
540  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
541    
542  EOF  EOF
# Line 495  all: \$(EXECUTABLE) Line 623  all: \$(EXECUTABLE)
623  depend:  depend:
624          @make links          @make links
625          makedepend -o .f \$(INCLUDES) \$(SRCFILES)          makedepend -o .f \$(INCLUDES) \$(SRCFILES)
626    
627  links: \$(SRCFILES)  links: \$(SRCFILES)
628    
629  small_f: \$(F77FILES)  small_f: \$(F77FILES)
# Line 503  clean: Line 632  clean:
632          -rm -rf *.o *.f *.p ${RMFILES}          -rm -rf *.o *.f *.p ${RMFILES}
633  Clean:  Clean:
634          @make clean          @make clean
635          -find . -type l -exec rm {} \;          @make cleanlinks
636          -rm Makefile.bak          -rm -f Makefile.bak
637  CLEAN:  CLEAN:
638          @make Clean          @make Clean
639          -find \$(ROOTDIR)/verification/*/input/ -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
640          -find \$(ROOTDIR)/verification/*/input/ -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
641          -rm \$(EXECUTABLE)          -rm -f \$(EXECUTABLE)
642    
643    makefile:
644            ${0} $argv
645    cleanlinks:
646            -find . -type l -exec rm {} \;
647    
648  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .f - .o  )
649  .F.f:  .F.f:

Legend:
Removed from v.1.22.2.4  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.22