user/pages/06.compilers/01.cray/docs.en.md
56bd334a
 ---
 title: 'Cray Compiler'
 taxonomy:
     category:
         - docs
 external_links:
     process: true
     no_follow: true
     target: _blank
     mode: active
 ---
 
 [toc]
 
 
 ## Environment Settings{#enviroment}
 
 
 ### Software Version and System Requirements{#version}
 
cea98d4f
 Version  |   System A     |  System B  |  System C  |  Notes                     
 --------  |  -----------  |  --------  |  --------  |  ---------
7b02fd0d
 9.1.3 | +  | +  | +  | Installed in March 2020 (Clang 9 based)
d26469da
 9.1.3 classic | +  | +  | +  | Installed in March 2020
 9.0.2 | +  | +  | +  | Installed in October 2019 (Clang 9 based)
 9.0.2 classic | +  | +  | +  | Installed in October 2019
 8.7.9  | + (default) | + (default)  | + (default)   | Installed in March 2019
e63bae92
 8.7.6  | +  | +   | +    | Installed in Dedember 2018
e7d5a583
 8.6.5  | +  | +   | +    | Installed in March 2018
cea98d4f
 8.6.3  | +  | ―  | ―  | Installed in December 2017
 8.6.1  | +  | ―  | ―  | Installed in August 2017
 8.5.8  | +  | ―  | ―  | Installed in March 2017
 8.5.5  | +  | +   | +    | Installed in Dedember 2016
 8.5.2  | +  | ―  | ―  | Installed in October 2016
56bd334a
 
 \+ : Available for use  
 ― : Not available for use
 
 
 ### Setting Up System{#modules}
 
 Version           |  Modulefile Name
 ------------------| ---------------
7b02fd0d
 9.1.3|cce/9.1.3
 9.1.3 classic|cce/9.1.3-classic
d4ea2f61
 9.0.2 |cce/9.0.2
 9.0.2 classic|cce/9.0.2-classic
e7d5a583
 8.7.9 |cce/8.7.9
e63bae92
 8.7.6 |cce/8.7.6
cea98d4f
 8.6.5 |cce/8.6.5
4fd2f26e
 8.6.3             |cce/8.6.3
25253470
 8.6.1             |cce/8.6.1
cea98d4f
 8.5.8 |cce/8.5.8
 8.5.5 |cce/8.5.5
efc0b464
 8.5.2             |cce/8.5.2
56bd334a
 
 When logging in to the System A, Cray Compiler is set as default:
 
 
 ```nohighlight
 $ module list
 Currently Loaded Modulefiles:
   x)  cce/8.3.0   x) PrgEnv-cray/5.2.14
 ```
 
 
cea98d4f
 When logging in to the System B,C, Intel Compiler is set as default. Thus, you need to switch from the Intel Compiler to the Cray Compiler as below: 
