--- MITgcm/tools/genmake2 2008/12/11 17:50:56 1.180 +++ MITgcm/tools/genmake2 2009/03/29 19:09:24 1.186 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.180 2008/12/11 17:50:56 utke Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.186 2009/03/29 19:09:24 jmc Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -1046,6 +1046,8 @@ FFLAGS= FOPTIM= FEXTRAFLAGS= +USE_EXTENDED_SRC= +EXTENDED_SRC_FLAG= CFLAGS= KFLAGS1= KFLAGS2= @@ -1646,6 +1648,11 @@ INCLUDES="$INCLUDES $GSLINC" LIBS="$LIBS $GSLLIB" fi +#- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS : +if test ! "x$USE_EXTENDED_SRC" = x ; then + FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG" + F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG" +fi printf "\n=== Checking system libraries ===\n" printf " Do we have the system() command using $FC... " @@ -1768,19 +1775,63 @@ printf "\n=== Setting defaults ===\n" -printf " Adding MODS directories: " +printf " Adding MODS directories: " +MPI_LNKF= for d in $MODS ; do if test ! -d $d ; then echo echo "Error: MODS directory \"$d\" not found!" exit 1 else - printf " $d" + printf "$d " SOURCEDIRS="$SOURCEDIRS $d" INCLUDEDIRS="$INCLUDEDIRS $d" + #------------------------------------------------------- + # Put special links so that MPI specific files are used + MPI_FILES=`(cd $d ; find . -name "*_mpi" -print)` + for i in $MPI_FILES ; do + ii=`echo $i | sed 's:^\./::'` + name=`echo $ii | sed 's:_mpi::' ` + if test "x$MPI" = x ; then + # NO: We undo an _mpi symbolically linked file + if test -L $name ; then + cmp $name "$d/$ii" > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then + printf "Un-linking $name ; " + rm -f $name + fi + fi + else + # YES: We symbolically link this file (with conditions if already there) + if test -L $name ; then + cmp $d/$ii $name > /dev/null 2>&1 + RETVAL=$? + yy=0 ; + for xx in $MPI_LNKF ; do if test $xx = $name ; then yy=1 ; fi ; done + if test "x$RETVAL" != x0 -a $yy = 0 ; then + # remove sym-link if different and has not just been linked + printf "Un-link + " + rm -f $name + fi + if test "x$RETVAL" = x0 ; then + # if identical, keep sym-link and keep record of it + MPI_LNKF="$MPI_LNKF $name" + fi + fi + if ! test -f $name ; then + # make sym-link and keep record of it + printf "Linking $ii to $name ; " + ln -sf $d/$ii $name + MPI_LNKF="$MPI_LNKF $name" + fi + fi + done + #------------------------------------------------------- fi done echo +#echo "MPI_LNKF='$MPI_LNKF'" if test "x${PLATFORM}" = x ; then PLATFORM=$p_PLATFORM @@ -2720,7 +2771,7 @@ #=== Automatic Differentiation Rules === #=== for TAMC/TAF ====================== -if test "x$OPENAD" == x ; then +if test "x$OPENAD" = x ; then cat >>$MAKEFILE < WHIRL # note that the canonicalized version cuts off at col 72 @@ -3022,8 +3073,8 @@ ./whirl2xaif -s -n --debug 1 -o \$@ \$< # XAIF -> XAIF' -ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd openad_adm - ./openad_adm -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r +ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver + ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r # XAIF' -> WHIRL' ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl @@ -3037,8 +3088,9 @@ ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash ../OAD_support/insertTemplateDir.bash \$< \$@ +PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F # postprocess F' -ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 multi-pp.pl ../OAD_support/ad_inline.f \$(wildcard ../OAD_support/ad_template.*.f) +ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 multi-pp.pl \$(PPEXTRAS:.F=.f) perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$< # the postprocessor still gets the name wrong cat \$<.pp | sed 's/RETURN//' > \$@ @@ -3077,8 +3129,8 @@ whirl2f whirl2f_be: \$(LN) \${OPEN64ROOT}/whirl2f/\$@ . -openad_adm: - \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/test/t \$@ +oadDriver: + \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@ # ============ end OpenAD specific section ==============