This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:compiling_tips_n_tricks [2013/07/19 09:46] kevin |
howto:compiling_tips_n_tricks [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 9: | Line 9: | ||
| > Many people write the first and last as C/ | > Many people write the first and last as C/ | ||
| - | The compilers found at the CHPC fall into three families: GCC, Intel and Sun Studio. | + | The compilers found at the CHPC fall into three families: GCC, Intel and [[guide: |
| > ' | > ' | ||
| - | >> There' | + | >> There' |
| ====Table of Compilers and their Command Names==== | ====Table of Compilers and their Command Names==== | ||
| Line 25: | Line 25: | ||
| <code bash> | <code bash> | ||
| - | you@login01: | + | gcc -o hello hello.c |
| </ | </ | ||
| Line 31: | Line 31: | ||
| <code bash> | <code bash> | ||
| - | you@login01: | + | ifort -o hello hello.f90 |
| </ | </ | ||
| - | |||
| - | By convention, there are variables that define the actual command invoked (see above) and which can be used in the shell, with make files and '' | ||
| ====Table of Compiler Variables==== | ====Table of Compiler Variables==== | ||
| + | |||
| + | By convention, there are variables that define the actual command invoked (see above) and which can be used in the shell, with make files and '' | ||
| ^ Variable ^ Compiler ^ Example | | ^ Variable ^ Compiler ^ Example | | ||
| Line 43: | Line 43: | ||
| ^ '' | ^ '' | ||
| - | > The last example shows that you can include the full path to a particular | + | > The last example shows that you can include the full path to a specific |
| Fortran comes in two main flavours, Fortran 77 and Fortran 90 (also called 9x since it includes Fortran 95). By default '' | Fortran comes in two main flavours, Fortran 77 and Fortran 90 (also called 9x since it includes Fortran 95). By default '' | ||
| Line 51: | Line 51: | ||
| ====Example==== | ====Example==== | ||
| - | When building an MPI library --- for example, OpenMPI --- one should | + | When building an MPI library --- for example, OpenMPI --- one should |
| | '' | | '' | ||
| Line 58: | Line 58: | ||
| | '' | | '' | ||
| - | When building | + | When building |
| - | < | + | < |
| ./configure --prefix=$HOME/ | ./configure --prefix=$HOME/ | ||
| CC=icc CXX=icpc F77=ifort FC=ifort \ | CC=icc CXX=icpc F77=ifort FC=ifort \ | ||
| Line 68: | Line 68: | ||
| > The above example uses Intel compilers and also builds in InfiniBand support. | > The above example uses Intel compilers and also builds in InfiniBand support. | ||
| + | |||
| + | |||
| + | =====Which Compilers am I Using?===== | ||
| + | |||
| + | That's a very good question. | ||
| + | |||
| + | ====Table of Compiler Commands for Version==== | ||
| + | |||
| + | | Language ^ GCC | ||
| + | ^ C | '' | ||
| + | ^ Fortran | ||
| + | ^ C++ | '' | ||
| + | |||
| + | The '' | ||
| + | |||
| + | <code bash> | ||
| + | login01:~$ icc -v | ||
| + | Version 12.0.0 | ||
| + | </ | ||
| + | |||
| + | For the GCC compilers, '' | ||
| + | |||
| + | < | ||
| + | login01:~$ gfortran -v | ||
| + | Using built-in specs. | ||
| + | Target: x86_64-redhat-linux | ||
| + | Configured with: ../ | ||
| + | --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib | ||
| + | --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable- | ||
| + | languages=c, | ||
| + | --disable-plugin --with-java-home=/ | ||
| + | --host=x86_64-redhat-linux | ||
| + | Thread model: posix | ||
| + | gcc version 4.1.2 20080704 (Red Hat 4.1.2-52) | ||
| + | </ | ||
| + | |||
| + | Which is why GCC compilers provide the long option '' | ||
| + | |||
| + | < | ||
| + | login01:~$ gfortran --version | ||
| + | GNU Fortran (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52) | ||
| + | Copyright (C) 2007 Free Software Foundation, Inc. | ||
| + | |||
| + | GNU Fortran comes with NO WARRANTY, to the extent permitted by law. | ||
| + | You may redistribute copies of GNU Fortran | ||
| + | under the terms of the GNU General Public License. | ||
| + | For more information about these matters, see the file named COPYING | ||
| + | |||
| + | </ | ||
| + | |||
| + | > You also get a copyright message but the version is in the first line. | ||
| + | > < | ||
| + | GNU Fortran (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)</ | ||
| + | |||
| + | Using a different, newer, version of GCC is easy through the use of GNU [[guide: | ||
| + | |||
| + | <code bash> | ||
| + | login01:~$ module load gcc | ||
| + | login01:~$ gfortran --version | head -1 | ||
| + | GNU Fortran (GCC) 4.7.2 | ||
| + | </ | ||
| + | |||