/[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.83 by adcroft, Tue Jul 6 18:06:49 2004 UTC revision 1.119 by edhill, Wed Mar 9 19:57:00 2005 UTC
# Line 1  Line 1 
1  #! /usr/bin/env sh  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4  #  #
# Line 122  EOF Line 122  EOF
122        stop        stop
123        end        end
124  EOF  EOF
125      test -e 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=$?
134      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
135          if test "x$FS" = x ; then          if test "x$FS" = x ; then
136              FS='for'              FS='for'
137              FS90='fr9'              FS90='fr9'
# 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 -e 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 158  EOF Line 158  EOF
158  }  }
159    
160    
161    look_for_makedepend()  {
162    
163        #  The "original" makedepend is part of the Imake system that is
164        #  most often distributed with XFree86 or with an XFree86 source
165        #  package.  As a result, many machines (eg. generic Linux) do not
166        #  have a system-default "makedepend" available.  For those
167        #  systems, we have two fall-back options:
168        #
169        #    1) a makedepend implementation shipped with the cyrus-imapd
170        #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
171        #
172        #    2) a known-buggy xmakedpend shell script
173        #
174        #  So the choices are, in order:
175        #
176        #    1) use the user-specified program
177        #    2) use a system-wide default
178        #    3) locally build and use the cyrus implementation
179        #    4) fall back to the buggy local xmakedpend script
180        #
181        if test "x${MAKEDEPEND}" = x ; then
182            which makedepend > /dev/null 2>&1
183            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
194          program test
195          write(*,*) 'test'
196          stop
197          end
198    EOF
199            makedepend genmake_tc.f > /dev/null 2>&1
200            test -f $MAKEFILE  &&  rm -f $MAKEFILE
201            test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
202            RV1=$?
203            if test "x${RV0}${RV1}" = x00 ; then
204                MAKEDEPEND=makedepend
205            else
206                echo "    a system-default makedepend was not found."
207                
208                #  Try to build the cyrus implementation
209                build_cyrus_makedepend
210                RETVAL=$?
211                if test "x$RETVAL" != x0 ; then
212                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
213                fi
214                rm -f ./genmake_cy_md
215            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
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 188  find_possible_configs()  { Line 278  find_possible_configs()  {
278          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
279      fi      fi
280    
281      #  The "original" makedepend is part of the Imake system that is      look_for_makedepend
282      #  most often distributed with XFree86 or with an XFree86 source  
283      #  package.  As a result, many machines (eg. generic Linux) do not      #================================================================
284      #  have a system-default "makedepend" available.  For those      #  look for possible C compilers
285      #  systems, we have two fall-back options:      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286      #      p_CC=
287      #    1) a makedepend implementation shipped with the cyrus-imapd      for c in $tmp ; do
288      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/          rm -f ./genmake_hello.c  ./genmake_hello
289      #          cat >> genmake_hello.c << EOF
290      #    2) a known-buggy xmakedpend shell script  #include <stdio.h>
291      #  int main(int argc, char **argv) {
292      #  So the choices are, in order:    printf("Hello!\n");
293      #    return 0;
294      #    1) use the user-specified program  }
     #    2) use a system-wide default  
     #    3) locally build and use the cyrus implementation  
     #    4) fall back to the buggy local xmakedpend script  
     #  
     if test "x${MAKEDEPEND}" = x ; then  
       which makedepend > /dev/null 2>&1  
       RV0=$?  
       cat <<EOF >> genmake_tc.f  
       program test  
       write(*,*) 'test'  
       stop  
       end  
295  EOF  EOF
296        makedepend genmake_tc.f > /dev/null 2>&1          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297        RV1=$?          RETVAL=$?
298        if test ! "x${RV0}${RV1}" = x00 ; then          if test "x${RETVAL}" = x0 ; then
299           echo "    a system-default makedepend was not found."              p_CC="$p_CC $c"
300            fi
301           #  Try to build the cyrus impl      done
302           rm -f ./genmake_cy_md      rm -f ./genmake_hello.c ./genmake_hello
303           (      if test "x${p_CC}" = x ; then
304               cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cat 1>&2 <<EOF
305                   &&  ./configure > /dev/null 2>&1  \  
306                   &&  make > /dev/null 2>&1  Error: No C compilers were found in your path.  Please specify one using:
307               if test -x ./makedepend.exe ; then  
308                   $LN ./makedepend.exe ./makedepend      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309               fi      2) the CC or MITGCM_CC environment variables.
310               ./makedepend ifparser.c > /dev/null 2>&1  \  
311                   &&  echo "true"  EOF
312           ) > ./genmake_cy_md          exit 1
313           grep true ./genmake_cy_md > /dev/null 2>&1      else
314           RETVAL=$?          echo "  The possible C compilers found in your path are:"
315           if test "x$RETVAL" = x0 ; then          echo "   "$p_CC
316               MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'          if test "x$CC" = x ; then
317           else              CC=`echo $p_CC | $AWK '{print $1}'`
318               MAKEDEPEND='$(TOOLSDIR)/xmakedepend'              echo "  Setting C compiler to: "$CC
319           fi          fi
          rm -f ./genmake_cy_md  
       fi  
320      fi      fi
321    
322      # look for possible fortran compilers      #================================================================
323        #  look for possible FORTRAN compilers
324      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
325      p_FC=      p_FC=
326      for c in $tmp ; do      for c in $tmp ; do
# Line 269  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 440  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
# Line 449  Usage: "$0" [OPTIONS] Line 531  Usage: "$0" [OPTIONS]
531            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
532      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
533            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
534            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
535            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
536    
537      -bash NAME      -bash NAME
538            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 475  EOF Line 557  EOF
557    
558  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
559  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
560    
561        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
562        if test ! "x$FC_NAMEMANGLE" = x ; then
563            return 0
564        fi
565    
566      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
567            
568      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 492  WARNING: Please contact <MITgcm-support@ Line 580  WARNING: Please contact <MITgcm-support@
580  EOF  EOF
581          return 1          return 1
582      fi      fi
583      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`
584      RETVAL=$?      RETVAL=$?
585      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
586          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 504  WARNING: Please contact <MITgcm-support@ Line 592  WARNING: Please contact <MITgcm-support@
592  EOF  EOF
593          return 1          return 1
594      fi      fi
595      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
596        subroutine tcall( string )        subroutine tcall( string )
597        character*(*) string        character*(*) string
598        call tsub( string )        call tsub( string )
599        end        end
600  EOF  EOF
601      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1
602      RETVAL=$?      RETVAL=$?
603      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
604          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 522  WARNING: Please contact <MITgcm-support@ Line 610  WARNING: Please contact <MITgcm-support@
610  EOF  EOF
611          return 1          return 1
612      fi      fi
613      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`
614      RETVAL=$?      RETVAL=$?
615      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
616          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 576  void FC_NAMEMANGLE(cloc) ( double *curti Line 664  void FC_NAMEMANGLE(cloc) ( double *curti
664   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
665  }  }
666  EOF  EOF
667      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
668      RET_C=$?      RET_C=$?
669      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
670        program hello        program hello
671        Real*8 wtime        Real*8 wtime
672        external cloc        external cloc
# Line 586  EOF Line 674  EOF
674        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
675        end program hello        end program hello
676  EOF  EOF
677      $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
678      RET_F=$?      RET_F=$?
679      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
680      RETVAL=$?      RETVAL=$?
681      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
682          HAVE_CLOC=t          HAVE_CLOC=t
# Line 598  EOF Line 686  EOF
686  }  }
687    
688    
689    check_HAVE_STAT()  {
690        get_fortran_c_namemangling
691        cat <<EOF > genmake_tc_1.c
692    $FC_NAMEMANGLE
693    #include <stdio.h>
694    #include <stdlib.h>
695    #include <unistd.h>
696    #include <sys/stat.h>
697    #include <sys/types.h>
698    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
699    {
700        char name[512];
701        struct stat astat;
702    
703        name[0] = 'a'; name[1] = '\0';
704        if (! stat(name, &astat))
705            *nbyte = (int)(astat.st_size);
706        else
707            *nbyte = -1;
708    }
709    EOF
710        make genmake_tc_1.o >> genmake_tc.log 2>&1
711        RET_C=$?
712        cat <<EOF > genmake_tc_2.$FS
713          program hello
714          integer nbyte
715          call tfsize(nbyte)
716          print *," HELLO WORLD", nbyte
717          end program hello
718    EOF
719        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
720        RET_F=$?
721        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
722        RETVAL=$?
723        if test "x$RETVAL" = x0 ; then
724            HAVE_STAT=t
725            DEFINES="$DEFINES -DHAVE_STAT"
726        fi
727        rm -f genmake_tc*
728    }
729    
730    
731  check_netcdf_libs()  {  check_netcdf_libs()  {
732      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
733            return
734        fi
735        echo "" > genmake_tnc.log
736        cat <<EOF > genmake_tnc.F
737        program fgennc        program fgennc
738  #include "netcdf.inc"  #include "netcdf.inc"
739    EOF
740        if test ! "x$MPI" = x ; then
741            echo '#include "mpif.h"' >> genmake_tnc.F
742        fi
743        cat <<EOF >> genmake_tnc.F
744        integer iret, ncid, xid        integer iret, ncid, xid
745        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
746        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 611  check_netcdf_libs()  { Line 750  check_netcdf_libs()  {
750        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
751        end        end
752  EOF  EOF
753      $CPP genmake_tnc.for > genmake_tnc.f  \      echo "Executing:" > genmake_tnc.log
754          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      echo "  $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \
755            > genmake_tnc.log
756        RET_CPP=f
757        $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
758            &&  RET_CPP=t
759        if test "x$RET_CPP" = xf ; then
760            echo "  WARNING: CPP failed to pre-process the netcdf test." \
761                > genmake_tnc.log
762            echo "    Please check that \$INCLUDES is properly set." \
763                > genmake_tnc.log
764        fi
765        echo "Executing:" > genmake_tnc.log
766        echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log
767        echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log
768        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
769            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
770      RET_COMPILE=$?      RET_COMPILE=$?
771      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1  
772      RETVAL=$?      #EH3  Remove test program execution for machines that either disallow
773      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  execution or cannot support it (eg. cross-compilers)
774        #EH3
775        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
776        #EH3 RETVAL=$?
777        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
778    
779        if test "x$RET_COMPILE" = x0 ; then
780          HAVE_NETCDF=t          HAVE_NETCDF=t
781      else      else
782          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
783          $CPP genmake_tnc.for > genmake_tnc.f  \          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
784              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
785              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
786          RET_COMPILE=$?          RET_COMPILE=$?
787          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  
788              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
789              HAVE_NETCDF=t              HAVE_NETCDF=t
790          else          else
# Line 649  PLATFORM= Line 807  PLATFORM=
807  LN=  LN=
808  S64=  S64=
809  KPP=  KPP=
810  FC=  #FC=
811  CPP=  #CC=gcc
812    #CPP=
813  LINK=  LINK=
814  DEFINES=  DEFINES=
815  PACKAGES=  PACKAGES=
816  ENABLE=  ENABLE=
817  DISABLE=  DISABLE=
818  MAKEFILE=  # MAKEFILE=
819  MAKEDEPEND=  # MAKEDEPEND=
820  PDEPEND=  PDEPEND=
821  DUMPSTATE=t  DUMPSTATE=t
822  PDEFAULT=  PDEFAULT=
823  OPTFILE=  OPTFILE=
824  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
825  FFLAGS=  FFLAGS=
826  FOPTIM=  FOPTIM=
827  CFLAGS=  CFLAGS=
# Line 681  HAVE_SYSTEM= Line 840  HAVE_SYSTEM=
840  HAVE_FDATE=  HAVE_FDATE=
841  FC_NAMEMANGLE=  FC_NAMEMANGLE=
842  HAVE_CLOC=  HAVE_CLOC=
843    HAVE_STAT=
844  HAVE_NETCDF=  HAVE_NETCDF=
845  HAVE_ETIME=  HAVE_ETIME=
846    
# Line 693  STANDARDDIRS="USE_THE_DEFAULT" Line 853  STANDARDDIRS="USE_THE_DEFAULT"
853  G2ARGS=  G2ARGS=
854  BASH=  BASH=
855  PWD=`pwd`  PWD=`pwd`
856  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
857  AWK=awk  test "x$AWK" = x   &&  AWK=awk
858  THISHOSTNAME=`hostname`  THISHOST=`hostname`
859  THISCWD=`pwd`  THISCWD=`pwd`
860  THISDATE=`date`  THISDATE=`date`
861    THISUSER=`echo $USER`
862    THISVER=
863  MACHINE=`uname -a`  MACHINE=`uname -a`
864  EXECUTABLE=  EXECUTABLE=
865  EXEHOOK=  EXEHOOK=
# Line 731  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STA Line 893  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STA
893  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
894  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 "
895  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
896  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
897  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
898  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
899    
# Line 763  for i in . $MODS ; do Line 925  for i in . $MODS ; do
925      fi      fi
926  done  done
927  printf "  getting local config information:  "  printf "  getting local config information:  "
928  if test -e $gm_local ; then  if test -f $gm_local ; then
929      echo "using $gm_local"      echo "using $gm_local"
930      . $gm_local      . $gm_local
931      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 772  else Line 934  else
934      echo "none found"      echo "none found"
935  fi  fi
936    
937  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
938  #OPTIONS=  #OPTIONS=
939  #n=0  #n=0
940  #for i ; do  #for i ; do
# Line 784  fi Line 946  fi
946  #done  #done
947  #parse_options  #parse_options
948  ac_prev=  ac_prev=
949  for ac_option ; do  for ac_option in "$@" ; do
950    
951      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
952    
# Line 880  for ac_option ; do Line 1042  for ac_option ; do
1042  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1043  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1044  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1045                        
1046            -cc | --cc)
1047                ac_prev=CC ;;
1048            -cc=* | --cc=*)
1049                CC=$ac_optarg ;;
1050            
1051          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1052              ac_prev=FC ;;              ac_prev=FC ;;
1053          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 939  for ac_option ; do Line 1106  for ac_option ; do
1106            
1107  done  done
1108    
1109    
1110  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1111      echo      echo
1112      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 951  if test -f ./.genmakerc ; then Line 1119  if test -f ./.genmakerc ; then
1119      echo      echo
1120  fi  fi
1121    
1122    #  Find the MITgcm ${ROOTDIR}
1123  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1124      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1125        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1126          ROOTDIR=".."          ROOTDIR=".."
1127      else      else
1128          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
# Line 976  if test ! -d ${ROOTDIR} ; then Line 1146  if test ! -d ${ROOTDIR} ; then
1146      exit 1      exit 1
1147  fi  fi
1148    
1149    #  Find the MITgcm ${THISVER}
1150    if test -f "${ROOTDIR}/doc/tag-index" ; then
1151        THISVER=`grep checkpoint ${ROOTDIR}/doc/tag-index | head -1`
1152    fi
1153    
1154    if test "x$MAKEFILE" = x ; then
1155        MAKEFILE="Makefile"
1156    fi
1157    
1158  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1159  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1160      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 1005  if test "x$OPTFILE" != xNONE ; then Line 1184  if test "x$OPTFILE" != xNONE ; then
1184      fi      fi
1185  fi  fi
1186    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1187  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1188  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1189      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1035  if test "x${AD_OPTFILE}" != xNONE ; then Line 1211  if test "x${AD_OPTFILE}" != xNONE ; then
1211      fi      fi
1212  fi  fi
1213    
1214  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1215    #  Set default values if not set by the optfile
1216    #
1217    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1218  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1219  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1220      # 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 1051  Error: no Fortran compiler: please speci Line 1230  Error: no Fortran compiler: please speci
1230  EOF  EOF
1231      exit 1      exit 1
1232  fi  fi
1233    if test "x$CC" = x ; then
1234        CC=cc
1235    #     cat <<EOF 1>&2
1236    # Error: no C compiler: please specify using one of the following:
1237    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1238    #   2) the "-cc=XXX" command-line option
1239    #   3) the "./genmake_local" file
1240    # EOF
1241    #     exit 1
1242    fi
1243  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1244      LINK=$FC      LINK=$FC
1245  fi  fi
# Line 1085  EOF Line 1274  EOF
1274  else  else
1275      rm -f test_cpp      rm -f test_cpp
1276  fi  fi
1277  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1278  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1279      LN="ln -s"      LN="ln -s"
1280  fi  fi
# Line 1115  fi Line 1302  fi
1302    
1303  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1304  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1305  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1306        program hello        program hello
1307        call system('echo hi')        call system('echo hi')
1308        end        end
1309  EOF  EOF
1310  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1311  RETVAL=$?  RETVAL=$?
1312  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1313      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1133  fi Line 1320  fi
1320  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1321    
1322  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1323  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1324        program hello        program hello
1325        CHARACTER(128) string        CHARACTER(128) string
1326        string = ' '        string = ' '
# Line 1141  cat > genmake_tcomp.f <<EOF Line 1328  cat > genmake_tcomp.f <<EOF
1328        print *, string        print *, string
1329        end        end
1330  EOF  EOF
1331  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1332  RETVAL=$?  RETVAL=$?
1333  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1334      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1154  fi Line 1341  fi
1341  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1342    
1343  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1344  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1345        program hello        program hello
1346        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1347        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1163  cat > genmake_tcomp.f <<EOF Line 1350  cat > genmake_tcomp.f <<EOF
1350        print *, tarray        print *, tarray
1351        end        end
1352  EOF  EOF
1353  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1354  RETVAL=$?  RETVAL=$?
1355  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1356      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1184  else Line 1371  else
1371  fi  fi
1372  rm -f genmake_t*  rm -f genmake_t*
1373    
1374    printf "  Can we use stat() through C calls...  "
1375    check_HAVE_STAT
1376    if test "x$HAVE_STAT" != x ; then
1377        echo "yes"
1378    else
1379        echo "no"
1380    fi
1381    rm -f genmake_t*
1382    
1383  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1384  check_netcdf_libs  check_netcdf_libs
1385  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1208  for d in $MODS ; do Line 1404  for d in $MODS ; do
1404  done  done
1405  echo  echo
1406    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1407  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1408      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1409  fi  fi
1410    
1411  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1412      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1413        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1414          EXEDIR=../exe          EXEDIR=../exe
1415      else      else
1416          EXEDIR=.          EXEDIR=.
# Line 1235  if test ! -d ${TOOLSDIR} ; then Line 1429  if test ! -d ${TOOLSDIR} ; then
1429      exit 1      exit 1
1430  fi  fi
1431  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1432      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1433        RETVAL=$?
1434        if test "x${RETVAL}" = x0 ; then
1435            S64='$(TOOLSDIR)/set64bitConst.sh'
1436        else
1437            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1438            RETVAL=$?
1439            if test "x${RETVAL}" = x0 ; then
1440                S64='$(TOOLSDIR)/set64bitConst.csh'
1441            else
1442                cat <<EOF
1443    
1444    ERROR: neither of the two default scripts:
1445    
1446        ${TOOLSDIR}/set64bitConst.sh
1447        ${TOOLSDIR}/set64bitConst.csh
1448    
1449      are working so please check paths or specify (with \$S64) a
1450      working version of this script.
1451    
1452    EOF
1453                exit 1
1454            fi
1455        fi
1456  fi  fi
1457  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1458    
# Line 1334  else Line 1551  else
1551              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1552          done          done
1553          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1554          while ! expand_pkg_groups; do echo > /dev/null; done          RET=1
1555            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1556          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1557      fi      fi
1558  fi  fi
# Line 1379  done Line 1597  done
1597  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1598  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1599    
1600    #  Check availability of NetCDF and then either build the MNC template
1601    #  files or delete mnc from the list of available packages.
1602    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1603    RETVAL=$?
1604    if test "x$RETVAL" = x0 ; then
1605        if test "x$HAVE_NETCDF" != xt ; then
1606            cat <<EOF
1607    
1608    *********************************************************************
1609    WARNING: the "mnc" package was enabled but tests failed to compile
1610      NetCDF applications.  Please check that:
1611    
1612      1) NetCDF is correctly installed for this compiler and
1613      2) the LIBS variable (within the "optfile") specifies the correct
1614           NetCDF library to link against.
1615    
1616      Due to this failure, the "mnc" package is now DISABLED.
1617    *********************************************************************
1618    
1619    EOF
1620            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1621            DISABLE="$DISABLE mnc"
1622        else
1623            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1624            RETVAL=$?
1625            if test "x${RETVAL}" = x0 ; then
1626                rm -f make_mnc.errors
1627            else
1628                echo "Error: problem encountered while building source files in pkg/mnc:"
1629                cat make_mnc.errors 1>&2
1630                exit 1
1631            fi
1632        fi
1633    fi
1634    
1635  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1636  ck=  ck=
1637  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1443  while test "x$ck" != xtt ; do Line 1696  while test "x$ck" != xtt ; do
1696              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1697              exit 1              exit 1
1698          fi          fi
1699          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1700            #i=$(( $i + 1 ))
1701      done      done
1702      ck=$ck"t"      ck=$ck"t"
1703  done  done
# Line 1462  for i in $PACKAGES ; do Line 1716  for i in $PACKAGES ; do
1716      fi      fi
1717  done  done
1718    
 #  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  
   
