首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >fortran: Error:实际参数在(1)和实际参数(2)之间不匹配(整数(8)/INTEGER(2))

fortran: Error:实际参数在(1)和实际参数(2)之间不匹配(整数(8)/INTEGER(2))
EN

Stack Overflow用户
提问于 2021-10-23 09:20:34
回答 2查看 3.3K关注 0票数 0

我是Fortran的初学者,运行着一个由Fortran编写的模型。当我试图编译它时,我收到了如下错误消息:

代码语言:javascript
运行
复制
libtool: link: (cd ".libs" && rm -f "libgrib_api_f77.so" && ln -s "libgrib_api_f77.so.1.0.0" "libgrib_api_f77.so")
libtool: link: ar cru .libs/libgrib_api_f77.a  grib_fortran.o grib_f77.o
libtool: link: ranlib .libs/libgrib_api_f77.a
libtool: link: ( cd ".libs" && rm -f "libgrib_api_f77.la" && ln -s "../libgrib_api_f77.la" "libgrib_api_f77.la" )
gfortran   -c -o same_int_long.o same_int_long.f90
same_int_long.f90:23:18:
 
   17 |   call check_long(x2(1),x2(2),ret)
      |                  2
......
   23 |   call check_long(x4(1),x4(2),ret)
      |                  1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2)).
same_int_long.f90:29:18:
 
   17 |   call check_long(x2(1),x2(2),ret)
      |                  2
......
   29 |   call check_long(x8(1),x8(2),ret)
      |                  1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(2)).
same_int_long.f90:51:17:
 
   45 |   call check_int(x2(1),x2(2),ret)
      |                 2
......
   51 |   call check_int(x4(1),x4(2),ret)
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/INTEGER(2)).
same_int_long.f90:57:17:
 
   45 |   call check_int(x2(1),x2(2),ret)
      |                 2
......
   57 |   call check_int(x8(1),x8(2),ret)
      |                 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(2)).
make[2]: *** [Makefile:546: same_int_long.o] Error 1
make[2]: Leaving directory '/gpfs/home3/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source/fortran'
make[1]: *** [Makefile:604: all-recursive] Error 1
make[1]: Leaving directory '/gpfs/home3/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source'
make: *** [Makefile:398: /home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source-LXgfortran/include/grib_api.mod] Error 2

我所做的基本上是在安装模型之后:

Step1

代码语言:javascript
运行
复制
(base) [eccei339@int3 ~]$ mkdir snellius_surfex
(base) [eccei339@int3 ~]$ cp open_surfex_v8_1_20200107.tar-2.gz snellius_surfex/
(base) [eccei339@int3 ~]$ cd snellius_surfex/
(base) [eccei339@int3 snellius_surfex]$ tar zxvf open_surfex_v8_1_20200107.tar-2.gz

…(省略tar zxvf日志信息)

步骤2:一些本质的env变量

代码语言:javascript
运行
复制
(base) [eccei339@int3 snellius_surfex]$ export VER_MPI="NOMPI"
(base) [eccei339@int3 snellius_surfex]$ export OMP_NUM_THREADS=1
(base) [eccei339@int3 snellius_surfex]$ module load 2021
(base) [eccei339@int3 snellius_surfex]$ module load GCC/10.3.0
(base) [eccei339@int3 snellius_surfex]$ ls
open_SURFEX_V8_1  open_surfex_v8_1_20200107.tar-2.gz

(在这里,我按照软件安装说明导出了一些必要的envi var )

步骤3:配置

代码语言:javascript
运行
复制
(base) [eccei339@int3 snellius_surfex]$ cd open_SURFEX_V8_1/src/
(base) [eccei339@int3 src]$ ls
ASSIM      Makefile            Rules.bullXI15.mk    Rules.MCgfortran.mk  SURFEX
configure  Makefile.SURFEX.mk  Rules.bullXI16.mk    Rules.SX8.mk
FORC       OFFLIN              Rules.LXgfortran.mk  Rules.zgfortran.mk
include    Rules.AIX64.mk      Rules.LXifort.mk     Rules.zifort.mk
LIB        Rules.bgfortran.mk  Rules.LXpgi.mk       scripts
(base) [eccei339@int3 src]$ ./configure

(省略“配置”命令的长日志信息)

