本文介绍了从调用FORTRAN C函数,麻烦argc和argv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的非常新的Fortran。目前我正在写(或试图写入)一个Fortran应用程序,它调用C库。

我已经走到这一步工作的几件事情,但我坚持与它期望ARGC库中init功能和argv只是为了得到这是调用函数的程序名。

在C-库预计指针argc和argv:

 无效的init(gint的argc,gchar *** argv的);

我不知道如何前preSS是***的argv在FORTRAN。其他功能只需要整数,所以我只好用这个框架对他们没有烦恼:

 接口
    子程序的init(ARGC,ARGV)
        ??
    结束子程序ee_init
结束接口调用的init(,)


解决方案

您可能会需要用C来写,init_fortran或类似您自己的包装功能,你的Fortran打电话的方式,你可以前$ P带参数在Fortran的$ PSS,然后将它们转换到C init函数所期待的。

I'm very new to Fortran. Currently I'm writing (or trying to write) a fortran application which calls a C-library.

I've got a few things working so far but I'm stuck with the init-function from the library which expects argc and argv just to get the program name which is calling the function.

The C-library expects pointers to argc and argv:

void init(gint argc, gchar ***argv);

I have no idea how to express that ***argv in fortran. The other functions only need integers so I had no trouble using this skeleton for them:

interface
    subroutine init( argc, argv)
        ??
    end subroutine ee_init
end interface

call init( , )
解决方案

You will probably need to write your own wrapper function in C, init_fortran, or similar which you call from Fortran and takes arguments in a way you can express in Fortran, then converts them to what the C init function expects.

这篇关于从调用FORTRAN C函数,麻烦argc和argv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 09:52