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

如何在ifort命令行/ifort.cfg中忽略#6633实参与哑参类型不匹配错误

Intel Fortran编译旧代码的接口检查问题及解决方法

问题背景

使用ifort 2022.1.0编译一段无人维护的Fortran代码时,出现错误:error #6633: The type of the actual argument differs from the type of the dummy argument.。已知在Intel Visual Fortran中可通过设置“属性->Fortran->诊断->检查例程接口->[否]”绕过该检查,但仅能使用命令行版本,需了解是否可通过ifort.cfg文件实现相同效果,或其他可行方案。


报错相关代码片段

主调用子程序代码

subroutine aovec_aosph_nw2ac(ntot,natom,aoind,aostr,geoind,trmat,fileout)
   use mod_fun
   use mod_print
   implicit none
   integer ntot,natom,fileout
   integer aoind(ntot,5),geoind(natom,3)
   double precision trmat(ntot,ntot)
   character(4) aostr(ntot,2)
   integer aotmp(5)
   integer i,j,k,b1,b2,c1,c2,k1,k2,l1,l2,m1,m2

!  aoind(i,j,k,l,m) i:nw-order/j:atom/k:ang/l:ang(lz)/m:ang(lz,ind)
!  geoind(a,b,c)    a:atom/b:atom-group/c:group-ind
!  aces-ind         b->k->l->m->c
   do i = 1,ntot-1
   do j = i+1,ntot
      ! atom group
      b1=geoind(aoind(i,2),2)
      b2=geoind(aoind(j,2),2)
      if (b2.lt.b1) then
         call rot_aoind(ntot,aoind,i,j)
      elseif (b2.eq.b1) then
         ! angular momentum
         k1=aoind(i,3)
         k2=aoind(j,3)
         if (k2.lt.k1) then
            call rot_aoind(ntot,aoind,i,j)
         elseif (k2.eq.k1) then
            ! angular momentum (z-axis)
            l1=aoind(i,4)
            l2=aoind(j,4)
            if (l2.lt.l1) then
               call rot_aoind(ntot,aoind,i,j)
            elseif (l2.eq.l1) then
               ! angular momentum (z-axis,index)
               m1=aoind(i,5)
               m2=aoind(j,5)
               if (m2.lt.m1) then
                  call rot_aoind(ntot,aoind,i,j)
               elseif (m2.eq.m1) then
                  ! atom group index
                  c1=aoind(i,2)
                  c2=aoind(j,2)
                  if (c2.lt.c1) then
                     call rot_aoind(ntot,aoind,i,j)
                  endif
               endif
            endif
         endif
      endif
   enddo
   enddo

   write(fileout,'(/,a)') '* aolab (nwchem rotated)'
   do i = 1,ntot
      write(fileout,'(5i5,2a4)') (aoind(i,j),j=1,5), &
           (aostr(aoind(i,1),k),k=1,2)
   enddo

   trmat(1:ntot,1:ntot) = 0.0d0
   do i = 1,ntot
      trmat(aoind(i,1),i) = 1.0d0  
   enddo

   write(fileout,'(/,a)') '* trmat (nwchem rotated)'
   call print_rmat(trmat,ntot*ntot,ntot,ntot,fileout,2)
end subroutine aovec_aosph_nw2ac

rot_aoind子程序代码

subroutine rot_aoind(ntot,aoind,ind1,ind2)                                                                                                       
   implicit none
   integer ntot,aoind(ntot,5),ind1,ind2
   integer k,aotmp(5)
   do k = 1, 5  
      aotmp(k)      = aoind(ind1,k) 
      aoind(ind1,k) = aoind(ind2,k)
      aoind(ind2,k) = aotmp(k)
   enddo
end subroutine rot_aoind

编译命令

ifort file.f90

错误信息

file.f90(21): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
         call rot_aoind(ntot,aoind,i,j)
------------------------^
file.f90(21): error #6633: The type of the actual argument differs from the type of the dummy argument.   [AOIND]
         call rot_aoind(ntot,aoind,i,j)
-----------------------------^
file.f90(21): warning #6075: The data type of the actual argument does not match the definition.   [I]
         call rot_aoind(ntot,aoind,i,j)
-----------------------------------^
file.f90(21): warning #6075: The data type of the actual argument does not match the definition.   [J]
         call rot_aoind(ntot,aoind,i,j)
