/[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.55 by jmc, Sat Dec 6 00:34:29 2003 UTC revision 1.136 by edhill, Thu Nov 24 17:52:15 2005 UTC
# Line 37  test_for_string_in_file() { Line 37  test_for_string_in_file() {
37      grep -i "$strng" $file > /dev/null 2>&1      grep -i "$strng" $file > /dev/null 2>&1
38      RETVAL=$?      RETVAL=$?
39      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
40          echo -n "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
41          grep -i "$strng" $file          grep -i "$strng" $file
42          return 1          return 1
43      fi      fi
# Line 67  expand_pkg_groups() { Line 67  expand_pkg_groups() {
67          done          done
68          PACKAGES=$new_packages          PACKAGES=$new_packages
69          rm -f ./p[1,2].tmp          rm -f ./p[1,2].tmp
70            return $matched
71      else      else
72          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
73      fi      fi
74  }  }
75    
76    #  Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
77    #  cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
78    check_for_broken_Ff()  {
79        #  Do we have defaults for $FS and/or $FS90 ?
80        tfs=f
81        tfs9=f90
82        if test "x$FS" != x ; then
83            tfs="$FS"
84        fi
85        if test "x$FS90" != x ; then
86            tfs9="$FS90"
87        fi
88    
89        #  First check the ability to create a *.F/.f pair.
90        cat <<EOF >> genmake_hello.F
91          program hello
92          write(*,*) 'hi'
93          stop
94          end
95    EOF
96        cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
97        RETVAL=$?
98        if test "x$RETVAL" != x0 ; then
99            if test "x$FS" = x ; then
100                FS='for'
101                FS90='fr9'
102                check_for_broken_Ff
103            else
104                cat <<EOF 2>&1
105    ERROR: Your file system cannot distinguish between *.F and *.f files
106      (fails the "cp" test) and this program cannot find a suitable
107      replacement extension.  Please try a different build environment or
108      contact the <MITgcm-support@mitgcm.org> list for help.
109    
110    EOF
111                exit -1
112            fi
113            return
114        fi
115        rm -f genmake_hello.*
116    
117        #  Check the ability of ${MAKE} and ${LN} to use the current set
118        #  of extensions.
119        cat <<EOF >> genmake_hello.F
120          program hello
121          write(*,*) 'hi'
122          stop
123          end
124    EOF
125        test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
126        cat <<EOF >> $MAKEFILE
127    .SUFFIXES:
128    .SUFFIXES: .$tfs .F
129    .F.$tfs:
130            $LN \$< \$@
131    EOF
132        $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133        RETVAL=$?
134        if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
135            if test "x$FS" = x ; then
136                FS='for'
137                FS90='fr9'
138                check_for_broken_Ff
139            else
140                cat <<EOF 2>&1
141    ERROR: Your file system cannot distinguish between *.F and *.f files
142      (fails the "make/ln" test) and this program cannot find a suitable
143      replacement extension.  Please try a different build environment or
144      contact the <MITgcm-support@mitgcm.org> list for help.
145    
146    EOF
147                exit -1
148                return
149            fi
150        fi
151        rm -f genmake_hello.* $MAKEFILE
152        test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
153    
154        #  If we make it here, use the extensions
155        FS=$tfs
156        FS90=$tfs9
157        return
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    
254      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
255      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
256      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
257      PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
258        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/'`
260        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 98  find_possible_configs()  { Line 278  find_possible_configs()  {
278          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
279      fi      fi
280    
281      # makedepend is not always available      look_for_makedepend
282      if test "x${MAKEDEPEND}" = x ; then  
283        which makedepend >& /dev/null      #================================================================
284        RETVAL=$?      #  look for possible C compilers
285        if test "x${RETVAL}" = x1 ; then      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286           echo "    makedepend was not found. Using xmakedpend instead."      p_CC=
287           MAKEDEPEND='$(TOOLSDIR)/xmakedepend'      for c in $tmp ; do
288        fi          rm -f ./genmake_hello.c  ./genmake_hello
289            cat >> genmake_hello.c << EOF
290    #include <stdio.h>
291    int main(int argc, char **argv) {
292      printf("Hello!\n");
293      return 0;
294    }
295    EOF
296            $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297            RETVAL=$?
298            if test "x${RETVAL}" = x0 ; then
299                p_CC="$p_CC $c"
300            fi
301        done
302        rm -f ./genmake_hello.c ./genmake_hello
303        if test "x${p_CC}" = x ; then
304            cat 1>&2 <<EOF
305    
306    Error: No C compilers were found in your path.  Please specify one using:
307    
308        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309        2) the CC or MITGCM_CC environment variables.
310    
311    EOF
312            exit 1
313        else
314            echo "  The possible C compilers found in your path are:"
315            echo "   "$p_CC
316            if test "x$CC" = x ; then
317                CC=`echo $p_CC | $AWK '{print $1}'`
318                echo "  Setting C compiler to: "$CC
319            fi
320      fi      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 134  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
         if test "x$FC" = x ; then  
             FC=`echo $p_FC | $AWK '{print $1}'`  
         fi  
356      fi      fi
357    
358      for i in $p_FC ; do      #  Use the first of the compilers found in the current PATH
359          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i      #  that has a correctly-named optfile
360          if test -r $p_OF ; then      if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
361              OPTFILE=$p_OF          for i in $p_FC ; do
362              echo "  The options file:  $p_OF"              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363              echo "    appears to match so we'll use it."              if test -r $OPTFILE ; then
364              break                  echo "  Setting OPTFILE to: "$OPTFILE
365          fi                  break
366      done              fi
367            done
368        fi
369    
370        if test "x$OPTFILE" = x ; then
371            OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
372            if test ! -r $OPTFILE ; then
373                 echo "  I looked for the file "$OPTFILE" but did not find it"
374            fi
375        fi
376    #    echo "  The options file:  $p_OF"
377    #    echo "    appears to match so we'll use it."
378    #   for i in $p_FC ; do
379    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
380    #if test -r $p_OF ; then
381    #    OPTFILE=$p_OF
382    #    echo "  The options file:  $p_OF"
383    #    echo "    appears to match so we'll use it."
384    #    break
385    #fi
386    #   done
387      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
388          cat 1>&2 <<EOF          cat 1>&2 <<EOF
389    
# Line 213  get_pdepend_list()  { Line 442  get_pdepend_list()  {
442      . ./.pd_tmp      . ./.pd_tmp
443      rm -f ./.pd_tmp      rm -f ./.pd_tmp
444    
445      echo -n "PNAME = "${}      printf "PNAME = "${}
446  }  }
447    
448    
# Line 227  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 251  Usage: "$0" [OPTIONS] Line 485  Usage: "$0" [OPTIONS]
485        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
486            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
487    
488        -makedepend NAME | -md NAME
489          --makedepend=NAME | -md=NAME
490              Use "NAME" for the MAKEDEPEND program.
491    
492      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
493        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
494            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
# Line 287  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    
541        -mpi | --mpi
542              Include MPI header files and link to MPI libraries
543        -mpi=PATH | --mpi=PATH
544              Include MPI header files and link to MPI libraries using MPI_ROOT
545              set to PATH. i.e. Include files from \$PATH/include, link to libraries
546              from \$PATH/lib and use binaries from \$PATH/bin.
547    
548        -bash NAME
549              Explicitly specify the Bourne or BASH shell to use
550    
551    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
552    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
553    
# Line 312  EOF Line 568  EOF
568    
569  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
570  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
571    
572        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
573        if test ! "x$FC_NAMEMANGLE" = x ; then
574            return 0
575        fi
576    
577      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
578            
579      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 329  WARNING: Please contact <MITgcm-support@ Line 591  WARNING: Please contact <MITgcm-support@
591  EOF  EOF
592          return 1          return 1
593      fi      fi
594      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`
595      RETVAL=$?      RETVAL=$?
596      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
597          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 341  WARNING: Please contact <MITgcm-support@ Line 603  WARNING: Please contact <MITgcm-support@
603  EOF  EOF
604          return 1          return 1
605      fi      fi
606      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
607        subroutine tcall( string )        subroutine tcall( string )
608        character*(*) string        character*(*) string
609        call tsub( string )        call tsub( string )
610        end        end
611  EOF  EOF
612      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
613      RETVAL=$?      RETVAL=$?
614      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
615          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 359  WARNING: Please contact <MITgcm-support@ Line 621  WARNING: Please contact <MITgcm-support@
621  EOF  EOF
622          return 1          return 1
623      fi      fi
624      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`
625      RETVAL=$?      RETVAL=$?
626      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
627          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 413  void FC_NAMEMANGLE(cloc) ( double *curti Line 675  void FC_NAMEMANGLE(cloc) ( double *curti
675   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
676  }  }
677  EOF  EOF
678      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
679      RET_C=$?      RET_C=$?
680      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
681        program hello        program hello
682        Real*8 wtime        REAL*8 wtime
683        external cloc        external cloc
684        call cloc(wtime)        call cloc(wtime)
685        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
686        end program hello        end
687  EOF  EOF
688      $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
689      RET_F=$?      RET_F=$?
690      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
691      RETVAL=$?      RETVAL=$?
692      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
693          HAVE_CLOC=t          HAVE_CLOC=t
# Line 435  EOF Line 697  EOF
697  }  }
698    
699    
700    check_HAVE_SETRLSTK()  {
701        get_fortran_c_namemangling
702        cat <<EOF > genmake_tc_1.c
703    $FC_NAMEMANGLE
704    #include <sys/time.h>
705    #include <sys/resource.h>
706    #include <unistd.h>
707    void FC_NAMEMANGLE(setrlstk) ()
708    {
709        struct rlimit rls;
710        rls.rlim_cur = RLIM_INFINITY;
711        rls.rlim_max = RLIM_INFINITY;
712        setrlimit(RLIMIT_STACK, &rls);
713        return;
714    }
715    EOF
716        make genmake_tc_1.o >> genmake_warnings 2>&1
717        RET_C=$?
718        cat <<EOF > genmake_tc_2.$FS
719          program hello
720          external setrlstk
721          call setrlstk()
722          end
723    EOF
724        echo >> genmake_warnings
725        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
726        cat genmake_tc_2.$FS >> genmake_warnings
727        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
728        echo $COMM >> genmake_warnings
729        $COMM >> genmake_warnings 2>&1
730        RETVAL=$?
731        if test "x$RETVAL" = x0 ; then
732            HAVE_SETRLSTK=t
733            DEFINES="$DEFINES -DHAVE_SETRLSTK"
734        fi
735        rm -f genmake_tc*
736    }
737    
738    
739    check_HAVE_STAT()  {
740        get_fortran_c_namemangling
741        cat <<EOF > genmake_tc_1.c
742    $FC_NAMEMANGLE
743    #include <stdio.h>
744    #include <stdlib.h>
745    #include <unistd.h>
746    #include <sys/stat.h>
747    #include <sys/types.h>
748    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
749    {
750        char name[512];
751        struct stat astat;
752    
753        name[0] = 'a'; name[1] = '\0';
754        if (! stat(name, &astat))
755            *nbyte = (int)(astat.st_size);
756        else
757            *nbyte = -1;
758    }
759    EOF
760        make genmake_tc_1.o >> genmake_tc.log 2>&1
761        RET_C=$?
762        cat <<EOF > genmake_tc_2.$FS
763          program hello
764          integer nbyte
765          call tfsize(nbyte)
766          print *," HELLO WORLD", nbyte
767          end
768    EOF
769        echo >> genmake_warnings
770        echo "running: check_HAVE_STAT()" >> genmake_warnings
771        cat genmake_tc_2.$FS >> genmake_warnings
772        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
773        echo $COMM >> genmake_warnings
774        $COMM >> genmake_tc.log 2>&1
775        RETVAL=$?
776        if test "x$RETVAL" = x0 ; then
777            HAVE_STAT=t
778            DEFINES="$DEFINES -DHAVE_STAT"
779        fi
780        rm -f genmake_tc*
781    }
782    
783    
784    check_netcdf_libs()  {
785        if test ! "x$SKIP_NETCDF_CHECK" = x ; then
786            return
787        fi
788        echo >> genmake_warnings
789        echo "running: check_netcdf_libs()" >> genmake_warnings
790        cat <<EOF > genmake_tnc.F
791          program fgennc
792    #include "netcdf.inc"
793    EOF
794        if test ! "x$MPI" = x ; then
795            echo '#include "mpif.h"' >> genmake_tnc.F
796        fi
797        cat <<EOF >> genmake_tnc.F
798          integer iret, ncid, xid
799          iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
800          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
801          iret = nf_def_dim(ncid, 'X', 11, xid)
802          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
803          iret = nf_close(ncid)
804          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
805          end
806    EOF
807        echo "===  genmake_tnc.F  ===" > genmake_tnc.log
808        cat genmake_tnc.F >> genmake_tnc.log
809        echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
810        RET_CPP=f
811        COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
812        echo "$COMM" >> genmake_tnc.log
813        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
814        if test "x$RET_CPP" = xf ; then
815            echo "  WARNING: CPP failed to pre-process the netcdf test." \
816                >> genmake_tnc.log
817            echo "    Please check that \$INCLUDES is properly set." \
818                >> genmake_tnc.log
819        fi
820        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
821        echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
822        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
823            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
824        RET_COMPILE=$?
825        cat genmake_tnc.log >> genmake_warnings
826    
827        #EH3  Remove test program execution for machines that either disallow
828        #EH3  execution or cannot support it (eg. cross-compilers)
829        #EH3
830        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
831        #EH3 RETVAL=$?
832        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
833    
834        if test "x$RET_COMPILE" = x0 ; then
835            HAVE_NETCDF=t
836        else
837            # try again with "-lnetcdf" added to the libs
838            echo "try again with added '-lnetcdf'" > genmake_tnc.log
839            echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
840            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
841            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
842            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
843                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
844                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
845            RET_COMPILE=$?
846            cat genmake_tnc.log >> genmake_warnings
847            if test "x$RET_COMPILE" = x0 ; then
848                LIBS="$LIBS -lnetcdf"
849                HAVE_NETCDF=t
850            fi
851        fi
852        rm -f genmake_tnc*
853    }
854    
855    
856    
857    ###############################################################################
858    #   Sequential part of script starts here
859    ###############################################################################
860    
861  #  Set defaults here  #  Set defaults here
862  COMMANDL="$0 $@"  COMMANDL="$0 $@"
863    
# Line 442  PLATFORM= Line 865  PLATFORM=
865  LN=  LN=
866  S64=  S64=
867  KPP=  KPP=
868  FC=  #FC=
869    #CC=gcc
870    #CPP=
871  LINK=  LINK=
 # DEFINES="-DWORDLENGTH=4"  
