--- MITgcm/tools/genmake2 2009/02/20 21:08:02 1.184 +++ MITgcm/tools/genmake2 2009/03/27 20:18:07 1.185 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.184 2009/02/20 21:08:02 utke Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.185 2009/03/27 20:18:07 jmc Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -1775,16 +1775,58 @@ 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=$? + xx=`echo $MPI_LNKF | grep -c $name` + if test "x$RETVAL" != x0 -a $xx == 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 -s $d/$ii $name + MPI_LNKF="$MPI_LNKF $name" + fi + fi + done + #------------------------------------------------------- fi done echo