-------------------------------------^
file.f90(27): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
            call rot_aoind(ntot,aoind,i,j)
---------------------------^
file.f90(27): error #6633: The type of the actual argument differs from the type of the dummy argument.   [AOIND]
            call rot_aoind(ntot,aoind,i,j)
--------------------------------^
file.f90(27): warning #6075: The data type of the actual argument does not match the definition.   [I]
            call rot_aoind(ntot,aoind,i,j)
--------------------------------------^
file.f90(27): warning #6075: The data type of the actual argument does not match the definition.   [J]
            call rot_aoind(ntot,aoind,i,j)
----------------------------------------^
file.f90(33): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
               call rot_aoind(ntot,aoind,i,j)
------------------------------^
file.f90(33): error #6633: The type of the actual argument differs from the type of the dummy argument.   [AOIND]
               call rot_aoind(ntot,aoind,i,j)
-----------------------------------^
file.f90(33): warning #6075: The data type of the actual argument does not match the definition.   [I]
               call rot_aoind(ntot,aoind,i,j)
-----------------------------------------^
file.f90(33): warning #6075: The data type of the actual argument does not match the definition.   [J]
               call rot_aoind(ntot,aoind,i,j)
-------------------------------------------^
file.f90(39): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
                  call rot_aoind(ntot,aoind,i,j)
---------------------------------^
file.f90(39): error #6633: The type of the actual argument differs from the type of the dummy argument.   [AOIND]
                  call rot_aoind(ntot,aoind,i,j)
--------------------------------------^
file.f90(39): warning #6075: The data type of the actual argument does not match the definition.   [I]
                  call rot_aoind(ntot,aoind,i,j)
--------------------------------------------^
file.f90(39): warning #6075: The data type of the actual argument does not match the definition.   [J]
                  call rot_aoind(ntot,aoind,i,j)
----------------------------------------------^
file.f90(45): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
                     call rot_aoind(ntot,aoind,i,j)
------------------------------------^
file.f90(45): error #6633: The type of the actual argument differs from the type of the dummy argument.   [AOIND]
                     call rot_aoind(ntot,aoind,i,j)
-----------------------------------------^
file.f90(45): warning #6075: The data type of the actual argument does not match the definition.   [I]
                     call rot_aoind(ntot,aoind,i,j)
-----------------------------------------------^
file.f90(45): warning #6075: The data type of the actual argument does not match the definition.   [J]
                     call rot_aoind(ntot,aoind,i,j)
-------------------------------------------------^
file.f90(66): warning #6075: The data type of the actual argument does not match the definition.
   call print_rmat(trmat,ntot*ntot,ntot,ntot,fileout,2)
-----------------------------^
file.f90(66): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
   call print_rmat(trmat,ntot*ntot,ntot,ntot,fileout,2)
-----------------------------------^
file.f90(66): warning #6075: The data type of the actual argument does not match the definition.   [NTOT]
   call print_rmat(trmat,ntot*ntot,ntot,ntot,fileout,2)
----------------------------------------^
file.f90(66): warning #6075: The data type of the actual argument does not match the definition.   [FILEOUT]
   call print_rmat(trmat,ntot*ntot,ntot,ntot,fileout,2)
---------------------------------------------^
compilation aborted for file.f90 (code 1)

解决方法

方法1:命令行直接关闭接口检查

Intel Visual Fortran中“检查例程接口->[否]”对应的命令行选项为-check nointerfaces,直接添加到编译命令即可:

ifort -check nointerfaces file.f90

方法2:通过ifort.cfg文件全局设置

ifort会自动读取当前目录或指定路径下的ifort.cfg配置文件,在文件中添加以下内容,即可每次编译自动应用该选项:

-check nointerfaces

若需指定cfg文件路径,可设置环境变量IFORT_CONFIG指向目标文件。

方法3:修复代码(更可靠的长期方案)

报错根源是rot_aoind子程序未在调用前声明,导致编译器无法校验接口匹配。可在aovec_aosph_nw2ac的implicit none后添加接口声明:

interface
    subroutine rot_aoind(ntot,aoind,ind1,ind2)
        integer ntot,aoind(ntot,5),ind1,ind2
    end subroutine rot_aoind
end interface

或把rot_aoind放入模块中,在主子程序中use该模块,即可让编译器自动校验接口,消除报错。


内容的提问来源于stack exchange,提问作者Grzegorz Skrzyński

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 15:00:53