- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to pass a function or subroutine as a component of a derived type variable? If so, how is it done?
Thanks in advance,
Olivier
Thanks in advance,
Olivier
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - opmkl
Is it possible to pass a function or subroutine as a component of a derived type variable? If so, how is it done?
Thanks in advance,
Olivier
Thanks in advance,
Olivier
This is possible with Fortran 2003 using type-bound procedures. IVF has support for this in v11.1
The syntax is the following:
TYPE :: A
REAL :: val
CONTAINS
PROCEDURE :: PROC
END TYPE A
regards,
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thomas describes what is called a type-bound procedure. This may or may not be what you want. The compiler also supports procedure pointers as components of a derived type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thomas, Steve, thanks to both of you. The two suggested solutions would work well for what I want to do. I had kind of forgotten the procedure pointer technique, which was already available in previous versions of IVF and which I used in the past as well...
Thanks again- and have a nice day!
Olivier
Thanks again- and have a nice day!
Olivier

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