872  DEFINES=  DEFINES=
873  PACKAGES=  PACKAGES=
874  ENABLE=  ENABLE=
875  DISABLE=  DISABLE=
876  MAKEFILE=  # MAKEFILE=
877  MAKEDEPEND=  # MAKEDEPEND=
878  PDEPEND=  PDEPEND=
879  DUMPSTATE=t  DUMPSTATE=t
880  PDEFAULT=  PDEFAULT=
881  OPTFILE=  OPTFILE=
882  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
883  FFLAGS=  FFLAGS=
884  FOPTIM=  FOPTIM=
885  CFLAGS=  CFLAGS=
886  KFLAGS1=  KFLAGS1=
887  KFLAGS2=  KFLAGS2=
888    #LDADD=
889  LIBS=  LIBS=
890  KPPFILES=  KPPFILES=
891  NOOPTFILES=  NOOPTFILES=
892  NOOPTFLAGS=  NOOPTFLAGS=
893    MPI=
894    MPIPATH=
895    TS=
896    HAVE_TEST_L=
897    
898  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
899  HAVE_SYSTEM=  HAVE_SYSTEM=
900  HAVE_FDATE=  HAVE_FDATE=
901  FC_NAMEMANGLE=  FC_NAMEMANGLE=
902  HAVE_CLOC=  HAVE_CLOC=
903    HAVE_SETRLSTK=
904    HAVE_STAT=
905    HAVE_NETCDF=
906    HAVE_ETIME=
907    IGNORE_TIME=
908    
909  MODS=  MODS=
910  TOOLSDIR=  TOOLSDIR=
911  SOURCEDIRS=  SOURCEDIRS=
912  INCLUDEDIRS=  INCLUDEDIRS=
913  STANDARDDIRS=  STANDARDDIRS="USE_THE_DEFAULT"
914    
915    G2ARGS=
916    BASH=
917  PWD=`pwd`  PWD=`pwd`
918  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
919  AWK=awk  test "x$AWK" = x   &&  AWK=awk
920  THISHOSTNAME=`hostname`  THISHOST=`hostname`
921  THISCWD=`pwd`  THISCWD=`pwd`
922  THISDATE=`date`  THISDATE=`date`
923    THISUSER=`echo $USER`
924    THISVER=
925  MACHINE=`uname -a`  MACHINE=`uname -a`
926  EXECUTABLE=  EXECUTABLE=
927  EXEHOOK=  EXEHOOK=
# Line 493  IEEE= Line 931  IEEE=
931  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
932      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
933  fi  fi
934    FS=
935    FS90=
936    
937  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
938  AD_OPTFILE=  AD_OPTFILE=
# Line 510  TAMC_EXTRA= Line 950  TAMC_EXTRA=
950    
951  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
952  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
953  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
954    
955  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
956  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 "
957  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
958  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
959  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
960  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
961    
962  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
963  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 546  for i in . $MODS ; do Line 986  for i in . $MODS ; do
986          break          break
987      fi      fi
988  done  done
989  echo -n "  getting local config information:  "  printf "  getting local config information:  "
990  if test -e $gm_local ; then  if test -f $gm_local ; then
991      echo "using $gm_local"      echo "using $gm_local"
992      . $gm_local      . $gm_local
993      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 556  else Line 996  else
996      echo "none found"      echo "none found"
997  fi  fi
998    
999  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1000  #OPTIONS=  #OPTIONS=
1001  #n=0  #n=0
1002  #for i ; do  #for i ; do
# Line 568  fi Line 1008  fi
1008  #done  #done
1009  #parse_options  #parse_options
1010  ac_prev=  ac_prev=
1011  for ac_option ; do  for ac_option in "$@" ; do
1012    
1013        G2ARGS="$G2ARGS \"$ac_option\""
1014    
1015      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
1016      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
# Line 611  for ac_option ; do Line 1053  for ac_option ; do
1053          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1054              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1055                    
1056            -bash | --bash)
1057                ac_prev=BASH ;;
1058            -bash=* | --bash=*)
1059                BASH=$ac_optarg ;;
1060            
1061            -makedepend | --makedepend | -md | --md)
1062                ac_prev=MAKEDEPEND ;;
1063            -makedepend=* | --makedepend=* | -md=* | --md=*)
1064                MAKEDEPEND=$ac_optarg ;;
1065            
1066          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
1067              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1068          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
# Line 652  for ac_option ; do Line 1104  for ac_option ; do
1104  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1105  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1106  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1107                        
1108            -cc | --cc)
1109                ac_prev=CC ;;
1110            -cc=* | --cc=*)
1111                CC=$ac_optarg ;;
1112            
1113          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1114              ac_prev=FC ;;              ac_prev=FC ;;
1115          -fc=* | --fc=*)          -fc=* | --fc=*)
1116              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1117                    
1118            -fs | --fs)
1119                ac_prev=FS ;;
1120            -fs=* | --fs=*)
1121                FS=$ac_optarg ;;
1122            
1123            -fs90 | --fs90)
1124                ac_prev=FS90 ;;
1125            -fs90=* | --fs90=*)
1126                FS90=$ac_optarg ;;
1127            
1128          -ieee | --ieee)          -ieee | --ieee)
1129              IEEE=true ;;              IEEE=true ;;
1130          -noieee | --noieee)          -noieee | --noieee)
1131              IEEE= ;;              IEEE= ;;
1132    
1133            -ts | --ts)
1134                TS=true ;;
1135    
1136            -mpi | --mpi)
1137                MPI=true ;;
1138            -mpi=* | --mpi=*)
1139                MPIPATH=$ac_optarg
1140                MPI=true ;;
1141                    
1142  #       -jam | --jam)  #       -jam | --jam)
1143  #           JAM=1 ;;  #           JAM=1 ;;
# Line 680  for ac_option ; do Line 1156  for ac_option ; do
1156              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1157          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1158              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1159            
1160            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1161                IGNORE_TIME="-DIGNORE_TIME" ;;
1162    
1163          -*)          -*)
1164              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 695  for ac_option ; do Line 1174  for ac_option ; do
1174            
1175  done  done
1176    
1177    
1178  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1179      echo      echo
1180      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 707  if test -f ./.genmakerc ; then Line 1187  if test -f ./.genmakerc ; then
1187      echo      echo
1188  fi  fi
1189    
1190    #  Find the MITgcm ${ROOTDIR}
1191  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1192      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1193        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1194          ROOTDIR=".."          ROOTDIR=".."
1195      else      else
1196          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1197              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1198                  ROOTDIR=$d                  ROOTDIR=$d
1199                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
1200                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
1201                  break                  break
1202              fi              fi
# Line 732  if test ! -d ${ROOTDIR} ; then Line 1214  if test ! -d ${ROOTDIR} ; then
1214      exit 1      exit 1
1215  fi  fi
1216    
1217    #  Find the MITgcm ${THISVER}
1218    if test -f "${ROOTDIR}/doc/tag-index" ; then
1219        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1220    fi
1221    
1222    if test "x$MAKEFILE" = x ; then
1223        MAKEFILE="Makefile"
1224    fi
1225    
1226  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1227  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1228      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 748  if test "x$OPTFILE" != xNONE ; then Line 1239  if test "x$OPTFILE" != xNONE ; then
1239          . "$OPTFILE"          . "$OPTFILE"
1240          RETVAL=$?          RETVAL=$?
1241          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1242              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
1243              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1244              exit 1              exit 1
1245          fi          fi
# Line 775  if test "x${AD_OPTFILE}" != xNONE ; then Line 1266  if test "x${AD_OPTFILE}" != xNONE ; then
1266          . "$AD_OPTFILE"          . "$AD_OPTFILE"
1267          RETVAL=$?          RETVAL=$?
1268          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1269              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""              printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1270              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1271              exit 1              exit 1
1272          fi          fi
# Line 788  if test "x${AD_OPTFILE}" != xNONE ; then Line 1279  if test "x${AD_OPTFILE}" != xNONE ; then
1279      fi      fi
1280  fi  fi
1281    
1282  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1283    #  Set default values if not set by the optfile
1284    #
1285    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1286  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1287    if test ! "x$BASH" = x ; then
1288        # add a trailing space so that it works within the Makefile syntax (see below)
1289        BASH="$BASH "
1290    fi
1291  if test "x$FC" = x ; then  if test "x$FC" = x ; then
1292      cat <<EOF 1>&2      cat <<EOF 1>&2
1293    
# Line 800  Error: no Fortran compiler: please speci Line 1298  Error: no Fortran compiler: please speci
1298  EOF  EOF
1299      exit 1      exit 1
1300  fi  fi
1301    if test "x$CC" = x ; then
1302        CC=cc
1303    #     cat <<EOF 1>&2
1304    # Error: no C compiler: please specify using one of the following:
1305    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1306    #   2) the "-cc=XXX" command-line option
1307    #   3) the "./genmake_local" file
1308    # EOF
1309    #     exit 1
1310    fi
1311  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1312      LINK=$FC      LINK=$FC
1313  fi  fi
 if test "x$CPP" = x ; then  
     CPP="cpp"  
 fi  
