/[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.76 by edhill, Thu Apr 8 21:32:11 2004 UTC revision 1.140 by ce107, Thu Dec 22 01:36:24 2005 UTC
# Line 97  EOF Line 97  EOF
97      RETVAL=$?      RETVAL=$?
98      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
99          if test "x$FS" = x ; then          if test "x$FS" = x ; then
100              FS='fs'              FS='for'
101              FS90='fs90'              FS90='fr9'
102              check_for_broken_Ff              check_for_broken_Ff
103          else          else
104              cat <<EOF 2>&1              cat <<EOF 2>&1
# 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
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='fs'              FS='for'
137              FS90='fs9'              FS90='fr9'
138              check_for_broken_Ff              check_for_broken_Ff
139          else          else
140              cat <<EOF 2>&1              cat <<EOF 2>&1
# Line 147  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 157  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            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
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 167  find_possible_configs()  { Line 258  find_possible_configs()  {
258      tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
259      tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`      tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
260      PLATFORM=$tmp3      PLATFORM=$tmp3
261        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
262      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
263      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
264            
# Line 186  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  }
295      #    2) use a system-wide default  EOF
296      #    3) locally build and use the cyrus implementation          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297      #    4) fall back to the buggy local xmakedpend script          RETVAL=$?
298      #          if test "x${RETVAL}" = x0 ; then
299      if test "x${MAKEDEPEND}" = x ; then              p_CC="$p_CC $c"
300        which makedepend > /dev/null 2>&1          fi
301        RETVAL=$?      done
302        if test ! "x${RETVAL}" = x0 ; then      rm -f ./genmake_hello.c ./genmake_hello
303           echo "    a system-default makedepend was not found."      if test "x${p_CC}" = x ; then
304            cat 1>&2 <<EOF
305           #  Try to build the cyrus impl  
306           rm -f ./genmake_cy_md  Error: No C compilers were found in your path.  Please specify one using:
307           (  
308               cd $ROOTDIR/tools/cyrus-imapd-makedepend  \      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309                   &&  ./configure > /dev/null 2>&1  \      2) the CC or MITGCM_CC environment variables.
310                   &&  make > /dev/null 2>&1  \  
311                   &&  ./makedepend ifparser.c > /dev/null 2>&1  \  EOF
312                   &&  echo "true"          exit 1
313           ) > ./genmake_cy_md      else
314           grep true ./genmake_cy_md > /dev/null 2>&1          echo "  The possible C compilers found in your path are:"
315           RETVAL=$?          echo "   "$p_CC
316           if test "x$RETVAL" = x0 ; then          if test "x$CC" = x ; then
317               MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'              CC=`echo $p_CC | $AWK '{print $1}'`
318           else              echo "  Setting C compiler to: "$CC
319               MAKEDEPEND='$(TOOLSDIR)/xmakedepend'          fi
          fi  
          rm -f ./genmake_cy_md  
       fi  
320      fi      fi
321    
322      # look for possible fortran compilers      #================================================================
323      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      #  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 256  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
353      else      else
354          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
355          echo "   "$p_FC          echo "   "$p_FC
356          if test "x$FC" = x ; then      fi
357              FC=`echo $p_FC | $AWK '{print $1}'`  
358              echo "  Setting FORTRAN compiler to: "$FC      #  Use the first of the compilers found in the current PATH
359          fi      #  that has a correctly-named optfile
360        if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
361            for i in $p_FC ; do
362                OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363                if test -r $OPTFILE ; then
364                    echo "  Setting OPTFILE to: "$OPTFILE
365                    break
366                fi
367            done
368      fi      fi
369    
370      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 358  Usage: "$0" [OPTIONS] Line 456  Usage: "$0" [OPTIONS]
456      -help | --help | -h | --h      -help | --help | -h | --h
457            Print this help message and exit.            Print this help message and exit.
458    
459        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
460          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
461              Use "NAME" as the adoptfile.  By default, the file at
462              "tools/adjoint_options/adjoint_default" will be used.
463    
464      -nooptfile | --nooptfile      -nooptfile | --nooptfile
465        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
466        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
# Line 422  Usage: "$0" [OPTIONS] Line 525  Usage: "$0" [OPTIONS]
525            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
526            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
527    
528        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
529              Use "NAME" as the C compiler.  By default, genmake
530              will search for a working compiler by trying a list of
531              "usual suspects" such as gcc, c89, cc, etc.
532    
533      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
534            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
535            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
536            is being used.            is being used.
537    
538        -ts | --ts
539              Produce timing information per timestep
540        -papis | --papis
541              Produce summary MFlop/s with PAPI per timestep
542        -foolad | --foolad
543              Fool the AD code generator
544        -papi | --papi
545              Performance analysis with PAPI
546        -hpmt | --hpmt
547              Performance analysis with the HPM Toolkit
548    
549        -gsl | --gsl
550              Use GSL to control floating point rounding and precision
551    
552      -mpi | --mpi      -mpi | --mpi
553            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
554      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
555            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
556            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
557            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
558    
559      -bash NAME      -bash NAME
560            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 457  EOF Line 579  EOF
579    
580  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
581  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
582    
583        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
584        if test ! "x$FC_NAMEMANGLE" = x ; then
585            return 0
586        fi
587    
588      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
589            
590      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 474  WARNING: Please contact <MITgcm-support@ Line 602  WARNING: Please contact <MITgcm-support@
602  EOF  EOF
603          return 1          return 1
604      fi      fi
605      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`
606      RETVAL=$?      RETVAL=$?
607      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
608          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 486  WARNING: Please contact <MITgcm-support@ Line 614  WARNING: Please contact <MITgcm-support@
614  EOF  EOF
615          return 1          return 1
616      fi      fi
617      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
618        subroutine tcall( string )        subroutine tcall( string )
619        character*(*) string        character*(*) string
620        call tsub( string )        call tsub( string )
621        end        end
622  EOF  EOF
623      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
624      RETVAL=$?      RETVAL=$?
625      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
626          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 504  WARNING: Please contact <MITgcm-support@ Line 632  WARNING: Please contact <MITgcm-support@
632  EOF  EOF
633          return 1          return 1
634      fi      fi
635      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`
636      RETVAL=$?      RETVAL=$?
637      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
638          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 558  void FC_NAMEMANGLE(cloc) ( double *curti Line 686  void FC_NAMEMANGLE(cloc) ( double *curti
686   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
687  }  }
688  EOF  EOF
689      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
690      RET_C=$?      RET_C=$?
691      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
692        program hello        program hello
693        Real*8 wtime        REAL*8 wtime
694        external cloc        external cloc
695        call cloc(wtime)        call cloc(wtime)
696        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
697        end program hello        end
698  EOF  EOF
699      $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
700      RET_F=$?      RET_F=$?
701      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
702      RETVAL=$?      RETVAL=$?
703      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
704          HAVE_CLOC=t          HAVE_CLOC=t
# Line 580  EOF Line 708  EOF
708  }  }
709    
710    
711    check_HAVE_SIGREG()  {
712        get_fortran_c_namemangling
713        cat <<EOF > genmake_tc_1.c
714    $FC_NAMEMANGLE
715    #include <stdlib.h>
716    #include <stdio.h>
717    #include <signal.h>
718    #include <errno.h>
719    #include <ucontext.h>
720    
721    int * ip;
722    
723    static void killhandler(
724        unsigned int sn, siginfo_t  si, struct ucontext *sc )
725    {
726        *ip = *ip + 1;
727        return;
728    }
729    
730    void FC_NAMEMANGLE(sigreg) (int * aip)
731    {
732        struct sigaction s;
733        ip = aip;
734        s.sa_flags = SA_SIGINFO;
735        s.sa_sigaction = (void *)killhandler;
736        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
737            printf("Sigaction returned error = %d\n", errno);
738            exit(0);
739        }
740        return;
741    }
742    EOF
743        make genmake_tc_1.o >> genmake_warnings 2>&1
744        RET_C=$?
745        cat <<EOF > genmake_tc_2.$FS
746          program hello
747          integer anint
748          common /iv/ anint
749          external sigreg
750          call sigreg(anint)
751          end
752    EOF
753        echo >> genmake_warnings
754        echo "running: check_HAVE_SIGREG()" >> genmake_warnings
755        cat genmake_tc_2.$FS >> genmake_warnings
756        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
757        echo $COMM >> genmake_warnings
758        $COMM >> genmake_warnings 2>&1
759        RETVAL=$?
760        if test "x$RETVAL" = x0 ; then
761            HAVE_SIGREG=t
762            DEFINES="$DEFINES -DHAVE_SIGREG"
763        fi
764        rm -f genmake_tc*
765    }
766    
767    
768    check_HAVE_SETRLSTK()  {
769        get_fortran_c_namemangling
770        cat <<EOF > genmake_tc_1.c
771    $FC_NAMEMANGLE
772    #include <sys/time.h>
773    #include <sys/resource.h>
774    #include <unistd.h>
775    void FC_NAMEMANGLE(setrlstk) ()
776    {
777        struct rlimit rls;
778        rls.rlim_cur = RLIM_INFINITY;
779        rls.rlim_max = RLIM_INFINITY;
780        setrlimit(RLIMIT_STACK, &rls);
781        return;
782    }
783    EOF
784        make genmake_tc_1.o >> genmake_warnings 2>&1
785        RET_C=$?
786        cat <<EOF > genmake_tc_2.$FS
787          program hello
788          external setrlstk
789          call setrlstk()
790          end
791    EOF
792        echo >> genmake_warnings
793        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
794        cat genmake_tc_2.$FS >> genmake_warnings
795        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
796        echo $COMM >> genmake_warnings
797        $COMM >> genmake_warnings 2>&1
798        RETVAL=$?
799        if test "x$RETVAL" = x0 ; then
800            HAVE_SETRLSTK=t
801            DEFINES="$DEFINES -DHAVE_SETRLSTK"
802        fi
803        rm -f genmake_tc*
804    }
805    
806    
807    check_HAVE_STAT()  {
808        get_fortran_c_namemangling
809        cat <<EOF > genmake_tc_1.c
810    $FC_NAMEMANGLE
811    #include <stdio.h>
812    #include <stdlib.h>
813    #include <unistd.h>
814    #include <sys/stat.h>
815    #include <sys/types.h>
816    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
817    {
818        char name[512];
819        struct stat astat;
820    
821        name[0] = 'a'; name[1] = '\0';
822        if (! stat(name, &astat))
823            *nbyte = (int)(astat.st_size);
824        else
825            *nbyte = -1;
826    }
827    EOF
828        make genmake_tc_1.o >> genmake_tc.log 2>&1
829        RET_C=$?
830        cat <<EOF > genmake_tc_2.$FS
831          program hello
832          integer nbyte
833          call tfsize(nbyte)
834          print *," HELLO WORLD", nbyte
835          end
836    EOF
837        echo >> genmake_warnings
838        echo "running: check_HAVE_STAT()" >> genmake_warnings
839        cat genmake_tc_2.$FS >> genmake_warnings
840        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
841        echo $COMM >> genmake_warnings
842        $COMM >> genmake_tc.log 2>&1
843        RETVAL=$?
844        if test "x$RETVAL" = x0 ; then
845            HAVE_STAT=t
846            DEFINES="$DEFINES -DHAVE_STAT"
847        fi
848        rm -f genmake_tc*
849    }
850    
851    
852  check_netcdf_libs()  {  check_netcdf_libs()  {
853      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
854            return
855        fi
856        echo >> genmake_warnings
857        echo "running: check_netcdf_libs()" >> genmake_warnings
858        cat <<EOF > genmake_tnc.F
859        program fgennc        program fgennc
860  #include "netcdf.inc"  #include "netcdf.inc"
861    EOF
862        if test ! "x$MPI" = x ; then
863            echo '#include "mpif.h"' >> genmake_tnc.F
864        fi
865        cat <<EOF >> genmake_tnc.F
866        integer iret, ncid, xid        integer iret, ncid, xid
867        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
868        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 593  check_netcdf_libs()  { Line 872  check_netcdf_libs()  {
872        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
873        end        end
874  EOF  EOF
875      $CPP genmake_tnc.for > genmake_tnc.f  \      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
876          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      cat genmake_tnc.F >> genmake_tnc.log
877        echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
878        RET_CPP=f
879        COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
880        echo "$COMM" >> genmake_tnc.log
881        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
882        if test "x$RET_CPP" = xf ; then
883            echo "  WARNING: CPP failed to pre-process the netcdf test." \
884                >> genmake_tnc.log
885            echo "    Please check that \$INCLUDES is properly set." \
886                >> genmake_tnc.log
887        fi
888        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
889        echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
890        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
891            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
892      RET_COMPILE=$?      RET_COMPILE=$?
893      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      cat genmake_tnc.log >> genmake_warnings
894      RETVAL=$?  
895      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  Remove test program execution for machines that either disallow
896        #EH3  execution or cannot support it (eg. cross-compilers)
897        #EH3
898        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
899        #EH3 RETVAL=$?
900        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
901    
902        if test "x$RET_COMPILE" = x0 ; then
903          HAVE_NETCDF=t          HAVE_NETCDF=t
904      else      else
905          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
906          $CPP genmake_tnc.for > genmake_tnc.f  \          echo "try again with added '-lnetcdf'" > genmake_tnc.log
907              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
908              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
909            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
910            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
911                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
912                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
913          RET_COMPILE=$?          RET_COMPILE=$?
914          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          cat genmake_tnc.log >> genmake_warnings
915          RETVAL=$?          if test "x$RET_COMPILE" = x0 ; then
         if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then  
916              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
917              HAVE_NETCDF=t              HAVE_NETCDF=t
         else  
             cat genmake_tnc.log >> genmake_warnings  
918          fi          fi
919      fi      fi
920      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 631  PLATFORM= Line 933  PLATFORM=
933  LN=  LN=
934  S64=  S64=
935  KPP=  KPP=
936  FC=  #FC=
937  CPP=  #CC=gcc
938    #CPP=
939  LINK=  LINK=
940  DEFINES=  DEFINES=
941  PACKAGES=  PACKAGES=
942  ENABLE=  ENABLE=
943  DISABLE=  DISABLE=
944  MAKEFILE=  # MAKEFILE=
945  MAKEDEPEND=  # MAKEDEPEND=
946  PDEPEND=  PDEPEND=
947  DUMPSTATE=t  DUMPSTATE=t
948  PDEFAULT=  PDEFAULT=
949  OPTFILE=  OPTFILE=
950  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
951  FFLAGS=  FFLAGS=
952  FOPTIM=  FOPTIM=
953  CFLAGS=  CFLAGS=
# Line 657  NOOPTFILES= Line 960  NOOPTFILES=
960  NOOPTFLAGS=  NOOPTFLAGS=
961  MPI=  MPI=
962  MPIPATH=  MPIPATH=
963    TS=
964    PAPIS=
965    FOOLAD=
966    PAPI=
967    HPMT=
968    GSL=
969    HAVE_TEST_L=
970    
971  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
972  HAVE_SYSTEM=  HAVE_SYSTEM=
973  HAVE_FDATE=  HAVE_FDATE=
974  FC_NAMEMANGLE=  FC_NAMEMANGLE=
975  HAVE_CLOC=  HAVE_CLOC=
976    HAVE_SETRLSTK=
977    HAVE_STAT=
978  HAVE_NETCDF=  HAVE_NETCDF=
979    HAVE_ETIME=
980    IGNORE_TIME=
981    
982  MODS=  MODS=
983  TOOLSDIR=  TOOLSDIR=
# Line 674  STANDARDDIRS="USE_THE_DEFAULT" Line 988  STANDARDDIRS="USE_THE_DEFAULT"
988  G2ARGS=  G2ARGS=
989  BASH=  BASH=
990  PWD=`pwd`  PWD=`pwd`
991  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
992  AWK=awk  test "x$AWK" = x   &&  AWK=awk
993  THISHOSTNAME=`hostname`  THISHOST=`hostname`
994  THISCWD=`pwd`  THISCWD=`pwd`
995  THISDATE=`date`  THISDATE=`date`
996    THISUSER=`echo $USER`
997    THISVER=
998  MACHINE=`uname -a`  MACHINE=`uname -a`
999  EXECUTABLE=  EXECUTABLE=
1000  EXEHOOK=  EXEHOOK=
# Line 707  TAMC_EXTRA= Line 1023  TAMC_EXTRA=
1023    
1024  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1025  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1026  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"
1027    
1028  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1029  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 "
1030  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
1031  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
1032  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
1033  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
1034    
1035  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1036  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
# Line 744  for i in . $MODS ; do Line 1060  for i in . $MODS ; do
1060      fi      fi
1061  done  done
1062  printf "  getting local config information:  "  printf "  getting local config information:  "
1063  if test -e $gm_local ; then  if test -f $gm_local ; then
1064      echo "using $gm_local"      echo "using $gm_local"
1065      . $gm_local      . $gm_local
1066      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 753  else Line 1069  else
1069      echo "none found"      echo "none found"
1070  fi  fi
1071    
1072  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1073  #OPTIONS=  #OPTIONS=
1074  #n=0  #n=0
1075  #for i ; do  #for i ; do
# Line 765  fi Line 1081  fi
1081  #done  #done
1082  #parse_options  #parse_options
1083  ac_prev=  ac_prev=
1084  for ac_option ; do  for ac_option in "$@" ; do
1085    
1086      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
1087    
# Line 861  for ac_option ; do Line 1177  for ac_option ; do
1177  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1178  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1179  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1180                        
1181            -cc | --cc)
1182                ac_prev=CC ;;
1183            -cc=* | --cc=*)
1184                CC=$ac_optarg ;;
1185            
1186          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1187              ac_prev=FC ;;              ac_prev=FC ;;
1188          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 882  for ac_option ; do Line 1203  for ac_option ; do
1203          -noieee | --noieee)          -noieee | --noieee)
1204              IEEE= ;;              IEEE= ;;
1205    
1206            -ts | --ts)
1207                TS=true ;;
1208            -papis | --papis)
1209                PAPIS=true ;;
1210            -foolad | --foolad)
1211                FOOLAD=true ;;
1212            -papi | --papi)
1213                PAPI=true ;;
1214            -hpmt | --hpmt)
1215                HPMT=true ;;
1216    
1217            -gsl | --gsl)
1218                GSL=true ;;
1219    
1220          -mpi | --mpi)          -mpi | --mpi)
1221              MPI=true ;;              MPI=true ;;
1222          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 905  for ac_option ; do Line 1240  for ac_option ; do
1240              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1241          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1242              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1243            
1244            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1245                IGNORE_TIME="-DIGNORE_TIME" ;;
1246    
1247          -*)          -*)
1248              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 920  for ac_option ; do Line 1258  for ac_option ; do
1258            
1259  done  done
1260    
1261    
1262  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1263      echo      echo
1264      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 932  if test -f ./.genmakerc ; then Line 1271  if test -f ./.genmakerc ; then
1271      echo      echo
1272  fi  fi
1273    
1274    #  Find the MITgcm ${ROOTDIR}
1275  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1276      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1277        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1278          ROOTDIR=".."          ROOTDIR=".."
1279      else      else
1280          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
# Line 957  if test ! -d ${ROOTDIR} ; then Line 1298  if test ! -d ${ROOTDIR} ; then
1298      exit 1      exit 1
1299  fi  fi
1300    
1301    #  Find the MITgcm ${THISVER}
1302    if test -f "${ROOTDIR}/doc/tag-index" ; then
1303        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1304    fi
1305    
1306    if test "x$MAKEFILE" = x ; then
1307        MAKEFILE="Makefile"
1308    fi
1309    
1310  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1311  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1312      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 986  if test "x$OPTFILE" != xNONE ; then Line 1336  if test "x$OPTFILE" != xNONE ; then
1336      fi      fi
1337  fi  fi
1338    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 check_for_broken_Ff  
   
1339  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1340  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1341      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1016  if test "x${AD_OPTFILE}" != xNONE ; then Line 1363  if test "x${AD_OPTFILE}" != xNONE ; then
1363      fi      fi
1364  fi  fi
1365    
1366  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1367    #  Set default values if not set by the optfile
1368    #
1369    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1370  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1371  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1372      # 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 1032  Error: no Fortran compiler: please speci Line 1382  Error: no Fortran compiler: please speci
1382  EOF  EOF
1383      exit 1      exit 1
1384  fi  fi
1385    if test "x$CC" = x ; then
1386        CC=cc
1387    #     cat <<EOF 1>&2
1388    # Error: no C compiler: please specify using one of the following:
1389    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1390    #   2) the "-cc=XXX" command-line option
1391    #   3) the "./genmake_local" file
1392    # EOF
1393    #     exit 1
1394    fi
1395  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1396      LINK=$FC      LINK=$FC
1397  fi  fi
# Line 1066  EOF Line 1426  EOF
1426  else  else
1427      rm -f test_cpp      rm -f test_cpp
1428  fi  fi
1429  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1430  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1431      LN="ln -s"      LN="ln -s"
1432  fi  fi
# Line 1084  Error: The command "ln -s" failed -- ple Line 1442  Error: The command "ln -s" failed -- ple
1442  EOF  EOF
1443      exit 1      exit 1
1444  fi  fi
1445    test -L genmake_tlink > /dev/null 2>&1
1446    RETVAL=$?
1447    if test "x$RETVAL" = x0 ; then
1448        HAVE_TEST_L=t
1449    fi
1450  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1451    
1452    #  Check for broken *.F/*.f handling and fix if possible
1453    check_for_broken_Ff
1454    
1455  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1456        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1457        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1458  fi  fi
1459    
1460    if test ! "x$TS" = x ; then
1461          echo "  Turning on timing per timestep"
1462          if test ! "x$FOOLAD" = x ; then
1463                DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1464          else
1465                DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1466          fi
1467    fi
1468    if test ! "x$PAPIS" = x ; then
1469          echo "  Turning on PAPI flop summary per timestep"
1470          echo "  Please make sure PAPIINC, PAPILIB are defined"
1471          if test ! "x$FOOLAD" = x ; then
1472                DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1473          else
1474                DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1475          fi
1476          INCLUDES="$INCLUDES $PAPIINC"
1477          LIBS="$LIBS $PAPILIB"
1478    fi
1479    if test ! "x$PAPI" = x ; then
1480          if test ! "x$PAPIS" = x ; then
1481              echo "  PAPI performance analysis and flop summary per timestep cannot co-exist!"
1482              echo "  Sticking with PAPI flop summary per timestep!"
1483          else
1484              echo "  Turning on performance analysis with PAPI"
1485              echo "  Please make sure PAPIINC, PAPILIB are defined"
1486              DEFINES="$DEFINES -DUSE_PAPI"
1487              INCLUDES="$INCLUDES $PAPIINC"
1488              LIBS="$LIBS $PAPILIB"
1489          fi
1490    fi
1491    if test ! "x$HPMT" = x ; then
1492          if test ! "x$PAPI" = x ; then
1493              echo "  PAPI and the HPM Toolkit cannot co-exist!"
1494              echo "  Sticking with PAPI!"
1495          else
1496              echo "  Turning on performance analysis with the HPM Toolkit"
1497              echo "  Please make sure HPMTINC, HPMTLIB are defined"
1498              DEFINES="$DEFINES -DUSE_LIBHPM"
1499              INCLUDES="$INCLUDES $HPMTINC"
1500              LIBS="$LIBS $HPMTLIB"
1501          fi
1502    fi
1503    if test ! "x$GSL" = x ; then
1504          echo "  Turning on use of GSL to control floating point calculations"
1505          echo "  Please make sure GSLINC, GSLLIB are defined"
1506          DEFINES="$DEFINES -DUSE_GSL_IEEE"
1507          INCLUDES="$INCLUDES $GSLINC"
1508          LIBS="$LIBS $GSLLIB"
1509    fi
1510    
1511  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1512  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1513  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1514        program hello        program hello
1515        call system('echo hi')        call system('echo hi')
1516        end        end
1517  EOF  EOF
1518  $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
1519  RETVAL=$?  RETVAL=$?
1520  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1521      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1111  fi Line 1528  fi
1528  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1529    
1530  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1531  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1532        program hello        program hello
1533        CHARACTER(128) string        CHARACTER*(128) string
1534        string = ' '        string = ' '
1535        call fdate( string )        call fdate( string )
1536        print *, string        print *, string
1537        end        end
1538  EOF  EOF
1539  $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
1540  RETVAL=$?  RETVAL=$?
1541  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1542      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1131  else Line 1548  else
1548  fi  fi
1549  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1550    
1551    printf "  Do we have the etime() command using $FC...  "
1552    cat > genmake_tcomp.$FS <<EOF
1553          program hello
1554          REAL*4 ACTUAL, TARRAY(2)
1555          EXTERNAL ETIME
1556          REAL*4 ETIME
1557          actual = etime( tarray )
1558          print *, tarray
1559          end
1560    EOF
1561    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1562    RETVAL=$?
1563    if test "x$RETVAL" = x0 ; then
1564        HAVE_ETIME=t
1565        DEFINES="$DEFINES -DHAVE_ETIME"
1566        echo "yes"
1567    else
1568        HAVE_ETIME=
1569        echo "no"
1570    fi
1571    rm -f genmake_tcomp*
1572    
1573  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1574  check_HAVE_CLOC  check_HAVE_CLOC
1575  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
# Line 1140  else Line 1579  else
1579  fi  fi
1580  rm -f genmake_t*  rm -f genmake_t*
1581    
1582    printf "  Can we unlimit the stack size using $FC...  "
1583    check_HAVE_SETRLSTK
1584    if test "x$HAVE_SETRLSTK" != x ; then
1585        echo "yes"
1586    else
1587        echo "no"
1588    fi
1589    rm -f genmake_t*
1590    
1591    printf "  Can we register a signal handler using $FC...  "
1592    check_HAVE_SIGREG
1593    if test "x$HAVE_SIGREG" != x ; then
1594        echo "yes"
1595    else
1596        echo "no"
1597    fi
1598    rm -f genmake_t*
1599    
1600    printf "  Can we use stat() through C calls...  "
1601    check_HAVE_STAT
1602    if test "x$HAVE_STAT" != x ; then
1603        echo "yes"
1604    else
1605        echo "no"
1606    fi
1607    rm -f genmake_t*
1608    
1609  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1610  check_netcdf_libs  check_netcdf_libs
1611  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1147  if test "x$HAVE_NETCDF" != x ; then Line 1613  if test "x$HAVE_NETCDF" != x ; then
1613  else  else
1614      echo "no"      echo "no"
1615  fi  fi
1616    DEFINES="$DEFINES $IGNORE_TIME"
1617    
1618  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1619  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1164  for d in $MODS ; do Line 1630  for d in $MODS ; do
1630  done  done
1631  echo  echo
1632    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1633  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1634      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1635  fi  fi
1636    
1637  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1638      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1639        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1640          EXEDIR=../exe          EXEDIR=../exe
1641      else      else
1642          EXEDIR=.          EXEDIR=.
# Line 1191  if test ! -d ${TOOLSDIR} ; then Line 1655  if test ! -d ${TOOLSDIR} ; then
1655      exit 1      exit 1
1656  fi  fi
1657  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1658      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1659        RETVAL=$?
1660        if test "x${RETVAL}" = x0 ; then
1661            S64='$(TOOLSDIR)/set64bitConst.sh'
1662        else
1663            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1664            RETVAL=$?
1665            if test "x${RETVAL}" = x0 ; then
1666                S64='$(TOOLSDIR)/set64bitConst.csh'
1667            else
1668                cat <<EOF
1669    
1670    ERROR: neither of the two default scripts:
1671    
1672        ${TOOLSDIR}/set64bitConst.sh
1673        ${TOOLSDIR}/set64bitConst.csh
1674    
1675      are working so please check paths or specify (with \$S64) a
1676      working version of this script.
1677    
1678    EOF
1679                exit 1
1680            fi
1681        fi
1682  fi  fi
1683  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1684    
# Line 1290  else Line 1777  else
1777              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1778          done          done
1779          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1780          while ! expand_pkg_groups; do echo > /dev/null; done          RET=1
1781            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1782          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1783      fi      fi
1784  fi  fi
# Line 1335  done Line 1823  done
1823  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1824  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1825    
1826    #  Check availability of NetCDF and then either build the MNC template
1827    #  files or delete mnc from the list of available packages.
1828    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1829    RETVAL=$?
1830    if test "x$RETVAL" = x0 ; then
1831        if test "x$HAVE_NETCDF" != xt ; then
1832            cat <<EOF
1833    
1834    *********************************************************************
1835    WARNING: the "mnc" package was enabled but tests failed to compile
1836      NetCDF applications.  Please check that:
1837    
1838      1) NetCDF is correctly installed for this compiler and
1839      2) the LIBS variable (within the "optfile") specifies the correct
1840           NetCDF library to link against.
1841    
1842      Due to this failure, the "mnc" package is now DISABLED.
1843    *********************************************************************
1844    
1845    EOF
1846            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1847            DISABLE="$DISABLE mnc"
1848        else
1849            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1850            RETVAL=$?
1851            if test "x${RETVAL}" = x0 ; then
1852                rm -f make_mnc.errors
1853            else
1854                echo "Error: problem encountered while building source files in pkg/mnc:"
1855                cat make_mnc.errors 1>&2
1856                exit 1
1857            fi
1858        fi
1859    fi
1860    
1861  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1862  ck=  ck=
1863  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1399  while test "x$ck" != xtt ; do Line 1922  while test "x$ck" != xtt ; do
1922              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1923              exit 1              exit 1
1924          fi          fi
1925          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1926            #i=$(( $i + 1 ))
1927      done      done
1928      ck=$ck"t"      ck=$ck"t"
1929  done  done
# Line 1418  for i in $PACKAGES ; do Line 1942  for i in $PACKAGES ; do
1942      fi      fi
1943  done  done
1944    
 #  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  
   
1945  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1946  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1947  #  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 1464  for n in $names ; do Line 1961  for n in $names ; do
1961              fi              fi
1962          done          done
1963          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1964              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1965              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1966          fi          fi
1967      fi      fi
1968  done  done
1969  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1970  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1971      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1972      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1973  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1974    
# Line 1555  for i in $SOURCEDIRS ; do Line 2052  for i in $SOURCEDIRS ; do
2052          cat $i/$j >> ad_files          cat $i/$j >> ad_files
2053      done      done
2054  done  done
2055    if test ! "x"$FS = "x.f" ; then
2056        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
2057        mv -f ad_files_f ad_files
2058    fi
2059    
2060  echo  echo
2061  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
2062  echo "  setting INCLUDES"  echo "  setting INCLUDES"
2063  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
2064      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
2065          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
2066      fi      fi
2067  done  done
2068    
2069    if test ! "x$DIVA" = x ; then
2070        echo "  Creating the pseudo-MPI include directory"
2071        INCLUDES="-I./mpi_headers $INCLUDES"
2072        rm -rf ./mpi_headers
2073        mkdir -p ./mpi_headers
2074    
2075        if test "x$MPIINCLUDEDIR" = x ; then
2076            if test "x$MPIHOME" = x ; then
2077                MPIHOME='/usr'
2078            fi
2079            MPIINCLUDEDIR='$MPIHOME/include'
2080        fi
2081        
2082        if test -r $MPIINCLUDEDIR/mpif.h ; then
2083            for i in $MPI_HEADER_FILES; do
2084                cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2085            done
2086    
2087            perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2088        else
2089            echo " We cannot create a copy of mpif.h!"
2090            exit -1
2091        fi
2092    fi
2093    
2094  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2095  rm -rf .links.tmp  rm -rf .links.tmp
2096  mkdir .links.tmp  mkdir .links.tmp
# Line 1586  for d in $alldirs ; do Line 2109  for d in $alldirs ; do
2109      for sf in $sfiles ; do      for sf in $sfiles ; do
2110          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2111              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2112                    ignore_f=f
2113                  case $d/$sf in                  case $d/$sf in
2114                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2115                          ;;                          ;;
# Line 1593  for d in $alldirs ; do Line 2117  for d in $alldirs ; do
2117                          ;;                          ;;
2118                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2119                          ;;                          ;;
2120                      ./BUILD_INFO.h)
2121                            ;;
2122                    *)                    *)
2123                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
2124                          deplist="$deplist $sf"                          #  ignore all soft-links
2125                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2126                                ignore_f=t
2127                            else
2128                                touch .links.tmp/$sf
2129                                deplist="$deplist $sf"
2130                            fi
2131                          ;;                          ;;
2132                  esac                  esac
2133                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
2134                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2135                      F)                      case $extn in
2136                          echo    " \\"  >> srclist.inc                          F)
2137                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
2138                          ;;                              printf " $sf" >> srclist.inc
2139                      F90)                              ;;
2140                          echo    " \\"  >> f90srclist.inc                          F90)
2141                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
2142                          ;;                              printf " $sf" >> f90srclist.inc
2143                      c)                              ;;
2144                          echo    " \\"  >> csrclist.inc                          c)
2145                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
2146                          ;;                              printf " $sf" >> csrclist.inc
2147                      h)                              ;;
2148                          echo    " \\"  >> hlist.inc                          h)
2149                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
2150                          ;;                              printf " $sf" >> hlist.inc
2151                      flow)                              ;;
2152                          echo    " \\"  >> ad_flow_files.inc                          flow)
2153                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
2154                          ;;                              printf " $sf" >> ad_flow_files.inc
2155                  esac                              ;;
2156                        esac
2157                    fi
2158              fi              fi
2159          fi          fi
2160      done      done
# Line 1638  echo "" >> f90srclist.inc Line 2172  echo "" >> f90srclist.inc
2172  echo "" >> hlist.inc  echo "" >> hlist.inc
2173  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
2174    
2175  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2176      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2177  fi  fi
2178  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1649  echo "#    $THISDATE" >> $MAKEFILE Line 2183  echo "#    $THISDATE" >> $MAKEFILE
2183  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2184  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2185  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2186  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2187    
2188  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2189  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1695  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2229  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2229  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2230    
2231  # These files are created by Makefile  # These files are created by Makefile
2232  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
2233    
2234  EOF  EOF
2235    
# Line 1714  KPP = ${KPP} Line 2248  KPP = ${KPP}
2248  FC = ${FC}  FC = ${FC}
2249  # Fortran compiler  # Fortran compiler
2250  F90C = ${F90C}  F90C = ${F90C}
2251    # C compiler
2252    CC = ${CC}
2253  # Link editor  # Link editor
2254  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2255    
# Line 1736  CFLAGS = ${CFLAGS} Line 2272  CFLAGS = ${CFLAGS}
2272  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2273  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2274  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2275  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2276  # Name of the Mekfile  # Name of the Mekfile
2277  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2278    
# Line 1749  cat hlist.inc         >> $MAKEFILE Line 2285  cat hlist.inc         >> $MAKEFILE
2285  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2286  echo >> $MAKEFILE  echo >> $MAKEFILE
2287  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2288  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2289  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2290  echo >> $MAKEFILE  echo >> $MAKEFILE
2291  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2292  echo '.SUFFIXES: .o .F .p .'$FS' .c .F90 .'$FS90 >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2293  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
2294  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2295    
# Line 1769  depend: Line 2305  depend:
2305          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2306          -rm -f makedepend.out          -rm -f makedepend.out
2307    
2308    lib: libmitgcmuv.a
2309    
2310    libmitgcmuv.a: \$(OBJFILES)
2311            ar rcv libmitgcmuv.a \$(OBJFILES)
2312    
2313  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2314    
2315  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 1789  CLEAN: Line 2330  CLEAN:
2330          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2331          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2332          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2333          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2334    
2335  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2336  makefile:  makefile:
# Line 1797  makefile: Line 2338  makefile:
2338  cleanlinks:  cleanlinks:
2339          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2340    
2341  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2342  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2343          @echo Creating \$@ ...          @echo Creating \$@ ...
2344          @$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 1808  FC_NAMEMANGLE.h: Line 2349  FC_NAMEMANGLE.h:
2349          @echo Creating \$@ ...          @echo Creating \$@ ...
2350          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2351    
2352    BUILD_INFO.h:
2353            @echo Creating \$@ ...
2354    EOF
2355    
2356    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2357    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2358    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2359    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2360    
2361    cat >>$MAKEFILE <<EOF
2362    
2363  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2364    
2365  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2366    ## %.o : %.F
2367    
2368  .F.$FS:  .F.$FS:
2369          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1821  FC_NAMEMANGLE.h: Line 2374  FC_NAMEMANGLE.h:
2374  .$FS90.o:  .$FS90.o:
2375          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2376  .c.o:  .c.o:
2377          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2378    
2379  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2380  .F.p:  .F.p:
# Line 1866  cat >>$MAKEFILE <<EOF Line 2419  cat >>$MAKEFILE <<EOF
2419    
2420  # ... AD ...  # ... AD ...
2421  adall: ad_taf  adall: ad_taf
2422  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2423  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2424    
2425  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2426          @$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
2427          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
2428          -rm -f ad_config.template          -rm -f ad_config.template
2429          @make \$(F77FILES)          @make \$(F77FILES)
2430          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2431          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2432    
2433  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2434          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2435          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
2436    
2437  adtafonly:  adtafonly:
2438          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2439          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
2440    
2441  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2442          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2443    
2444  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2445          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2446          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
2447    
2448  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2449          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2450    
2451    adonlyfwd:
2452            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2453    
2454    adtrick:
2455            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2456    
2457  # ... FTL ...  # ... FTL ...
2458  ftlall: ftl_taf  ftlall: ftl_taf
2459  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2460  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2461    
2462  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2463          @$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
2464          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
2465          -rm -f ftl_config.template          -rm -f ftl_config.template
2466          @make \$(F77FILES)          @make \$(F77FILES)
2467          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2468          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2469    
2470  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2471          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2472          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
2473    
2474  ftltafonly:  ftltafonly:
2475          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2476          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
2477    
2478  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2479          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2480    
2481  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2482          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2483          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
2484    
2485  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2486          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2487    
2488    
2489  # ... SVD ...  # ... SVD ...
2490  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2491  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2492            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2493    svdall: svd_touch svd_taf
2494    
2495  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2496          \$(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)
2497    
2498            @echo "--->>> Only COMPILE svd code! <<<---"
2499            @echo "--->>> Assumes you previously <<<---"
2500            @echo "--->>> did make svdtaf        <<<---"
2501    
2502    svd_touch:
2503            @echo "--->>> Only COMPILE svd code! <<<---"
2504            @echo "--->>> Assumes you previously <<<---"
2505            @echo "--->>> did make svdtaf        <<<---"
2506            touch ad_taf_output.$FS ftl_taf_output.$FS
2507            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2508            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2509            @$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
2510            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2511            -rm -f ftl_config.template
2512    
2513  #=========================================  #=========================================
2514    

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.140

  ViewVC Help
Powered by ViewVC 1.1.22