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

changing dummy argument in the interface leads to error.

sinozhan
Beginner
1,006 Views

!*****************************************
!this function can compute the sum of a,b,and c or compute the sum of a,b,c and d.
function s(a,b,c,d) result(s_result)
implicit none
real,intent(in) ::a,b,c
real::s_result,temp_d
real,optional,intent(in)::d
if(present(d))then
temp_d=d
else
temp_d=0
endif
s_result=a+b+c+temp_d
end function s

!***********************************
program cal_sum
implicit none
INTERFACE
function s(upper,down,left,right) result(s_result)
implicit none
real,intent(in) ::upper,down,left
real:: s_result
real,optional,intent(in)::right
end function s
END INTERFACE

print *,s(d=1000.0,a=1.0,b=10.0,c=100.0) !it is correct.
print *,s(upper=3.0,down=4.0,left=5.0) !there is something wrong with this sentence.
! Error: This is an actual argument keyword name, and not a dummy argument name. [UPPER]
pause
end program cal_sum

!Please help me ,thanks a lot.

0 Kudos
1 Reply
Steven_L_Intel1
Employee
1,006 Views
Hmm - seems to be a bug in the generated interface checking. Surprising.

You can turn off generated interface checking (and generation) under the Fortran > Diagnostics property page (two options). An alternative is to make S a contained function (and name the arguments consistently.) Or I suppose you could also make the explicit interface consistent in naming with the actual routine.

My preference is for not using an INTERFACE block when calling Fortran code - either make the called routine a CONTAINed routine or put it in a module.
0 Kudos
Reply