Skip to content

Overhaul coarray finalization, convert prif_coarray_handle to be interoperable #320

Open
bonachea wants to merge 16 commits intoBerkeleyLab:mainfrom
bonachea:bind-c-handle
Open

Overhaul coarray finalization, convert prif_coarray_handle to be interoperable #320
bonachea wants to merge 16 commits intoBerkeleyLab:mainfrom
bonachea:bind-c-handle

Conversation

@bonachea
Copy link
Copy Markdown
Member

@bonachea bonachea commented May 5, 2026

Implement the following changes expected in PRIF 0.8, as proposed in https://github.com/BerkeleyLab/prif/issues/157 (proposals 2, 2.1. 2.2, 2.3) and approved in https://github.com/BerkeleyLab/prif/pull/159 :

  • Convert prif_coarray_handle to an interoperable type
  • Convert the final_func argument to prif_allocate_coarray into a procedure pointer named final_proc,
    while adjusting the callback interface and removing the stat/errmsg arguments.
  • Convert prif_local_data_pointer, prif_size_bytes and prif_{get,set}_context_data to be interoperable

bonachea added 16 commits May 1, 2026 20:17
* Replace info field with type(c_ptr)
* Add helper functions to convert between prif_coarray_handle and descriptor pointer (dp)
* Adjust all internal manipulation of prif_coarray_handle
* Make some minor unrelated improvements to affected code while rewriting
* Convert prif_coarray_handle argument from pointer to value
* Convert errmsg argument to kind=c_char
* Update tests
As the redesigned final_func is now supported by all supported compilers
Convert `prif_allocate_coarray(final_func)` argument to:
  `procedure(prif_coarray_cleanup_interface), pointer`

Adjust test code accordingly
Also, add gfortran bug workarounds:

1. Use caf_c_funloc_deref helper to workaround broken c_funloc
2. Use final_func_usher for !HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
As resolved in the 2026-04-16 PRIF Committee meeting

Adjust tests, removing keyword args to work with either version of PRIF
@bonachea bonachea added this to the Caffeine 0.8.0 milestone May 5, 2026
@bonachea bonachea requested a review from ktras May 5, 2026 17:57
@bonachea bonachea added release-blocker Must be resolved before next release priority=high coarray queries PRIF coarray query subroutines prif types storage management labels May 5, 2026
@bonachea
Copy link
Copy Markdown
Member Author

bonachea commented May 5, 2026

This is a somewhat large PR, primarily due to the pervasive impact of changing the internal representation of prif_coarray_handle, and (to a lesser extent) due to the breaking changes in the finalization interface.

I recommend the following reading order for most logical review:

  1. src/prif.F90
  2. src/caffeine/unit_test_parameters_m.F90
  3. test/test-uses-alloc.F90
  4. test/prif_allocate_test.F90
  5. test/prif_support_test.c
  6. other test code
  7. src/caffeine/prif_private_s.F90
  8. src/caffeine/allocation_s.F90
  9. everything else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coarray queries PRIF coarray query subroutines prif types priority=high release-blocker Must be resolved before next release storage management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant