Warning, /tools/genmake2 is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit f955de4b on 2025-01-19 04:15:59 UTC
3185ed66f0 Ed H*0001 #! /usr/bin/env bash
6aec5d9846 Ed H*0002 #
0003 # Makefile generator for MITgcm UV codes
0004 # created by cnh 03/98
0005 # adapted by aja 06/98
0006 # modified by aja 01/00
0007 # rewritten in bash by eh3 08/03
0008
23f21461eb Jean*0009 # Explain usage
0010 usage() {
0011 cat <<EOF
0012
0013 Usage: "$0" [OPTIONS]
0014 where [OPTIONS] can be:
0015
0016 -help | --help | -h | --h
36e14999eb Jean*0017 Print this help message and exit.
23f21461eb Jean*0018
b4daa24319 Shre*0019 -tap | --tap
0020 Generate a Makefile for a Tapenade build
0021
16cc6e2b59 Jean*0022 -oad | --oad
0023 Generate a Makefile for an OpenAD built
0024
9d0c386f0c dngo*0025 -oadsingularity NAME | --oadsingularity NAME | -oadsngl NAME | --oadsngl NAME
0026 -oadsingularity=NAME | --oadsingularity=NAME | -oadsngl=NAME | --oadsngl=NAME
0027 Here, "NAME" specifies the singularity file
0028 that contains the OpenAD execulable.
0029
44f4a23ebb Jean*0030 -nocat4ad | -dog4ad | -ncad | -dad
0031 do not concatenate (cat) source code sent to TAF
0032 resulting in compilation of multiple files
0033
23f21461eb Jean*0034 -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
0035 -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
36e14999eb Jean*0036 Use "NAME" as the adoptfile. By default, the file at
16cc6e2b59 Jean*0037 "tools/adjoint_options/adjoint_oad" (for OpenAD built) or
36e14999eb Jean*0038 "tools/adjoint_options/adjoint_default" will be used.
23f21461eb Jean*0039
bdd2b3a476 Jean*0040 -optfile NAME | --optfile NAME | -of NAME | --of NAME
23f21461eb Jean*0041 -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
36e14999eb Jean*0042 Use "NAME" as the optfile. By default, an attempt will be
0043 made to find an appropriate "standard" optfile in the
0044 tools/build_options/ directory.
23f21461eb Jean*0045
0046 -pdepend NAME | --pdepend NAME
0047 -pdepend=NAME | --pdepend=NAME
36e14999eb Jean*0048 Get package dependency information from "NAME".
23f21461eb Jean*0049
0050 -pgroups NAME | --pgroups NAME
0051 -pgroups=NAME | --pgroups=NAME
36e14999eb Jean*0052 Get the package groups information from "NAME".
23f21461eb Jean*0053
0054 -bash NAME
36e14999eb Jean*0055 Explicitly specify the Bourne or BASH shell to use
23f21461eb Jean*0056
0057 -make NAME | -m NAME
0058 --make=NAME | -m=NAME
36e14999eb Jean*0059 Use "NAME" for the MAKE program. The default is "make" but
0060 many platforms, "gmake" is the preferred choice.
23f21461eb Jean*0061
0062 -makefile NAME | -mf NAME
0063 --makefile=NAME | -mf=NAME
36e14999eb Jean*0064 Call the makefile "NAME". The default is "Makefile".
23f21461eb Jean*0065
0066 -makedepend NAME | -md NAME
0067 --makedepend=NAME | -md=NAME
36e14999eb Jean*0068 Use "NAME" for the MAKEDEPEND program.
23f21461eb Jean*0069
0070 -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
0071 -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
f955de4ba2 Jean*0072 Specify the location of the MITgcm root directory as 'NAME'.
0073 By default, genmake will try to find the location by
36e14999eb Jean*0074 looking in parent directories (up to the 5th parent).
23f21461eb Jean*0075
0076 -mods NAME | --mods NAME | -mo NAME | --mo NAME
0077 -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
36e14999eb Jean*0078 Here, "NAME" specifies a list of directories that are
0079 used for additional source code. Files found in the
0080 "mods list" are given preference over files of the same
0081 name found elsewhere.
23f21461eb Jean*0082
0083 -disable NAME | --disable NAME
0084 -disable=NAME | --disable=NAME
36e14999eb Jean*0085 Here "NAME" specifies a list of packages that we don't
0086 want to use. If this violates package dependencies,
f955de4ba2 Jean*0087 genmake will exit with an error message.
23f21461eb Jean*0088
0089 -enable NAME | --enable NAME
0090 -enable=NAME | --enable=NAME
36e14999eb Jean*0091 Here "NAME" specifies a list of packages that we wish
0092 to specifically enable. If this violates package
f955de4ba2 Jean*0093 dependencies, genmake will exit with an error message.
23f21461eb Jean*0094
0095 -standarddirs NAME | --standarddirs NAME
0096 -standarddirs=NAME | --standarddirs=NAME
36e14999eb Jean*0097 Here, "NAME" specifies a list of directories to be
0098 used as the "standard" code.
23f21461eb Jean*0099
0100 -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
0101 -fc=NAME | --fc=NAME
36e14999eb Jean*0102 Use "NAME" as the fortran compiler. By default, genmake
0103 will search for a working compiler by trying a list of
0104 "usual suspects" such as g77, f77, etc.
23f21461eb Jean*0105
0106 -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
36e14999eb Jean*0107 Use "NAME" as the C compiler. By default, genmake
0108 will search for a working compiler by trying a list of
0109 "usual suspects" such as gcc, c89, cc, etc.
23f21461eb Jean*0110
0111 -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
36e14999eb Jean*0112 Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
0113 *only* works if CPP_EEOPTIONS.h allows this.
23f21461eb Jean*0114
0115 -ignoretime | -ignore_time | --ignoretime | --ignore_time
36e14999eb Jean*0116 Ignore all the "wall clock" routines entirely. This will
0117 not in any way hurt the model results -- it simply means
0118 that the code that checks how long the model spends in
0119 various routines will give junk values.
23f21461eb Jean*0120
0121 -ts | --ts
36e14999eb Jean*0122 Produce timing information per timestep
23f21461eb Jean*0123 -papis | --papis
36e14999eb Jean*0124 Produce summary MFlop/s (and IPC) with PAPI per timestep
23f21461eb Jean*0125 -pcls | --pcls
36e14999eb Jean*0126 Produce summary MFlop/s etc. with PCL per timestep
23f21461eb Jean*0127 -foolad | --foolad
36e14999eb Jean*0128 Fool the AD code generator
23f21461eb Jean*0129 -papi | --papi
36e14999eb Jean*0130 Performance analysis with PAPI
23f21461eb Jean*0131 -pcl | --pcl
36e14999eb Jean*0132 Performance analysis with PCL
23f21461eb Jean*0133 -hpmt | --hpmt
36e14999eb Jean*0134 Performance analysis with the HPM Toolkit
23f21461eb Jean*0135
4d1f7e1a03 Jean*0136 -ieee | --ieee
36e14999eb Jean*0137 use IEEE numerics. Note that this option *only* works
0138 if it is supported by the OPTFILE that is being used.
23f21461eb Jean*0139 -devel | --devel
36e14999eb Jean*0140 Add additional warning and debugging flags for development
0141 (if supported by the OPTFILE); also switch to IEEE numerics.
4d1f7e1a03 Jean*0142 -gsl | --gsl
36e14999eb Jean*0143 Use GSL to control floating point rounding and precision
23f21461eb Jean*0144
0145 -mpi | --mpi
36e14999eb Jean*0146 Include MPI header files and link to MPI libraries
23f21461eb Jean*0147 -mpi=PATH | --mpi=PATH
36e14999eb Jean*0148 Include MPI header files and link to MPI libraries using MPI_ROOT
0149 set to PATH. i.e. Include files from \$PATH/include, link to libraries
0150 from \$PATH/lib and use binaries from \$PATH/bin.
23f21461eb Jean*0151
0152 -omp | --omp
fb8a3f8f0e Jean*0153 Activate OpenMP code
23f21461eb Jean*0154 -omp=OMPFLAG | --omp=OMPFLAG
36e14999eb Jean*0155 Activate OpenMP code + use Compiler option OMPFLAG
23f21461eb Jean*0156
0157 -es | --es | -embed-source | --embed-source
36e14999eb Jean*0158 Embed a tarball containing the full source code
0159 (including the Makefile, etc.) used to build the
0160 executable [off by default]
23f21461eb Jean*0161
0162 -ds | --ds
36e14999eb Jean*0163 Report genmake internal variables status (DUMPSTATE)
0164 to file "genmake_state" (for debug purpose)
23f21461eb Jean*0165
0166 While it is most often a single word, the "NAME" variables specified
0167 above can in many cases be a space-delimited string such as:
0168
0169 --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'
0170 -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'
0171 -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
0172
0173 which, depending upon your shell, may need to be single-quoted.
0174
516b08a580 jm-c 0175 For more detailed genmake documentation, please see section "Building the model"
0176 (under "Getting Started") at: https://mitgcm.readthedocs.io/
23f21461eb Jean*0177
0178 EOF
516b08a580 jm-c 0179 #- full link directly to section 3.5:
0180 #https://mitgcm.readthedocs.io/en/latest/getting_started/getting_started.html#building-the-model
23f21461eb Jean*0181
0182 exit 1
0183 }
0184
6d54cf9ca1 Ed H*0185 # Search for particular CPP #cmds associated with packages
0186 # usage: test_for_package_in_cpp_options CPP_file package_name
0187 test_for_package_in_cpp_options() {
0188 cpp_options=$1
0189 pkg=$2
e8e03c465c Jean*0190 test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_$pkg\>"
0191 test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_$pkg\>"
0192 test_for_string_in_file $cpp_options "^ *# *define *\<DISABLE_$pkg\>"
0193 test_for_string_in_file $cpp_options "^ *# *undef *\<DISABLE_$pkg\>"
40f7a33215 Alis*0194 }
0195
0196 # Search for particular CPP #cmds associated with MPI
0197 # usage: test_for_mpi_in_cpp_eeoptions CPP_file
0198 test_for_mpi_in_cpp_eeoptions() {
0199 cpp_options=$1
e8e03c465c Jean*0200 test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_USE_MPI\>"
0201 test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_USE_MPI\>"
40f7a33215 Alis*0202 }
0203
0204 # Search for particular string in a file. Return 1 if detected, 0 if not
0205 # usage: test_for_string_in_file file string
0206 test_for_string_in_file() {
0207 file=$1
0208 strng=$2
e8e03c465c Jean*0209 grep "$strng" $file > /dev/null 2>&1
6d54cf9ca1 Ed H*0210 RETVAL=$?
0211 if test "x${RETVAL}" = x0 ; then
13fa7032ba Ed H*0212 printf "Error: In $file there is an illegal line: "
36e14999eb Jean*0213 grep -i "$strng" $file
d54f5b7a0d Ed H*0214 exit 99
6d54cf9ca1 Ed H*0215 fi
40f7a33215 Alis*0216 return 0
6d54cf9ca1 Ed H*0217 }
0218
0219 # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
0220 # the package list.
0221 expand_pkg_groups() {
0222 new_packages=
0223 if test -r $PKG_GROUPS ; then
7deef35259 Jean*0224 cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > $TMP.p1
0225 cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2
6d54cf9ca1 Ed H*0226 matched=0
0227 for i in $PACKAGES ; do
7deef35259 Jean*0228 line=`grep "^ *$i" $TMP.p2`
6d54cf9ca1 Ed H*0229 RETVAL=$?
0230 if test "x$RETVAL" = x0 ; then
0231 matched=1
3e661b1a92 Ed H*0232 replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
a5a3c4e100 Jean*0233 echo " replacing \"$i\" with:$replace"
6d54cf9ca1 Ed H*0234 new_packages="$new_packages $replace"
0235 else
0236 new_packages="$new_packages $i"
0237 fi
0238 done
0239 PACKAGES=$new_packages
7deef35259 Jean*0240 rm -f $TMP.p[1,2]
d3d6cca041 Alis*0241 return $matched
6d54cf9ca1 Ed H*0242 else
0243 echo "Warning: can't read package groups definition file: $PKG_GROUPS"
0244 fi
0245 }
6aec5d9846 Ed H*0246
5bb11ad8a0 Ed H*0247 # Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
0248 # cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
0249 check_for_broken_Ff() {
3eb03232c2 Ed H*0250 # Do we have defaults for $FS and/or $FS90 ?
0251 tfs=f
0252 tfs9=f90
0253 if test "x$FS" != x ; then
0254 tfs="$FS"
0255 fi
0256 if test "x$FS90" != x ; then
0257 tfs9="$FS90"
0258 fi
0259
5bb11ad8a0 Ed H*0260 # First check the ability to create a *.F/.f pair.
3eb03232c2 Ed H*0261 cat <<EOF >> genmake_hello.F
5bb11ad8a0 Ed H*0262 program hello
0263 write(*,*) 'hi'
0264 stop
0265 end
0266 EOF
3eb03232c2 Ed H*0267 cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
5bb11ad8a0 Ed H*0268 RETVAL=$?
0269 if test "x$RETVAL" != x0 ; then
3eb03232c2 Ed H*0270 if test "x$FS" = x ; then
a4cdb0c6f0 Ed H*0271 FS='for'
0272 FS90='fr9'
3eb03232c2 Ed H*0273 check_for_broken_Ff
0274 else
0275 cat <<EOF 2>&1
5be35a17af Jean*0276 ERROR: Your file system cannot distinguish between *.F and *.f files
0277 (fails the "cp" test) and this program cannot find a suitable
0278 replacement extension. Please try a different build environment or
3eb03232c2 Ed H*0279 contact the <MITgcm-support@mitgcm.org> list for help.
0280
0281 EOF
0282 exit -1
0283 fi
5bb11ad8a0 Ed H*0284 return
0285 fi
3eb03232c2 Ed H*0286 rm -f genmake_hello.*
5bb11ad8a0 Ed H*0287
3eb03232c2 Ed H*0288 # Check the ability of ${MAKE} and ${LN} to use the current set
0289 # of extensions.
0290 cat <<EOF >> genmake_hello.F
0291 program hello
0292 write(*,*) 'hi'
0293 stop
0294 end
0295 EOF
3ce2ed8dc5 Ed H*0296 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
0297 cat <<EOF >> $MAKEFILE
5bb11ad8a0 Ed H*0298 .SUFFIXES:
7a76cc695e Ed H*0299 .SUFFIXES: .$tfs .F
0300 .F.$tfs:
0301 $LN \$< \$@
5bb11ad8a0 Ed H*0302 EOF
18371f2c52 Jean*0303 $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
5bb11ad8a0 Ed H*0304 RETVAL=$?
355771feeb Ed H*0305 if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
3eb03232c2 Ed H*0306 if test "x$FS" = x ; then
a4cdb0c6f0 Ed H*0307 FS='for'
0308 FS90='fr9'
3eb03232c2 Ed H*0309 check_for_broken_Ff
0310 else
776d1c0efd Jean*0311 echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
0312 echo " see simple makefile: '$MAKEFILE' (left here)"
0313 echo " Please check (1) your '$MAKE' command, (2) your '$LN' command"
0314 echo " and (3) the allowed sufix '.F' and '.$tfs' in makefile"
0315 echo " or contact the <MITgcm-support@mitgcm.org> list for help."
0316 echo ""
3eb03232c2 Ed H*0317 exit -1
0318 return
0319 fi
5bb11ad8a0 Ed H*0320 fi
3ce2ed8dc5 Ed H*0321 rm -f genmake_hello.* $MAKEFILE
0322 test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
5bb11ad8a0 Ed H*0323
3eb03232c2 Ed H*0324 # If we make it here, use the extensions
0325 FS=$tfs
0326 FS90=$tfs9
0327 return
5bb11ad8a0 Ed H*0328 }
0329
072ddee95c Ed H*0330 look_for_makedepend() {
6aec5d9846 Ed H*0331
b0867682b1 Ed H*0332 # The "original" makedepend is part of the Imake system that is
0333 # most often distributed with XFree86 or with an XFree86 source
0334 # package. As a result, many machines (eg. generic Linux) do not
0335 # have a system-default "makedepend" available. For those
0336 # systems, we have two fall-back options:
0337 #
0338 # 1) a makedepend implementation shipped with the cyrus-imapd
0339 # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
88a755a5b2 Jean*0340 # 2) a local tools/xmakedepend shell script
b0867682b1 Ed H*0341 #
0342 # So the choices are, in order:
0343 # 1) use the user-specified program
88a755a5b2 Jean*0344 # 2) use the local xmakedepend script (get all dependencies, but slower)
0345 # 3) use a system-wide default
0346 # 4) locally build and use the cyrus makedepend
0347 # (faster, but can miss some dependencies)
b0867682b1 Ed H*0348 #
b353a7c6c6 Jean*0349 echo >> $LOGFILE
0350 echo "running: look_for_makedepend()" >> $LOGFILE
0351 if test "x${MAKEDEPEND}" != x ; then
0352 echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
0353 RETVAL=$?
0354 if test x"$RETVAL" = x0 ; then
0355 build_cyrus_makedepend
0356 RETVAL=$?
0357 if test "x$RETVAL" != x0 ; then
88a755a5b2 Jean*0358 echo "WARNING: unable to build cyrus-makedepend. Try other 'makedepend'"
b353a7c6c6 Jean*0359 MAKEDEPEND=
0360 fi
0361 else
9131c4d333 Jean*0362 echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
0363 RETVAL=$?
0364 if test "x$RETVAL" = x0 ; then
0365 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
0366 fi
b353a7c6c6 Jean*0367 echo " --> MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
0368 fi
0369 fi
19d7e59ef3 Alis*0370 if test "x${MAKEDEPEND}" = x ; then
3ce2ed8dc5 Ed H*0371 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
0372 # echo 'MAKEFILE="'$MAKEFILE'"'
0373 cat <<EOF >> $MAKEFILE
0374 # THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
0375 #
5be35a17af Jean*0376 # Some "makedepend" implementations will die if they cannot
0377 # find a Makefile -- so this file is here to gives them an
3ce2ed8dc5 Ed H*0378 # empty one to find and parse.
0379 EOF
925891ca7b Ed H*0380 cat <<EOF >> genmake_tc.f
a4cdb0c6f0 Ed H*0381 program test
0382 write(*,*) 'test'
0383 stop
0384 end
0385 EOF
88a755a5b2 Jean*0386 $ROOTDIR/tools/xmakedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
b681e6be2e Mart*0387 RV1=$?
88a755a5b2 Jean*0388 which makedepend > /dev/null 2>&1
0389 RV2=$?
0390 if test "x${RV2}" = x0 ; then
0391 makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
0392 RV3=$? ; loc_msg='not working.'
0393 else RV3=$RV2 ; loc_msg='not found.'
0394 fi
3ce2ed8dc5 Ed H*0395 test -f $MAKEFILE && rm -f $MAKEFILE
0396 test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
88a755a5b2 Jean*0397 echo " check makedepend (local: $RV1, system: $RV2, $RV3)"
0398 if test "x${RV1}" = x0 ; then
0399 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
0400 echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
0401 elif test "x${RV3}" = x0 ; then
0402 echo " local tools/xmakedepend not working. Use system-default makedepend"
925891ca7b Ed H*0403 MAKEDEPEND=makedepend
b353a7c6c6 Jean*0404 echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
925891ca7b Ed H*0405 else
88a755a5b2 Jean*0406 echo " local tools/xmakedepend not working; system-default makedepend $loc_msg"
0407 echo -n " Try to build cyrus-makedepend ..."
925891ca7b Ed H*0408 # Try to build the cyrus implementation
b0dc3e31a0 Ed H*0409 build_cyrus_makedepend
925891ca7b Ed H*0410 RETVAL=$?
88a755a5b2 Jean*0411 if test "x$RETVAL" = x0 ; then
0412 echo " Works"
0413 else
0414 echo " Fails" ; echo "" >> $LOGFILE
0415 echo "ERROR: no working makedepend found ; look_for_makedepend FAILED" | tee -a $LOGFILE
0416 echo ""
0417 exit -1
0418 return
925891ca7b Ed H*0419 fi
b0dc3e31a0 Ed H*0420 fi
19d7e59ef3 Alis*0421 fi
072ddee95c Ed H*0422 }
0423
b0dc3e31a0 Ed H*0424 build_cyrus_makedepend() {
b353a7c6c6 Jean*0425 echo >> $LOGFILE
0426 echo "running: build_cyrus_makedepend()" >> $LOGFILE
b0dc3e31a0 Ed H*0427 rm -f ./genmake_cy_md
0428 (
0429 cd $ROOTDIR/tools/cyrus-imapd-makedepend \
0430 && ./configure > /dev/null 2>&1 \
621623385c Jean*0431 && $MAKE > /dev/null 2>&1
b0dc3e31a0 Ed H*0432 if test -x ./makedepend.exe ; then
0433 $LN ./makedepend.exe ./makedepend
0434 fi
0435 ./makedepend ifparser.c > /dev/null 2>&1 \
0436 && echo "true"
0437 ) > ./genmake_cy_md
0438 grep true ./genmake_cy_md > /dev/null 2>&1
0439 RETVAL=$?
0440 rm -f ./genmake_cy_md
0441 if test "x$RETVAL" = x0 ; then
0442 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
b353a7c6c6 Jean*0443 echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
b0dc3e31a0 Ed H*0444 return 0
0445 else
b353a7c6c6 Jean*0446 echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
b0dc3e31a0 Ed H*0447 return 1
0448 fi
0449 }
0450
ab504a3a96 Ed H*0451 build_embed_encode()
0452 {
0453 printf " building the embed-encode utility... "
0454 if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
36e14999eb Jean*0455 if test ! -d "$ROOTDIR/tools/embed_encode" ; then
0456 echo
0457 echo " Error: can't locate \"$ROOTDIR/tools/embed_encode\""
0458 echo
0459 EMBED_SRC=f
ab504a3a96 Ed H*0460 return 1
36e14999eb Jean*0461 fi
ab504a3a96 Ed H*0462 clist="cc gcc c89 $CC"
5be35a17af Jean*0463 for ic in $clist ; do
ab504a3a96 Ed H*0464 comm="$ic -o encode_files encode_files.c"
0465 ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
0466 RETVAL=$?
0467 if test "x$RETVAL" = x0 ; then
0468 echo "OK"
0469 return 0
0470 fi
0471 done
0472 echo
0473 echo " Error: unable to build $ROOTDIR/embed_encode/encode_files"
0474 echo " so it has been disabled"
0475 echo
0476 EMBED_SRC=f
0477 return 1
0478 fi
0479 echo "OK"
0480 }
0481
0e2704be3d Jean*0482 # look for possible C compilers
0483 look_for_C_compilers() {
65377ddbcb Jean*0484 echo >> $LOGFILE
0485 echo "running: look_for_C_compilers()" >> $LOGFILE
0486 rm -f ./genmake_hello.c ./genmake_hello
0487 cat >> genmake_hello.c << EOF
e8a04cb645 Ed H*0488 #include <stdio.h>
0489 int main(int argc, char **argv) {
0490 printf("Hello!\n");
0491 return 0;
0492 }
0493 EOF
65377ddbcb Jean*0494 tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
0495 p_CC=
0496 for c in $tmp ; do
0497 COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
0498 echo $COMM >> $LOGFILE
0499 $COMM >> $LOGFILE 2>&1
e8a04cb645 Ed H*0500 RETVAL=$?
0501 if test "x${RETVAL}" = x0 ; then
65377ddbcb Jean*0502 echo " $c test successful" >> $LOGFILE
e8a04cb645 Ed H*0503 p_CC="$p_CC $c"
0504 fi
0505 done
0506 rm -f ./genmake_hello.c ./genmake_hello
0507 if test "x${p_CC}" = x ; then
0508 cat 1>&2 <<EOF
0509
0510 Error: No C compilers were found in your path. Please specify one using:
0511
0512 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
0513 2) the CC or MITGCM_CC environment variables.
0514
0515 EOF
0516 exit 1
0517 else
65377ddbcb Jean*0518 echo " The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE
e8a04cb645 Ed H*0519 if test "x$CC" = x ; then
0520 CC=`echo $p_CC | $AWK '{print $1}'`
0521 echo " Setting C compiler to: "$CC
0522 fi
0523 fi
65377ddbcb Jean*0524 echo " --> set CC='$CC'" >> $LOGFILE
0e2704be3d Jean*0525 }
0526
0527 # Guess possible config options for this host
0528 find_possible_optfile() {
0529
23f21461eb Jean*0530 echo >> $LOGFILE
0531 echo "running: find_possible_optfile()" >> $LOGFILE
0e2704be3d Jean*0532 tmp1=`uname`"_"`uname -m`
0533 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
0534 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
726aa03a13 Gael*0535 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|' | sed -e 's|aarch64|arm64|'`
0e2704be3d Jean*0536 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
0537 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
0538 PLATFORM=$tmp3
0539 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
0540 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
23f21461eb Jean*0541 echo " The platform appears to be: $PLATFORM" | tee -a $LOGFILE
e8a04cb645 Ed H*0542
0543 #================================================================
0544 # look for possible FORTRAN compilers
23f21461eb Jean*0545 echo " look for possible FORTRAN compilers" >> $LOGFILE
0546 tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
6aec5d9846 Ed H*0547 p_FC=
23f21461eb Jean*0548 rm -f ./genmake_hello.f
0549 cat >> genmake_hello.f <<EOF
f10e3a8bdd Ed H*0550 program hello
0551 do i=1,3
0552 print *, 'hello world : ', i
0553 enddo
0554 end
0555 EOF
23f21461eb Jean*0556 for f in $tmp ; do
0557 COMM="$f -o genmake_hello genmake_hello.f"
0558 echo $COMM >> $LOGFILE
0559 $COMM >> $LOGFILE 2>&1
6aec5d9846 Ed H*0560 RETVAL=$?
0561 if test "x${RETVAL}" = x0 ; then
23f21461eb Jean*0562 echo " $f test successful" >> $LOGFILE
0563 p_FC="$p_FC $f"
6aec5d9846 Ed H*0564 fi
0565 done
23f21461eb Jean*0566 rm -f ./genmake_hello.f ./genmake_hello
6aec5d9846 Ed H*0567 if test "x${p_FC}" = x ; then
f10e3a8bdd Ed H*0568 cat 1>&2 <<EOF
0569
0570 Error: No Fortran compilers were found in your path. Please specify one using:
0571
0572 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
0573 2) a command-line option (eg. "-fc NAME"), or
e8a04cb645 Ed H*0574 3) the FC or MITGCM_FC environment variables.
f10e3a8bdd Ed H*0575
0576 EOF
0577 exit 1
6aec5d9846 Ed H*0578 else
23f21461eb Jean*0579 echo " The possible FORTRAN compilers found in your path are: $p_FC" | tee -a $LOGFILE
611257dd1a Ed H*0580 fi
0581
0582 # Use the first of the compilers found in the current PATH
0583 # that has a correctly-named optfile
0584 if test "x$OPTFILE" = x -a "x$FC" = x ; then
0585 for i in $p_FC ; do
0586 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
0587 if test -r $OPTFILE ; then
23f21461eb Jean*0588 echo " Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
611257dd1a Ed H*0589 break
0590 fi
0591 done
6aec5d9846 Ed H*0592 fi
0593
c1324e0980 Alis*0594 if test "x$OPTFILE" = x ; then
0595 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
0596 if test ! -r $OPTFILE ; then
776d1c0efd Jean*0597 echo " I looked for the file "$OPTFILE" but did not find it"
0598 fi
c1324e0980 Alis*0599 fi
0e2704be3d Jean*0600
f10e3a8bdd Ed H*0601 if test "x$OPTFILE" = x ; then
0602 cat 1>&2 <<EOF
0603
0604 Error: No options file was found in: $ROOTDIR/tools/build_options/
0605 that matches this platform ("$PLATFORM") and the compilers found in
0606 your path. Please specify an "optfile" using:
0607
0608 1) the command line (eg. "-optfile=path/to/OPTFILE"), or
0609 2) the MITGCM_OF environment variable.
0610
516b08a580 jm-c 0611 If you need help, please contact the <MITgcm-support@mitgcm.org> list.
f10e3a8bdd Ed H*0612
0613 EOF
0614 exit 1
6aec5d9846 Ed H*0615 fi
0616 }
f955de4ba2 Jean*0617 #---- keep this line unchanged after the end of find_possible_optfile -----
6aec5d9846 Ed H*0618
f7aaac66f3 jm-c 0619 # Just try to use FC, report failed attempt as a Warning
0620 check_fortran_compiler() {
0621 echo -n " check Fortran Compiler... "
0622 echo "" >> $LOGFILE
0623 echo "running: check_fortran_compiler" >> $LOGFILE
0624 FC_CHECK=-1
0625 rm -f ./genmake_tcomp.f
0626 cat >> genmake_tcomp.f <<EOF
0627 program hello
0628 integer i
0629 do i=1,3
0630 print *, 'hello world : ', i
0631 enddo
0632 end
0633 EOF
0634 COMM="$FC $FFLAGS $FOPTIM -c genmake_tcomp.f"
0635 echo ' '$COMM >> $LOGFILE
0636 $COMM >> $LOGFILE 2>&1
0637 RETVAL=$?
0638 if test "x$RETVAL" != x0 ; then
0639 FC_CHECK=0
0640 echo "" >> $LOGFILE
0641 echo " Warning: FORTRAN compiler test fails to compile" >> $LOGFILE
0642 echo -n " fail to compile"
0643 fi
0644 if test $FC_CHECK = '-1' ; then
0645 COMM="$LINK $FFLAGS $FOPTIM -o genmake_tcomp genmake_tcomp.o $LIBS"
0646 echo ' '$COMM >> $LOGFILE
0647 $COMM >> $LOGFILE 2>&1
0648 RETVAL=$?
0649 else RETVAL=0 ; fi
0650 if test "x$RETVAL" != x0 ; then
0651 FC_CHECK=1
0652 echo "" >> $LOGFILE
0653 echo " Warning: FORTRAN compiler test fails to link" >> $LOGFILE
0654 echo -n " fail to generate executable"
0655 fi
0656 if test $FC_CHECK = '-1' -a -x genmake_tcomp ; then
0657 if test "x$MPI" = 'xtrue' ; then
516b08a580 jm-c 0658 which mpirun > /dev/null 2>&1
0659 RETVAL=$?
0660 if test "x${RETVAL}" = x0 ; then
6c0f1b57d6 Oliv*0661 COMM="mpirun -np 1 ./genmake_tcomp"
516b08a580 jm-c 0662 else
0663 which mpiexec > /dev/null 2>&1
0664 RETVAL=$?
0665 if test "x${RETVAL}" = x0 ; then
0666 COMM="mpiexec -np 1 ./genmake_tcomp"
0667 else
0668 FC_CHECK=4
0669 echo "" >> $LOGFILE
0670 echo " warning: MPI run command not found ==> skip run-test check" >> $LOGFILE
0671 #echo -n " fail to generate executable"
0672 fi
0673 fi
f7aaac66f3 jm-c 0674 else
0675 COMM="./genmake_tcomp"
0676 fi
516b08a580 jm-c 0677 elif test $FC_CHECK = '-1' ; then
0678 FC_CHECK=2
0679 echo 'WARNING: missing executable from FORTRAN compiler test' >> $LOGFILE
0680 echo -n " fail to generate executable"
0681 fi
0682 if test $FC_CHECK = '-1' ; then
f7aaac66f3 jm-c 0683 echo ' '$COMM >> $LOGFILE
0684 $COMM >> $LOGFILE 2>&1
0685 RETVAL=$?
0686 if test "x$RETVAL" != x0 ; then
0687 FC_CHECK=3
0688 #echo -n " fail to run"
0689 else
516b08a580 jm-c 0690 FC_CHECK=5
f7aaac66f3 jm-c 0691 echo -n " pass"
0692 fi
0693 fi
0694 rm -f genmake_tcomp.* genmake_tcomp
516b08a580 jm-c 0695 echo " --> set FC_CHECK= $FC_CHECK /5" >> $LOGFILE
0696 echo " (set FC_CHECK=${FC_CHECK}/5)"
f7aaac66f3 jm-c 0697 }
0698
fea3e7d209 Jean*0699 # Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
0700 # checking for additional included headers (in case of chain of included header)
0701 mpi_headers_do_local_copy() {
0702
0703 dBug=0
cd15dc9a7a Jean*0704 rm -rf ./mpi_headers
0705 if test -d $MPIINCLUDEDIR ; then
0706
0707 #----- check for additional headers (chain of included headers)
0708 echo -n ' Check MPI headers ... '
0709 listIni=$MPI_HEADER_FILES
0710 echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1
0711 outp=$?
0712 #- always check mpif.h (the only mpi-header included in standard MITgcm code)
0713 if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi
0714 if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi
0715
0716 doCheck=1 ; list2copy='' ; list2check=$listIni
0717 while test $doCheck = 1 ; do
0718 newList=''
0719 for i in $list2check ; do
0720 if test -f $MPIINCLUDEDIR/$i ; then
0721 newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \
fea3e7d209 Jean*0722 sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g" -e 's/\"//g'`
cd15dc9a7a Jean*0723 if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi
0724 for j in $newInc ; do
0725 echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1
0726 outp=$?
0727 if test $outp != 0 ; then
0728 if test $dBug = 1 ; then echo -n " ; adding $j" ; fi
0729 newList="$newList $j"
0730 fi
0731 done
0732 if test $dBug = 1 ; then echo "" ; fi
0733 fi
0734 done
0735 if test "x$newList" = x ; then doCheck=0
0736 else list2check=$newList ; list2copy="$list2copy $newList"
0737 fi
fea3e7d209 Jean*0738 done
cd15dc9a7a Jean*0739 list2copy="$MPI_HEADER_FILES $list2copy"
0740 if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi
0741
0742 #----- create local mpi_headers dir if we have files to copy
0743 mkListInc=`echo $list2copy | wc -w`
0744 if test $mkListInc != 0 ; then
0745 echo 'create local "./mpi_headers" dir'
0746 mkdir -p ./mpi_headers
0747 INCLUDES="-I./mpi_headers $INCLUDES"
0748 mkListInc=1
fea3e7d209 Jean*0749 fi
cd15dc9a7a Jean*0750 if test "x$LOCAL_MPI_HEADERS" != x ; then mkListInc=0 ; fi
0751
0752 #----- make local copy and update LOCAL_MPI_HEADERS (if not already set)
0753 for i in $list2copy ; do
0754 if test -f $MPIINCLUDEDIR/$i ; then
fea3e7d209 Jean*0755 cp -p $MPIINCLUDEDIR/$i ./mpi_headers
0756 if test $i = 'mpif.h' ; then
0757 perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
0758 fi
cd15dc9a7a Jean*0759 if test $mkListInc = 2 ; then
fea3e7d209 Jean*0760 LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i"
0761 fi
cd15dc9a7a Jean*0762 if test $mkListInc = 1 ; then
0763 LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=2
fea3e7d209 Jean*0764 fi
cd15dc9a7a Jean*0765 fi
0766 done
0767 else
0768 echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a directory"
0769 echo "WARNING: => skip checking for MPI headers (no ./mpi_headers dir)"
0770 # exit -1
0771 fi
fea3e7d209 Jean*0772 }
0773
6aec5d9846 Ed H*0774 # Parse the package dependency information
0775 get_pdepend_list() {
0776
0777 # strip the comments and then convert the dependency file into
0778 # two arrays: PNAME, DNAME
0779 cat $1 | sed -e 's/#.*$//g' \
bf318dd62d Jean*0780 | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
6aec5d9846 Ed H*0781 > ./.pd_tmp
bf318dd62d Jean*0782 RETVAL=$?
0783 if test ! "x${RETVAL}" = x0 ; then
a5a3c4e100 Jean*0784 echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
bf318dd62d Jean*0785 exit 1
0786 fi
12417e3119 Jean*0787 #echo "---- content of tmp file '.pd_tmp' :" ; cat .pd_tmp ; echo "---- end of file"
3021a6b819 Ed H*0788 . ./.pd_tmp
6aec5d9846 Ed H*0789 rm -f ./.pd_tmp
0790 }
0791
8636935175 Ed H*0792 # Build a CPP macro to automate calling C routines from FORTRAN
0793 get_fortran_c_namemangling() {
353dc202ae Ed H*0794
0795 #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
0796 if test ! "x$FC_NAMEMANGLE" = x ; then
776d1c0efd Jean*0797 return 0
353dc202ae Ed H*0798 fi
0e2704be3d Jean*0799 echo " running: get_fortran_c_namemangling()" >> $LOGFILE
353dc202ae Ed H*0800
8636935175 Ed H*0801 default_nm="#define FC_NAMEMANGLE(X) X ## _"
5be35a17af Jean*0802
8636935175 Ed H*0803 cat > genmake_test.c <<EOF
0804 void tcall( char * string ) { tsub( string ); }
0805 EOF
0e2704be3d Jean*0806 COMM="$CC $CFLAGS -c genmake_test.c"
0807 echo ' '$COMM >> $LOGFILE
0808 $COMM >> $LOGFILE 2>&1
8636935175 Ed H*0809 RETVAL=$?
0810 if test "x$RETVAL" != x0 ; then
0811 FC_NAMEMANGLE=$default_nm
683b8f029b Jean*0812 cat <<EOF>> $LOGFILE
06c46c472d Ed H*0813
0e2704be3d Jean*0814 WARNING: C test compile fails
0815 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
0816 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
06c46c472d Ed H*0817 EOF
8636935175 Ed H*0818 return 1
0819 fi
e8a04cb645 Ed H*0820 c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
8636935175 Ed H*0821 RETVAL=$?
0822 if test "x$RETVAL" != x0 ; then
0823 FC_NAMEMANGLE=$default_nm
683b8f029b Jean*0824 cat <<EOF>> $LOGFILE
06c46c472d Ed H*0825
0e2704be3d Jean*0826 WARNING: The "nm" command failed.
0827 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
0828 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
06c46c472d Ed H*0829 EOF
8636935175 Ed H*0830 return 1
0831 fi
6554790d1c Ed H*0832 cat > genmake_tcomp.$FS <<EOF
8636935175 Ed H*0833 subroutine tcall( string )
0834 character*(*) string
0835 call tsub( string )
0836 end
0837 EOF
0e2704be3d Jean*0838 COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
0839 echo ' '$COMM >> $LOGFILE
0840 $COMM >> $LOGFILE 2>&1
8636935175 Ed H*0841 RETVAL=$?
0842 if test "x$RETVAL" != x0 ; then
0843 FC_NAMEMANGLE=$default_nm
683b8f029b Jean*0844 cat <<EOF>> $LOGFILE
06c46c472d Ed H*0845
0e2704be3d Jean*0846 WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
0847 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
0848 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
06c46c472d Ed H*0849 EOF
8636935175 Ed H*0850 return 1
0851 fi
e8a04cb645 Ed H*0852 f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
8636935175 Ed H*0853 RETVAL=$?
0854 if test "x$RETVAL" != x0 ; then
0855 FC_NAMEMANGLE=$default_nm
683b8f029b Jean*0856 cat <<EOF>> $LOGFILE
06c46c472d Ed H*0857
0e2704be3d Jean*0858 WARNING: The "nm" command failed.
0859 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
0860 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
06c46c472d Ed H*0861 EOF
8636935175 Ed H*0862 return 1
0863 fi
0864
0865 c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
0866 f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
0867 c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
0868 f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
0869
0870 nmangle="X"
0871 if test "x$c_a" != "x$f_a" ; then
0872 comm="echo x$f_a | sed -e 's|x$c_a||'"
0873 a=`eval $comm`
0874 nmangle="$a ## $nmangle"
0875 fi
0876 if test "x$c_b" != "x$f_b" ; then
0877 comm="echo x$f_b | sed -e 's|x$c_b||'"
0878 b=`eval $comm`
0879 nmangle="$nmangle ## $b"
0880 fi
0881
0882 FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle"
63e5b59462 Ed H*0883
0884 # cleanup the testing files
0885 rm -f genmake_tcomp.* genmake_test.*
0e2704be3d Jean*0886
0887 echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
8636935175 Ed H*0888 }
6aec5d9846 Ed H*0889
06c46c472d Ed H*0890 check_HAVE_CLOC() {
683b8f029b Jean*0891 echo >> $LOGFILE
0892 echo "running: check_HAVE_CLOC()" >> $LOGFILE
06c46c472d Ed H*0893 get_fortran_c_namemangling
0894 cat <<EOF > genmake_tc_1.c
0895 $FC_NAMEMANGLE
0896 #include <stdio.h>
0897 #include <stdlib.h>
0898 #include <unistd.h>
0899 #include <assert.h>
0900 #include <sys/time.h>
0901 void FC_NAMEMANGLE(cloc) ( double *curtim )
0902 {
0903 struct timeval tv1;
0904 gettimeofday(&tv1 , (void *)NULL );
0905 *curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
0906 *curtim = *curtim/1.E6;
0907 }
0908 EOF
e89c0084d6 Mart*0909 COMM="$CC $CFLAGS -c genmake_tc_1.c"
683b8f029b Jean*0910 echo $COMM >> $LOGFILE
0911 $COMM >> $LOGFILE 2>&1
06c46c472d Ed H*0912 RET_C=$?
6554790d1c Ed H*0913 cat <<EOF > genmake_tc_2.$FS
06c46c472d Ed H*0914 program hello
c899631d80 Ed H*0915 REAL*8 wtime
06c46c472d Ed H*0916 external cloc
0917 call cloc(wtime)
0918 print *," HELLO WORLD", wtime
f745933813 Ed H*0919 end
06c46c472d Ed H*0920 EOF
5e91cc7226 Mart*0921 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
683b8f029b Jean*0922 echo $COMM >> $LOGFILE
0923 $COMM >> $LOGFILE 2>&1
06c46c472d Ed H*0924 RET_F=$?
683b8f029b Jean*0925 test -x ./genmake_tc && ./genmake_tc >> $LOGFILE 2>&1
06c46c472d Ed H*0926 RETVAL=$?
0927 if test "x$RETVAL" = x0 ; then
0928 HAVE_CLOC=t
0929 fi
0930 rm -f genmake_tc*
0e2704be3d Jean*0931 echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
06c46c472d Ed H*0932 }
0933
b81731e160 Ed H*0934 check_HAVE_SIGREG() {
1c82e4d566 Ed H*0935 if test ! "x$HAVE_SIGREG" = x ; then
0936 return
0937 fi
683b8f029b Jean*0938 echo >> $LOGFILE
0939 echo "running: check_HAVE_SIGREG()" >> $LOGFILE
b81731e160 Ed H*0940 get_fortran_c_namemangling
0941 cat <<EOF > genmake_tc_1.c
0942 $FC_NAMEMANGLE
0943 #include <stdlib.h>
0944 #include <stdio.h>
0945 #include <signal.h>
0946 #include <errno.h>
0947 #include <ucontext.h>
0948
0949 int * ip;
0950
0951 static void killhandler(
0952 unsigned int sn, siginfo_t si, struct ucontext *sc )
0953 {
0954 *ip = *ip + 1;
0955 return;
0956 }
0957
0958 void FC_NAMEMANGLE(sigreg) (int * aip)
0959 {
0960 struct sigaction s;
b696d1568c Ed H*0961 ip = aip;
b81731e160 Ed H*0962 s.sa_flags = SA_SIGINFO;
0963 s.sa_sigaction = (void *)killhandler;
0964 if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
0965 printf("Sigaction returned error = %d\n", errno);
0966 exit(0);
0967 }
0968 return;
0969 }
0970 EOF
e89c0084d6 Mart*0971 COMM="$CC $CFLAGS -c genmake_tc_1.c"
683b8f029b Jean*0972 echo $COMM >> $LOGFILE
0973 $COMM >> $LOGFILE 2>&1
b81731e160 Ed H*0974 RET_C=$?
0975 cat <<EOF > genmake_tc_2.$FS
0976 program hello
0977 integer anint
0978 common /iv/ anint
0979 external sigreg
0980 call sigreg(anint)
0981 end
0982 EOF
683b8f029b Jean*0983 cat genmake_tc_2.$FS >> $LOGFILE
b81731e160 Ed H*0984 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
683b8f029b Jean*0985 echo $COMM >> $LOGFILE
0986 $COMM >> $LOGFILE 2>&1
b81731e160 Ed H*0987 RETVAL=$?
0988 if test "x$RETVAL" = x0 ; then
0989 HAVE_SIGREG=t
0990 fi
0991 rm -f genmake_tc*
0e2704be3d Jean*0992 echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
b81731e160 Ed H*0993 }
0994
df91541502 Ed H*0995 check_HAVE_SETRLSTK() {
36459526ba Ed H*0996 if test ! "x$HAVE_SETRLSTK" = x ; then
0997 return
0998 fi
683b8f029b Jean*0999 echo >> $LOGFILE
1000 echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
df91541502 Ed H*1001 get_fortran_c_namemangling
1002 cat <<EOF > genmake_tc_1.c
1003 $FC_NAMEMANGLE
1004 #include <sys/time.h>
1005 #include <sys/resource.h>
1006 #include <unistd.h>
1007 void FC_NAMEMANGLE(setrlstk) ()
1008 {
1009 struct rlimit rls;
1010 rls.rlim_cur = RLIM_INFINITY;
1011 rls.rlim_max = RLIM_INFINITY;
1012 setrlimit(RLIMIT_STACK, &rls);
1013 return;
1014 }
1015 EOF
e89c0084d6 Mart*1016 COMM="$CC $CFLAGS -c genmake_tc_1.c"
683b8f029b Jean*1017 echo $COMM >> $LOGFILE
1018 $COMM >> $LOGFILE 2>&1
df91541502 Ed H*1019 RET_C=$?
1020 cat <<EOF > genmake_tc_2.$FS
1021 program hello
1022 external setrlstk
1023 call setrlstk()
1024 end
1025 EOF
683b8f029b Jean*1026 cat genmake_tc_2.$FS >> $LOGFILE
b566c11b33 Ed H*1027 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
683b8f029b Jean*1028 echo $COMM >> $LOGFILE
1029 $COMM >> $LOGFILE 2>&1
df91541502 Ed H*1030 RETVAL=$?
1031 if test "x$RETVAL" = x0 ; then
1032 HAVE_SETRLSTK=t
1033 fi
1034 rm -f genmake_tc*
0e2704be3d Jean*1035 echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
df91541502 Ed H*1036 }
1037
ab11ba1276 Ed H*1038 check_HAVE_STAT() {
683b8f029b Jean*1039 echo >> $LOGFILE
1040 echo "running: check_HAVE_STAT()" >> $LOGFILE
ab11ba1276 Ed H*1041 get_fortran_c_namemangling
1042 cat <<EOF > genmake_tc_1.c
1043 $FC_NAMEMANGLE
1044 #include <stdio.h>
1045 #include <stdlib.h>
1046 #include <unistd.h>
1047 #include <sys/stat.h>
1048 #include <sys/types.h>
1049 void FC_NAMEMANGLE(tfsize) ( int *nbyte )
1050 {
1051 char name[512];
1052 struct stat astat;
1053
1054 name[0] = 'a'; name[1] = '\0';
1055 if (! stat(name, &astat))
1056 *nbyte = (int)(astat.st_size);
1057 else
1058 *nbyte = -1;
1059 }
1060 EOF
e89c0084d6 Mart*1061 COMM="$CC $CFLAGS -c genmake_tc_1.c"
683b8f029b Jean*1062 echo $COMM >> $LOGFILE
e89c0084d6 Mart*1063 $COMM >> genmake_tc.log 2>&1
ab11ba1276 Ed H*1064 RET_C=$?
6554790d1c Ed H*1065 cat <<EOF > genmake_tc_2.$FS
ab11ba1276 Ed H*1066 program hello
1067 integer nbyte
1068 call tfsize(nbyte)
1069 print *," HELLO WORLD", nbyte
f745933813 Ed H*1070 end
ab11ba1276 Ed H*1071 EOF
683b8f029b Jean*1072 cat genmake_tc_2.$FS >> $LOGFILE
b566c11b33 Ed H*1073 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
683b8f029b Jean*1074 echo $COMM >> $LOGFILE
b566c11b33 Ed H*1075 $COMM >> genmake_tc.log 2>&1
ab11ba1276 Ed H*1076 RETVAL=$?
1077 if test "x$RETVAL" = x0 ; then
1078 HAVE_STAT=t
1079 fi
1080 rm -f genmake_tc*
0e2704be3d Jean*1081 echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
ab11ba1276 Ed H*1082 }
1083
4b2baec0be Ed H*1084 check_netcdf_libs() {
92d9fec357 Ed H*1085 if test ! "x$SKIP_NETCDF_CHECK" = x ; then
1086 return
1087 fi
683b8f029b Jean*1088 echo >> $LOGFILE
1089 echo "running: check_netcdf_libs()" >> $LOGFILE
54fd2d570d Ed H*1090 cat <<EOF > genmake_tnc.F
4b2baec0be Ed H*1091 program fgennc
1092 #include "netcdf.inc"
92d9fec357 Ed H*1093 EOF
14693852dd Jean*1094 #if test ! "x$MPI" = x ; then
1095 # echo '#include "mpif.h"' >> genmake_tnc.F
1096 #fi
54fd2d570d Ed H*1097 cat <<EOF >> genmake_tnc.F
4b2baec0be Ed H*1098 integer iret, ncid, xid
1099 iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
1100 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
1101 iret = nf_def_dim(ncid, 'X', 11, xid)
1102 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
1103 iret = nf_close(ncid)
1104 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
1105 end
1106 EOF
6206da1394 Jean*1107 echo "=== genmake_tnc.F >>>" > genmake_tnc.log
b566c11b33 Ed H*1108 cat genmake_tnc.F >> genmake_tnc.log
6206da1394 Jean*1109 echo "<<< genmake_tnc.F ===" >> genmake_tnc.log
4647ba122e Ed H*1110 RET_CPP=f
527acd427b Ed H*1111 COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
b566c11b33 Ed H*1112 echo "$COMM" >> genmake_tnc.log
1fa3d1c640 Davi*1113 eval $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t
4647ba122e Ed H*1114 if test "x$RET_CPP" = xf ; then
1115 echo " WARNING: CPP failed to pre-process the netcdf test." \
d3c49ba21e Ed H*1116 >> genmake_tnc.log
4647ba122e Ed H*1117 echo " Please check that \$INCLUDES is properly set." \
d3c49ba21e Ed H*1118 >> genmake_tnc.log
4647ba122e Ed H*1119 fi
b566c11b33 Ed H*1120 echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
56758c9c48 Greg*1121 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS" >> genmake_tnc.log
54fd2d570d Ed H*1122 $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
f49dfe24c3 Ed H*1123 && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
4b2baec0be Ed H*1124 RET_COMPILE=$?
683b8f029b Jean*1125 cat genmake_tnc.log >> $LOGFILE
2fc7466b7d Ed H*1126
1127 #EH3 Remove test program execution for machines that either disallow
1128 #EH3 execution or cannot support it (eg. cross-compilers)
1129 #EH3
1130 #EH3 test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1
1131 #EH3 RETVAL=$?
1132 #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1133
1134 if test "x$RET_COMPILE" = x0 ; then
4b2baec0be Ed H*1135 HAVE_NETCDF=t
683b8f029b Jean*1136 echo "check_netcdf: successful" >> $LOGFILE
4b2baec0be Ed H*1137 else
2978624509 Ed H*1138 # try again with "-lnetcdf" added to the libs
6206da1394 Jean*1139 echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
527acd427b Ed H*1140 echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
d3c49ba21e Ed H*1141 echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
f49dfe24c3 Ed H*1142 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
527acd427b Ed H*1143 cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \
54fd2d570d Ed H*1144 && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
f49dfe24c3 Ed H*1145 && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
2978624509 Ed H*1146 RET_COMPILE=$?
683b8f029b Jean*1147 echo >> $LOGFILE
1148 cat genmake_tnc.log >> $LOGFILE
2fc7466b7d Ed H*1149 if test "x$RET_COMPILE" = x0 ; then
2978624509 Ed H*1150 LIBS="$LIBS -lnetcdf"
1151 HAVE_NETCDF=t
683b8f029b Jean*1152 echo "check_netcdf: successful" >> $LOGFILE
979d83c92d Cons*1153 else
56758c9c48 Greg*1154 # try again with "-lnetcdff -lnetcdf" added to the libs
6206da1394 Jean*1155 echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
979d83c92d Cons*1156 echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1157 echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
56758c9c48 Greg*1158 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf" >> genmake_tnc.log
979d83c92d Cons*1159 cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \
1160 && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
1161 && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1162 RET_COMPILE=$?
683b8f029b Jean*1163 echo >> $LOGFILE
1164 cat genmake_tnc.log >> $LOGFILE
979d83c92d Cons*1165 if test "x$RET_COMPILE" = x0 ; then
1166 LIBS="$LIBS -lnetcdff -lnetcdf"
1167 HAVE_NETCDF=t
683b8f029b Jean*1168 echo "check_netcdf: successful" >> $LOGFILE
979d83c92d Cons*1169 fi
2978624509 Ed H*1170 fi
4b2baec0be Ed H*1171 fi
1172 rm -f genmake_tnc*
0e2704be3d Jean*1173 echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
4b2baec0be Ed H*1174 }
1175
991445cec7 Oliv*1176 check_lapack_libs() {
516b08a580 jm-c 1177 HAVE_LAPACK=f
991445cec7 Oliv*1178 echo >> $LOGFILE
1179 echo "running: check_lapack_libs()" >> $LOGFILE
1180 cat <<EOF > genmake_tla.F
1181 program fgenla
776d1c0efd Jean*1182 integer info
991445cec7 Oliv*1183 integer ipiv( 2 )
1184 double precision ab( 4, 2 ), b( 2 )
1185 data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1186 data b / 1., 1. /
1187 call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1188 IF (info .NE. 0) write(*,*) 'Error:', info
1189 write(*,*) b
1190 end
1191 EOF
1192 echo "=== genmake_tla.F >>>" > genmake_tla.log
1193 cat genmake_tla.F >> genmake_tla.log
1194 echo "<<< genmake_tla.F ===" >> genmake_tla.log
1195 RET_CPP=f
1196 COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1197 echo "$COMM" >> genmake_tla.log
1198 eval $COMM > genmake_tla.$FS 2>/dev/null && RET_CPP=t
1199 if test "x$RET_CPP" = xf ; then
1200 echo " WARNING: CPP failed to pre-process the lapack test." \
1201 >> genmake_tla.log
1202 echo " Please check that \$INCLUDES is properly set." \
1203 >> genmake_tla.log
1204 fi
1205 echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1206 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1207 $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1208 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1209 RET_COMPILE=$?
1210 cat genmake_tla.log >> $LOGFILE
1211
1212 # test program execution not always possible (see check_netcdf_libs)
1213 #
1214 #test -x ./genmake_tla && ./genmake_tla >> genmake_tla.log 2>&1
1215 #RETVAL=$?
1216 #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1217
1218 if test "x$RET_COMPILE" = x0 ; then
1219 HAVE_LAPACK=t
1220 echo "check_lapack: successful" >> $LOGFILE
1221 else
1222 # try again with "-llapack" added to the libs
1223 echo "==> try again with added '-llapack'" > genmake_tla.log
1224 echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1225 echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1226 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1227 cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \
1228 && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1229 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1230 RET_COMPILE=$?
1231 echo >> $LOGFILE
1232 cat genmake_tla.log >> $LOGFILE
1233 if test "x$RET_COMPILE" = x0 ; then
1234 LIBS="$LIBS -llapack"
1235 HAVE_LAPACK=t
1236 echo "check_lapack: successful" >> $LOGFILE
1237 else
1238 # try again with "-lf77blas -lcblas" added to the libs
1239 echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1240 echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1241 echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1242 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1243 cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \
1244 && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1245 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1246 RET_COMPILE=$?
1247 echo >> $LOGFILE
1248 cat genmake_tla.log >> $LOGFILE
1249 if test "x$RET_COMPILE" = x0 ; then
1250 LIBS="$LIBS -llapack -lf77blas -lcblas"
1251 HAVE_LAPACK=t
1252 echo "check_lapack: successful" >> $LOGFILE
776d1c0efd Jean*1253 else
1254 # try again with "-latlas" added to the libs
1255 echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1256 echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1257 echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1258 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1259 cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \
1260 && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1261 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1262 RET_COMPILE=$?
1263 echo >> $LOGFILE
1264 cat genmake_tla.log >> $LOGFILE
1265 if test "x$RET_COMPILE" = x0 ; then
1266 LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1267 HAVE_LAPACK=t
1268 echo "check_lapack: successful" >> $LOGFILE
1269 fi
991445cec7 Oliv*1270 fi
1271 fi
1272 fi
1273 rm -f genmake_tla*
1274 echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1275 }
1276
7d5fc6b559 Jean*1277 check_HAVE_FLUSH() {
1278 if test ! "x$SKIP_CHECK_FLUSH" = x ; then
1279 return
1280 fi
1281 echo >> $LOGFILE
1282 echo "running: check_HAVE_FLUSH()" >> $LOGFILE
1283 cat <<EOF > genmake_tflsh.$FS
1284 program fgenflsh
1285 integer iounit
1286 character*9 fname
1287 iounit = 26
1288 fname = 'tmp.tflsh'
1289 open(iounit,FILE=fname,STATUS='unknown')
1290 write(iounit,*) 'genmake_tflsh: hello'
1291 call flush(iounit)
1292 close(iounit)
1293 end
1294 EOF
1295 echo "=== genmake_tflsh.$FS >>>" > genmake_tflsh.log
1296 cat genmake_tflsh.$FS >> genmake_tflsh.log
1297 echo "<<< genmake_tflsh.$FS ===" >> genmake_tflsh.log
1298
1299 echo "$FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS \ " >> genmake_tflsh.log
1300 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tflsh.o $LIBS" >> genmake_tflsh.log
1301 $FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS >> genmake_tflsh.log 2>&1 \
1302 && $LINK $FFLAGS $FOPTIM -o genmake_tflsh genmake_tflsh.o $LIBS >> genmake_tflsh.log 2>&1
1303 RET_COMPILE=$?
1304
1305 if test "x$RET_COMPILE" = x0 ; then
1306 HAVE_FLUSH=t
1307 #cat genmake_tflsh.log >> $LOGFILE
1308 echo " check_HAVE_FLUSH: successful" >> $LOGFILE
1309 else
1310 HAVE_FLUSH=f
1311 cat genmake_tflsh.log >> $LOGFILE
1312 fi
1313 rm -f genmake_tflsh*
1314 echo " --> set HAVE_FLUSH='$HAVE_FLUSH'" >> $LOGFILE
1315 }
4b2baec0be Ed H*1316
c1324e0980 Alis*1317 ###############################################################################
1318 # Sequential part of script starts here
1319 ###############################################################################
1320
6aec5d9846 Ed H*1321 # Set defaults here
2ff82eb834 Ed H*1322 COMMANDL="$0 $@"
1323
6aec5d9846 Ed H*1324 PLATFORM=
1325 LN=
1326 S64=
1327 KPP=
6e9c5fd628 Ed H*1328 #FC=
9d6ad94e1e Ed H*1329 #CC=gcc
6e9c5fd628 Ed H*1330 #CPP=
6aec5d9846 Ed H*1331 LINK=
8636935175 Ed H*1332 DEFINES=
6aec5d9846 Ed H*1333 PACKAGES=
1334 ENABLE=
1335 DISABLE=
3ce2ed8dc5 Ed H*1336 # MAKEFILE=
1337 # MAKEDEPEND=
a5a3c4e100 Jean*1338 PKG_DEPEND=
1339 PKG_GROUPS=
683b8f029b Jean*1340 DUMPSTATE=f
6aec5d9846 Ed H*1341 OPTFILE=
4647ba122e Ed H*1342 INCLUDES="-I. $INCLUDES"
6aec5d9846 Ed H*1343 FFLAGS=
1344 FOPTIM=
780fea06ba Mart*1345 FEXTRAFLAGS=
ebe06b86a4 Jean*1346 USE_EXTENDED_SRC=
1347 EXTENDED_SRC_FLAG=
40958e8f52 Jean*1348 GET_FC_VERSION=
6aec5d9846 Ed H*1349 CFLAGS=
1350 KFLAGS1=
1351 KFLAGS2=
e129bec2de Ed H*1352 #LDADD=
6aec5d9846 Ed H*1353 LIBS=
1354 KPPFILES=
1355 NOOPTFILES=
1356 NOOPTFLAGS=
c1324e0980 Alis*1357 MPI=
1358 MPIPATH=
e9e6f33093 Jean*1359 OMP=
1360 OMPFLAG=
b3a27c6152 Jean*1361 USE_R4=
a66d6f811f Cons*1362 TS=
29eb399fd0 Cons*1363 PAPIS=
008ba3ca0d Cons*1364 PCLS=
29eb399fd0 Cons*1365 FOOLAD=
1366 PAPI=
008ba3ca0d Cons*1367 PCL=
29eb399fd0 Cons*1368 HPMT=
1369 GSL=
979d83c92d Cons*1370 DEVEL=
f7f6e70984 Ed H*1371 HAVE_TEST_L=
6aec5d9846 Ed H*1372
937e30e5d7 Jean*1373 # set this to "t" to enable lapack test
1374 CHECK_FOR_LAPACK=f
1c6c4d23f7 Oliv*1375
4b08b6ee66 Ed H*1376 # DEFINES checked by test compilation or command-line
e51ecc3fef Ed H*1377 HAVE_SYSTEM=
1378 HAVE_FDATE=
f7aaac66f3 jm-c 1379 FC_CHECK=
e51ecc3fef Ed H*1380 FC_NAMEMANGLE=
06c46c472d Ed H*1381 HAVE_CLOC=
36459526ba Ed H*1382 # HAVE_SETRLSTK=
ab11ba1276 Ed H*1383 HAVE_STAT=
4b2baec0be Ed H*1384 HAVE_NETCDF=
9698b7effe Chri*1385 HAVE_ETIME=
4b08b6ee66 Ed H*1386 IGNORE_TIME=
991445cec7 Oliv*1387 HAVE_LAPACK=
7d5fc6b559 Jean*1388 HAVE_FLUSH=
e51ecc3fef Ed H*1389
6aec5d9846 Ed H*1390 MODS=
1391 TOOLSDIR=
1392 SOURCEDIRS=
1393 INCLUDEDIRS=
57ace0c46a Ed H*1394 STANDARDDIRS="USE_THE_DEFAULT"
9d0c386f0c dngo*1395 SINGULARITYFILE=
6aec5d9846 Ed H*1396
36e14999eb Jean*1397 #- local config file
1398 gm_local="genmake_local"
1399
6aefb07181 Ed H*1400 G2ARGS=
13fa7032ba Ed H*1401 BASH=
6aec5d9846 Ed H*1402 PWD=`pwd`
6e9c5fd628 Ed H*1403 test "x$MAKE" = x && MAKE=make
1404 test "x$AWK" = x && AWK=awk
ab504a3a96 Ed H*1405 EMBED_SRC=
9a263a84a8 Ed H*1406 THISHOST=`hostname`
6aec5d9846 Ed H*1407 THISCWD=`pwd`
1408 THISDATE=`date`
9a263a84a8 Ed H*1409 THISUSER=`echo $USER`
1410 THISVER=
6aec5d9846 Ed H*1411 MACHINE=`uname -a`
6c90987a77 Ed H*1412 EXECUTABLE=
1413 EXEHOOK=
1414 EXEDIR=
6d54cf9ca1 Ed H*1415 IEEE=
1416 if test "x$MITGCM_IEEE" != x ; then
1417 IEEE=$MITGCM_IEEE
1418 fi
3eb03232c2 Ed H*1419 FS=
1420 FS90=
6aec5d9846 Ed H*1421
668b211e58 Ed H*1422 AUTODIFF_PKG_USED=f
b4daa24319 Shre*1423 TAPENADE=
1424 TAPENADECMD=tapenade
16cc6e2b59 Jean*1425 OPENAD=
668b211e58 Ed H*1426 AD_OPTFILE=
44f4a23ebb Jean*1427 CAT_SRC_FOR_TAF=1
0c0e61146f Ed H*1428 TAF=
1429 AD_TAF_FLAGS=
1430 FTL_TAF_FLAGS=
1431 SVD_TAF_FLAGS=
1432 TAF_EXTRA=
1433 TAMC=
1434 AD_TAMC_FLAGS=
1435 FTL_TAF_FLAGS=
1436 SVD_TAMC_FLAGS=
1437 TAMC_EXTRA=
1438
fea3e7d209 Jean*1439 DIVA=
1440 MPIINCLUDEDIR=
1441 MPI_HEADER_FILES=
1442 LOCAL_MPI_HEADERS=
1443
2ff82eb834 Ed H*1444 # The following state can be set directly by command-line switches
621623385c Jean*1445 gm_s1="ROOTDIR STANDARDDIRS MODS PKG_DEPEND PKG_GROUPS DISABLE ENABLE"
1446 gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1447 gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
2ff82eb834 Ed H*1448
1449 # The following state is not directly set by command-line switches
621623385c Jean*1450 gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
dd9f72a48c Jean*1451 gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
7d5fc6b559 Jean*1452 gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
f7aaac66f3 jm-c 1453 gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_CHECK FC_NAMEMANGLE"
7d5fc6b559 Jean*1454 gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH"
2ff82eb834 Ed H*1455
668b211e58 Ed H*1456 # The following are all related to adjoint/tangent-linear stuff
b4daa24319 Shre*1457 gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAPENADE TAPENADECMD OPENAD TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
e51ecc3fef Ed H*1458 gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
fea3e7d209 Jean*1459 gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
668b211e58 Ed H*1460
dd9f72a48c Jean*1461 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
e51ecc3fef Ed H*1462 gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
2ff82eb834 Ed H*1463
06a58fb2fc Ed H*1464 cat <<EOF
1465
1466 GENMAKE :
1467
683b8f029b Jean*1468 A program for GENerating MAKEfiles for the MITgcm project.
1469 For a quick list of options, use "genmake2 -h"
516b08a580 jm-c 1470 or for more detail see the documentation, section "Building the model"
1471 (under "Getting Started") at: https://mitgcm.readthedocs.io/
06a58fb2fc Ed H*1472
1473 EOF
2ff82eb834 Ed H*1474
309b5c610e Jean*1475 if test "x$MITGCM_ROOTDIR" = x ; then
1476 if test "x$ROOTDIR" != x ; then
f955de4ba2 Jean*1477 echo "WARNING: Environment Variable 'ROOTDIR' no longer recognized"
1478 echo "WARNING: use instead 'MITGCM_ROOTDIR'" ; ROOTDIR=
309b5c610e Jean*1479 echo ''
1480 fi
1481 else
1482 ROOTDIR=$MITGCM_ROOTDIR
1483 fi
1484
683b8f029b Jean*1485 LOGFILE="genmake.log"
6206da1394 Jean*1486 #- clean-up previous genmake logfiles:
683b8f029b Jean*1487 rm -f genmake_state genmake_*optfile $LOGFILE
67fd6ce146 Jean*1488
76c1b0ef61 Ed H*1489 echo "=== Processing options files and arguments ==="
6aec5d9846 Ed H*1490
a674d19f61 Ed H*1491 #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
76c1b0ef61 Ed H*1492 #parse_options
1493 ac_prev=
405899ca27 Ed H*1494 for ac_option in "$@" ; do
76c1b0ef61 Ed H*1495
6aefb07181 Ed H*1496 G2ARGS="$G2ARGS \"$ac_option\""
1497
76c1b0ef61 Ed H*1498 # If the previous option needs an argument, assign it.
1499 if test -n "$ac_prev"; then
1500 eval "$ac_prev=\$ac_option"
1501 ac_prev=
1502 continue
1503 fi
5be35a17af Jean*1504
76c1b0ef61 Ed H*1505 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
5be35a17af Jean*1506
76c1b0ef61 Ed H*1507 case $ac_option in
776d1c0efd Jean*1508
76c1b0ef61 Ed H*1509 -help | --help | -h | --h)
1510 usage ;;
776d1c0efd Jean*1511
76c1b0ef61 Ed H*1512 -optfile | --optfile | -of | --of)
c53a297da3 Ed H*1513 ac_prev=OPTFILE ;;
76c1b0ef61 Ed H*1514 -optfile=* | --optfile=* | -of=* | --of=*)
1515 OPTFILE=$ac_optarg ;;
776d1c0efd Jean*1516
b4daa24319 Shre*1517 -tap | --tap)
1518 TAPENADE="true" ; ALWAYS_USE_F90=1 ;;
1519
16cc6e2b59 Jean*1520 -oad | --oad)
9bf5db3002 Jean*1521 OPENAD="true" ; ALWAYS_USE_F90=1 ;;
9d0c386f0c dngo*1522 -oadsingularity | --oadsingularity | -oadsngl | --oadsngl)
1523 ac_prev=SINGULARITYFILE ;;
1524 -oadsingularity=* | --oadsingularity=* | -oadsngl=* | --oadsngl=*)
1525 SINGULARITYFILE=$ac_optarg ;;
44f4a23ebb Jean*1526 -nocat4ad | -dog4ad | -ncad | -dad)
1527 CAT_SRC_FOR_TAF=0 ;;
b34430ea9b Ed H*1528 -adoptfile | --adoptfile | -adof | --adof)
668b211e58 Ed H*1529 ac_prev=AD_OPTFILE ;;
1530 -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1531 AD_OPTFILE=$ac_optarg ;;
776d1c0efd Jean*1532
76c1b0ef61 Ed H*1533 -pdepend | --pdepend)
a5a3c4e100 Jean*1534 ac_prev=PKG_DEPEND ;;
76c1b0ef61 Ed H*1535 -pdepend=* | --pdepend=*)
a5a3c4e100 Jean*1536 PKG_DEPEND=$ac_optarg ;;
776d1c0efd Jean*1537
a5a3c4e100 Jean*1538 -pgroups | --pgroups)
1539 ac_prev=PKG_GROUPS ;;
1540 -pgroups=* | --pgroups=*)
1541 PKG_GROUPS=$ac_optarg ;;
776d1c0efd Jean*1542
b34aa4cc66 Ed H*1543 -make | --make | -m | --m)
1544 ac_prev=MAKE ;;
1545 -make=* | --make=* | -m=* | --m=*)
1546 MAKE=$ac_optarg ;;
776d1c0efd Jean*1547
13fa7032ba Ed H*1548 -bash | --bash)
1549 ac_prev=BASH ;;
1550 -bash=* | --bash=*)
1551 BASH=$ac_optarg ;;
776d1c0efd Jean*1552
b0867682b1 Ed H*1553 -makedepend | --makedepend | -md | --md)
1554 ac_prev=MAKEDEPEND ;;
1555 -makedepend=* | --makedepend=* | -md=* | --md=*)
1556 MAKEDEPEND=$ac_optarg ;;
776d1c0efd Jean*1557
36e14999eb Jean*1558 -makefile | --makefile | -mf | --mf)
c53a297da3 Ed H*1559 ac_prev=MAKEFILE ;;
36e14999eb Jean*1560 -makefile=* | --makefile=* | -mf=* | --mf=*)
76c1b0ef61 Ed H*1561 MAKEFILE=$ac_optarg ;;
776d1c0efd Jean*1562
06a58fb2fc Ed H*1563 -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1564 echo "ERROR: The platform option has been removed. Please specify"
1565 echo " the build options using the \"optfile\" mechanism."
1566 echo
1567 usage
1568 ;;
776d1c0efd Jean*1569
76c1b0ef61 Ed H*1570 -rootdir | --rootdir | -rd | --rd)
c53a297da3 Ed H*1571 ac_prev=ROOTDIR ;;
76c1b0ef61 Ed H*1572 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1573 ROOTDIR=$ac_optarg ;;
776d1c0efd Jean*1574
76c1b0ef61 Ed H*1575 -mods | --mods | -mo | --mo)
c53a297da3 Ed H*1576 ac_prev=MODS ;;
76c1b0ef61 Ed H*1577 -mods=* | --mods=* | -mo=* | --mo=*)
1578 MODS=$ac_optarg ;;
776d1c0efd Jean*1579
76c1b0ef61 Ed H*1580 -disable | --disable)
c53a297da3 Ed H*1581 ac_prev=DISABLE ;;
76c1b0ef61 Ed H*1582 -disable=* | --disable=*)
1583 DISABLE=$ac_optarg ;;
776d1c0efd Jean*1584
76c1b0ef61 Ed H*1585 -enable | --enable)
c53a297da3 Ed H*1586 ac_prev=ENABLE ;;
76c1b0ef61 Ed H*1587 -enable=* | --enable=*)
1588 ENABLE=$ac_optarg ;;
776d1c0efd Jean*1589
6d54cf9ca1 Ed H*1590 -standarddirs | --standarddirs)
1591 ac_prev=STANDARDDIRS ;;
1592 -standarddirs=* | --standarddirs=*)
1593 STANDARDDIRS=$ac_optarg ;;
1594
76c1b0ef61 Ed H*1595 # -cpp | --cpp)
1596 # ac_prev=cpp ;;
1597 # -cpp=* | --cpp=*)
1598 # CPP=$ac_optarg ;;
776d1c0efd Jean*1599
e8a04cb645 Ed H*1600 -cc | --cc)
1601 ac_prev=CC ;;
1602 -cc=* | --cc=*)
1603 CC=$ac_optarg ;;
776d1c0efd Jean*1604
76c1b0ef61 Ed H*1605 -fortran | --fortran | -fc | --fc)
c53a297da3 Ed H*1606 ac_prev=FC ;;
76c1b0ef61 Ed H*1607 -fc=* | --fc=*)
1608 FC=$ac_optarg ;;
776d1c0efd Jean*1609
3eb03232c2 Ed H*1610 -fs | --fs)
1611 ac_prev=FS ;;
1612 -fs=* | --fs=*)
1613 FS=$ac_optarg ;;
776d1c0efd Jean*1614
3eb03232c2 Ed H*1615 -fs90 | --fs90)
1616 ac_prev=FS90 ;;
1617 -fs90=* | --fs90=*)
1618 FS90=$ac_optarg ;;
776d1c0efd Jean*1619
4d1f7e1a03 Jean*1620 -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1621 USE_R4=true ;;
1622
76c1b0ef61 Ed H*1623 -ieee | --ieee)
6d54cf9ca1 Ed H*1624 IEEE=true ;;
76c1b0ef61 Ed H*1625 -noieee | --noieee)
4d1f7e1a03 Jean*1626 echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
36e14999eb Jean*1627 -devel | --devel)
4d1f7e1a03 Jean*1628 IEEE=true ; DEVEL=true ;;
36e14999eb Jean*1629 -gsl | --gsl)
4d1f7e1a03 Jean*1630 GSL=true ;;
b3a27c6152 Jean*1631
a66d6f811f Cons*1632 -ts | --ts)
1633 TS=true ;;
29eb399fd0 Cons*1634 -papis | --papis)
1635 PAPIS=true ;;
008ba3ca0d Cons*1636 -pcls | --pcls)
1637 PCLS=true ;;
29eb399fd0 Cons*1638 -foolad | --foolad)
1639 FOOLAD=true ;;
1640 -papi | --papi)
1641 PAPI=true ;;
008ba3ca0d Cons*1642 -pcl | --pcl)
1643 PCL=true ;;
29eb399fd0 Cons*1644 -hpmt | --hpmt)
1645 HPMT=true ;;
1646
c1324e0980 Alis*1647 -mpi | --mpi)
1648 MPI=true ;;
1649 -mpi=* | --mpi=*)
1650 MPIPATH=$ac_optarg
1651 MPI=true ;;
776d1c0efd Jean*1652
1653 -omp | --omp)
1654 OMP=true ;;
e9e6f33093 Jean*1655 -omp=* | --omp=*)
1656 OMPFLAG=$ac_optarg
1657 OMP=true ;;
776d1c0efd Jean*1658
2ff82eb834 Ed H*1659 -ds | --ds)
1660 DUMPSTATE=t ;;
776d1c0efd Jean*1661
dd9f72a48c Jean*1662 -extra_flag | --extra_flag)
1663 ac_prev=FEXTRAFLAGS ;;
1664 -extra_flag=* | --extra_flag=*)
1665 FEXTRAFLAGS=$ac_optarg ;;
776d1c0efd Jean*1666
0c0e61146f Ed H*1667 -taf_extra | --taf_extra)
1668 ac_prev=TAF_EXTRA ;;
1669 -taf_extra=* | --taf_extra=*)
1670 TAF_EXTRA=$ac_optarg ;;
1671
1672 -tamc_extra | --tamc_extra)
1673 ac_prev=TAMC_EXTRA ;;
1674 -tamc_extra=* | --tamc_extra=*)
1675 TAMC_EXTRA=$ac_optarg ;;
776d1c0efd Jean*1676
4b08b6ee66 Ed H*1677 -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1678 IGNORE_TIME="-DIGNORE_TIME" ;;
0c0e61146f Ed H*1679
ab504a3a96 Ed H*1680 -es | --es | -embed-source | --embed-source)
1681 EMBED_SRC=t ;;
1682
76c1b0ef61 Ed H*1683 -*)
1684 echo "Error: unrecognized option: "$ac_option
1685 usage
1686 ;;
776d1c0efd Jean*1687
76c1b0ef61 Ed H*1688 *)
1689 echo "Error: unrecognized argument: "$ac_option
1690 usage
1691 ;;
776d1c0efd Jean*1692
76c1b0ef61 Ed H*1693 esac
5be35a17af Jean*1694
6aec5d9846 Ed H*1695 done
1696
4965aa2630 Jean*1697 #TMP=./genmk_$$
7deef35259 Jean*1698 #- try to put temporary files in system-local /tmp dir
b3a874fe30 Jean*1699 TMP=/tmp/genmk_${USER}_$$
4965aa2630 Jean*1700 touch $TMP ; retVal=$?
1701 if [ $retVal -eq 0 ] ; then
1702 if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1703 else
1704 TMP=./genmk_$$
1705 fi
1706 rm -f $TMP
1707 #echo " temp files: $TMP.*"
7deef35259 Jean*1708
36e14999eb Jean*1709 printf " getting local config information: "
1710 if test -f $gm_local ; then
1711 echo "using $gm_local"
1712 . $gm_local
1713 else
1714 echo "none found"
1715 fi
1716
6d54cf9ca1 Ed H*1717 if test -f ./.genmakerc ; then
1718 echo
1719 echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
516b08a580 jm-c 1720 echo " file. This file format is no longer supported."
1721 echo " For directions on how to setup and use the new \"genmake2\" script,"
1722 echo " please see the User Manual at: https://mitgcm.readthedocs.io/"
55252a5af3 Jean*1723 echo "WARNING: ignore \"./.genmakerc\" and continue."
5be35a17af Jean*1724 echo
6d54cf9ca1 Ed H*1725 fi
1726
f955de4ba2 Jean*1727 # Find the MITgcm root directory (${ROOTDIR})
f10e3a8bdd Ed H*1728 if test "x${ROOTDIR}" = x ; then
87042bad2c Ed H*1729 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
822f69f065 Ed H*1730 if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
f10e3a8bdd Ed H*1731 ROOTDIR=".."
1732 else
1733 for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1734 if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1735 ROOTDIR=$d
f955de4ba2 Jean*1736 printf "Warning: MITgcm root directory was not specified ;"
b353a7c6c6 Jean*1737 echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
f10e3a8bdd Ed H*1738 break
1739 fi
1740 done
1741 fi
1742 fi
1743 if test "x${ROOTDIR}" = x ; then
f955de4ba2 Jean*1744 echo "Error: Cannot determine MITgcm root directory for MITgcm code."
1745 echo " Please specify a root directory using either the command line"
1746 echo " option '-rootdir' or the environment variable 'MITGCM_ROOTDIR'."
f10e3a8bdd Ed H*1747 exit 1
1748 fi
1749 if test ! -d ${ROOTDIR} ; then
f955de4ba2 Jean*1750 echo "Error: the specified MITgcm root directory (\"$ROOTDIR\") does not exist!"
f10e3a8bdd Ed H*1751 exit 1
1752 fi
1753
9a263a84a8 Ed H*1754 # Find the MITgcm ${THISVER}
dbad7fe471 Jean*1755 version_file="${ROOTDIR}/doc/tag-index"
1756 if test -f $version_file ; then
8a81a79ea3 Jean*1757 THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
dbad7fe471 Jean*1758 #- remove ./BUILD_INFO.h file if older than version_file
1759 if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1760 echo " remove ./BUILD_INFO.h (older than ${version_file})"
1761 rm -f ./BUILD_INFO.h
1762 fi
9a263a84a8 Ed H*1763 fi
1764
3ce2ed8dc5 Ed H*1765 if test "x$MAKEFILE" = x ; then
1766 MAKEFILE="Makefile"
1767 fi
1768
dd9f72a48c Jean*1769 echo " getting OPTFILE information:"
6aec5d9846 Ed H*1770 if test "x${OPTFILE}" = x ; then
f10e3a8bdd Ed H*1771 if test "x$MITGCM_OF" = x ; then
1772 echo "Warning: no OPTFILE specified so we'll look for possible settings"
1773 printf "\n=== Searching for possible settings for OPTFILE ===\n"
0e2704be3d Jean*1774 find_possible_optfile
6aec5d9846 Ed H*1775 else
f10e3a8bdd Ed H*1776 OPTFILE=$MITGCM_OF
1777 fi
1778 fi
1779 if test "x$OPTFILE" != xNONE ; then
1780 if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
1781 echo " using OPTFILE=\"$OPTFILE\""
3021a6b819 Ed H*1782 . "$OPTFILE"
f10e3a8bdd Ed H*1783 RETVAL=$?
1784 if test "x$RETVAL" != x0 ; then
13fa7032ba Ed H*1785 printf "Error: failed to source OPTFILE \"$OPTFILE\""
f10e3a8bdd Ed H*1786 echo "--please check that variable syntax is bash-compatible"
6aec5d9846 Ed H*1787 exit 1
1788 fi
683b8f029b Jean*1789 if test "x$DUMPSTATE" = xt ; then
6d54cf9ca1 Ed H*1790 cp -f $OPTFILE "genmake_optfile"
f10e3a8bdd Ed H*1791 fi
1792 else
1793 echo "Error: can't read OPTFILE=\"$OPTFILE\""
1794 exit 1
6aec5d9846 Ed H*1795 fi
1796 fi
1797
dd9f72a48c Jean*1798 echo " getting AD_OPTFILE information:"
668b211e58 Ed H*1799 if test "x${AD_OPTFILE}" = x ; then
16cc6e2b59 Jean*1800 if test "x$MITGCM_AD_OF" != x ; then
1801 AD_OPTFILE=$MITGCM_AD_OF
b4daa24319 Shre*1802 elif test "x$TAPENADE" != x ; then
1803 AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_tap
1804 elif test "x$OPENAD" != x ; then
16cc6e2b59 Jean*1805 AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad
b4daa24319 Shre*1806 else
1807 AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
668b211e58 Ed H*1808 fi
1809 fi
1810 if test "x${AD_OPTFILE}" != xNONE ; then
1811 if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
1812 echo " using AD_OPTFILE=\"$AD_OPTFILE\""
3021a6b819 Ed H*1813 . "$AD_OPTFILE"
668b211e58 Ed H*1814 RETVAL=$?
1815 if test "x$RETVAL" != x0 ; then
13fa7032ba Ed H*1816 printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
668b211e58 Ed H*1817 echo "--please check that variable syntax is bash-compatible"
1818 exit 1
1819 fi
683b8f029b Jean*1820 if test "x$DUMPSTATE" = xt ; then
668b211e58 Ed H*1821 cp -f $AD_OPTFILE "genmake_ad_optfile"
1822 fi
1823 else
1824 echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
1825 exit 1
1826 fi
1827 fi
1828
3ce2ed8dc5 Ed H*1829 #====================================================================
25bb252094 Jean*1830 # Initialize INCLUDEDIRSMK from and optfile INCLUDEDIRS
1831 if test "x${INCLUDEDIRS}" != "x" ; then
1832 INCLUDEDIRSMK=${INCLUDEDIRS}
1833 fi
1834
1835 #====================================================================
3ce2ed8dc5 Ed H*1836 # Set default values if not set by the optfile
1837 #
e8a04cb645 Ed H*1838 # Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not,
06c46c472d Ed H*1839 # either set defaults or complain and abort!
13fa7032ba Ed H*1840 if test ! "x$BASH" = x ; then
1841 # add a trailing space so that it works within the Makefile syntax (see below)
1842 BASH="$BASH "
1843 fi
61e39758c3 Ed H*1844 if test "x$FC" = x ; then
1845 cat <<EOF 1>&2
1846
1847 Error: no Fortran compiler: please specify using one of the following:
1848 1) within the options file ("FC=...") as specified by "-of=OPTFILE"
1849 2) the "-fc=XXX" command-line option
6d54cf9ca1 Ed H*1850 3) the "./genmake_local" file
61e39758c3 Ed H*1851 EOF
1852 exit 1
1853 fi
40958e8f52 Jean*1854 if test "x$GET_FC_VERSION" != x ; then
1855 echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
db3ae3fff3 Jean*1856 ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1857 if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
bb9d8ba6da Jean*1858 $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1859 if test -s genmake_fc_vers1 ; then
1860 cat genmake_fc_vers1 >> $LOGFILE
1861 else
1862 cat genmake_fc_vers2 >> $LOGFILE
1863 fi
5c9316216b Jean*1864 echo "<-- compiler version ----" >> $LOGFILE
bb9d8ba6da Jean*1865 rm -f genmake_fc_vers1 genmake_fc_vers2
40958e8f52 Jean*1866 fi
0e2704be3d Jean*1867
e8a04cb645 Ed H*1868 if test "x$CC" = x ; then
0e2704be3d Jean*1869 look_for_C_compilers
e8a04cb645 Ed H*1870 fi
0e2704be3d Jean*1871
61e39758c3 Ed H*1872 if test "x$LINK" = x ; then
1873 LINK=$FC
1874 fi
06c46c472d Ed H*1875 if test "x$MAKE" = x ; then
1876 MAKE="make"
1877 fi
f7aaac66f3 jm-c 1878
1879 #- check for fortran compiler (for now, just for information, no consequence)
bcbb675387 jm-c 1880 if test "x$FC_CHECK" = x -o "x$FC_CHECK" = xt ; then
1881 check_fortran_compiler
1882 else FC_CHECK=-2 ; fi
f7aaac66f3 jm-c 1883
4fbb3ff84d Ed H*1884 if test "x$CPP" = x ; then
0e2704be3d Jean*1885 CPP="cpp -traditional -P"
4fbb3ff84d Ed H*1886 fi
1887 #EH3 === UGLY ===
3eb03232c2 Ed H*1888 # The following is an ugly little hack to check for $CPP in /lib/ and
1889 # it should eventually be replaced with a more general function that
4fbb3ff84d Ed H*1890 # searches a combo of the user's path and a list of "usual suspects"
1891 # to find the correct location for binaries such as $CPP.
1892 for i in " " "/lib/" ; do
1893 echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1894 done
1895 #EH3 === UGLY ===
7f196e2d92 Ed H*1896 echo "#define A a" | $CPP > test_cpp 2>&1
f10e3a8bdd Ed H*1897 RETVAL=$?
1898 if test "x$RETVAL" != x0 ; then
61e39758c3 Ed H*1899 cat <<EOF 1>&2
1900
f10e3a8bdd Ed H*1901 Error: C pre-processor "$CPP" failed the test case: please specify using:
1902
61e39758c3 Ed H*1903 1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
6d54cf9ca1 Ed H*1904 2) the "./genmake_local" file
c419bc9ed8 Ed H*1905 3) with the CPP environment variable
61e39758c3 Ed H*1906
1907 EOF
1908 exit 1
f10e3a8bdd Ed H*1909 else
1910 rm -f test_cpp
1911 fi
0e2704be3d Jean*1912
072ddee95c Ed H*1913 look_for_makedepend
0e2704be3d Jean*1914
1915 # Check that soft-link command is set and usable
48cf0b55dd Ed H*1916 if test "x$LN" = x ; then
1917 LN="ln -s"
1918 fi
1919 echo "test" > genmake_test_ln
1920 $LN genmake_test_ln genmake_tlink
1921 RETVAL=$?
1922 if test "x$RETVAL" != x0 ; then
1923 cat <<EOF 1>&2
61e39758c3 Ed H*1924
0e2704be3d Jean*1925 Error: The command "$LN" failed -- please specify a working soft-link
48cf0b55dd Ed H*1926 command in the optfile.
1927
1928 EOF
1929 exit 1
1930 fi
f7f6e70984 Ed H*1931 test -L genmake_tlink > /dev/null 2>&1
1932 RETVAL=$?
1933 if test "x$RETVAL" = x0 ; then
1934 HAVE_TEST_L=t
1935 fi
48cf0b55dd Ed H*1936 rm -f genmake_test_ln genmake_tlink
e51ecc3fef Ed H*1937
a4cdb0c6f0 Ed H*1938 # Check for broken *.F/*.f handling and fix if possible
1939 check_for_broken_Ff
1940
c1324e0980 Alis*1941 if test ! "x$MPI" = x ; then
1942 echo " Turning on MPI cpp macros"
e8e03c465c Jean*1943 DEFINES="$DEFINES -DALLOW_USE_MPI"
fb0eed0ba5 Jean*1944 #- To compile code older than checkpoint63s (2012/09/05), un-comment the following line:
1945 # DEFINES="$DEFINES -DALWAYS_USE_MPI"
c1324e0980 Alis*1946 fi
e9e6f33093 Jean*1947 if test ! "x$OMP" = x ; then
1948 echo " Add OMPFLAG and turn on OpenMP cpp macros"
1949 FFLAGS="$FFLAGS $OMPFLAG"
1950 F90FLAGS="$F90FLAGS $OMPFLAG"
1951 DEFINES="$DEFINES -DUSE_OMP_THREADING"
1952 fi
06c46c472d Ed H*1953
b3a27c6152 Jean*1954 if test ! "x$USE_R4" = x ; then
1955 echo " Turning on LET_RS_BE_REAL4 cpp flag"
1956 DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1957 fi
1958
a66d6f811f Cons*1959 if test ! "x$TS" = x ; then
1960 echo " Turning on timing per timestep"
29eb399fd0 Cons*1961 if test ! "x$FOOLAD" = x ; then
776d1c0efd Jean*1962 DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
29eb399fd0 Cons*1963 else
1964 DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1965 fi
35f9e7450d Cons*1966 PACKAGES="$PACKAGES showflops"
29eb399fd0 Cons*1967 fi
1968 if test ! "x$PAPIS" = x ; then
1969 echo " Turning on PAPI flop summary per timestep"
1970 echo " Please make sure PAPIINC, PAPILIB are defined"
1971 if test ! "x$FOOLAD" = x ; then
1972 DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1973 else
1974 DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1975 fi
1976 INCLUDES="$INCLUDES $PAPIINC"
1977 LIBS="$LIBS $PAPILIB"
35f9e7450d Cons*1978 PACKAGES="$PACKAGES showflops"
29eb399fd0 Cons*1979 fi
008ba3ca0d Cons*1980 if test ! "x$PCLS" = x ; then
1981 echo " Turning on PCL counter summary per timestep"
1982 echo " Please make sure PCLINC, PCLLIB are defined"
1983 if test ! "x$FOOLAD" = x ; then
1984 DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1985 else
1986 DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1987 fi
1988 INCLUDES="$INCLUDES $PCLINC"
1989 LIBS="$LIBS $PCLLIB"
35f9e7450d Cons*1990 PACKAGES="$PACKAGES showflops"
008ba3ca0d Cons*1991 fi
29eb399fd0 Cons*1992 if test ! "x$PAPI" = x ; then
1993 if test ! "x$PAPIS" = x ; then
1994 echo " PAPI performance analysis and flop summary per timestep cannot co-exist!"
1995 echo " Sticking with PAPI flop summary per timestep!"
1996 else
1997 echo " Turning on performance analysis with PAPI"
776d1c0efd Jean*1998 echo " Please make sure PAPIINC, PAPILIB are defined"
29eb399fd0 Cons*1999 DEFINES="$DEFINES -DUSE_PAPI"
2000 INCLUDES="$INCLUDES $PAPIINC"
2001 LIBS="$LIBS $PAPILIB"
2002 fi
2003 fi
008ba3ca0d Cons*2004 if test ! "x$PCL" = x ; then
2005 if test ! "x$PCLS" = x ; then
2006 echo " PCL performance analysis and flop summary per timestep cannot co-exist!"
2007 echo " Sticking with PCL flop summary per timestep!"
2008 else
2009 echo " Turning on performance analysis with PCL"
776d1c0efd Jean*2010 echo " Please make sure PCLINC, PCLLIB are defined"
008ba3ca0d Cons*2011 DEFINES="$DEFINES -DUSE_PCL"
2012 INCLUDES="$INCLUDES $PCLINC"
2013 LIBS="$LIBS $PCLLIB"
2014 fi
2015 fi
29eb399fd0 Cons*2016 if test ! "x$HPMT" = x ; then
2017 if test ! "x$PAPI" = x ; then
2018 echo " PAPI and the HPM Toolkit cannot co-exist!"
2019 echo " Sticking with PAPI!"
36e14999eb Jean*2020 else
2021 if test ! "x$PCL" = x ; then
008ba3ca0d Cons*2022 echo " PCL and the HPM Toolkit cannot co-exist!"
2023 echo " Sticking with PCL!"
36e14999eb Jean*2024 else
29eb399fd0 Cons*2025 echo " Turning on performance analysis with the HPM Toolkit"
776d1c0efd Jean*2026 echo " Please make sure HPMTINC, HPMTLIB are defined"
29eb399fd0 Cons*2027 DEFINES="$DEFINES -DUSE_LIBHPM"
776d1c0efd Jean*2028 INCLUDES="$INCLUDES $HPMTINC"
29eb399fd0 Cons*2029 LIBS="$LIBS $HPMTLIB"
36e14999eb Jean*2030 fi
de1771f913 Cons*2031 fi
29eb399fd0 Cons*2032 fi
2033 if test ! "x$GSL" = x ; then
2034 echo " Turning on use of GSL to control floating point calculations"
2035 echo " Please make sure GSLINC, GSLLIB are defined"
2036 DEFINES="$DEFINES -DUSE_GSL_IEEE"
2037 INCLUDES="$INCLUDES $GSLINC"
2038 LIBS="$LIBS $GSLLIB"
a66d6f811f Cons*2039 fi
ebe06b86a4 Jean*2040 #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
2041 if test ! "x$USE_EXTENDED_SRC" = x ; then
2042 FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
2043 F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
2044 fi
a66d6f811f Cons*2045
e51ecc3fef Ed H*2046 printf "\n=== Checking system libraries ===\n"
13fa7032ba Ed H*2047 printf " Do we have the system() command using $FC... "
6554790d1c Ed H*2048 cat > genmake_tcomp.$FS <<EOF
e51ecc3fef Ed H*2049 program hello
2050 call system('echo hi')
2051 end
2052 EOF
64947e6405 Ed H*2053 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
e51ecc3fef Ed H*2054 RETVAL=$?
2055 if test "x$RETVAL" = x0 ; then
2056 HAVE_SYSTEM=t
2057 DEFINES="$DEFINES -DHAVE_SYSTEM"
2058 echo "yes"
2059 else
2060 HAVE_SYSTEM=
2061 echo "no"
2062 fi
2063 rm -f genmake_tcomp*
2064
13fa7032ba Ed H*2065 printf " Do we have the fdate() command using $FC... "
6554790d1c Ed H*2066 cat > genmake_tcomp.$FS <<EOF
e51ecc3fef Ed H*2067 program hello
c899631d80 Ed H*2068 CHARACTER*(128) string
e51ecc3fef Ed H*2069 string = ' '
2070 call fdate( string )
2071 print *, string
2072 end
2073 EOF
64947e6405 Ed H*2074 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
e51ecc3fef Ed H*2075 RETVAL=$?
2076 if test "x$RETVAL" = x0 ; then
2077 HAVE_FDATE=t
2078 DEFINES="$DEFINES -DHAVE_FDATE"
2079 echo "yes"
2080 else
2081 HAVE_FDATE=
2082 echo "no"
2083 fi
2084 rm -f genmake_tcomp*
2085
7c83a0f18d Jean*2086 printf " Do we have the etime() command using $FC... "
f9872c5276 Jean*2087 cat > genmake_tcomp_1.$FS <<EOF
2088 program hello
2089 REAL*4 actual, tarray(2)
2090 EXTERNAL ETIME
2091 REAL*4 ETIME
2092 actual = ETIME( tarray )
2093 print *, tarray
2094 end
2095 EOF
2096 $FC $FFLAGS -o genmake_tcomp_1 genmake_tcomp_1.$FS > genmake_tcomp.log 2>&1
2097 RETVAL=$?
2098 if test "x$RETVAL" = x0 ; then
2099 HAVE_ETIME='Fct'
2100 DEFINES="$DEFINES -DHAVE_ETIME_FCT"
2101 echo " yes (${HAVE_ETIME})"
2102 else
2103 cat > genmake_tcomp_2.$FS <<EOF
9698b7effe Chri*2104 program hello
7c83a0f18d Jean*2105 REAL*4 actual, tarray(2)
2106 actual = -999.
2107 call ETIME( tarray, actual )
2108 if ( actual.ge.0. ) then
2109 print *, 0, tarray, actual
2110 else
2111 print *, 1, tarray, actual
2112 endif
9698b7effe Chri*2113 end
2114 EOF
f9872c5276 Jean*2115 $FC $FFLAGS -o genmake_tcomp_2 genmake_tcomp_2.$FS >> genmake_tcomp.log 2>&1
2116 RETVAL=$?
2117 if test "x$RETVAL" = x0 ; then
7c83a0f18d Jean*2118 echo -n 'c,'
f9872c5276 Jean*2119 ./genmake_tcomp_2 > genmake_tcomp_2.out 2>&1
7c83a0f18d Jean*2120 RETVAL=$?
f9872c5276 Jean*2121 fi
2122 if test "x$RETVAL" = x0 ; then
7c83a0f18d Jean*2123 echo -n 'r:'
f9872c5276 Jean*2124 RETVAL=`cat genmake_tcomp_2.out | $AWK '{print $1}'`
2125 fi
2126 if test "x$RETVAL" = x0 ; then
2127 HAVE_ETIME='SbR'
2128 DEFINES="$DEFINES -DHAVE_ETIME_SBR"
2129 echo " yes (${HAVE_ETIME})"
2130 else
9698b7effe Chri*2131 HAVE_ETIME=
7c83a0f18d Jean*2132 echo " no"
f9872c5276 Jean*2133 fi
9698b7effe Chri*2134 fi
7c83a0f18d Jean*2135 #mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime
9698b7effe Chri*2136 rm -f genmake_tcomp*
2137
13fa7032ba Ed H*2138 printf " Can we call simple C routines (here, \"cloc()\") using $FC... "
06c46c472d Ed H*2139 check_HAVE_CLOC
2140 if test "x$HAVE_CLOC" != x ; then
b5e03e7d0e Jean*2141 DEFINES="$DEFINES -DHAVE_CLOC"
06c46c472d Ed H*2142 echo "yes"
2143 else
df91541502 Ed H*2144 echo "no"
ab504a3a96 Ed H*2145 if test "x$EMBED_SRC" = xt ; then
2146 echo " WARNING: you requested file embedding but it has"
2147 echo " been disabled since C code cannot be called"
2148 EMBED_SRC=
2149 fi
df91541502 Ed H*2150 fi
2151 rm -f genmake_t*
2152
2153 printf " Can we unlimit the stack size using $FC... "
2154 check_HAVE_SETRLSTK
36459526ba Ed H*2155 if test "x$HAVE_SETRLSTK" = xt ; then
b5e03e7d0e Jean*2156 DEFINES="$DEFINES -DHAVE_SETRLSTK"
df91541502 Ed H*2157 echo "yes"
2158 else
06c46c472d Ed H*2159 echo "no"
e51ecc3fef Ed H*2160 fi
06c46c472d Ed H*2161 rm -f genmake_t*
e51ecc3fef Ed H*2162
b81731e160 Ed H*2163 printf " Can we register a signal handler using $FC... "
2164 check_HAVE_SIGREG
1c82e4d566 Ed H*2165 if test "x$HAVE_SIGREG" = xt ; then
b5e03e7d0e Jean*2166 DEFINES="$DEFINES -DHAVE_SIGREG"
b81731e160 Ed H*2167 echo "yes"
2168 else
2169 echo "no"
2170 fi
2171 rm -f genmake_t*
2172
ab11ba1276 Ed H*2173 printf " Can we use stat() through C calls... "
2174 check_HAVE_STAT
2175 if test "x$HAVE_STAT" != x ; then
b5e03e7d0e Jean*2176 DEFINES="$DEFINES -DHAVE_STAT"
ab11ba1276 Ed H*2177 echo "yes"
2178 else
2179 echo "no"
2180 fi
2181 rm -f genmake_t*
2182
13fa7032ba Ed H*2183 printf " Can we create NetCDF-enabled binaries... "
4b2baec0be Ed H*2184 check_netcdf_libs
2185 if test "x$HAVE_NETCDF" != x ; then
b5e03e7d0e Jean*2186 DEFINES="$DEFINES -DHAVE_NETCDF"
4b2baec0be Ed H*2187 echo "yes"
2188 else
2189 echo "no"
2190 fi
991445cec7 Oliv*2191
516b08a580 jm-c 2192 if test "x$CHECK_FOR_LAPACK" = xf ; then
2193 echo " skip check for LAPACK Libs"
991445cec7 Oliv*2194 else
516b08a580 jm-c 2195 printf " Can we create LAPACK-enabled binaries... "
2196 check_lapack_libs
2197 if test "x$HAVE_LAPACK" = xt ; then
2198 echo "yes"
2199 else
2200 echo "no"
2201 fi
2202 fi
2203 if test "x$HAVE_LAPACK" = xt ; then
2204 DEFINES="$DEFINES -DHAVE_LAPACK"
2205 elif test "x$HAVE_LAPACK" = x ; then
2206 #- do not report if unset and unchecked:
2207 gm_state=`echo $gm_state | sed 's/HAVE_LAPACK//'`
991445cec7 Oliv*2208 fi
e51ecc3fef Ed H*2209
7d5fc6b559 Jean*2210 printf " Can we call FLUSH intrinsic subroutine... "
2211 check_HAVE_FLUSH
2212 if test "x$HAVE_FLUSH" = xt ; then
2213 DEFINES="$DEFINES -DHAVE_FLUSH"
2214 echo "yes"
2215 else
2216 echo "no"
2217 fi
2218
2219 DEFINES="$DEFINES $IGNORE_TIME"
ab504a3a96 Ed H*2220 if test "x$EMBED_SRC" = xt ; then
2221 build_embed_encode
2222 fi
2223 if test "x$EMBED_SRC" = xt ; then
2224 ENABLE="$ENABLE embed_files"
b5e03e7d0e Jean*2225 # DEFINES="$DEFINES -DHAVE_EMBED_SRC"
ab504a3a96 Ed H*2226 fi
2227
76c1b0ef61 Ed H*2228 printf "\n=== Setting defaults ===\n"
ab728c5fe9 Jean*2229 printf " Adding MODS directories: "
6aec5d9846 Ed H*2230 for d in $MODS ; do
2231 if test ! -d $d ; then
76c1b0ef61 Ed H*2232 echo
2233 echo "Error: MODS directory \"$d\" not found!"
6aec5d9846 Ed H*2234 exit 1
2235 else
ab728c5fe9 Jean*2236 printf "$d "
6aec5d9846 Ed H*2237 SOURCEDIRS="$SOURCEDIRS $d"
2238 INCLUDEDIRS="$INCLUDEDIRS $d"
25bb252094 Jean*2239 SOURCEDIRSMK="$SOURCEDIRSMK $d"
2240 INCLUDEDIRSMK="$INCLUDEDIRSMK $d"
6aec5d9846 Ed H*2241 fi
2242 done
2243 echo
2244
0e2704be3d Jean*2245 #if test "x${PLATFORM}" = x ; then
2246 # PLATFORM=$p_PLATFORM
2247 #fi
6aec5d9846 Ed H*2248
2249 if test "x${EXEDIR}" = x ; then
87042bad2c Ed H*2250 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1d6dde53d4 Ed H*2251 if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
6aec5d9846 Ed H*2252 EXEDIR=../exe
2253 else
2254 EXEDIR=.
2255 fi
2256 fi
2257 if test ! -d ${EXEDIR} ; then
2258 echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
2259 exit 1
2260 fi
2261
2262 if test "x${TOOLSDIR}" = x ; then
2263 TOOLSDIR="$ROOTDIR/tools"
25bb252094 Jean*2264 TOOLSDIRMK='$(ROOTDIR)'"/tools"
2265 else
2266 TOOLSDIRMK=${TOOLSDIR}
6aec5d9846 Ed H*2267 fi
2268 if test ! -d ${TOOLSDIR} ; then
50c201310d Chri*2269 echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
6aec5d9846 Ed H*2270 exit 1
2271 fi
f10e3a8bdd Ed H*2272 if test "x$S64" = x ; then
a82b95c41f Ed H*2273 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
2274 RETVAL=$?
2275 if test "x${RETVAL}" = x0 ; then
2276 S64='$(TOOLSDIR)/set64bitConst.sh'
2277 else
2278 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
2279 RETVAL=$?
2280 if test "x${RETVAL}" = x0 ; then
2281 S64='$(TOOLSDIR)/set64bitConst.csh'
2282 else
2283 cat <<EOF
2284
2285 ERROR: neither of the two default scripts:
2286
2287 ${TOOLSDIR}/set64bitConst.sh
2288 ${TOOLSDIR}/set64bitConst.csh
2289
5be35a17af Jean*2290 are working so please check paths or specify (with \$S64) a
a82b95c41f Ed H*2291 working version of this script.
2292
2293 EOF
2294 exit 1
2295 fi
2296 fi
f10e3a8bdd Ed H*2297 fi
0c83fc374c Alis*2298 THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
6aec5d9846 Ed H*2299
2300 EXECUTABLE=${EXECUTABLE:-mitgcmuv}
2301
bf318dd62d Jean*2302 # Set Standard Code Directories:
2303 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
2304 STANDARDDIRS="eesupp model"
2305 fi
2306 # if model in Standard-Code-Dir, add eesupp (needed to compile model)
2307 echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
2308 ckM=$?
2309 echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
2310 ckE=$?
5be35a17af Jean*2311 if test $ckM = 0 -a $ckE = 1 ; then
bf318dd62d Jean*2312 STANDARDDIRS="$STANDARDDIRS eesupp"
2313 fi
2314
6aec5d9846 Ed H*2315 # We have a special set of source files in eesupp/src which are
2316 # generated from some template source files. We'll make them first so
2317 # they appear as regular source code
2318 if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
2319 echo " Making source files in eesupp from templates"
149a2bf4b6 Jean*2320 ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
2321 ) > make_eesupp.errors 2>&1
6aec5d9846 Ed H*2322 RETVAL=$?
76c1b0ef61 Ed H*2323 if test "x${RETVAL}" = x0 ; then
6aec5d9846 Ed H*2324 rm -f make_eesupp.errors
2325 else
2326 echo "Error: problem encountered while building source files in eesupp:"
4666a7f4f2 Ed H*2327 cat make_eesupp.errors 1>&2
6aec5d9846 Ed H*2328 exit 1
2329 fi
2330 fi
2331
822f69f065 Ed H*2332 #same for pkg/exch2 and pkg/regrid
2333 for pdir in exch2 regrid ; do
2334 if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
2335 echo " Making source files in pkg/${pdir} from templates"
149a2bf4b6 Jean*2336 ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
2337 ) > make_${pdir}.errors 2>&1
822f69f065 Ed H*2338 RETVAL=$?
2339 if test "x${RETVAL}" = x0 ; then
2340 rm -f make_${pdir}.errors
2341 else
2342 echo "Error: problem encountered while building source files in pkg/${pdir}:"
2343 cat make_${pdir}.errors 1>&2
2344 exit 1
2345 fi
73aeb7d4dc Andr*2346 fi
822f69f065 Ed H*2347 done
73aeb7d4dc Andr*2348
76c1b0ef61 Ed H*2349 printf "\n=== Determining package settings ===\n"
a5a3c4e100 Jean*2350 if test "x${PKG_DEPEND}" = x ; then
6aec5d9846 Ed H*2351 tmp=$ROOTDIR"/pkg/pkg_depend"
a5a3c4e100 Jean*2352 if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
2353 fi
2354 if test "x${PKG_DEPEND}" = x ; then
6aec5d9846 Ed H*2355 echo "Warning: No package dependency information was specified."
2356 echo " Please check that ROOTDIR/pkg/pkg_depend exists."
a5a3c4e100 Jean*2357 else
2358 if test ! -r ${PKG_DEPEND} ; then
2359 echo "Error: can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
2360 exit 1
6aec5d9846 Ed H*2361 fi
a5a3c4e100 Jean*2362 echo " getting package dependency info from $PKG_DEPEND"
2363 # Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
2364 get_pdepend_list $PKG_DEPEND
2365 fi
2366
2367 # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
2368 # to define the "default_pkg_list" and package groups (for convenience, one
2369 # can specify a group of packages using names like "ocean" and "atmosphere").
2370 if test "x${PKG_GROUPS}" = x ; then
2371 tmp=$ROOTDIR"/pkg/pkg_groups"
2372 if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
2373 fi
2374 if test "x${PKG_GROUPS}" = x ; then
2375 echo "Warning: No package groups information was specified."
2376 echo " Please check that ROOTDIR/pkg/pkg_groups exists."
6aec5d9846 Ed H*2377 else
a5a3c4e100 Jean*2378 if test ! -r ${PKG_GROUPS} ; then
2379 echo "Error: can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
6aec5d9846 Ed H*2380 exit 1
2381 fi
a5a3c4e100 Jean*2382 echo " getting package groups info from $PKG_GROUPS"
6aec5d9846 Ed H*2383 fi
a5a3c4e100 Jean*2384
2385 # Search for packages to compile.
2386 echo " checking list of packages to compile:"
2387 PKG_LIST=
2388 if test "x${PKG_LIST}" = x ; then
6d54cf9ca1 Ed H*2389 for i in "." $MODS ; do
2390 if test -r $i"/packages.conf" ; then
a5a3c4e100 Jean*2391 PKG_LIST=$i"/packages.conf"
6d54cf9ca1 Ed H*2392 break
2393 fi
2394 done
2395 fi
a5a3c4e100 Jean*2396 if test "x${PKG_LIST}" = x ; then
2397 pkg_list='default_pkg_list'
2398 if test "x${PKG_GROUPS}" = x ; then
2399 echo "Error: need package groups info to expand pkg_list=\"$pkg_list\""
2400 exit 1
2401 fi
6aec5d9846 Ed H*2402 else
a5a3c4e100 Jean*2403 if test ! -r $PKG_LIST ; then
2404 echo "Error: can't read package list from PKG_LIST=\"$PKG_LIST\""
2405 exit 1
6aec5d9846 Ed H*2406 else
a5a3c4e100 Jean*2407 echo " using PKG_LIST=\"$PKG_LIST\""
36e14999eb Jean*2408 # Strip the comments and add all the names
a5a3c4e100 Jean*2409 pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
6aec5d9846 Ed H*2410 RETVAL=$?
2411 if test "x${RETVAL}" != x0 ; then
a5a3c4e100 Jean*2412 printf "Error: can't parse package list "
2413 echo "-- please check PKG_LIST=\"$PKG_LIST\""
6aec5d9846 Ed H*2414 exit 1
2415 fi
2416 fi
2417 fi
a5a3c4e100 Jean*2418 for i in $pkg_list ; do
2419 PACKAGES="$PACKAGES $i"
2420 done
2421 echo " before group expansion packages are:$PACKAGES"
2422 if test "x${PKG_GROUPS}" != x ; then
2423 RET=1
2424 while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2425 echo " after group expansion packages are: $PACKAGES"
2426 fi
6aec5d9846 Ed H*2427
2428 echo " applying DISABLE settings"
7deef35259 Jean*2429 echo "" > $TMP.pack
d3d6cca041 Alis*2430 for i in $PACKAGES ; do
7deef35259 Jean*2431 echo $i >> $TMP.pack
d3d6cca041 Alis*2432 done
7deef35259 Jean*2433 for i in `grep "-" $TMP.pack` ; do
d3d6cca041 Alis*2434 j=`echo $i | sed 's/[-]//'`
2435 DISABLE="$DISABLE $j"
2436 done
6aec5d9846 Ed H*2437 pack=
2438 for p in $PACKAGES ; do
2439 addit="t"
2440 for d in $DISABLE ; do
2441 if test "x$p" = "x$d" ; then
2442 addit="f"
2443 fi
2444 done
2445 if test "x$addit" = xt ; then
2446 pack="$pack $p"
2447 fi
2448 done
2449 PACKAGES="$pack"
2450 echo " applying ENABLE settings"
7deef35259 Jean*2451 echo "" > $TMP.pack
6aec5d9846 Ed H*2452 PACKAGES="$PACKAGES $ENABLE"
d3d6cca041 Alis*2453 # Test if each explicitly referenced package exists
6aec5d9846 Ed H*2454 for i in $PACKAGES ; do
d3d6cca041 Alis*2455 j=`echo $i | sed 's/[-+]//'`
2456 if test ! -d "$ROOTDIR/pkg/$j" ; then
a5a3c4e100 Jean*2457 echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
776d1c0efd Jean*2458 exit 1
6aec5d9846 Ed H*2459 fi
7deef35259 Jean*2460 echo $i >> $TMP.pack
6aec5d9846 Ed H*2461 done
2462 PACKAGES=
7deef35259 Jean*2463 for i in `grep -v "-" $TMP.pack | sort | uniq` ; do
6aec5d9846 Ed H*2464 PACKAGES="$PACKAGES $i"
2465 done
7deef35259 Jean*2466 rm -f $TMP.pack
bf318dd62d Jean*2467 echo " packages are: $PACKAGES"
6aec5d9846 Ed H*2468
5be35a17af Jean*2469 # Check for package MNC: if NetCDF is available, then build the MNC
55252a5af3 Jean*2470 # template files ; otherwise, delete mnc from the list of packages.
bf318dd62d Jean*2471 echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
5be35a17af Jean*2472 mnc_in=$?
2473 if test "x$HAVE_NETCDF" != xt ; then
2474 if test "x$mnc_in" = x0 ; then
bee85d1689 Ed H*2475 cat <<EOF
2476 *********************************************************************
2477 WARNING: the "mnc" package was enabled but tests failed to compile
2478 NetCDF applications. Please check that:
2479
2480 1) NetCDF is correctly installed for this compiler and
5be35a17af Jean*2481 2) the LIBS variable (within the "optfile") specifies the correct
bee85d1689 Ed H*2482 NetCDF library to link against.
2483
2484 Due to this failure, the "mnc" package is now DISABLED.
2485 *********************************************************************
2486 EOF
2487 PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2488 DISABLE="$DISABLE mnc"
2489 else
5be35a17af Jean*2490 # this prevent to add mnc (due to pdepend rules) if not available
2491 DISABLE="$DISABLE mnc"
2492 fi
2493 else
2494 # we have NetCDF, we try to build MNC template files
2495 ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2496 RETVAL=$?
2497 if test "x${RETVAL}" = x0 ; then
2498 rm -f make_mnc.errors
2499 else
2500 echo "Error: problem encountered while building source files in pkg/mnc:"
2501 cat make_mnc.errors 1>&2
2502 if test "x$mnc_in" = x0 ; then
36e14999eb Jean*2503 exit 1
bee85d1689 Ed H*2504 else
5be35a17af Jean*2505 DISABLE="$DISABLE mnc"
bee85d1689 Ed H*2506 fi
2507 fi
2508 fi
2509
55252a5af3 Jean*2510 # Check for package PROFILES: if NetCDF is not available,
2511 # then delete profiles from the list of available packages.
5be35a17af Jean*2512 if test "x$HAVE_NETCDF" != xt ; then
2513 echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2514 RETVAL=$?
2515 if test "x$RETVAL" = x0 ; then
55252a5af3 Jean*2516 cat <<EOF
2517 *********************************************************************
2518 WARNING: the "profiles" package was enabled but tests failed to
2519 compile NetCDF applications. Please check that:
2520
2521 1) NetCDF is correctly installed for this compiler and
5be35a17af Jean*2522 2) the LIBS variable (within the "optfile") specifies the correct
55252a5af3 Jean*2523 NetCDF library to link against.
2524
2525 Due to this failure, the "profiles" package is now DISABLED.
2526 *********************************************************************
2527 EOF
2528 PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2529 DISABLE="$DISABLE profiles"
5be35a17af Jean*2530 else
2531 # this prevent to add profiles (due to pdepend rules) if not available
2532 DISABLE="$DISABLE profiles"
55252a5af3 Jean*2533 fi
2534 fi
2535
b4daa24319 Shre*2536 # Make sure the tapenade package is enabled if using TAPENADE
2537 if test "x$TAPENADE" != x ; then
2538 echo " $PACKAGES " | grep ' tapenade ' > /dev/null 2>&1
2539 RETVAL=$?
2540 if test "x$RETVAL" != x0 ; then
2541 cat <<EOF
2542
2543 *********************************************************************
2544 ERROR: when generating an adjoint with TAPENADE, the tapenade package
2545 must be enabled. Please add it to packages.conf.
2546 *********************************************************************
2547
2548 EOF
2549 exit 1
2550 fi
2551 fi
2552
c5032d3931 Oliv*2553 # Make sure the openad package is enabled if using OpenAD
2554 if test "x$OPENAD" != x ; then
2555 echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
2556 RETVAL=$?
2557 if test "x$RETVAL" != x0 ; then
2558 cat <<EOF
2559
2560 *********************************************************************
2561 ERROR: when generating an adjoint with OpenAD, the openad package
2562 must be enabled. Please add it to packages.conf.
2563 *********************************************************************
2564
2565 EOF
2566 exit 1
2567 fi
2568 fi
2569
a5a3c4e100 Jean*2570 if test "x${PKG_DEPEND}" != x ; then
2571 echo " applying package dependency rules"
2572 ck=
2573 while test "x$ck" != xtt ; do
6aec5d9846 Ed H*2574 i=0
76c1b0ef61 Ed H*2575 # rtot=${#PNAME[@]}
2576 rtot=$nname
553241f6b0 Jean*2577 while test $i -le $rtot ; do
6aec5d9846 Ed H*2578
2579 # Is $pname in the current $PACKAGES list?
76c1b0ef61 Ed H*2580 # pname=${PNAME[$i]}
2581 tmp="pname=\"\$PNAME_$i\""
2582 eval $tmp
6aec5d9846 Ed H*2583 pin="f"
2584 for p in $PACKAGES ; do
2585 if test "x$p" = "x$pname" ; then
2586 pin="t"
2587 fi
2588 done
bf318dd62d Jean*2589 # or in the current $STANDARDDIRS list?
2590 for p in $STANDARDDIRS ; do
2591 if test "x$p" = "x$pname" ; then pin="t" ; fi
2592 done
6aec5d9846 Ed H*2593
12417e3119 Jean*2594 # Is the DNAME entry a (=), (+) or (-) rule ?
76c1b0ef61 Ed H*2595 tmp="dname=\"\$DNAME_$i\""
2596 eval $tmp
12417e3119 Jean*2597 plus="a"
76c1b0ef61 Ed H*2598 echo $dname | grep '^+' > /dev/null 2>&1
6aec5d9846 Ed H*2599 RETVAL=$?
12417e3119 Jean*2600 if test "x$RETVAL" = x0 ; then plus="+" ; fi
2601 echo $dname | grep '^-' > /dev/null 2>&1
2602 RETVAL=$?
2603 if test "x$RETVAL" = x0 ; then plus="-" ; fi
6aec5d9846 Ed H*2604
2605 # Is $dname in the current $PACKAGES list?
12417e3119 Jean*2606 dname=`echo $dname | sed -e 's/^[=+-]//'`
6aec5d9846 Ed H*2607 din="f"
2608 for p in $PACKAGES ; do
2609 if test "x$p" = "x$dname" ; then
2610 din="t"
2611 fi
2612 done
2613
2614 # Do we need to add $dname according to the dependency rules?
12417e3119 Jean*2615 if test "x$pin" = xt -a "x$plus" != "x-" -a "x$din" = xf ; then
776d1c0efd Jean*2616 #echo " " $pname ": need to add :" $dname
6aec5d9846 Ed H*2617 in_dis="f"
2618 for dis in $DISABLE ; do
2619 if test "x$dis" = "x$dname" ; then
2620 in_dis="t"
2621 fi
2622 done
2623 if test "x$in_dis" = xt ; then
12417e3119 Jean*2624 if test "x$plus" = "x+" ; then
2625 echo "Error: can't satisfy package dependencies:"
2626 echo " \"$dname\" is required with pkg \"$pname\" (dependency rules)"
2627 echo " but is disallowed by the DISABLE settings"
2628 exit 1
2629 elif test "x$ck" = xt ; then
2630 #- (=) is a weaker dependency rule: warning but no stop
2631 echo "Warning: pkg \"$dname\" is set DISABLE (from: \"$PKG_LIST\")"
2632 echo -n " but is recommended with pkg \"$pname\" (dependency rules)"
2633 echo " <- ignores recommendation"
2634 fi
6aec5d9846 Ed H*2635 else
2636 PACKAGES="$PACKAGES $dname"
2637 ck=
2638 fi
2639 fi
2640
2641 # Do we need to get rid of $dname according to the dependency rules?
2642 if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
2643 echo "Error: can't satisfy package dependencies:"
12417e3119 Jean*2644 echo " \"$dname\" was requested but is disallowed by"
2645 echo " the dependency rules for \"$pname\""
6aec5d9846 Ed H*2646 exit 1
2647 fi
ef774c4a3e Jean*2648 i=`expr $i + 1`
2649 #i=`echo "$i + 1" | bc -l`
6aec5d9846 Ed H*2650 done
2651 ck=$ck"t"
a5a3c4e100 Jean*2652 done
2653 echo " packages are: $PACKAGES"
2654 fi
6aec5d9846 Ed H*2655 for i in $PACKAGES ; do
2656 adr="$ROOTDIR/pkg/$i"
25bb252094 Jean*2657 adrmk='$(ROOTDIR)'"/pkg/$i"
6aec5d9846 Ed H*2658 if test -d $adr ; then
2659 SOURCEDIRS="$SOURCEDIRS $adr"
2660 INCLUDEDIRS="$INCLUDEDIRS $adr"
25bb252094 Jean*2661 SOURCEDIRSMK="$SOURCEDIRSMK $adrmk"
2662 INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk"
668b211e58 Ed H*2663 if test "x$i" = xautodiff ; then
2664 AUTODIFF_PKG_USED=t
2665 fi
6aec5d9846 Ed H*2666 else
2667 echo "Error: the directory \"$adr\" for package $i doesn't exist"
2668 exit 1
2669 fi
2670 done
2671
6d54cf9ca1 Ed H*2672 # Create a list of #define and #undef to enable/disable packages
2673 PACKAGES_DOT_H=PACKAGES_CONFIG.h
5be35a17af Jean*2674 # The following UGLY HACK sets multiple "#undef"s and it needs to go
2675 # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
6aec5d9846 Ed H*2676 # file would eventually be split up so that all package-related #define
2677 # statements could be separated and handled only by genmake.
2678 names=`ls -1 "$ROOTDIR/pkg"`
2679 all_pack=
0c83fc374c Alis*2680 DISABLED_PACKAGES=
6aec5d9846 Ed H*2681 for n in $names ; do
2682 if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
2683 has_pack="f"
2684 for pack in $PACKAGES ; do
2685 if test "x$pack" = "x$n" ; then
2686 has_pack="t"
2687 break
2688 fi
2689 done
2690 if test "x$has_pack" = xf ; then
523cb1423f Ed H*2691 undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
776d1c0efd Jean*2692 DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
6aec5d9846 Ed H*2693 fi
2694 fi
2695 done
0c83fc374c Alis*2696 ENABLED_PACKAGES=
6aec5d9846 Ed H*2697 for i in $PACKAGES ; do
523cb1423f Ed H*2698 def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
0c83fc374c Alis*2699 ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
6d54cf9ca1 Ed H*2700 #eh3 DEFINES="$DEFINES -D$def"
6aec5d9846 Ed H*2701
2702 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
5be35a17af Jean*2703 case $i in
6aec5d9846 Ed H*2704 aim_v23)
776d1c0efd Jean*2705 ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
a1c0f64028 Jean*2706 echo "Warning: ALLOW_AIM is set to enable aim_v23."
6aec5d9846 Ed H*2707 ;;
2708 esac
2709 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
2710
2711 done
2712
bf318dd62d Jean*2713 echo " Adding STANDARDDIRS='$STANDARDDIRS'"
6aec5d9846 Ed H*2714 BUILDDIR=${BUILDDIR:-.}
57ace0c46a Ed H*2715 if test "x$STANDARDDIRS" != x ; then
2716 for d in $STANDARDDIRS ; do
2717 adr="$ROOTDIR/$d/src"
25bb252094 Jean*2718 adrmk='$(ROOTDIR)/'"$d/src"
57ace0c46a Ed H*2719 if test ! -d $adr ; then
2720 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2721 echo " is correct and that you correctly specified the STANDARDDIRS option"
2722 exit 1
2723 else
2724 SOURCEDIRS="$SOURCEDIRS $adr"
25bb252094 Jean*2725 SOURCEDIRSMK="$SOURCEDIRSMK $adrmk"
57ace0c46a Ed H*2726 fi
2727 adr="$ROOTDIR/$d/inc"
25bb252094 Jean*2728 adrmk='$(ROOTDIR)/'"$d/inc"
57ace0c46a Ed H*2729 if test ! -d $adr ; then
2730 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2731 echo " is correct and that you correctly specified the STANDARDDIRS option"
2732 exit 1
2733 else
2734 INCLUDEDIRS="$INCLUDEDIRS $adr"
25bb252094 Jean*2735 INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk"
57ace0c46a Ed H*2736 fi
2737 done
2738 fi
6aec5d9846 Ed H*2739
40f7a33215 Alis*2740 echo " Searching for *OPTIONS.h files in order to warn about the presence"
2741 echo " of \"#define \"-type statements that are no longer allowed:"
6d54cf9ca1 Ed H*2742 CPP_OPTIONS=
40f7a33215 Alis*2743 CPP_EEOPTIONS=
6d54cf9ca1 Ed H*2744 spaths=". $INCLUDEDIRS"
40f7a33215 Alis*2745 names=`ls -1 "$ROOTDIR/pkg"`
6d54cf9ca1 Ed H*2746 for i in $spaths ; do
2747 try="$i/CPP_OPTIONS.h"
5e1b06e200 Ed H*2748 if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
6d54cf9ca1 Ed H*2749 echo " found CPP_OPTIONS=\"$try\""
2750 CPP_OPTIONS="$try"
776d1c0efd Jean*2751 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
2752 for n in $names ; do
2753 test_for_package_in_cpp_options $CPP_OPTIONS $n
2754 done
40f7a33215 Alis*2755 fi
2756 try="$i/CPP_EEOPTIONS.h"
5e1b06e200 Ed H*2757 if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
40f7a33215 Alis*2758 echo " found CPP_EEOPTIONS=\"$try\""
776d1c0efd Jean*2759 # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
40f7a33215 Alis*2760 #**** not yet enabled ****
2761 # test_for_mpi_in_cpp_eeoptions $try
2762 #**** not yet enabled ****
2763 CPP_EEOPTIONS="$try"
6d54cf9ca1 Ed H*2764 fi
2765 done
2766 if test "x$CPP_OPTIONS" = x ; then
2767 echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
2768 exit 1
2769 fi
6aec5d9846 Ed H*2770
ea893758ea Patr*2771 # Here, we build the list of files to be "run through" the adjoint compiler.
2772 # split this list between F77 and F90 src code:
668b211e58 Ed H*2773 echo " Creating the list of files for the adjoint compiler."
ea893758ea Patr*2774 test -f $TMP.adSrcFiles && rm -f $TMP.adSrcFiles
2775 test -f $TMP.adF90Files && rm -f $TMP.adF90Files
7deef35259 Jean*2776 touch $TMP.adSrcFiles
ea893758ea Patr*2777 touch $TMP.adF90Files
668b211e58 Ed H*2778 for i in $SOURCEDIRS ; do
0524b7d1ff Mart*2779 list_files=`( cd $i && ls -1 *_ad_diff.list 2>/dev/null )`
668b211e58 Ed H*2780 for j in $list_files ; do
ea893758ea Patr*2781 grep '\.f\>' $i/$j >> $TMP.adSrcFiles
2782 grep '\.f90\>' $i/$j >> $TMP.adF90Files
668b211e58 Ed H*2783 done
2784 done
4b2baec0be Ed H*2785
76c1b0ef61 Ed H*2786 echo
2787 echo "=== Creating the Makefile ==="
6aec5d9846 Ed H*2788 echo " setting INCLUDES"
2789 for i in $INCLUDEDIRS ; do
1d6dde53d4 Ed H*2790 if test ! -d $i ; then
6aec5d9846 Ed H*2791 echo "Warning: can't find INCLUDEDIRS=\"$i\""
2792 fi
2793 done
2794
7783960e4d Jean*2795 if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then
cd15dc9a7a Jean*2796 if test ! "x$MPIINCLUDEDIR" = x ; then
fea3e7d209 Jean*2797 # Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
2798 # checking for additional included headers (in case of chain of included
2799 # header); also set LOCAL_MPI_HEADERS (if not already set)
2800 mpi_headers_do_local_copy
29eb399fd0 Cons*2801 fi
2802 fi
2803
6aec5d9846 Ed H*2804 echo " Determining the list of source and include files"
7deef35259 Jean*2805 rm -rf $TMP.links
2806 mkdir $TMP.links
2807 touch $TMP.links/foo
2808 if test ! -r "$TMP.links/foo" ; then
5709a39825 Ed H*2809 echo
2810 echo "ERROR : something is wrong with your directory permissions or"
2811 echo " your user file-creation mask (\"umask\") since creating a"
2812 echo " sub-dir, touch-ing a file within it, and then reading it is"
2813 echo " not working. Please try setting your umask to something"
2814 echo " sane such as:"
2815 echo
2816 echo " umask 0002"
2817 echo
2818 echo " and please verify that you have the proper permissions for"
2819 echo " creating sub-directories and then reading files created"
2820 echo " within them."
2821 echo
2822 exit 1
2823 fi
7deef35259 Jean*2824 rm -f $TMP.links/foo
5bd7f28048 Jean*2825
b4daa24319 Shre*2826 if test "x$TAPENADE" != x ; then
2827 TAP_DONT_COMPILE="/dev/null"
2828 TAP_DONT_TRANSFORM="/dev/null"
2829 TAP_KEEP_ORIGINAL="/dev/null"
2830 TAP_CB2M_FILES="/dev/null"
2831 TAPTOOLS="$TOOLSDIR/TAP_support"
2832 TAPTOOLSMK='$(TOOLSDIR)/TAP_support'
2833 echo " looking for dontCompile file: "
2834 for i in "." $MODS $TAPTOOLS ; do
2835 if test -r $i"/dontCompile" ; then
2836 TAP_DONT_COMPILE=$i"/dontCompile"
2837 echo " found $TAP_DONT_COMPILE"
2838 break
2839 fi
2840 done
2841 echo " looking for dontTransform file: "
2842 for i in "." $MODS $TAPTOOLS ; do
2843 if test -r $i"/dontTransform" ; then
2844 TAP_DONT_TRANSFORM=$i"/dontTransform"
2845 echo " found $TAP_DONT_TRANSFORM"
2846 break
2847 fi
2848 done
2849 echo " looking for keepOriginal file: "
2850 for i in "." $MODS $TAPTOOLS ; do
2851 if test -r $i"/keepOriginal" ; then
2852 TAP_KEEP_ORIGINAL=$i"/keepOriginal"
2853 echo " found $TAP_KEEP_ORIGINAL"
2854 break
2855 fi
2856 done
2857 echo " looking for cb2mFiles: "
2858 for i in "." $MODS $TAPTOOLS ; do
2859 if test -r $i"/cb2mFiles" ; then
2860 TAP_CB2M_FILES=$i"/cb2mFiles"
2861 echo " found $TAP_CB2M_FILES"
2862 break
2863 fi
2864 done
2865 echo " TAPENADE exceptions: "
2866 fi
2867
5be35a17af Jean*2868 if test "x$OPENAD" != x ; then
5bd7f28048 Jean*2869 OAD_DONT_COMPILE="/dev/null"
2870 OAD_DONT_TRANSFORM="/dev/null"
2871 OAD_KEEP_ORIGINAL="/dev/null"
2872 OAD_CB2M_FILES="/dev/null"
8702af1f36 Patr*2873 OADTOOLS="$TOOLSDIR/OAD_support"
25bb252094 Jean*2874 OADTOOLSMK='$(TOOLSDIR)/OAD_support'
5bd7f28048 Jean*2875 echo " looking for dontCompile file: "
595aad8523 Patr*2876 for i in "." $MODS $OADTOOLS ; do
5bd7f28048 Jean*2877 if test -r $i"/dontCompile" ; then
2878 OAD_DONT_COMPILE=$i"/dontCompile"
2879 echo " found $OAD_DONT_COMPILE"
2880 break
2881 fi
2882 done
2883 echo " looking for dontTransform file: "
595aad8523 Patr*2884 for i in "." $MODS $OADTOOLS ; do
5bd7f28048 Jean*2885 if test -r $i"/dontTransform" ; then
2886 OAD_DONT_TRANSFORM=$i"/dontTransform"
2887 echo " found $OAD_DONT_TRANSFORM"
2888 break
2889 fi
2890 done
2891 echo " looking for keepOriginal file: "
595aad8523 Patr*2892 for i in "." $MODS $OADTOOLS ; do
5bd7f28048 Jean*2893 if test -r $i"/keepOriginal" ; then
2894 OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2895 echo " found $OAD_KEEP_ORIGINAL"
2896 break
2897 fi
2898 done
2899 echo " looking for cb2mFiles: "
595aad8523 Patr*2900 for i in "." $MODS $OADTOOLS ; do
5bd7f28048 Jean*2901 if test -r $i"/cb2mFiles" ; then
2902 OAD_CB2M_FILES=$i"/cb2mFiles"
2903 echo " found $OAD_CB2M_FILES"
2904 break
2905 fi
2906 done
2907 echo " OpenAD exceptions: "
2908 fi
2909
7deef35259 Jean*2910 echo "# This section creates symbolic links" > $TMP.srclinks
2911 echo "" >> $TMP.srclinks
2912 printf 'F77_SRC_FILES = ' > $TMP.F77srclist
2913 printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist
2914 printf 'C_SRC_FILES = ' > $TMP.csrclist
2915 printf 'F90_SRC_FILES = ' > $TMP.F90srclist
ea893758ea Patr*2916 printf 'NON_AD_F90_SRC_FILES = ' > $TMP.nonADF90srclist
7deef35259 Jean*2917 printf 'H_SRC_FILES = ' > $TMP.hsrclist
2918 printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
d119ddb592 Alis*2919 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
25bb252094 Jean*2920 alldirsmk=(${SOURCEDIRSMK} ${INCLUDEDIRSMK} ".")
2921 nd=0
6aec5d9846 Ed H*2922 for d in $alldirs ; do
25bb252094 Jean*2923 dmk=${alldirsmk[${nd}]}
2924 nd=$((${nd}+1))
6aec5d9846 Ed H*2925 deplist=
668b211e58 Ed H*2926 sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
27c9249c85 Chri*2927 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
b4daa24319 Shre*2928 if test "x$TAPENADE" != x ; then
2929 sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2930 fi
5be35a17af Jean*2931 if test "x$OPENAD" != x ; then
5bd7f28048 Jean*2932 sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2933 fi
6aec5d9846 Ed H*2934 for sf in $sfiles ; do
7deef35259 Jean*2935 if test ! -r "$TMP.links/$sf" ; then
6aec5d9846 Ed H*2936 if test -f "$d/$sf" ; then
f7f6e70984 Ed H*2937 ignore_f=f
776d1c0efd Jean*2938 case $d/$sf in
2939 ./$PACKAGES_DOT_H)
ab504a3a96 Ed H*2940 ignore_f=t
0c83fc374c Alis*2941 ;;
776d1c0efd Jean*2942 ./AD_CONFIG.h)
ab504a3a96 Ed H*2943 ignore_f=t
0c83fc374c Alis*2944 ;;
776d1c0efd Jean*2945 ./FC_NAMEMANGLE.h)
ab504a3a96 Ed H*2946 ignore_f=t
0c83fc374c Alis*2947 ;;
776d1c0efd Jean*2948 ./BUILD_INFO.h)
ab504a3a96 Ed H*2949 ignore_f=t
2950 ;;
776d1c0efd Jean*2951 ./EMBEDDED_FILES.h)
ab504a3a96 Ed H*2952 ignore_f=t
f79257694d Ed H*2953 ;;
776d1c0efd Jean*2954 *)
f7f6e70984 Ed H*2955 # For the local directory *ONLY*,
2956 # ignore all soft-links
2957 if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2958 ignore_f=t
2959 else
7deef35259 Jean*2960 touch $TMP.links/$sf
f7f6e70984 Ed H*2961 deplist="$deplist $sf"
2962 fi
0c83fc374c Alis*2963 ;;
776d1c0efd Jean*2964 esac
f7f6e70984 Ed H*2965 if test "x$ignore_f" = xf ; then
2966 extn=`echo $sf | $AWK -F. '{print $NF}'`
ea893758ea Patr*2967 # this is built-in bash and does not rely on $AWK :
2968 # extn=${sf##*.}
f7f6e70984 Ed H*2969 case $extn in
5bd7f28048 Jean*2970 F)
7deef35259 Jean*2971 echo " \\" >> $TMP.F77srclist
2972 printf " $sf" >> $TMP.F77srclist
b4daa24319 Shre*2973
2974 if test "x$TAPENADE" != x ; then
2975 basename=${sf%%.F}
2976 isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles`
2977 if test -z "$isAD" ; then
2978 toBeIgnored=`egrep ^$basename'[ ]*' ${TAP_DONT_COMPILE}`
2979 if test -z "$toBeIgnored" ; then
2980 echo " \\" >> $TMP.nonADF77srclist
2981 printf " $sf" >> $TMP.nonADF77srclist
2982 else
2983 echo " not to be compiled : $sf"
2984 fi
2985 else # file is initially listed as an AD file we want to exclude it
2986 # or we want to retain the untransformed version
2987 notToBeTransformed=`egrep ^$basename'[ ]*' ${TAP_DONT_TRANSFORM}`
2988 untransformedVersionToBeKept=`egrep ^$basename'[ ]*' ${TAP_KEEP_ORIGINAL}`
2989 if test -n "$notToBeTransformed"; then
2990 echo " not to be transformed: $sf"
2991 fi
2992 if test -n "$untransformedVersionToBeKept" ; then
2993 echo " original to be kept : $sf"
2994 fi
2995 if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2996 echo " \\" >> $TMP.nonADF77srclist
2997 printf " $sf" >> $TMP.nonADF77srclist
2998 fi
2999 fi
3000 fi
3001
7783960e4d Jean*3002 if test "x$OPENAD" = x ; then
3003 basename=${sf%%.F}
7deef35259 Jean*3004 isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles`
7783960e4d Jean*3005 if test -z "$isAD" ; then
7deef35259 Jean*3006 echo " \\" >> $TMP.nonADF77srclist
3007 printf " $sf" >> $TMP.nonADF77srclist
7783960e4d Jean*3008 fi
3009 else #- OpenAD case:
5bd7f28048 Jean*3010 basename=${sf%%.F}
7deef35259 Jean*3011 isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles`
5be35a17af Jean*3012 if test -z "$isAD" ; then
5bd7f28048 Jean*3013 toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}`
5be35a17af Jean*3014 if test -z "$toBeIgnored" ; then
7deef35259 Jean*3015 echo " \\" >> $TMP.nonADF77srclist
3016 printf " $sf" >> $TMP.nonADF77srclist
5be35a17af Jean*3017 else
5bd7f28048 Jean*3018 echo " not to be compiled : $sf"
3019 fi
5be35a17af Jean*3020 else # file is initially listed as an AD file we want to exclude it
5bd7f28048 Jean*3021 # or we want to retain the untransformed version
3022 notToBeTransformed=`egrep ^$basename'[ ]*' ${OAD_DONT_TRANSFORM}`
3023 untransformedVersionToBeKept=`egrep ^$basename'[ ]*' ${OAD_KEEP_ORIGINAL}`
5be35a17af Jean*3024 if test -n "$notToBeTransformed"; then
5bd7f28048 Jean*3025 echo " not to be transformed: $sf"
3026 fi
3027 if test -n "$untransformedVersionToBeKept" ; then
3028 echo " original to be kept : $sf"
5be35a17af Jean*3029 fi
5bd7f28048 Jean*3030 if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
7deef35259 Jean*3031 echo " \\" >> $TMP.nonADF77srclist
3032 printf " $sf" >> $TMP.nonADF77srclist
5bd7f28048 Jean*3033 fi
3034 fi
3035 fi
3036 ;;
3037 F90)
ea893758ea Patr*3038 echo " \\" >> $TMP.F90srclist
7deef35259 Jean*3039 printf " $sf" >> $TMP.F90srclist
ea893758ea Patr*3040 if ( test "x$OPENAD" = x && test "x$TAPENADE" = x ) ; then
3041 basename=${sf%%.F90}
3042 isAD=`egrep ^$basename.f90'[ ]*' $TMP.adF90Files`
3043 if test -z "$isAD" ; then
3044 echo " \\" >> $TMP.nonADF90srclist
3045 printf " $sf" >> $TMP.nonADF90srclist
3046 fi
3047 fi
5bd7f28048 Jean*3048 ;;
3049 c)
7deef35259 Jean*3050 echo " \\" >> $TMP.csrclist
3051 printf " $sf" >> $TMP.csrclist
5bd7f28048 Jean*3052 ;;
3053 h)
7deef35259 Jean*3054 echo " \\" >> $TMP.hsrclist
3055 printf " $sf" >> $TMP.hsrclist
5bd7f28048 Jean*3056 ;;
776d1c0efd Jean*3057 flow)
7deef35259 Jean*3058 echo " \\" >> $TMP.ad_flow_files
3059 printf " $sf" >> $TMP.ad_flow_files
5bd7f28048 Jean*3060 ;;
3061 esac
3062 fi
6aec5d9846 Ed H*3063 fi
3064 fi
3065 done
3066 if test "x$deplist" != x ; then
5bd7f28048 Jean*3067 if test "$d" != "." ; then
7deef35259 Jean*3068 echo "" >> $TMP.srclinks
25bb252094 Jean*3069 echo "# These files are linked from $dmk ( aka $d )" >> $TMP.srclinks
7deef35259 Jean*3070 echo "$deplist :" >> $TMP.srclinks
097ea4d955 Oliv*3071 # We need to make sure that the link isn't already there.
3072 # This may happen when make thinks that a header file has to be "remade"
3073 # because a module it depends on has changed. In this case we do nothing.
25bb252094 Jean*3074 printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $dmk >> $TMP.srclinks
5bd7f28048 Jean*3075 fi
6aec5d9846 Ed H*3076 fi
3077 done
7deef35259 Jean*3078 rm -rf $TMP.links
3079 echo "" >> $TMP.F77srclist
3080 echo "" >> $TMP.nonADF77srclist
ea893758ea Patr*3081 echo "" >> $TMP.nonADF90srclist
7deef35259 Jean*3082 echo "" >> $TMP.csrclist
3083 echo "" >> $TMP.F90srclist
3084 echo "" >> $TMP.hsrclist
3085 echo "" >> $TMP.ad_flow_files
6aec5d9846 Ed H*3086
0ec5c8a391 Jean*3087 CMDLINE=$0
3088 for xx in "$@" ; do nw=`echo $xx | wc -w`
3089 if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
36e14999eb Jean*3090 else CMDLINE="$CMDLINE '$xx'" ; fi
0ec5c8a391 Jean*3091 done
3092
355771feeb Ed H*3093 if test -f $MAKEFILE ; then
bf318dd62d Jean*3094 mv -f $MAKEFILE "$MAKEFILE.old"
6aec5d9846 Ed H*3095 fi
3096 echo " Writing makefile: $MAKEFILE"
3097 echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
3098 echo "# $MACHINE" >> $MAKEFILE
3099 echo "# This makefile was generated automatically on" >> $MAKEFILE
3100 echo "# $THISDATE" >> $MAKEFILE
3101 echo "# by the command:" >> $MAKEFILE
0ec5c8a391 Jean*3102 echo "# $CMDLINE" >> $MAKEFILE
6aec5d9846 Ed H*3103 echo "# executed by:" >> $MAKEFILE
9a263a84a8 Ed H*3104 echo "# ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
74d4132da5 Ed H*3105
b4daa24319 Shre*3106 if test "x$TAPENADE" = x ; then
3107 EXE_ADJ=$EXECUTABLE"_ad"
3108 EXE_TLM=$EXECUTABLE"_ftl"
3109 else
3110 EXE_ADJ=$EXECUTABLE"_tap_adj"
3111 EXE_TLM=$EXECUTABLE"_tap_tlm"
3112 fi
74d4132da5 Ed H*3113 EXE_SVD=$EXECUTABLE"_svd"
3114
6aec5d9846 Ed H*3115 cat >>$MAKEFILE <<EOF
0058ae90fe Ed H*3116 #
3117 # OPTFILE="$OPTFILE"
bf318dd62d Jean*3118 #
6aec5d9846 Ed H*3119 # BUILDDIR : Directory where object files are written
3120 # SOURCEDIRS : Directories containing the source (.F) files
3121 # INCLUDEDIRS : Directories containing the header-source (.h) files
3122 # EXEDIR : Directory where executable that is generated is written
3123 # EXECUTABLE : Full path of executable binary
3124 #
3125 # CPP : C-preprocessor command
3126 # INCLUDES : Directories searched for header files
3127 # DEFINES : Macro definitions for CPP
3128 # MAKEDEPEND : Dependency generator
3129 # FC : Fortran compiler command
3130 # FFLAGS : Configuration/debugging options for FC
3131 # FOPTIM : Optimization options for FC
3132 # LINK : Command for link editor program
3133 # LIBS : Library flags /or/ additional optimization/debugging flags
3134
3135 ROOTDIR = ${ROOTDIR}
bf318dd62d Jean*3136 BUILDDIR = ${BUILDDIR}
25bb252094 Jean*3137 SOURCEDIRS = ${SOURCEDIRSMK}
3138 INCLUDEDIRS = ${INCLUDEDIRSMK}
6aec5d9846 Ed H*3139 EXEDIR = ${EXEDIR}
3140 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
25bb252094 Jean*3141 TOOLSDIR = ${TOOLSDIRMK}
3142 OADTOOLS = ${OADTOOLSMK}
6aec5d9846 Ed H*3143
668b211e58 Ed H*3144 #eh3 new defines for the adjoint work
25bb252094 Jean*3145 AUTODIFF = \$(ROOTDIR)/pkg/autodiff
b4daa24319 Shre*3146 EXE_ADJ = ${EXE_ADJ}
3147 EXE_TLM = ${EXE_TLM}
74d4132da5 Ed H*3148 EXE_SVD = ${EXE_SVD}
668b211e58 Ed H*3149
0c83fc374c Alis*3150 ENABLED_PACKAGES = ${ENABLED_PACKAGES}
3151 DISABLED_PACKAGES = ${DISABLED_PACKAGES}
3152
40f7a33215 Alis*3153 # These files are created by Makefile
9a263a84a8 Ed H*3154 SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
6aec5d9846 Ed H*3155 EOF
3156
ab504a3a96 Ed H*3157 if test "x$EMBED_SRC" = xt ; then
3158 echo "EMBEDDED_FILES = EMBEDDED_FILES.h" >>$MAKEFILE
3159 else
3160 echo "EMBEDDED_FILES = " >>$MAKEFILE
3161 fi
3162
bc2c9aac73 Oliv*3163 # extract default cpp search path so we can pass it to makedepend
d220271442 Oliv*3164 CPPINCLUDES=`cat /dev/null | $CPP -v 2>&1 | $AWK '/^End of search/{f=0}!/^#/{if(f){printf " -I%s", $1;}}/^#include "..." search start/{f=1}'`
bc2c9aac73 Oliv*3165
6aec5d9846 Ed H*3166 cat >>$MAKEFILE <<EOF
3167 # Unix ln (link)
3168 LN = ${LN}
3169 # Dependency generator
3170 MAKEDEPEND = ${MAKEDEPEND}
3171 # Special preprocessor (KAP on DECs, FPP on Crays)
3172 KPP = ${KPP}
3173 # Fortran compiler
89c0a4365c Ed H*3174 FC = ${FC}
27c9249c85 Chri*3175 # Fortran compiler
3176 F90C = ${F90C}
dec9692aba Ed H*3177 # C compiler
3178 CC = ${CC}
6aec5d9846 Ed H*3179 # Link editor
e129bec2de Ed H*3180 LINK = ${LINK} ${LDADD}
6aec5d9846 Ed H*3181
3182 # Defines for CPP
3183 DEFINES = ${DEFINES}
3184 # Includes for CPP
3185 INCLUDES = ${INCLUDES}
bc2c9aac73 Oliv*3186 # default CPP includes for makedepend
3187 CPPINCLUDES = ${CPPINCLUDES}
6aec5d9846 Ed H*3188 # Flags for KPP
3189 KFLAGS1 = ${KFLAGS1}
3190 KFLAGS2 = ${KFLAGS2}
3191 # Optim./debug for FC
052caf96de Mart*3192 FFLAGS = ${FFLAGS}
3193 FOPTIM = ${FOPTIM} ${FEXTRAFLAGS}
27c9249c85 Chri*3194 # Optim./debug for FC
3195 F90FLAGS = ${F90FLAGS}
3196 F90OPTIM = ${F90OPTIM}
5bd7f28048 Jean*3197 F90FIXEDFORMAT = ${F90FIXEDFORMAT}
6aec5d9846 Ed H*3198 # Flags for CC
3199 CFLAGS = ${CFLAGS}
3200 # Files that should not be optimized
3201 NOOPTFILES = ${NOOPTFILES}
3202 NOOPTFLAGS = ${NOOPTFLAGS}
3203 # Flags and libraries needed for linking
395713ae01 Ed H*3204 LIBS = ${LIBS}
18371f2c52 Jean*3205 # Name of the makefile
621623385c Jean*3206 MAKEFILE = ${MAKEFILE}
3207 # Name of the make program
3208 MAKE = ${MAKE}
6aec5d9846 Ed H*3209
3210 EOF
3211
7deef35259 Jean*3212 cat $TMP.F77srclist >> $MAKEFILE
3213 cat $TMP.nonADF77srclist >> $MAKEFILE
ea893758ea Patr*3214 cat $TMP.nonADF90srclist >> $MAKEFILE
7deef35259 Jean*3215 cat $TMP.csrclist >> $MAKEFILE
3216 cat $TMP.F90srclist >> $MAKEFILE
3217 cat $TMP.hsrclist >> $MAKEFILE
3218 cat $TMP.ad_flow_files >> $MAKEFILE
5bd7f28048 Jean*3219
ea893758ea Patr*3220 rm -f $TMP.F77srclist $TMP.nonADF77srclist $TMP.nonADF90srclist $TMP.csrclist $TMP.F90srclist $TMP.hsrclist $TMP.ad_flow_files
5bd7f28048 Jean*3221
5bb11ad8a0 Ed H*3222 echo >> $MAKEFILE
5bd7f28048 Jean*3223
bf318dd62d Jean*3224 # add definitions for preprocessed sources
3225 # and note that not all systems allow case sensitive extensions
3226 # hence the $FS and $FS90 here.
3227 # for fixed format f90 files we use ff90 or FF90 resp
5bd7f28048 Jean*3228 # but these are not expected to be the original source files
3229
3230 echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')' >> $MAKEFILE
3231 echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
3232 echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
b4daa24319 Shre*3233
3234 if test "x$TAPENADE" != x ; then
3235 cat >>$MAKEFILE <<EOF
3236 TAPENADE_SUPPORT_C_SRC_FILES = \
3237 ${TAPTOOLS}/ADFirstAidKit/adStack.c \
3238 ${TAPTOOLS}/ADFirstAidKit/adBinomial.c
3239 EOF
3240 echo 'TAP_SUPPORT_OBJFILES = $(TAPENADE_SUPPORT_C_SRC_FILES:.c=.o)' >> $MAKEFILE
3241 fi
3242
5bb11ad8a0 Ed H*3243 echo >> $MAKEFILE
3244 echo '.SUFFIXES:' >> $MAKEFILE
71b7a3e5ac Mart*3245 echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flow' >> $MAKEFILE
6aec5d9846 Ed H*3246
3247 cat >>$MAKEFILE <<EOF
3248
621623385c Jean*3249 all: fwd_exe_target
3250 fwd_exe_target:
3251 @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
3252 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3253 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3254 @-rm -f ad_config.template
3255 \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
3256
5bd7f28048 Jean*3257 \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
0c83fc374c Alis*3258 @echo Creating \$@ ...
6aec5d9846 Ed H*3259 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
dd9f72a48c Jean*3260
6aec5d9846 Ed H*3261 depend:
621623385c Jean*3262 @\$(MAKE) -f \$(MAKEFILE) links
bc2c9aac73 Oliv*3263 \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F77_SRC_FILES)
f79ba37af1 Mart*3264 \$(MAKEDEPEND) -f \$(MAKEFILE) -a -o .$FS90 \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F90_SRC_FILES)
95cd2dedde Ivan*3265 \$(TOOLSDIR)/f90mkdepend -fs $FS -fs90 $FS90 >> \$(MAKEFILE)
c55c6693ee Ed H*3266 -rm -f makedepend.out
6aec5d9846 Ed H*3267
04be54cff9 Chri*3268 lib: libmitgcmuv.a
3269
25bb252094 Jean*3270 libmitgcmuv.a: \$(SPECIAL_FILES) \$(OBJFILES)
04be54cff9 Chri*3271 ar rcv libmitgcmuv.a \$(OBJFILES)
3a8b237fcd Chri*3272 ar d libmitgcmuv.a main.o
04be54cff9 Chri*3273
dd9f72a48c Jean*3274 obj: \$(OBJFILES)
3275
5bd7f28048 Jean*3276 links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
6aec5d9846 Ed H*3277
5bd7f28048 Jean*3278 small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
6aec5d9846 Ed H*3279
6206da1394 Jean*3280 # remove most of the files that "make" generates
6aec5d9846 Ed H*3281 clean:
f68e8310e6 Patr*3282 -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
3283 -rm -rf *.o
71b7a3e5ac Mart*3284 -rm -rf *.$FS
45de16ddcf Jean*3285 -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
6206da1394 Jean*3286
3287 # remove most of the files that "make" and "make depend" generate
6aec5d9846 Ed H*3288 Clean:
621623385c Jean*3289 @\$(MAKE) -f \$(MAKEFILE) clean
3290 @\$(MAKE) -f \$(MAKEFILE) cleanlinks
71b7a3e5ac Mart*3291 -rm -rf *.flowdir
fa507bf6a3 Jean*3292 -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
b9626ac20f Jean*3293 -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
6206da1394 Jean*3294
3295 # remove also the executable, files that "genmake2" generates (except Makefile)
683b8f029b Jean*3296 # and output from a run (plus log files from testreport)
6aec5d9846 Ed H*3297 CLEAN:
621623385c Jean*3298 @\$(MAKE) -f \$(MAKEFILE) Clean
b4daa24319 Shre*3299 -rm -f \$(EXECUTABLE) \$(EXE_ADJ) \$(EXE_TLM) *.bak
8d24b8817c Jean*3300 -rm -f $LOGFILE genmake_state genmake_*optfile
3301 -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
fea3e7d209 Jean*3302 -rm -rf mpi_headers mnc_test_*
6aec5d9846 Ed H*3303 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
3304 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
3305 -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
bafb387432 Jean*3306 -rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
3307 -rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_*
3308 -rm -f *_MIT_CE_000.opt0000 costfunction*0000
cd15dc9a7a Jean*3309 -rm -f oad_cp.[0-9][0-9][0-9].?????
6aec5d9846 Ed H*3310
3311 makefile:
6aefb07181 Ed H*3312 $THIS_SCRIPT $G2ARGS
6aec5d9846 Ed H*3313 cleanlinks:
3314 -find . -type l -exec rm {} \;
3315
5bd7f28048 Jean*3316 # Special targets (SPECIAL_FILES) which are created by make
0c83fc374c Alis*3317 ${PACKAGES_DOT_H}:
3318 @echo Creating \$@ ...
621623385c Jean*3319 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
0c83fc374c Alis*3320 AD_CONFIG.h:
3321 @echo Creating \$@ ...
621623385c Jean*3322 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@
40f7a33215 Alis*3323 FC_NAMEMANGLE.h:
3324 @echo Creating \$@ ...
3325 echo "$FC_NAMEMANGLE" > \$@
0c83fc374c Alis*3326
9a263a84a8 Ed H*3327 BUILD_INFO.h:
3328 @echo Creating \$@ ...
3329 EOF
3330
3331 test ! "x$THISVER" = x && echo " -echo \"#define THISVER '$THISVER'\" > \$@" >> $MAKEFILE
3332 test ! "x$THISUSER" = x && echo " -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
3333 test ! "x$THISDATE" = x && echo " -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
3334 test ! "x$THISHOST" = x && echo " -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
3335
ab504a3a96 Ed H*3336 if test "x$EMBED_SRC" = xt ; then
3337 cat >>$MAKEFILE <<EOF
3338
3339 decode_files.o : EMBEDDED_FILES.h
3340
bf318dd62d Jean*3341 ## \$(F77_PP_SRC_FILES)
5bd7f28048 Jean*3342 all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
ab504a3a96 Ed H*3343 @echo Creating \$@ ...
5bd7f28048 Jean*3344 -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
ab504a3a96 Ed H*3345 -rm -f all_fF.tar.gz
3346 -gzip all_fF.tar
3347
3348 EMBEDDED_FILES.h : all_fF.tar.gz
3349 @echo Creating \$@ ...
3350 -\${ROOTDIR}/tools/embed_encode/encode_files EMBEDDED_FILES.h all_fF.tar.gz
3351
3352 EOF
3353 fi
3354
9a263a84a8 Ed H*3355 cat >>$MAKEFILE <<EOF
3356
3eb03232c2 Ed H*3357 # The normal chain of rules is ( .F - .$FS - .o )
3358
7a76cc695e Ed H*3359 ## This nullifies any default implicit rules concerning these two file types:
3af519cc10 Jean*3360 ## %.o : %.F
3eb03232c2 Ed H*3361
7d5fc6b559 Jean*3362 # C preprocessing and replacing the _d in constants:
5158aa0815 Jean*3363 CPPCMD = cat \$< | ${CPP} \$(DEFINES) \$(INCLUDES) | ${S64}
3364
3eb03232c2 Ed H*3365 .F.$FS:
5158aa0815 Jean*3366 \$(CPPCMD) > \$@
3eb03232c2 Ed H*3367 .$FS.o:
6aec5d9846 Ed H*3368 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
23f21461eb Jean*3369 .F.o:
3370 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
5bd7f28048 Jean*3371 .F90.$FS90:
5158aa0815 Jean*3372 \$(CPPCMD) > \$@
5bd7f28048 Jean*3373 .FF90.f$FS90:
5158aa0815 Jean*3374 \$(CPPCMD) > \$@
5bd7f28048 Jean*3375 .$FS90.o:
27c9249c85 Chri*3376 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
5bd7f28048 Jean*3377 .f$FS90.o:
3378 cp \$< \$(basename \$<).f90
3379 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename \$<).f90
6aec5d9846 Ed H*3380 .c.o:
29eb399fd0 Cons*3381 \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
6aec5d9846 Ed H*3382
3eb03232c2 Ed H*3383 # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
3384 .F.p:
5158aa0815 Jean*3385 \$(CPPCMD) > \$@
3eb03232c2 Ed H*3386 .p.$FS:
6aec5d9846 Ed H*3387 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
3388
5bd7f28048 Jean*3389 EOF
3390
668b211e58 Ed H*3391 #=========================================
3392 #=== Automatic Differentiation Rules ===
5bd7f28048 Jean*3393 #=== for TAMC/TAF ======================
3394
b4daa24319 Shre*3395 if test "x$TAPENADE" = x ; then
5be35a17af Jean*3396 if test "x$OPENAD" = x ; then
5bd7f28048 Jean*3397
3398 cat >>$MAKEFILE <<EOF
668b211e58 Ed H*3399
3400 TAMC = ${TAMC}
3401 TAF = ${TAF}
3402
0c0e61146f Ed H*3403 TAF_EXTRA = ${TAF_EXTRA}
3404 TAMC_EXTRA = ${TAMC_EXTRA}
fea3e7d209 Jean*3405 LOCAL_MPI_HEADERS = ${LOCAL_MPI_HEADERS}
0c0e61146f Ed H*3406
668b211e58 Ed H*3407 EOF
3408
3409 ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
3410 ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
3411 ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
3412 for i in $ad_vars ; do
3413 name=$i
36459526ba Ed H*3414 t1="t2=\$"`echo "$i"`
668b211e58 Ed H*3415 eval $t1
3416 printf "%-20s = " $name >> $MAKEFILE
36459526ba Ed H*3417 echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
668b211e58 Ed H*3418 done
3419
3420 echo " Add the source list for AD code generation"
3421 echo >> $MAKEFILE
13fa7032ba Ed H*3422 printf "AD_FILES = " >> $MAKEFILE
ea893758ea Patr*3423 AD_FILES=`cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g"`
668b211e58 Ed H*3424 for i in $AD_FILES ; do
0524b7d1ff Mart*3425 echo " \\" >> $MAKEFILE
13fa7032ba Ed H*3426 printf " $i" >> $MAKEFILE
668b211e58 Ed H*3427 done
3428 echo >> $MAKEFILE
7deef35259 Jean*3429 rm -f $TMP.adSrcFiles
ea893758ea Patr*3430 printf "AD_F90FILES = " >> $MAKEFILE
3431 AD_F90FILES=`cat $TMP.adF90Files | sed -e "s/\.f90/.$FS90/g"`
3432 for i in $AD_F90FILES ; do
0524b7d1ff Mart*3433 echo " \\" >> $MAKEFILE
ea893758ea Patr*3434 printf " $i" >> $MAKEFILE
3435 done
3436 echo >> $MAKEFILE
3437 rm -f $TMP.adF90Files
668b211e58 Ed H*3438
44f4a23ebb Jean*3439 if test $CAT_SRC_FOR_TAF = 0 ; then
3440 cat >>$MAKEFILE <<EOF
3441
3442 # ... Utilities ...
3443 remove_comments:
3444 sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES)
3445 @-rm -f \$(AD_FILES:.$FS=.$FS.bak)
3446 adj_sed:
3447 sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
3448 @-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
3449 ftl_sed:
3450 sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS)
3451 @-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak)
ea893758ea Patr*3452 adobjfiles: \$(AD_FILES:.$FS=_ad.o) \$(AD_F90FILES:.$FS90=_ad.o)
0524b7d1ff Mart*3453 ftlobjfiles: \$(AD_FILES:.$FS=_tl.o) \$(AD_F90FILES:.$FS90=_tl.o)
44f4a23ebb Jean*3454 EOF
3455 fi
3456
668b211e58 Ed H*3457 cat >>$MAKEFILE <<EOF
3458
eb2bbeeb07 Ed H*3459 # ... AD ...
621623385c Jean*3460 adall: ad_exe_target
e1583c94d9 Ed H*3461 adtaf: ad_taf_output.$FS
3462 adtamc: ad_tamc_output.$FS
74d4132da5 Ed H*3463
621623385c Jean*3464 ad_exe_target:
b4daa24319 Shre*3465 @echo Update AD_CONFIG.h and make \$(EXE_ADJ)
621623385c Jean*3466 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3467 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3468 @-rm -f ad_config.template
b4daa24319 Shre*3469 \$(MAKE) -f \$(MAKEFILE) \$(EXE_ADJ)
621623385c Jean*3470
7783960e4d Jean*3471 ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES)
621623385c Jean*3472 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
577a31280a Ed H*3473 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
621623385c Jean*3474 @-rm -f ad_config.template
3475 @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
71b7a3e5ac Mart*3476 cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
4a967b9107 Ed H*3477
ea893758ea Patr*3478 EOF
3479 if test -n "$AD_F90FILES" ; then
3480 cat >>$MAKEFILE <<EOF
3481 ad_inpF90_code.$FS90: \$(AD_F90FILES) \$(AD_FLOW_FILES)
3482 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3483 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3484 @-rm -f ad_config.template
3485 @\$(MAKE) -f \$(MAKEFILE) \$(F90_PP_SRC_FILES)
3486 cat \$(AD_F90FILES) > ad_inpF90_code.$FS90
3487
3488 EOF
3489 fi
3490 cat >>$MAKEFILE <<EOF
3491 # this is an unused target and could be removed
3492 adtafonly: ad_input_code.$FS
3493 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) -fixed ad_input_code.$FS
20ef1172ff Jean*3494 ls -l ad_input_code_ad.$FS
e1583c94d9 Ed H*3495 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
668b211e58 Ed H*3496
44f4a23ebb Jean*3497 EOF
3498
3499 if test $CAT_SRC_FOR_TAF = 1 ; then
ea893758ea Patr*3500 if test -z "$AD_F90FILES" ; then
44f4a23ebb Jean*3501 cat >>$MAKEFILE <<EOF
3502 # ... send 1 file to TAF ...
3503 ad_taf_output.$FS: ad_input_code.$FS
3504 @-rm -f ad_input_code_ad.$FS ; echo ''
ea893758ea Patr*3505 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) -fixed ad_input_code.$FS
20ef1172ff Jean*3506 ls -l ad_input_code_ad.$FS
e1583c94d9 Ed H*3507 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
405822b4f9 Patr*3508
ea893758ea Patr*3509 \$(EXE_ADJ): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3510 \$(LINK) -o \${EXE_ADJ} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
668b211e58 Ed H*3511
ea893758ea Patr*3512 adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
668b211e58 Ed H*3513
44f4a23ebb Jean*3514 EOF
ea893758ea Patr*3515 else
3516 cat >>$MAKEFILE <<EOF
3517 # ... send 1 fixed format file and 1 free format file to TAF ...
3518 ad_taf_output.$FS: ad_input_code.$FS ad_inpF90_code.$FS90
3519 @-rm -f ad_input_code_ad.$FS ad_inpF90_code_ad.$FS90 ; echo ''
3520 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) -fixed ad_input_code.$FS -free ad_inpF90_code.$FS90
3521 ls -l ad_input_code_ad.$FS ad_inpF90_code_ad.$FS90
3522 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3523
3524 # We need the extra target for ad_taf_outpF90.$FS90, because the file is
3525 # generated together with ad_taf_output.$FS.
3526 ad_taf_outpF90.$FS90: ad_taf_output.$FS
3527 cat ad_inpF90_code_ad.$FS90 > ad_taf_outpF90.$FS90
3528
3529 \$(EXE_ADJ): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o ad_taf_outpF90.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3530 \$(LINK) -o \${EXE_ADJ} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o ad_taf_outpF90.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3531
3532 adobj: ad_taf_output.o ad_taf_outpF90.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3533
3534 EOF
3535 fi
668b211e58 Ed H*3536
44f4a23ebb Jean*3537 else
3538 cat >>$MAKEFILE <<EOF
3539 # ... send multiple files to TAF ...
ea893758ea Patr*3540 ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES) \$(AD_F90FILES)
44f4a23ebb Jean*3541 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3542 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3543 @-rm -f ad_config.template
ea893758ea Patr*3544 @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
44f4a23ebb Jean*3545 @-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
ea893758ea Patr*3546 @-rm -f \$(AD_F90FILES:.$FS90=_ad.$FS90) \$(AD_F90FILES:.$FS90=_ad.o); echo ''
44f4a23ebb Jean*3547 \$(MAKE) -f \$(MAKEFILE) remove_comments
71b7a3e5ac Mart*3548 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) -fixed \$(AD_FLOW_FILES) \$(AD_FILES) -free \$(AD_F90FILES)
44f4a23ebb Jean*3549 \$(MAKE) -f \$(MAKEFILE) adj_sed
3550 cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS
3551
ea893758ea Patr*3552 \$(EXE_ADJ): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
b3a874fe30 Jean*3553 \$(MAKE) -f \$(MAKEFILE) adobjfiles
ea893758ea Patr*3554 \$(LINK) -o \${EXE_ADJ} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_ad.o) \$(AD_F90FILES:.$FS90=_ad.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
44f4a23ebb Jean*3555
ea893758ea Patr*3556 adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
b3a874fe30 Jean*3557 \$(MAKE) -f \$(MAKEFILE) adobjfiles
44f4a23ebb Jean*3558
3559 EOF
3560 fi
3561
3924ebfa1b Mart*3562 #adonlyfwd:
3563 # patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3564 #adtrick:
3565 # patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
668b211e58 Ed H*3566
3924ebfa1b Mart*3567 cat >>$MAKEFILE <<EOF
44f4a23ebb Jean*3568 ad_tamc_output.$FS: ad_input_code.$FS
3569 \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3570 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3571
3572 ad_tamc: ad_tamc_output.o \$(OBJFILES)
b4daa24319 Shre*3573 \$(LINK) -o ${EXE_ADJ} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
863253e995 Jean*3574
0f20d21780 Ed H*3575 # ... FTL ...
621623385c Jean*3576 ftlall: ftl_exe_target
e1583c94d9 Ed H*3577 ftltaf: ftl_taf_output.$FS
3578 ftltamc: ftl_tamc_output.$FS
74d4132da5 Ed H*3579
621623385c Jean*3580 ftl_exe_target:
b4daa24319 Shre*3581 @echo Update AD_CONFIG.h and make \$(EXE_TLM)
621623385c Jean*3582 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3583 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3584 @-rm -f ad_config.template
b4daa24319 Shre*3585 \$(MAKE) -f \$(MAKEFILE) \$(EXE_TLM)
621623385c Jean*3586
0524b7d1ff Mart*3587 ftl_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES)
621623385c Jean*3588 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3589 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3590 @-rm -f ad_config.template
3591 @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
7783960e4d Jean*3592 cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
4a967b9107 Ed H*3593
0524b7d1ff Mart*3594 EOF
3595 if test -n "$AD_F90FILES" ; then
3596 cat >>$MAKEFILE <<EOF
3597 ftl_inpF90_code.$FS90: \$(AD_F90FILES) \$(AD_FLOW_FILES)
3598 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3599 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3600 @-rm -f ad_config.template
3601 @\$(MAKE) -f \$(MAKEFILE) \$(F90_PP_SRC_FILES)
3602 cat \$(AD_F90FILES) > ftl_inpF90_code.$FS90
3603
3604 EOF
3605 fi
3606 cat >>$MAKEFILE <<EOF
ea893758ea Patr*3607 # this is an unused target and could be removed
44f4a23ebb Jean*3608 ftltafonly:
ea893758ea Patr*3609 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) -fixed ftl_input_code.$FS
09f59bbc00 Patr*3610 ls -l ftl_input_code_tl.$FS
3611 cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
668b211e58 Ed H*3612
44f4a23ebb Jean*3613 EOF
3614
3615 if test $CAT_SRC_FOR_TAF = 1 ; then
0524b7d1ff Mart*3616 if test -z "$AD_F90FILES" ; then
44f4a23ebb Jean*3617 cat >>$MAKEFILE <<EOF
3618 # ... send 1 file to TAF ...
3619 ftl_taf_output.$FS: ftl_input_code.$FS
3620 @-rm -f ftl_input_code_tl.$FS ; echo ''
ea893758ea Patr*3621 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) -fixed ftl_input_code.$FS
09f59bbc00 Patr*3622 ls -l ftl_input_code_tl.$FS
3623 cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
0b6ffb4e9b Patr*3624
0524b7d1ff Mart*3625 \$(EXE_TLM): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3626 \$(LINK) -o \${EXE_TLM} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
668b211e58 Ed H*3627
0524b7d1ff Mart*3628 ftlobj: ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
c59dd234b1 Jean*3629
44f4a23ebb Jean*3630 EOF
0524b7d1ff Mart*3631 else
3632 cat >>$MAKEFILE <<EOF
3633 # ... send 1 fixed format file and 1 free format file to TAF ...
3634 ftl_taf_output.$FS: ftl_input_code.$FS ftl_inpF90_code.$FS90
3635 @-rm -f ftl_input_code_tl.$FS ftl_inpF90_code_tl.$FS90 ; echo ''
3636 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) -fixed ftl_input_code.$FS -free ftl_inpF90_code.$FS90
3637 ls -l ftl_input_code_tl.$FS ftl_inpF90_code_tl.$FS90
3638 cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3639
3640 # We need the extra target for ftl_taf_outpF90.$FS90, because the file is
3641 # generated together with ftl_taf_output.$FS.
3642 ftl_taf_outpF90.$FS90: ftl_taf_output.$FS
3643 cat ftl_inpF90_code_tl.$FS90 > ftl_taf_outpF90.$FS90
3644
3645 \$(EXE_TLM): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o ftl_taf_outpF90.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3646 \$(LINK) -o \${EXE_TLM} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o ftl_taf_outpF90.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3647
3648 ftlobj: ftl_taf_output.o ftl_taf_outpF90.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3649
3650 EOF
3651 fi
44f4a23ebb Jean*3652
3653 else
3654 cat >>$MAKEFILE <<EOF
3655 # ... send multiple files to TAF ...
0524b7d1ff Mart*3656 ftl_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES) \$(AD_F90FILES)
44f4a23ebb Jean*3657 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3658 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3659 @-rm -f ad_config.template
0524b7d1ff Mart*3660 @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
44f4a23ebb Jean*3661 @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3662 @-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo ''
0524b7d1ff Mart*3663 @-rm -f \$(AD_F90FILES:.$FS90=_tl.$FS90) \$(AD_F90FILES:.$FS90=_tl.o); echo ''
44f4a23ebb Jean*3664 \$(MAKE) -f \$(MAKEFILE) remove_comments
0524b7d1ff Mart*3665 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) -fixed \$(AD_FLOW_FILES) \$(AD_FILES) -free \$(AD_F90FILES)
44f4a23ebb Jean*3666 \$(MAKE) -f \$(MAKEFILE) ftl_sed
3667 cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS
3668
0524b7d1ff Mart*3669 \$(EXE_TLM): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
b3a874fe30 Jean*3670 \$(MAKE) -f \$(MAKEFILE) ftlobjfiles
0524b7d1ff Mart*3671 \$(LINK) -o \${EXE_TLM} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_tl.o) \$(AD_F90FILES:.$FS90=_tl.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
44f4a23ebb Jean*3672
0524b7d1ff Mart*3673 ftlobj: ftl_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(NON_AD_F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
c59dd234b1 Jean*3674 \$(MAKE) -f \$(MAKEFILE) ftlobjfiles
3675
44f4a23ebb Jean*3676 EOF
3677 fi
3678
3679 cat >>$MAKEFILE <<EOF
e1583c94d9 Ed H*3680 ftl_tamc_output.$FS: ftl_input_code.$FS
3681 \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3682 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
eb2bbeeb07 Ed H*3683
0f20d21780 Ed H*3684 ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
b4daa24319 Shre*3685 \$(LINK) -o ${EXE_TLM} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
eb2bbeeb07 Ed H*3686
3687 # ... SVD ...
e1583c94d9 Ed H*3688 svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
fdbd521b91 Patr*3689 @echo "--->>> Only ran TAF to generate SVD code! <<<---"
3690 @echo "--->>> Do make svdall afterwards to compile. <<<---"
3691 svdall: svd_touch svd_taf
eb2bbeeb07 Ed H*3692
fdbd521b91 Patr*3693 svd_taf: \$(OBJFILES)
0b6ffb4e9b Patr*3694 \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
668b211e58 Ed H*3695
fdbd521b91 Patr*3696 @echo "--->>> Only COMPILE svd code! <<<---"
3697 @echo "--->>> Assumes you previously <<<---"
3698 @echo "--->>> did make svdtaf <<<---"
3699
3700 svd_touch:
3701 @echo "--->>> Only COMPILE svd code! <<<---"
3702 @echo "--->>> Assumes you previously <<<---"
3703 @echo "--->>> did make svdtaf <<<---"
e1583c94d9 Ed H*3704 touch ad_taf_output.$FS ftl_taf_output.$FS
3705 \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3706 \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
621623385c Jean*3707 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "SVD version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3708 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3709 @-rm -f ad_config.template
668b211e58 Ed H*3710
5bd7f28048 Jean*3711 EOF
3712
5be35a17af Jean*3713 fi
b4daa24319 Shre*3714 fi
3715
3716 #=== for TAPENADE ========================
3717
3718 if test "x$TAPENADE" != x ; then
3719
3720 # ============ begin TAPENADE specific section ==============
3721
3722 cat >>$MAKEFILE <<EOF
3723 # ========== begin TAPENADE specific section ==============
3724 EOF
3725
3726 echo " Add the source list for AD code generation"
3727 echo >> $MAKEFILE
3728 printf "AD_FILES = " >> $MAKEFILE
3729 AD_FILES=`cat $TMP.adSrcFiles`
3730 for i in $AD_FILES ; do
3731 basename=${i%%.f}
3732 toBeIgnored=`egrep ^$basename'[ ]*' ${TAP_DONT_COMPILE} ${TAP_DONT_TRANSFORM}`
3733 if test -z "$toBeIgnored" ; then
3734 echo " \\" >> $MAKEFILE
3735 printf " $i" >> $MAKEFILE
3736 fi
3737 done
3738 echo >> $MAKEFILE
3739 rm -f $TMP.adSrcFiles
ea893758ea Patr*3740 rm -f $TMP.adF90Files
b4daa24319 Shre*3741
3742 cat >>$MAKEFILE <<EOF
3743
3744 TAPENADECMD = ${TAPENADECMD}
3745
3746 TAPENADE_SUPPORT_F90_SRC_FILES = \
3747 ${TAPTOOLS}/diffsizes.F90
3748 AD_CLEAN = *_b.f *_d.f *.f~ *.msg *.msg~ f95_test_mods.f90
3749
3750 f95_test_mods.f90: \$(TAPENADE_SUPPORT_F90_SRC_FILES)
3751 cat \$^ > \$@
3752 #
3753 AD_FILES_ADJ=\$(AD_FILES:.$FS=_b.f)
3754 AD_FILES_TLM=\$(AD_FILES:.$FS=_d.f)
3755 #
3756 .PHONY: TAP_TLM_FILES
3757 TAP_TLM_FILES: \$(AD_FILES) f95_test_mods.f90
3758 touch \$(AD_FILES_TLM)
3759 \$(TAPENADECMD) -d -ext "${TAPTOOLS}/flow_tap" -head "the_main_loop(fc)/(xx_genarr3d_dummy, xx_genarr2d_dummy, xx_gentim2d_dummy)" \$(AD_FILES) f95_test_mods.f90
3760 #
3761 .PHONY: TAP_ADJ_FILES
3762 TAP_ADJ_FILES: \$(AD_FILES) f95_test_mods.f90
3763 touch \$(AD_FILES_ADJ)
3764 \$(TAPENADECMD) -b -ext "${TAPTOOLS}/flow_tap" -head "the_main_loop(fc)/(xx_genarr3d_dummy, xx_genarr2d_dummy, xx_gentim2d_dummy)" \$(AD_FILES) f95_test_mods.f90
3765
3766 tap_adj: ad_exe_target
3767 ad_exe_target:
3768 @echo Update AD_CONFIG.h and make \$(EXE_ADJ)
3769 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3770 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3771 @-rm -f ad_config.template
3772 \$(MAKE) -f \$(MAKEFILE) \$(EXE_ADJ)
3773
3774 tap_tlm: tlm_exe_target
3775 tlm_exe_target:
3776 @echo Update AD_CONFIG.h and make \$(EXE_TLM)
3777 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Tangent linear version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3778 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3779 @-rm -f ad_config.template
3780 \$(MAKE) -f \$(MAKEFILE) \$(EXE_TLM)
3781
3782 \$(EXE_ADJ): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(TAP_SUPPORT_OBJFILES) \$(EMBEDDED_FILES) TAP_ADJ_FILES
3783 @echo Creating \$@ ...
3784 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(AD_FILES_ADJ) \$(TAP_SUPPORT_OBJFILES:${TAPTOOLS}/ADFirstAidKit/%=%) \$(LIBS)
3785 \$(EXE_TLM): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(TAP_SUPPORT_OBJFILES) \$(EMBEDDED_FILES) TAP_TLM_FILES
3786 @echo Creating \$@ ...
3787 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(AD_FILES_TLM) \$(TAP_SUPPORT_OBJFILES:${TAPTOOLS}/ADFirstAidKit/%=%) \$(LIBS)
3788
3789 # ============ end TAPENADE specific section ==============
3790
3791 EOF
3792
3793 fi
5bd7f28048 Jean*3794
3795 #=== for OpenAD ========================
3796
5be35a17af Jean*3797 if test "x$OPENAD" != x ; then
5bd7f28048 Jean*3798
3799 # ============ begin OpenAD specific section ==============
3800
3801 cat >>$MAKEFILE <<EOF
fc13640ec0 Jean*3802 # ... OpenAD ...
5bd7f28048 Jean*3803
5be35a17af Jean*3804 # all the source files linked from the various locations:
5bd7f28048 Jean*3805 ALL_LINKED_FILES= \
3806 \$(F77_SRC_FILES) \
3807 \$(C_SRC_FILES) \
3808 \$(H_SRC_FILES) \
3809 \$(F90_SRC_FILES) \
3810 \$(SPECIAL_FILES)
3811
9d0c386f0c dngo*3812 EOF
3813
3814 if test "x$SINGULARITYFILE" != x ; then
3815 # run OpenAD commands in singularity container with standard paths
3816 cat >>$MAKEFILE <<EOF
3817 SINGULARITYCMD = singularity exec ${SINGULARITYFILE}
3818 export SINGULARITYENV_LD_LIBRARY_PATH=/OpenAD//Open64/osprey1.0/targ_ia64_ia64_linux/whirl2f/
3819 export OPENADROOT=/OpenAD
3820 export XAIFBOOSTERROOT=/OpenAD/xaifBooster/..
3821 export XAIFSCHEMAROOT=/OpenAD/xaif
3822 export OPENADFORTTK_BASE=/OpenAD/OpenADFortTk
3823 export OPEN64ROOT=/OpenAD/Open64/osprey1.0/targ_ia64_ia64_linux
3824 export OPENADFORTTK=/OpenAD/OpenADFortTk/OpenADFortTk-x86_64-Linux
3825
3826 EOF
3827 else
3828 # run OpenAD directly
3829 cat >>$MAKEFILE <<EOF
3830 SINGULARITYCMD =
3831
3832 EOF
3833 fi
3834
3835 cat >>$MAKEFILE <<EOF
5bd7f28048 Jean*3836 ifndef OPENADROOT
3837 \$(error "Error: environment variable OPENADROOT not defined!")
3838 endif
3839
3840 ifndef XAIFSCHEMAROOT
3841 \$(error "Error: environment variable XAIFSCHEMAROOT not defined!")
3842 endif
3843
3844 ifndef XAIFBOOSTERROOT
3845 \$(error "Error: environment variable XAIFBOOSTERROOT not defined!")
3846 endif
71a0839232 Chri*3847
3848 EOF
3849
5bd7f28048 Jean*3850 echo " Add the source list for common block to module conversion "
3851 echo >> $MAKEFILE
3852 printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
3853 for i in `cat ${OAD_CB2M_FILES}` ; do
3854 echo " \\" >> $MAKEFILE
3855 printf " $i" >> $MAKEFILE
3856 done
3857 echo >> $MAKEFILE
3858
3859 echo " Add the source list for AD code generation"
3860 echo >> $MAKEFILE
3861 printf "AD_FILES = " >> $MAKEFILE
3862 for i in `cat ${OAD_CB2M_FILES}` ; do
3863 echo " \\" >> $MAKEFILE
3864 printf " ${i}_mod.f$FS90" >> $MAKEFILE
3865 done
7deef35259 Jean*3866 AD_FILES=`cat $TMP.adSrcFiles`
5bd7f28048 Jean*3867 for i in $AD_FILES ; do
3868 basename=${i%%.f}
3869 toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3870 if test -z "$toBeIgnored" ; then
3871 echo " \\" >> $MAKEFILE
3872 printf " $i" >> $MAKEFILE
3873 fi
3874 done
3875 echo >> $MAKEFILE
7deef35259 Jean*3876 rm -f $TMP.adSrcFiles
ea893758ea Patr*3877 rm -f $TMP.adF90Files
5bd7f28048 Jean*3878
3879 cat >>$MAKEFILE <<EOF
3880
fc13640ec0 Jean*3881 adAll: ad_exe_target
5bd7f28048 Jean*3882 .PHONY: adAll
3883
fc13640ec0 Jean*3884 ad_exe_target:
b4daa24319 Shre*3885 @echo Update AD_CONFIG.h and make \$(EXE_ADJ)
fc13640ec0 Jean*3886 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3887 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3888 @-rm -f ad_config.template
b4daa24319 Shre*3889 \$(MAKE) -f \$(MAKEFILE) \$(EXE_ADJ)
fc13640ec0 Jean*3890
5bd7f28048 Jean*3891 CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3892
3893 .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3894
3895 .PHONY: adDepend
3896 adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
c62d6c2ba9 Jean*3897 \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
95cd2dedde Ivan*3898 \$(TOOLSDIR)/f90mkdepend -fs $FS -fs90 $FS90 >> \$(MAKEFILE)
5bd7f28048 Jean*3899 -rm -f makedepend.out
3900
3901 OPENAD_SUPPORT_F90_SRC_FILES = \
3902 w2f__types.F90 \
3903 OAD_active.F90 \
3904 OAD_cp.F90 \
3905 OAD_rev.F90 \
b6f3d01b24 Jean*3906 OAD_tape.F90 \
279dc77b07 Patr*3907 OAD_regular_cp.F90 \
b6f3d01b24 Jean*3908 revolve.F90
5bd7f28048 Jean*3909
3910 OPENAD_SUPPORT_C_SRC_FILES = \
3911 iaddr.c \
3912 timeRatio.c
3913
3914 f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3915 cat \$^ > \$@
3916
5be35a17af Jean*3917 f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
5bd7f28048 Jean*3918 cat \$^ > \$@
3919
3920 f95_test.out: f95_test_mods.f90 f95_test.f90
3921 f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3922 f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3923
0e81c91d99 Jean*3924 CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
5bd7f28048 Jean*3925
0e81c91d99 Jean*3926 AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) OAD_intrinsics_oad.o \$(CB2M_AD_FILES:.f$FS90=_oad.o)
45de16ddcf Jean*3927
3928 AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
3929
b4daa24319 Shre*3930 \$(EXE_ADJ): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
45de16ddcf Jean*3931 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
5bd7f28048 Jean*3932
0e81c91d99 Jean*3933 # create sources files modules from header files containing common blocks
25bb252094 Jean*3934 %_mod.FF90 : %.h \$(OADTOOLS)/cb2mGetModules.csh \$(OADTOOLS)/cb2mGetModules.awk
3935 \$(OADTOOLS)/cb2mGetModules.csh $< \$(OADTOOLS)/cb2mGetModules.awk
5bd7f28048 Jean*3936
776d1c0efd Jean*3937 # create new header files with USE statements for the new modules made above
25bb252094 Jean*3938 %_mod.h : %.h \$(OADTOOLS)/cb2mGetHeaders.csh \$(OADTOOLS)/cb2mGetHeaders.awk
3939 \$(OADTOOLS)/cb2mGetHeaders.csh $< \$(OADTOOLS)/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
5bd7f28048 Jean*3940
0e81c91d99 Jean*3941 # change the include directives of everybody to refer to the new header files with the USE statements
25bb252094 Jean*3942 %_cb2m.FF90 : %.F \$(OADTOOLS)/cb2mUseModules.bash
3943 \$(OADTOOLS)/cb2mUseModules.bash $< ${MPI}
5bd7f28048 Jean*3944
3945 # makefile debug rule
3946 small_f: \$(CB2M_F90_PP_SRC_FILES)
3947 .PHONY: small_f
3948
0684e64a42 Jean*3949 ad_input_code.f$FS90: \$(CB2M_AD_FILES)
5bd7f28048 Jean*3950 cat \$^ > \$@
3951
3952 # canonicalizer
776d1c0efd Jean*3953 ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
9d0c386f0c dngo*3954 \${SINGULARITYCMD} \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S -o \$@ \$^
0e81c91d99 Jean*3955
3956 # replace stop statements (to avoid the implied unstructured control flow) with print statements
3957 ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
25bb252094 Jean*3958 cat \$< | sed -f \$(OADTOOLS)/stop2print.sed > ad_input_code_sf.pre.s2p.f90
5bd7f28048 Jean*3959
3960 # F -> WHIRL
0e81c91d99 Jean*3961 ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
9d0c386f0c dngo*3962 \${SINGULARITYCMD} \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
5bd7f28048 Jean*3963
3964 # WHIRL -> XAIF
776d1c0efd Jean*3965 ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
9d0c386f0c dngo*3966 \${SINGULARITYCMD} \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
5bd7f28048 Jean*3967
3968 # XAIF -> XAIF'
776d1c0efd Jean*3969 ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd
9d0c386f0c dngo*3970 \${SINGULARITYCMD} \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
5bd7f28048 Jean*3971
3972 # XAIF' -> WHIRL'
776d1c0efd Jean*3973 ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
9d0c386f0c dngo*3974 \${SINGULARITYCMD} \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
5bd7f28048 Jean*3975
3976 # WHIRL' -> F'
776d1c0efd Jean*3977 ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
9d0c386f0c dngo*3978 \${SINGULARITYCMD} \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
5bd7f28048 Jean*3979
3980 # insert template directives
25bb252094 Jean*3981 ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \$(OADTOOLS)/insertTemplateDir.bash
3982 \$(OADTOOLS)/insertTemplateDir.bash \$< \$@
5bd7f28048 Jean*3983
25bb252094 Jean*3984 PPEXTRAS=\$(notdir \$(wildcard \$(OADTOOLS)/ad_template.*.F)) ad_inline.F
5bd7f28048 Jean*3985 # postprocess F'
0e81c91d99 Jean*3986 postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
9d0c386f0c dngo*3987 \${SINGULARITYCMD} \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ad_inline.f \$<
0e81c91d99 Jean*3988 # the target is a placeholder to trigger a single execution of the rule
45de16ddcf Jean*3989 touch \$@
776d1c0efd Jean*3990 # put this so make knows about the postprocessing output
0e81c91d99 Jean*3991 OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
5bd7f28048 Jean*3992
0e81c91d99 Jean*3993 # link the XAIF schema files
5bd7f28048 Jean*3994 %.xsd:
3995 \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3996
3997 # link the support files:
01e0754d66 Oliv*3998 \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
25bb252094 Jean*3999 \$(LN) \$(OADTOOLS)/\$@ .
5bd7f28048 Jean*4000
01e0754d66 Oliv*4001 AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag
45de16ddcf Jean*4002
5bd7f28048 Jean*4003 # ============ end OpenAD specific section ==============
4004
4005 EOF
4006
4007 fi
4008
4009 #=========================================
4010
6c90987a77 Ed H*4011 if test "x$EXEHOOK" != x ; then
4012 printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
4013 fi
4014
6aec5d9846 Ed H*4015 echo " Making list of \"exceptions\" that need \".p\" files"
4016 for i in $KPPFILES ; do
4017 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
4018 RETVAL=$?
4019 if test "x$RETVAL" != x0 ; then
4020 echo "Error: unable to add file \"$i\" to the exceptions list"
4021 fi
3eb03232c2 Ed H*4022 echo "$base.$FS: $base.p" >> $MAKEFILE
6aec5d9846 Ed H*4023 done
4024
4025 echo " Making list of NOOPTFILES"
4026 for i in $NOOPTFILES ; do
4027 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
4028 RETVAL=$?
4029 if test "x$RETVAL" != x0 ; then
4030 echo "Error: unable to add file \"$i\" to the exceptions list"
4031 fi
3eb03232c2 Ed H*4032 echo "$base.o: $base.$FS" >> $MAKEFILE
76c1b0ef61 Ed H*4033 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
6aec5d9846 Ed H*4034 done
4035
4036 echo " Add rules for links"
7deef35259 Jean*4037 cat $TMP.srclinks >> $MAKEFILE
4038 rm -f $TMP.srclinks
6aec5d9846 Ed H*4039
4040 echo " Adding makedepend marker"
76c1b0ef61 Ed H*4041 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
6aec5d9846 Ed H*4042
76c1b0ef61 Ed H*4043 printf "\n=== Done ===\n"
2ff82eb834 Ed H*4044
1f2ed3565b Alis*4045 # Create special header files
621623385c Jean*4046 $BASH $TOOLSDIR/convert_cpp_cmd2defines -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
1f2ed3565b Alis*4047 if test ! -f $PACKAGES_DOT_H ; then
4048 mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
4049 else
a29e11f9ee Ed H*4050 cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
1f2ed3565b Alis*4051 RETVAL=$?
4052 if test "x$RETVAL" = x0 ; then
4053 rm -f $PACKAGES_DOT_H".tmp"
4054 else
4055 mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
4056 mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
4057 fi
4058 fi
4059 if test ! -f AD_CONFIG.h ; then
621623385c Jean*4060 $BASH $TOOLSDIR/convert_cpp_cmd2defines "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h
1f2ed3565b Alis*4061 fi
4062
2ff82eb834 Ed H*4063 # Write the "state" for future records
683b8f029b Jean*4064 if test "x$DUMPSTATE" = xt ; then
13fa7032ba Ed H*4065 printf "" > genmake_state
2ff82eb834 Ed H*4066 for i in $gm_state ; do
4067 t1="t2=\$$i"
4068 eval $t1
dd9f72a48c Jean*4069 echo "$i='$t2'" | sed -e 's/ */ /g' >> genmake_state
2ff82eb834 Ed H*4070 done
4071 fi
f7aaac66f3 jm-c 4072
4073 # Conclude
516b08a580 jm-c 4074 if test $FC_CHECK = 5 ; then
f7aaac66f3 jm-c 4075 echo " original 'Makefile' generated successfully"
4076 echo "=> next steps:"
4077 ad=`echo $PACKAGES | grep -c autodiff`
4078 if test "x$OPENAD" != x ; then
4079 echo " > make adAll (<-- adjoint executable)"
4080 elif test $ad != 0 ; then
4081 echo " > make depend"
b4daa24319 Shre*4082 if test "x$TAPENADE" = x ; then
4083 echo " > make adall (<-- adjoint executable with TAF)"
4084 echo " or > make ftlall (<-- tang-lin executable with TAF)"
4085 else
4086 echo " > make tap_adj (<-- adjoint executable with Tapenade)"
4087 echo " or > make tap_tlm (<-- tang-lin executable with Tapenade)"
4088 fi
f7aaac66f3 jm-c 4089 echo " or > make (<-- forward executable)"
4090 else
4091 # echo " > make depend (add dependencies to Makefile)"
4092 echo " > make depend"
4093 echo " > make (<-- to generate executable)"
4094 fi
516b08a580 jm-c 4095 elif [ $FC_CHECK -ge 3 ] ; then
4096 echo " original 'Makefile' generated but was unable to"
4097 echo " run compiled test-program (please see '$LOGFILE')"
bcbb675387 jm-c 4098 elif [ $FC_CHECK -ge 0 ] ; then
516b08a580 jm-c 4099 echo "Warning: FORTRAN compiler test failed (please see '$LOGFILE')"
4100 echo "Warning: 'Makefile' might be unusable (check your optfile)"
f7aaac66f3 jm-c 4101 fi