View previous topic :: View next topic |
Author |
Message |
jlb
Joined: 21 Oct 2020 Posts: 79
|
Posted: Tue Nov 05, 2024 3:23 pm Post subject: |
|
|
Paul
Thank you for the clarification. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8145 Location: Salford, UK
|
Posted: Tue Nov 05, 2024 5:18 pm Post subject: |
|
|
jlb
I should have added...
Users with a support licence are notified directly about full releases by Silverfrost Ltd.
Users of the personal edition can download full releases from the Silverfrost.com website. |
|
Back to top |
|
 |
jlb
Joined: 21 Oct 2020 Posts: 79
|
Posted: Tue Nov 05, 2024 5:28 pm Post subject: |
|
|
Paul
Thank you. I was just wondering as the new implementation was announced for an interim release, but the also needed mod file as in a full release. |
|
Back to top |
|
 |
jlb
Joined: 21 Oct 2020 Posts: 79
|
Posted: Wed Feb 26, 2025 1:41 pm Post subject: |
|
|
Using FTN95 v. 9.10, a call like
Code: | CALL C_F_POINTER(c_string_pointer, char_array_pointer, [255]) |
still produces an error at compile time
Quote: | error 1251 - Invalid arguments in call to C_F_POINTER |
Note: Looking inside ISO_C_BINDING.MOD (in \Silverfrost\FTN95\include) with a editor doesn't show any string C_F_POINTER |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8145 Location: Salford, UK
|
Posted: Wed Feb 26, 2025 4:52 pm Post subject: |
|
|
jlb
C_F_POINTER does not appear in the module because it has to be created by FTN95.
It is non-trivial and I found it difficult to use. The sample program below works for x64 and uses a test function defined in ClearWin64.dll.
Code: | program main
use iso_c_binding,only:c_ptr,c_f_pointer
implicit none
interface
subroutine c_f_pointer_test$(p) bind(c,name='__c_f_pointer_test')
import :: c_ptr
type(c_ptr), intent(out) :: p
end subroutine
end interface
type(c_ptr) :: cptr
real,pointer :: a(:)
real,pointer :: b(:,:)
real,pointer :: c
real::ss1,ss2
integer s(1)
call c_f_pointer_test$(cptr)
s = [12]
call c_f_pointer(cptr, a, s)
ss1 = sum(a)
call c_f_pointer(cptr, b, [3,4])
ss2 = sum(b)
call c_f_pointer(cptr, c)
if(ss1 == ss2 .and. c == 1.0) print*, "Success"
end program main |
Code: | extern "C" void __c_f_pointer_test(float*& a)
{
a = (float*)malloc(12 * sizeof(float));
float* b = a;
for (int i = 1; i <= 12; ++i) *b++ = (float)i;
}
|
|
|
Back to top |
|
 |
jlb
Joined: 21 Oct 2020 Posts: 79
|
Posted: Thu Feb 27, 2025 12:35 pm Post subject: |
|
|
Paul
Thanks for providing me with a working example. It allowed me to create a reproducer for error 1251 at compile time using FTN95 v.9.10 x64. The reproducer compiles with ifort.
Code: | program main
use iso_c_binding,only:c_ptr,c_f_pointer
implicit none
interface
subroutine c_f_pointer_test$(q) bind(c,name='__c_f_pointer_test')
import :: c_ptr
type(c_ptr), intent(out) :: q
end subroutine
end interface
type(c_ptr) :: cptr
REAL :: X
call c_f_pointer_test$(cptr)
X=TEST(cptr)
PRINT*, X
CONTAINS
REAL FUNCTION TEST(J)
implicit none
type(c_ptr), INTENT(IN) :: J
real,pointer :: a(:)
real,pointer :: b(:,:)
real,pointer :: c
real::ss1,ss2
integer s(1)
s = [12]
call c_f_pointer(J, a, s)
ss1 = sum(a)
call c_f_pointer(J, b, [3,4])
ss2 = sum(b)
call c_f_pointer(J, c)
if(ss1 == ss2 .and. c == 1.0) print*, "Success"
TEST=a(12)
END FUNCTION TEST
end program main |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8145 Location: Salford, UK
|
Posted: Thu Feb 27, 2025 12:45 pm Post subject: |
|
|
jlb
Thank you for the bug report. I have logged this for investigation. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8145 Location: Salford, UK
|
Posted: Tue Mar 11, 2025 2:38 pm Post subject: |
|
|
This failure has now been fixed for the next release of FTN95. |
|
Back to top |
|
 |
jlb
Joined: 21 Oct 2020 Posts: 79
|
Posted: Wed Mar 12, 2025 10:48 am Post subject: |
|
|
Paul
Thank you for your prompt assistance. Is this an interim release or a full release of FTN95? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8145 Location: Salford, UK
|
Posted: Wed Mar 12, 2025 1:02 pm Post subject: |
|
|
It will probably be an interim release following the full release of the personal edition of FTN95 v9.10. |
|
Back to top |
|
 |
|