1 // 2 // Copyright (C) 2002, 2003 Si-Lab b.v.b.a., Toon Knapen and Kresimir Fresl 3 // 2010 Thomas Klimpel 4 // 5 // Distributed under the Boost Software License, Version 1.0. 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // 9 10 #ifndef BOOST_NUMERIC_BINDINGS_DETAIL_CONFIG_FORTRAN_HPP 11 #define BOOST_NUMERIC_BINDINGS_DETAIL_CONFIG_FORTRAN_HPP 12 13 #if defined(BIND_FORTRAN_LOWERCASE_UNDERSCORE) || defined(BIND_FORTRAN_LOWERCASE) || defined(BIND_FORTRAN_UPPERCASE_UNDERSCORE) || defined(BIND_FORTRAN_UPPERCASE) 14 // Allow manual override of the defaults, e.g. if you want to use a fortran 15 // lib compiled with gcc from MSVC 16 #else 17 18 // We have no chance of determining the conventions for linking C with Fortran 19 // here, because they only depend on the fortran compiler and it's command line 20 // switches, but not on the C++ compiler which compiles these lines. 21 22 // We default to lowercase underscore, because this is much more common than 23 // the other option. (The previous automatic configuration only selected the 24 // other option in case of "defined(__IBMCPP__) || defined(_MSC_VER)".) 25 #define BIND_FORTRAN_LOWERCASE_UNDERSCORE 26 27 #endif 28 29 // Next we define macro's to convert our symbols to 30 // the current convention 31 #if defined(BIND_FORTRAN_LOWERCASE_UNDERSCORE) 32 #define FORTRAN_ID( id ) id##_ 33 #define FORTRAN_ID2( id, ID2 ) id##_ 34 #elif defined(BIND_FORTRAN_LOWERCASE) 35 #define FORTRAN_ID( id ) id 36 #define FORTRAN_ID2( id, ID2 ) id 37 #elif defined(BIND_FORTRAN_UPPERCASE_UNDERSCORE) 38 #define FORTRAN_ID2( id, ID2 ) ID2##_ 39 #elif defined(BIND_FORTRAN_UPPERCASE) 40 #define FORTRAN_ID2( id, ID2 ) ID2 41 #else 42 #error do not know how to bind to fortran calling convention 43 #endif 44 45 46 #ifdef BIND_FORTRAN_F2C_RETURN_CONVENTIONS 47 // "g77" or clapack or "gfortran -ff2c" 48 #define BIND_FORTRAN_RETURN_REAL_DOUBLE 49 #define BIND_FORTRAN_RETURN_COMPLEX_FIRST_ARG 50 #elif BIND_FORTRAN_MKL_RETURN_CONVENTIONS 51 // mkl 52 #define BIND_FORTRAN_RETURN_COMPLEX_FIRST_ARG 53 #elif BIND_FORTRAN_OSX_RETURN_CONVENTIONS 54 // OS X 55 #define BIND_FORTRAN_RETURN_COMPLEX_LAST_ARG 56 #else 57 // "g77 -fno-f2c" or "gfortran" 58 #endif 59 60 61 // "g77" or "gfortran" or mkl_intel_lp64 62 //#undef BIND_FORTRAN_INTEGER_8 63 // clapack or "gfortran -fdefault-integer-8" or mkl_intel_ilp64 64 //#define BIND_FORTRAN_INTEGER_8 65 66 // Most fortran compilers use fortran_int_t := int by default, so we follow 67 // this default, even so f2c (=clapack) uses "typedef long int integer;" 68 #ifndef BIND_FORTRAN_INTEGER_8 69 typedef int fortran_int_t; 70 #else 71 typedef std::ptrdiff_t fortran_int_t; 72 #endif 73 74 // Looks like fortran_int_t and fortran_bool_t should be identical, the unsigned is 75 // required so overloads can distinguish between fortran_bool_t and fortran_int_t. 76 #ifndef BIND_FORTRAN_INTEGER_8 77 typedef unsigned int fortran_bool_t; 78 #else 79 typedef std::size_t fortran_bool_t; 80 #endif 81 82 // This definition of external_fp is identical to the definition of L_fp from 83 // f2c, and it seems to work more or less. These functions return fortran_bool_t, 84 // but they don't all take the same type of arguments. A reinterpret_cast will 85 // probably work for most compilers to extend the allowed function signatures. 86 typedef fortran_bool_t (*external_fp)(...); 87 88 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H 89