56bd334a
 
 
 ```nohighlight
 $ module switch PrgEnv-intel PrgEnv-cray
 ```
 
 
 The default version of Intel Compiler is as listed above.  
 To switch the version of Cray Compiler to another, execute the module command with the PrgEnv-cray loaded as below:
 
 
 ```nohighlight
 $ module switch cce/8.0.4 cce/8.0.6
 ```
 
 
 To automatically execute a command when logging in to the System, specify such command in the login shell startup-file by following [Setting Up System](/config#login_shell).   
 For details on the module command, see [Modules](/config/modules).
 
d4ea2f61
 ### Cray Compiler moves to be Clang-based (version 9 and later){#ver9}
 
 The architecture of Cray C Compiler 9 and Cray C++ Compiler 9 has moved from proprietary to Clang-based.
 The compile options of Clang-based version are much different from the previous versions'.
 Major options are shown in [Compile Options](#option_clang).
 Note that Cray Fortran Compiler 9 continues to be the proprietary-based and its options are same as the previous versions.
 
 At version 9, the proprietary-based Cray C Compiler 9 and Cray C++ Compiler 9 are also provided, called the classic version.
 The compile options of classic version are same as the previous versions.
 The module name of classic version is like that: **cce/(version name)\_classic.**
 
 When you switch to Cray Compiler 9, the Clang-based version is loaded first.
 If you want to use the classic version, switch the loaded cce module from Clang-based to classic version.
 
 ### Major changes of Cray Compiler 9 {#change}
 
 See the below document. (Japanese version only)
 
 [CDT 19.09](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/CDT_19.09.pdf)
56bd334a
 
55b8423d
 ### Notice for using version 8.6 or later{#caution}
 
 #### for 8.6.1
25253470
 
 Cray Compiler 8.6.1 is not available by merely switching the version of current cce module to 8.6.1.
 
d4ea2f61
 craype and cray-mpich (in system BC, cray-impi), and cray-libsci also need to be switched as shown below.
25253470
 
 ```nohighlight
55b8423d
 $ module switch craype/2.5.12
25253470
 $ module switch cray-mpich/7.6.0
d4ea2f61
 $ module switch cray-libsci/17.06.1
25253470
 ```
 
 [PrgEnv](/config/modules#prgenv) command is useful as switching those modules by one command.
 
 ```nohighlight
 $ PrgEnv cce 8.6.1
 ```
 
061ec015
 #### for 8.6.3 and later
 
d4ea2f61
 The craype and cray-mpich (in system BC, cray-impi), and cray-libsci also need to be switched as same as the case of 8.6.1.
061ec015
 [PrgEnv](/config/modules#prgenv) command is useful as switching those modules.
e63bae92
 (Sorry, this command is available only in system A.)
061ec015
 
56bd334a
 ## How to Compile{#usage}
 
 
 ### Compile Commands{#command}
 
 Language |  Commands | Operands                                   
 --------- | -------- | -------------------------------------------
  Fortran |  ftn     |  ftn [sequence_of_options] sequence_of_files
  C |        cc    |    cc [sequence_of_options] sequence_of_files 
  C++ |      CC     |   CC [sequence_of_options] sequence_of_files 
 
 
d4ea2f61
 ### Compile Options (classic version){#option}
56bd334a
 
d4ea2f61
 #### **Main options (e.g., parallelization, optimization)**
56bd334a
 
 Option                                 |  Purpose                                                                                                    
     --------------------------------------- | -----------------------------------------------------------------------------------------------------------
     -o _FILENAME_ | Specifies the name of the object file.                                                                     
     -h omp                                  |  Enables compiler recognition of OpenMP directives. (Enables by default.)                                  
     -h noomp                                |  Disables compiler recognition of OpenMP directives.                                                       
     -h autothread                           | Enables autothreading.                                                                                     
     -O0/-O1/-O2/-O3                        |  Performs general optimization at four levels. (The default is 2.)                                          
     -h msgs                                 | Displays optimization messages.                                                                            
     -h negmsgs                              | Displays messages to explain why optimizations did not occur in a given instance.                          
     -h add_paren                            | Performs a calculation in order from left to right when sequencing an operation by operators; +, -, and *. 
     -h pic                         | Compiles codes using more than 2GB of static memory. (use -dynamic together)
     -dynamic                       | Links libraries dynamically.
 -g                                      |  Generates debug information.                                                                              
 
 
 
d4ea2f61
 #### **Fortran language options**
56bd334a
 
 
 Option         |  Purpose                                                                                                                                           
     --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------
     -ra             | Generates a report.                                                                                                                               
     -m2             | Displays all warning messages.                                                                                                                    
     -eI             | Considers that using an undefined variable is an error.                                                                                           
     -Rb             | Defines an array out of bounds error.                                                                                                             
     -en             | Displays information on non-standard functions.                                                                                                   
     -e0             | Initializes all undefined local stack variables to 0. If a user variable is of type character, it is initialized to NUL.
     -ez             | Initializes to 0 when allocating memory dynamically by an ALLOCATE statement.                                           
     -f fixed       |  Specifies that Fortran source programs are written in fixed source form.                                                                          
     -f free        |  Specifies that Fortran source programs are written in free source form.                                                                           
     -em            |  Enables modules.                                                                                                                                  
     -h byteswapio   | Supports the big-endian file.                                                                                                                     
     -ev             | Supports when the total number of local variable within subroutine exceeds 2GB.                                                                   
     -G1/-G2/-Gfast |  Generates debug information with optimization.                                                                        
 
 
d4ea2f61
 #### **C/C++ language options**
56bd334a
 
 
 Option   |  Purpose                                              
     --------- | -----------------------------------------------------
     -h list=a | Generates a report.                                  
     -h zero   | Initializes all undefined local stack variables to 0.
 
 
d4ea2f61
 ### Compile Options (Clang-based C and C++){#option_clang}
 
 **The below options are of Clang, so the details of function of options may differ from the classics'.**
 
 #### Main options (e.g., parallelization, optimization)
 
 |Option |Purpose|
 |-|-|
 |-o FILENAME |Specifies the name of the object file.|
 |-fopenmp |Enables compiler recognition of OpenMP directives. (**Disables by default.**)|
 |-O0/-O1/-O2/-O3 |Performs general optimization at four levels(**-O0 by default**)  Specify "**-O3 -ffast-math**" to be equivalent to **-O3** of classic version. |
 |-ffast-math | Tolerant for minute errors of floating point calculation to perform aggressive optimizations.|
 |-fsave-optimization-record |Saves optimization messages to a file.|
 |-mcmodel=medium|Compiles codes using more than 2GB of static memory. (use -dynamic together)|
 |-dynamic|Links libraries dynamically.(**Enables by default.**)|
 |-static|Links libraries statically.|
 |-g | 	Generates debug information.|
 |-Wall|Displays warning messages.|
 
 
 ### Compile Options (Clang-based Fortran){#option_flang}
 
 Clang Cray Fortran Compiler 9 continues to be the proprietary-based (not Flang) and its options are same as [Compile Options (classic version)](#option).
56bd334a
 
 
 ## Examples of Compiling{#sample}
 
 
 ### Non-Parallelized Program{#serial}
 
 
 
 ```nohighlight
 $ ftn test.f90           # For Fortran
 ```
 
 ```nohighlight
 $ cc test.c              # For C
 ```
 
 ```nohighlight
 $ CC test.cpp            # For C++
 ```
 
 ```nohighlight
 $ tssrun ./a.out         # Executing
 ```
 
 
 
d4ea2f61
 ### Using Auto-Parallelization (classic version only){#auto_parallel}
56bd334a
 
 ```nohighlight
 $ ftn -h autothread -h noomp test.f90
 ```
 
 ```nohighlight
 $ tssrun -A p=1:t=4:c=4 ./a.out # Executing with the number of parallels = 4
 ```
 
 
 
 ### Using OpenMP{#openmp}
 
d4ea2f61
 * classic version
56bd334a
 ```nohighlight
 $ cc -h omp test.c
 ```
 
d4ea2f61
 * Clang version
 ```nohighlight
 $ cc -fopenmp test.c
 ```
 
56bd334a
 ```nohighlight
 $ tssrun -A p=1:t=8:c=8 ./a.out # Executing with the number of parallels = 8
 ```
 
 
 
 ## Compiler Messages{#compile_message}
 
 
 ###  Fortran{#fortran_message}
 
 Cray Fortran compiler outputs messages, that indicate important information or programming error, in the format below.
 
 
 ```nohighlight
 ftn-XXX crayftn: YYY MAIN, File = File name, Line = Line number, Colum = Column number
 Message body
 ```
 
 
 * XXX : Message serial number
 * YYY : Type of message(ERROR/WARNING/CAUTION/NOTE/COMMENT/ANSI)
 
 
 #### Examples
 
 
 ```nohighlight
 ftn-1197 crayftn: ERROR MAIN, File = test.f90, Line = 27, Column = 28
   The array subscript for dimension 2 does not fall within the defined range.
 ```
 
 
 
 ###  C/C++{#c_message}
 
d4ea2f61
 #### classic version
 
56bd334a
 Cray C/C++ Compiler outputs messages in the following format when indicating important information or programming errors: 
 
 
 ```nohighlight
 CC-XXX craycc: YYY File = File name, Line = Line number
 Message body
 ```
 
 
 * XXX : Message serial number
 * YYY : Type of message (ERROR/WARNING/CAUTION/NOTE/COMMENT)
 
 
d4ea2f61
 * Examples
56bd334a
 
 
 ```nohighlight
 CC-175 craycc: WARNING File = test.c, Line = 27
   The indicated subscript is out of range.
 ```
 
 
 
 ### Checking Message Details{#message_detail}
 
 Use the explain command to see details of the message that indicate when compiling.
 
 
 ```nohighlight
 $ explain ftn-XXX   (Fortran)
 $ explain CC-XXX   (C/C++)
 ```
 
 
 
 #### Examples
 
 
 ```nohighlight
 $ explain ftn-1197
 Error: The array subscript for dimension %d does not fall within the defined range.
 An array reference was encountered where a subscript was out of bounds for
 the array.  (The rest is omitted.)
 ```
 
 
 
 ### FAQs{#faq}
 
 * **Q-1:** An error like below occurs when compiling.
 
 
     ```nohighlight
     sample.f90:32: relocation truncated to fit: R_X86_64_32S against `.bss'
     sample.f90:33: additional relocation overflows omitted from the output
     ```
 
 
 * **A-1:** This message indicates that the memory usage of the program may exceed 2GB. Please specify the -h pic -dynamic option when compiling.  
 
 
 * **Q-2:** The following error occurs when compiling.
 
 
     ```nohighlight
     sample.s:837: Error: 0x9ab5c0f0 out range of signed 32bit displacement
     ```
 
 
 * **A-2:** This message indicates that the memory usage of local variable within the Fortran subroutine may exceed 2GB. Please specify the -ev option when compiling.  
 
 
 * **Q-3:** The following error occurs when writing the CONVERT specifier in the OPEN statement with Cray Fortran.
 
 
     ```nohighlight
     ftn-73 crayftn: ERROR MAIN, File = sample.f90, Line = 6, Column = 30
       This control item specifier is not allowed for this I/O statement.
     ```
 
 
 * **A-3:** The CONVERT specifier in OPEN statement does not exist in Fortran standards, and is not supported by Cray Fortran compiler. Thus both file formats(big-endian and little-endian) cannot be loaded in the same program by Cray Compiler.  
 
 
 * **Q-4:** The following error occurs when executing.
 
 
     ```nohighlight
     lib-4211 : UNRECOVERABLE library error
       A WRITE operation tried to write a record that was too long.
     Encountered during a sequential formatted WRITE to unit 11
     Fortran unit 11 is connected to a sequential formatted text file: "fort.11"
      Current format:  1000 FORMAT (1000(f7.5,1x))
     ```
 
 
 
 
 * **A-4:** This error occurs because it sets 1024 characters per line of output restriction by default in the Cray Fortran compiler. Please specify the number of characters per line (e.g., recl=2048) by using the RECL specifier in the OPEN statement.
 
 
 
 
 * **Q-5:** The following error occurs when executing an MPI program including “MPI_LONG_DOUBLE”.
 
 
     ```nohighlight
     MPI_Irecv(110): Null Datatype pointer
     ```
 
 
 * **A-5:** Cray Compiler does not support “MPI_LONG_DOUBLE”, please use “MPI_DOUBLE”. When using MPI in the System A, Intel Compiler (PrgEnv-intel) and GNU compiler (PrgEnv-gnu) support “MPI_LONG_DOUBLE”.
 
 
 ## Available Libraries{#library}
 
 
 ### MPI Library{#mpi_library}
 <!--
 [Cray MPI library](/compilers/craympi) is available in the System A and E. For details on how to compile, link, and run MPI programs, see [Cray MPI Library](/compilers/craympi).
 -->
 
cea98d4f
 Library  |  System A | System B,C                                                    
 ----------------------------------------  |  --------  |  --------  
 [Cray MPI library](/compilers/craympi)   | +        | ―         
 Cray IntelMPI library (wrapper for cray env.)   | ―        | +      
56bd334a
 <!--
 [MVAPICH2](/compilers/mvapich2) | ―        | +        | ―        
 -->
 
 
 
 ### Numerical Library{#numerical_library}
 
cea98d4f
 The following numerical libraries are available when using Cray Compiler in the System A,B,C. For details on how to use each library, see each library’s page.
56bd334a
 
cea98d4f
 Library                                  |  System A | System B,C 
 ---------------------------------------- | -------- | -------- 
 [Cray LibSci Library](/compilers/craylibsci)   | +        | +      
 [IMSL Library](/compilers/imsl)   | ―        | AU     
56bd334a
 
 \+: Available for all users  
 AU: Available for academic users only  
 ― : Not available for use 
 
 
05072d57
 ### Available combinations of modules{#combi}
 
 There are restrictions for available combinations of Cray compilers and libraries.
 The following combinations of Cray compiler modules and Cray MPICH modules, and Cray compiler modules and Cray LibSci modules, can be loaded at the same time.
 
 
 * cce and cray-mpich
 
 |mpi\cce|8.4.6|8.5.2|8.5.5|8.5.8|8.6.1|8.6.3|8.6.5|8.7.6|8.7.9|
 |-|-|-|-|-|-|-|-|-|-|
 |7.3.3|〇|x|x|x|x|x|x|x|x|
 |7.4.2|x|〇|〇|〇|x|x|x|x|x|
 |7.5.0|x|〇|〇|〇|x|x|x|x|x|
 |7.5.3|x|〇|〇|〇|x|x|x|x|x|
 |7.6.0|x|x|x|x|〇|〇|〇|〇|〇|
 |7.6.3|x|x|x|x|〇|〇|〇|〇|〇|
 |7.7.0|x|x|x|x|〇|〇|〇|〇|〇|
 |7.7.3|x|x|x|x|〇|〇|〇|〇|〇|
 |7.7.6|x|x|x|x|〇|〇|〇|〇|〇|
 
 
 * cce and cray-libsci
 
 |libsci\cce|8.4.6|8.5.2|8.5.5|8.5.8|8.6.1|8.6.3|8.6.5|8.7.6|8.7.9|
 |-|-|-|-|-|-|-|-|-|-|
 |16.03.1|〇|〇|〇|〇|〇|〇|〇|〇|〇|
 |16.07.1|x|〇|〇|〇|〇|〇|〇|〇|〇|
 |16.11.1|x|〇|〇|〇|〇|〇|〇|〇|〇|
 |16.11.1|x|〇|〇|〇|〇|〇|〇|〇|〇|
 |17.06.1|x|x|x|x|〇|〇|〇|〇|〇|
 |17.09.1|x|x|x|x|〇|〇|〇|〇|〇|
 |18.03.1|x|x|x|x|〇|〇|〇|〇|〇|
 |18.07.1|x|x|x|x|〇|〇|〇|〇|〇|
 |19.02.1|x|x|x|x|〇|〇|〇|〇|〇|
 
 If you load modules excluding the above combinations, you cannot compile your program with an error like the following.
 
 ```nohighlight
 Error:
 cray-mpich 7.7.6 is not compatible with cce 8.5.8.
 Either switch to cce/8.6.0 or later, or switch to cray-mpich earlier than 7.6.0.
 ```
 
 
56bd334a
 ## Manuals{#manual}
 
 
 ### Version 8.5{#ver8_5}
 
e406ceae
 * [Cray Fortran Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_Fortran_Reference_Manual_S-3901_85.pdf)
 * [Cray C and C++ Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_C_and_Cplusplus_Reference_Manual_S-2179_85.pdf)
56bd334a
 
ae6319e2
 ### Version 8.6{#ver8_6}
 
 * [Cray Fortran Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_Fortran_Reference_Manual_S-3901_86.pdf)
 * [Cray C and C++ Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_C_and_Cplusplus_Reference_Manual_S-2179_86.pdf)
 
fe6960c0
 ### Version 8.7{#ver8_7}
 * [Cray Fortran Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_Fortran_Reference_Manual_S-3901_87.pdf)
 * [Cray C and C++ Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_C_and_C++_Reference_Manual_S-2179_87.pdf)
 
d4ea2f61
 ### Version 9.0{#ver9_0}
 * [Cray Fortran Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_Fortran_Reference_Manual_S-3901_90.pdf)
 * [Cray Classic C and C++ Reference Manual](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_Crassic_C_and_C++_Reference_Manual_S-2179_90.pdf)
 * [Clang Compiler User's Manual](https://clang.llvm.org/docs/UsersManual.html)
 
 
56bd334a
 ### CrayDoc{#craydoc}
 
 * [Cray XE and Cray XK System Documentation](http://docs.cray.com/cgi-bin/craydoc.cgi?mode=SiteMap;f=xe_sitemap)
 * [Cray XC System Documentation](http://docs.cray.com/cgi-bin/craydoc.cgi?mode=SiteMap;f=xc_sitemap)
 
 
 ## Release Notes{#release_notes}
 
 * [CCE 8.2.2](https://web.kudpc.kyoto-u.ac.jp/release/cray/S-9407-1312.pdf)
 * [CCE 8.3.0](https://web.kudpc.kyoto-u.ac.jp/release/cray/S-5212-83.pdf)
 * [CCE 8.4.0](https://web.kudpc.kyoto-u.ac.jp/release/cray/S-5212-84.pdf)
e406ceae
 * [CCE 8.5](https://web.kudpc.kyoto-u.ac.jp/Cray_Manual/Cray_Compiling_Environment_Release_Overview_and_Installation_Guide_85.pdf)
ca3976c9
 
 ### 8.6 and later
 
 The release notes for CCE 8.6 and later are not provided in book style.
cea98d4f
 Please type `$ module help cce/<version>` to see the release note for each version.