Open rupertford opened 5 years ago
We also need to support multiple dimensions ...
Could not process DIMENSION(3, ndf, nqp_h, nqp_v). Only integer literals are supported for explicit shape array declarations.
We also need to support multiple dimensions ...
Multiple dimensions are supported, but your example has integer variables (not literals), which is the same as 'Case 1'.
The seconds case real ... :: a(XXX)
is also quite trivial, but it will fail again by having integer variables as the size.
To solve this the main change we need to make is allowing the Symbol shape
to contain references to another Symbol of type Integer in addition to the None and Integer Literal currently supported. Note that this integer symbol should already be in the symbol table before declaring the array.
I've just tried the new branch and most kernels now produce a schedule (whoop) however in some cases we get a related error. For example, in compute_total_aam_code we get ...
PSyclone internal error: Could not process (Intrinsic_Type_Spec('REAL', Kind_Selector('(', Name('r_def'), ')')), None, Entity_Decl_List(',', (Entity_Decl(Name('u_at_quad'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None), Entity_Decl(Name('scaled_omega_vec'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None), Entity_Decl(Name('r_vec'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None), Entity_Decl(Name('am'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None), Entity_Decl(Name('x_vec'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None), Entity_Decl(Name('u_vec'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None), Entity_Decl(Name('j_u'), Explicit_Shape_Spec(None, Int_Literal_Constant('3', None)), None, None)))). Multiple dimension specifications found.
for the following code ...
real(kind=r_def) :: u_at_quad(3), scaled_omega_vec(3), r_vec(3), &
am(3), x_vec(3), u_vec(3), j_u(3)
Similarly for ...
real(kind=r_def) :: grad_theta_v_at_quad(3), v(3)
and
real(kind=r_def) :: jacobian(3,3,ndf,1), jacobian_inv(3,3,ndf,1), dj(ndf,1)
So I'm guessing it is to do with multiple array declarations per line.
OK, it seems the error 'Multiple dimension specifications found.' message I added in #338 is misleading, I will solve this in the current PR and ask you to try again :)
I also found this (but only one file) :-) ...
Could not process (Intrinsic_Type_Spec('REAL', Kind_Selector('(', Name('r_def'), ')')), Attr_Spec('ALLOCATABLE'), Entity_Decl(Name('u_n_local'), Assumed_Shape_Spec(None, None), None, None)). Unrecognized attribute 'ALLOCATABLE'.
And this :-) (but only one file) ...
TypeError: Could not process DIMENSION(0 : nlayers - 1). Only scalar integer literals or symbols are allowed for explicit shape array declarations.
And a logical (in one file) ...
Could not process (Intrinsic_Type_Spec('LOGICAL', Kind_Selector('(', Name('l_def'), ')')), None, Entity_Decl_List(',', (Entity_Decl(Name('positive'), None, None, None), Entity_Decl(Name('monotone'), None, None, None)))). Only 'real', 'integer' and 'character' intrinsic types are supported.
I am introducing the Logical types at #338 and fixing the multiple array in a single statement issue..
I will not add support for ALLOCATABLES or dimension ranges in that PR yet.
Also, you may want to add: kernel_schedule.symbol_table.view()
in your script to check that PSyIR does not just accept the declarations, but it got them right when comparing to the original Fortran.
PR #338 has been merged to master but I'm keeping this issue open as there are two outstanding issues from the LFRic code base as described above (allocatables and dimension ranges/offsets).
With the additions of Loops fparser2-to-PSyIR, there are the following things missing for fully representing LFRic kernels:
NotImplementedError:
Unrecognized nodes:
Not related to PSyclone:
Having run Sergi's kernel to PSyIR translation on the latest LFRic master using the following PSyclone script ...
and a simple script over all algorithm files ...
I get two types of error (which are repeated in the different kernels).
Andy says the first is because in
currently XXX must be a literal and we have variable names
and the second is because array declarations of the form ...
are not yet supported.