/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Annotation of /MITgcm/tools/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.139 - (hide annotations) (download)
Thu Dec 22 01:22:27 2005 UTC (18 years, 3 months ago) by ce107
Branch: MAIN
Changes since 1.138: +102 -4 lines
Added support for enabling timing per timestep (-ts), PAPI MFlop/s per
timestep (-papis), variations of the above for TAF (add a "-foolad"),
PAPI (-papi) or HPMT (-hpmt) performance monitoring per timed section and
support for runtime floating point environment modification (-gsl). No
tests for establishing the locations of these libraries are provided.
Also added hooks for automatic trick to create the MPI header directory
for DIVA and patch mpif.h on AIX systems.

1 edhill 1.86 #! /usr/bin/env bash
2 edhill 1.1 #
3 ce107 1.139 # $Header: /u/gcmpack/MITgcm/tools/genmake2,v 1.138 2005/12/04 13:57:08 edhill Exp $
4 edhill 1.1 #
5     # Makefile generator for MITgcm UV codes
6     # created by cnh 03/98
7     # adapted by aja 06/98
8     # modified by aja 01/00
9     # rewritten in bash by eh3 08/03
10    
11 edhill 1.12 # Search for particular CPP #cmds associated with packages
12     # usage: test_for_package_in_cpp_options CPP_file package_name
13     test_for_package_in_cpp_options() {
14     cpp_options=$1
15     pkg=$2
16 adcroft 1.52 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99
17     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99
18     test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99
19     test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99
20     }
21    
22     # Search for particular CPP #cmds associated with MPI
23     # usage: test_for_mpi_in_cpp_eeoptions CPP_file
24     test_for_mpi_in_cpp_eeoptions() {
25     cpp_options=$1
26     test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99
27     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99
28     test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99
29     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99
30     }
31    
32     # Search for particular string in a file. Return 1 if detected, 0 if not
33     # usage: test_for_string_in_file file string
34     test_for_string_in_file() {
35     file=$1
36     strng=$2
37     grep -i "$strng" $file > /dev/null 2>&1
38 edhill 1.12 RETVAL=$?
39     if test "x${RETVAL}" = x0 ; then
40 edhill 1.71 printf "Error: In $file there is an illegal line: "
41 adcroft 1.52 grep -i "$strng" $file
42     return 1
43 edhill 1.12 fi
44 adcroft 1.52 return 0
45 edhill 1.12 }
46    
47     # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
48     # the package list.
49     expand_pkg_groups() {
50     new_packages=
51     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
52     if test -r $PKG_GROUPS ; then
53     cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
54 edhill 1.15 cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
55 edhill 1.12 matched=0
56     for i in $PACKAGES ; do
57     line=`grep "^ *$i" ./p2.tmp`
58     RETVAL=$?
59     if test "x$RETVAL" = x0 ; then
60     matched=1
61 edhill 1.15 replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
62 edhill 1.12 echo " replacing \"$i\" with: $replace"
63     new_packages="$new_packages $replace"
64     else
65     new_packages="$new_packages $i"
66     fi
67     done
68     PACKAGES=$new_packages
69     rm -f ./p[1,2].tmp
70 adcroft 1.74 return $matched
71 edhill 1.12 else
72     echo "Warning: can't read package groups definition file: $PKG_GROUPS"
73     fi
74     }
75 edhill 1.1
76 edhill 1.75 # Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
77     # cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
78     check_for_broken_Ff() {
79 edhill 1.76 # Do we have defaults for $FS and/or $FS90 ?
80     tfs=f
81     tfs9=f90
82     if test "x$FS" != x ; then
83     tfs="$FS"
84     fi
85     if test "x$FS90" != x ; then
86     tfs9="$FS90"
87     fi
88    
89 edhill 1.75 # First check the ability to create a *.F/.f pair.
90 edhill 1.76 cat <<EOF >> genmake_hello.F
91 edhill 1.75 program hello
92     write(*,*) 'hi'
93     stop
94     end
95     EOF
96 edhill 1.76 cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
97 edhill 1.75 RETVAL=$?
98     if test "x$RETVAL" != x0 ; then
99 edhill 1.76 if test "x$FS" = x ; then
100 edhill 1.77 FS='for'
101     FS90='fr9'
102 edhill 1.76 check_for_broken_Ff
103     else
104     cat <<EOF 2>&1
105     ERROR: Your file system cannot distinguish between *.F and *.f files
106     (fails the "cp" test) and this program cannot find a suitable
107     replacement extension. Please try a different build environment or
108     contact the <MITgcm-support@mitgcm.org> list for help.
109    
110     EOF
111     exit -1
112     fi
113 edhill 1.75 return
114     fi
115 edhill 1.76 rm -f genmake_hello.*
116 edhill 1.75
117 edhill 1.76 # Check the ability of ${MAKE} and ${LN} to use the current set
118     # of extensions.
119     cat <<EOF >> genmake_hello.F
120     program hello
121     write(*,*) 'hi'
122     stop
123     end
124     EOF
125 edhill 1.119 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
126     cat <<EOF >> $MAKEFILE
127 edhill 1.75 .SUFFIXES:
128 edhill 1.101 .SUFFIXES: .$tfs .F
129     .F.$tfs:
130     $LN \$< \$@
131 edhill 1.75 EOF
132 edhill 1.76 $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133 edhill 1.75 RETVAL=$?
134 edhill 1.88 if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
135 edhill 1.76 if test "x$FS" = x ; then
136 edhill 1.77 FS='for'
137     FS90='fr9'
138 edhill 1.76 check_for_broken_Ff
139     else
140     cat <<EOF 2>&1
141     ERROR: Your file system cannot distinguish between *.F and *.f files
142     (fails the "make/ln" test) and this program cannot find a suitable
143     replacement extension. Please try a different build environment or
144     contact the <MITgcm-support@mitgcm.org> list for help.
145    
146     EOF
147     exit -1
148     return
149     fi
150 edhill 1.75 fi
151 edhill 1.119 rm -f genmake_hello.* $MAKEFILE
152     test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
153 edhill 1.75
154 edhill 1.76 # If we make it here, use the extensions
155     FS=$tfs
156     FS90=$tfs9
157     return
158 edhill 1.75 }
159    
160    
161 edhill 1.84 look_for_makedepend() {
162 adcroft 1.33
163 edhill 1.69 # The "original" makedepend is part of the Imake system that is
164     # most often distributed with XFree86 or with an XFree86 source
165     # package. As a result, many machines (eg. generic Linux) do not
166     # have a system-default "makedepend" available. For those
167     # systems, we have two fall-back options:
168     #
169     # 1) a makedepend implementation shipped with the cyrus-imapd
170     # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
171     #
172     # 2) a known-buggy xmakedpend shell script
173     #
174     # So the choices are, in order:
175     #
176     # 1) use the user-specified program
177     # 2) use a system-wide default
178     # 3) locally build and use the cyrus implementation
179     # 4) fall back to the buggy local xmakedpend script
180     #
181 adcroft 1.33 if test "x${MAKEDEPEND}" = x ; then
182 edhill 1.85 which makedepend > /dev/null 2>&1
183     RV0=$?
184 edhill 1.119 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
185     # echo 'MAKEFILE="'$MAKEFILE'"'
186     cat <<EOF >> $MAKEFILE
187     # THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
188     #
189     # Some "makedepend" implementations will die if they cannot
190     # find a Makefile -- so this file is here to gives them an
191     # empty one to find and parse.
192     EOF
193 edhill 1.85 cat <<EOF >> genmake_tc.f
194 edhill 1.77 program test
195     write(*,*) 'test'
196     stop
197     end
198     EOF
199 edhill 1.85 makedepend genmake_tc.f > /dev/null 2>&1
200 mlosch 1.120 RV1=$?
201 edhill 1.119 test -f $MAKEFILE && rm -f $MAKEFILE
202     test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
203 edhill 1.85 if test "x${RV0}${RV1}" = x00 ; then
204     MAKEDEPEND=makedepend
205     else
206     echo " a system-default makedepend was not found."
207    
208     # Try to build the cyrus implementation
209 edhill 1.90 build_cyrus_makedepend
210 edhill 1.85 RETVAL=$?
211 edhill 1.90 if test "x$RETVAL" != x0 ; then
212 edhill 1.85 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
213     fi
214     rm -f ./genmake_cy_md
215     fi
216 edhill 1.90 else
217     # echo "MAKEDEPEND=${MAKEDEPEND}"
218     echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
219     RETVAL=$?
220     if test x"$RETVAL" = x0 ; then
221     build_cyrus_makedepend
222     fi
223 edhill 1.1 fi
224 edhill 1.84 }
225    
226    
227 edhill 1.90 build_cyrus_makedepend() {
228     rm -f ./genmake_cy_md
229     (
230     cd $ROOTDIR/tools/cyrus-imapd-makedepend \
231     && ./configure > /dev/null 2>&1 \
232     && make > /dev/null 2>&1
233     if test -x ./makedepend.exe ; then
234     $LN ./makedepend.exe ./makedepend
235     fi
236     ./makedepend ifparser.c > /dev/null 2>&1 \
237     && echo "true"
238     ) > ./genmake_cy_md
239     grep true ./genmake_cy_md > /dev/null 2>&1
240     RETVAL=$?
241     rm -f ./genmake_cy_md
242     if test "x$RETVAL" = x0 ; then
243     MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
244     return 0
245     else
246     echo "WARNING: unable to build cyrus-imapd-makedepend"
247     return 1
248     fi
249     }
250    
251 edhill 1.84 # Guess possible config options for this host
252     find_possible_configs() {
253    
254     tmp1=`uname`"_"`uname -m`
255     tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
256     tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
257     tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
258     tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
259     tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
260     PLATFORM=$tmp3
261     echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
262     OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
263     echo " The platform appears to be: $PLATFORM"
264    
265     echo "test" > test
266     ln -s ./test link
267     RETVAL=$?
268     if test "x${RETVAL}" = x0 ; then
269     LN="ln -s"
270     else
271     echo "Error: \"ln -s\" does not appear to work on this system!"
272     echo " For help, please contact <MITgcm-support@mitgcm.org>."
273     exit 1
274     fi
275     rm -f test link
276    
277     if test "x$CPP" = x ; then
278     CPP="cpp -traditional -P"
279     fi
280    
281     look_for_makedepend
282 edhill 1.1
283 edhill 1.91 #================================================================
284     # look for possible C compilers
285     tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286     p_CC=
287     for c in $tmp ; do
288     rm -f ./genmake_hello.c ./genmake_hello
289     cat >> genmake_hello.c << EOF
290     #include <stdio.h>
291     int main(int argc, char **argv) {
292     printf("Hello!\n");
293     return 0;
294     }
295     EOF
296     $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297     RETVAL=$?
298     if test "x${RETVAL}" = x0 ; then
299     p_CC="$p_CC $c"
300     fi
301     done
302     rm -f ./genmake_hello.c ./genmake_hello
303     if test "x${p_CC}" = x ; then
304     cat 1>&2 <<EOF
305    
306     Error: No C compilers were found in your path. Please specify one using:
307    
308     1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309     2) the CC or MITGCM_CC environment variables.
310    
311     EOF
312     exit 1
313     else
314     echo " The possible C compilers found in your path are:"
315     echo " "$p_CC
316     if test "x$CC" = x ; then
317     CC=`echo $p_CC | $AWK '{print $1}'`
318     echo " Setting C compiler to: "$CC
319     fi
320     fi
321    
322     #================================================================
323     # look for possible FORTRAN compilers
324 edhill 1.123 tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"
325 edhill 1.1 p_FC=
326 edhill 1.11 for c in $tmp ; do
327     rm -f ./hello.f ./hello
328     cat >> hello.f <<EOF
329     program hello
330     do i=1,3
331     print *, 'hello world : ', i
332     enddo
333     end
334     EOF
335     $c -o hello hello.f > /dev/null 2>&1
336 edhill 1.1 RETVAL=$?
337     if test "x${RETVAL}" = x0 ; then
338     p_FC="$p_FC $c"
339     fi
340     done
341 edhill 1.21 rm -f ./hello.f ./hello
342 edhill 1.1 if test "x${p_FC}" = x ; then
343 edhill 1.11 cat 1>&2 <<EOF
344    
345     Error: No Fortran compilers were found in your path. Please specify one using:
346    
347     1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
348     2) a command-line option (eg. "-fc NAME"), or
349 edhill 1.91 3) the FC or MITGCM_FC environment variables.
350 edhill 1.11
351     EOF
352     exit 1
353 edhill 1.1 else
354 edhill 1.11 echo " The possible FORTRAN compilers found in your path are:"
355     echo " "$p_FC
356 edhill 1.136 fi
357    
358     # Use the first of the compilers found in the current PATH
359     # that has a correctly-named optfile
360     if test "x$OPTFILE" = x -a "x$FC" = x ; then
361     for i in $p_FC ; do
362     OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363     if test -r $OPTFILE ; then
364     echo " Setting OPTFILE to: "$OPTFILE
365     break
366     fi
367     done
368 edhill 1.1 fi
369    
370 adcroft 1.67 if test "x$OPTFILE" = x ; then
371     OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
372     if test ! -r $OPTFILE ; then
373     echo " I looked for the file "$OPTFILE" but did not find it"
374     fi
375     fi
376     # echo " The options file: $p_OF"
377     # echo " appears to match so we'll use it."
378     # for i in $p_FC ; do
379     #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
380     #if test -r $p_OF ; then
381     # OPTFILE=$p_OF
382     # echo " The options file: $p_OF"
383     # echo " appears to match so we'll use it."
384     # break
385     #fi
386     # done
387 edhill 1.11 if test "x$OPTFILE" = x ; then
388     cat 1>&2 <<EOF
389    
390     Error: No options file was found in: $ROOTDIR/tools/build_options/
391     that matches this platform ("$PLATFORM") and the compilers found in
392     your path. Please specify an "optfile" using:
393    
394     1) the command line (eg. "-optfile=path/to/OPTFILE"), or
395     2) the MITGCM_OF environment variable.
396    
397     If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
398    
399 edhill 1.1 EOF
400 edhill 1.11 exit 1
401 edhill 1.1 fi
402 edhill 1.11
403     # # look for possible MPI libraries
404     # mpi_libs=
405     # mpi_fort=`which mpif77 2>/dev/null`
406     # RETVAL=$?
407     # if test "x${RETVAL}" = x0 ; then
408     # cat >>test.f <<EOF
409     # PROGRAM HELLO
410     # DO 10, I=1,10
411     # PRINT *,'Hello World'
412     # 10 CONTINUE
413     # STOP
414     # END
415     # EOF
416     # eval "$mpi_fort -showme test.f > out"
417     # RETVAL=$?
418     # if test "x${RETVAL}" = x0 ; then
419     # a=`cat out`
420     # for i in $a ; do
421     # case $i in
422     # -*)
423     # mpi_libs="$mpi_libs $i" ;;
424     # esac
425     # done
426     # echo "The MPI libs appear to be:"
427     # echo " "$mpi_libs
428     # fi
429     # rm -f test.f out
430     # fi
431 edhill 1.1
432     }
433    
434     # Parse the package dependency information
435     get_pdepend_list() {
436    
437     # strip the comments and then convert the dependency file into
438     # two arrays: PNAME, DNAME
439     cat $1 | sed -e 's/#.*$//g' \
440 edhill 1.15 | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
441 edhill 1.1 > ./.pd_tmp
442 edhill 1.34 . ./.pd_tmp
443 edhill 1.1 rm -f ./.pd_tmp
444    
445 edhill 1.71 printf "PNAME = "${}
446 edhill 1.1 }
447    
448    
449     # Explain usage
450     usage() {
451 edhill 1.41 cat <<EOF
452    
453     Usage: "$0" [OPTIONS]
454     where [OPTIONS] can be:
455    
456     -help | --help | -h | --h
457     Print this help message and exit.
458 edhill 1.79
459     -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
460     -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
461     Use "NAME" as the adoptfile. By default, the file at
462     "tools/adjoint_options/adjoint_default" will be used.
463 edhill 1.41
464     -nooptfile | --nooptfile
465     -optfile NAME | --optfile NAME | -of NAME | --of NAME
466     -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
467     Use "NAME" as the optfile. By default, an attempt will be
468     made to find an appropriate "standard" optfile in the
469     tools/build_options/ directory.
470    
471     -pdepend NAME | --pdepend NAME
472     -pdepend=NAME | --pdepend=NAME
473     Get package dependency information from "NAME".
474    
475     -pdefault NAME | --pdefault NAME
476     -pdefault=NAME | --pdefault=NAME
477     Get the default package list from "NAME".
478    
479     -make NAME | -m NAME
480     --make=NAME | -m=NAME
481     Use "NAME" for the MAKE program. The default is "make" but
482     many platforms, "gmake" is the preferred choice.
483    
484     -makefile NAME | -mf NAME
485     --makefile=NAME | -mf=NAME
486     Call the makefile "NAME". The default is "Makefile".
487    
488 edhill 1.69 -makedepend NAME | -md NAME
489     --makedepend=NAME | -md=NAME
490     Use "NAME" for the MAKEDEPEND program.
491    
492 edhill 1.41 -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
493     -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
494     Specify the location of the MITgcm ROOTDIR as "NAME".
495     By default, genamke will try to find the location by
496     looking in parent directories (up to the 5th parent).
497    
498     -mods NAME | --mods NAME | -mo NAME | --mo NAME
499     -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
500     Here, "NAME" specifies a list of directories that are
501     used for additional source code. Files found in the
502     "mods list" are given preference over files of the same
503     name found elsewhere.
504    
505     -disable NAME | --disable NAME
506     -disable=NAME | --disable=NAME
507     Here "NAME" specifies a list of packages that we don't
508     want to use. If this violates package dependencies,
509     genamke will exit with an error message.
510    
511     -enable NAME | --enable NAME
512     -enable=NAME | --enable=NAME
513     Here "NAME" specifies a list of packages that we wish
514     to specifically enable. If this violates package
515     dependencies, genamke will exit with an error message.
516    
517     -standarddirs NAME | --standarddirs NAME
518     -standarddirs=NAME | --standarddirs=NAME
519     Here, "NAME" specifies a list of directories to be
520     used as the "standard" code.
521    
522     -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
523     -fc=NAME | --fc=NAME
524     Use "NAME" as the fortran compiler. By default, genmake
525     will search for a working compiler by trying a list of
526     "usual suspects" such as g77, f77, etc.
527    
528 edhill 1.91 -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
529     Use "NAME" as the C compiler. By default, genmake
530     will search for a working compiler by trying a list of
531     "usual suspects" such as gcc, c89, cc, etc.
532    
533 edhill 1.41 -[no]ieee | --[no]ieee
534     Do or don't use IEEE numerics. Note that this option
535     *only* works if it is supported by the OPTFILE that
536     is being used.
537    
538 ce107 1.126 -ts | --ts
539     Produce timing information per timestep
540 ce107 1.139 -papis | --papis
541     Produce summary MFlop/s with PAPI per timestep
542     -foolad | --foolad
543     Fool the AD code generator
544     -papi | --papi
545     Performance analysis with PAPI
546     -hpmt | --hpmt
547     Performance analysis with the HPM Toolkit
548    
549     -gsl | --gsl
550     Use GSL to control floating point rounding and precision
551 ce107 1.126
552 adcroft 1.67 -mpi | --mpi
553     Include MPI header files and link to MPI libraries
554     -mpi=PATH | --mpi=PATH
555     Include MPI header files and link to MPI libraries using MPI_ROOT
556 edhill 1.95 set to PATH. i.e. Include files from \$PATH/include, link to libraries
557     from \$PATH/lib and use binaries from \$PATH/bin.
558 adcroft 1.67
559 edhill 1.71 -bash NAME
560     Explicitly specify the Bourne or BASH shell to use
561    
562 edhill 1.41 While it is most often a single word, the "NAME" variables specified
563     above can in many cases be a space-delimited string such as:
564    
565     --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'
566     -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'
567     -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
568    
569     which, depending upon your shell, may need to be single-quoted.
570    
571     For more detailed genmake documentation, please see:
572    
573     http://mitgcm.org/devel_HOWTO/
574    
575     EOF
576    
577 edhill 1.1 exit 1
578     }
579    
580 edhill 1.31 # Build a CPP macro to automate calling C routines from FORTRAN
581     get_fortran_c_namemangling() {
582 edhill 1.89
583     #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
584     if test ! "x$FC_NAMEMANGLE" = x ; then
585     return 0
586     fi
587    
588 edhill 1.31 default_nm="#define FC_NAMEMANGLE(X) X ## _"
589    
590     cat > genmake_test.c <<EOF
591     void tcall( char * string ) { tsub( string ); }
592     EOF
593 edhill 1.39 $MAKE genmake_test.o >> genmake_warnings 2>&1
594 edhill 1.31 RETVAL=$?
595     if test "x$RETVAL" != x0 ; then
596     FC_NAMEMANGLE=$default_nm
597 edhill 1.39 cat <<EOF>> genmake_errors
598    
599     WARNING: C test compile fails
600     WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
601     WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
602     EOF
603 edhill 1.31 return 1
604     fi
605 edhill 1.91 c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
606 edhill 1.31 RETVAL=$?
607     if test "x$RETVAL" != x0 ; then
608     FC_NAMEMANGLE=$default_nm
609 edhill 1.39 cat <<EOF>> genmake_warnings
610    
611     WARNING: The "nm" command failed.
612     WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
613     WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
614     EOF
615 edhill 1.31 return 1
616     fi
617 edhill 1.118 cat > genmake_tcomp.$FS <<EOF
618 edhill 1.31 subroutine tcall( string )
619     character*(*) string
620     call tsub( string )
621     end
622     EOF
623 edhill 1.134 $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
624 edhill 1.31 RETVAL=$?
625     if test "x$RETVAL" != x0 ; then
626     FC_NAMEMANGLE=$default_nm
627 edhill 1.39 cat <<EOF>> genmake_warnings
628    
629     WARNING: FORTRAN test compile fails -- please see "genmake_errors"
630     WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
631     WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
632     EOF
633 edhill 1.31 return 1
634     fi
635 edhill 1.91 f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
636 edhill 1.31 RETVAL=$?
637     if test "x$RETVAL" != x0 ; then
638     FC_NAMEMANGLE=$default_nm
639 edhill 1.39 cat <<EOF>> genmake_warnings
640    
641     WARNING: The "nm" command failed.
642     WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
643     WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
644     EOF
645 edhill 1.31 return 1
646     fi
647    
648     c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
649     f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
650     c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
651     f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
652    
653     nmangle="X"
654     if test "x$c_a" != "x$f_a" ; then
655     comm="echo x$f_a | sed -e 's|x$c_a||'"
656     a=`eval $comm`
657     nmangle="$a ## $nmangle"
658     fi
659     if test "x$c_b" != "x$f_b" ; then
660     comm="echo x$f_b | sed -e 's|x$c_b||'"
661     b=`eval $comm`
662     nmangle="$nmangle ## $b"
663     fi
664    
665     FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle"
666 edhill 1.32
667     # cleanup the testing files
668     rm -f genmake_tcomp.* genmake_test.*
669 edhill 1.31 }
670 edhill 1.1
671 edhill 1.39
672     check_HAVE_CLOC() {
673     get_fortran_c_namemangling
674     cat <<EOF > genmake_tc_1.c
675     $FC_NAMEMANGLE
676     #include <stdio.h>
677     #include <stdlib.h>
678     #include <unistd.h>
679     #include <assert.h>
680     #include <sys/time.h>
681     void FC_NAMEMANGLE(cloc) ( double *curtim )
682     {
683     struct timeval tv1;
684     gettimeofday(&tv1 , (void *)NULL );
685     *curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
686     *curtim = *curtim/1.E6;
687     }
688     EOF
689 edhill 1.118 make genmake_tc_1.o >> genmake_warnings 2>&1
690 edhill 1.39 RET_C=$?
691 edhill 1.118 cat <<EOF > genmake_tc_2.$FS
692 edhill 1.39 program hello
693 edhill 1.129 REAL*8 wtime
694 edhill 1.39 external cloc
695     call cloc(wtime)
696     print *," HELLO WORLD", wtime
697 edhill 1.128 end
698 edhill 1.39 EOF
699 edhill 1.118 $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
700 edhill 1.39 RET_F=$?
701 edhill 1.118 test -x ./genmake_tc && ./genmake_tc >> genmake_warnings 2>&1
702 edhill 1.39 RETVAL=$?
703     if test "x$RETVAL" = x0 ; then
704     HAVE_CLOC=t
705     DEFINES="$DEFINES -DHAVE_CLOC"
706     fi
707     rm -f genmake_tc*
708     }
709    
710    
711 edhill 1.137 check_HAVE_SIGREG() {
712     get_fortran_c_namemangling
713     cat <<EOF > genmake_tc_1.c
714     $FC_NAMEMANGLE
715     #include <stdlib.h>
716     #include <stdio.h>
717     #include <signal.h>
718     #include <errno.h>
719     #include <ucontext.h>
720    
721     int * ip;
722    
723     static void killhandler(
724     unsigned int sn, siginfo_t si, struct ucontext *sc )
725     {
726     *ip = *ip + 1;
727     return;
728     }
729    
730     void FC_NAMEMANGLE(sigreg) (int * aip)
731     {
732 edhill 1.138 struct sigaction s;
733 edhill 1.137 ip = aip;
734     s.sa_flags = SA_SIGINFO;
735     s.sa_sigaction = (void *)killhandler;
736     if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
737     printf("Sigaction returned error = %d\n", errno);
738     exit(0);
739     }
740     return;
741     }
742     EOF
743     make genmake_tc_1.o >> genmake_warnings 2>&1
744     RET_C=$?
745     cat <<EOF > genmake_tc_2.$FS
746     program hello
747     integer anint
748     common /iv/ anint
749     external sigreg
750     call sigreg(anint)
751     end
752     EOF
753     echo >> genmake_warnings
754     echo "running: check_HAVE_SIGREG()" >> genmake_warnings
755     cat genmake_tc_2.$FS >> genmake_warnings
756     COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
757     echo $COMM >> genmake_warnings
758     $COMM >> genmake_warnings 2>&1
759     RETVAL=$?
760     if test "x$RETVAL" = x0 ; then
761     HAVE_SIGREG=t
762     DEFINES="$DEFINES -DHAVE_SIGREG"
763     fi
764     rm -f genmake_tc*
765     }
766    
767    
768 edhill 1.130 check_HAVE_SETRLSTK() {
769     get_fortran_c_namemangling
770     cat <<EOF > genmake_tc_1.c
771     $FC_NAMEMANGLE
772     #include <sys/time.h>
773     #include <sys/resource.h>
774     #include <unistd.h>
775     void FC_NAMEMANGLE(setrlstk) ()
776     {
777     struct rlimit rls;
778     rls.rlim_cur = RLIM_INFINITY;
779     rls.rlim_max = RLIM_INFINITY;
780     setrlimit(RLIMIT_STACK, &rls);
781     return;
782     }
783     EOF
784     make genmake_tc_1.o >> genmake_warnings 2>&1
785     RET_C=$?
786     cat <<EOF > genmake_tc_2.$FS
787     program hello
788     external setrlstk
789     call setrlstk()
790     end
791     EOF
792 edhill 1.135 echo >> genmake_warnings
793     echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
794     cat genmake_tc_2.$FS >> genmake_warnings
795     COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
796     echo $COMM >> genmake_warnings
797     $COMM >> genmake_warnings 2>&1
798 edhill 1.130 RETVAL=$?
799     if test "x$RETVAL" = x0 ; then
800     HAVE_SETRLSTK=t
801     DEFINES="$DEFINES -DHAVE_SETRLSTK"
802     fi
803     rm -f genmake_tc*
804     }
805    
806    
807 edhill 1.108 check_HAVE_STAT() {
808     get_fortran_c_namemangling
809     cat <<EOF > genmake_tc_1.c
810     $FC_NAMEMANGLE
811     #include <stdio.h>
812     #include <stdlib.h>
813     #include <unistd.h>
814     #include <sys/stat.h>
815     #include <sys/types.h>
816     void FC_NAMEMANGLE(tfsize) ( int *nbyte )
817     {
818     char name[512];
819     struct stat astat;
820    
821     name[0] = 'a'; name[1] = '\0';
822     if (! stat(name, &astat))
823     *nbyte = (int)(astat.st_size);
824     else
825     *nbyte = -1;
826     }
827     EOF
828     make genmake_tc_1.o >> genmake_tc.log 2>&1
829     RET_C=$?
830 edhill 1.118 cat <<EOF > genmake_tc_2.$FS
831 edhill 1.108 program hello
832     integer nbyte
833     call tfsize(nbyte)
834     print *," HELLO WORLD", nbyte
835 edhill 1.128 end
836 edhill 1.108 EOF
837 edhill 1.135 echo >> genmake_warnings
838     echo "running: check_HAVE_STAT()" >> genmake_warnings
839     cat genmake_tc_2.$FS >> genmake_warnings
840     COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
841     echo $COMM >> genmake_warnings
842     $COMM >> genmake_tc.log 2>&1
843 edhill 1.108 RETVAL=$?
844     if test "x$RETVAL" = x0 ; then
845     HAVE_STAT=t
846     DEFINES="$DEFINES -DHAVE_STAT"
847     fi
848     rm -f genmake_tc*
849     }
850    
851    
852 edhill 1.60 check_netcdf_libs() {
853 edhill 1.113 if test ! "x$SKIP_NETCDF_CHECK" = x ; then
854     return
855     fi
856 edhill 1.135 echo >> genmake_warnings
857     echo "running: check_netcdf_libs()" >> genmake_warnings
858 edhill 1.117 cat <<EOF > genmake_tnc.F
859 edhill 1.60 program fgennc
860     #include "netcdf.inc"
861 edhill 1.113 EOF
862     if test ! "x$MPI" = x ; then
863 edhill 1.117 echo '#include "mpif.h"' >> genmake_tnc.F
864 edhill 1.113 fi
865 edhill 1.117 cat <<EOF >> genmake_tnc.F
866 edhill 1.60 integer iret, ncid, xid
867     iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
868     IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
869     iret = nf_def_dim(ncid, 'X', 11, xid)
870     IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
871     iret = nf_close(ncid)
872     IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
873     end
874     EOF
875 edhill 1.135 echo "=== genmake_tnc.F ===" > genmake_tnc.log
876     cat genmake_tnc.F >> genmake_tnc.log
877     echo "=== genmake_tnc.F ===" >> genmake_tnc.log
878 edhill 1.111 RET_CPP=f
879 edhill 1.135 COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
880     echo "$COMM" >> genmake_tnc.log
881     $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t
882 edhill 1.111 if test "x$RET_CPP" = xf ; then
883     echo " WARNING: CPP failed to pre-process the netcdf test." \
884 edhill 1.133 >> genmake_tnc.log
885 edhill 1.111 echo " Please check that \$INCLUDES is properly set." \
886 edhill 1.133 >> genmake_tnc.log
887 edhill 1.111 fi
888 edhill 1.135 echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
889     echo " && $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
890 edhill 1.117 $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
891 edhill 1.96 && $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
892 edhill 1.60 RET_COMPILE=$?
893 edhill 1.135 cat genmake_tnc.log >> genmake_warnings
894 edhill 1.99
895     #EH3 Remove test program execution for machines that either disallow
896     #EH3 execution or cannot support it (eg. cross-compilers)
897     #EH3
898     #EH3 test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1
899     #EH3 RETVAL=$?
900     #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
901    
902     if test "x$RET_COMPILE" = x0 ; then
903 edhill 1.60 HAVE_NETCDF=t
904     else
905 edhill 1.66 # try again with "-lnetcdf" added to the libs
906 edhill 1.135 echo "try again with added '-lnetcdf'" > genmake_tnc.log
907 edhill 1.133 echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
908     echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
909     echo " && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
910 edhill 1.117 $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null \
911     && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
912 edhill 1.99 && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
913 edhill 1.66 RET_COMPILE=$?
914 edhill 1.135 cat genmake_tnc.log >> genmake_warnings
915 edhill 1.99 if test "x$RET_COMPILE" = x0 ; then
916 edhill 1.66 LIBS="$LIBS -lnetcdf"
917     HAVE_NETCDF=t
918     fi
919 edhill 1.60 fi
920     rm -f genmake_tnc*
921     }
922    
923    
924 adcroft 1.67
925     ###############################################################################
926     # Sequential part of script starts here
927     ###############################################################################
928    
929 edhill 1.1 # Set defaults here
930 edhill 1.5 COMMANDL="$0 $@"
931    
932 edhill 1.1 PLATFORM=
933     LN=
934     S64=
935     KPP=
936 edhill 1.114 #FC=
937 edhill 1.93 #CC=gcc
938 edhill 1.114 #CPP=
939 edhill 1.1 LINK=
940 edhill 1.31 DEFINES=
941 edhill 1.1 PACKAGES=
942     ENABLE=
943     DISABLE=
944 edhill 1.119 # MAKEFILE=
945     # MAKEDEPEND=
946 edhill 1.1 PDEPEND=
947 edhill 1.11 DUMPSTATE=t
948 edhill 1.1 PDEFAULT=
949     OPTFILE=
950 edhill 1.111 INCLUDES="-I. $INCLUDES"
951 edhill 1.1 FFLAGS=
952     FOPTIM=
953     CFLAGS=
954     KFLAGS1=
955     KFLAGS2=
956 edhill 1.70 #LDADD=
957 edhill 1.1 LIBS=
958     KPPFILES=
959     NOOPTFILES=
960     NOOPTFLAGS=
961 adcroft 1.67 MPI=
962     MPIPATH=
963 ce107 1.126 TS=
964 ce107 1.139 PAPIS=
965     FOOLAD=
966     PAPI=
967     HPMT=
968     GSL=
969 edhill 1.131 HAVE_TEST_L=
970 edhill 1.1
971 edhill 1.124 # DEFINES checked by test compilation or command-line
972 edhill 1.29 HAVE_SYSTEM=
973     HAVE_FDATE=
974     FC_NAMEMANGLE=
975 edhill 1.39 HAVE_CLOC=
976 edhill 1.130 HAVE_SETRLSTK=
977 edhill 1.108 HAVE_STAT=
978 edhill 1.60 HAVE_NETCDF=
979 cnh 1.81 HAVE_ETIME=
980 edhill 1.124 IGNORE_TIME=
981 edhill 1.29
982 edhill 1.1 MODS=
983     TOOLSDIR=
984     SOURCEDIRS=
985     INCLUDEDIRS=
986 edhill 1.57 STANDARDDIRS="USE_THE_DEFAULT"
987 edhill 1.1
988 edhill 1.73 G2ARGS=
989 edhill 1.71 BASH=
990 edhill 1.1 PWD=`pwd`
991 edhill 1.114 test "x$MAKE" = x && MAKE=make
992     test "x$AWK" = x && AWK=awk
993 edhill 1.97 THISHOST=`hostname`
994 edhill 1.1 THISCWD=`pwd`
995     THISDATE=`date`
996 edhill 1.97 THISUSER=`echo $USER`
997     THISVER=
998 edhill 1.1 MACHINE=`uname -a`
999 edhill 1.7 EXECUTABLE=
1000     EXEHOOK=
1001     EXEDIR=
1002 edhill 1.12 PACKAGES_CONF=
1003     IEEE=
1004     if test "x$MITGCM_IEEE" != x ; then
1005     IEEE=$MITGCM_IEEE
1006     fi
1007 edhill 1.76 FS=
1008     FS90=
1009 edhill 1.1
1010 edhill 1.14 AUTODIFF_PKG_USED=f
1011     AD_OPTFILE=
1012 edhill 1.17 TAF=
1013     AD_TAF_FLAGS=
1014     FTL_TAF_FLAGS=
1015     SVD_TAF_FLAGS=
1016     TAF_EXTRA=
1017     TAMC=
1018     AD_TAMC_FLAGS=
1019     FTL_TAF_FLAGS=
1020     SVD_TAMC_FLAGS=
1021     TAMC_EXTRA=
1022    
1023 edhill 1.14
1024 edhill 1.5 # The following state can be set directly by command-line switches
1025 edhill 1.41 gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1026 ce107 1.139 gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"
1027 edhill 1.5
1028     # The following state is not directly set by command-line switches
1029     gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
1030     gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
1031 edhill 1.97 gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
1032 edhill 1.12 gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
1033 cnh 1.81 gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
1034 edhill 1.5
1035 edhill 1.14 # The following are all related to adjoint/tangent-linear stuff
1036 edhill 1.29 gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1037     gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1038     gm_s12="TAF_EXTRA TAMC_EXTRA"
1039 edhill 1.14
1040 edhill 1.29 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
1041     gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1042 edhill 1.5
1043 edhill 1.41 cat <<EOF
1044    
1045     GENMAKE :
1046    
1047     A program for GENerating MAKEfiles for the MITgcm project. For a
1048     quick list of options, use "genmake -h" or for more detail see:
1049    
1050     http://mitgcm.org/devel_HOWTO/
1051    
1052     EOF
1053 edhill 1.5
1054 edhill 1.2 echo "=== Processing options files and arguments ==="
1055 edhill 1.12 gm_local="genmake_local"
1056     for i in . $MODS ; do
1057     if test -r $i/$gm_local ; then
1058 edhill 1.34 . $i/$gm_local
1059 edhill 1.12 break
1060     fi
1061     done
1062 edhill 1.71 printf " getting local config information: "
1063 edhill 1.88 if test -f $gm_local ; then
1064 edhill 1.1 echo "using $gm_local"
1065 edhill 1.34 . $gm_local
1066 edhill 1.2 # echo "DISABLE=$DISABLE"
1067     # echo "ENABLE=$ENABLE"
1068 edhill 1.1 else
1069     echo "none found"
1070     fi
1071    
1072 edhill 1.103 #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1073 edhill 1.2 #OPTIONS=
1074     #n=0
1075     #for i ; do
1076     # echo "$i $n"
1077     # setvar="OPTIONS[$n]='$i'"
1078     # # echo " $setvar"
1079     # eval "$setvar"
1080     # n=$(( $n + 1 ))
1081     #done
1082     #parse_options
1083     ac_prev=
1084 edhill 1.102 for ac_option in "$@" ; do
1085 edhill 1.2
1086 edhill 1.73 G2ARGS="$G2ARGS \"$ac_option\""
1087    
1088 edhill 1.2 # If the previous option needs an argument, assign it.
1089     if test -n "$ac_prev"; then
1090     eval "$ac_prev=\$ac_option"
1091     ac_prev=
1092     continue
1093     fi
1094    
1095     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1096    
1097     case $ac_option in
1098    
1099     -help | --help | -h | --h)
1100     usage ;;
1101    
1102     -nooptfile | --nooptfile)
1103     OPTFILE="NONE" ;;
1104     -optfile | --optfile | -of | --of)
1105 edhill 1.4 ac_prev=OPTFILE ;;
1106 edhill 1.2 -optfile=* | --optfile=* | -of=* | --of=*)
1107     OPTFILE=$ac_optarg ;;
1108    
1109 edhill 1.50 -adoptfile | --adoptfile | -adof | --adof)
1110 edhill 1.14 ac_prev=AD_OPTFILE ;;
1111     -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1112     AD_OPTFILE=$ac_optarg ;;
1113    
1114 edhill 1.2 -pdepend | --pdepend)
1115 edhill 1.4 ac_prev=PDEPEND ;;
1116 edhill 1.2 -pdepend=* | --pdepend=*)
1117     PDEPEND=$ac_optarg ;;
1118    
1119     -pdefault | --pdefault)
1120 edhill 1.4 ac_prev=PDEFAULT ;;
1121 edhill 1.2 -pdefault=* | --pdefault=*)
1122     PDEFAULT=$ac_optarg ;;
1123    
1124 edhill 1.6 -make | --make | -m | --m)
1125     ac_prev=MAKE ;;
1126     -make=* | --make=* | -m=* | --m=*)
1127     MAKE=$ac_optarg ;;
1128 edhill 1.69
1129 edhill 1.71 -bash | --bash)
1130     ac_prev=BASH ;;
1131     -bash=* | --bash=*)
1132     BASH=$ac_optarg ;;
1133    
1134 edhill 1.69 -makedepend | --makedepend | -md | --md)
1135     ac_prev=MAKEDEPEND ;;
1136     -makedepend=* | --makedepend=* | -md=* | --md=*)
1137     MAKEDEPEND=$ac_optarg ;;
1138 edhill 1.6
1139     -makefile | --makefile | -ma | --ma)
1140 edhill 1.4 ac_prev=MAKEFILE ;;
1141 edhill 1.6 -makefile=* | --makefile=* | -ma=* | --ma=*)
1142 edhill 1.2 MAKEFILE=$ac_optarg ;;
1143    
1144 edhill 1.41 -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1145     echo "ERROR: The platform option has been removed. Please specify"
1146     echo " the build options using the \"optfile\" mechanism."
1147     echo
1148     usage
1149     ;;
1150 edhill 1.2
1151     -rootdir | --rootdir | -rd | --rd)
1152 edhill 1.4 ac_prev=ROOTDIR ;;
1153 edhill 1.2 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1154     ROOTDIR=$ac_optarg ;;
1155    
1156     -mods | --mods | -mo | --mo)
1157 edhill 1.4 ac_prev=MODS ;;
1158 edhill 1.2 -mods=* | --mods=* | -mo=* | --mo=*)
1159     MODS=$ac_optarg ;;
1160    
1161     -disable | --disable)
1162 edhill 1.4 ac_prev=DISABLE ;;
1163 edhill 1.2 -disable=* | --disable=*)
1164     DISABLE=$ac_optarg ;;
1165    
1166     -enable | --enable)
1167 edhill 1.4 ac_prev=ENABLE ;;
1168 edhill 1.2 -enable=* | --enable=*)
1169     ENABLE=$ac_optarg ;;
1170    
1171 edhill 1.12 -standarddirs | --standarddirs)
1172     ac_prev=STANDARDDIRS ;;
1173     -standarddirs=* | --standarddirs=*)
1174     STANDARDDIRS=$ac_optarg ;;
1175    
1176 edhill 1.2 # -cpp | --cpp)
1177     # ac_prev=cpp ;;
1178     # -cpp=* | --cpp=*)
1179     # CPP=$ac_optarg ;;
1180 edhill 1.91
1181     -cc | --cc)
1182     ac_prev=CC ;;
1183     -cc=* | --cc=*)
1184     CC=$ac_optarg ;;
1185    
1186 edhill 1.2 -fortran | --fortran | -fc | --fc)
1187 edhill 1.4 ac_prev=FC ;;
1188 edhill 1.2 -fc=* | --fc=*)
1189     FC=$ac_optarg ;;
1190    
1191 edhill 1.76 -fs | --fs)
1192     ac_prev=FS ;;
1193     -fs=* | --fs=*)
1194     FS=$ac_optarg ;;
1195    
1196     -fs90 | --fs90)
1197     ac_prev=FS90 ;;
1198     -fs90=* | --fs90=*)
1199     FS90=$ac_optarg ;;
1200    
1201 edhill 1.2 -ieee | --ieee)
1202 edhill 1.12 IEEE=true ;;
1203 edhill 1.2 -noieee | --noieee)
1204 edhill 1.12 IEEE= ;;
1205 adcroft 1.67
1206 ce107 1.126 -ts | --ts)
1207     TS=true ;;
1208 ce107 1.139 -papis | --papis)
1209     PAPIS=true ;;
1210     -foolad | --foolad)
1211     FOOLAD=true ;;
1212     -papi | --papi)
1213     PAPI=true ;;
1214     -hpmt | --hpmt)
1215     HPMT=true ;;
1216    
1217     -gsl | --gsl)
1218     GSL=true ;;
1219 ce107 1.126
1220 adcroft 1.67 -mpi | --mpi)
1221     MPI=true ;;
1222     -mpi=* | --mpi=*)
1223     MPIPATH=$ac_optarg
1224     MPI=true ;;
1225 edhill 1.2
1226 edhill 1.41 # -jam | --jam)
1227     # JAM=1 ;;
1228     # -nojam | --nojam)
1229     # JAM=0 ;;
1230 edhill 1.2
1231 edhill 1.5 -ds | --ds)
1232     DUMPSTATE=t ;;
1233    
1234 edhill 1.17 -taf_extra | --taf_extra)
1235     ac_prev=TAF_EXTRA ;;
1236     -taf_extra=* | --taf_extra=*)
1237     TAF_EXTRA=$ac_optarg ;;
1238    
1239     -tamc_extra | --tamc_extra)
1240     ac_prev=TAMC_EXTRA ;;
1241     -tamc_extra=* | --tamc_extra=*)
1242     TAMC_EXTRA=$ac_optarg ;;
1243 edhill 1.124
1244     -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1245     IGNORE_TIME="-DIGNORE_TIME" ;;
1246 edhill 1.17
1247 edhill 1.2 -*)
1248     echo "Error: unrecognized option: "$ac_option
1249     usage
1250     ;;
1251    
1252     *)
1253     echo "Error: unrecognized argument: "$ac_option
1254     usage
1255     ;;
1256    
1257     esac
1258    
1259 edhill 1.1 done
1260    
1261 edhill 1.119
1262 edhill 1.12 if test -f ./.genmakerc ; then
1263     echo
1264     echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1265     echo " file. This file format is no longer supported. Please see:"
1266     echo
1267     echo " http://mitgcm.org/devel_HOWTO/"
1268     echo
1269     echo " for directions on how to setup and use the new \"genmake2\" input"
1270     echo " files and send an email to MITgcm-support@mitgcm.org if you want help."
1271     echo
1272     fi
1273    
1274 edhill 1.97 # Find the MITgcm ${ROOTDIR}
1275 edhill 1.11 if test "x${ROOTDIR}" = x ; then
1276 edhill 1.112 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1277 edhill 1.87 if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1278 edhill 1.11 ROOTDIR=".."
1279     else
1280     for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1281     if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1282     ROOTDIR=$d
1283 edhill 1.71 printf "Warning: ROOTDIR was not specified but there appears to be"
1284 edhill 1.11 echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
1285     break
1286     fi
1287     done
1288     fi
1289     fi
1290     if test "x${ROOTDIR}" = x ; then
1291     echo "Error: Cannot determine ROOTDIR for MITgcm code."
1292     echo " Please specify a ROOTDIR using either an options "
1293     echo " file or a command-line option."
1294     exit 1
1295     fi
1296     if test ! -d ${ROOTDIR} ; then
1297     echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
1298     exit 1
1299     fi
1300    
1301 edhill 1.97 # Find the MITgcm ${THISVER}
1302     if test -f "${ROOTDIR}/doc/tag-index" ; then
1303 edhill 1.125 THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1304 edhill 1.97 fi
1305    
1306 edhill 1.119 if test "x$MAKEFILE" = x ; then
1307     MAKEFILE="Makefile"
1308     fi
1309    
1310 edhill 1.1 echo " getting OPTFILE information: "
1311     if test "x${OPTFILE}" = x ; then
1312 edhill 1.11 if test "x$MITGCM_OF" = x ; then
1313     echo "Warning: no OPTFILE specified so we'll look for possible settings"
1314     printf "\n=== Searching for possible settings for OPTFILE ===\n"
1315     find_possible_configs
1316 edhill 1.1 else
1317 edhill 1.11 OPTFILE=$MITGCM_OF
1318     fi
1319     fi
1320     if test "x$OPTFILE" != xNONE ; then
1321     if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
1322     echo " using OPTFILE=\"$OPTFILE\""
1323 edhill 1.34 . "$OPTFILE"
1324 edhill 1.11 RETVAL=$?
1325     if test "x$RETVAL" != x0 ; then
1326 edhill 1.71 printf "Error: failed to source OPTFILE \"$OPTFILE\""
1327 edhill 1.11 echo "--please check that variable syntax is bash-compatible"
1328 edhill 1.1 exit 1
1329     fi
1330 edhill 1.11 if test "x$DUMPSTATE" != xf ; then
1331 edhill 1.12 cp -f $OPTFILE "genmake_optfile"
1332 edhill 1.11 fi
1333     else
1334     echo "Error: can't read OPTFILE=\"$OPTFILE\""
1335     exit 1
1336 edhill 1.1 fi
1337     fi
1338 edhill 1.8
1339 edhill 1.14 echo " getting AD_OPTFILE information: "
1340     if test "x${AD_OPTFILE}" = x ; then
1341     if test "x$MITGCM_AD_OF" = x ; then
1342     AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1343     else
1344     AD_OPTFILE=$MITGCM_AD_OF
1345     fi
1346     fi
1347     if test "x${AD_OPTFILE}" != xNONE ; then
1348     if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
1349     echo " using AD_OPTFILE=\"$AD_OPTFILE\""
1350 edhill 1.34 . "$AD_OPTFILE"
1351 edhill 1.14 RETVAL=$?
1352     if test "x$RETVAL" != x0 ; then
1353 edhill 1.71 printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1354 edhill 1.14 echo "--please check that variable syntax is bash-compatible"
1355     exit 1
1356     fi
1357     if test "x$DUMPSTATE" != xf ; then
1358     cp -f $AD_OPTFILE "genmake_ad_optfile"
1359     fi
1360     else
1361     echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
1362     exit 1
1363     fi
1364     fi
1365    
1366 edhill 1.119 #====================================================================
1367     # Set default values if not set by the optfile
1368     #
1369 edhill 1.91 # Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not,
1370 edhill 1.39 # either set defaults or complain and abort!
1371 edhill 1.71 if test ! "x$BASH" = x ; then
1372     # add a trailing space so that it works within the Makefile syntax (see below)
1373     BASH="$BASH "
1374     fi
1375 edhill 1.8 if test "x$FC" = x ; then
1376     cat <<EOF 1>&2
1377    
1378     Error: no Fortran compiler: please specify using one of the following:
1379     1) within the options file ("FC=...") as specified by "-of=OPTFILE"
1380     2) the "-fc=XXX" command-line option
1381 edhill 1.12 3) the "./genmake_local" file
1382 edhill 1.8 EOF
1383     exit 1
1384     fi
1385 edhill 1.91 if test "x$CC" = x ; then
1386 edhill 1.93 CC=cc
1387     # cat <<EOF 1>&2
1388     # Error: no C compiler: please specify using one of the following:
1389     # 1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1390     # 2) the "-cc=XXX" command-line option
1391     # 3) the "./genmake_local" file
1392     # EOF
1393     # exit 1
1394 edhill 1.91 fi
1395 edhill 1.8 if test "x$LINK" = x ; then
1396     LINK=$FC
1397     fi
1398 edhill 1.39 if test "x$MAKE" = x ; then
1399     MAKE="make"
1400     fi
1401 edhill 1.63 if test "x$CPP" = x ; then
1402     CPP=cpp
1403     fi
1404     #EH3 === UGLY ===
1405 edhill 1.76 # The following is an ugly little hack to check for $CPP in /lib/ and
1406     # it should eventually be replaced with a more general function that
1407 edhill 1.63 # searches a combo of the user's path and a list of "usual suspects"
1408     # to find the correct location for binaries such as $CPP.
1409     for i in " " "/lib/" ; do
1410     echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1411     done
1412     #EH3 === UGLY ===
1413 edhill 1.13 echo "#define A a" | $CPP > test_cpp 2>&1
1414 edhill 1.11 RETVAL=$?
1415     if test "x$RETVAL" != x0 ; then
1416 edhill 1.8 cat <<EOF 1>&2
1417    
1418 edhill 1.11 Error: C pre-processor "$CPP" failed the test case: please specify using:
1419    
1420 edhill 1.8 1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
1421 edhill 1.12 2) the "./genmake_local" file
1422 edhill 1.30 3) with the CPP environment variable
1423 edhill 1.11
1424 edhill 1.8 EOF
1425     exit 1
1426 edhill 1.11 else
1427     rm -f test_cpp
1428 edhill 1.8 fi
1429 edhill 1.84 look_for_makedepend
1430 edhill 1.35 if test "x$LN" = x ; then
1431     LN="ln -s"
1432     fi
1433     echo "test" > genmake_test_ln
1434     $LN genmake_test_ln genmake_tlink
1435     RETVAL=$?
1436     if test "x$RETVAL" != x0 ; then
1437     cat <<EOF 1>&2
1438 edhill 1.29
1439 edhill 1.35 Error: The command "ln -s" failed -- please specify a working soft-link
1440     command in the optfile.
1441    
1442     EOF
1443     exit 1
1444     fi
1445 edhill 1.131 test -L genmake_tlink > /dev/null 2>&1
1446     RETVAL=$?
1447     if test "x$RETVAL" = x0 ; then
1448     HAVE_TEST_L=t
1449     fi
1450 edhill 1.35 rm -f genmake_test_ln genmake_tlink
1451 edhill 1.77
1452     # Check for broken *.F/*.f handling and fix if possible
1453     check_for_broken_Ff
1454 edhill 1.29
1455 adcroft 1.67 if test ! "x$MPI" = x ; then
1456     echo " Turning on MPI cpp macros"
1457 adcroft 1.68 DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1458 adcroft 1.67 fi
1459 edhill 1.39
1460 ce107 1.126 if test ! "x$TS" = x ; then
1461     echo " Turning on timing per timestep"
1462 ce107 1.139 if test ! "x$FOOLAD" = x ; then
1463     DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1464     else
1465     DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1466     fi
1467     fi
1468     if test ! "x$PAPIS" = x ; then
1469     echo " Turning on PAPI flop summary per timestep"
1470     echo " Please make sure PAPIINC, PAPILIB are defined"
1471     if test ! "x$FOOLAD" = x ; then
1472     DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1473     else
1474     DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1475     fi
1476     INCLUDES="$INCLUDES $PAPIINC"
1477     LIBS="$LIBS $PAPILIB"
1478     fi
1479     if test ! "x$PAPI" = x ; then
1480     if test ! "x$PAPIS" = x ; then
1481     echo " PAPI performance analysis and flop summary per timestep cannot co-exist!"
1482     echo " Sticking with PAPI flop summary per timestep!"
1483     else
1484     echo " Turning on performance analysis with PAPI"
1485     echo " Please make sure PAPIINC, PAPILIB are defined"
1486     DEFINES="$DEFINES -DUSE_PAPI"
1487     INCLUDES="$INCLUDES $PAPIINC"
1488     LIBS="$LIBS $PAPILIB"
1489     fi
1490     fi
1491     if test ! "x$HPMT" = x ; then
1492     if test ! "x$PAPI" = x ; then
1493     echo " PAPI and the HPM Toolkit cannot co-exist!"
1494     echo " Sticking with PAPI!"
1495     else
1496     echo " Turning on performance analysis with the HPM Toolkit"
1497     echo " Please make sure HPMTINC, HPMTLIB are defined"
1498     DEFINES="$DEFINES -DUSE_LIBHPM"
1499     INCLUDES="$INCLUDES $HPMTINC"
1500     LIBS="$LIBS $HPMTLIB"
1501     fi
1502     fi
1503     if test ! "x$GSL" = x ; then
1504     echo " Turning on use of GSL to control floating point calculations"
1505     echo " Please make sure GSLINC, GSLLIB are defined"
1506     DEFINES="$DEFINES -DUSE_GSL_IEEE"
1507     INCLUDES="$INCLUDES $GSLINC"
1508     LIBS="$LIBS $GSLLIB"
1509 ce107 1.126 fi
1510    
1511 edhill 1.29 printf "\n=== Checking system libraries ===\n"
1512 edhill 1.71 printf " Do we have the system() command using $FC... "
1513 edhill 1.118 cat > genmake_tcomp.$FS <<EOF
1514 edhill 1.29 program hello
1515     call system('echo hi')
1516     end
1517     EOF
1518 edhill 1.134 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1519 edhill 1.29 RETVAL=$?
1520     if test "x$RETVAL" = x0 ; then
1521     HAVE_SYSTEM=t
1522     DEFINES="$DEFINES -DHAVE_SYSTEM"
1523     echo "yes"
1524     else
1525     HAVE_SYSTEM=
1526     echo "no"
1527     fi
1528     rm -f genmake_tcomp*
1529    
1530 edhill 1.71 printf " Do we have the fdate() command using $FC... "
1531 edhill 1.118 cat > genmake_tcomp.$FS <<EOF
1532 edhill 1.29 program hello
1533 edhill 1.129 CHARACTER*(128) string
1534 edhill 1.29 string = ' '
1535     call fdate( string )
1536     print *, string
1537     end
1538     EOF
1539 edhill 1.134 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1540 edhill 1.29 RETVAL=$?
1541     if test "x$RETVAL" = x0 ; then
1542     HAVE_FDATE=t
1543     DEFINES="$DEFINES -DHAVE_FDATE"
1544     echo "yes"
1545     else
1546     HAVE_FDATE=
1547     echo "no"
1548     fi
1549     rm -f genmake_tcomp*
1550    
1551 cnh 1.81 printf " Do we have the etime() command using $FC... "
1552 edhill 1.118 cat > genmake_tcomp.$FS <<EOF
1553 cnh 1.81 program hello
1554 cnh 1.82 REAL*4 ACTUAL, TARRAY(2)
1555     EXTERNAL ETIME
1556     REAL*4 ETIME
1557     actual = etime( tarray )
1558 cnh 1.81 print *, tarray
1559     end
1560     EOF
1561 edhill 1.134 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1562 cnh 1.81 RETVAL=$?
1563     if test "x$RETVAL" = x0 ; then
1564     HAVE_ETIME=t
1565     DEFINES="$DEFINES -DHAVE_ETIME"
1566     echo "yes"
1567     else
1568     HAVE_ETIME=
1569     echo "no"
1570     fi
1571     rm -f genmake_tcomp*
1572    
1573 edhill 1.71 printf " Can we call simple C routines (here, \"cloc()\") using $FC... "
1574 edhill 1.39 check_HAVE_CLOC
1575     if test "x$HAVE_CLOC" != x ; then
1576     echo "yes"
1577     else
1578     echo "no"
1579 edhill 1.29 fi
1580 edhill 1.39 rm -f genmake_t*
1581 edhill 1.29
1582 edhill 1.130 printf " Can we unlimit the stack size using $FC... "
1583     check_HAVE_SETRLSTK
1584     if test "x$HAVE_SETRLSTK" != x ; then
1585     echo "yes"
1586     else
1587     echo "no"
1588     fi
1589     rm -f genmake_t*
1590    
1591 edhill 1.137 printf " Can we register a signal handler using $FC... "
1592     check_HAVE_SIGREG
1593     if test "x$HAVE_SIGREG" != x ; then
1594     echo "yes"
1595     else
1596     echo "no"
1597     fi
1598     rm -f genmake_t*
1599    
1600 edhill 1.108 printf " Can we use stat() through C calls... "
1601     check_HAVE_STAT
1602     if test "x$HAVE_STAT" != x ; then
1603     echo "yes"
1604     else
1605     echo "no"
1606     fi
1607     rm -f genmake_t*
1608    
1609 edhill 1.71 printf " Can we create NetCDF-enabled binaries... "
1610 edhill 1.60 check_netcdf_libs
1611     if test "x$HAVE_NETCDF" != x ; then
1612     echo "yes"
1613     else
1614     echo "no"
1615     fi
1616 edhill 1.124 DEFINES="$DEFINES $IGNORE_TIME"
1617 edhill 1.8
1618 edhill 1.2 printf "\n=== Setting defaults ===\n"
1619 edhill 1.71 printf " Adding MODS directories: "
1620 edhill 1.1 for d in $MODS ; do
1621     if test ! -d $d ; then
1622 edhill 1.2 echo
1623     echo "Error: MODS directory \"$d\" not found!"
1624 edhill 1.1 exit 1
1625     else
1626 edhill 1.71 printf " $d"
1627 edhill 1.1 SOURCEDIRS="$SOURCEDIRS $d"
1628     INCLUDEDIRS="$INCLUDEDIRS $d"
1629     fi
1630     done
1631     echo
1632    
1633     if test "x${PLATFORM}" = x ; then
1634     PLATFORM=$p_PLATFORM
1635     fi
1636    
1637     if test "x${EXEDIR}" = x ; then
1638 edhill 1.112 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1639 edhill 1.87 if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1640 edhill 1.1 EXEDIR=../exe
1641     else
1642     EXEDIR=.
1643     fi
1644     fi
1645     if test ! -d ${EXEDIR} ; then
1646     echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
1647     exit 1
1648     fi
1649    
1650     if test "x${TOOLSDIR}" = x ; then
1651     TOOLSDIR="$ROOTDIR/tools"
1652     fi
1653     if test ! -d ${TOOLSDIR} ; then
1654 cnh 1.65 echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1655 edhill 1.1 exit 1
1656     fi
1657 edhill 1.11 if test "x$S64" = x ; then
1658 edhill 1.104 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1659     RETVAL=$?
1660     if test "x${RETVAL}" = x0 ; then
1661     S64='$(TOOLSDIR)/set64bitConst.sh'
1662     else
1663     echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1664     RETVAL=$?
1665     if test "x${RETVAL}" = x0 ; then
1666     S64='$(TOOLSDIR)/set64bitConst.csh'
1667     else
1668     cat <<EOF
1669    
1670     ERROR: neither of the two default scripts:
1671    
1672     ${TOOLSDIR}/set64bitConst.sh
1673     ${TOOLSDIR}/set64bitConst.csh
1674    
1675     are working so please check paths or specify (with \$S64) a
1676     working version of this script.
1677    
1678     EOF
1679     exit 1
1680     fi
1681     fi
1682 edhill 1.11 fi
1683 adcroft 1.44 THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1684 edhill 1.1
1685     EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1686    
1687     # We have a special set of source files in eesupp/src which are
1688     # generated from some template source files. We'll make them first so
1689     # they appear as regular source code
1690     if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1691     echo " Making source files in eesupp from templates"
1692 edhill 1.36 ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1
1693 edhill 1.1 RETVAL=$?
1694 edhill 1.2 if test "x${RETVAL}" = x0 ; then
1695 edhill 1.1 rm -f make_eesupp.errors
1696     else
1697     echo "Error: problem encountered while building source files in eesupp:"
1698 edhill 1.62 cat make_eesupp.errors 1>&2
1699 edhill 1.1 exit 1
1700 afe 1.58 fi
1701     fi
1702    
1703     #same for exch2
1704     if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1705     echo " Making source files in exch2 from templates"
1706     ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1707     RETVAL=$?
1708     if test "x${RETVAL}" = x0 ; then
1709     rm -f make_exch2.errors
1710     else
1711 edhill 1.59 echo "Error: problem encountered while building source files in exch2:"
1712 edhill 1.62 cat make_exch2.errors 1>&2
1713 afe 1.58 exit 1
1714 edhill 1.1 fi
1715     fi
1716    
1717 edhill 1.2 printf "\n=== Determining package settings ===\n"
1718 edhill 1.1 if test "x${PDEPEND}" = x ; then
1719     tmp=$ROOTDIR"/pkg/pkg_depend"
1720     if test -r $tmp ; then
1721     PDEPEND=$tmp
1722     else
1723     echo "Warning: No package dependency information was specified."
1724     echo " Please check that ROOTDIR/pkg/pkg_depend exists."
1725     fi
1726     else
1727     if test ! -r ${PDEPEND} ; then
1728     echo "Error: can't read package dependency info from PDEPEND=\"$PDEPEND\""
1729     exit 1
1730     fi
1731     fi
1732     echo " getting package dependency info from $PDEPEND"
1733     # Strip the comments and then convert the dependency file into
1734     # two arrays: PNAME, DNAME
1735     cat $PDEPEND | sed -e 's/#.*$//g' \
1736 edhill 1.15 | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
1737 edhill 1.1 > ./.pd_tmp
1738     RETVAL=$?
1739     if test ! "x${RETVAL}" = x0 ; then
1740     echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
1741     exit 1
1742     fi
1743 edhill 1.34 . ./.pd_tmp
1744 edhill 1.1 rm -f ./.pd_tmp
1745    
1746 edhill 1.12 # Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups"
1747     # file should eventually be added so that, for convenience, one can
1748     # specify groups of packages using names like "ocean" and "atmosphere".
1749 edhill 1.41 echo " checking default package list: "
1750 edhill 1.1 if test "x${PDEFAULT}" = x ; then
1751 edhill 1.12 for i in "." $MODS ; do
1752     if test -r $i"/packages.conf" ; then
1753     PDEFAULT=$i"/packages.conf"
1754     break
1755     fi
1756     done
1757     fi
1758     if test "x${PDEFAULT}" = x ; then
1759 edhill 1.1 PDEFAULT="$ROOTDIR/pkg/pkg_default"
1760     fi
1761     if test "x${PDEFAULT}" = xNONE ; then
1762 edhill 1.41 echo " default packages file disabled"
1763 edhill 1.1 else
1764     if test ! -r $PDEFAULT ; then
1765     echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\""
1766     else
1767 edhill 1.41 echo " using PDEFAULT=\"$PDEFAULT\""
1768 edhill 1.1 # Strip the comments and add all the names
1769 edhill 1.15 def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1770 edhill 1.1 RETVAL=$?
1771     if test "x${RETVAL}" != x0 ; then
1772 edhill 1.71 printf "Error: can't parse default package list "
1773 edhill 1.1 echo "-- please check PDEFAULT=\"$PDEFAULT\""
1774     exit 1
1775     fi
1776     for i in $def ; do
1777     PACKAGES="$PACKAGES $i"
1778     done
1779 edhill 1.12 echo " before group expansion packages are: $PACKAGES"
1780 edhill 1.87 RET=1
1781     while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1782 edhill 1.12 echo " after group expansion packages are: $PACKAGES"
1783 edhill 1.1 fi
1784     fi
1785    
1786     echo " applying DISABLE settings"
1787 adcroft 1.74 for i in $PACKAGES ; do
1788     echo $i >> ./.tmp_pack
1789     done
1790     for i in `grep "-" ./.tmp_pack` ; do
1791     j=`echo $i | sed 's/[-]//'`
1792     DISABLE="$DISABLE $j"
1793     done
1794 edhill 1.1 pack=
1795     for p in $PACKAGES ; do
1796     addit="t"
1797     for d in $DISABLE ; do
1798     if test "x$p" = "x$d" ; then
1799     addit="f"
1800     fi
1801     done
1802     if test "x$addit" = xt ; then
1803     pack="$pack $p"
1804     fi
1805     done
1806     PACKAGES="$pack"
1807     echo " applying ENABLE settings"
1808 edhill 1.12 echo "" > ./.tmp_pack
1809 edhill 1.1 PACKAGES="$PACKAGES $ENABLE"
1810 adcroft 1.74 # Test if each explicitly referenced package exists
1811 edhill 1.1 for i in $PACKAGES ; do
1812 adcroft 1.74 j=`echo $i | sed 's/[-+]//'`
1813     if test ! -d "$ROOTDIR/pkg/$j" ; then
1814 edhill 1.1 echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1815 adcroft 1.74 exit 1
1816 edhill 1.1 fi
1817     echo $i >> ./.tmp_pack
1818     done
1819     PACKAGES=
1820 adcroft 1.74 for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1821 edhill 1.1 PACKAGES="$PACKAGES $i"
1822     done
1823 adcroft 1.74 rm -f ./.tmp_pack
1824 edhill 1.1 echo " packages are: $PACKAGES"
1825    
1826 edhill 1.100 # Check availability of NetCDF and then either build the MNC template
1827     # files or delete mnc from the list of available packages.
1828     echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1829     RETVAL=$?
1830     if test "x$RETVAL" = x0 ; then
1831     if test "x$HAVE_NETCDF" != xt ; then
1832     cat <<EOF
1833    
1834     *********************************************************************
1835     WARNING: the "mnc" package was enabled but tests failed to compile
1836     NetCDF applications. Please check that:
1837    
1838     1) NetCDF is correctly installed for this compiler and
1839     2) the LIBS variable (within the "optfile") specifies the correct
1840     NetCDF library to link against.
1841    
1842     Due to this failure, the "mnc" package is now DISABLED.
1843     *********************************************************************
1844    
1845     EOF
1846     PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1847     DISABLE="$DISABLE mnc"
1848     else
1849 edhill 1.110 ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1850 edhill 1.100 RETVAL=$?
1851     if test "x${RETVAL}" = x0 ; then
1852     rm -f make_mnc.errors
1853     else
1854     echo "Error: problem encountered while building source files in pkg/mnc:"
1855     cat make_mnc.errors 1>&2
1856     exit 1
1857     fi
1858     fi
1859     fi
1860    
1861 edhill 1.1 echo " applying package dependency rules"
1862     ck=
1863     while test "x$ck" != xtt ; do
1864     i=0
1865 edhill 1.2 # rtot=${#PNAME[@]}
1866     rtot=$nname
1867 edhill 1.1 while test $i -lt $rtot ; do
1868    
1869     # Is $pname in the current $PACKAGES list?
1870 edhill 1.2 # pname=${PNAME[$i]}
1871     tmp="pname=\"\$PNAME_$i\""
1872     eval $tmp
1873 edhill 1.1 pin="f"
1874     for p in $PACKAGES ; do
1875     if test "x$p" = "x$pname" ; then
1876     pin="t"
1877     fi
1878     done
1879    
1880     # Is the DNAME entry a (+) or (-) rule ?
1881 edhill 1.2 tmp="dname=\"\$DNAME_$i\""
1882     eval $tmp
1883 edhill 1.1 plus="-"
1884 edhill 1.2 echo $dname | grep '^+' > /dev/null 2>&1
1885 edhill 1.1 RETVAL=$?
1886     if test "x$RETVAL" = x0 ; then
1887     plus="+"
1888     fi
1889    
1890     # Is $dname in the current $PACKAGES list?
1891 edhill 1.2 dname=`echo $dname | sed -e 's/^[+-]//'`
1892 edhill 1.1 din="f"
1893     for p in $PACKAGES ; do
1894     if test "x$p" = "x$dname" ; then
1895     din="t"
1896     fi
1897     done
1898    
1899     # Do we need to add $dname according to the dependency rules?
1900     if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
1901     in_dis="f"
1902     for dis in $DISABLE ; do
1903     if test "x$dis" = "x$dname" ; then
1904     in_dis="t"
1905     fi
1906     done
1907     if test "x$in_dis" = xt ; then
1908     echo "Error: can't satisfy package dependencies:"
1909     echo " \"$dname\" is required by the dependency rules"
1910     echo " but is disallowed by the DISABLE settings"
1911     exit 1
1912     else
1913     PACKAGES="$PACKAGES $dname"
1914     ck=
1915     fi
1916     fi
1917    
1918     # Do we need to get rid of $dname according to the dependency rules?
1919     if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
1920     echo "Error: can't satisfy package dependencies:"
1921     echo " \"$pname\" was requested but is disallowed by"
1922     echo " the dependency rules for \"$dname\""
1923     exit 1
1924     fi
1925 edhill 1.87 i=`echo "$i + 1" | bc -l`
1926     #i=$(( $i + 1 ))
1927 edhill 1.1 done
1928     ck=$ck"t"
1929     done
1930     echo " packages are: $PACKAGES"
1931     for i in $PACKAGES ; do
1932     adr="$ROOTDIR/pkg/$i"
1933     if test -d $adr ; then
1934     SOURCEDIRS="$SOURCEDIRS $adr"
1935     INCLUDEDIRS="$INCLUDEDIRS $adr"
1936 edhill 1.14 if test "x$i" = xautodiff ; then
1937     AUTODIFF_PKG_USED=t
1938     fi
1939 edhill 1.1 else
1940     echo "Error: the directory \"$adr\" for package $i doesn't exist"
1941     exit 1
1942     fi
1943     done
1944    
1945 edhill 1.12 # Create a list of #define and #undef to enable/disable packages
1946     PACKAGES_DOT_H=PACKAGES_CONFIG.h
1947 edhill 1.1 # The following UGLY HACK sets multiple "#undef"s and it needs to go
1948     # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
1949     # file would eventually be split up so that all package-related #define
1950     # statements could be separated and handled only by genmake.
1951     names=`ls -1 "$ROOTDIR/pkg"`
1952     all_pack=
1953 adcroft 1.44 DISABLED_PACKAGES=
1954 edhill 1.1 for n in $names ; do
1955     if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
1956     has_pack="f"
1957     for pack in $PACKAGES ; do
1958     if test "x$pack" = "x$n" ; then
1959     has_pack="t"
1960     break
1961     fi
1962     done
1963     if test "x$has_pack" = xf ; then
1964 edhill 1.116 undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1965 adcroft 1.44 DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1966 edhill 1.1 fi
1967     fi
1968     done
1969 adcroft 1.44 ENABLED_PACKAGES=
1970 edhill 1.1 for i in $PACKAGES ; do
1971 edhill 1.116 def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1972 adcroft 1.44 ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1973 edhill 1.12 #eh3 DEFINES="$DEFINES -D$def"
1974 edhill 1.1
1975     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
1976     case $i in
1977     aim_v23)
1978 adcroft 1.46 ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1979 jmc 1.55 echo "Warning: ALLOW_AIM is set to enable aim_v23."
1980 edhill 1.1 ;;
1981     esac
1982     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
1983    
1984     done
1985    
1986     echo " Adding STANDARDDIRS"
1987     BUILDDIR=${BUILDDIR:-.}
1988 edhill 1.57 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1989 edhill 1.12 STANDARDDIRS="eesupp model"
1990     fi
1991 edhill 1.57 if test "x$STANDARDDIRS" != x ; then
1992     for d in $STANDARDDIRS ; do
1993     adr="$ROOTDIR/$d/src"
1994     if test ! -d $adr ; then
1995     echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1996     echo " is correct and that you correctly specified the STANDARDDIRS option"
1997     exit 1
1998     else
1999     SOURCEDIRS="$SOURCEDIRS $adr"
2000     fi
2001     adr="$ROOTDIR/$d/inc"
2002     if test ! -d $adr ; then
2003     echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2004     echo " is correct and that you correctly specified the STANDARDDIRS option"
2005     exit 1
2006     else
2007     INCLUDEDIRS="$INCLUDEDIRS $adr"
2008     fi
2009     done
2010     fi
2011 edhill 1.1
2012 adcroft 1.52 echo " Searching for *OPTIONS.h files in order to warn about the presence"
2013     echo " of \"#define \"-type statements that are no longer allowed:"
2014 edhill 1.12 CPP_OPTIONS=
2015 adcroft 1.52 CPP_EEOPTIONS=
2016 edhill 1.12 spaths=". $INCLUDEDIRS"
2017 adcroft 1.52 names=`ls -1 "$ROOTDIR/pkg"`
2018 edhill 1.12 for i in $spaths ; do
2019     try="$i/CPP_OPTIONS.h"
2020 edhill 1.54 if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
2021 edhill 1.12 echo " found CPP_OPTIONS=\"$try\""
2022     CPP_OPTIONS="$try"
2023 adcroft 1.52 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
2024     for n in $names ; do
2025     test_for_package_in_cpp_options $CPP_OPTIONS $n
2026     done
2027     fi
2028     try="$i/CPP_EEOPTIONS.h"
2029 edhill 1.54 if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
2030 adcroft 1.52 echo " found CPP_EEOPTIONS=\"$try\""
2031     # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
2032     #**** not yet enabled ****
2033     # test_for_mpi_in_cpp_eeoptions $try
2034     #**** not yet enabled ****
2035     CPP_EEOPTIONS="$try"
2036 edhill 1.12 fi
2037     done
2038     if test "x$CPP_OPTIONS" = x ; then
2039     echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
2040     exit 1
2041     fi
2042 edhill 1.1
2043 edhill 1.14 # Here, we build the list of files to be "run through" the adjoint
2044     # compiler.
2045     if test -f ./ad_files ; then
2046     rm -f ./ad_files
2047     fi
2048     echo " Creating the list of files for the adjoint compiler."
2049     for i in $SOURCEDIRS ; do
2050     list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2051     for j in $list_files ; do
2052     cat $i/$j >> ad_files
2053     done
2054     done
2055 edhill 1.121 if test ! "x"$FS = "x.f" ; then
2056 edhill 1.122 cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
2057 edhill 1.121 mv -f ad_files_f ad_files
2058     fi
2059 edhill 1.14
2060 edhill 1.2 echo
2061     echo "=== Creating the Makefile ==="
2062 edhill 1.1 echo " setting INCLUDES"
2063     for i in $INCLUDEDIRS ; do
2064 edhill 1.87 if test ! -d $i ; then
2065 edhill 1.1 echo "Warning: can't find INCLUDEDIRS=\"$i\""
2066     fi
2067     done
2068    
2069 ce107 1.139 echo " Creating the pseudo-MPI include directory"
2070     if test ! "x$DIVA" = x ; then
2071     INCLUDES="-I./mpi_headers $INCLUDES"
2072     rm -rf ./mpi_headers
2073     mkdir -p ./mpi_headers
2074    
2075     if test "x$MPIINCLUDEDIR" = x ; then
2076     if test "x$MPIHOME" = x ; then
2077     MPIHOME='/usr'
2078     fi
2079     MPIINCLUDEDIR='$MPIHOME/include'
2080     fi
2081    
2082     if test -r $MPIINCLUDEDIR/mpif.h ; then
2083     for i in $MPI_HEADER_FILES; do
2084     cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2085     done
2086    
2087     perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2088     else
2089     echo " We cannot create a copy of mpif.h!"
2090     exit -1
2091     fi
2092     fi
2093    
2094 edhill 1.1 echo " Determining the list of source and include files"
2095     rm -rf .links.tmp
2096     mkdir .links.tmp
2097     echo "# This section creates symbolic links" > srclinks.tmp
2098     echo "" >> srclinks.tmp
2099 edhill 1.71 printf 'SRCFILES = ' > srclist.inc
2100     printf 'CSRCFILES = ' > csrclist.inc
2101     printf 'F90SRCFILES = ' > f90srclist.inc
2102     printf 'HEADERFILES = ' > hlist.inc
2103     printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
2104 adcroft 1.9 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2105 edhill 1.1 for d in $alldirs ; do
2106     deplist=
2107 edhill 1.14 sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2108 cnh 1.3 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2109 edhill 1.1 for sf in $sfiles ; do
2110     if test ! -r ".links.tmp/$sf" ; then
2111     if test -f "$d/$sf" ; then
2112 edhill 1.131 ignore_f=f
2113 adcroft 1.44 case $d/$sf in
2114     ./$PACKAGES_DOT_H)
2115     ;;
2116     ./AD_CONFIG.h)
2117     ;;
2118     ./FC_NAMEMANGLE.h)
2119     ;;
2120 edhill 1.98 ./BUILD_INFO.h)
2121     ;;
2122 adcroft 1.44 *)
2123 edhill 1.131 # For the local directory *ONLY*,
2124     # ignore all soft-links
2125     if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2126     ignore_f=t
2127     else
2128     touch .links.tmp/$sf
2129     deplist="$deplist $sf"
2130     fi
2131 adcroft 1.44 ;;
2132     esac
2133 edhill 1.131 if test "x$ignore_f" = xf ; then
2134     extn=`echo $sf | $AWK -F. '{print $NF}'`
2135     case $extn in
2136     F)
2137     echo " \\" >> srclist.inc
2138     printf " $sf" >> srclist.inc
2139     ;;
2140     F90)
2141     echo " \\" >> f90srclist.inc
2142     printf " $sf" >> f90srclist.inc
2143     ;;
2144     c)
2145     echo " \\" >> csrclist.inc
2146     printf " $sf" >> csrclist.inc
2147     ;;
2148     h)
2149     echo " \\" >> hlist.inc
2150     printf " $sf" >> hlist.inc
2151     ;;
2152     flow)
2153     echo " \\" >> ad_flow_files.inc
2154     printf " $sf" >> ad_flow_files.inc
2155     ;;
2156     esac
2157     fi
2158 edhill 1.1 fi
2159     fi
2160     done
2161     if test "x$deplist" != x ; then
2162 edhill 1.2 echo "" >> srclinks.tmp
2163     echo "# These files are linked from $d" >> srclinks.tmp
2164 edhill 1.1 echo "$deplist :" >> srclinks.tmp
2165 edhill 1.2 printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
2166 edhill 1.1 fi
2167     done
2168     rm -rf .links.tmp
2169     echo "" >> srclist.inc
2170     echo "" >> csrclist.inc
2171 cnh 1.3 echo "" >> f90srclist.inc
2172 edhill 1.1 echo "" >> hlist.inc
2173 edhill 1.14 echo "" >> ad_flow_files.inc
2174 edhill 1.1
2175 edhill 1.88 if test -f $MAKEFILE ; then
2176 edhill 1.1 mv -f $MAKEFILE "$MAKEFILE.bak"
2177     fi
2178     echo " Writing makefile: $MAKEFILE"
2179     echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
2180     echo "# $MACHINE" >> $MAKEFILE
2181     echo "# This makefile was generated automatically on" >> $MAKEFILE
2182     echo "# $THISDATE" >> $MAKEFILE
2183     echo "# by the command:" >> $MAKEFILE
2184 edhill 1.73 echo "# $0 $G2ARGS" >> $MAKEFILE
2185 edhill 1.1 echo "# executed by:" >> $MAKEFILE
2186 edhill 1.97 echo "# ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2187 edhill 1.21
2188     EXE_AD=$EXECUTABLE"_ad"
2189     EXE_FTL=$EXECUTABLE"_ftl"
2190     EXE_SVD=$EXECUTABLE"_svd"
2191    
2192 edhill 1.1 cat >>$MAKEFILE <<EOF
2193 edhill 1.53 #
2194     # OPTFILE="$OPTFILE"
2195 edhill 1.1 #
2196     # BUILDDIR : Directory where object files are written
2197     # SOURCEDIRS : Directories containing the source (.F) files
2198     # INCLUDEDIRS : Directories containing the header-source (.h) files
2199     # EXEDIR : Directory where executable that is generated is written
2200     # EXECUTABLE : Full path of executable binary
2201     #
2202     # CPP : C-preprocessor command
2203     # INCLUDES : Directories searched for header files
2204     # DEFINES : Macro definitions for CPP
2205     # MAKEDEPEND : Dependency generator
2206     # KPP : Special preprocessor command (specific to platform)
2207     # KFLAGS : Flags for KPP
2208     # FC : Fortran compiler command
2209     # FFLAGS : Configuration/debugging options for FC
2210     # FOPTIM : Optimization options for FC
2211     # LINK : Command for link editor program
2212     # LIBS : Library flags /or/ additional optimization/debugging flags
2213    
2214     ROOTDIR = ${ROOTDIR}
2215     BUILDDIR = ${BUILDDIR}
2216     SOURCEDIRS = ${SOURCEDIRS}
2217     INCLUDEDIRS = ${INCLUDEDIRS}
2218     EXEDIR = ${EXEDIR}
2219     EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
2220     TOOLSDIR = ${TOOLSDIR}
2221    
2222 edhill 1.14 #eh3 new defines for the adjoint work
2223     AUTODIFF = ${ROOTDIR}/pkg/autodiff
2224 edhill 1.21 EXE_AD = ${EXE_AD}
2225     EXE_FTL = ${EXE_FTL}
2226     EXE_SVD = ${EXE_SVD}
2227 edhill 1.14
2228 adcroft 1.44 ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2229     DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2230    
2231 adcroft 1.52 # These files are created by Makefile
2232 edhill 1.97 SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2233 adcroft 1.52
2234 edhill 1.1 EOF
2235    
2236     # Note: figure out some way to add Hyades JAM libraries here
2237    
2238     cat >>$MAKEFILE <<EOF
2239     # Unix ln (link)
2240     LN = ${LN}
2241     # C preprocessor
2242     CPP = cat \$< | ${S64} | ${CPP}
2243     # Dependency generator
2244     MAKEDEPEND = ${MAKEDEPEND}
2245     # Special preprocessor (KAP on DECs, FPP on Crays)
2246     KPP = ${KPP}
2247     # Fortran compiler
2248 edhill 1.94 FC = ${FC}
2249 cnh 1.3 # Fortran compiler
2250     F90C = ${F90C}
2251 edhill 1.92 # C compiler
2252     CC = ${CC}
2253 edhill 1.1 # Link editor
2254 edhill 1.70 LINK = ${LINK} ${LDADD}
2255 edhill 1.1
2256     # Defines for CPP
2257     DEFINES = ${DEFINES}
2258     # Includes for CPP
2259     INCLUDES = ${INCLUDES}
2260     # Flags for KPP
2261     KFLAGS1 = ${KFLAGS1}
2262     KFLAGS2 = ${KFLAGS2}
2263     # Optim./debug for FC
2264     FFLAGS = ${FFLAGS}
2265     FOPTIM = ${FOPTIM}
2266 cnh 1.3 # Optim./debug for FC
2267     F90FLAGS = ${F90FLAGS}
2268     F90OPTIM = ${F90OPTIM}
2269 edhill 1.1 # Flags for CC
2270     CFLAGS = ${CFLAGS}
2271     # Files that should not be optimized
2272     NOOPTFILES = ${NOOPTFILES}
2273     NOOPTFLAGS = ${NOOPTFLAGS}
2274     # Flags and libraries needed for linking
2275 edhill 1.107 LIBS = ${LIBS}
2276 cnh 1.3 # Name of the Mekfile
2277     MAKEFILE=${MAKEFILE}
2278 edhill 1.1
2279     EOF
2280    
2281 edhill 1.14 cat srclist.inc >> $MAKEFILE
2282     cat csrclist.inc >> $MAKEFILE
2283     cat f90srclist.inc >> $MAKEFILE
2284     cat hlist.inc >> $MAKEFILE
2285     cat ad_flow_files.inc >> $MAKEFILE
2286 edhill 1.75 echo >> $MAKEFILE
2287 edhill 1.76 echo 'F77FILES = $(SRCFILES:.F=.'$FS')' >> $MAKEFILE
2288 heimbach 1.127 echo 'F90FILES = $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2289 edhill 1.76 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2290 edhill 1.75 echo >> $MAKEFILE
2291     echo '.SUFFIXES:' >> $MAKEFILE
2292 adcroft 1.83 echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2293 cnh 1.3 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
2294 edhill 1.14 rm -f ad_flow_files.inc
2295 edhill 1.1
2296     cat >>$MAKEFILE <<EOF
2297    
2298     all: \$(EXECUTABLE)
2299 adcroft 1.52 \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2300 adcroft 1.44 @echo Creating \$@ ...
2301 edhill 1.1 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2302     depend:
2303     @make links
2304 edhill 1.76 \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2305 adcroft 1.44 \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2306 edhill 1.72 -rm -f makedepend.out
2307 edhill 1.1
2308 cnh 1.132 lib: libmitgcmuv.a
2309    
2310     libmitgcmuv.a: \$(OBJFILES)
2311     ar rcv libmitgcmuv.a \$(OBJFILES)
2312    
2313 adcroft 1.52 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2314 edhill 1.1
2315 cnh 1.3 small_f: \$(F77FILES) \$(F90FILES)
2316 edhill 1.1
2317     output.txt: \$(EXECUTABLE)
2318     @printf 'running ... '
2319     @\$(EXECUTABLE) > \$@
2320    
2321     clean:
2322 edhill 1.76 -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2323 edhill 1.1 Clean:
2324     @make clean
2325     @make cleanlinks
2326 adcroft 1.52 -rm -f \$(SPECIAL_FILES)
2327 adcroft 1.51 -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
2328 edhill 1.1 CLEAN:
2329     @make Clean
2330     -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2331     -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2332     -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2333 adcroft 1.78 -rm -f \$(EXECUTABLE) output.txt STD*
2334 edhill 1.1
2335 edhill 1.18 #eh3 Makefile: makefile
2336 edhill 1.1 makefile:
2337 edhill 1.73 $THIS_SCRIPT $G2ARGS
2338 edhill 1.1 cleanlinks:
2339     -find . -type l -exec rm {} \;
2340    
2341 edhill 1.97 # Special targets (SPECIAL_FILES) which are create by make
2342 adcroft 1.44 ${PACKAGES_DOT_H}:
2343     @echo Creating \$@ ...
2344 edhill 1.71 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
2345 adcroft 1.44 AD_CONFIG.h:
2346     @echo Creating \$@ ...
2347 edhill 1.71 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@
2348 adcroft 1.52 FC_NAMEMANGLE.h:
2349     @echo Creating \$@ ...
2350     echo "$FC_NAMEMANGLE" > \$@
2351 adcroft 1.44
2352 edhill 1.97 BUILD_INFO.h:
2353     @echo Creating \$@ ...
2354     EOF
2355    
2356     test ! "x$THISVER" = x && echo " -echo \"#define THISVER '$THISVER'\" > \$@" >> $MAKEFILE
2357     test ! "x$THISUSER" = x && echo " -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2358     test ! "x$THISDATE" = x && echo " -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2359     test ! "x$THISHOST" = x && echo " -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2360    
2361     cat >>$MAKEFILE <<EOF
2362    
2363 edhill 1.76 # The normal chain of rules is ( .F - .$FS - .o )
2364    
2365 edhill 1.101 ## This nullifies any default implicit rules concerning these two file types:
2366     ## %.o : %.F
2367 edhill 1.76
2368     .F.$FS:
2369 edhill 1.1 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2370 edhill 1.76 .$FS.o:
2371 edhill 1.1 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2372 edhill 1.76 .F90.$FS90:
2373 cnh 1.3 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2374 edhill 1.76 .$FS90.o:
2375 cnh 1.3 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2376 edhill 1.1 .c.o:
2377 ce107 1.139 \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2378 edhill 1.1
2379 edhill 1.76 # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2380     .F.p:
2381 edhill 1.1 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2382 edhill 1.76 .p.$FS:
2383 edhill 1.1 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2384 edhill 1.14
2385     #=========================================
2386     #=== Automatic Differentiation Rules ===
2387    
2388     TAMC = ${TAMC}
2389     TAF = ${TAF}
2390    
2391 edhill 1.17 TAF_EXTRA = ${TAF_EXTRA}
2392     TAMC_EXTRA = ${TAMC_EXTRA}
2393    
2394 edhill 1.14 EOF
2395    
2396     ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
2397     ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
2398     ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2399     for i in $ad_vars ; do
2400     name=$i
2401     t1="t2=\$"`echo $i`
2402     eval $t1
2403     printf "%-20s = " $name >> $MAKEFILE
2404     echo $t2 >> $MAKEFILE
2405     done
2406    
2407     echo " Add the source list for AD code generation"
2408     echo >> $MAKEFILE
2409 edhill 1.71 printf "AD_FILES = " >> $MAKEFILE
2410 edhill 1.14 AD_FILES=`cat ad_files`
2411     for i in $AD_FILES ; do
2412     echo " \\" >> $MAKEFILE
2413 edhill 1.71 printf " $i" >> $MAKEFILE
2414 edhill 1.14 done
2415     echo >> $MAKEFILE
2416 edhill 1.21 rm -f ad_files
2417 edhill 1.14
2418     cat >>$MAKEFILE <<EOF
2419    
2420 edhill 1.16 # ... AD ...
2421 edhill 1.23 adall: ad_taf
2422 edhill 1.121 adtaf: ad_taf_output.$FS
2423     adtamc: ad_tamc_output.$FS
2424 edhill 1.21
2425 edhill 1.121 ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2426 edhill 1.71 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2427 edhill 1.23 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2428 adcroft 1.44 -rm -f ad_config.template
2429 edhill 1.22 @make \$(F77FILES)
2430     @make \$(AD_FLOW_FILES)
2431 edhill 1.121 cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2432 edhill 1.22
2433 edhill 1.121 ad_taf_output.$FS: ad_input_code.$FS
2434     \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2435     cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2436 heimbach 1.37
2437     adtafonly:
2438 edhill 1.121 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2439     cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2440 edhill 1.14
2441     ad_taf: ad_taf_output.o \$(OBJFILES)
2442 edhill 1.21 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2443 edhill 1.14
2444 edhill 1.121 ad_tamc_output.$FS: ad_input_code.$FS
2445     \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2446     cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2447 edhill 1.14
2448     ad_tamc: ad_tamc_output.o \$(OBJFILES)
2449 edhill 1.21 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2450 edhill 1.14
2451 heimbach 1.105 adonlyfwd:
2452 edhill 1.106 patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2453 heimbach 1.105
2454     adtrick:
2455 edhill 1.106 patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2456 edhill 1.14
2457 edhill 1.19 # ... FTL ...
2458 edhill 1.23 ftlall: ftl_taf
2459 edhill 1.121 ftltaf: ftl_taf_output.$FS
2460     ftltamc: ftl_tamc_output.$FS
2461 edhill 1.21
2462 edhill 1.121 ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2463 edhill 1.71 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2464 edhill 1.23 cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2465 adcroft 1.44 -rm -f ftl_config.template
2466 edhill 1.23 @make \$(F77FILES)
2467 edhill 1.22 @make \$(AD_FLOW_FILES)
2468 edhill 1.121 cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2469 edhill 1.22
2470 edhill 1.121 ftl_taf_output.$FS: ftl_input_code.$FS
2471     \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2472     cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2473 edhill 1.14
2474 heimbach 1.40 ftltafonly:
2475 edhill 1.121 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2476     cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2477 heimbach 1.40
2478 edhill 1.19 ftl_taf: ftl_taf_output.o \$(OBJFILES)
2479 edhill 1.21 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2480 edhill 1.14
2481 edhill 1.121 ftl_tamc_output.$FS: ftl_input_code.$FS
2482     \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2483     cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2484 edhill 1.16
2485 edhill 1.19 ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2486 edhill 1.21 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2487 edhill 1.16
2488    
2489     # ... SVD ...
2490 edhill 1.121 svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2491 heimbach 1.109 @echo "--->>> Only ran TAF to generate SVD code! <<<---"
2492     @echo "--->>> Do make svdall afterwards to compile. <<<---"
2493     svdall: svd_touch svd_taf
2494 edhill 1.16
2495 heimbach 1.109 svd_taf: \$(OBJFILES)
2496 heimbach 1.40 \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
2497 edhill 1.14
2498 heimbach 1.109 @echo "--->>> Only COMPILE svd code! <<<---"
2499     @echo "--->>> Assumes you previously <<<---"
2500     @echo "--->>> did make svdtaf <<<---"
2501    
2502     svd_touch:
2503     @echo "--->>> Only COMPILE svd code! <<<---"
2504     @echo "--->>> Assumes you previously <<<---"
2505     @echo "--->>> did make svdtaf <<<---"
2506 edhill 1.121 touch ad_taf_output.$FS ftl_taf_output.$FS
2507     \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2508     \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2509 heimbach 1.109 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2510     cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2511     -rm -f ftl_config.template
2512 edhill 1.14
2513     #=========================================
2514 edhill 1.1
2515     EOF
2516 edhill 1.7
2517     if test "x$EXEHOOK" != x ; then
2518     printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
2519     fi
2520 edhill 1.1
2521     echo " Making list of \"exceptions\" that need \".p\" files"
2522     for i in $KPPFILES ; do
2523     base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
2524     RETVAL=$?
2525     if test "x$RETVAL" != x0 ; then
2526     echo "Error: unable to add file \"$i\" to the exceptions list"
2527     fi
2528 edhill 1.76 echo "$base.$FS: $base.p" >> $MAKEFILE
2529 edhill 1.1 done
2530    
2531     echo " Making list of NOOPTFILES"
2532     for i in $NOOPTFILES ; do
2533     base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
2534     RETVAL=$?
2535     if test "x$RETVAL" != x0 ; then
2536     echo "Error: unable to add file \"$i\" to the exceptions list"
2537     fi
2538 edhill 1.76 echo "$base.o: $base.$FS" >> $MAKEFILE
2539 edhill 1.2 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2540 edhill 1.1 done
2541    
2542     echo " Add rules for links"
2543     cat srclinks.tmp >> $MAKEFILE
2544     rm -f srclinks.tmp
2545    
2546     echo " Adding makedepend marker"
2547 edhill 1.2 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
2548 edhill 1.1
2549 edhill 1.2 printf "\n=== Done ===\n"
2550 adcroft 1.47
2551     # Create special header files
2552 edhill 1.71 $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
2553 adcroft 1.47 if test ! -f $PACKAGES_DOT_H ; then
2554     mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2555     else
2556 edhill 1.61 cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
2557 adcroft 1.47 RETVAL=$?
2558     if test "x$RETVAL" = x0 ; then
2559     rm -f $PACKAGES_DOT_H".tmp"
2560     else
2561     mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
2562     mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2563     fi
2564     fi
2565     if test ! -f AD_CONFIG.h ; then
2566 edhill 1.71 $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h
2567 adcroft 1.47 fi
2568 edhill 1.5
2569    
2570     # Write the "state" for future records
2571     if test "x$DUMPSTATE" != xf ; then
2572 edhill 1.71 printf "" > genmake_state
2573 edhill 1.5 for i in $gm_state ; do
2574     t1="t2=\$$i"
2575     eval $t1
2576 edhill 1.12 echo "$i='$t2'" >> genmake_state
2577 edhill 1.5 done
2578     fi

  ViewVC Help
Powered by ViewVC 1.1.22