Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29375 Discussions

Problem when passing arguments to a set of functions

Daniel_A_
Beginner
647 Views

Hi,

I am having problem when using a set functions and I do not know how to proceed to fix the errors. I have attached a bit of the code at the end of this post. My intention is to pass the arguments X to the function NU1, which in turn should call two other functions (M,PX) with the same arguments. The calculated value should thereafter be saved in the variable F1.

I get the following type of errors:

error #6579: A dummy argument of a statement function is invalid in this context.   [XIN]

error #6073: The statement function arguments must not be array-valued.   [NU1]

Any idea on how to resolve the errors is appreciated.

Thanks in advance!

 PROGRAM KINET
      IMPLICIT REAL*8(A-H,O-Z)
      REAL P,R,RHOC,DCHAR, XC0, F1
      REAL X(7), A(4), K(7), KP(4), KA(4), EA(4)
      
      ! Functions
      PX(XIN) = (XIN(1)+XIN(2)+XIN(3)+XIN(4)+XIN(5)+XIN(6)+XIN(7))*
     +          1.0/P
      M(XIN) = (K(2)+1.0/P)*XIN(2)+(K(3)+1.0/P)*XIN(3)+(K(4)+1.0/P)*
     +          XIN(4)+(K(5)+1.0/P)*XIN(5)+(K(6)+1.0/P)*XIN(6)+
     +          (K(7)+1.0/P)*XIN(7)
      NU1(XIN) = -KA(1)*((XIN(5)-XIN(3)**2/(PX(XIN)*KP(1)))/M(XIN))*
     +            (XC0/XIN(1))**(1.0/3.0)*XIN(1)/(RHOC*DCHAR)
      !---------------------------------------------------
      P = 1
      RHOC = 1300.00
      DCHAR = 0.50E-3
      EA(1)=77390.00
      EA(2)=121620.00
      EA(3)=19210.00
      EA(4)=36150.00
      A(1)= 3.616E1
      A(2)= 1.517E4
      A(3)= 4.189E-3
      A(4)= 7.301E-2
      K(1) = 0.0
      K(2) = 7.59
      K(3) = 2.6E-4
      K(4) = 6.5E-5
      K(5) = 1.98E-5
      K(6) = 0.0
      K(7) = 0.0
      KP(1) = 205.4924
      KP(2) = 162.2103
      KP(3) = 0.1125828
      KP(4) = 1440.815
      KA(1) = 1.2956897E-02
      KA(2) = 5.8338180E-02
      KA(3) = 5.8452162E-04
      KA(4) = 1.7940423E-03
      X(1)= 0.427491
      X(2)= 0.00
      X(3)= 0.00
      X(4)= 0.477754
      X(5)= 0.365797
      X(6)= 0.206712
      X(7)= 0.29
      XC0 = X(1)
      
      F1 = NU1(X)

      END PROGRAM KINET

 

0 Kudos
2 Replies
mecej4
Honored Contributor III
647 Views

Dummy arguments of statement functions must be scalar. Rewrite the statement functions as CONTAINED, EXTERNAL or MODULE procedures, or simply  calculate the statement functions in-line, as in:

      PROGRAM KINET
c      IMPLICIT REAL*8(A-H,O-Z)
      REAL P,R,RHOC,DCHAR, XC0, F1,M,NU1,PX
      REAL X(7), A(4), K(7), KP(4), KA(4), EA(4)

      ! Functions
      !---------------------------------------------------
      P = 1
      RHOC = 1300.00
      DCHAR = 0.50E-3
      EA(1)=77390.00
      EA(2)=121620.00
      EA(3)=19210.00
      EA(4)=36150.00
      A(1)= 3.616E1
      A(2)= 1.517E4
      A(3)= 4.189E-3
      A(4)= 7.301E-2
      K(1) = 0.0
      K(2) = 7.59
      K(3) = 2.6E-4
      K(4) = 6.5E-5
      K(5) = 1.98E-5
      K(6) = 0.0
      K(7) = 0.0
      KP(1) = 205.4924
      KP(2) = 162.2103
      KP(3) = 0.1125828
      KP(4) = 1440.815
      KA(1) = 1.2956897E-02
      KA(2) = 5.8338180E-02
      KA(3) = 5.8452162E-04
      KA(4) = 1.7940423E-03
      X(1)= 0.427491
      X(2)= 0.00
      X(3)= 0.00
      X(4)= 0.477754
      X(5)= 0.365797
      X(6)= 0.206712
      X(7)= 0.29
      XC0 = X(1)

      PX = (X(1)+X(2)+X(3)+X(4)+X(5)+X(6)+X(7))/P
      M = (K(2)+1.0/P)*X(2)+(K(3)+1.0/P)*X(3)+(K(4)+1.0/P)*
     +          X(4)+(K(5)+1.0/P)*X(5)+(K(6)+1.0/P)*X(6)+
     +          (K(7)+1.0/P)*X(7)
      NU1 = -KA(1)*((X(5)-X(3)**2/(PX*KP(1)))/M)*
     +            (XC0/X(1))**(1.0/3.0)*X(1)/(RHOC*DCHAR)
      F1 = NU1
      write(*,*)F1

      END PROGRAM KINET

 

0 Kudos
Daniel_A_
Beginner
647 Views

Thanks for the help!

0 Kudos
Reply