Skip to content

Removal of Fortran API variadic functions #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Mar 21, 2025

Conversation

corentin-prigent
Copy link
Contributor

This update is motivated by problems encountered when using variadic functions, such as MMG3D_Init_mesh() in Fortran on a ARM processor.
Up to now, the Fortran API did not provide interfaces for variadic functions, as such functions do not exist in Fortran.
In this update, variadic functions from the Fortran API have been removed. They have been replaced by functions holding the same name with a different prototype, using arrays of pointer of unknown length, allowing to mimic the behaviour of C variadic functions.
As a consequence, the typical use of these functions in Fortran as been modifed. As illustrated in the libexamples, functions should be called using the following syntax:

  CALL MMG3D_Init_mesh((/MMG5_ARG_start, &
       MMG5_ARG_ppMesh,LOC(mmgMesh),MMG5_ARG_ppMet,LOC(mmgSol), &
       MMG5_ARG_end/),ier)

where variadic arguments are passed through an array of MMG5_DATA_PTR_T elements. The LOC() function must be used to pass data by reference.
The perl script generating the Fortran interface has been modified in order to have consistency between both types of elements in the array: indicators such as MMG5_ARG_start should be interpreted as INTEGER(kind=N), which correspond to the type MMG5_DATA_PTR_T.

…ere is a rounding error introduced by FMA in CLANG
… MMG5_ARG_* should be defined as integer(kind=8) to match new API functions
…structures and mmg3d_free_all to have a return value
@corentin-prigent corentin-prigent added kind: ci-failure unexpected ci failure part: library library usage specific priority: high linked to blocking behaviour or to a close deadline labels Mar 6, 2025
@taupalosaurus
Copy link
Contributor

Why do we need to change all these thresholds in the core sources of src/common ? That doesn't really seem desirable to me...

@corentin-prigent
Copy link
Contributor Author

In order to validate some unitary tests, the values of these thresholds have been set ad hoc, by taking into account the truncation error of gcc. If clang is used, or if some optimizations are made, truncation errors may vary and lead to slightly different output values. That is why the threshold have been modified so that the tests are valid in these situations.

@corentin-prigent corentin-prigent merged commit 1772899 into MmgTools:develop Mar 21, 2025
24 checks passed
@corentin-prigent corentin-prigent deleted the feature/macos-ci branch March 21, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: ci-failure unexpected ci failure part: library library usage specific priority: high linked to blocking behaviour or to a close deadline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants