本文介绍了修复FORTRAN IV警告:“参数的数量与intrinsinc过程不兼容,假定'external'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我需要运行一个旧的FORTRAN IV代码(我认为它运行得很好)。我下载了英特尔编译器的试用版,并尝试编译我使用以下命令给出的源文件: ifort -f66 abel .for -o mycode 其中abel.for是源文件的名称。我收到了一堆警告和错误。我想问一下我得到的第一个警告: 参数的数量与intrinsinc过程不兼容,假设'external' 。 [KNOT] 其中KNOT是一个函数,定义如下: C AAOK0162 C用于定位样条曲线部分的程序,其中AAOK0163 C为自变量BELONGS。 AAOK0164 CN样条表示中的节点数AAOK0165 CU节点位置AAOK0166 CX发现样条节的理由AAOK0167 CI最小的节点数超过X AAOK0168 C AAOK0169 INTEGER FUNCTION KNOT(N,U,X)AAOK0170 IMPLICIT REAL * 8(AH,OZ)AAOK0171 DIMENSION U(1)AAOK0172 C测试范围是否在范围AAOK0173 IF(X.LT.U(1))GOTO 990 AAOK0174 IF(X.GT.U(N))GOTO 990 AAOK0175 C ESTIMATE KNOT INTERVAL通过假设EQU ALLY SPACED KNOTS AAOK0176 J = DABS(XU(1))/(U(N)-U(1))*(N-1)+1 AAOK0177 C确保案例X = U(N )GIVES J = N-1 AAOK0178 J = MIN0(J,N-1)AAOK0179 C搜索包含X AAOK0180 IF(X.GE.U(J))的结点间隔GOTO 11 AAOK0181 2 J = J-1 AAOK0182 IF(X.LT.U(J))GOTO 2 AAOK0183 GOTO 7 AAOK0184 1 J = J + 1 AAOK0185 11 IF(X.GT.U(J + 1))GOTO 1 AAOK0186 7 KNOT = J + 1 AAOK0187 RE TURN AAOK0188 990 KNOT = -1 AAOK0189 RETURN AAOK0190 END AAOK0191 并且编译器错误指示从后续子例程(行AAOK0211)调用此函数: SUBROUTINE ABEL1(N ,IN,X,XN,A,B,C,D,YCALC)AAOK0201 IMPLICIT REAL * 8(AH,OZ)AAOK0202 DIMENSION X(1),XN(1),A )B(1),C(1),D(1),YCALC(1)AAOK0203 COMMON / R / R AAOK0204 COMMON / PI / PI AAOK0205 DO 70 L = 1,IN A AOK0206 R = X(L)AAOK0207 IF(R.EQ.0.D0)R = 1.D-6 AAOK0208 YCALC(L)= 0.D0 AAOK0209 IF(R.EQ.XN(N + 1))R = R-1.D-6 AAOK0210 I = KNOT(N + 1,XN,R)AAOK0211 IF(I.EQ 。-1)GOTO 70 AAOK0212 IF(I.EQ.N + 1)GOTO 99 AAOK0213 DO 60 K = I,N AAOK0214 X1 = XN(K)AAOK0215 $ b $ (K)* DI1(2,X1,X2)+ 2.D0 * B(K)* DI1(1,X1,X2)x2 = XN(K + 1)AAOK0216 S = 3.D0 * )+ C(K)* DI1(0,X1,X2)AAOK0217 YCALC(L)= YCALC(L)+ S AAOK0218 60 CONTINUE AAOK0219 99 X2 = XN(I)AAOK0220 S = 3.D0 * A(I-1)* DI1(2,R,X2)+ 2.D0 * B(I-1)* DI1(1,R,X2)AAOK0221 * + C(I-1)* DI1(0,R,X2)AAOK0222 YCALC(L)= - (YCALC (L)+ S)/ PI AAOK0223 70 CONTINUE AAOK0224 RETURN AAOK0225 END AAOK0226 我想问一下这个警告是怎么产生的,如果忽略它是安全的? 解决方案 KNOT()是 NOT 函数的非标准特定内部函数它接受8个字节的整数(请参见 https://docs.oracle。 com / cd / E19422-01 / 819-3684 / 3_F77_Intrins.html )。 在这种情况下,您确实可以忽略警告。由于参数的数量和类型不同,编译器不会无意中调用内部函数,所以它是安全的。如果编译器有一个看起来完全一样但功能完全不同的函数,问题就会出现。 外部语句用于防止这种冲突。 您可以采取的措施来抑制警告通过放置 KNOT() > EXTERNAL * KNOT 在每个编译单元的声明部分调用 KNOT ,例如, SUBROUTINE ABEL1(N,IN,X,XN,A,B ,C,D,YCALC) IMPLICIT REAL * 8(AH,OZ) EXTERNAL * KNOT 这个类型在给定隐式输入规则时应该是完全正确的,但是您可以通过显式指定它: INTEGER KNOT 注意: * code> in EXTERNAL * KNOT 表示不应该使用内部函数,而应该使用用户提供的函数。这种行为不同于现代Fortran!请参阅 http://h21007.www2。 hp.com/portal/download/files/unprot/fortran/docs/lrm/lrm0633a.htm 在FORTRAN 77和更高版本中,只需使用 EXTERNAL KNOT 。 p> I need to run an old FORTRAN IV code I was given (which is supposed to run just fine). I downloaded a trial version of Intel compiler and tried to compile the source file I was given with the command:ifort -f66 abel.for -o mycodewhere abel.for is the name of the source file. I got a bunch of warnings and errors. I wanted to ask about the first warning I was given:The number of arguments is incompatible with intrinsinc procedure, assume 'external'. [KNOT]where KNOT is a function defined as:C AAOK0162C PROCEDURE FOR LOCATING THE SPLINE SECTION TO WHICH AN AAOK0163C ARGUMENT BELONGS. AAOK0164C N NUMBER OF KNOTS IN THE SPLINE REPRESENTATION AAOK0165C U KNOTS POSITION AAOK0166C X THE ARGUMENT WHOSE SPLINE SECTION IS SOUGHT AAOK0167C I THE NUMBER OF THE SMALLEST KNOT LARGER THAN X AAOK0168C AAOK0169 INTEGER FUNCTION KNOT(N,U,X) AAOK0170 IMPLICIT REAL*8(A-H,O-Z) AAOK0171 DIMENSION U(1) AAOK0172C TEST WHETHER POINT IN RANGE AAOK0173 IF (X.LT.U(1)) GOTO 990 AAOK0174 IF (X.GT.U(N)) GOTO 990 AAOK0175C ESTIMATE KNOT INTERVAL BY ASSUMING EQUALLY SPACED KNOTS AAOK0176 J=DABS(X-U(1))/(U(N)-U(1))*(N-1)+1 AAOK0177C ENSURE CASE X=U(N) GIVES J=N-1 AAOK0178 J=MIN0(J,N-1) AAOK0179C SEARCH FOR KNOT INTERVAL CONTAINING X AAOK0180 IF (X.GE.U(J)) GOTO 11 AAOK01812 J=J-1 AAOK0182 IF(X.LT.U(J)) GOTO 2 AAOK0183 GOTO 7 AAOK01841 J=J+1 AAOK018511 IF(X.GT.U(J+1)) GOTO 1 AAOK01867 KNOT=J+1 AAOK0187 RETURN AAOK0188990 KNOT=-1 AAOK0189 RETURN AAOK0190 END AAOK0191and the compiler error indicates the call of this function from a subsequent subroutine (line AAOK0211): SUBROUTINE ABEL1(N,IN,X,XN,A,B,C,D,YCALC) AAOK0201 IMPLICIT REAL*8 (A-H,O-Z) AAOK0202 DIMENSION X(1),XN(1),A(1),B(1),C(1),D(1),YCALC(1) AAOK0203 COMMON /R/ R AAOK0204 COMMON /PI/ PI AAOK0205 DO 70 L=1,IN AAOK0206 R=X(L) AAOK0207 IF(R.EQ.0.D0) R=1.D-6 AAOK0208 YCALC(L)=0.D0 AAOK0209 IF (R.EQ.XN(N+1)) R=R-1.D-6 AAOK0210 I=KNOT(N+1,XN,R) AAOK0211 IF(I.EQ.-1) GOTO 70 AAOK0212 IF(I.EQ.N+1) GOTO 99 AAOK0213 DO 60 K=I,N AAOK0214 X1=XN(K) AAOK0215 X2=XN(K+1) AAOK0216 S=3.D0*A(K)*DI1(2,X1,X2)+2.D0*B(K)*DI1(1,X1,X2)+C(K)*DI1(0,X1,X2) AAOK0217 YCALC(L)=YCALC(L)+S AAOK021860 CONTINUE AAOK021999 X2=XN(I) AAOK0220 S=3.D0*A(I-1)*DI1(2,R,X2)+2.D0*B(I-1)*DI1(1,R,X2) AAOK0221 * +C(I-1)*DI1(0,R,X2) AAOK0222 YCALC(L)=-(YCALC(L)+S)/PI AAOK022370 CONTINUE AAOK0224 RETURN AAOK0225 END AAOK0226I wanted to ask what seems to cause this warning and if it is safe to just ignore it? 解决方案 KNOT() is a non-standard specific intrinsic function for the NOT function which accepts 8 byte integers (see https://docs.oracle.com/cd/E19422-01/819-3684/3_F77_Intrins.html ).You can indeed ignore the warning in this case. Because the numbers and types of the arguments differ, the compiler will not call the intrinsic inadvertently, so it is safe. The problem would be if the compiler had a function which looks exactly the same but does something different. The external statement serves the purpose to prevent such collisions.The thing you can do to suppress the warning is to tell the compiler you have your own external function KNOT() by placingEXTERNAL *KNOTin the declaration section of each compilation unit which calls KNOT, so for example, SUBROUTINE ABEL1(N,IN,X,XN,A,B,C,D,YCALC) IMPLICIT REAL*8 (A-H,O-Z) EXTERNAL *KNOTThe type should be all-right given your implicit typing rules, but you can specify it explicitly by INTEGER KNOTNote: the * in EXTERNAL *KNOT means that not an intrinsic, but a user-supplied function should be used. This behaviour differs from modern Fortran! See http://h21007.www2.hp.com/portal/download/files/unprot/fortran/docs/lrm/lrm0633a.htm In FORTRAN 77 and later use just EXTERNAL KNOT. 这篇关于修复FORTRAN IV警告:“参数的数量与intrinsinc过程不兼容,假定'external'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-13 02:26