50 |
echo "***" Command line \"$arg\" will override this. |
echo "***" Command line \"$arg\" will override this. |
51 |
endif |
endif |
52 |
set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `) |
set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `) |
|
if (! $?EXEDIR) set EXEDIR = ( . ) |
|
53 |
breaksw |
breaksw |
54 |
case -mods: |
case -mods: |
55 |
case -mods=: |
case -mods=: |
88 |
echo "Including paths to JAM libraries" |
echo "Including paths to JAM libraries" |
89 |
breaksw |
breaksw |
90 |
case -help: |
case -help: |
91 |
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]" |
92 |
|
cat << EOF |
93 |
|
|
94 |
|
$0 is used to generate the Makefile in the current directory. |
95 |
|
|
96 |
|
Typical invocations are: |
97 |
|
o from "bin": ../tools/genmake |
98 |
|
o from "verification/expt/code": ../../../tools/genmake |
99 |
|
o from "verification/expt/input": ../../../tools/genmake -mods=../code |
100 |
|
o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm |
101 |
|
or ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods |
102 |
|
|
103 |
|
Packages (collected modules of code) can be disabled to avoid unnecessary |
104 |
|
compilation of unused code. For instance if you know you will not |
105 |
|
use GM/Redi, KPP and OBCS and they are appropriate turned-off in the |
106 |
|
configuration: |
107 |
|
.../tools/genmake -disable=gmredi,kpp,obcs |
108 |
|
|
109 |
|
If you add some source files you can re-call the previous instance of |
110 |
|
genmake with "make makefile". |
111 |
|
|
112 |
|
genmake also reads the file .genmakerc which can be used to configure |
113 |
|
options (primarily the command-line options above) for particular experiments. |
114 |
|
EOF |
115 |
exit |
exit |
116 |
breaksw |
breaksw |
117 |
default: |
default: |
135 |
set mach = ( `uname -a` ) |
set mach = ( `uname -a` ) |
136 |
echo Operating system: $mach |
echo Operating system: $mach |
137 |
|
|
|
|
|
138 |
# Directories for source, includes, binaries and executables |
# Directories for source, includes, binaries and executables |
139 |
# |
# |
140 |
# 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 |
141 |
# 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 |
142 |
if (! $?ROOTDIR) then |
if (! $?ROOTDIR) then |
143 |
set pwd=`pwd` |
set pwd=`pwd` |
144 |
if ($pwd:t == bin) then |
if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then |
145 |
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 |
|
146 |
endif |
endif |
147 |
endif |
endif |
148 |
# Scan for logical ROOTDIR |
# Scan for logical ROOTDIR |
150 |
foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..) |
foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..) |
151 |
if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then |
if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then |
152 |
set ROOTDIR = $dr |
set ROOTDIR = $dr |
|
if (! $?EXEDIR) set EXEDIR = ( . ) |
|
153 |
echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\" |
echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\" |
154 |
break |
break |
155 |
endif |
endif |
176 |
if (! -d $BUILDDIR) then |
if (! -d $BUILDDIR) then |
177 |
echo Build directory $BUILDDIR not found.;exit 1 |
echo Build directory $BUILDDIR not found.;exit 1 |
178 |
endif |
endif |
179 |
|
if (! $?EXEDIR) then |
180 |
|
set pwd=`pwd` |
181 |
|
if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then |
182 |
|
set EXEDIR = ( ../exe ) |
183 |
|
else |
184 |
|
set EXEDIR = ( . ) |
185 |
|
endif |
186 |
|
endif |
187 |
if (! -d $EXEDIR) then |
if (! -d $EXEDIR) then |
188 |
echo Executable directory $EXEDIR not found.;exit 1 |
echo Executable directory $EXEDIR not found.;exit 1 |
189 |
endif |
endif |
193 |
endif |
endif |
194 |
if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv ) |
if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv ) |
195 |
|
|
196 |
|
# We have a special set of source files in eesupp/src which |
197 |
|
# are generated from some template source files. We'll make them |
198 |
|
# first so the appear as regular source code |
199 |
|
if (-r $ROOTDIR/eesupp/src/Makefile) then |
200 |
|
echo Making source files in eesupp from templates... |
201 |
|
(cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs |
202 |
|
if ($status == 0) then |
203 |
|
rm -f make_eesupp.errs |
204 |
|
else |
205 |
|
cat make_eesupp.errs |
206 |
|
exit 2 |
207 |
|
endif |
208 |
|
endif |
209 |
|
|
210 |
# Now scan the standard source code tree |
# Now scan the standard source code tree |
211 |
foreach dr ($SOURCEDIRS) |
foreach dr ($SOURCEDIRS) |
212 |
set adr=$dr |
set adr=$dr |
215 |
endif |
endif |
216 |
echo Adding mods directory $adr |
echo Adding mods directory $adr |
217 |
end |
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) |
|
|
end |
|
218 |
if (! $?PACKAGES) then |
if (! $?PACKAGES) then |
219 |
set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`) |
set PACKAGES=() |
220 |
|
foreach pkg (`cd $ROOTDIR/pkg; find . -type d | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`) |
221 |
|
if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg) |
222 |
|
end |
223 |
endif |
endif |
224 |
foreach dr ($PACKAGES) |
foreach dr ($PACKAGES) |
225 |
set enable |
set enable |
226 |
foreach p ($DISABLE) |
foreach p ($DISABLE) |
227 |
|
if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then |
228 |
|
echo Specified package \"$p\" does not exist. |
229 |
|
exit 1 |
230 |
|
endif |
231 |
if ($dr == $p) unset enable |
if ($dr == $p) unset enable |
232 |
if ($p == 'all') unset enable |
if ($p == 'all') unset enable |
233 |
|
# The following allows entire trees to be disabled |
234 |
|
if ($dr:h == $p) unset enable |
235 |
|
if ($dr:h:h == $p) unset enable |
236 |
|
if ($dr:h:h:h == $p) unset enable |
237 |
|
if ($dr:h:h:h:h == $p) unset enable |
238 |
end |
end |
239 |
foreach p ($ENABLE) |
foreach p ($ENABLE) |
240 |
if ($dr == $p) set enable |
if ($dr == $p) set enable |
251 |
echo "*" Package \"$dr\" has not been enabled. |
echo "*" Package \"$dr\" has not been enabled. |
252 |
endif |
endif |
253 |
end |
end |
254 |
|
if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model) |
255 |
|
foreach dr ($STANDARDDIRS) |
256 |
|
set adr=$ROOTDIR/$dr/src |
257 |
|
if (! -d $adr) then |
258 |
|
echo Source directory $adr not found.; exit 1 |
259 |
|
endif |
260 |
|
echo Adding source directory $adr |
261 |
|
set SOURCEDIRS = ($SOURCEDIRS $adr) |
262 |
|
set idr = `echo $adr | sed 's/src/inc/'` |
263 |
|
set INCLUDEDIRS = ($INCLUDEDIRS $idr) |
264 |
|
end |
265 |
|
|
266 |
# This is the generic configuration. |
# This is the generic configuration. |
267 |
# Platform specific options are chosen below |
# Platform specific options are chosen below |
429 |
breaksw |
breaksw |
430 |
case Linux+pgi+mpi: |
case Linux+pgi+mpi: |
431 |
if ($?include_jam_libs) then |
if ($?include_jam_libs) then |
432 |
set INCLUDES = ( '-I/usr/local//mpich-cnh-install/include' ) |
set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' ) |
433 |
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' ) |
434 |
else |
else |
435 |
set INCLUDES = ( '-I/usr/local/include' ) |
set INCLUDES = ( '-I/usr/local/include' ) |
436 |
set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
592 |
# extra stuff for Hyades ............................................ |
# extra stuff for Hyades ............................................ |
593 |
HYADES_DIR = /u/u0/cnh/jam-lib/software |
HYADES_DIR = /u/u0/cnh/jam-lib/software |
594 |
HYADES_DIR = /u/u0/cnh/jam-lib-twoproc |
HYADES_DIR = /u/u0/cnh/jam-lib-twoproc |
595 |
|
HYADES_DIR = /usr/local/jamlib/current/dual_proc |
596 |
WORK_DIR = \$(HYADES_DIR) |
WORK_DIR = \$(HYADES_DIR) |
597 |
DEPOSIT_DIR = linux_bin |
DEPOSIT_DIR = linux_bin |
598 |
|
|
668 |
depend: |
depend: |
669 |
@make links |
@make links |
670 |
makedepend -o .f \$(INCLUDES) \$(SRCFILES) |
makedepend -o .f \$(INCLUDES) \$(SRCFILES) |
671 |
|
|
672 |
links: \$(SRCFILES) |
links: \$(SRCFILES) |
673 |
|
|
674 |
small_f: \$(F77FILES) |
small_f: \$(F77FILES) |
677 |
-rm -rf *.o *.f *.p ${RMFILES} |
-rm -rf *.o *.f *.p ${RMFILES} |
678 |
Clean: |
Clean: |
679 |
@make clean |
@make clean |
680 |
-find . -type l -exec rm {} \; |
@make cleanlinks |
681 |
-rm -f Makefile.bak |
-rm -f Makefile.bak |
682 |
CLEAN: |
CLEAN: |
683 |
@make Clean |
@make Clean |
685 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
686 |
-rm -f \$(EXECUTABLE) |
-rm -f \$(EXECUTABLE) |
687 |
|
|
688 |
|
makefile: |
689 |
|
${0} $argv |
690 |
|
cleanlinks: |
691 |
|
-find . -type l -exec rm {} \; |
692 |
|
|
693 |
# The normal chain of rules is ( .F - .f - .o ) |
# The normal chain of rules is ( .F - .f - .o ) |
694 |
.F.f: |
.F.f: |
695 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |