1.Test1.C文件

void test_simple();
void test_call(char filename[], int a[], int n, int* val);void test_call(char filename[], int a[], int n, int* val)
{printf("%s\t%d\n", filename, n);
}void test_simple()
{printf("%s\t%d\n", "test_simple", 123456);
}

2.Test2.f90文件

program nameuse,intrinsic::iso_c_bindingimplicit nonecharacter(80) strinteger, parameter:: n=3integer aa(n), s!函数接口interfacesubroutine test_call(filename,a,n,s) bind(c,name='test_call')character filename(*)integer,value:: ninteger aa(n), send subroutineend interfaceinterfacesubroutine test_simple() bind(c)end subroutineend interfaceaa = [1,2,3]str = "1.txt"    // C_NULL_CHARcall test_call(str,a,n,s)call test_simple()end program 

3.用gfortran编译c和Fortran

D:\Soft\mingw64\bin\gfortran.exe -c Test1.c

D:\Soft\mingw64\bin\gfortran.exe -c Test2.f90

会产生Test1.o和Test2.o两个文件

4.链接

D:\Soft\mingw64\bin\gfortran.exe Test1.o Test2.o -o Test.exe

5.也可以把C文件编译成lib库,再和Fortran链接

D:\Soft\mingw64\bin\ar.exe rv Test1.a Test1.o

D:\Soft\mingw64\bin\gfortran.exe Test2.o Test1.a -o Test.exe

这个地方一定要注意文件的顺序, .o文件一定要放到.a的前面,否则将编译错误: undefined reference to `test_call'

用gfortran编译C和Fortran相关推荐

  1. 使用 gfortran 编译 CALPUFF

    1. 升级gfortran 7 默认gortran的版本是4.8 gfortran --version GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5- ...

  2. linux gfortran编译,gfortran编译学习

    一.http://wiki.ubuntu.org.cn/index.php?title=Compiling_Fortran&variant=zh-cn 二.http://blog.scienc ...

  3. WRF——OBSGRID使用方法(gfortran编译)

    一.安装 cd /home/ubuntu/WRFCHEM/ #自己的wrf目录 git clone https://github.com/wrf-model/OBSGRID.git cd /home/ ...

  4. 解决pscad Gfortran编译问题

    跑pscad程序一直出现错误: Fatal Error: Parse error when checking module version for file 'ndde.mod' opened at ...

  5. linux升级gfortran,gfortran编译cp2k4.1

    大部分安装包可以在https://www.cp2k.org/static/downloads/找到,其它的可以去官网自行下载.https://www.cndba.cn/shuye100/article ...

  6. windows下gfortran编译error:Note: The following floating-point exceptions are signalling: IEEE_UNDERFLOW

    这是gfortran版本不兼容的问题: IEEE_INVALID_FLAG is triggered by invalid operations, such as trying to take sqr ...

  7. linux下源代码安装f90,linux下编译fortran linux安装gfortran

    linux上面如何编译fortran源代码? 格式:ifort要编译的文件名-0指定生成的文件名 如我要把123.f文件编译 ifort123.f-o123.e 如果不加指定生成的文件名,系统会自动生 ...

  8. Fortran和C/C++混合编程学习笔记(一):编译链接

    有时候,我们希望使用Fortran和C/C++混合编程,以利用各语言的优势.只要确保函数调用时传递的参数类型正确,定义和声明的变量类型和大小匹配,Fortran和C 语言二者的函数和全局变量就可以彼此 ...

  9. Fortran教程1:安装和编译

    文章目录 安装 入门的第一段fortran代码 虽然号称上古语言,而且貌似用户数量一年不如一年,但偶尔也有诈尸的时候,而且比较夭寿的是20年的时候竟然有人开发了fortran的包管理工具fpm,更离谱 ...

最新文章

  1. (转)创业需要知道的13句话
  2. go Windows Service
  3. 基于YARN集群构建运行PySpark Application
  4. python -pymysql的操作
  5. 一个七年程序员的经验
  6. shell简单的交互式脚本
  7. android下测试方法及junit单元测试框架配置方法
  8. 麒麟KY-RTI分布仿真技术:第三章 KY-OMT对象模型模板工具
  9. 日系插画学习笔记(三):光影与结构
  10. Material studio 中如何构建方形晶胞
  11. 材料分享主题一:如何向上级汇报部门/组织架构
  12. CF1379C Choosing flowers
  13. 安装CAD出现Error:1402
  14. 社会人文跨计算机考研,各位跨专业考研党,不要违反这个规则,不然结果会让人遗憾...
  15. 用计算机打字方法,电脑快速打字方法
  16. shell清除cach
  17. PTA R7-5 Jack cheng的烦恼3
  18. openstack 等管理工具
  19. alphassl通配符证书送一个月
  20. 淘宝双十一自动刷喵币

热门文章

  1. 超级表格新功能:表格数据支持卡片模式查看
  2. [ Linux RK ] 更改网卡名字|CSDN创作打卡
  3. 基于DGL库图神经网络教程(1)——基本的建图操作
  4. 6.S081参考书笔记 —— 第7章调度、进程交互
  5. java switch case null_如何在switch中使用null
  6. 2023最新!QQ接入ChatGpt!!!保姆级教程
  7. 3分钟教你开通阿里云AccessKey秘钥,并完成对应授权!
  8. qrcode二维码生成工具
  9. python这个怎么读-python怎么读(python怎么读中文)
  10. 职场漂流记:过往皆为浮云