diff options
| author | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:55 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:55 +0200 |
| commit | de18fc13175a5bf0e2b48a042d2fc06e87c88d24 (patch) | |
| tree | f517074cd603d30eb7ba7e2122d38051e4c1439c /map65/libm65/datcom_ptrs_mod.f90 | |
| parent | b76e8361909e47f0937d4a64a5a4cb5939f51eb7 (diff) | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
Update upstream source from tag 'upstream/3.0.2+dfsg'
Update to upstream version '3.0.2+dfsg'
with Debian dir 90381fe7be9f5ea84d9b16c9cccf200a3fbe138b
Diffstat (limited to 'map65/libm65/datcom_ptrs_mod.f90')
| -rw-r--r-- | map65/libm65/datcom_ptrs_mod.f90 | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/map65/libm65/datcom_ptrs_mod.f90 b/map65/libm65/datcom_ptrs_mod.f90 new file mode 100644 index 00000000..bcc8d41a --- /dev/null +++ b/map65/libm65/datcom_ptrs_mod.f90 @@ -0,0 +1,85 @@ +module datcom_ptrs_mod + use iso_c_binding + implicit none + + ! Fortran pointer targets + real(c_float), pointer, contiguous :: dd(:,:) => null() ! [4, 5760000] + real(c_float), pointer, contiguous :: ss(:,:,:) => null() ! [4, 322, NFFT] + real(c_float), pointer, contiguous :: savg(:,:) => null() ! [4, NFFT] + + ! Scalar values + integer, parameter :: NFFT=32768 !Length of FFTs + integer(c_int) :: junk1 = 0, junk2 = 0, quitid = 0 + +contains + + ! Helper subroutine to copy fixed-length Fortran string to C buffer + subroutine move_chars(dest, dest_len, src) + integer(c_int), intent(in) :: dest_len + character(kind=c_char), intent(out) :: dest(dest_len) + character(len=*), intent(in) :: src + integer :: i, n + + n = min(len(src), dest_len) + do i = 1, n + dest(i) = src(i:i) + end do + end subroutine move_chars + + subroutine set_dd_ptr(ptr, dim1, dim2) bind(C, name="set_dd_ptr") + use iso_c_binding + implicit none + type(c_ptr), value :: ptr + integer(c_int), value :: dim1, dim2 + call c_f_pointer(ptr, dd, [dim1, dim2]) + print *, "Fortran: dd pointer associated with dimensions", dim1, dim2 + end subroutine + + subroutine set_ss_ptr(ptr, dim1, dim2, dim3) bind(C, name="set_ss_ptr") + use iso_c_binding + implicit none + type(c_ptr), value :: ptr + integer(c_int), value :: dim1, dim2, dim3 + call c_f_pointer(ptr, ss, [dim1, dim2, dim3]) + print *, "Fortran: ss pointer associated with dimensions", dim1, dim2, dim3 + end subroutine + + subroutine set_savg_ptr(ptr, dim1, dim2) bind(C, name="set_savg_ptr") + use iso_c_binding + implicit none + type(c_ptr), value :: ptr + integer(c_int), value :: dim1, dim2 + call c_f_pointer(ptr, savg, [dim1, dim2]) + print *, "Fortran: savg pointer associated with dimensions", dim1, dim2 + end subroutine + + function get_junk1() bind(C, name="get_junk1") + integer(c_int) :: get_junk1 + get_junk1 = junk1 + end function + + function get_junk2() bind(C, name="get_junk2") + integer(c_int) :: get_junk2 + get_junk2 = junk2 + end function + +subroutine set_quitid(val) bind(C, name="set_quitid") + use iso_c_binding + integer(c_long_long), value :: val + quitid = val + ! print*,'DATCOM_PTRS_MOD QUITID is:',quitid + end subroutine + + subroutine set_junk1(val) bind(C, name="set_junk1") + use iso_c_binding + integer(c_int), value :: val + junk1 = val + end subroutine + + subroutine set_junk2(val) bind(C, name="set_junk2") + use iso_c_binding + integer(c_int), value :: val + junk2 = val + end subroutine + +end module datcom_ptrs_mod |
