stfc / PSyclone

Domain-specific compiler and code transformation system for Finite Difference/Volume/Element Earth-system models in Fortran
BSD 3-Clause "New" or "Revised" License
107 stars 28 forks source link

Avoid unnecessary `USE`s in quadrature code #1686

Open samcusworth opened 2 years ago

samcusworth commented 2 years ago

We would like to add the -Werror=unused-parameter flag to GNU builds of LFRic miniapps. This would prevent unused PARAMETER variables from being added to the codebase. Unfortunately, at present we generate some statements in the PSycode like this

USE function_space_mod, ONLY: BASIS, DIFF_BASIS

but only actually make use of one or other of BASIS or DIFF_BASIS.

We should only generate the module USEs for the variables that we actually want to use.

rupertford commented 2 years ago

Thanks @samcusworth, I can take a look at that.

Of course that feature is already available in our premium distribution, so if you would like that functionality now please feel free to sign up to our monthly payment plan.

samcusworth commented 2 years ago

Oh ok, thanks @rupertford. I've got a working copy where I've edited the initialise() method of DynBasisFunctions to search through the self._basis_fns and add (only) the appropriate function space USE to the schedule. That seems to work as I'd expect it to when I build the gravity_wave LFRic miniapp. I was still working out a) how best to search through a list of dicts b) where to add an appropriate unit test for this

rupertford commented 2 years ago

Apologies @samcusworth, I thought you were just reporting this. Please continue if you are developing the solution :-). We can add you as a developer to the project if that would help.