The Fundamental of GNU CC++ Fortran Compiler

Document Sample
The Fundamental of GNU CC++ Fortran Compiler Powered By Docstoc
					    GNU C/C++      Fortran


     hmli@ustc.edu.cn, lihm@qibebt.ac.cn



                2009   12




(      )         GNU                   2009   12   1 / 39
1   GNU C/C++         Fortran

2   GNU C/C++

3   GNU Fortran

4                     gdb

5




        (         )             GNU   2009   12   2 / 39
GNU C/C++                Fortran

GNU C/C++ Fortran

   GNU           C C++                                  gcc   g++
      Fortran 77  9x                              g77    gfortran
         gfortran                  Fortran 77
         g77              Fortran 9x


   HP RX2600                   GNU                 3
   Fortran 9x
                        gfortran
                                          4.1.2




     (              )              GNU                    2009   12   3 / 39
1   GNU C/C++         Fortran

2   GNU C/C++

3   GNU Fortran

4                     gdb

5




        (         )             GNU   2009   12   4 / 39
C         gcc [options] file1 [ file2   ...]
C++          g++ [options] file1 [ file2       ...]


[ ]




      (           )           GNU                   2009   12   5 / 39
    filename.c      C
    filename.C
    filename.CC
    filename.cc    C++
    filename.cpp
    filename.cxx
    filename.a
    filename.so
    filename.i
    filename.o
    filename.s

(        )         GNU   2009   12   6 / 39
    filename.i              -p
    filename.o         -c
    filename.s         -s
       a.out




(        )      GNU             2009   12   7 / 39
(   )   GNU   2009   12   8 / 39
                           I
-x language
     language
         c c-header c-cpp-output
         c++ c++-header c++-cpp-output
         objective-c objective-c-header objective-c-cpp-output
         objective-c++ objective-c++-header objective-c++-cpp-output
         assembler assembler-with-cpp
         ada
         f95 f95-cpp-input
         java
         treelang
     language       none

-c                             .o
-o file
-v
     (          )              GNU                       2009   12     9 / 39
                   II
-###

–help
–target-help
–version




   (           )        GNU   2009   12   10 / 39
C

    -ansi C                       ISO C90   C++
       ISO C++              GNU
    -std=
    c89 iso9899:1990 iso9899:199409 c99 c9x
    iso9899:1999 iso9899:199x gnu89 gnu99 gnu9x    c++98   gnu++
    -B                      C++               //
                             -C
    -c8x     -c89       C           C89
    -c9x     -c99       C           C99




         (          )         GNU             2009   12    11 / 39
-fsyntax-only
-w
-Wfatal-errors




     (      )    GNU   2009   12   12 / 39
-g
-ggdb        gbd




     (   )         GNU   2009   12   13 / 39
-O[level]         level
0 1 2 3 s




 (     )    GNU           2009   12   14 / 39
-C                C
-D name                name     1
-D name=def              name def
-U name                    name
-undef                GCC
-dD
-dI
-dM
-dN     -dD
-E         .c
-I<           >
-M       make
-MD        make               file.d file
-MM         make
-MMD          make               file.d    file

-P                           file.c                      file.i
     (      )          GNU                      2009   12       15 / 39
-pie
-s
-rdynamic
-static
-shared
     -fpic
-shared-libgcc                 libgcc
-static-libgcc               libgcc
-u <symbol>               symbol
-I<                   >
-l<          >                          libxyz.a    -lxyz
-L<           >
-B<       >



      (           )             GNU                2009   12   16 / 39
CPU

  -mtune=cpu-type                  CPU
  generic core2 k8 opteron
  -march=cpu-type                  CPU
  generic core2 k8 opteron
  -mieee-fp   -mno-ieee-fp               IEEE




      (       )              GNU         2009   12   17 / 39
-fpic
-fPIC
-fopenmp        OpenMP
-fpie   -fPIE    -fpic   -fPIC




   (        )            GNU     2009   12   18 / 39
      OpenMP

   C     yourprog.c                  yourprog
gcc −o yourprog yourprog.c
   C     yourprog.c                yourprog.o
gcc −c yourprog.c
       lapack    C      yourprog.c
yourprog
gcc −o yourprog −L/opt/lib −llapack yourprog.c
   C    yourprog.c            O3                        yourprog
gcc −O3 −static −o yourprog yourprog.c
  C++      yourprog.cpp                   yourprog
g++ −o yourprog yourprog.cpp
   OpenMP            C     yourprog-omp.c
yourprog-omp
gcc −o yourprog−omp −fopenmp yourprog.c

  (        )           GNU                       2009   12    19 / 39
1   GNU C/C++         Fortran

2   GNU C/C++

3   GNU Fortran

4                     gdb

5




        (         )             GNU   2009   12   20 / 39
4.x.y           gfortran [options] file1 [ file2      ...]
3.x.y           g77 [options] file1 [ file2   ...]


[ ]


              4.x.y    gfortran     3.x.y            g77




      (   )           GNU                          2009    12   21 / 39
    filename.a
    filename.f
    filename.for   Fortran   Fortran
    filename.ftn
    filename.i
    filename.fpp
    filename.FPP
    filename.F     Fortran      Fortran
    filename.FOR
    filename.FTN
    filename.f90   Fortran   Fortran
    filename.i90
    filename.F90   Fortran      Fortran
    filename.s
    filename.so
    filename.o




