replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Workaround for C_F_POINTER
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Workaround for C_F_POINTER
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
jlb



Joined: 21 Oct 2020
Posts: 79

PostPosted: Tue Nov 05, 2024 3:23 pm    Post subject: Reply with quote

Paul
Thank you for the clarification.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8145
Location: Salford, UK

PostPosted: Tue Nov 05, 2024 5:18 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 79

PostPosted: Tue Nov 05, 2024 5:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
jlb



Joined: 21 Oct 2020
Posts: 79

PostPosted: Wed Feb 26, 2025 1:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8145
Location: Salford, UK

PostPosted: Wed Feb 26, 2025 4:52 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 79

PostPosted: Thu Feb 27, 2025 12:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8145
Location: Salford, UK

PostPosted: Thu Feb 27, 2025 12:45 pm    Post subject: Reply with quote

jlb

Thank you for the bug report. I have logged this for investigation.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8145
Location: Salford, UK

PostPosted: Tue Mar 11, 2025 2:38 pm    Post subject: Reply with quote

This failure has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 79

PostPosted: Wed Mar 12, 2025 10:48 am    Post subject: Reply with quote

Paul

Thank you for your prompt assistance. Is this an interim release or a full release of FTN95?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8145
Location: Salford, UK

PostPosted: Wed Mar 12, 2025 1:02 pm    Post subject: Reply with quote

It will probably be an interim release following the full release of the personal edition of FTN95 v9.10.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group