- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Module mytype_module !Example taken from "Fortran 95/2003 explained," by Metcalf, Reid, Cohen, Page 280; !IFORT 16.0.0 compilation fails with !"error #6074: The number of actual arguments does not match the definition. [WRITE]" !when the passed-object argument follows an absent optional argument !It seems to me that ! call x%write !is implemented as ! call write_mytype(x), !instead of ! call write_mytype(this = x), !which could explain the compilation failure Use iso_fortran_env, Only: output_unit Implicit None Type mytype Real :: myvalue(4) = 0 Contains Procedure, Pass(this) :: write => write_mytype End Type mytype Private :: write_mytype Contains Subroutine write_mytype(unit, this) Integer, Optional :: unit Class(mytype), Intent(In) :: this If(Present(unit)) Then Write(unit, *) this%myvalue Else Print '(4f6.3)', this%myvalue End If End Subroutine write_mytype End Module mytype_module Program test Use mytype_module Implicit None Type(mytype) :: x = mytype((/1, 2, 3, 4/)) !WAY to make IFORT compile: Call x%write !comment out this line and !Call x%write(output_unit) !uncomment this, so as to provide the !optional argument End Program test
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, we'll take a look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Escalated as issue DPD200381108 - thanks. I will reply here when there is news.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I expect this to be fixed in the 17.0 compiler (not in the current beta.) Interestingly, the NAG compiler has the same problem - I've let them know about it. The test case isn't exactly from the book, it's an adaptation. (The book example that I saw doesn't have optional arguments.)
Furthermore, my opinion is that the standard could use some clarifying words about how the passed-object is handled to make it clearer what is supposed to happen.

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