Week5 - Implement SAVE, DataImpliedDo, External & Bug Fixes
Implement SAVE, DataImpliedDo, External & Bug Fixes
Date: June 18, 2023.
Hii! Welcome to the fifth blog of my GSoC '23 journey. This week I majorly focused on implementaiton of SAVE attribute, DataImpliedDo, External and some bug fixes.
Let's start with SAVE attribute, it is used to save the value of a variable in memory even after the program has finished executing. This attribute is used in various places in SciPy codebase, so we decided to implement it. It was fairly simple to implement, on encountering `save` attribute in Declaration node of AST we set ASR::storageType to `ASR::storage_typeType::Save`.
There were majorly two cases, one `save x, y` , where it is specified to save the value of both `x` and `y` and second `save` where it is specified to save the value of all the variables. More details about implementation can be found in PR: 1835.
Now let us move ahead with DataImpliedDo. I will use a small example to explain it: ```fortran program data_implied_do_01 real :: a(5) integer :: i DATA (a(i),i=1,5) /1.0, 2.0, 3*0.0/ end program ``` > This Translates to below code internally ```fortran program data_implied_do_01 real :: a(5) integer :: i DATA a(1), a(2), a(3), a(4), a(5) / 1.0, 2.0, 0.0, 0.0, 0.0 / end program ``` So, in the above example we can see that we are initializing `a(1)` to `1.0`, `a(2)` to `2.0` and `a(3)` to `0.0` and so on. This is what DataImpliedDo does, it is used to initialize the variables in a single line.
To start with implementation, we converted DataImpliedDo AST node to ImpliedDoLoop node of ASR and then added provision within `visit_DataStmt` to handle ASR::ImpliedDoLoop node. More details about implementation can be found in PR:1837.
Later, there were few external attribute bugs reported at Issue: 1801, Issue: 1803 which got fixed by PR: 1819, another one Issue: 1820 for which I have a fix ready.
All in all with 20 hours of work this week, I was able to implement Save, DataImpliedDo, and fixed various bugs related to external attribute. Now only a few files are left to compile to ASR. Along with that we encountered a new feature `Entry` that is yet to be implemented but looks like LFortran has sufficient infrastrucutre to implement it. For the next week I am planning to get a above mentioned external issues done, along with that I will probably start implementation of block data as discussed and if possible I will try to implement `Entry` aswell.
I would like to thank Ondřej Čertík for taking out time and helping me when I was stuck. Looking forward to many more commits.