1314  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
1315      MAKE="make"      MAKE="make"
1316  fi  fi
1317    if test "x$CPP" = x ; then
1318        CPP=cpp
1319    fi
1320    #EH3 === UGLY ===
1321    #  The following is an ugly little hack to check for $CPP in /lib/ and
1322    #  it should eventually be replaced with a more general function that
1323    #  searches a combo of the user's path and a list of "usual suspects"
1324    #  to find the correct location for binaries such as $CPP.
1325    for i in " " "/lib/" ; do
1326        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1327    done
1328    #EH3 === UGLY ===
1329  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
1330  RETVAL=$?  RETVAL=$?
1331  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 825  EOF Line 1342  EOF
1342  else  else
1343      rm -f test_cpp      rm -f test_cpp
1344  fi  fi
1345  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1346  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1347      LN="ln -s"      LN="ln -s"
1348  fi  fi
# Line 843  Error: The command "ln -s" failed -- ple Line 1358  Error: The command "ln -s" failed -- ple
1358  EOF  EOF
1359      exit 1      exit 1
1360  fi  fi
1361    test -L genmake_tlink > /dev/null 2>&1
1362    RETVAL=$?
1363    if test "x$RETVAL" = x0 ; then
1364        HAVE_TEST_L=t
1365    fi
1366  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1367    
1368    #  Check for broken *.F/*.f handling and fix if possible
1369    check_for_broken_Ff
1370    
1371    if test ! "x$MPI" = x ; then
1372          echo "  Turning on MPI cpp macros"
1373          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1374    fi
1375    
1376    if test ! "x$TS" = x ; then
1377          echo "  Turning on timing per timestep"
1378          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1379    fi
1380    
1381  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1382  echo -n "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1383  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1384        program hello        program hello
1385        call system('echo hi')        call system('echo hi')
1386        end        end
1387  EOF  EOF
1388  $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
1389  RETVAL=$?  RETVAL=$?
1390  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1391      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 865  else Line 1397  else
1397  fi  fi
1398  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1399    
1400  echo -n "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1401  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1402        program hello        program hello
1403        CHARACTER(128) string        CHARACTER*(128) string
1404        string = ' '        string = ' '
1405        call fdate( string )        call fdate( string )
1406        print *, string        print *, string
1407        end        end
1408  EOF  EOF
1409  $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
1410  RETVAL=$?  RETVAL=$?
1411  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1412      HAVE_FDATE=t      HAVE_FDATE=t
# Line 886  else Line 1418  else
1418  fi  fi
1419  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1420    
1421  echo -n "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1422    cat > genmake_tcomp.$FS <<EOF
1423          program hello
1424          REAL*4 ACTUAL, TARRAY(2)
1425          EXTERNAL ETIME
1426          REAL*4 ETIME
1427          actual = etime( tarray )
1428          print *, tarray
1429          end
1430    EOF
1431    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1432    RETVAL=$?
1433    if test "x$RETVAL" = x0 ; then
1434        HAVE_ETIME=t
1435        DEFINES="$DEFINES -DHAVE_ETIME"
1436        echo "yes"
1437    else
1438        HAVE_ETIME=
1439        echo "no"
1440    fi
1441    rm -f genmake_tcomp*
1442    
1443    printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1444  check_HAVE_CLOC  check_HAVE_CLOC
1445  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1446      echo "yes"      echo "yes"
# Line 895  else Line 1449  else
1449  fi  fi
1450  rm -f genmake_t*  rm -f genmake_t*
1451    
1452    printf "  Can we unlimit the stack size using $FC...  "
1453    check_HAVE_SETRLSTK
1454    if test "x$HAVE_SETRLSTK" != x ; then
1455        echo "yes"
1456    else
1457        echo "no"
1458    fi
1459    rm -f genmake_t*
1460    
1461    printf "  Can we use stat() through C calls...  "
1462    check_HAVE_STAT
1463    if test "x$HAVE_STAT" != x ; then
1464        echo "yes"
1465    else
1466        echo "no"
1467    fi
1468    rm -f genmake_t*
1469    
1470    printf "  Can we create NetCDF-enabled binaries...  "
1471    check_netcdf_libs
1472    if test "x$HAVE_NETCDF" != x ; then
1473        echo "yes"
1474    else
1475        echo "no"
1476    fi
1477    DEFINES="$DEFINES $IGNORE_TIME"
1478    
1479  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1480  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1481  for d in $MODS ; do  for d in $MODS ; do
1482      if test ! -d $d ; then      if test ! -d $d ; then
1483          echo          echo
1484          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1485          exit 1          exit 1
1486      else      else
1487          echo -n " $d"          printf " $d"
1488          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1489          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1490      fi      fi
1491  done  done
1492  echo  echo
1493    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1494  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1495      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1496  fi  fi
1497    
1498  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1499      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1500        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1501          EXEDIR=../exe          EXEDIR=../exe
1502      else      else
1503          EXEDIR=.          EXEDIR=.
# Line 934  if test "x${TOOLSDIR}" = x ; then Line 1512  if test "x${TOOLSDIR}" = x ; then
1512      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1513  fi  fi
1514  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1515      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1516      exit 1      exit 1
1517  fi  fi
1518  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1519      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1520        RETVAL=$?
1521        if test "x${RETVAL}" = x0 ; then
1522            S64='$(TOOLSDIR)/set64bitConst.sh'
1523        else
1524            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1525            RETVAL=$?
1526            if test "x${RETVAL}" = x0 ; then
1527                S64='$(TOOLSDIR)/set64bitConst.csh'
1528            else
1529                cat <<EOF
1530    
1531    ERROR: neither of the two default scripts:
1532    
1533        ${TOOLSDIR}/set64bitConst.sh
1534        ${TOOLSDIR}/set64bitConst.csh
1535    
1536      are working so please check paths or specify (with \$S64) a
1537      working version of this script.
1538    
1539    EOF
1540                exit 1
1541            fi
1542        fi
1543  fi  fi
1544  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1545    
# Line 955  if test -r $ROOTDIR"/eesupp/src/Makefile Line 1556  if test -r $ROOTDIR"/eesupp/src/Makefile
1556          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1557      else      else
1558          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1559          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1560          exit 1          exit 1
1561      fi      fi
1562  fi  fi
1563    
1564    #same for exch2
1565    if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1566        echo "  Making source files in exch2 from  templates"
1567        ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1568        RETVAL=$?
1569        if test "x${RETVAL}" = x0 ; then
1570            rm -f make_exch2.errors
1571        else
1572            echo "Error: problem encountered while building source files in exch2:"
1573            cat make_exch2.errors 1>&2
1574            exit 1
1575        fi
1576    fi
1577    
1578  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1579  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
1580      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
# Line 1015  else Line 1630  else
1630          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1631          RETVAL=$?          RETVAL=$?
1632          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1633              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1634              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1635              exit 1              exit 1
1636          fi          fi
# Line 1023  else Line 1638  else
1638              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1639          done          done
1640          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1641          expand_pkg_groups          RET=1
1642            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1643          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1644      fi      fi
1645  fi  fi
1646    
1647  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1648    for i in $PACKAGES ; do
1649        echo $i >> ./.tmp_pack
1650    done
1651    for i in `grep  "-" ./.tmp_pack` ; do
1652        j=`echo $i | sed 's/[-]//'`
1653        DISABLE="$DISABLE $j"
1654    done
1655  pack=  pack=
1656  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1657      addit="t"      addit="t"
# Line 1045  PACKAGES="$pack" Line 1668  PACKAGES="$pack"
1668  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1669  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1670  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1671    # Test if each explicitly referenced package exists
1672  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1673      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1674        if test ! -d "$ROOTDIR/pkg/$j" ; then
1675          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1676          exit 1          exit 1
1677      fi      fi
1678      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1679  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1680  PACKAGES=  PACKAGES=
1681  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1682      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1683  done  done
1684    rm -f ./.tmp_pack
1685  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1686    
1687    #  Check availability of NetCDF and then either build the MNC template
1688    #  files or delete mnc from the list of available packages.
1689    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1690    RETVAL=$?
1691    if test "x$RETVAL" = x0 ; then
1692        if test "x$HAVE_NETCDF" != xt ; then
1693            cat <<EOF
1694    
1695    *********************************************************************
1696    WARNING: the "mnc" package was enabled but tests failed to compile
1697      NetCDF applications.  Please check that:
1698    
1699      1) NetCDF is correctly installed for this compiler and
1700      2) the LIBS variable (within the "optfile") specifies the correct
1701           NetCDF library to link against.
1702    
1703      Due to this failure, the "mnc" package is now DISABLED.
1704    *********************************************************************
1705    
1706    EOF
1707            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1708            DISABLE="$DISABLE mnc"
1709        else
1710            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1711            RETVAL=$?
1712            if test "x${RETVAL}" = x0 ; then
1713                rm -f make_mnc.errors
1714            else
1715                echo "Error: problem encountered while building source files in pkg/mnc:"
1716                cat make_mnc.errors 1>&2
1717                exit 1
1718            fi
1719        fi
1720    fi
1721    
1722  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1723  ck=  ck=
1724  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1124  while test "x$ck" != xtt ; do Line 1783  while test "x$ck" != xtt ; do
1783              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1784              exit 1              exit 1
1785          fi          fi
1786          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1787            #i=$(( $i + 1 ))
1788      done      done
1789      ck=$ck"t"      ck=$ck"t"
1790  done  done
# Line 1143  for i in $PACKAGES ; do Line 1803  for i in $PACKAGES ; do
1803      fi      fi
1804  done  done
1805    
   
