/[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.31 - (hide annotations) (download)
Wed Nov 12 21:14:57 2003 UTC (20 years, 4 months ago) by edhill
Branch: MAIN
Changes since 1.30: +82 -52 lines
 o improve the FORTRAN <==> C name-mangling detection algorithm
   - tested on: linux_ia32_g77, linux_ia64_g77, darwin_ppc_g77,
       darwin_ppc_xlf, AIX SP4 (blackforest)

1 edhill 1.1 #!/bin/bash
2     #
3 edhill 1.31 # $Header: /u/u3/gcmpack/MITgcm/tools/genmake2,v 1.30 2003/11/11 21:11:06 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     grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
17     RETVAL=$?
18     if test "x${RETVAL}" = x0 ; then
19     echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"
20     exit 99
21     fi
22     grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
23     RETVAL=$?
24     if test "x${RETVAL}" = x0 ; then
25     echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"
26     exit 99
27     fi
28     grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
29     RETVAL=$?
30     if test "x${RETVAL}" = x0 ; then
31     echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"
32     exit 99
33     fi
34     grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
35     RETVAL=$?
36     if test "x${RETVAL}" = x0 ; then
37     echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"
38     exit 99
39     fi
40     }
41    
42     # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
43     # the package list.
44     expand_pkg_groups() {
45     new_packages=
46     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
47     if test -r $PKG_GROUPS ; then
48     cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
49 edhill 1.15 cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
50 edhill 1.12 matched=0
51     for i in $PACKAGES ; do
52     line=`grep "^ *$i" ./p2.tmp`
53     RETVAL=$?
54     if test "x$RETVAL" = x0 ; then
55     matched=1
56 edhill 1.15 replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
57 edhill 1.12 echo " replacing \"$i\" with: $replace"
58     new_packages="$new_packages $replace"
59     else
60     new_packages="$new_packages $i"
61     fi
62     done
63     PACKAGES=$new_packages
64     rm -f ./p[1,2].tmp
65     else
66     echo "Warning: can't read package groups definition file: $PKG_GROUPS"
67     fi
68     }
69 edhill 1.1
70     # Guess possible config options for this host
71     find_possible_configs() {
72    
73 edhill 1.11 tmp1=`uname`"_"`uname -m`
74     tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
75 edhill 1.25 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
76     PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
77 edhill 1.11 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
78     echo " The platform appears to be: $PLATFORM"
79     # if test "x$OFLIST" = x ; then
80     # echo " No pre-defined options files were found matching this platform"
81     # echo " but examples for other platforms can be found in:"
82     # echo " $ROOTDIR/tools/build_options"
83     # else
84     # echo " Options files (located in $ROOTDIR/tools/build_options) that"
85     # echo " may work with this machine are:"
86     # for i in $OFLIST ; do
87     # echo " $i"
88     # done
89     # fi
90    
91 edhill 1.1 echo "test" > test
92     ln -s ./test link
93     RETVAL=$?
94     if test "x${RETVAL}" = x0 ; then
95 edhill 1.11 LN="ln -s"
96     else
97     echo "Error: \"ln -s\" does not appear to work on this system!"
98     echo " For help, please contact <MITgcm-support@mitgcm.org>."
99     exit 1
100 edhill 1.1 fi
101     rm -f test link
102    
103 edhill 1.11 if test "x$CPP" = x ; then
104     CPP="cpp -traditional -P"
105 edhill 1.1 fi
106    
107     # look for possible fortran compilers
108 cnh 1.24 tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
109 edhill 1.1 p_FC=
110 edhill 1.11 for c in $tmp ; do
111     rm -f ./hello.f ./hello
112     cat >> hello.f <<EOF
113     program hello
114     do i=1,3
115     print *, 'hello world : ', i
116     enddo
117     end
118     EOF
119     $c -o hello hello.f > /dev/null 2>&1
120 edhill 1.1 RETVAL=$?
121     if test "x${RETVAL}" = x0 ; then
122     p_FC="$p_FC $c"
123     fi
124     done
125 edhill 1.21 rm -f ./hello.f ./hello
126 edhill 1.1 if test "x${p_FC}" = x ; then
127 edhill 1.11 cat 1>&2 <<EOF
128    
129     Error: No Fortran compilers were found in your path. Please specify one using:
130    
131     1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
132     2) a command-line option (eg. "-fc NAME"), or
133     3) the MITGCM_FC environment variable.
134    
135     EOF
136     exit 1
137 edhill 1.1 else
138 edhill 1.11 echo " The possible FORTRAN compilers found in your path are:"
139     echo " "$p_FC
140     if test "x$FC" = x ; then
141 edhill 1.15 FC=`echo $p_FC | $AWK '{print $1}'`
142 edhill 1.11 fi
143 edhill 1.1 fi
144    
145 edhill 1.11 for i in $p_FC ; do
146     p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
147     if test -r $p_OF ; then
148     OPTFILE=$p_OF
149     echo " The options file: $p_OF"
150     echo " appears to match so we'll use it."
151     break
152     fi
153     done
154     if test "x$OPTFILE" = x ; then
155     cat 1>&2 <<EOF
156    
157     Error: No options file was found in: $ROOTDIR/tools/build_options/
158     that matches this platform ("$PLATFORM") and the compilers found in
159     your path. Please specify an "optfile" using:
160    
161     1) the command line (eg. "-optfile=path/to/OPTFILE"), or
162     2) the MITGCM_OF environment variable.
163    
164     If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
165    
166 edhill 1.1 EOF
167 edhill 1.11 exit 1
168 edhill 1.1 fi
169 edhill 1.11
170     # # look for possible MPI libraries
171     # mpi_libs=
172     # mpi_fort=`which mpif77 2>/dev/null`
173     # RETVAL=$?
174     # if test "x${RETVAL}" = x0 ; then
175     # cat >>test.f <<EOF
176     # PROGRAM HELLO
177     # DO 10, I=1,10
178     # PRINT *,'Hello World'
179     # 10 CONTINUE
180     # STOP
181     # END
182     # EOF
183     # eval "$mpi_fort -showme test.f > out"
184     # RETVAL=$?
185     # if test "x${RETVAL}" = x0 ; then
186     # a=`cat out`
187     # for i in $a ; do
188     # case $i in
189     # -*)
190     # mpi_libs="$mpi_libs $i" ;;
191     # esac
192     # done
193     # echo "The MPI libs appear to be:"
194     # echo " "$mpi_libs
195     # fi
196     # rm -f test.f out
197     # fi
198 edhill 1.1
199     }
200    
201     # Parse the package dependency information
202     get_pdepend_list() {
203    
204     # strip the comments and then convert the dependency file into
205     # two arrays: PNAME, DNAME
206     cat $1 | sed -e 's/#.*$//g' \
207 edhill 1.15 | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
208 edhill 1.1 > ./.pd_tmp
209     source ./.pd_tmp
210     rm -f ./.pd_tmp
211    
212     echo -n "PNAME = "${}
213     }
214    
215    
216     # Explain usage
217     usage() {
218 edhill 1.2 echo
219 edhill 1.1 echo "Usage: "$0" [OPTIONS]"
220 edhill 1.2 echo " where [OPTIONS] can be:"
221     echo
222 edhill 1.1 echo " -help | --help | -h | --h"
223     echo " -nooptfile | --nooptfile"
224     echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME"
225     echo " -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME"
226     echo " -pdepend NAME | --pdepend NAME"
227     echo " -pdepend=NAME | --pdepend=NAME"
228     echo " -pdefault NAME | --pdefault NAME"
229     echo " -pdefault=NAME | --pdefault=NAME"
230 edhill 1.6 echo " -make NAME | -m NAME"
231     echo " --make=NAME | -m=NAME"
232     echo " -makefile NAME | -mf NAME"
233     echo " --makefile=NAME | -mf=NAME"
234 edhill 1.1 echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME"
235     echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
236     echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
237     echo " -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME"
238     echo " -mods NAME | --mods NAME | -mo NAME | --mo NAME"
239     echo " -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME"
240     echo " -disable NAME | --disable NAME"
241     echo " -disable=NAME | --disable=NAME"
242     echo " -enable NAME | --enable NAME"
243     echo " -enable=NAME | --enable=NAME"
244 edhill 1.12 echo " -standarddirs NAME | --standarddirs NAME"
245     echo " -standarddirs=NAME | --standarddirs=NAME"
246 edhill 1.1 echo " -noopt NAME | --noopt NAME"
247     echo " -noopt=NAME | --noopt=NAME"
248     # echo " -cpp NAME | --cpp NAME"
249     # echo " -cpp=NAME | --cpp=NAME"
250     echo " -fortran NAME | --fortran NAME | -fc NAME | --fc NAME"
251     echo " -fc=NAME | --fc=NAME"
252     echo " -[no]ieee | --[no]ieee"
253     echo " -[no]mpi | --[no]mpi"
254 edhill 1.2 echo " -[no]jam | --[no]jam"
255     echo
256     echo " and NAME is a string such as:"
257     echo
258 edhill 1.1 echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'"
259     echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'"
260 edhill 1.2 echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"
261     echo
262 edhill 1.1 echo " which, depending upon your shell, may need to be single-quoted"
263     echo " if it contains spaces, dashes, or other special characters."
264     exit 1
265     }
266    
267 edhill 1.31 # Build a CPP macro to automate calling C routines from FORTRAN
268     get_fortran_c_namemangling() {
269     default_nm="#define FC_NAMEMANGLE(X) X ## _"
270    
271     cat > genmake_test.c <<EOF
272     void tcall( char * string ) { tsub( string ); }
273     EOF
274     $MAKE genmake_test.o > genmake_test.log 2>&1
275     RETVAL=$?
276     if test "x$RETVAL" != x0 ; then
277     cat genmake_test.log >> genmake_errors
278     FC_NAMEMANGLE=$default_nm
279     echo
280     echo "WARNING: C test compile fails -- please see \"genmake_errors\""
281     echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
282     echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
283     return 1
284     fi
285     c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3`
286     RETVAL=$?
287     if test "x$RETVAL" != x0 ; then
288     FC_NAMEMANGLE=$default_nm
289     echo
290     echo "WARNING: The \"nm\" command failed."
291     echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
292     echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
293     return 1
294     fi
295     cat > genmake_tcomp.f <<EOF
296     subroutine tcall( string )
297     character*(*) string
298     call tsub( string )
299     end
300     EOF
301     $FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1
302     RETVAL=$?
303     if test "x$RETVAL" != x0 ; then
304     cat genmake_tcomp.log >> genmake_errors
305     FC_NAMEMANGLE=$default_nm
306     echo
307     echo "WARNING: FORTRAN test compile fails -- please see \"genmake_errors\""
308     echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
309     echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
310     return 1
311     fi
312     f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3`
313     RETVAL=$?
314     if test "x$RETVAL" != x0 ; then
315     FC_NAMEMANGLE=$default_nm
316     echo
317     echo "WARNING: The \"nm\" command failed."
318     echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
319     echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
320     return 1
321     fi
322    
323     c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
324     f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
325     c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
326     f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
327    
328     nmangle="X"
329     if test "x$c_a" != "x$f_a" ; then
330     comm="echo x$f_a | sed -e 's|x$c_a||'"
331     a=`eval $comm`
332     nmangle="$a ## $nmangle"
333     fi
334     if test "x$c_b" != "x$f_b" ; then
335     comm="echo x$f_b | sed -e 's|x$c_b||'"
336     b=`eval $comm`
337     nmangle="$nmangle ## $b"
338     fi
339    
340     FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle"
341     }
342 edhill 1.1
343     # Set defaults here
344 edhill 1.5 COMMANDL="$0 $@"
345    
346 edhill 1.1 PLATFORM=
347     LN=
348     S64=
349     KPP=
350     FC=
351     LINK=
352 edhill 1.31 # DEFINES="-DWORDLENGTH=4"
353     DEFINES=
354 edhill 1.1 PACKAGES=
355     ENABLE=
356     DISABLE=
357     MAKEFILE=
358     MAKEDEPEND=
359     PDEPEND=
360 edhill 1.11 DUMPSTATE=t
361 edhill 1.1 PDEFAULT=
362     OPTFILE=
363 edhill 1.2 INCLUDES="-I."
364 edhill 1.1 FFLAGS=
365     FOPTIM=
366     CFLAGS=
367     KFLAGS1=
368     KFLAGS2=
369     LIBS=
370     KPPFILES=
371     NOOPTFILES=
372     NOOPTFLAGS=
373    
374 edhill 1.29 # DEFINES checked by test compilation
375     HAVE_SYSTEM=
376     HAVE_FDATE=
377     FC_NAMEMANGLE=
378    
379 edhill 1.1 MODS=
380     TOOLSDIR=
381     SOURCEDIRS=
382     INCLUDEDIRS=
383 edhill 1.12 STANDARDDIRS=
384 edhill 1.1
385     PWD=`pwd`
386     MAKE=make
387 edhill 1.15 AWK=awk
388 edhill 1.1 THISHOSTNAME=`hostname`
389     THISCWD=`pwd`
390     THISDATE=`date`
391     MACHINE=`uname -a`
392 edhill 1.7 EXECUTABLE=
393     EXEHOOK=
394     EXEDIR=
395 edhill 1.12 PACKAGES_CONF=
396     IEEE=
397     if test "x$MITGCM_IEEE" != x ; then
398     IEEE=$MITGCM_IEEE
399     fi
400 edhill 1.1
401 edhill 1.14 AUTODIFF_PKG_USED=f
402     AD_OPTFILE=
403 edhill 1.17 TAF=
404     AD_TAF_FLAGS=
405     FTL_TAF_FLAGS=
406     SVD_TAF_FLAGS=
407     TAF_EXTRA=
408     TAMC=
409     AD_TAMC_FLAGS=
410     FTL_TAF_FLAGS=
411     SVD_TAMC_FLAGS=
412     TAMC_EXTRA=
413    
414 edhill 1.14
415 edhill 1.5 # The following state can be set directly by command-line switches
416     gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
417 edhill 1.12 gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
418 edhill 1.5
419     # The following state is not directly set by command-line switches
420     gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
421     gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
422     gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
423 edhill 1.12 gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
424 edhill 1.29 gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"
425 edhill 1.5
426 edhill 1.14 # The following are all related to adjoint/tangent-linear stuff
427 edhill 1.29 gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
428     gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
429     gm_s12="TAF_EXTRA TAMC_EXTRA"
430 edhill 1.14
431 edhill 1.29 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
432     gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
433 edhill 1.5
434    
435 edhill 1.2 echo
436     echo "=== Processing options files and arguments ==="
437 edhill 1.12 gm_local="genmake_local"
438     for i in . $MODS ; do
439     if test -r $i/$gm_local ; then
440     source $i/$gm_local
441     break
442     fi
443     done
444 edhill 1.1 echo -n " getting local config information: "
445     if test -e $gm_local ; then
446     echo "using $gm_local"
447     source $gm_local
448 edhill 1.2 # echo "DISABLE=$DISABLE"
449     # echo "ENABLE=$ENABLE"
450 edhill 1.1 else
451     echo "none found"
452     fi
453    
454     # echo "$0::$1:$2:$3:$4:$5:$6:$7:"
455 edhill 1.2 #OPTIONS=
456     #n=0
457     #for i ; do
458     # echo "$i $n"
459     # setvar="OPTIONS[$n]='$i'"
460     # # echo " $setvar"
461     # eval "$setvar"
462     # n=$(( $n + 1 ))
463     #done
464     #parse_options
465     ac_prev=
466     for ac_option ; do
467    
468     # If the previous option needs an argument, assign it.
469     if test -n "$ac_prev"; then
470     eval "$ac_prev=\$ac_option"
471     ac_prev=
472     continue
473     fi
474    
475     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
476    
477     case $ac_option in
478    
479     -help | --help | -h | --h)
480     usage ;;
481    
482     -nooptfile | --nooptfile)
483     OPTFILE="NONE" ;;
484     -optfile | --optfile | -of | --of)
485 edhill 1.4 ac_prev=OPTFILE ;;
486 edhill 1.2 -optfile=* | --optfile=* | -of=* | --of=*)
487     OPTFILE=$ac_optarg ;;
488    
489 edhill 1.14 -adoptfile | --adoptfile | -ad | --ad)
490     ac_prev=AD_OPTFILE ;;
491     -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
492     AD_OPTFILE=$ac_optarg ;;
493    
494 edhill 1.2 -pdepend | --pdepend)
495 edhill 1.4 ac_prev=PDEPEND ;;
496 edhill 1.2 -pdepend=* | --pdepend=*)
497     PDEPEND=$ac_optarg ;;
498    
499     -pdefault | --pdefault)
500 edhill 1.4 ac_prev=PDEFAULT ;;
501 edhill 1.2 -pdefault=* | --pdefault=*)
502     PDEFAULT=$ac_optarg ;;
503    
504 edhill 1.6 -make | --make | -m | --m)
505     ac_prev=MAKE ;;
506     -make=* | --make=* | -m=* | --m=*)
507     MAKE=$ac_optarg ;;
508    
509     -makefile | --makefile | -ma | --ma)
510 edhill 1.4 ac_prev=MAKEFILE ;;
511 edhill 1.6 -makefile=* | --makefile=* | -ma=* | --ma=*)
512 edhill 1.2 MAKEFILE=$ac_optarg ;;
513    
514     -platform | --platform | -pl | --pl)
515 edhill 1.4 ac_prev=PLATFORM ;;
516 edhill 1.2 -platform=* | --platform=* | -pl=* | --pl=*)
517     PLATFORM=$ac_optarg ;;
518    
519     -rootdir | --rootdir | -rd | --rd)
520 edhill 1.4 ac_prev=ROOTDIR ;;
521 edhill 1.2 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
522     ROOTDIR=$ac_optarg ;;
523    
524     -mods | --mods | -mo | --mo)
525 edhill 1.4 ac_prev=MODS ;;
526 edhill 1.2 -mods=* | --mods=* | -mo=* | --mo=*)
527     MODS=$ac_optarg ;;
528    
529     -disable | --disable)
530 edhill 1.4 ac_prev=DISABLE ;;
531 edhill 1.2 -disable=* | --disable=*)
532     DISABLE=$ac_optarg ;;
533    
534     -enable | --enable)
535 edhill 1.4 ac_prev=ENABLE ;;
536 edhill 1.2 -enable=* | --enable=*)
537     ENABLE=$ac_optarg ;;
538    
539 edhill 1.12 -standarddirs | --standarddirs)
540     ac_prev=STANDARDDIRS ;;
541     -standarddirs=* | --standarddirs=*)
542     STANDARDDIRS=$ac_optarg ;;
543    
544 edhill 1.2 -noopt | --noopt)
545 edhill 1.4 ac_prev=NOOPT ;;
546 edhill 1.2 -noopt=* | --noopt=*)
547     NOOPT=$ac_optarg ;;
548    
549     # -cpp | --cpp)
550     # ac_prev=cpp ;;
551     # -cpp=* | --cpp=*)
552     # CPP=$ac_optarg ;;
553    
554     -fortran | --fortran | -fc | --fc)
555 edhill 1.4 ac_prev=FC ;;
556 edhill 1.2 -fc=* | --fc=*)
557     FC=$ac_optarg ;;
558    
559     -ieee | --ieee)
560 edhill 1.12 IEEE=true ;;
561 edhill 1.2 -noieee | --noieee)
562 edhill 1.12 IEEE= ;;
563 edhill 1.2
564     -mpi | --mpi)
565 edhill 1.12 MPI=true ;;
566 edhill 1.2 -nompi | --nompi)
567 edhill 1.12 MPI= ;;
568 edhill 1.2
569     -jam | --jam)
570     JAM=1 ;;
571     -nojam | --nojam)
572     JAM=0 ;;
573    
574 edhill 1.5 -ds | --ds)
575     DUMPSTATE=t ;;
576    
577 edhill 1.17 -taf_extra | --taf_extra)
578     ac_prev=TAF_EXTRA ;;
579     -taf_extra=* | --taf_extra=*)
580     TAF_EXTRA=$ac_optarg ;;
581    
582     -tamc_extra | --tamc_extra)
583     ac_prev=TAMC_EXTRA ;;
584     -tamc_extra=* | --tamc_extra=*)
585     TAMC_EXTRA=$ac_optarg ;;
586    
587 edhill 1.2 -*)
588     echo "Error: unrecognized option: "$ac_option
589     usage
590     ;;
591    
592     *)
593     echo "Error: unrecognized argument: "$ac_option
594     usage
595     ;;
596    
597     esac
598    
599 edhill 1.1 done
600    
601 edhill 1.12 if test -f ./.genmakerc ; then
602     echo
603     echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
604     echo " file. This file format is no longer supported. Please see:"
605     echo
606     echo " http://mitgcm.org/devel_HOWTO/"
607     echo
608     echo " for directions on how to setup and use the new \"genmake2\" input"
609     echo " files and send an email to MITgcm-support@mitgcm.org if you want help."
610     echo
611     fi
612    
613 edhill 1.11 if test "x${ROOTDIR}" = x ; then
614     if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
615     ROOTDIR=".."
616     else
617     for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
618     if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
619     ROOTDIR=$d
620     echo -n "Warning: ROOTDIR was not specified but there appears to be"
621     echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
622     break
623     fi
624     done
625     fi
626     fi
627     if test "x${ROOTDIR}" = x ; then
628     echo "Error: Cannot determine ROOTDIR for MITgcm code."
629     echo " Please specify a ROOTDIR using either an options "
630     echo " file or a command-line option."
631     exit 1
632     fi
633     if test ! -d ${ROOTDIR} ; then
634     echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
635     exit 1
636     fi
637    
638 edhill 1.1 echo " getting OPTFILE information: "
639     if test "x${OPTFILE}" = x ; then
640 edhill 1.11 if test "x$MITGCM_OF" = x ; then
641     echo "Warning: no OPTFILE specified so we'll look for possible settings"
642     printf "\n=== Searching for possible settings for OPTFILE ===\n"
643     find_possible_configs
644 edhill 1.1 else
645 edhill 1.11 OPTFILE=$MITGCM_OF
646     fi
647     fi
648     if test "x$OPTFILE" != xNONE ; then
649     if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
650     echo " using OPTFILE=\"$OPTFILE\""
651     source "$OPTFILE"
652     RETVAL=$?
653     if test "x$RETVAL" != x0 ; then
654     echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
655     echo "--please check that variable syntax is bash-compatible"
656 edhill 1.1 exit 1
657     fi
658 edhill 1.11 if test "x$DUMPSTATE" != xf ; then
659 edhill 1.12 cp -f $OPTFILE "genmake_optfile"
660 edhill 1.11 fi
661     else
662     echo "Error: can't read OPTFILE=\"$OPTFILE\""
663     exit 1
664 edhill 1.1 fi
665     fi
666 edhill 1.8
667 edhill 1.14 echo " getting AD_OPTFILE information: "
668     if test "x${AD_OPTFILE}" = x ; then
669     if test "x$MITGCM_AD_OF" = x ; then
670     AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
671     else
672     AD_OPTFILE=$MITGCM_AD_OF
673     fi
674     fi
675     if test "x${AD_OPTFILE}" != xNONE ; then
676     if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
677     echo " using AD_OPTFILE=\"$AD_OPTFILE\""
678     source "$AD_OPTFILE"
679     RETVAL=$?
680     if test "x$RETVAL" != x0 ; then
681     echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
682     echo "--please check that variable syntax is bash-compatible"
683     exit 1
684     fi
685     if test "x$DUMPSTATE" != xf ; then
686     cp -f $AD_OPTFILE "genmake_ad_optfile"
687     fi
688     else
689     echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
690     exit 1
691     fi
692     fi
693    
694 edhill 1.8 # Check that FC, LINK, CPP, and S64 are defined. If not, complain
695     # and abort!
696     if test "x$FC" = x ; then
697     cat <<EOF 1>&2
698    
699     Error: no Fortran compiler: please specify using one of the following:
700     1) within the options file ("FC=...") as specified by "-of=OPTFILE"
701     2) the "-fc=XXX" command-line option
702 edhill 1.12 3) the "./genmake_local" file
703 edhill 1.8 EOF
704     exit 1
705     fi
706     if test "x$LINK" = x ; then
707     LINK=$FC
708     fi
709     if test "x$CPP" = x ; then
710 edhill 1.11 CPP="cpp"
711     fi
712 edhill 1.13 echo "#define A a" | $CPP > test_cpp 2>&1
713 edhill 1.11 RETVAL=$?
714     if test "x$RETVAL" != x0 ; then
715 edhill 1.8 cat <<EOF 1>&2
716    
717 edhill 1.11 Error: C pre-processor "$CPP" failed the test case: please specify using:
718    
719 edhill 1.8 1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
720 edhill 1.12 2) the "./genmake_local" file
721 edhill 1.30 3) with the CPP environment variable
722 edhill 1.11
723 edhill 1.8 EOF
724     exit 1
725 edhill 1.11 else
726     rm -f test_cpp
727 edhill 1.8 fi
728 edhill 1.11 if test "x$MAKEDEPEND" = x ; then
729     MAKEDEPEND=makedepend
730 edhill 1.8 fi
731 edhill 1.29
732    
733     printf "\n=== Checking system libraries ===\n"
734     echo -n " Do we have the system() command using $FC... "
735     cat > genmake_tcomp.f <<EOF
736     program hello
737     call system('echo hi')
738     end
739     EOF
740     $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
741     RETVAL=$?
742     if test "x$RETVAL" = x0 ; then
743     HAVE_SYSTEM=t
744     DEFINES="$DEFINES -DHAVE_SYSTEM"
745     echo "yes"
746     else
747     HAVE_SYSTEM=
748     echo "no"
749     fi
750     rm -f genmake_tcomp*
751    
752     echo -n " Do we have the fdate() command using $FC... "
753     cat > genmake_tcomp.f <<EOF
754     program hello
755     CHARACTER(128) string
756     string = ' '
757     call fdate( string )
758     print *, string
759     end
760     EOF
761     $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
762     RETVAL=$?
763     if test "x$RETVAL" = x0 ; then
764     HAVE_FDATE=t
765     DEFINES="$DEFINES -DHAVE_FDATE"
766     echo "yes"
767     else
768     HAVE_FDATE=
769     echo "no"
770     fi
771     rm -f genmake_tcomp*
772    
773 edhill 1.31 echo " The name mangling convention for $FC is... "
774     #FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _"
775 edhill 1.29 if test "x$FC_NAMEMANGLE" = x ; then
776 edhill 1.31 get_fortran_c_namemangling
777 edhill 1.29 fi
778 edhill 1.31 echo " '$FC_NAMEMANGLE'"
779 edhill 1.29 echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template
780     cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1
781     RETVAL=$?
782     if test "x$RETVAL" != x0 ; then
783     mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h
784     fi
785    
786 edhill 1.8
787 edhill 1.2 printf "\n=== Setting defaults ===\n"
788 edhill 1.1 echo -n " Adding MODS directories: "
789     for d in $MODS ; do
790     if test ! -d $d ; then
791 edhill 1.2 echo
792     echo "Error: MODS directory \"$d\" not found!"
793 edhill 1.1 exit 1
794     else
795     echo -n " $d"
796     SOURCEDIRS="$SOURCEDIRS $d"
797     INCLUDEDIRS="$INCLUDEDIRS $d"
798     fi
799     done
800     echo
801    
802     if test "x$MAKEFILE" = x ; then
803     MAKEFILE="Makefile"
804     fi
805     if test "x${PLATFORM}" = x ; then
806     PLATFORM=$p_PLATFORM
807     fi
808    
809     if test "x${EXEDIR}" = x ; then
810     if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
811     EXEDIR=../exe
812     else
813     EXEDIR=.
814     fi
815     fi
816     if test ! -d ${EXEDIR} ; then
817     echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
818     exit 1
819     fi
820    
821     if test "x${TOOLSDIR}" = x ; then
822     TOOLSDIR="$ROOTDIR/tools"
823     fi
824     if test ! -d ${TOOLSDIR} ; then
825     echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
826     exit 1
827     fi
828 edhill 1.11 if test "x$S64" = x ; then
829     S64='$(TOOLSDIR)/set64bitConst.sh'
830     fi
831 edhill 1.1
832     EXECUTABLE=${EXECUTABLE:-mitgcmuv}
833    
834     # We have a special set of source files in eesupp/src which are
835     # generated from some template source files. We'll make them first so
836     # they appear as regular source code
837     if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
838     echo " Making source files in eesupp from templates"
839     $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1
840     RETVAL=$?
841 edhill 1.2 if test "x${RETVAL}" = x0 ; then
842 edhill 1.1 rm -f make_eesupp.errors
843     else
844     echo "Error: problem encountered while building source files in eesupp:"
845     cat make_eesupp.errors
846     exit 1
847     fi
848     fi
849    
850 edhill 1.2 printf "\n=== Determining package settings ===\n"
851 edhill 1.1 if test "x${PDEPEND}" = x ; then
852     tmp=$ROOTDIR"/pkg/pkg_depend"
853     if test -r $tmp ; then
854     PDEPEND=$tmp
855     else
856     echo "Warning: No package dependency information was specified."
857     echo " Please check that ROOTDIR/pkg/pkg_depend exists."
858     fi
859     else
860     if test ! -r ${PDEPEND} ; then
861     echo "Error: can't read package dependency info from PDEPEND=\"$PDEPEND\""
862     exit 1
863     fi
864     fi
865     echo " getting package dependency info from $PDEPEND"
866     # Strip the comments and then convert the dependency file into
867     # two arrays: PNAME, DNAME
868     cat $PDEPEND | sed -e 's/#.*$//g' \
869 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}' \
870 edhill 1.1 > ./.pd_tmp
871     RETVAL=$?
872     if test ! "x${RETVAL}" = x0 ; then
873     echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
874     exit 1
875     fi
876     source ./.pd_tmp
877     rm -f ./.pd_tmp
878    
879 edhill 1.12 # Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups"
880     # file should eventually be added so that, for convenience, one can
881     # specify groups of packages using names like "ocean" and "atmosphere".
882 edhill 1.1 echo -n " checking default package list: "
883     if test "x${PDEFAULT}" = x ; then
884 edhill 1.12 for i in "." $MODS ; do
885     if test -r $i"/packages.conf" ; then
886     PDEFAULT=$i"/packages.conf"
887     break
888     fi
889     done
890     fi
891     if test "x${PDEFAULT}" = x ; then
892 edhill 1.1 PDEFAULT="$ROOTDIR/pkg/pkg_default"
893     fi
894     if test "x${PDEFAULT}" = xNONE ; then
895     echo "default packages file disabled"
896     else
897     if test ! -r $PDEFAULT ; then
898     echo ""
899     echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\""
900     else
901     echo " using PDEFAULT=\"$PDEFAULT\""
902     # Strip the comments and add all the names
903 edhill 1.15 def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
904 edhill 1.1 RETVAL=$?
905     if test "x${RETVAL}" != x0 ; then
906     echo -n "Error: can't parse default package list "
907     echo "-- please check PDEFAULT=\"$PDEFAULT\""
908     exit 1
909     fi
910     for i in $def ; do
911     PACKAGES="$PACKAGES $i"
912     done
913 edhill 1.12 echo " before group expansion packages are: $PACKAGES"
914     expand_pkg_groups
915     echo " after group expansion packages are: $PACKAGES"
916 edhill 1.1 fi
917     fi
918    
919     echo " applying DISABLE settings"
920     pack=
921     for p in $PACKAGES ; do
922     addit="t"
923     for d in $DISABLE ; do
924     if test "x$p" = "x$d" ; then
925     addit="f"
926     fi
927     done
928     if test "x$addit" = xt ; then
929     pack="$pack $p"
930     fi
931     done
932     PACKAGES="$pack"
933     echo " applying ENABLE settings"
934 edhill 1.12 echo "" > ./.tmp_pack
935 edhill 1.1 PACKAGES="$PACKAGES $ENABLE"
936     for i in $PACKAGES ; do
937     if test ! -d "$ROOTDIR/pkg/$i" ; then
938     echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
939     exit 1
940     fi
941     echo $i >> ./.tmp_pack
942     done
943     pack=`cat ./.tmp_pack | sort | uniq`
944     rm -f ./.tmp_pack
945     PACKAGES=
946     for i in $pack ; do
947     PACKAGES="$PACKAGES $i"
948     done
949     echo " packages are: $PACKAGES"
950    
951     echo " applying package dependency rules"
952     ck=
953     while test "x$ck" != xtt ; do
954     i=0
955 edhill 1.2 # rtot=${#PNAME[@]}
956     rtot=$nname
957 edhill 1.1 while test $i -lt $rtot ; do
958    
959     # Is $pname in the current $PACKAGES list?
960 edhill 1.2 # pname=${PNAME[$i]}
961     tmp="pname=\"\$PNAME_$i\""
962     eval $tmp
963 edhill 1.1 pin="f"
964     for p in $PACKAGES ; do
965     if test "x$p" = "x$pname" ; then
966     pin="t"
967     fi
968     done
969    
970     # Is the DNAME entry a (+) or (-) rule ?
971 edhill 1.2 tmp="dname=\"\$DNAME_$i\""
972     eval $tmp
973 edhill 1.1 plus="-"
974 edhill 1.2 echo $dname | grep '^+' > /dev/null 2>&1
975 edhill 1.1 RETVAL=$?
976     if test "x$RETVAL" = x0 ; then
977     plus="+"
978     fi
979    
980     # Is $dname in the current $PACKAGES list?
981 edhill 1.2 dname=`echo $dname | sed -e 's/^[+-]//'`
982 edhill 1.1 din="f"
983     for p in $PACKAGES ; do
984     if test "x$p" = "x$dname" ; then
985     din="t"
986     fi
987     done
988    
989     # Do we need to add $dname according to the dependency rules?
990     if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
991     in_dis="f"
992     for dis in $DISABLE ; do
993     if test "x$dis" = "x$dname" ; then
994     in_dis="t"
995     fi
996     done
997     if test "x$in_dis" = xt ; then
998     echo "Error: can't satisfy package dependencies:"
999     echo " \"$dname\" is required by the dependency rules"
1000     echo " but is disallowed by the DISABLE settings"
1001     exit 1
1002     else
1003     PACKAGES="$PACKAGES $dname"
1004     ck=
1005     fi
1006     fi
1007    
1008     # Do we need to get rid of $dname according to the dependency rules?
1009     if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
1010     echo "Error: can't satisfy package dependencies:"
1011     echo " \"$pname\" was requested but is disallowed by"
1012     echo " the dependency rules for \"$dname\""
1013     exit 1
1014     fi
1015     i=$(( $i + 1 ))
1016     done
1017     ck=$ck"t"
1018     done
1019     echo " packages are: $PACKAGES"
1020     for i in $PACKAGES ; do
1021     adr="$ROOTDIR/pkg/$i"
1022     if test -d $adr ; then
1023     SOURCEDIRS="$SOURCEDIRS $adr"
1024     INCLUDEDIRS="$INCLUDEDIRS $adr"
1025 edhill 1.14 if test "x$i" = xautodiff ; then
1026     AUTODIFF_PKG_USED=t
1027     fi
1028 edhill 1.1 else
1029     echo "Error: the directory \"$adr\" for package $i doesn't exist"
1030     exit 1
1031     fi
1032     done
1033    
1034    
1035 edhill 1.12 # Create a list of #define and #undef to enable/disable packages
1036     PACKAGES_DOT_H=PACKAGES_CONFIG.h
1037     cat <<EOF >$PACKAGES_DOT_H".tmp"
1038 edhill 1.1 C=== GENMAKE v2 ===
1039 edhill 1.11 C The following defines have been set by GENMAKE, so please do not
1040     C edit anything below these comments. In general, you should
1041 edhill 1.1 C add or remove packages by re-running genmake with different
1042     C "-enable" and/or "-disable" options.
1043    
1044 edhill 1.12 #ifndef PACKAGES_H
1045     #define PACKAGES_H
1046    
1047 edhill 1.1 C Packages disabled by genmake:
1048     EOF
1049     # The following UGLY HACK sets multiple "#undef"s and it needs to go
1050     # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
1051     # file would eventually be split up so that all package-related #define
1052     # statements could be separated and handled only by genmake.
1053     names=`ls -1 "$ROOTDIR/pkg"`
1054     all_pack=
1055     for n in $names ; do
1056     if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
1057     has_pack="f"
1058     for pack in $PACKAGES ; do
1059     if test "x$pack" = "x$n" ; then
1060     has_pack="t"
1061     break
1062     fi
1063     done
1064     if test "x$has_pack" = xf ; then
1065 edhill 1.15 undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
1066 edhill 1.12 echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
1067 edhill 1.1 fi
1068     fi
1069     done
1070 edhill 1.12 cat <<EOF >>$PACKAGES_DOT_H".tmp"
1071 edhill 1.1
1072     C Packages enabled by genmake:
1073     EOF
1074     for i in $PACKAGES ; do
1075 edhill 1.15 def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
1076 edhill 1.12 echo "#define $def" >> $PACKAGES_DOT_H".tmp"
1077     #eh3 DEFINES="$DEFINES -D$def"
1078 edhill 1.1
1079     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
1080     case $i in
1081     aim_v23)
1082 edhill 1.12 echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
1083     DEFINES="$DEFINES -DALLOW_AIM"
1084     echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
1085 edhill 1.1 ;;
1086     esac
1087     #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
1088    
1089     done
1090 edhill 1.12 cat <<EOF >>$PACKAGES_DOT_H".tmp"
1091    
1092     #endif /* PACKAGES_H */
1093     EOF
1094    
1095     if test ! -f $PACKAGES_DOT_H ; then
1096     mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1097     else
1098     cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1099     RETVAL=$?
1100     if test "x$RETVAL" = x0 ; then
1101     rm -f $PACKAGES_DOT_H".tmp"
1102     else
1103     mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
1104     mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1105     fi
1106     fi
1107 edhill 1.1
1108     echo " Adding STANDARDDIRS"
1109     BUILDDIR=${BUILDDIR:-.}
1110 edhill 1.12 if test "x$STANDARDDIRS" = x ; then
1111     STANDARDDIRS="eesupp model"
1112     fi
1113 edhill 1.1 for d in $STANDARDDIRS ; do
1114     adr="$ROOTDIR/$d/src"
1115     if test ! -d $adr ; then
1116     echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1117     echo " is correct and that you correctly specified the STANDARDDIRS option"
1118     exit 1
1119     else
1120     SOURCEDIRS="$SOURCEDIRS $adr"
1121     fi
1122     adr="$ROOTDIR/$d/inc"
1123     if test ! -d $adr ; then
1124     echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1125     echo " is correct and that you correctly specified the STANDARDDIRS option"
1126     exit 1
1127     else
1128     INCLUDEDIRS="$INCLUDEDIRS $adr"
1129     fi
1130     done
1131    
1132 edhill 1.22 echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
1133     echo " of \"#define ALLOW_PKGNAME\"-type statements:"
1134 edhill 1.12 CPP_OPTIONS=
1135     spaths=". $INCLUDEDIRS"
1136     for i in $spaths ; do
1137     try="$i/CPP_OPTIONS.h"
1138     # echo -n " trying $try : "
1139     if test -f $try -a -r $try ; then
1140     echo " found CPP_OPTIONS=\"$try\""
1141     CPP_OPTIONS="$try"
1142     break
1143     fi
1144     done
1145     if test "x$CPP_OPTIONS" = x ; then
1146     echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1147     exit 1
1148     fi
1149     # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1150     names=`ls -1 "$ROOTDIR/pkg"`
1151     for n in $names ; do
1152     test_for_package_in_cpp_options $CPP_OPTIONS $n
1153     done
1154    
1155 edhill 1.1
1156 edhill 1.14 # Here, we build the list of files to be "run through" the adjoint
1157     # compiler.
1158     if test -f ./ad_files ; then
1159     rm -f ./ad_files
1160     fi
1161     echo " Creating the list of files for the adjoint compiler."
1162     for i in $SOURCEDIRS ; do
1163     list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1164     for j in $list_files ; do
1165     cat $i/$j >> ad_files
1166     done
1167     done
1168    
1169     cat <<EOF > adjoint_sed
1170     s/call adopen(/call adopen ( mythid,\\
1171     \& /g
1172     s/call adclose(/call adclose( mythid,\\
1173     \& /g
1174     s/call adread(/call adread ( mythid,\\
1175     \& /g
1176     s/call adwrite(/call adwrite( mythid,\\
1177     \& /g
1178    
1179     EOF
1180    
1181 edhill 1.2 echo
1182     echo "=== Creating the Makefile ==="
1183 edhill 1.1 echo " setting INCLUDES"
1184     for i in $INCLUDEDIRS ; do
1185 edhill 1.12 if ! test -d $i ; then
1186     # INCLUDES="$INCLUDES -I$i"
1187     # else
1188 edhill 1.1 echo "Warning: can't find INCLUDEDIRS=\"$i\""
1189     fi
1190     done
1191    
1192     echo " Determining the list of source and include files"
1193     rm -rf .links.tmp
1194     mkdir .links.tmp
1195     echo "# This section creates symbolic links" > srclinks.tmp
1196     echo "" >> srclinks.tmp
1197 cnh 1.3 echo -n 'SRCFILES = ' > srclist.inc
1198     echo -n 'CSRCFILES = ' > csrclist.inc
1199     echo -n 'F90SRCFILES = ' > f90srclist.inc
1200 edhill 1.1 echo -n 'HEADERFILES = ' > hlist.inc
1201 edhill 1.14 echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc
1202 adcroft 1.9 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1203 edhill 1.1 for d in $alldirs ; do
1204     deplist=
1205 edhill 1.14 sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1206 cnh 1.3 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1207 edhill 1.1 for sf in $sfiles ; do
1208     if test ! -r ".links.tmp/$sf" ; then
1209     if test -f "$d/$sf" ; then
1210 edhill 1.15 extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1211 edhill 1.1 touch .links.tmp/$sf
1212     deplist="$deplist $sf"
1213     case $extn in
1214     F)
1215     echo " \\" >> srclist.inc
1216     echo -n " $sf" >> srclist.inc
1217     ;;
1218 cnh 1.3 F90)
1219     echo " \\" >> f90srclist.inc
1220     echo -n " $sf" >> f90srclist.inc
1221     ;;
1222 edhill 1.1 c)
1223     echo " \\" >> csrclist.inc
1224     echo -n " $sf" >> csrclist.inc
1225     ;;
1226     h)
1227     echo " \\" >> hlist.inc
1228     echo -n " $sf" >> hlist.inc
1229     ;;
1230 edhill 1.14 flow)
1231     echo " \\" >> ad_flow_files.inc
1232     echo -n " $sf" >> ad_flow_files.inc
1233     ;;
1234 edhill 1.1 esac
1235     fi
1236     fi
1237     done
1238     if test "x$deplist" != x ; then
1239 edhill 1.2 echo "" >> srclinks.tmp
1240     echo "# These files are linked from $d" >> srclinks.tmp
1241 edhill 1.1 echo "$deplist :" >> srclinks.tmp
1242 edhill 1.2 printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
1243 edhill 1.1 fi
1244     done
1245     rm -rf .links.tmp
1246     echo "" >> srclist.inc
1247     echo "" >> csrclist.inc
1248 cnh 1.3 echo "" >> f90srclist.inc
1249 edhill 1.1 echo "" >> hlist.inc
1250 edhill 1.14 echo "" >> ad_flow_files.inc
1251 edhill 1.1
1252     if test -e $MAKEFILE ; then
1253     mv -f $MAKEFILE "$MAKEFILE.bak"
1254     fi
1255     echo " Writing makefile: $MAKEFILE"
1256     echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
1257     echo "# $MACHINE" >> $MAKEFILE
1258     echo "# This makefile was generated automatically on" >> $MAKEFILE
1259     echo "# $THISDATE" >> $MAKEFILE
1260     echo "# by the command:" >> $MAKEFILE
1261     echo "# $0 $@" >> $MAKEFILE
1262     echo "# executed by:" >> $MAKEFILE
1263     echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1264 edhill 1.21
1265     EXE_AD=$EXECUTABLE"_ad"
1266     EXE_FTL=$EXECUTABLE"_ftl"
1267     EXE_SVD=$EXECUTABLE"_svd"
1268    
1269 edhill 1.1 cat >>$MAKEFILE <<EOF
1270     #
1271     # BUILDDIR : Directory where object files are written
1272     # SOURCEDIRS : Directories containing the source (.F) files
1273     # INCLUDEDIRS : Directories containing the header-source (.h) files
1274     # EXEDIR : Directory where executable that is generated is written
1275     # EXECUTABLE : Full path of executable binary
1276     #
1277     # CPP : C-preprocessor command
1278     # INCLUDES : Directories searched for header files
1279     # DEFINES : Macro definitions for CPP
1280     # MAKEDEPEND : Dependency generator
1281     # KPP : Special preprocessor command (specific to platform)
1282     # KFLAGS : Flags for KPP
1283     # FC : Fortran compiler command
1284     # FFLAGS : Configuration/debugging options for FC
1285     # FOPTIM : Optimization options for FC
1286     # LINK : Command for link editor program
1287     # LIBS : Library flags /or/ additional optimization/debugging flags
1288    
1289     ROOTDIR = ${ROOTDIR}
1290     BUILDDIR = ${BUILDDIR}
1291     SOURCEDIRS = ${SOURCEDIRS}
1292     INCLUDEDIRS = ${INCLUDEDIRS}
1293     EXEDIR = ${EXEDIR}
1294     EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
1295     TOOLSDIR = ${TOOLSDIR}
1296    
1297 edhill 1.14 #eh3 new defines for the adjoint work
1298     AUTODIFF = ${ROOTDIR}/pkg/autodiff
1299 edhill 1.21 EXE_AD = ${EXE_AD}
1300     EXE_FTL = ${EXE_FTL}
1301     EXE_SVD = ${EXE_SVD}
1302 edhill 1.14
1303 edhill 1.1 EOF
1304    
1305     # Note: figure out some way to add Hyades JAM libraries here
1306    
1307     cat >>$MAKEFILE <<EOF
1308     # Unix ln (link)
1309     LN = ${LN}
1310     # C preprocessor
1311     CPP = cat \$< | ${S64} | ${CPP}
1312     # Dependency generator
1313     MAKEDEPEND = ${MAKEDEPEND}
1314     # Special preprocessor (KAP on DECs, FPP on Crays)
1315     KPP = ${KPP}
1316     # Fortran compiler
1317     FC = ${FC}
1318 cnh 1.3 # Fortran compiler
1319     F90C = ${F90C}
1320 edhill 1.1 # Link editor
1321     LINK = ${LINK}
1322    
1323     # Defines for CPP
1324     DEFINES = ${DEFINES}
1325     # Includes for CPP
1326     INCLUDES = ${INCLUDES}
1327     # Flags for KPP
1328     KFLAGS1 = ${KFLAGS1}
1329     KFLAGS2 = ${KFLAGS2}
1330     # Optim./debug for FC
1331     FFLAGS = ${FFLAGS}
1332     FOPTIM = ${FOPTIM}
1333 cnh 1.3 # Optim./debug for FC
1334     F90FLAGS = ${F90FLAGS}
1335     F90OPTIM = ${F90OPTIM}
1336 edhill 1.1 # Flags for CC
1337     CFLAGS = ${CFLAGS}
1338     # Files that should not be optimized
1339     NOOPTFILES = ${NOOPTFILES}
1340     NOOPTFLAGS = ${NOOPTFLAGS}
1341     # Flags and libraries needed for linking
1342     LIBS = ${LIBS} \$(XLIBS)
1343 cnh 1.3 # Name of the Mekfile
1344     MAKEFILE=${MAKEFILE}
1345 edhill 1.1
1346     EOF
1347    
1348 edhill 1.14 cat srclist.inc >> $MAKEFILE
1349     cat csrclist.inc >> $MAKEFILE
1350     cat f90srclist.inc >> $MAKEFILE
1351     cat hlist.inc >> $MAKEFILE
1352     cat ad_flow_files.inc >> $MAKEFILE
1353     echo >> $MAKEFILE
1354 cnh 1.3 echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE
1355     echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE
1356     echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1357 edhill 1.1
1358 cnh 1.3 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1359 edhill 1.14 rm -f ad_flow_files.inc
1360 edhill 1.1
1361     cat >>$MAKEFILE <<EOF
1362    
1363     .SUFFIXES:
1364 cnh 1.3 .SUFFIXES: .o .f .p .F .c .F90 .f90
1365 edhill 1.1
1366     all: \$(EXECUTABLE)
1367     \$(EXECUTABLE): \$(OBJFILES)
1368     \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1369     depend:
1370     @make links
1371     \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1372 edhill 1.7 ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
1373 edhill 1.1
1374 cnh 1.3 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
1375 edhill 1.1
1376 cnh 1.3 small_f: \$(F77FILES) \$(F90FILES)
1377 edhill 1.1
1378     output.txt: \$(EXECUTABLE)
1379     @printf 'running ... '
1380     @\$(EXECUTABLE) > \$@
1381    
1382     clean:
1383 edhill 1.22 -cat AD_CONFIG.template > AD_CONFIG.h
1384 cnh 1.3 -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1385 edhill 1.1 Clean:
1386     @make clean
1387     @make cleanlinks
1388 edhill 1.22 -rm -f Makefile.bak genmake_state genmake_*optfile make.log
1389 edhill 1.1 CLEAN:
1390     @make Clean
1391     -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1392     -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1393     -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1394 edhill 1.12 -rm -f \$(EXECUTABLE) output.txt
1395 edhill 1.1
1396 edhill 1.18 #eh3 Makefile: makefile
1397 edhill 1.1 makefile:
1398     ${0} $@
1399     cleanlinks:
1400     -find . -type l -exec rm {} \;
1401    
1402     # The normal chain of rules is ( .F - .f - .o )
1403     .F.f:
1404     \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1405     .f.o:
1406     \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1407 cnh 1.3 .F90.f90:
1408     \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1409     .f90.o:
1410     \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1411 edhill 1.1 .c.o:
1412     \$(CC) \$(CFLAGS) -c \$<
1413    
1414     # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
1415     .F.p:
1416     \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1417     .p.f:
1418     \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1419 edhill 1.14
1420     #=========================================
1421     #=== Automatic Differentiation Rules ===
1422    
1423     TAMC = ${TAMC}
1424     TAF = ${TAF}
1425    
1426 edhill 1.17 TAF_EXTRA = ${TAF_EXTRA}
1427     TAMC_EXTRA = ${TAMC_EXTRA}
1428    
1429 edhill 1.14 EOF
1430    
1431     ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1432     ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1433     ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1434     for i in $ad_vars ; do
1435     name=$i
1436     t1="t2=\$"`echo $i`
1437     eval $t1
1438     printf "%-20s = " $name >> $MAKEFILE
1439     echo $t2 >> $MAKEFILE
1440     done
1441    
1442     echo " Add the source list for AD code generation"
1443     echo >> $MAKEFILE
1444     echo -n "AD_FILES = " >> $MAKEFILE
1445     AD_FILES=`cat ad_files`
1446     for i in $AD_FILES ; do
1447     echo " \\" >> $MAKEFILE
1448     echo -n " $i" >> $MAKEFILE
1449     done
1450     echo >> $MAKEFILE
1451 edhill 1.21 rm -f ad_files
1452 edhill 1.14
1453     cat >>$MAKEFILE <<EOF
1454    
1455 edhill 1.16 # ... AD ...
1456 edhill 1.23 adall: ad_taf
1457     adtaf: ad_taf_output.f
1458     adtamc: ad_tamc_output.f
1459 edhill 1.21
1460 heimbach 1.26 ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1461 edhill 1.23 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1462 edhill 1.22 @make \$(F77FILES)
1463     @make \$(AD_FLOW_FILES)
1464     cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1465    
1466 edhill 1.14 ad_taf_output.f: ad_input_code.f
1467 edhill 1.17 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1468 edhill 1.14 cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1469    
1470     ad_taf: ad_taf_output.o \$(OBJFILES)
1471 edhill 1.21 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1472 edhill 1.14
1473     ad_tamc_output.f: ad_input_code.f
1474 edhill 1.17 \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1475 edhill 1.16 cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1476 edhill 1.14
1477     ad_tamc: ad_tamc_output.o \$(OBJFILES)
1478 edhill 1.21 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1479 edhill 1.14
1480    
1481 edhill 1.19 # ... FTL ...
1482 edhill 1.23 ftlall: ftl_taf
1483     ftltaf: ftl_taf_output.f
1484     ftltamc: ftl_tamc_output.f
1485 edhill 1.21
1486 heimbach 1.26 ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1487 edhill 1.23 cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1488     @make \$(F77FILES)
1489 edhill 1.22 @make \$(AD_FLOW_FILES)
1490     cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1491    
1492     ftl_taf_output.f: ftl_input_code.f
1493     \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1494     cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f
1495 edhill 1.14
1496 edhill 1.19 ftl_taf: ftl_taf_output.o \$(OBJFILES)
1497 edhill 1.21 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1498 edhill 1.14
1499 edhill 1.22 ftl_tamc_output.f: ftl_input_code.f
1500     \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1501     cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f
1502 edhill 1.16
1503 edhill 1.19 ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1504 edhill 1.21 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1505 edhill 1.16
1506    
1507     # ... SVD ...
1508 edhill 1.21 svd: svd_taf
1509     svd_taf_f: svd_taf_output.f
1510    
1511 edhill 1.22 svd_input_code.f: \$(SRCFILES)
1512 edhill 1.23 cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h
1513     @make \$(F77FILES)
1514 edhill 1.22 @make \$(AD_FLOW_FILES)
1515     cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f
1516    
1517     svd_taf_output.f: svd_input_code.f
1518     \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f
1519     cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1520 edhill 1.16
1521     svd_taf: svd_taf_output.o \$(OBJFILES)
1522 edhill 1.21 \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1523 edhill 1.14
1524    
1525     #=========================================
1526 edhill 1.1
1527     EOF
1528 edhill 1.7
1529     if test "x$EXEHOOK" != x ; then
1530     printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1531     fi
1532 edhill 1.1
1533     echo " Making list of \"exceptions\" that need \".p\" files"
1534     for i in $KPPFILES ; do
1535     base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
1536     RETVAL=$?
1537     if test "x$RETVAL" != x0 ; then
1538     echo "Error: unable to add file \"$i\" to the exceptions list"
1539     fi
1540     echo "$base.f: $base.p" >> $MAKEFILE
1541     done
1542    
1543     echo " Making list of NOOPTFILES"
1544     for i in $NOOPTFILES ; do
1545     base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
1546     RETVAL=$?
1547     if test "x$RETVAL" != x0 ; then
1548     echo "Error: unable to add file \"$i\" to the exceptions list"
1549     fi
1550     echo "$base.o: $base.f" >> $MAKEFILE
1551 edhill 1.2 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1552 edhill 1.1 done
1553    
1554     echo " Add rules for links"
1555     cat srclinks.tmp >> $MAKEFILE
1556     rm -f srclinks.tmp
1557    
1558     echo " Adding makedepend marker"
1559 edhill 1.2 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1560 edhill 1.1
1561 edhill 1.2 printf "\n=== Done ===\n"
1562 edhill 1.22
1563     # Write the "template" files for the adjoint builds
1564 edhill 1.23 cat >AD_CONFIG.template <<EOF
1565 edhill 1.22 C WARNING: This file is automatically generated by genmake2 and
1566     C used by the Makefile rules. Please DO NOT EDIT this file
1567 edhill 1.23 C unless you are CERTAIN that you know what you are doing.
1568 edhill 1.22
1569     #undef ALLOW_ADJOINT_RUN
1570     #undef ALLOW_TANGENTLINEAR_RUN
1571     #undef ALLOW_ECCO_OPTIMIZATION
1572     EOF
1573 edhill 1.23 cat >ad_config.template <<EOF
1574 edhill 1.22 C WARNING: This file is automatically generated by genmake2 and
1575     C used by the Makefile rules. Please DO NOT EDIT this file
1576 edhill 1.23 C unless you are CERTAIN that you know what you are doing.
1577 edhill 1.22
1578 edhill 1.23 #define ALLOW_ADJOINT_RUN
1579 edhill 1.22 #undef ALLOW_TANGENTLINEAR_RUN
1580     #undef ALLOW_ECCO_OPTIMIZATION
1581     EOF
1582 edhill 1.23 cat >ftl_config.template <<EOF
1583 edhill 1.22 C WARNING: This file is automatically generated by genmake2 and
1584     C used by the Makefile rules. Please DO NOT EDIT this file
1585 edhill 1.23 C unless you are CERTAIN that you know what you are doing.
1586 edhill 1.22
1587     #undef ALLOW_ADJOINT_RUN
1588 edhill 1.23 #define ALLOW_TANGENTLINEAR_RUN
1589 edhill 1.22 #undef ALLOW_ECCO_OPTIMIZATION
1590     EOF
1591 edhill 1.23 cat >svd_config.template <<EOF
1592 edhill 1.22 C WARNING: This file is automatically generated by genmake2 and
1593     C used by the Makefile rules. Please DO NOT EDIT this file
1594 edhill 1.23 C unless you are CERTAIN that you know what you are doing.
1595 edhill 1.22
1596     #undef ALLOW_ADJOINT_RUN
1597     #undef ALLOW_TANGENTLINEAR_RUN
1598     #undef ALLOW_ECCO_OPTIMIZATION
1599     EOF
1600     cp AD_CONFIG.template AD_CONFIG.h
1601 edhill 1.5
1602    
1603     # Write the "state" for future records
1604     if test "x$DUMPSTATE" != xf ; then
1605 edhill 1.12 echo -n "" > genmake_state
1606 edhill 1.5 for i in $gm_state ; do
1607     t1="t2=\$$i"
1608     eval $t1
1609 edhill 1.12 echo "$i='$t2'" >> genmake_state
1610 edhill 1.5 done
1611     fi

  ViewVC Help
Powered by ViewVC 1.1.22