包括FORTRAN子程序一个C / C ++头文件 [英] including a c/c++ header file in fortran subroutines
问题描述
我已经写在其中宣布,由它开发的C / C ++库,有一个Fortran接口。该界面将包含一个头文件的* .h和调用一个子程序古典启用。我想我的编译Fortran程序链接也该库。
该库已经被测试,它的作品。
I have a library written in C/C++ which is declared, by its developers, to have a Fortran interface. The interface would be enabled including a header file *.h and calling a classical subroutine. I would like to compile my Fortran program linking also that library. The library has been tested already and it works.
这是主程序:
! Main program
INCLUDE 'pastix_fortran.h'
Program TEST
IMPLICIT NONE
call GO_PASTIX
END PROGRAM TEST
例行GO_PASTIX是
The routine GO_PASTIX is
SUBROUTINE GO_PASTIX
IMPLICIT NONE
pastix_data_ptr_t :: pastix_data
integer :: pastix_comm
pastix_int_t :: n, rhs, ia(NCOLS+1), ja(NNZER)
pastix_float_t :: avals(NNZER), b(NROWS)
pastix_int_t :: perm(NROWS), invp(NROWS), iparm(64)
real*8 :: dparm(64)
call pastix_fortran(pastix_data,pastix_comm,n,ia,ja,avals,perm,invp,b,rhs,iparm,dparm)
END SUBROUTINE
鉴于文件pastix_fortran.h的类型在子程序中使用的变量中定义
Whereas in the file pastix_fortran.h the types of variables used in the subroutine are defined:
#define PASTIX_INT_KIND 4
#define pastix_int_t INTEGER(kind=4)
#define pastix_uint_t unsigned INTEGER(kind=4)
#define pastix_data_ptr_t INTEGER(kind=4)
#define MPI_PASTIX_INT MPI_INTEGER4
#define pastix_float_t REAL(kind=8)
#define MPI_PASTIX_FLOAT MPI_REAL8
使用VS2010我加入/ FPP选项以preprocess文件,我没有忘记添加所有包含的目录和文件。但是编译器说:
Using VS2010 I added the option to preprocess file with /fpp and I did not forgot to add all include directories and files. However the compiler says that:
为标题行:警告1警告#5117:不良#preprocessor行
for the header lines: "Warning 1 warning #5117: Bad # preprocessor line"
对于FORTRAN子程序:错误#6404:这个名字没有一个类型,而且必须有一个明确的类型[PASTIX_DATA_PTR_T]等为变量的休息...
for the fortran subroutine: "error #6404: This name does not have a type, and must have an explicit type. [PASTIX_DATA_PTR_T]" and so on for the rest of the variables...
我怎样才能制定出此?
推荐答案
这行
#define pastix_uint_t unsigned INTEGER(kind=4)
将会导致大多数Fortran编译凌晨问题,因为语言从未支持使用或任何其他语法无符号整数。有些离经叛道的实现可能支持他们,但他们绝对不是标准的。
is going to cause most Fortran compilers a wee problem since the language has never supported unsigned integers using this or any other syntax. Some deviant implementations may have supported them, but they are definitely not standard.
这篇关于包括FORTRAN子程序一个C / C ++头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!