- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another problem I meet, trying to call a Fortran function from a C++ program :
How can I pass a structure from C++ in the parameter of the Fortran Function ?
Example :
typedef struct _testst (int test1; int test2) testst, *lptestst;
extern "C" void f1(lptest rec);
What does my Fortran function f1 look like ? In fortran side, do I have to declare rec as a COMMON and how ? Is it also possible to declare it as a STRUCTURE (VMS keyword) ?
If you have any example, it would be great !
Thanks in advance for your answer !
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
subroutine f1 (rec) bind(C,name="f1")
use,intrinsic :: iso_c_binding
type, bind(C) :: testst
integer(C_INT) :: test1
integer(C_INT) :: test2
end type testst
type(testst), intent(inout) :: rec
! code goes here
! components are rec%test1 and rec%test2
end subroutine f1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks for the information, I will try this.
Nevertheless, if I want to use the DEC STRUCTURE/RECORD extension, what would be the syntax to use it in C++ ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer test1
integer test2
end structure
record /testst/ rec
intent(inout) :: rec
I don't know why you would want to do that rather than the standard-conforming method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, this is very simple :
My C++ Project has to call Mathematical Fortran Model made by our technical department. This department used to do their model in VAX VMS.
Now they have to migrate it to a Linux server sothey would like to do the less modification as possible.
That's why I want to keep the syntax of VMS Fortran.
Thanks a lot for your answer !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The INTENT is optional and is primarily there to aid in error checking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I understand, but the code of this model containt some call to SYS$ of OpenVMS system that cannot be use in linux.
So the code has to be change in this way. Nevertheless, you mean that the actual syntax used for OpenVMS will be applied to the linux system ? Won't I have any problem if I keep for examplea REAL*4 which has to be modified by C++ ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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