Pathscale Fortran and C/C++ Compilers
Total Page:16
File Type:pdf, Size:1020Kb
PathScale™ Compiler Suite User Guide Version 3.2 Page i PathScale Compiler Suite User Guide Version 3.2 Page ii PathScale Compiler Suite User Guide Version 3.2 Information furnished in this manual is believed to be accurate and reliable. However, PathScale LLC assumes no responsibility for its use, nor for any infringements of patents or other rights of third parties which may result from its use. PathScale LLC reserves the right to change product specifications at any time without notice. Applications described in this document for any of these products are for illustrative purposes only. PathScale LLC makes no representation nor warranty that such applications are suitable for the specified use without further testing or modification. PathScale LLC assumes no responsibility for any errors that may appear in this document. No part of this document may be copied nor reproduced by any means, nor translated nor transmitted to any magnetic medium without the express written consent of PathScale LLC. In accordance with the terms of their valid PathScale agreements, customers are permitted to make electronic and paper copies of this document for their own exclusive use. Linux is a registered trademark of Linus Torvalds. PathScale, the PathScale logo, and EKOPath are registered trademarks of PathScale, LLC. Red Hat and all Red Hat-based trademarks are trademarks or registered trademarks of Red Hat, Inc. SuSE is a registered trademark of SuSE Linux AG. All other brand and product names are trademarks or registered trademarks of their respective owners. © 2007, 2008 PathScale, LLC. All rights reserved. © 2006, 2007 QLogic Corporation. All rights reserved worldwide. © 2004, 2005, 2006 PathScale. All rights reserved. First Published: April 2004 Printed in U.S.A. PathScale LLC, 2071 Stierlin Ct., Suite 200, Mountain View, CA 94043 Page iii PathScale Compiler Suite User Guide Version 3.2 Page iv Table of Contsents Section 1 Introduction 1.1 Conventions Used in This Document . 1-2 1.2 Documentation Suite . 1-2 Section 2 Compiler Quick Reference 2.1 What You Installed . 2-1 2.2 How To Invoke the PathScale Compilers . 2-1 2.2.1 Accessing the GCC 4.x Front-ends for C and C++ . 2-2 2.3 Compiling for Different Platforms . 2-3 2.3.1 Target Options for This Release . 2-4 2.3.2 Defaults Flag . 2-5 2.3.3 Compiling for an Alternate Platform . 2-5 2.3.4 Compiling Option Tool: pathhow-compiled . 2-6 2.4 Input File Types . 2-6 2.5 Other Input Files . 2-7 2.6 Common Compiler Options . 2-8 2.7 Shared Libraries . 2-8 2.8 Large File Support . 2-9 2.9 Memory Model Support . 2-9 2.9.1 Page v PathScale Compiler Suite User Guide Version 3.2 Support for "Large" Memory Model . 2-10 2.10 Debugging . 2-11 2.11 Profiling: Locate Your Program’s Hot Spots . 2-11 2.12 taskset: Assigning a Process to a Specific CPU. 2-12 Section 3 The PathScale Fortran Compiler 3.1 Using the Fortran Compiler. 3-1 3.1.1 Fixed-form and Free-form Files . 3-2 3.2 Modules . 3-3 3.2.1 Order of Appearance . 3-3 3.2.2 Linking Object Files to the Rest of the Program . 3-4 3.3 Linking When the Main Program Is In a Library . 3-4 3.3.1 Module-related Error Messages . 3-4 3.4 Fortran 2003 Support . 3-5 3.4.1 Syntax Improvements . 3-5 3.4.2 Intrinsic Procedures . 3-6 3.4.3 Pointer INTENT . 3-7 3.4.4 VOLATILE Attribute and Statement . 3-8 3.4.5 IMPORT Statement . 3-9 3.4.6 Intrinsic Module ISO_FORTRAN_ENV . 3-10 3.4.7 IEEE Floating Point . 3-11 3.4.7.1 Gradual Underflow . 3-12 Page vi PathScale Compiler Suite User Guide Version 3.2 PathScale Compiler Suite User 3.4.8 Allocatable Components and Dummy Arguments . 3-12 3.4.9 Fortran 2003 C Interoperability . 3-13 3.4.9.1 BIND attribute . 3-14 3.4.9.2 Intrinsic Module ISO_C_BINDING . 3-16 3.4.9.3 Pointer Compatibility . 3-18 3.4.9.4 Passing Arguments by Value . 3-18 3.4.9.5 Enumerations . 3-19 3.4.9.6 Example: Using C "malloc" from Fortran . 3-20 3.4.9.7 Issues Unique to C++ . 3-20 3.4.9.8 Pitfalls . 3-21 3.5 Extensions . 3-21 3.5.1 Promotion of REAL and INTEGER Types . 3-21 3.5.2 Cray Pointers . 3-21 3.5.3 Directives . 3-22 3.5.3.1 Prefetch Directives . 3-22 3.5.3.2 Changing Optimization Using Directives . 3-24 3.6 Compiler and Runtime Features. 3-24 3.6.1 Preprocessing Source Files with -cpp . 3-24 3.6.2 Preprocessing Source Files with -ftpp . 3-24 3.6.3 Support for Varying Length Character Strings . 3-25 3.6.4 Preprocessing Source Files with -fcoco . 3-25 Page vii PathScale Compiler Suite User Guide Version 3.2 3.6.4.1 Pre-defined Macros . 3-26 3.6.5 Error Numbers: The explain Command . 3-27 3.6.6 Fortran 90 Dope Vector . 3-28 3.6.7 Bounds Checking . 3-29 3.6.8 Pseudo-random Numbers . 3-29 3.7 Mixed Code. 3-29 3.7.1 Legacy Support for Calls between C and Fortran . 3-30 3.7.1.1 Example: Calls between C and Fortran . 3-31 3.7.1.2 Example: Accessing Common Blocks from C . 3-33 3.8 Runtime I/O Compatibility . 3-34 3.8.1 Performing Endian Conversions . 3-35 3.8.1.1 The assign Command . 3-35 3.8.1.2 Using the Wildcard Option . 3-35 3.8.1.3 Converting Data and Record Headers . 3-36 3.8.1.4 The ASSIGN( ) Procedure . 3-36 3.8.1.5 I/O Compilation Flags . 3-36 3.8.2 Reserved File Units . 3-37 3.9 Source Code Compatibility . 3-37 3.9.1 Fortran KINDs . 3-37 3.10 Library Compatibility . 3-37 3.10.1 Name Mangling . 3-38 Page viii PathScale Compiler Suite User Guide Version 3.2 PathScale Compiler Suite User 3.10.2 ABI Compatibility . 3-39 3.10.3 Linking with g77-compiled Libraries . 3-39 3.10.3.1 AMD Core Math Library (ACML) . 3-40 3.10.4 List Directed I/O and Repeat Factors . 3-40 3.10.4.1 Environment Variable . 3-41 3.10.4.2 assign Command . 3-41 3.11 Porting Fortran Code . ..