--- MITgcm/tools/genmake2 2008/12/11 17:50:56 1.180 +++ MITgcm/tools/genmake2 2009/04/22 18:35:00 1.190 @@ -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.190 2009/04/22 18:35:00 utke 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 @@ -1046,6 +1051,8 @@ FFLAGS= FOPTIM= FEXTRAFLAGS= +USE_EXTENDED_SRC= +EXTENDED_SRC_FLAG= CFLAGS= KFLAGS1= KFLAGS2= @@ -1056,6 +1063,8 @@ NOOPTFLAGS= MPI= MPIPATH= +OMP= +OMPFLAG= TS= PAPIS= PCLS= @@ -1123,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" @@ -1324,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 ;; @@ -1565,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" @@ -1646,6 +1662,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 +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 @@ -2521,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 @@ -3005,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 @@ -3022,8 +3086,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,11 +3101,10 @@ 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) - perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$< - # the postprocessor still gets the name wrong - cat \$<.pp | sed 's/RETURN//' > \$@ +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 postProcess.py \$(PPEXTRAS:.F=.f) + ./postProcess.py -m r -i ../OAD_support/ad_inline.f -o \$@ \$< # extract all transformed modules all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90 @@ -3068,17 +3131,14 @@ whirl2xaif xaif2whirl: \$(LN) \${OPENADFORTTK}/bin/\$@ . -%.pl: - \$(LN) \${OPENADFORTTK}/bin/\$@ . - -preProcess.py: +preProcess.py postProcess.py: \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ . 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 ==============