Week11 - Align Specfun output with GFortran
Align Specfun output with GFortran
Date: July 30, 2023.
Hello everyone! Welcome to blog of week 11. This week I focused on understanding how the scipy tests work and how can we align the output of LFortran with GFortran ( for scipy/special/specfun ).
So, I will document the steps that I followed to grasp the working of scipy tests. For `scipy/special` suite the tests can be found at `scipy/special/tests`, let us focus on a test that is `test_basic.py`.
So, here are the steps one can follow to build the SciPy system and run tests:
To run a specfic test, one can append the test name at end of command, for example:
So, once we have the tests getting passed with GFortran, we can start working on aligning the output of LFortran with GFortran.
Now, we will have to somehow let the SciPy build system know that we want to use LFortran instead of GFortran. And that can be done by following the following steps:
Now, once the tests run, we will be able to see an assert failed for `test_riccati_yn`, that shows divergence. The following divergence is because of `SUBROUTINE RCTY(N,X,NM,RY,DY)` present in `specfun.f`. The output of GFortran and LFortran for this subroutine is different. More information about this can be found at Issue: 2067 and Issue: 2078.
Now, one digging deep into the code, I found that the divergence was because of pass `do_loops.cpp` which replaces the do loop with do while loop. Let us understand the error with an example:
This was simple to resolve, i just added at new statement to increment do loop variable by increment value. More information about this can be found at PR: 2079.
So all in all with 12 hours of work, I got to understand how the tests work in SciPy and also how can I work on alignment of output of LFortran. I shifted back to my Linux system and hence I am working on setting up SciPy again on my system, it is failing while executing tests. I will push to get that done, and then will setup CI as discussed. For next week, I will work on scipy tests and try to get as many working as possible.
I would like to thank Ondřej Čertík for helping in scipy setup and helping me whenever I am stuck. Looking forward to many more commits.