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
104 stars 27 forks source link

Protected Statement not supported #2658

Open hiker opened 2 months ago

hiker commented 2 months ago

build_output/science/jules/science/params/veg3_param_mod.f90 contains:

  LOGICAL :: l_veg3 = .FALSE.
  PUBLIC :: veg3_parm_init, veg3_parm_allocate
  PUBLIC :: veg3_ctrl, litter_parms, red_parms, l_veg3
  PUBLIC :: veg3_ctrl_type, litter_parm_type, red_parm_type
  PROTECTED :: l_veg3, litter_parms, veg3_ctrl, red_parms

The PROTECTED statement causes the whole module to be turned into a code block. Two step solution:

  1. In the fparser script to remove protected, also remove protected statements (as opposed to attribute ... why oh why does Fortran have so many different ways of specifying the same thing)
  2. Turn only the protected statement into a UnsupportedFortranType

I am actually surprised that the public statement does not cause the same problem .

arporter commented 2 months ago

I'd prefer to implement proper support for it. I've done a quick google and AFAICT, it's a symbol that can be read outside the module but only written to by routines inside a module? Could we extend the public/private support to include protected? That would mean we could use the same mechanisms that we already have to handle PUBLIC ::/PRIVATE :: statements.

arporter commented 2 months ago

Just a note (while I think about it) to say that we will need to update the Dev Guide: https://psyclone-dev.readthedocs.io/en/latest/psyir_symbols.html#datatypes