--- MITgcm/tools/genmake2 2006/08/12 03:47:36 1.154 +++ MITgcm/tools/genmake2 2007/07/31 22:27:01 1.164 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.154 2006/08/12 03:47:36 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.164 2007/07/31 22:27:01 ce107 Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -325,7 +325,7 @@ #================================================================ # look for possible C compilers - tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc" + tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc" p_CC= for c in $tmp ; do rm -f ./genmake_hello.c ./genmake_hello @@ -364,7 +364,7 @@ #================================================================ # look for possible FORTRAN compilers - tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran" + tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95" p_FC= for c in $tmp ; do rm -f ./hello.f ./hello @@ -601,6 +601,8 @@ -gsl | --gsl Use GSL to control floating point rounding and precision + -devel | --devel + Add additional warning and debugging flags for development -mpi | --mpi Include MPI header files and link to MPI libraries @@ -754,7 +756,9 @@ print *," HELLO WORLD", wtime end EOF - $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1 + COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o" + echo $COMM >> genmake_warnings + $COMM >> genmake_warnings 2>&1 RET_F=$? test -x ./genmake_tc && ./genmake_tc >> genmake_warnings 2>&1 RETVAL=$? @@ -946,7 +950,7 @@ RET_CPP=f COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES" echo "$COMM" >> genmake_tnc.log - $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t + eval $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t if test "x$RET_CPP" = xf ; then echo " WARNING: CPP failed to pre-process the netcdf test." \ >> genmake_tnc.log @@ -983,6 +987,21 @@ if test "x$RET_COMPILE" = x0 ; then LIBS="$LIBS -lnetcdf" HAVE_NETCDF=t + else + # try again with "-lnetcdff" added to the libs + echo "try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log + echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log + echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log + echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log + cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \ + && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ + && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1 + RET_COMPILE=$? + cat genmake_tnc.log >> genmake_warnings + if test "x$RET_COMPILE" = x0 ; then + LIBS="$LIBS -lnetcdff -lnetcdf" + HAVE_NETCDF=t + fi fi fi rm -f genmake_tnc* @@ -1036,6 +1055,7 @@ PCL= HPMT= GSL= +DEVEL= HAVE_TEST_L= # DEFINES checked by test compilation or command-line @@ -1094,7 +1114,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 MPI JAM DUMPSTATE STANDARDDIRS" +gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI JAM 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 " @@ -1292,6 +1312,9 @@ -gsl | --gsl) GSL=true ;; + -devel | --devel) + DEVEL=true ;; + -mpi | --mpi) MPI=true ;; -mpi=* | --mpi=*) @@ -1340,12 +1363,11 @@ if test -f ./.genmakerc ; then echo echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" - echo " file. This file format is no longer supported. Please see:" - echo + echo " file. This file format is no longer supported. For directions on" + echo " how to setup and use the new \"genmake2\" script, please see:" echo " http://mitgcm.org/devel_HOWTO/" - echo - echo " for directions on how to setup and use the new \"genmake2\" input" - echo " files and send an email to MITgcm-support@mitgcm.org if you want help." + echo " and send an email to MITgcm-support@mitgcm.org if you need help." + echo "WARNING: ignore \"./.genmakerc\" and continue." echo fi @@ -1542,6 +1564,7 @@ else DEFINES="$DEFINES -DTIME_PER_TIMESTEP" fi + PACKAGES="$PACKAGES showflops" fi if test ! "x$PAPIS" = x ; then echo " Turning on PAPI flop summary per timestep" @@ -1553,6 +1576,7 @@ fi INCLUDES="$INCLUDES $PAPIINC" LIBS="$LIBS $PAPILIB" + PACKAGES="$PACKAGES showflops" fi if test ! "x$PCLS" = x ; then echo " Turning on PCL counter summary per timestep" @@ -1564,6 +1588,7 @@ fi INCLUDES="$INCLUDES $PCLINC" LIBS="$LIBS $PCLLIB" + PACKAGES="$PACKAGES showflops" fi if test ! "x$PAPI" = x ; then if test ! "x$PAPIS" = x ; then @@ -1943,8 +1968,8 @@ rm -f ./.tmp_pack echo " packages are: $PACKAGES" -# Check availability of NetCDF and then either build the MNC template -# files or delete mnc from the list of available packages. +# Check for package MNC: if NetCDF is available, then build the MNC +# template files ; otherwise, delete mnc from the list of packages. echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1 RETVAL=$? if test "x$RETVAL" = x0 ; then @@ -1978,13 +2003,38 @@ fi fi +# Check for package PROFILES: if NetCDF is not available, +# then delete profiles from the list of available packages. +echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1 +RETVAL=$? +if test "x$RETVAL" = x0 ; then + if test "x$HAVE_NETCDF" != xt ; then + cat < \$@ clean: - -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template + -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template + -rm -rf *.o + -rm -rf *.$FS Clean: @make clean @make cleanlinks @@ -2538,9 +2592,7 @@ \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ .$FS.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< -.F90.$FS90: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ -.$FS90.o: +.F90.o: \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< .c.o: \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<