从c调用fortran子程序 [英] Calling fortran subroutine from c

查看:89
本文介绍了从c调用fortran子程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我不知道这是否是正确的论坛,如果没有,请建议一个

适合。

我必须从C主程序调用fortran子程序。


fortran子程序语句是


wload( starttime,duration,station,component,dataray,nsamp,calib,srate,

samplength,datadir)


定义变量


真实* 8开始时间

实际持续时间

字符*(*)sta

字符*(*)组件

整数* 4 dataray(1)

整数nsamp,samplength

真实校准,srate

字符* 100 datadir


其中,开始时间,持续时间,站点,组件都是输入。 dataray是一个

整数向量,在C程序中通过dataray = calloc(65000,

sizeof(int))创建


在C代码中我有以下变量defs ..

双启动时间

char sta [5],组件[4]

char * datadir

浮动持续时间,校准,srate


但我无法调用fortran sub来使用健壮性。你是否b / b
有关于如何定义c变量和函数的任何指示

wload_的原型可以做到这一点吗?


如果你知道一个很好的常见问题解答,这对我也有用...


你的,


Stuart

Stuart A. Weinstein博士

Ewa海滩构造研究所

错误是人类,但真正犯规需要一个创造论者

创造论者并不是不受逻辑的影响:他们没有注意到它。

解决方案

< blockquote>


Bigdakine写道:


我不知道这是否是正确的论坛,如果不是,请建议一个
适合。

我必须从C主程序中调用fortran子程序。

Fortran子程序声明是

wload(starttime,duration,station,component,dataray,nsamp,calib,srate,
samplength,datadir)

变量定义

真实* 8启动时间
实际持续时间
字符*(*)sta
字符*(*)组件
整数* 4 dataray(1)
整数nsamp,samplength
真实校准,srate
字符* 100 datadir
sizeof(int))创建的整数向量

在C代码中我有以下变量defs ..
双启动时间
char sta [5],组件[4]
char * datadir
浮动持续时间,校准,srate

但我可以没有得到fortran sub的调用来使用健壮性。你有没有关于如何定义c变量的指示和一个可以实现这个功能的wload_函数原型?

如果你知道一个很好的常见问题解答这对我也有用......

你的,

Stuart

Stuart A. Weinstein博士
Ewa Beach构造学研究所
犯错误是人类,但真正犯规需要创造论者

创造论者不会不接受逻辑:他们没有忘记它。




答案将取决于您的平台以及您使用的是什么编译器

。您需要查看

平台的C和Fortran编译器手册。请注意,该解决方案可能无法移植。

-

Fred L. Kleinschmidt

波音助理技术研究员

技术架构师,通用用户界面服务

M / S 2R-94(206)544-5225


bi ******* @ aol.comG etaGrip(Bigdakine)在留言中写道:< 20 ******* ******************** @ mb-m17.aol.com> ...

我不知道这是不是正确的论坛,如果不是,请建议一个适合的

我必须从C主程序中调用fortran子程序。

Fortran子程序声明是

wload(starttime,duration,station,component,dataray,nsamp,calib,srate,
samplength,datadir)

并且定义了变量

真实* 8开始时间
实际持续时间
字符*(*)sta
字符*(*)组件
整数* 4 dataray(1)
整数nsamp,s amplength
真正的校准,srate
字符* 100 datadir

其中,starttime,duration,station,component是输入。 dataray是一个在C程序中通过dataray = calloc(65000,
sizeof(int))创建的整数向量

在C代码中我有以下变量defs ..
双启动时间
char sta [5],组件[4]
char * datadir
浮动持续时间,校准,srate

但我可以没有得到fortran sub的调用来使用健壮性。你有没有关于如何定义c变量的指示和一个可以实现这个功能的wload_函数原型?

如果你知道一个很好的常见问题解答这对我也有用...




在Google上快速搜索显示...

http://www.aei.mpg.de/~jthorn/c2f.html


问候,

Mark。


Bigdakine写道:

我不知道这是否是这个
的正确论坛,如果没有,请建议一个合适的论坛。


comp.lang.fortran

我需要从C主程序调用fortran子程序。

fortran子程序语句是wload(starttime,duration,station,component,dataray,nsamp,calib,srate,
samplength,datadir)

并且变量是定义的/>
真实* 8开始时间
实际持续时间
字符*(*)站点
字符*(*)组件
整数* 4 dataray(1)
整数nsamp,samplength
实校准,srate
字符* 100 datadir

其中,starttime,duration,station,component是输入。 dataray是一个在C程序中通过dataray = calloc(65000,
sizeof(int))创建的整数向量

在C代码中我有以下变量defs ..
双启动时间
char sta [5],组件[4]
char * datadir
浮动持续时间,校准,srate

但我可以没有调用fortran sub来使用健壮性。
你有没有关于如何定义c变量的指示
和wload_的函数原型可以实现这个?




void wload_(double *,float *,char *,char *,int *,int *,

float *,float *, int *,char *,int,int,int);


