Open szaghi opened 9 years ago
Hi,
I am just 'resurrecting' this project which I started with a colleague around 5 years ago. Unfortunately for now it's a minor side project for me, not sure how much I can get done in the next month or so. And agreed, there is basically no docs atm ... that would be next on my todo list :(
Note that if you are looking for a Fortran parser, there are (very probably) better ones out there. This one relies on a 'sensible' formatted Fortran program (e.g. spaced between keywords and variables etc).
What we can do for now is for example a maths mode, which reformats the sources:
+----------------------------------------------+
| rhokh_surf_ent(i,j) |
kh_top_factor(i,j) = MAX(0.7, 1.0-\ | ------------------------------------------ )
\| rho_uv(i,j,k)*w_h_top(i,j)*vkman*zh(i,j)
0.8
kh_sct_factor(i,j) * z_pr
rho_uv(i,j,k) * v_top(i,j) * g1 * vkman * ((1.0- --------------------------- )^ ) * z_pr * z_pr
zh_pr
rhokh_top(i,j,k) = ----------------------------------------------------------------------------------------------------
zh_pr
(of course that does not compile anymore, it's just for studying code). And we have started to write tools like 'add implicit none' (i.e. declare all variables) and some others.
If you tell me quickly what you want to use it for, I might tell you if it's worth looking at this, or if you are better off looking for something else.
Cheers, Joerg
Dear Joerg,
thank you very much for the lightning replay!
I am most involved into CFD codes development, obviously in Fortran language. It is some times that I am searching for a linter tool for detecting bad style addictions, wrong indentations and so on. Something like flake8 or pylint, but for Fortran. I am almost Obsessive and Compulsive in my codes and VIM greatly help me to be clean, but a linter could be very helpful. Moreover, a static analyzer with some smart logic like your is very interesting: your math mode is something I have never seen, my compliments!
For the moment I will watch your project that is very interesting. If I can help in some way, feel free to ask me more.
My best regards, Stefano
A linter like feature is partially implemented ny our stylesheets. Have a look at: Stylesheets/README, it actually does contain a fair amount of documentation. You would need to write a simple wrapper, similar to the one in bin/MathMode.py (note that this file contains a few functions like HandlePower etc, which are probably unnecessary - I should clean this up :) ).
I've just fixed a bug and added a small example for a reformatter. It at least allows you for now to change the case of keywords and variables - but unfortunately lines are not wrapped at all atm, I would need to check the reason for this (the output will happily contain 100's of characters per line).
Also it has atm only very few settings, if you want to (say) have a space before and after a "+", you would need to add this feature to the stylesheet settings, then query the stylesheet in the expression class ToList function that stores the expression (see AOR/Expression.py). In the "a+b" example, the class is Expression, which is a BasicExpression, which uses DoubleList to store the list ['a','+','b']. So BasicExpression.ToList calls DoubleList.ToList, which luckily already has an option to add a space (which is just not set atm), so it would be something like:
BasicExpression.py, class Expression:
...
def ToList(self, stylesheet, l2d):
if stylesheet["add_spaces"]:
self.l.ToList(stylesheet, l2d, 1)
else
self.l.ToList(stylesheet, l2d, 0)
You might need to distinguish what exactly the expression is (e.g. if you want that a*b does not get any spaces, but a+b should get spaces). There are already some hooks for maths mode (e.g. PowerExpression.ToList etc).
You would need a Fortran grammar close by to know the class names of all the elements ;)
I can try to fix the line wrappings, so at least valid fixed format (and length-limited free format) is created.
Hi all,
I am very interested in this project, however the documentation seems to be quite missing. Have you planned to add some more details?
Thank you very much for sharing your work.