(            )       GNU                 2009   12   22 / 39
    filename.o            -c
    filename.so                   -shared       -c
    filename.mod         MODULE
    filename.s            -S
    a.out                   -c




(             )   GNU                  2009   12    23 / 39
    gfortran         gcc




(   )          GNU         2009   12   24 / 39
 Fortran
-ffree-form -ffixed-form
   Fortran 90                              Fortran 77

-fdefault-double-8         DOUBLE PRECISION          8
-fdefault-integer-8        INTEGER LOGICAL             8
-fdefault-real-8        REAL         8
-fno-backslash              (\)
-ffixed-line-length-<n>                               n
-ffree-line-length-<n>                              n
-fmax-identifier-length=<n>                              n
Fortran 95 200x                   31 65
-fimplicit-none
-fcray-pointer         Cray
-fopenmp           OpenMP
-std=<std>            Fortran      std      f95 f2003 legacy
-M<dir> -J<dir>
-fconvert=<conversion>                 Fortran
           native            swap                    big-endian
        little-endian                   big-endian
     little-endian
   (        )             GNU                       2009   12     25 / 39
-c                 .o
-o file
-v
-###

–help
–target-help
–version




     (         )   GNU   2009   12   26 / 39
-fsyntax-only
-w
-Wfatal-errors




     (      )    GNU   2009   12   27 / 39
-g
-ggdb        gbd




     (   )         GNU   2009   12   28 / 39
-O[level]         level
0 1 2 3 s




 (     )    GNU           2009   12   29 / 39
-C              C
-D name                name           1
-D name=def              name       def
-U name                  name
-undef              GCC
-dD
-dI
-dM
-dN     -dD
-E
-I<          >
-M       make
-MD        make              file.d file
-MM        make
-MMD        make                file.d     file

-P                          file.c                       file.i
     (     )          GNU                       2009   12       30 / 39
-pie
-s
-rdynamic
-static
-shared
           -fpic
-shared-libgcc           libgcc
-static-libgcc         libgcc
-u <symbol>             symbol

-I<                >
-l<        >                      libxyz.a           -lxyz

-L<          >
-B<      >

   (           )       GNU               2009   12    31 / 39
-mtune=cpu-type                  CPU
generic core2 k8 opteron
-march=cpu-type                  CPU
generic core2 k8 opteron
-mieee-fp   -mno-ieee-fp               IEEE




   (        )              GNU         2009   12   32 / 39
-fno-automatic
SAVE
-ff2c      g77   f2c
-fno-underscoring                               gfortran
g77    f2c
                          -ff2c
                                 -fno-underscoring
-funderscoring                                        Fortran

-fsecond-underscore        gfortran
                                               -fno-underscoring
                          -ff2c
-fpic
-fPIC
-fpie   -fPIE     -fpic   -fPIC

   (        )             GNU                        2009   12     33 / 39
      OpenMP

   Fortran 77     yourprog.for                    yourprog
gfortran −o yourprog yourprog.for
   Fortran 90     yourprog.f90                    yourprog
gfortran −o yourprog yourprog.f90
       lapack      Fortran 90      yourprog.f90
   yourprog
gfortran −o yourprog −L/opt/lib −llapack yourprog.f90
   Fortran 90     yourprog.f90                  yourprog.o
gfortran −c yourprog.f90
   Fortran 90     yourprog.f90             O3
yourprog
gfortran −O3 −static −o yourprog yourprog.f90
   OpenMP               Fortran 90     yourprog-omp.f90
            yourprog-omp
gfortran −o yourprog−omp −fopenmp yourprog.f90
  (         )           GNU                      2009   12   34 / 39
1   GNU C/C++         Fortran

2   GNU C/C++

3   GNU Fortran

4                     gdb

5




        (         )             GNU   2009   12   35 / 39
GNU                       gdb

GNU        gdb                  C/C++   Fortran
                     -g

  gdb [-help] [-nx] [-q] [-batch] [-cd=dir] [-f] [-b bps] [-tty=dev] [-s
  symfile] [-e prog] [-se prog] [-c core] [-x cmds] [-d dir] [prog
  [core—procID]]
  gdb [options] –args prog [arguments]




      (          )              GNU                       2009   12    36 / 39
gdb

      -b bps                                         /
      -batch                     -x FILE    .gdbinit
            0
      -c FILE, -core=FILE             core
      -cd=directory     directory
      -e FILE, -exec=FILE
      -h, -help
      -se=file         file
      -q, -quiet
      -tty=device          device
      –args
      -tui
      -write                     core
      -x FILE, -command=FILE               gbd
        (        )            GNU                        2009   12   37 / 39
          gdb

      gdb
gbb             help                                          man gdb
      break [file:]function              [file       ]       function
      run [arglist] [        arglist           ]
      bt                        stack
      print expr
      c
      next
      edit [file:]function
      list [file:]function
      step
      help [name]             [GDB name                ]   GDB
      quit             GDB

           (           )               GNU                        2009   12   38 / 39
    http://scc.ustc.edu.cn
    0551-3602248
    sccadmin@ustc.edu.cn

        http://124.16.151.186
        http://scc.qibebt.cas.cn
    0532-80662613
    scc@qibebt.ac.cn

    http://staff.ustc.edu.cn/~hmli/
    0532-80662613
    hmli@ustc.edu.cn lihm@qibebt.ac.cn




(    )            GNU                    2009   12   39 / 39