TREX-CoE / trexio

TREX I/O library
https://trex-coe.github.io/trexio/
BSD 3-Clause "New" or "Revised" License
49 stars 14 forks source link

Import only used variables and procedures #146

Closed stefabat closed 6 months ago

stefabat commented 6 months ago

Currently, the Fortran API triggers a bunch of warnings when compiled with gfortran and the -Wuse-without-only flag, e.g.:

...
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]
/home/stefano/Code/cp2k/tools/toolchain/install/trexio-2.4.2/include/trexio_f.f90:10889:20:

10889 |   use, intrinsic :: iso_c_binding
      |                    1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]
/home/stefano/Code/cp2k/tools/toolchain/install/trexio-2.4.2/include/trexio_f.f90:10899:20:

10899 |   use, intrinsic :: iso_c_binding
      |                    1
Warning: USE statement at (1) has no ONLY qualifier [-Wuse-without-only]
/home/stefano/Code/cp2k/tools/toolchain/install/trexio-2.4.2/include/trexio_f.f90:10912:20:
...

It would be nice if the API file could be generated with the only keyword, specifying only the variables and procedures actually used from iso_c_binding.

scemama commented 6 months ago

Thanks! We will clean this for the next release.

q-posev commented 6 months ago

Noted! Do you think the use iso-c-binding call can be omitted in the basic Fortran function interfaces that have bind(C) in their declarations but which do not use any C native types or symbols like c_int32 or c_null_char?

scemama commented 6 months ago

Noted! Do you think the use iso-c-binding call can be omitted in the basic Fortran function interfaces that have bind(C) in their declarations but which do not use any C native types or symbols like c_int32 or c_null_char?

I don't think so because of the return type of the function which has to be a C type. Maybe subroutines without arguments will work, I need to try...

scemama commented 6 months ago

I created #147 for this request.