我最近继承了过去使用旧版英特尔Visual Fortran编译器构建的Fortran代码。有一段用于编译的代码,但现在抛出错误#6633'实际参数的类型与伪参数的类型不同。'
问题在于使用READ_AND_CONVERT
REAL*4
调用名为DATA_ARRAY(*)
的函数,但在READ_AND_CONVERT
中该参数被声明为INT*2
。我认为它只是想要DATA_ARRAY
的地址。
有没有办法传递DATA_ARRAY
的地址,即使它们属于不同类型?
以下是READ_AND_CONVERT
:
SUBROUTINE READ_AND_CONVERT (MX, N)
C=======================================================================
C Reads Integer*2 Data Array and Converts it to Real*4.
C
C This is a service routine called by subroutines
C READ_XYZ_2, READ_XYZ_4, READ_XYZ_ALL and READ_XYZ_FULL
C=======================================================================
C
IMPLICIT NONE
C
INCLUDE 'XYZ.FOR'
INCLUDE 'COMMON_XYZIO.FOR'
INCLUDE 'COMMON_HDR.FOR'
C
C-----------------------------------------------------------------------
C Local Parameters
C-----------------------------------------------------------------------
C
LOGICAL BB_FOUND
INTEGER*2 MX, MY
INTEGER*4 N, J
REAL*4 YJ, BB
C
DIMENSION MX(*), MY(2)
EQUIVALENCE (YJ, MY(1))
C
C-----------------------------------------------------------------------
C
CALL GET_REAL_PARAMETER ('XYZ$_OFFSET', BB, BB_FOUND)
C
READ (LUGIN) (MX(J), J = 1,N)
C
IF (BB_FOUND) THEN
DO J = N, 1, -1
YJ = (SCALE_FACTOR * MX(J)) + BB
MX(2*J) = MY(2)
MX(2*J-1) = MY(1)
END DO
ELSE
DO J = N, 1, -1
YJ = SCALE_FACTOR * MX(J)
MX(2*J) = MY(2)
MX(2*J-1) = MY(1)
END DO
END IF
C
RETURN
END
答案 0 :(得分:1)
找到解决方案here: 基本上禁用警告...通过设置属性| Fortran |诊断|检查例程接口[从是改为否]
本文还展示了如何在复杂数组的实例中进行转换:
use ISO_C_BINDING
complex(8), allocatable :: c(:)
real(8), pointer:: p(:)
allocate(c(N))
call C_F_POINTER(C_LOC(c), p, [2*N])
call donothing(N, p)
答案 1 :(得分:1)
英特尔Fortran中有指令禁用给定例程和给定参数的参数类型检查。禁用对所有代码的检查是危险的!
!DEC$ ATTRIBUTES NO_ARG_CHECK :: ARGUMENT_NAME
来源:https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/288896