- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am using FOTRAN 9.1 and I would like to know how to do two things with the following code. Currently I have:
[cpp] integer*4, POINTER :: xrftest_get !ms$attributes dllimport :: xrftest_get cDEC$ ATTRIBUTES EXTERN :: XRFTEST_GET !ms$attributes C, alias : '_xrftest_get' :: xrftest_get integer*4, pointer :: F1 F1 => xrftest_get(10) F1 = 453 And on the C side I have int a; __declspec (dllexport) void *xrftest_get(int a) { return &a; } [/cpp]
Is there a way to assign F1 the address without specifying the type for the function "integer*4, POINTER :: xrftest_get"
Perhaps a void type like in C?
Also, is there a way to do this for arrays, I tried without success:
[cpp] integer*4, POINTER :: xrftest_get(:) !ms$attributes dllimport :: xrftest_get cDEC$ ATTRIBUTES EXTERN :: XRFTEST_GET !ms$attributes C, alias : '_xrftest_get' :: xrftest_get integer*4, pointer :: F1(:) F1 => xrftest_get(10) F1(2) = 453 And the C part looks like: int abc[10] = {123,432,65,87,89,243,456,6,78,35}; __declspec (dllexport) void *xrftest_get(int a) { return &abc[0]; }[/cpp]
[cpp]
[/cpp]
[cpp][/cpp]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C_FUNPTR is implemented in current ifort. You would need to upgrade.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C_FUNPTR is implemented in current ifort. You would need to upgrade.
That's C_F_PTR in intrinsic module ISO_C_BINDING. Provided in version 10.0 and later. The C interoperability stuff from Fortran 2003 is really neat.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's C_F_PTR in intrinsic module ISO_C_BINDING. Provided in version 10.0 and later. The C interoperability stuff from Fortran 2003 is really neat.
This is my problem, I cannot upgrade because I have a lot of legacy stuff. In fact I even conpile with the CVF switch. Is there any solutionfor the old stuff?
Do you have a link to the ISO_C_BINDING documentation? I'll try to look into upgrading if it still works with the CVF switch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would have had to go out of your way to write something which impedes an upgrade from ifort 9.0. I can't see that any compatibility switches would get in the way of iso_c_binding. There are excellent discussions of iso_c_binding easily found by web search, and there is a good section in the current ifort help file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My error - the name is C_F_POINTER. I don't know what problems you have - the Intel compiler handles "legacy stuff" just fine. You can read about the C Interoperability features in the Intel Fortran Language Reference, part of the compiler documentation you can find here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My error - the name is C_F_POINTER. I don't know what problems you have - the Intel compiler handles "legacy stuff" just fine. You can read about the C Interoperability features in the Intel Fortran Language Reference, part of the compiler documentation you can find here.
Is there a library to link against because I get a link error:
unresolved external symbol
_ISO_C_BINDING_mp_C_F_POINTER_SCALAR
Also, your help files (bldaps_for.chm) seems to point to pages thatare unavailable. Is my proxy affecting this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which compiler version are you using? This should work in version 10.0 and later. No additional libraries needed.
Are you referencing the help pages on your local system, or are you trying to read this .chm file remotely?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which compiler version are you using? This should work in version 10.0 and later. No additional libraries needed.
Are you referencing the help pages on your local system, or are you trying to read this .chm file remotely?
I am using 10.1.019 and I am trying to link the FORTRAN library into the C executable. It's the C executable that has the link error.
For the help, I copied the CHM onto my desktop. This was what your zip contained; and my guess is that it is trying to access the pages remotely.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, ok. In that case you need to do this:
- In the Fortran project, Properties > Libraries. Set the property "Disable default library search rules" to No.
- Tools > Options > Projects > VC++ Directories > Libraries. add: $(IFORT_COMPILER10)IA32Lib to the list.
- Rebuild
All of the compiler documentation is installed on your system - you can get at it through Help in Visual Studio.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, ok. In that case you need to do this:
- In the Fortran project, Properties > Libraries. Set the property "Disable default library search rules" to No.
- Tools > Options > Projects > VC++ Directories > Libraries. add: $(IFORT_COMPILER10)IA32Lib to the list.
- Rebuild
All of the compiler documentation is installed on your system - you can get at it through Help in Visual Studio.
I previously already had these settings. Still the same problem. I have uploaded a small project with the example. It's probably something small and stupid that I am forgetting to set. Any input is greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your attachment isn't showing. You have to click on the attachment filename in the "folder" and click Insert as attachment". Please make sure that your files also include the buildlog.htm from the failed build.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your attachment isn't showing. You have to click on the attachment filename in the "folder" and click Insert as attachment". Please make sure that your files also include the buildlog.htm from the failed build.
I believe I have added both the build project and the htm since I had stripped all building stuff.
I tried to create the same project from scratch with the default settings and it seems to work except for the print in fortran. In any casethe linkerrorcould be related to the CVF option or power station option. Also, I converted this from compaq.
I believe that BOB is not xrftest in the example becuase you have to import xrftest? I fixed this by doing
[cpp] type(C_PTR), bind(C) :: xrftest
!ms$attributes dllimport :: xrftest
cDEC$ ATTRIBUTES EXTERN :: XRFTEST[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your build failed because the C project is specifying the 9.1 Fortran libraries in /LIBPATH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your build failed because the C project is specifying the 9.1 Fortran libraries in /LIBPATH.
It's always a little tweek that is missing. Thanks for your help.

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