--- MITgcm/tools/genmake2 2009/01/02 20:32:21 1.181 +++ MITgcm/tools/genmake2 2009/04/21 22:35:41 1.189 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.181 2009/01/02 20:32:21 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.189 2009/04/21 22:35:41 jmc Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -611,6 +611,11 @@ set to PATH. i.e. Include files from \$PATH/include, link to libraries from \$PATH/lib and use binaries from \$PATH/bin. + -omp | --omp + Activate OpenMP code + use Compiler option OMPFLAG + -omp=OMPFLAG | --omp=OMPFLAG + Activate OpenMP code + use Compiler option OMPFLAG + -es | --es | -embed-source | --embed-source Embed a tarball containing the full source code (including the Makefile, etc.) used to build the @@ -1058,6 +1063,8 @@ NOOPTFLAGS= MPI= MPIPATH= +OMP= +OMPFLAG= TS= PAPIS= PCLS= @@ -1125,7 +1132,7 @@ # The following state can be set directly by command-line switches gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" -gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI JAM DUMPSTATE STANDARDDIRS" +gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS" # The following state is not directly set by command-line switches gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS" @@ -1326,10 +1333,11 @@ MPIPATH=$ac_optarg MPI=true ;; -# -jam | --jam) -# JAM=1 ;; -# -nojam | --nojam) -# JAM=0 ;; + -omp | --omp) + OMP=true ;; + -omp=* | --omp=*) + OMPFLAG=$ac_optarg + OMP=true ;; -ds | --ds) DUMPSTATE=t ;; @@ -1567,6 +1575,12 @@ echo " Turning on MPI cpp macros" DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI" fi +if test ! "x$OMP" = x ; then + echo " Add OMPFLAG and turn on OpenMP cpp macros" + FFLAGS="$FFLAGS $OMPFLAG" + F90FLAGS="$F90FLAGS $OMPFLAG" + DEFINES="$DEFINES -DUSE_OMP_THREADING" +fi if test ! "x$TS" = x ; then echo " Turning on timing per timestep" @@ -1775,19 +1789,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 @@ -2528,7 +2586,6 @@ echo "EMBEDDED_FILES = " >>$MAKEFILE fi -# Note: figure out some way to add Hyades JAM libraries here cat >>$MAKEFILE <>$MAKEFILE < ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h -rm -f ad_config.template @@ -3012,7 +3069,7 @@ # canonicalizer ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py - ./preProcess.py --mode=reverse \$< -o \$@ + ./preProcess.py -H -S \$< -o \$@ # F -> WHIRL # note that the canonicalized version cuts off at col 72 @@ -3029,23 +3086,24 @@ ./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 - ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.pre.B \$< + ./xaif2whirl --debug 1 -t OpenADTy_active --structured ad_input_code_sf.w2f.pre.B \$< # WHIRL' -> F' ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be - ./whirl2f -FLIST:ftn_file=\$@ -openad \$< + ./whirl2f -FLIST:ftn_file=\$@ -openad -openadType OpenADTy_active \$< # insert template directives 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//' > \$@ @@ -3084,8 +3142,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 ==============