/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Diff of /MITgcm/tools/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.89 by edhill, Wed Jul 21 16:34:46 2004 UTC revision 1.134 by edhill, Wed Nov 9 04:31:30 2005 UTC
# Line 122  EOF Line 122  EOF
122        stop        stop
123        end        end
124  EOF  EOF
125      test -f Makefile  &&  mv -f Makefile Makefile.bak      test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
126      cat <<EOF >> Makefile      cat <<EOF >> $MAKEFILE
 %.$tfs : %.F  
127  .SUFFIXES:  .SUFFIXES:
128  genmake_hello.$tfs: genmake_hello.F  .SUFFIXES: .$tfs .F
129          $LN genmake_hello.F genmake_hello.$tfs  .F.$tfs:
130            $LN \$< \$@
131  EOF  EOF
132      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133      RETVAL=$?      RETVAL=$?
# Line 148  EOF Line 148  EOF
148              return              return
149          fi          fi
150      fi      fi
151      rm -f genmake_hello.* Makefile      rm -f genmake_hello.* $MAKEFILE
152      test -f Makefile  &&  mv -f Makefile.bak Makefile      test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
153    
154      #  If we make it here, use the extensions      #  If we make it here, use the extensions
155      FS=$tfs      FS=$tfs
# Line 181  look_for_makedepend()  { Line 181  look_for_makedepend()  {
181      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
182          which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
183          RV0=$?          RV0=$?
184            test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
185            #  echo 'MAKEFILE="'$MAKEFILE'"'
186            cat <<EOF >> $MAKEFILE
187    #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
188    #
189    #   Some "makedepend" implementations will die if they cannot
190    #   find a Makefile -- so this file is here to gives them an
191    #   empty one to find and parse.
192    EOF
193          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
194        program test        program test
195        write(*,*) 'test'        write(*,*) 'test'
# Line 189  look_for_makedepend()  { Line 198  look_for_makedepend()  {
198  EOF  EOF
199          makedepend genmake_tc.f > /dev/null 2>&1          makedepend genmake_tc.f > /dev/null 2>&1
200          RV1=$?          RV1=$?
201            test -f $MAKEFILE  &&  rm -f $MAKEFILE
202            test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
203          if test "x${RV0}${RV1}" = x00 ; then          if test "x${RV0}${RV1}" = x00 ; then
204              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
205          else          else
206              echo "    a system-default makedepend was not found."              echo "    a system-default makedepend was not found."
207                            
208              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
209              rm -f ./genmake_cy_md              build_cyrus_makedepend
             (  
                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \  
                     &&  ./configure > /dev/null 2>&1  \  
                     &&  make > /dev/null 2>&1  
                 if test -x ./makedepend.exe ; then  
                     $LN ./makedepend.exe ./makedepend  
                 fi  
                 ./makedepend ifparser.c > /dev/null 2>&1  \  
                     &&  echo "true"  
             ) > ./genmake_cy_md  
             grep true ./genmake_cy_md > /dev/null 2>&1  
210              RETVAL=$?              RETVAL=$?
211              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" != x0 ; then
                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'  
             else  