代码语言:javascript
运行
复制
(base) [eccei339@int3 src]$ . ../conf/profile_surfex-LXgfortran-SFX-V8-1-1-NOMPI-OMP-O2-X0

(按照软件安装说明采取的一个基本步骤)

第四步:让主人

代码语言:javascript
运行
复制
(base) [eccei339@int3 src]$ make
find: ‘/home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/dir_obj-LXgfortran-SFX-V8-1-1-NOMPI-OMP-O2-X0/MASTER’: No such file or directory
cd /home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source && LDFLAGS= FCFLAGS= CPPFLAGS="" \
 ./configure --disable-jpeg --prefix=/home/eccei339/snellius_surfex/open_SURFEX_V8_1/src/LIB/grib_api-1.17.0-Source-LXgfortran FC="gfortran" && \
 make -j 1 clean && \
 make -j 1 && \
 make -j 1 install && \
 make -j 1 clean
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no

(省略长日志记录信息,最后一行是本问题描述开头显示的错误消息。)

我在互联网上搜索到,这可能是因为GCC 10比GCC更严格(去年我用更老的could编译了这个模型,但这次失败了,因为我们的服务器被转移到了一个新系统,因此从旧版本升级到了新版本)。谷歌的一些信息说,我可以添加这样的内容:

代码语言:javascript
运行
复制
export FCFLAGS="-w -fallow-argument-mismatch -O2"
export FFLAGS="-w -fallow-argument-mismatch -O2"

但是我在第二步中尝试过,我导出了一些基本的环境变量,但是它仍然不起作用。所以我想知道有谁能帮我吗?非常感谢!

更新:来自grib_api-1.17.0-Source/fortran/same_int_long.f90空气污染指数/源代码如下:

代码语言:javascript
运行
复制
! Copyright 2005-2016 ECMWF.
!
! This software is licensed under the terms of the Apache Licence Version 2.0
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
! 
! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.

integer function kind_of_long()
  integer(2), dimension(2) :: x2 = (/1, 2/)
  integer(4), dimension(2) :: x4 = (/1, 2/)
  integer(8), dimension(2) :: x8 = (/1, 2/)
  character(len=1) :: ret

  kind_of_long=-1

  call check_long(x2(1),x2(2),ret)
  if (ret == 't') then
   kind_of_long=2
   return
  endif

  call check_long(x4(1),x4(2),ret)
  if (ret == 't') then
   kind_of_long=4
   return
  endif

  call check_long(x8(1),x8(2),ret)
  if (ret == 't') then
   kind_of_long=8
   return
  endif

end function kind_of_long

integer function kind_of_int()
  integer(2), dimension(2) :: x2 = (/1, 2/)
  integer(4), dimension(2) :: x4 = (/1, 2/)
  integer(8), dimension(2) :: x8 = (/1, 2/)
  character(len=1) :: ret

  kind_of_int=-1

  call check_int(x2(1),x2(2),ret)
  if (ret == 't') then
   kind_of_int=2
   return
  endif

  call check_int(x4(1),x4(2),ret)
  if (ret == 't') then
   kind_of_int=4
   return
  endif

  call check_int(x8(1),x8(2),ret)
  if (ret == 't') then
   kind_of_int=8
   return
  endif

end function kind_of_int

program same_int_long
  integer ki,kl

  ki=kind_of_int()
  kl=kind_of_long()
  if (ki /= kl) then
    write (*,'(i1)') 0
  else
    write (*,'(i1)') 1
  endif
end program same_int_long

以下是makeZ/view?usp=共享的完整日志信息

EN

回答 2

Stack Overflow用户

发布于 2022-03-03 14:04:41

这是用MPI fortran代码附加给我的。原因是gcc开发人员就什么应该是好的界面( 请看这里 )作出决定。就我的情况而言,有两种解决办法:

  • 告诉gfortran使用选项-fallow-argument-mismatch忽略这个问题。
  • 使用现代的fortran接口(use mpi而不是include mpif.h),我选择了后者。
票数 4
EN

Stack Overflow用户

发布于 2021-10-23 09:44:08

实例化为整数的是由另一个(变量或声明)整数分配的不同“字节”内存存储大小的值。例如,在其他语言中,int是4个字节,长是8个字节。(注意) Fortran也有指针-- C/C++ https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vna5/index.html nb:您没有在源文件same_int_long.f90中的第29 char 18行附近显示有问题的代码吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69686755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档