1719  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1720  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1721  #  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 1508  for n in $names ; do Line 1735  for n in $names ; do
1735              fi              fi
1736          done          done
1737          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1738              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1739              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1740          fi          fi
1741      fi      fi
1742  done  done
1743  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1744  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1745      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1746      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1747  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1748    
# Line 1605  echo Line 1832  echo
1832  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1833  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1834  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1835      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1836          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1837      fi      fi
1838  done  done
# Line 1637  for d in $alldirs ; do Line 1862  for d in $alldirs ; do
1862                          ;;                          ;;
1863                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1864                          ;;                          ;;
1865                      ./BUILD_INFO.h)
1866                            ;;
1867                    *)                    *)
1868                          touch .links.tmp/$sf                          touch .links.tmp/$sf
1869                          deplist="$deplist $sf"                          deplist="$deplist $sf"
1870                          ;;                          ;;
1871                  esac                  esac
1872                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F. '{print $NF}'`
1873                  case $extn in                  case $extn in
1874                      F)                      F)
1875                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
# Line 1682  echo "" >> f90srclist.inc Line 1909  echo "" >> f90srclist.inc
1909  echo "" >> hlist.inc  echo "" >> hlist.inc
1910  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
1911    
1912  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
1913      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
1914  fi  fi
1915  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1693  echo "#    $THISDATE" >> $MAKEFILE Line 1920  echo "#    $THISDATE" >> $MAKEFILE
1920  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1921  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1922  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1923  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
1924    
1925  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
1926  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1739  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 1966  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1966  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1967    
1968  # These files are created by Makefile  # These files are created by Makefile
1969  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
1970    
1971  EOF  EOF
1972    
# Line 1758  KPP = ${KPP} Line 1985  KPP = ${KPP}
1985  FC = ${FC}  FC = ${FC}
1986  # Fortran compiler  # Fortran compiler
1987  F90C = ${F90C}  F90C = ${F90C}
1988    # C compiler
1989    CC = ${CC}
1990  # Link editor  # Link editor
1991  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
1992    
# Line 1780  CFLAGS = ${CFLAGS} Line 2009  CFLAGS = ${CFLAGS}
2009  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2010  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2011  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2012  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2013  # Name of the Mekfile  # Name of the Mekfile
2014  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2015    
# Line 1841  makefile: Line 2070  makefile:
2070  cleanlinks:  cleanlinks:
2071          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2072    
2073  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2074  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2075          @echo Creating \$@ ...          @echo Creating \$@ ...
2076          @$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 1852  FC_NAMEMANGLE.h: Line 2081  FC_NAMEMANGLE.h:
2081          @echo Creating \$@ ...          @echo Creating \$@ ...
2082          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2083    
2084    BUILD_INFO.h:
2085            @echo Creating \$@ ...
2086    EOF
2087    
2088    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2089    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2090    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2091    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2092    
2093    cat >>$MAKEFILE <<EOF
2094    
2095  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2096    
2097  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2098    ## %.o : %.F
2099    
2100  .F.$FS:  .F.$FS:
2101          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1939  ad_tamc_output.f: ad_input_code.f Line 2180  ad_tamc_output.f: ad_input_code.f
2180  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2181          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2182    
2183    adonlyfwd:
2184            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2185    
2186    adtrick:
2187            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2188    
2189  # ... FTL ...  # ... FTL ...
2190  ftlall: ftl_taf  ftlall: ftl_taf
# Line 1974  ftl_tamc: ftl_tamc_output.o \$(OBJFILES) Line 2220  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2220    
2221  # ... SVD ...  # ... SVD ...
2222  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.f ftl_taf_output.f
2223  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2224            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2225    svdall: svd_touch svd_taf
2226    
2227  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2228          \$(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)
2229    
2230            @echo "--->>> Only COMPILE svd code! <<<---"
2231            @echo "--->>> Assumes you previously <<<---"
2232            @echo "--->>> did make svdtaf        <<<---"
2233    
2234    svd_touch:
2235            @echo "--->>> Only COMPILE svd code! <<<---"
2236            @echo "--->>> Assumes you previously <<<---"
2237            @echo "--->>> did make svdtaf        <<<---"
2238            touch ad_taf_output.f ftl_taf_output.f
2239            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.f
2240            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.f
2241            @$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
2242            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2243            -rm -f ftl_config.template
2244    
2245  #=========================================  #=========================================
2246    

Legend:
Removed from v.1.83  
changed lines
  Added in v.1.119

  ViewVC Help
Powered by ViewVC 1.1.22