212                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
213              fi              fi
214              rm -f ./genmake_cy_md              rm -f ./genmake_cy_md
215          fi          fi
216        else
217            #  echo "MAKEDEPEND=${MAKEDEPEND}"
218            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
219            RETVAL=$?
220            if test x"$RETVAL" = x0 ; then
221                build_cyrus_makedepend
222            fi
223      fi      fi
224  }  }
225    
226    
227    build_cyrus_makedepend()  {
228        rm -f ./genmake_cy_md
229        (
230            cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
231                &&  ./configure > /dev/null 2>&1  \
232                &&  make > /dev/null 2>&1
233            if test -x ./makedepend.exe ; then
234                $LN ./makedepend.exe ./makedepend
235            fi
236            ./makedepend ifparser.c > /dev/null 2>&1  \
237                &&  echo "true"
238        ) > ./genmake_cy_md
239        grep true ./genmake_cy_md > /dev/null 2>&1
240        RETVAL=$?
241        rm -f ./genmake_cy_md
242        if test "x$RETVAL" = x0 ; then
243            MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
244            return 0
245        else
246            echo "WARNING: unable to build cyrus-imapd-makedepend"
247            return 1
248        fi
249    }
250    
251  # Guess possible config options for this host  # Guess possible config options for this host
252  find_possible_configs()  {  find_possible_configs()  {
253    
# Line 251  find_possible_configs()  { Line 280  find_possible_configs()  {
280    
281      look_for_makedepend      look_for_makedepend
282    
283      # look for possible fortran compilers      #================================================================
284      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      #  look for possible C compilers
285        tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286        p_CC=
287        for c in $tmp ; do
288            rm -f ./genmake_hello.c  ./genmake_hello
289            cat >> genmake_hello.c << EOF
290    #include <stdio.h>
291    int main(int argc, char **argv) {
292      printf("Hello!\n");
293      return 0;
294    }
295    EOF
296            $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297            RETVAL=$?
298            if test "x${RETVAL}" = x0 ; then
299                p_CC="$p_CC $c"
300            fi
301        done
302        rm -f ./genmake_hello.c ./genmake_hello
303        if test "x${p_CC}" = x ; then
304            cat 1>&2 <<EOF
305    
306    Error: No C compilers were found in your path.  Please specify one using:
307    
308        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309        2) the CC or MITGCM_CC environment variables.
310    
311    EOF
312            exit 1
313        else
314            echo "  The possible C compilers found in your path are:"
315            echo "   "$p_CC
316            if test "x$CC" = x ; then
317                CC=`echo $p_CC | $AWK '{print $1}'`
318                echo "  Setting C compiler to: "$CC
319            fi
320        fi
321    
322        #================================================================
323        #  look for possible FORTRAN compilers
324        tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"
325      p_FC=      p_FC=
326      for c in $tmp ; do      for c in $tmp ; do
327          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 277  Error: No Fortran compilers were found i Line 346  Error: No Fortran compilers were found i
346    
347      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
348      2) a command-line option (eg. "-fc NAME"), or      2) a command-line option (eg. "-fc NAME"), or
349      3) the MITGCM_FC environment variable.      3) the FC or MITGCM_FC environment variables.
350    
351  EOF  EOF
352          exit 1          exit 1
# Line 448  Usage: "$0" [OPTIONS] Line 517  Usage: "$0" [OPTIONS]
517            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
518            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
519    
520        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
521              Use "NAME" as the C compiler.  By default, genmake
522              will search for a working compiler by trying a list of
523              "usual suspects" such as gcc, c89, cc, etc.
524    
525      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
526            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
527            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
528            is being used.            is being used.
529    
530        -ts | --ts
531              Produce timing information per timestep
532    
533      -mpi | --mpi      -mpi | --mpi
534            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
535      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
536            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
537            set to PATH. i.e. Include files from $PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
538            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
539    
540      -bash NAME      -bash NAME
541            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 506  WARNING: Please contact <MITgcm-support@ Line 583  WARNING: Please contact <MITgcm-support@
583  EOF  EOF
584          return 1          return 1
585      fi      fi
586      c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
587      RETVAL=$?      RETVAL=$?
588      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
589          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 518  WARNING: Please contact <MITgcm-support@ Line 595  WARNING: Please contact <MITgcm-support@
595  EOF  EOF
596          return 1          return 1
597      fi      fi
598      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
599        subroutine tcall( string )        subroutine tcall( string )
600        character*(*) string        character*(*) string
601        call tsub( string )        call tsub( string )
602        end        end
603  EOF  EOF
604      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
605      RETVAL=$?      RETVAL=$?
606      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
607          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 536  WARNING: Please contact <MITgcm-support@ Line 613  WARNING: Please contact <MITgcm-support@
613  EOF  EOF
614          return 1          return 1
615      fi      fi
616      f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
617      RETVAL=$?      RETVAL=$?
618      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
619          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 590  void FC_NAMEMANGLE(cloc) ( double *curti Line 667  void FC_NAMEMANGLE(cloc) ( double *curti
667   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
668  }  }
669  EOF  EOF
670      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
671      RET_C=$?      RET_C=$?
672      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
673        program hello        program hello
674        Real*8 wtime        REAL*8 wtime
675        external cloc        external cloc
676        call cloc(wtime)        call cloc(wtime)
677        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
678        end program hello        end
679  EOF  EOF
680      $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
681      RET_F=$?      RET_F=$?
682      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
683      RETVAL=$?      RETVAL=$?
684      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
685          HAVE_CLOC=t          HAVE_CLOC=t
# Line 612  EOF Line 689  EOF
689  }  }
690    
691    
692    check_HAVE_SETRLSTK()  {
693        get_fortran_c_namemangling
694        cat <<EOF > genmake_tc_1.c
695    $FC_NAMEMANGLE
696    #include <sys/time.h>
697    #include <sys/resource.h>
698    #include <unistd.h>
699    void FC_NAMEMANGLE(setrlstk) ()
700    {
701        struct rlimit rls;
702        rls.rlim_cur = RLIM_INFINITY;
703        rls.rlim_max = RLIM_INFINITY;
704        setrlimit(RLIMIT_STACK, &rls);
705        return;
706    }
707    EOF
708        make genmake_tc_1.o >> genmake_warnings 2>&1
709        RET_C=$?
710        cat <<EOF > genmake_tc_2.$FS
711          program hello
712          external setrlstk
713          call setrlstk()
714          end
715    EOF
716        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
717        RET_F=$?
718        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
719        RETVAL=$?
720        if test "x$RETVAL" = x0 ; then
721            HAVE_SETRLSTK=t
722            DEFINES="$DEFINES -DHAVE_SETRLSTK"
723        fi
724        rm -f genmake_tc*
725    }
726    
727    
728    check_HAVE_STAT()  {
729        get_fortran_c_namemangling
730        cat <<EOF > genmake_tc_1.c
731    $FC_NAMEMANGLE
732    #include <stdio.h>
733    #include <stdlib.h>
734    #include <unistd.h>
735    #include <sys/stat.h>
736    #include <sys/types.h>
737    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
738    {
739        char name[512];
740        struct stat astat;
741    
742        name[0] = 'a'; name[1] = '\0';
743        if (! stat(name, &astat))
744            *nbyte = (int)(astat.st_size);
745        else
746            *nbyte = -1;
747    }
748    EOF
749        make genmake_tc_1.o >> genmake_tc.log 2>&1
750        RET_C=$?
751        cat <<EOF > genmake_tc_2.$FS
752          program hello
753          integer nbyte
754          call tfsize(nbyte)
755          print *," HELLO WORLD", nbyte
756          end
757    EOF
758        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
759        RET_F=$?
760        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
761        RETVAL=$?
762        if test "x$RETVAL" = x0 ; then
763            HAVE_STAT=t
764            DEFINES="$DEFINES -DHAVE_STAT"
765        fi
766        rm -f genmake_tc*
767    }
768    
769    
770  check_netcdf_libs()  {  check_netcdf_libs()  {
771      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
772            return
773        fi
774        echo "" > genmake_tnc.log
775        cat <<EOF > genmake_tnc.F
776        program fgennc        program fgennc
777  #include "netcdf.inc"  #include "netcdf.inc"
778    EOF
779        if test ! "x$MPI" = x ; then
780            echo '#include "mpif.h"' >> genmake_tnc.F
781        fi
782        cat <<EOF >> genmake_tnc.F
783        integer iret, ncid, xid        integer iret, ncid, xid
784        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
785        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 625  check_netcdf_libs()  { Line 789  check_netcdf_libs()  {
789        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
790        end        end
791  EOF  EOF
792      #echo "$CPP $DEFINES $INCLUDES"      echo "Executing:" > genmake_tnc.log
793      $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f  \      echo "  $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \
794          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1          >> genmake_tnc.log
795        RET_CPP=f
796        $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
797            &&  RET_CPP=t
798        if test "x$RET_CPP" = xf ; then
799            echo "  WARNING: CPP failed to pre-process the netcdf test." \
800                >> genmake_tnc.log
801            echo "    Please check that \$INCLUDES is properly set." \
802                >> genmake_tnc.log
803        fi
804        echo "Executing:" > genmake_tnc.log
805        echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" >> genmake_tnc.log
806        echo "  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
807        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
808            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
809      RET_COMPILE=$?      RET_COMPILE=$?
810      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1  
811      RETVAL=$?      #EH3  Remove test program execution for machines that either disallow
812      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  execution or cannot support it (eg. cross-compilers)
813        #EH3
814        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
815        #EH3 RETVAL=$?
816        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
817    
818        if test "x$RET_COMPILE" = x0 ; then
819          HAVE_NETCDF=t          HAVE_NETCDF=t
820      else      else
821          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
822          $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f  \          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
823              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
824              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1          echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
825            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
826                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
827                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
828          RET_COMPILE=$?          RET_COMPILE=$?
829          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          if test "x$RET_COMPILE" = x0 ; then
         RETVAL=$?  
         if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then  
830              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
831              HAVE_NETCDF=t              HAVE_NETCDF=t
832          else          else
833                echo "===  genmake_tnc.F  ===" >> genmake_warnings
834                cat genmake_tnc.F >> genmake_warnings
835                echo "===  genmake_tnc.F  ===" >> genmake_warnings
836              cat genmake_tnc.log >> genmake_warnings              cat genmake_tnc.log >> genmake_warnings
837          fi          fi
838      fi      fi
# Line 664  PLATFORM= Line 852  PLATFORM=
852  LN=  LN=
853  S64=  S64=
854  KPP=  KPP=
855  FC=  #FC=
856  CPP=  #CC=gcc
857    #CPP=
858  LINK=  LINK=
859  DEFINES=  DEFINES=
860  PACKAGES=  PACKAGES=
861  ENABLE=  ENABLE=
862  DISABLE=  DISABLE=
863  MAKEFILE=  # MAKEFILE=
864  MAKEDEPEND=  # MAKEDEPEND=
865  PDEPEND=  PDEPEND=
866  DUMPSTATE=t  DUMPSTATE=t
867  PDEFAULT=  PDEFAULT=
868  OPTFILE=  OPTFILE=
869  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
870  FFLAGS=  FFLAGS=
871  FOPTIM=  FOPTIM=
872  CFLAGS=  CFLAGS=
# Line 690  NOOPTFILES= Line 879  NOOPTFILES=
879  NOOPTFLAGS=  NOOPTFLAGS=
880  MPI=  MPI=
881  MPIPATH=  MPIPATH=
882    TS=
883    HAVE_TEST_L=
884    
885  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
886  HAVE_SYSTEM=  HAVE_SYSTEM=
887  HAVE_FDATE=  HAVE_FDATE=
888  FC_NAMEMANGLE=  FC_NAMEMANGLE=
889  HAVE_CLOC=  HAVE_CLOC=
890    HAVE_SETRLSTK=
891    HAVE_STAT=
892  HAVE_NETCDF=  HAVE_NETCDF=
893  HAVE_ETIME=  HAVE_ETIME=
894    IGNORE_TIME=
895    
896  MODS=  MODS=
897  TOOLSDIR=  TOOLSDIR=
# Line 708  STANDARDDIRS="USE_THE_DEFAULT" Line 902  STANDARDDIRS="USE_THE_DEFAULT"
902  G2ARGS=  G2ARGS=
903  BASH=  BASH=
904  PWD=`pwd`  PWD=`pwd`
905  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
906  AWK=awk  test "x$AWK" = x   &&  AWK=awk
907  THISHOSTNAME=`hostname`  THISHOST=`hostname`
908  THISCWD=`pwd`  THISCWD=`pwd`
909  THISDATE=`date`  THISDATE=`date`
910    THISUSER=`echo $USER`
911    THISVER=
912  MACHINE=`uname -a`  MACHINE=`uname -a`
913  EXECUTABLE=  EXECUTABLE=
914  EXEHOOK=  EXEHOOK=
# Line 741  TAMC_EXTRA= Line 937  TAMC_EXTRA=
937    
938  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
939  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
940  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
941    
942  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
943  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
944  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
945  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
946  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
947  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
948    
# Line 787  else Line 983  else
983      echo "none found"      echo "none found"
984  fi  fi
985    
986  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
987  #OPTIONS=  #OPTIONS=
988  #n=0  #n=0
989  #for i ; do  #for i ; do
# Line 799  fi Line 995  fi
995  #done  #done
996  #parse_options  #parse_options
997  ac_prev=  ac_prev=
998  for ac_option in $@ ; do  for ac_option in "$@" ; do
999    
1000      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
1001    
# Line 895  for ac_option in $@ ; do Line 1091  for ac_option in $@ ; do
1091  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1092  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1093  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1094                        
1095            -cc | --cc)
1096                ac_prev=CC ;;
1097            -cc=* | --cc=*)
1098                CC=$ac_optarg ;;
1099            
1100          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1101              ac_prev=FC ;;              ac_prev=FC ;;
1102          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 916  for ac_option in $@ ; do Line 1117  for ac_option in $@ ; do
1117          -noieee | --noieee)          -noieee | --noieee)
1118              IEEE= ;;              IEEE= ;;
1119    
1120            -ts | --ts)
1121                TS=true ;;
1122    
1123          -mpi | --mpi)          -mpi | --mpi)
1124              MPI=true ;;              MPI=true ;;
1125          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 939  for ac_option in $@ ; do Line 1143  for ac_option in $@ ; do
1143              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1144          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1145              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1146            
1147            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1148                IGNORE_TIME="-DIGNORE_TIME" ;;
1149    
1150          -*)          -*)
1151              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 954  for ac_option in $@ ; do Line 1161  for ac_option in $@ ; do
1161            
1162  done  done
1163    
1164    
1165  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1166      echo      echo
1167      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
# Line 966  if test -f ./.genmakerc ; then Line 1174  if test -f ./.genmakerc ; then
1174      echo      echo
1175  fi  fi
1176    
1177    #  Find the MITgcm ${ROOTDIR}
1178  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1179      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1180      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1181          ROOTDIR=".."          ROOTDIR=".."
1182      else      else
# Line 992  if test ! -d ${ROOTDIR} ; then Line 1201  if test ! -d ${ROOTDIR} ; then
1201      exit 1      exit 1
1202  fi  fi
1203    
1204    #  Find the MITgcm ${THISVER}
1205    if test -f "${ROOTDIR}/doc/tag-index" ; then
1206        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1207    fi
1208    
1209    if test "x$MAKEFILE" = x ; then
1210        MAKEFILE="Makefile"
1211    fi
1212    
1213  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1214  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1215      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 1021  if test "x$OPTFILE" != xNONE ; then Line 1239  if test "x$OPTFILE" != xNONE ; then
1239      fi      fi
1240  fi  fi
1241    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1242  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1243  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1244      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1051  if test "x${AD_OPTFILE}" != xNONE ; then Line 1266  if test "x${AD_OPTFILE}" != xNONE ; then
1266      fi      fi
1267  fi  fi
1268    
1269  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1270    #  Set default values if not set by the optfile
1271    #
1272    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1273  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1274  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1275      # add a trailing space so that it works within the Makefile syntax (see below)      # add a trailing space so that it works within the Makefile syntax (see below)
# Line 1067  Error: no Fortran compiler: please speci Line 1285  Error: no Fortran compiler: please speci
1285  EOF  EOF
1286      exit 1      exit 1
1287  fi  fi
1288    if test "x$CC" = x ; then
1289        CC=cc
1290    #     cat <<EOF 1>&2
1291    # Error: no C compiler: please specify using one of the following:
1292    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1293    #   2) the "-cc=XXX" command-line option
1294    #   3) the "./genmake_local" file
1295    # EOF
1296    #     exit 1
1297    fi
1298  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1299      LINK=$FC      LINK=$FC
1300  fi  fi
# Line 1117  Error: The command "ln -s" failed -- ple Line 1345  Error: The command "ln -s" failed -- ple
1345  EOF  EOF
1346      exit 1      exit 1
1347  fi  fi
1348    test -L genmake_tlink > /dev/null 2>&1
1349    RETVAL=$?
1350    if test "x$RETVAL" = x0 ; then
1351        HAVE_TEST_L=t
1352    fi
1353  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1354    
1355  #  Check for broken *.F/*.f handling and fix if possible  #  Check for broken *.F/*.f handling and fix if possible
# Line 1127  if test ! "x$MPI" = x ; then Line 1360  if test ! "x$MPI" = x ; then
1360        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1361  fi  fi
1362    
1363    if test ! "x$TS" = x ; then
1364          echo "  Turning on timing per timestep"
1365          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1366    fi
1367    
1368  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1369  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1370  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1371        program hello        program hello
1372        call system('echo hi')        call system('echo hi')
1373        end        end
1374  EOF  EOF
1375  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1376  RETVAL=$?  RETVAL=$?
1377  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1378      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1147  fi Line 1385  fi
1385  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1386    
1387  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1388  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1389        program hello        program hello
1390        CHARACTER(128) string        CHARACTER*(128) string
1391        string = ' '        string = ' '
1392        call fdate( string )        call fdate( string )
1393        print *, string        print *, string
1394        end        end
1395  EOF  EOF
1396  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1397  RETVAL=$?  RETVAL=$?
1398  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1399      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1168  fi Line 1406  fi
1406  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1407    
1408  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1409  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1410        program hello        program hello
1411        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1412        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1177  cat > genmake_tcomp.f <<EOF Line 1415  cat > genmake_tcomp.f <<EOF
1415        print *, tarray        print *, tarray
1416        end        end
1417  EOF  EOF
1418  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1419  RETVAL=$?  RETVAL=$?
1420  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1421      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1198  else Line 1436  else
1436  fi  fi
1437  rm -f genmake_t*  rm -f genmake_t*
1438    
1439    printf "  Can we unlimit the stack size using $FC...  "
1440    check_HAVE_SETRLSTK
1441    if test "x$HAVE_SETRLSTK" != x ; then
1442        echo "yes"
1443    else
1444        echo "no"
1445    fi
1446    rm -f genmake_t*
1447    
1448    printf "  Can we use stat() through C calls...  "
1449    check_HAVE_STAT
1450    if test "x$HAVE_STAT" != x ; then
1451        echo "yes"
1452    else
1453        echo "no"
1454    fi
1455    rm -f genmake_t*
1456    
1457  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1458  check_netcdf_libs  check_netcdf_libs
1459  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1205  if test "x$HAVE_NETCDF" != x ; then Line 1461  if test "x$HAVE_NETCDF" != x ; then
1461  else  else
1462      echo "no"      echo "no"
1463  fi  fi
1464    DEFINES="$DEFINES $IGNORE_TIME"
1465    
1466  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1467  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1222  for d in $MODS ; do Line 1478  for d in $MODS ; do
1478  done  done
1479  echo  echo
1480    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1481  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1482      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1483  fi  fi
1484    
1485  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1486      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1487      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1488          EXEDIR=../exe          EXEDIR=../exe
1489      else      else
# Line 1250  if test ! -d ${TOOLSDIR} ; then Line 1503  if test ! -d ${TOOLSDIR} ; then
1503      exit 1      exit 1
1504  fi  fi
1505  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1506      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1507        RETVAL=$?
1508        if test "x${RETVAL}" = x0 ; then
1509            S64='$(TOOLSDIR)/set64bitConst.sh'
1510        else
1511            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1512            RETVAL=$?
1513            if test "x${RETVAL}" = x0 ; then
1514                S64='$(TOOLSDIR)/set64bitConst.csh'
1515            else
1516                cat <<EOF
1517    
1518    ERROR: neither of the two default scripts:
1519    
1520        ${TOOLSDIR}/set64bitConst.sh
1521        ${TOOLSDIR}/set64bitConst.csh
1522    
1523      are working so please check paths or specify (with \$S64) a
1524      working version of this script.
1525    
1526    EOF
1527                exit 1
1528            fi
1529        fi
1530  fi  fi
1531  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1532    
# Line 1395  done Line 1671  done
1671  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1672  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1673    
1674    #  Check availability of NetCDF and then either build the MNC template
1675    #  files or delete mnc from the list of available packages.
1676    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1677    RETVAL=$?
1678    if test "x$RETVAL" = x0 ; then
1679        if test "x$HAVE_NETCDF" != xt ; then
1680            cat <<EOF
1681    
1682    *********************************************************************
1683    WARNING: the "mnc" package was enabled but tests failed to compile
1684      NetCDF applications.  Please check that:
1685    
1686      1) NetCDF is correctly installed for this compiler and
1687      2) the LIBS variable (within the "optfile") specifies the correct
1688           NetCDF library to link against.
1689    
1690      Due to this failure, the "mnc" package is now DISABLED.
1691    *********************************************************************
1692    
1693    EOF
1694            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1695            DISABLE="$DISABLE mnc"
1696        else
1697            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1698            RETVAL=$?
1699            if test "x${RETVAL}" = x0 ; then
1700                rm -f make_mnc.errors
1701            else
1702                echo "Error: problem encountered while building source files in pkg/mnc:"
1703                cat make_mnc.errors 1>&2
1704                exit 1
1705            fi
1706        fi
1707    fi
1708    
1709  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1710  ck=  ck=
1711  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1479  for i in $PACKAGES ; do Line 1790  for i in $PACKAGES ; do
1790      fi      fi
1791  done  done
1792    
 #  Build MNC templates and check for ability to build and use NetCDF  
 echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  
 RETVAL=$?  
 if test "x$RETVAL" = x0 ; then  
     ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         rm -f make_mnc.errors  
     else  
         echo "Error: problem encountered while building source files in pkg/mnc:"  
         cat make_mnc.errors 1>&2  
         exit 1  
     fi  
     if test "x$HAVE_NETCDF" != xt ; then  
         cat <<EOF  
   
 WARNING: the "mnc" package has been enabled but tests failed to  
   compile and/or execute NetCDF applications.  Please check that:  
   
   1) NetCDF is installed for your compiler and  
   2) the LIBS variable (within the 'optfile") specifies the correct  
        NetCDF library to link against.  
     
 EOF  
     fi  
 fi  
   
1793  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1794  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1795  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
# Line 1525  for n in $names ; do Line 1809  for n in $names ; do
1809              fi              fi
1810          done          done
1811          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1812              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1813              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1814          fi          fi
1815      fi      fi
1816  done  done
1817  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1818  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1819      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1820      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1821  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1822    
# Line 1616  for i in $SOURCEDIRS ; do Line 1900  for i in $SOURCEDIRS ; do
1900          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1901      done      done
1902  done  done
1903    if test ! "x"$FS = "x.f" ; then
1904        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1905        mv -f ad_files_f ad_files
1906    fi
1907    
1908  echo  echo
1909  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
# Line 1645  for d in $alldirs ; do Line 1932  for d in $alldirs ; do
1932      for sf in $sfiles ; do      for sf in $sfiles ; do
1933          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1934              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1935                    ignore_f=f
1936                  case $d/$sf in                  case $d/$sf in
1937                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
1938                          ;;                          ;;
# Line 1652  for d in $alldirs ; do Line 1940  for d in $alldirs ; do
1940                          ;;                          ;;
1941                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1942                          ;;                          ;;
1943                      ./BUILD_INFO.h)
1944                            ;;
1945                    *)                    *)
1946                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
1947                          deplist="$deplist $sf"                          #  ignore all soft-links
1948                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
1949                                ignore_f=t
1950                            else
1951                                touch .links.tmp/$sf
1952                                deplist="$deplist $sf"
1953                            fi
1954                          ;;                          ;;
1955                  esac                  esac
1956                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
1957                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
1958                      F)                      case $extn in
1959                          echo    " \\"  >> srclist.inc                          F)
1960                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
1961                          ;;                              printf " $sf" >> srclist.inc
1962                      F90)                              ;;
1963                          echo    " \\"  >> f90srclist.inc                          F90)
1964                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
1965                          ;;                              printf " $sf" >> f90srclist.inc
1966                      c)                              ;;
1967                          echo    " \\"  >> csrclist.inc                          c)
1968                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
1969                          ;;                              printf " $sf" >> csrclist.inc
1970                      h)                              ;;
1971                          echo    " \\"  >> hlist.inc                          h)
1972                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
1973                          ;;                              printf " $sf" >> hlist.inc
1974                      flow)                              ;;
1975                          echo    " \\"  >> ad_flow_files.inc                          flow)
1976                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
1977                          ;;                              printf " $sf" >> ad_flow_files.inc
1978                  esac                              ;;
1979                        esac
1980                    fi
1981              fi              fi
1982          fi          fi
1983      done      done
# Line 1708  echo "#    $THISDATE" >> $MAKEFILE Line 2006  echo "#    $THISDATE" >> $MAKEFILE
2006  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2007  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2008  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2009  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2010    
2011  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2012  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1754  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2052  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2052  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2053    
2054  # These files are created by Makefile  # These files are created by Makefile
2055  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2056    
2057  EOF  EOF
2058    
# Line 1773  KPP = ${KPP} Line 2071  KPP = ${KPP}
2071  FC = ${FC}  FC = ${FC}
2072  # Fortran compiler  # Fortran compiler
2073  F90C = ${F90C}  F90C = ${F90C}
2074    # C compiler
2075    CC = ${CC}
2076  # Link editor  # Link editor
2077  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2078    
# Line 1795  CFLAGS = ${CFLAGS} Line 2095  CFLAGS = ${CFLAGS}
2095  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2096  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2097  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2098  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2099  # Name of the Mekfile  # Name of the Mekfile
2100  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2101    
# Line 1808  cat hlist.inc         >> $MAKEFILE Line 2108  cat hlist.inc         >> $MAKEFILE
2108  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2109  echo >> $MAKEFILE  echo >> $MAKEFILE
2110  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2111  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2112  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2113  echo >> $MAKEFILE  echo >> $MAKEFILE
2114  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
# Line 1828  depend: Line 2128  depend:
2128          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2129          -rm -f makedepend.out          -rm -f makedepend.out
2130    
2131    lib: libmitgcmuv.a
2132    
2133    libmitgcmuv.a: \$(OBJFILES)
2134            ar rcv libmitgcmuv.a \$(OBJFILES)
2135    
2136  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2137    
2138  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 1856  makefile: Line 2161  makefile:
2161  cleanlinks:  cleanlinks:
2162          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2163    
2164  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2165  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2166          @echo Creating \$@ ...          @echo Creating \$@ ...
2167          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
# Line 1867  FC_NAMEMANGLE.h: Line 2172  FC_NAMEMANGLE.h:
2172          @echo Creating \$@ ...          @echo Creating \$@ ...
2173          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2174    
2175    BUILD_INFO.h:
2176            @echo Creating \$@ ...
2177    EOF
2178    
2179    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2180    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2181    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2182    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2183    
2184    cat >>$MAKEFILE <<EOF
2185    
2186  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2187    
2188  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2189    ## %.o : %.F
2190    
2191  .F.$FS:  .F.$FS:
2192          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1925  cat >>$MAKEFILE <<EOF Line 2242  cat >>$MAKEFILE <<EOF
2242    
2243  # ... AD ...  # ... AD ...
2244  adall: ad_taf  adall: ad_taf
2245  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2246  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2247    
2248  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2249          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2250          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2251          -rm -f ad_config.template          -rm -f ad_config.template
2252          @make \$(F77FILES)          @make \$(F77FILES)
2253          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2254          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2255    
2256  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2257          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2258          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2259    
2260  adtafonly:  adtafonly:
2261          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2262          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2263    
2264  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2265          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2266    
2267  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2268          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2269          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2270    
2271  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2272          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2273    
2274    adonlyfwd:
2275            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2276    
2277    adtrick:
2278            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2279    
2280  # ... FTL ...  # ... FTL ...
2281  ftlall: ftl_taf  ftlall: ftl_taf
2282  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2283  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2284    
2285  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2286          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2287          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2288          -rm -f ftl_config.template          -rm -f ftl_config.template
2289          @make \$(F77FILES)          @make \$(F77FILES)
2290          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2291          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2292    
2293  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2294          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2295          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2296    
2297  ftltafonly:  ftltafonly:
2298          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2299          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2300    
2301  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2302          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2303    
2304  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2305          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2306          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2307    
2308  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2309          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2310    
2311    
2312  # ... SVD ...  # ... SVD ...
2313  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2314  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2315            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2316    svdall: svd_touch svd_taf
2317    
2318  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2319          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
2320    
2321            @echo "--->>> Only COMPILE svd code! <<<---"
2322            @echo "--->>> Assumes you previously <<<---"
2323            @echo "--->>> did make svdtaf        <<<---"
2324    
2325    svd_touch:
2326            @echo "--->>> Only COMPILE svd code! <<<---"
2327            @echo "--->>> Assumes you previously <<<---"
2328            @echo "--->>> did make svdtaf        <<<---"
2329            touch ad_taf_output.$FS ftl_taf_output.$FS
2330            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2331            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2332            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2333            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2334            -rm -f ftl_config.template
2335    
2336  #=========================================  #=========================================
2337    

Legend:
Removed from v.1.89  
changed lines
  Added in v.1.134

  ViewVC Help
Powered by ViewVC 1.1.22