Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_F77_wrappers.h
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef _TEUCHOS_F77_WRAPPERS_H_
43 #define _TEUCHOS_F77_WRAPPERS_H_
44 
49 #include "Teuchos_ConfigDefs.hpp"
50 
51 /* Define fcd (Fortran Teuchos_fcd descriptor) for non-standard situations */
52 
53 #if defined(CRAY_T3X)
54 
55 # include <fortran.h>
56 # define F77_CALL_PREFIX
57 # define FORTRAN_CHAR_1_ARG(ARG_NAME) fcd* ARG_NAME
58 # define FORTRAN_CONST_CHAR_1_ARG(ARG_NAME) const fcd& ARG_NAME
59 # define FORTRAN_CHAR_1_ARG_CALL(ARG_NAME) ARG_NAME
60 
61 #elif defined(INTEL_CXML)
62 
63 # define F77_CALL_PREFIX __stdcall
64 # define FORTRAN_CHAR_1_ARG(ARG_NAME) char* ARG_NAME, unsigned int
65 # define FORTRAN_CONST_CHAR_1_ARG(ARG_NAME) const char& ARG_NAME, unsigned int
66 # define FORTRAN_CHAR_1_ARG_CALL(ARG_NAME) ARG_NAME, 1
67 
68 #elif defined(INTEL_MKL)
69 
70 # define F77_CALL_PREFIX
71 # define FORTRAN_CHAR_1_ARG(ARG_NAME) char* ARG_NAME
72 # define FORTRAN_CONST_CHAR_1_ARG(ARG_NAME) const char& ARG_NAME
73 # define FORTRAN_CHAR_1_ARG_CALL(ARG_NAME) ARG_NAME, 1
74 
75 #else
76 
77 # define F77_CALL_PREFIX
78 # define FORTRAN_CHAR_1_ARG(ARG_NAME) char* ARG_NAME
79 # define FORTRAN_CONST_CHAR_1_ARG(ARG_NAME) const char& ARG_NAME
80 # define FORTRAN_CHAR_1_ARG_CALL(ARG_NAME) ARG_NAME
81 
82 #endif
83 
84 /* RAB: 20030924: ToDo: Find a way to see if const is supported or not by C or
85  just decide that this will only be for C++ code and be done with it. */
86 
87 /* External macros */
88 
89 #define FORTRAN_NAME_UL(UNAME,LNAME) F77_FUNC(LNAME,UNAME)
90 
91 #define FORTRAN_FUNC_DECL_UL(TYPE,UFUNC_NAME,LFUNC_NAME) TYPE F77_CALL_PREFIX FORTRAN_NAME_UL(UFUNC_NAME,LFUNC_NAME)
92 
93 #define FORTRAN_FUNC_CALL_UL(UFUNC_NAME,LFUNC_NAME) FORTRAN_NAME_UL(UFUNC_NAME,LFUNC_NAME)
94 
95 #define FORTRAN_FUNC_PTR_DECL_UL(TYPE,UFUNC_NAME,LFUNC_NAME) TYPE (F77_CALL_PREFIX *FORTRAN_NAME_UL(UFUNC_NAME,LFUNC_NAME))
96 
97 #define FORTRAN_COMMMON_BLOCK_NAME_UL(UNAME,LNAME) FORTRAN_NAME_UL(UNAME,LNAME)\
98 
99 #define FORTRAN_NAME_UL_(UNAME,LNAME) F77_FUNC_(LNAME,UNAME)
100 
101 #define FORTRAN_FUNC_DECL_UL_(TYPE,UFUNC_NAME,LFUNC_NAME) TYPE F77_CALL_PREFIX FORTRAN_NAME_UL_(UFUNC_NAME,LFUNC_NAME)
102 
103 #define FORTRAN_FUNC_CALL_UL_(UFUNC_NAME,LFUNC_NAME) FORTRAN_NAME_UL_(UFUNC_NAME,LFUNC_NAME)
104 
105 #define FORTRAN_FUNC_PTR_DECL_UL_(TYPE,UFUNC_NAME,LFUNC_NAME) TYPE (F77_CALL_PREFIX *FORTRAN_NAME_UL_(UFUNC_NAME,LFUNC_NAME))
106 
107 #define FORTRAN_COMMMON_BLOCK_NAME_UL_(UNAME,LNAME) FORTRAN_NAME_UL_(UNAME,LNAME)\
108 
109 #ifdef __cplusplus
110 
111 // These are the platform dependent C++ equivalents of fortran types
112 // RAB: 2003/11/20: ToDo: Move this into Teuchos namespace at some point
113 namespace FortranTypes {
114 
115 typedef int f_int; // INTEGER
116 typedef float f_real; // REAL
117 typedef double f_dbl_prec; // DOUBLE PRECISION
118 typedef int f_logical; // LOGICAL
119 typedef char f_char; // CHARACTER*1
120 typedef unsigned int f_char_len; // length argument for a CHARACTER*(*)
121 //typedef std::complex<f_real> f_complex; // COMPLEX
122 //typedef std::complex<f_dbl_prec> f_complex_16; // COMPLEX*16
123 
124 enum { F_TRUE = true, F_FALSE = false }; // Let compiler figure this out!
125 
126 #endif /* __cplusplus */
127 
128 } // namespace FortranTypes
129 
130 #endif // _TEUCHOS_F77_WRAPPERS_H_
Teuchos header file which uses auto-configuration information to include necessary C++ headers...