- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!*****************************************
!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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page