You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何改写iand函数以适配新版本gfortran编译器?

Fortran代码编译错误及解决过程

问题描述

处理旧Fortran代码时,编译出现如下错误:

if(iand(n_jz2_max,1).eq.0) then
1
Error: Arguments of ‘iand’ have different kind type parameters at (1)

其中n_jz2_max为integer*4类型。已知新版iand不支持不同kind类型的参数,尝试使用旧版gfortran编译,但当前Ubuntu版本无法安装旧版,重装旧版Ubuntu并非首选方案,希望通过修改代码解决问题。

解决更新

实际报错原因是使用了-fdefault-integer-8这类编译选项。原编译命令:

$ mpif90 -f90=gfortran -c -w -I include -O2 -fdefault-integer-8 -o build/mm_1.16.o source/mm_1.16.f90

经过多次尝试,卸载所有mpich版本并安装最新版本,修改编译命令为:

$ mpif90 -c -w -I include -O2 -o build/mm_1.16.o source/mm_1.16.f90

代码编译成功,未出现任何问题。


内容的提问来源于stack exchange,提问作者Sofia Kara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 16:53:10