Skip to content

More Cleanup of fortran_generic code#438

Merged
ltaylor16 merged 9 commits intodevelopfrom
fix-fortran-generic2
Nov 1, 2025
Merged

More Cleanup of fortran_generic code#438
ltaylor16 merged 9 commits intodevelopfrom
fix-fortran-generic2

Conversation

@ltaylor16
Copy link
Copy Markdown
Member

Avoid some special cases in GenFunctions.generic_funcion Have fortran_generic functions all call the same interface for the C function using intrinsic functions to convert arguments.

Or have a wrapper for each generic function and not one for the library function. Needed when +rank is different in fortran_generic. Also deal with void arguments.

Take into account overloaded functions when one of the also has fortran_generic. The Fortran generic interface can not also have a function by the same name.

Dump to JSON if options.debug_index.
Print in Fortran wrappers, similar to how C wrappers print them.
Add signature_i for Fortran interface to C function. May be different
from signature_c by passing bufferify arguments.

No changes to JSON since debug_index is not used in tests since it
will produce lots of changes as fc-statements changes.
fortran_generic was still relying on a C wrapper being generated.  The
wrap_fortran=True now also generates it's own C wrappers.  Shroud
tries to detect when a duplicate wrapper is created for wrap_c=True
and will share the wrapper.

These changes no longer assume the C wrapper is available.

If only scalar native types are used in fortran_generic, the original
library function is wrapped for C with an interface then each
fortran_generic generated function will call the same interface. The
Fortran wrappers will covert the argument using the a Fortran
intrinsic function. This is a special case controlled by the variable
FunctionNode._fortran_generic_wrap. The intent is to avoid having
duplicate C wrappers.
The one with a fortran_generic section.
Check for shadow type as return value.
Not yet wrapped due to errors.

Class1 *createView(const std::string& path, int type, long num_elems);
In the simplest case of only scalar native, all fortran_generic
functions will call the original function.

Function which have void* or rank attribute need a C wrapper for
each fortran_generic to ensure the ranks match with the arguments.

There are now fewer special cases when deciding how to wrap
fortran_generic.
createView is overloaded and uses a void* argument.  Test if it's
overloaded when deciding which wrappers to create.  Otherwise, two
wrappers may create identical name in the effort to minimize the
number of wrappers.

While this solves a problem, there may still be an issue with
cdesc.yaml GetScalar2 which may have a problem is its name was
overloaded since it uses a void pointer which is replaced in the
fortran_generic statement.
If a statement group has owner=caller a capsule argument will be added
which is intent(OUT). This capsule is used to release memory by the
user.

gfortran 13
  481 |         pure function c_class1_get_path(self, SHT_rv_capsule) &
      |                                                            1
Error: Argument ‘sht_rv_capsule’ of pure function ‘c_class1_get_path’ at (1)
must be INTENT(IN) or VALUE

intel 2025
 error #7115: The specification-part of a PURE function must specify that all dummy arguments have explicitly declared INTENT(IN) except procedure arguments and arguments with the POINTER or VALUE attributes.   [SHT_RV_CAPSULE]
        pure function c_class1_get_path(self, SHT_rv_capsule) &
----------------------------------------------^
Message from github actions

SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

********************************************************************************
Please consider removing the following classifiers in favor of a SPDX license expression:

License :: OSI Approved :: BSD License

See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
********************************************************************************
Message from github actions
    UserWarning: Unknown distribution option: 'test_suite'
@ltaylor16 ltaylor16 merged commit 58aa001 into develop Nov 1, 2025
3 checks passed
@ltaylor16 ltaylor16 deleted the fix-fortran-generic2 branch November 7, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant