Limiting associate
to a single line, is not good for readability.
associate (rho => csv(1), urho => csv(2), vrho => csv(3), wrho => csv(4), erho => csv(5))
! code
end associate
We can use &
to split this into multiple lines, but that feels awkward, and is error prone.
Often I find that I missed a comma ,
or &
, and as a result, the code fails.
In my opinion, associate
would have been easier to use, if it spanned across multiple lines, and did not depend on commas ,
or &
for separating the expressions.
associate
rho => csv(1)
urho => csv(2)
vrho => csv(3)
wrho => csv(4)
erho => csv(5)
cells => mesh%cells
nodes => mesh%nodes
nc => mesh%num_cells
nn => mesh%num_nodes
begin
! code
end associate
I think this is easier to use because,
- This follows the fortran convention of each statement being separated on each line, thus it is both easier to read, write, and edit.
- If I want to delete an expression, I can delete the whole line easily.
- If I want to add a new expression, I can add a new line easily
- If I want to change the indices of
csv(i)
, I can change them easily, by moving the cursor down one line at a time. - Reading this code is easier, and if I make a mistake, it’s easier to find in this form.
- Since we don’t need commas
,
between the expressions, it is easier to use - Since we don’t need ampersands
&
to extend the lines, it is easier to use - This allows and encourages the users to use
associate
more, since it is easier to use, and we can assign as many expressions as we want in eachassociate
block. - We can create complex expressions on each line
- Nesting these
associate
blocks would be easier - Automatic code formatting would be easier
Thanks