wload _(& starttime,& duration,sta,component,dataray,

& ; nsamp,& calib,& srate,& samplength,datadir,

strlen(sta),strlen(component),strlen(datadir));



I don''t know if this is the right forum for this, and if not please suggest one
which fits.

I have to call a fortran sub routine from a C main program.

The fortran subroutine statement is

wload(starttime, duration, station, component, dataray, nsamp, calib, srate,
samplength, datadir)

And the variables are defined

real*8 starttime
real duration
character*(*) sta
character*(*) component
integer*4 dataray(1)
integer nsamp,samplength
real calib,srate
character*100 datadir

Of these, starttime, duration, station, component are inputs. dataray is an
integer vector created in the C-program via dataray = calloc(65000,
sizeof(int))

In the C-code I have the following variable defs..
double starttime
char sta[5], component[4]
char *datadir
float duration, calib, srate

But I can''t get the call to the fortran sub to work with robustness. Do you
have any pointers as to how the c-variables should be defined and a function
prototype for wload_ that could accomplish that?

If you know of a good FAQ on this, that would work for me too...

Yours,

Stuart
Dr. Stuart A. Weinstein
Ewa Beach Institute of Tectonics
"To err is human, but to really foul things up requires a creationist"
"Creationists aren''t impervious to Logic: They''re oblivious to it."

解决方案



Bigdakine wrote:


I don''t know if this is the right forum for this, and if not please suggest one
which fits.

I have to call a fortran sub routine from a C main program.

The fortran subroutine statement is

wload(starttime, duration, station, component, dataray, nsamp, calib, srate,
samplength, datadir)

And the variables are defined

real*8 starttime
real duration
character*(*) sta
character*(*) component
integer*4 dataray(1)
integer nsamp,samplength
real calib,srate
character*100 datadir

Of these, starttime, duration, station, component are inputs. dataray is an
integer vector created in the C-program via dataray = calloc(65000,
sizeof(int))

In the C-code I have the following variable defs..
double starttime
char sta[5], component[4]
char *datadir
float duration, calib, srate

But I can''t get the call to the fortran sub to work with robustness. Do you
have any pointers as to how the c-variables should be defined and a function
prototype for wload_ that could accomplish that?

If you know of a good FAQ on this, that would work for me too...

Yours,

Stuart

Dr. Stuart A. Weinstein
Ewa Beach Institute of Tectonics
"To err is human, but to really foul things up requires a creationist"
"Creationists aren''t impervious to Logic: They''re oblivious to it."



The answer will depend on your platform and what compilers you are
using. You need to look at the C and Fortran compiler manuals for your
platform. Note that the solution will probably not be portable.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225


bi*******@aol.comGetaGrip (Bigdakine) wrote in message news:<20***************************@mb-m17.aol.com>...

I don''t know if this is the right forum for this, and if not please suggest one
which fits.

I have to call a fortran sub routine from a C main program.

The fortran subroutine statement is

wload(starttime, duration, station, component, dataray, nsamp, calib, srate,
samplength, datadir)

And the variables are defined

real*8 starttime
real duration
character*(*) sta
character*(*) component
integer*4 dataray(1)
integer nsamp,samplength
real calib,srate
character*100 datadir

Of these, starttime, duration, station, component are inputs. dataray is an
integer vector created in the C-program via dataray = calloc(65000,
sizeof(int))

In the C-code I have the following variable defs..
double starttime
char sta[5], component[4]
char *datadir
float duration, calib, srate

But I can''t get the call to the fortran sub to work with robustness. Do you
have any pointers as to how the c-variables should be defined and a function
prototype for wload_ that could accomplish that?

If you know of a good FAQ on this, that would work for me too...



A quick search on Google revealed ...

http://www.aei.mpg.de/~jthorn/c2f.html

Regards,
Mark.


Bigdakine wrote:

I don''t know if this is the right forum for this
and, if not, please suggest one which fits.
comp.lang.fortran
I need to call a fortran subroutine from a C main program.

The fortran subroutine statement is

wload(starttime, duration, station, component, dataray, nsamp, calib, srate,
samplength, datadir)

And the variables are defined

real*8 starttime
real duration
character*(*) station
character*(*) component
integer*4 dataray(1)
integer nsamp,samplength
real calib,srate
character*100 datadir

Of these, starttime, duration, station, component are inputs. dataray is an
integer vector created in the C-program via dataray = calloc(65000,
sizeof(int))

In the C-code I have the following variable defs..
double starttime
char sta[5], component[4]
char *datadir
float duration, calib, srate

But I can''t get the call to the fortran sub to work with robustness.
Do you have any pointers as to how the c-variables should be defined
and a function prototype for wload_ that could accomplish that?



void wload_(double*, float*, char*, char*, int*, int*,
float*, float*, int*, char*, int, int, int);

wload_(&starttime, &duration, sta, component, dataray,
&nsamp, &calib, &srate, &samplength, datadir,
strlen(sta), strlen(component), strlen(datadir));


这篇关于从c调用fortran子程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