1 / 17

Compiling Environment – ecgate

Compiling Environment – ecgate. Dominique Lucas User Support. Content. Introduction Fortran Compiler Compiler Options Word Lengths Fortran I/O Linking Libraries Debugging Profiling Practical session. Introduction. Why compiling at ECMWF?

leala
Download Presentation

Compiling Environment – ecgate

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Compiling Environment – ecgate Dominique Lucas User Support

  2. Content • Introduction • Fortran Compiler • Compiler Options • Word Lengths • Fortran I/O • Linking • Libraries • Debugging • Profiling • Practical session

  3. Introduction • Why compiling at ECMWF? • decoding of (MARS) data • model runs • Which platforms available? • Unix IBM server (ecgate) • IBM Supercomputers (hpca) • Which compilers? • Fortran (77/90/95) • C/C++ • Which platform to use? • High Performance Computing Facility (HPCF) for computing intensive work, including any // work. • IBM server for decoding or I/O bound work.

  4. Compilers • IBM compilers: • xlf[90|95] for Fortran • xlc for C • xlC for C++ • Which version do I use? • lslpp –l xlf* • lslpp –l xlC* • How to select a different version of a Compiler? • If a different version is available, this can be set with a ECMWF local utility called “use”, e.g.: • use xlf_8113

  5. Compilers • File suffixes for fortran • “.f” or “.F” to run the C preprocessor • “.f90” with -qsuffix=f=f90 • .F90 with –qsuffix=f=f90:cpp=F90

  6. Compilers • Common file suffixes and files • .o : object file • .a : archive file (library) • .so: share object (library) • .s: assembler listing • .list: source listing • .mod: fortran 90 module files • a.out: default name of executable

  7. Fortran compiler • Fortran source code format • Fixed with xlf • Free with xlf[90|95] • Format can be given with options “–qfixed” or “-qfree” • A few examples • $ xlf prog.f # fixed f77 • $ xlf prog.F # fixed f77 via cpp • $ xlf90 –qsuffix=f=f90 prog.f90 # free f90 • $ xlf90 prog.F # free f90 via cpp

  8. Fortran Compiler options • Setting options – given by increasing precedence • In the configuration file – system wide • less /etc/xlf.cfg • At the command line – used for all the file • xlf –qfixed prog.f • As a directive in the source code – for the next unit. • head prog.f @PROCESS FIXED

  9. Fortran Compiler common options • Fortran 77 / f90 • -c compilation only, no linking • -qsource listing • -qrealsize=8 64bit real variables • -O optimisation • -g debugging • -v verbose • -help display usage • Defaults: underscores (-qextname) and 32-bit addressing mode (-q32) • Well over 100 options. See man page for full list of options.

  10. Word lengths – precision • 32bit reals and integer by default • The option –qrealsize=8 promotes real variables to 64bit • Integer*8 and 128bit floating point computation available and slightly slower than integer*4 or real*8 computation. • When using a library, check its precision, e.g. for EMOSLIB.

  11. Fortran I/O • Unit numbers: • Units 0, 5 and 6 reserved, respectively for STD error, input and output. • Connecting files to Units: • open (1,file="data",...) • ln -s data fort.1 • Fortran record types: • formatted/unformatted • read (1)length • list-directed • write(*,*)'lenght=',length • Namelist • read(5,NML=name_l)

  12. Fortran I/O – data representation • Access method: • sequential access • direct access • record length - in bytes • IEEE format - big-endian • real*4 • bit 31: sign • bits 30-23: exponent • bits 22-0: mantissa • real*8 • bit 63: sign • bits 62-52: exponent • bits 51-0: mantissa

  13. Linking • Use xlf to link, eg. • $ xlf -o prog prog.f $EMOSLIB duplicated entries. • Static vs. dynamic linking: • Option –bdynamic or –bstatic • Default: -bdynamic • Loadmap useful to identify duplicated entries or unresolved symbols • $ xlf –bloadmap:map –o prog prog.f $EMOSLIB • $ less map

  14. Building libraries • Static and shared/dynamic libraries • Use "ar" to build static libraries, eg. • $ ar -vr libmy.a *.o • Use “xlc" to build shared/dynamic libraries, • $ cc -G *.o –o libmy.a • $ xlf -o prog prog.f -L. –lmy • $ export LIBPATH=${LIBPATH}:. • $ ./prog • Alternatively, see http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/genprogc/create_shared_lib.htm#HDRA144C1671

  15. Debugging • checking: • argument checking: -qextchk • xlf –qextchk prog.f –o prog checking done at compilation/linking • array bounds checking: -C • xlf –C prog.f –o prog • ./prog checking done at runtime • undefined reference checking • xlf –qinitauto=FF –qflttrap prog.f –o prog checking done at runtime

  16. Debugging – floating point exceptions • nothing generated on floating point exception. • Floating point trapping • % xlf –qflttrap=overflow:invalid:zerodivide:enable \ –qsigtrap prog.f –o prog • % ./prog • ... • interactive window based debugger: - totalview • Core files – how to get a traceback • % dbx ./prog core <<eof where eof

  17. Profiling - tuning • timex - command timer • $ timex [-ops] a.out • -O and other options at compilation for faster execution. • See man page. • other AIX applications, like prof, gprof • $ xlf –p prog.f • $ a.out • $ prof

More Related