- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am in the midst of write a small Fortran library and found a need to define a template for a set of methods and instantiate them using it for different intrinsic types. With GNU fortran, I did something along the line of the following.
[cpp]#define TEMPLATE(type_name,size) \\
TYPE(type_name) FUNCTION PROCNAME(init,type_name) result(o) ;\\
... ;\\
END FUNCTION PROCNAME(init,type_name) ;\\
SUBROUTINE PROCNAME(push,type_name)(this) ; \\
CLASS(type_name), INTENT(INOUT) :: this ; \\
... ; \\
END SUBROUTINE PROCNAME(push,type_name) [/cpp]
This worked O.K. with GNU Fortran 4.8.0. But ifort 14.0 complains with
error #5141: END statement must be only statement on line
Is there a work-around to have multiple subroutine definitions in a single line?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have this:
END SUBROUTINE PROCNAME(push,type_name)
In the END SUBROUTINE statement, you can name the subroutine but you DON'T repeat the argument list. If gfortran is accepting this, that's their bug,
However... We do seem to have an inappropriate restriction on using "Free form statement termination" with the END statement. I will let the developers know. Issue ID is DPD200248828.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve for quick response.
PROCNAME(push,type_name) is actually a macro and it expands to a procedure name.
And, interestingly, ifort is o.k. with 'END TYPE typename' followed by ';' and more statements.
So, I don't have any other way than breaking up the big macro and have each macro definition contain only one procedure/function definition?
Thanks a lot..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't think of anything offhand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It turns out that we don't have a bug after all. Interpretation 90/0130 covers exactly this situation where one has something like:
END; SUBROUTINE S
The interpretation reworded the introductory text for free source form from:
"A Fortran program unit is a sequence of one or more Fortran statements, comments and INCLUDE lines."
to:
"A Fortran program unit is a sequence of one or more lines, organized as Fortran statements, comments and INCLUDE lines."
The subtle distinction is that a line cannot contain pieces of more than one program unit.

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