/[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.27 by adcroft, Wed Feb 7 14:00:06 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       if (! $?EXEDIR) set EXEDIR = ( . )
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 56  end Line 104  end
104  # Default actions/options  # Default actions/options
105    
106  # If platform wasn't specified then determine platform type of the host  # If platform wasn't specified then determine platform type of the host
107  if ($?platform == 0) then  if (! $?platform) then
108   set platform = (`uname`)   set platform = (`uname`)
109  endif  endif
110  # If name of makefile wasn't specified then use default "Makefile"  # If name of makefile wasn't specified then use default "Makefile"
111  if ($?mfile == 0) set mfile = ( Makefile )  if (! $?mfile) set mfile = ( Makefile )
112    
113  set mach  = ( `uname -a` )  set mach  = ( `uname -a` )
114  echo Operating system: $mach  echo Operating system: $mach
115    
116    
117  # 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 ./  
118  #  #
119  # 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
120  # 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
121  if ($?ROOTDIR == 0) then  if (! $?ROOTDIR) then
122    set ROOTDIR = ( .. )    set pwd=`pwd`
123  else    if ($pwd:t == bin) then
124    if ($?EXEDIR == 0) set EXEDIR = ( ./ )      if (-d ../exe & -d ../model & -d ../eesupp & -d ../pkg) then
125          set ROOTDIR = ( .. )
126          if (! $?EXEDIR) set EXEDIR = ( ../exe )
127        else if (-d ../model & -d ../eesupp & -d ../pkg) then
128          echo In bin with no exe
129          if (! $?EXEDIR) set EXEDIR = ( . )
130        endif
131      endif
132  endif  endif
133  if ($?MYMODS == 0) then  # Scan for logical ROOTDIR
134   set SOURCEDIRS  = ( $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )  if (! $?ROOTDIR) then
135   set INCLUDEDIRS = ( ./ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )    foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
136        if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
137          set ROOTDIR = $dr
138          if (! $?EXEDIR) set EXEDIR = ( . )
139          echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
140          break
141        endif
142      end
143    endif
144    if (! $?ROOTDIR) then
145      echo Root directory was not specified and could not be determined.
146      echo Specify the root location of the model source with -rootdir=dir
147      exit 1
148    endif
149    if (! -d $ROOTDIR) then
150      echo Root directory $ROOTDIR not found.;exit 1
151    endif
152    # If -mods wasn't specified then we will assume that we can find all the
153    # source code in the standard directories
154    if (! $?MODS) then
155     set SOURCEDIRS  = ( )
156     set INCLUDEDIRS = ( . )
157  else  else
158   set SOURCEDIRS  = ( $MYMODS/ $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )   set SOURCEDIRS  = ( $MODS )
159   set INCLUDEDIRS = ( ./ $MYMODS/ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )   set INCLUDEDIRS = ( . $MODS )
160    endif
161    if (! $?BUILDDIR) set BUILDDIR = ( . )
162    if (! -d $BUILDDIR) then
163      echo Build directory $BUILDDIR not found.;exit 1
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 (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model diags)
183    foreach dr ($STANDARDDIRS)
184      set adr=$ROOTDIR/$dr/src
185      if (! -d $adr) then
186        echo Source directory $adr not found.; exit 1
187      endif
188      echo Adding source directory $adr
189      set SOURCEDIRS = ($SOURCEDIRS $adr)
190      set idr = `echo $adr | sed 's/src/inc/'`
191      set INCLUDEDIRS = ($INCLUDEDIRS $idr)
192    end
193    if (! $?PACKAGES) then
194      set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`)
195  endif  endif
196  if ($?BUILDDIR == 0) set BUILDDIR = ( ./ )  foreach dr ($PACKAGES)
197  if ($?EXEDIR == 0) set EXEDIR = ( $ROOTDIR/exe/ )    set enable
198  if ($?EXECUTABLE == 0) set EXECUTABLE  = ( mitgcmuv )    foreach p ($DISABLE)
199  if ($?TOOLSDIR == 0) set TOOLSDIR = ( $ROOTDIR/tools/ )     if ($dr == $p) unset enable
200       if ($p == 'all') unset enable
201      end
202      foreach p ($ENABLE)
203       if ($dr == $p) set enable
204      end
205      if ($?enable) then
206        set adr=$ROOTDIR/pkg/$dr
207        if (! -d $adr) then
208          echo Source directory $adr not found.; exit 1
209        endif
210        echo Adding package directory $adr
211        set SOURCEDIRS = ($SOURCEDIRS $adr)
212        set INCLUDEDIRS = ($INCLUDEDIRS $adr)
213      else
214        echo "*" Package \"$dr\" has not been enabled.
215      endif
216    end
217    
218  # This is the generic configuration.  # This is the generic configuration.
219  # Platform specific options are chosen below  # Platform specific options are chosen below
# Line 131  switch ($platform$USEMPI) Line 254  switch ($platform$USEMPI)
254      set KPPFILES   = ( 'main.F' )      set KPPFILES   = ( 'main.F' )
255      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )      set KFLAGS1    = ( '-scan=132 -noconc -cmp=' )
256      set FC         = ( 'f77' )      set FC         = ( 'f77' )
257      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' )
258      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )      set FOPTIM     = ( '-O5 -fast -tune host -inline all' )
259      set NOOPTFLAGS = ( '-O0' )      set NOOPTFLAGS = ( '-O0' )
260      set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )      set LIBS       = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
# Line 269  switch ($platform$USEMPI) Line 392  switch ($platform$USEMPI)
392      set CPP        = ( '/lib/cpp -traditional -P' )      set CPP        = ( '/lib/cpp -traditional -P' )
393      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )
394      set FC         = ( 'pgf77' )      set FC         = ( 'pgf77' )
395      set FFLAGS     = ( '-byteswapio' )      set FFLAGS     = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
396      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
397      set LINK       = ( 'pgf77' )      set LINK       = ( 'pgf77' )
398      breaksw      breaksw
# Line 361  foreach dr ($SOURCEDIRS) Line 484  foreach dr ($SOURCEDIRS)
484   if ($#deplist != 0) then   if ($#deplist != 0) then
485    echo "# These files are linked from $dr" >> srclinks.tmp    echo "# These files are linked from $dr" >> srclinks.tmp
486    echo $deplist':' >> srclinks.tmp    echo $deplist':' >> srclinks.tmp
487    echo '\t$(LN) '$dr'$@ $@' >> srclinks.tmp    echo '        $(LN) '$dr'/$@ $@' >> srclinks.tmp
488   endif   endif
489  end  end
490  rm -rf .links.tmp  rm -rf .links.tmp
# Line 373  set THISHOSTNAME = ( `hostname` ) Line 496  set THISHOSTNAME = ( `hostname` )
496  set THISCWD = ( `pwd` )  set THISCWD = ( `pwd` )
497  set THISDATE = ( `date` )  set THISDATE = ( `date` )
498    
499    if (-r $mfile) mv -f $mfile $mfile.bak
500  ###########################################  ###########################################
501  ## This is the template for the makefile ##  ## This is the template for the makefile ##
502  ###########################################  ###########################################
503  echo Creating makefile: $mfile  echo Creating makefile: $mfile
504  echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}  echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
505  echo "# This makefile was generated automatically pn" >> ${mfile}  echo "# This makefile was generated automatically on" >> ${mfile}
506  echo "#    $THISDATE" >> ${mfile}  echo "#    $THISDATE" >> ${mfile}
507  echo "# by the command:" >> ${mfile}  echo "# by the command:" >> ${mfile}
508  echo "#    ${0} $argv" >> ${mfile}  echo "#    ${0} $argv" >> ${mfile}
# Line 408  BUILDDIR    = ${BUILDDIR} Line 532  BUILDDIR    = ${BUILDDIR}
532  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
533  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
534  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
535  EXECUTABLE  = \$(EXEDIR)${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
536  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
537    
538  EOF  EOF
# Line 504  clean: Line 628  clean:
628  Clean:  Clean:
629          @make clean          @make clean
630          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
631          -rm Makefile.bak          -rm -f Makefile.bak
632  CLEAN:  CLEAN:
633          @make Clean          @make Clean
634          -find \$(ROOTDIR)/verification/*/input/ -name "*.meta" -exec rm {} \;          -find \$(ROOTDIR) -name "*.meta" -exec rm {} \;
635          -find \$(ROOTDIR)/verification/*/input/ -name "*.data" -exec rm {} \;          -find \$(ROOTDIR) -name "*.data" -exec rm {} \;
636          -rm \$(EXECUTABLE)          -rm -f \$(EXECUTABLE)
637    
638  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .f - .o  )
639  .F.f:  .F.f:

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

  ViewVC Help
Powered by ViewVC 1.1.22