1806  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1807  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1808  #  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 1163  for n in $names ; do Line 1822  for n in $names ; do
1822              fi              fi
1823          done          done
1824          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1825              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1826              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1827          fi          fi
1828      fi      fi
1829  done  done
1830  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1831  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1832      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1833      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1834  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1835    
# Line 1187  done Line 1846  done
1846    
1847  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1848  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1849  if test "x$STANDARDDIRS" = x ; then  if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1850      STANDARDDIRS="eesupp model"      STANDARDDIRS="eesupp model"
1851  fi  fi
1852  for d in $STANDARDDIRS ; do  if test "x$STANDARDDIRS" != x ; then
1853      adr="$ROOTDIR/$d/src"      for d in $STANDARDDIRS ; do
1854      if test ! -d $adr ; then          adr="$ROOTDIR/$d/src"
1855          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1856          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1857          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1858      else              exit 1
1859          SOURCEDIRS="$SOURCEDIRS $adr"          else
1860      fi              SOURCEDIRS="$SOURCEDIRS $adr"
1861      adr="$ROOTDIR/$d/inc"          fi
1862      if test ! -d $adr ; then          adr="$ROOTDIR/$d/inc"
1863          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1864          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1865          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1866      else              exit 1
1867          INCLUDEDIRS="$INCLUDEDIRS $adr"          else
1868      fi              INCLUDEDIRS="$INCLUDEDIRS $adr"
1869  done          fi
1870        done
1871    fi
1872    
1873  echo "  Searching for *OPTIONS.h files in order to warn about the presence"  echo "  Searching for *OPTIONS.h files in order to warn about the presence"
1874  echo "    of \"#define \"-type statements that are no longer allowed:"  echo "    of \"#define \"-type statements that are no longer allowed:"
# Line 1252  for i in $SOURCEDIRS ; do Line 1913  for i in $SOURCEDIRS ; do
1913          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1914      done      done
1915  done  done
1916    if test ! "x"$FS = "x.f" ; then
1917        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1918        mv -f ad_files_f ad_files
1919    fi
1920    
1921  echo  echo
1922  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1923  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1924  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1925      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1926          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1927      fi      fi
1928  done  done
# Line 1269  rm -rf .links.tmp Line 1932  rm -rf .links.tmp
1932  mkdir .links.tmp  mkdir .links.tmp
1933  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1934  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1935  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
1936  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
1937  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
1938  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
1939  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1940  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1941  for d in $alldirs ; do  for d in $alldirs ; do
1942      deplist=      deplist=
# Line 1282  for d in $alldirs ; do Line 1945  for d in $alldirs ; do
1945      for sf in $sfiles ; do      for sf in $sfiles ; do
1946          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1947              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1948                    ignore_f=f
1949                  case $d/$sf in                  case $d/$sf in
1950                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
1951                          ;;                          ;;
# Line 1289  for d in $alldirs ; do Line 1953  for d in $alldirs ; do
1953                          ;;                          ;;
1954                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1955                          ;;                          ;;
1956                      ./BUILD_INFO.h)
1957                            ;;
1958                    *)                    *)
1959                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
1960                          deplist="$deplist $sf"                          #  ignore all soft-links
1961                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
1962                                ignore_f=t
1963                            else
1964                                touch .links.tmp/$sf
1965                                deplist="$deplist $sf"
1966                            fi
1967                          ;;                          ;;
1968                  esac                  esac
1969                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
1970                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
1971                      F)                      case $extn in
1972                          echo    " \\"  >> srclist.inc                          F)
1973                          echo -n " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
1974                          ;;                              printf " $sf" >> srclist.inc
1975                      F90)                              ;;
1976                          echo    " \\"  >> f90srclist.inc                          F90)
1977                          echo -n " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
1978                          ;;                              printf " $sf" >> f90srclist.inc
1979                      c)                              ;;
1980                          echo    " \\"  >> csrclist.inc                          c)
1981                          echo -n " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
1982                          ;;                              printf " $sf" >> csrclist.inc
1983                      h)                              ;;
1984                          echo    " \\"  >> hlist.inc                          h)
1985                          echo -n " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
1986                          ;;                              printf " $sf" >> hlist.inc
1987                      flow)                              ;;
1988                          echo    " \\"  >> ad_flow_files.inc                          flow)
1989                          echo -n " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
1990                          ;;                              printf " $sf" >> ad_flow_files.inc
1991                  esac                              ;;
1992                        esac
1993                    fi
1994              fi              fi
1995          fi          fi
1996      done      done
# Line 1334  echo "" >> f90srclist.inc Line 2008  echo "" >> f90srclist.inc
2008  echo "" >> hlist.inc  echo "" >> hlist.inc
2009  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
2010    
2011  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2012      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2013  fi  fi
2014  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1343  echo "#    $MACHINE" >> $MAKEFILE Line 2017  echo "#    $MACHINE" >> $MAKEFILE
2017  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2018  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2019  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2020  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2021  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2022  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2023    
2024  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2025  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1391  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2065  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2065  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2066    
2067  # These files are created by Makefile  # These files are created by Makefile
2068  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
2069    
2070  EOF  EOF
2071    
# Line 1410  KPP = ${KPP} Line 2084  KPP = ${KPP}
2084  FC = ${FC}  FC = ${FC}
2085  # Fortran compiler  # Fortran compiler
2086  F90C = ${F90C}  F90C = ${F90C}
2087    # C compiler
2088    CC = ${CC}
2089  # Link editor  # Link editor
2090  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
2091    
2092  # Defines for CPP  # Defines for CPP
2093  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1432  CFLAGS = ${CFLAGS} Line 2108  CFLAGS = ${CFLAGS}
2108  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2109  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2110  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2111  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2112  # Name of the Mekfile  # Name of the Mekfile
2113  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2114    
# Line 1443  cat csrclist.inc      >> $MAKEFILE Line 2119  cat csrclist.inc      >> $MAKEFILE
2119  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
2120  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
2121  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2122  echo               >> $MAKEFILE  echo >> $MAKEFILE
2123  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2124  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2125  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2126    echo >> $MAKEFILE
2127    echo '.SUFFIXES:' >> $MAKEFILE
2128    echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2129  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
2130  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2131    
2132  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2133    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
2134  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2135  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2136          @echo Creating \$@ ...          @echo Creating \$@ ...
2137          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2138  depend:  depend:
2139          @make links          @make links
2140          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2141          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2142            -rm -f makedepend.out
2143    
2144    lib: libmitgcmuv.a
2145    
2146    libmitgcmuv.a: \$(OBJFILES)
2147            ar rcv libmitgcmuv.a \$(OBJFILES)
2148    
2149  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2150    
# Line 1474  output.txt: \$(EXECUTABLE) Line 2155  output.txt: \$(EXECUTABLE)
2155          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2156    
2157  clean:  clean:
2158          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2159  Clean:  Clean:
2160          @make clean          @make clean
2161          @make cleanlinks          @make cleanlinks
# Line 1485  CLEAN: Line 2166  CLEAN:
2166          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2167          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2168          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2169          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2170    
2171  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2172  makefile:  makefile:
2173          $THIS_SCRIPT $@          $THIS_SCRIPT $G2ARGS
2174  cleanlinks:  cleanlinks:
2175          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2176    
2177  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2178  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2179          @echo Creating \$@ ...          @echo Creating \$@ ...
2180          @\$(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) > \$@
2181  AD_CONFIG.h:  AD_CONFIG.h:
2182          @echo Creating \$@ ...          @echo Creating \$@ ...
2183          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@
2184  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2185          @echo Creating \$@ ...          @echo Creating \$@ ...
2186          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2187    
2188  # The normal chain of rules is (  .F - .f - .o  )  BUILD_INFO.h:
2189  .F.f:          @echo Creating \$@ ...
2190    EOF
2191    
2192    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2193    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2194    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2195    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2196    
2197    cat >>$MAKEFILE <<EOF
2198    
2199    # The normal chain of rules is (  .F - .$FS - .o  )
2200    
2201    ## This nullifies any default implicit rules concerning these two file types:
2202    ## %.o : %.F
2203    
2204    .F.$FS:
2205          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2206  .f.o:  .$FS.o:
2207          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2208  .F90.f90:  .F90.$FS90:
2209          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2210  .f90.o:  .$FS90.o:
2211          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2212  .c.o:  .c.o:
2213          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
2214    
2215  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2216  .F.p:  .F.p:
2217          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2218  .p.f:  .p.$FS:
2219          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2220    
2221  #=========================================  #=========================================
# Line 1546  done Line 2242  done
2242    
2243  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2244  echo >> $MAKEFILE  echo >> $MAKEFILE
2245  echo -n "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2246  AD_FILES=`cat ad_files`  AD_FILES=`cat ad_files`
2247  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2248      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2249      echo -n " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2250  done  done
2251  echo >> $MAKEFILE  echo >> $MAKEFILE
2252  rm -f ad_files  rm -f ad_files
# Line 1559  cat >>$MAKEFILE <<EOF Line 2255  cat >>$MAKEFILE <<EOF
2255    
2256  # ... AD ...  # ... AD ...
2257  adall: ad_taf  adall: ad_taf
2258  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2259  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2260    
2261  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2262          @\$(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
2263          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
2264          -rm -f ad_config.template          -rm -f ad_config.template
2265          @make \$(F77FILES)          @make \$(F77FILES)
2266          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2267          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2268    
2269  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2270          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2271          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
2272    
2273  adtafonly:  adtafonly:
2274          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2275          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
2276    
2277  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2278          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2279    
2280  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2281          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2282          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
2283    
2284  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2285          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2286    
2287    adonlyfwd:
2288            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2289    
2290    adtrick:
2291            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2292    
2293  # ... FTL ...  # ... FTL ...
2294  ftlall: ftl_taf  ftlall: ftl_taf
2295  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2296  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2297    
2298  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2299          @\$(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
2300          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
2301          -rm -f ftl_config.template          -rm -f ftl_config.template
2302          @make \$(F77FILES)          @make \$(F77FILES)
2303          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2304          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2305    
2306  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2307          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2308          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
2309    
2310  ftltafonly:  ftltafonly:
2311          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2312          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
2313    
2314  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2315          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2316    
2317  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2318          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2319          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
2320    
2321  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2322          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2323    
2324    
2325  # ... SVD ...  # ... SVD ...
2326  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2327  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2328            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2329    svdall: svd_touch svd_taf
2330    
2331  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2332          \$(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)
2333    
2334            @echo "--->>> Only COMPILE svd code! <<<---"
2335            @echo "--->>> Assumes you previously <<<---"
2336            @echo "--->>> did make svdtaf        <<<---"
2337    
2338    svd_touch:
2339            @echo "--->>> Only COMPILE svd code! <<<---"
2340            @echo "--->>> Assumes you previously <<<---"
2341            @echo "--->>> did make svdtaf        <<<---"
2342            touch ad_taf_output.$FS ftl_taf_output.$FS
2343            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2344            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2345            @$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
2346            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2347            -rm -f ftl_config.template
2348    
2349  #=========================================  #=========================================
2350    
# Line 1644  for i in $KPPFILES ; do Line 2361  for i in $KPPFILES ; do
2361      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2362          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2363      fi      fi
2364      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
2365  done  done
2366    
2367  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1654  for i in $NOOPTFILES ; do Line 2371  for i in $NOOPTFILES ; do
2371      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2372          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2373      fi      fi
2374      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
2375      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2376  done  done
2377    
# Line 1668  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 2385  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
2385  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
2386    
2387  # Create special header files  # Create special header files
2388  $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"  $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 > $PACKAGES_DOT_H".tmp"
2389  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
2390      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2391  else  else
2392      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
2393      RETVAL=$?      RETVAL=$?
2394      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
2395          rm -f $PACKAGES_DOT_H".tmp"          rm -f $PACKAGES_DOT_H".tmp"
# Line 1682  else Line 2399  else
2399      fi      fi
2400  fi  fi
2401  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
2402      $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h      $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h
2403  fi  fi
2404    
2405    
2406  #  Write the "state" for future records  #  Write the "state" for future records
2407  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
2408      echo -n "" > genmake_state      printf "" > genmake_state
2409      for i in $gm_state ; do      for i in $gm_state ; do
2410          t1="t2=\$$i"          t1="t2=\$$i"
2411          eval $t1          eval $t1

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.136

  ViewVC Help
Powered by ViewVC 1.1.22