Week 6: Implementation
May 1, 2025
Welcome back to my blog! Today, I’ll describe the installation process for S4 (and a number of other setbacks). First, let’s take a look at S4’s dependancies sourced from its main page.
S4 (again)
Refer to [1] for S4s homepage. Immediately, I ran into my first issue. I couldn’t run S4s binary package (outdated links/unsupported versions)! For this, I resorted to cloning S4s repo and building from source.
I quickly ran into my next obstacle—a missing ‘lua.h’ file. It turned out my version of Lua (the language and interpreter for S4) was too recent! You can tell by now S4 is a pretty old program. Installing lua5.2.4 resolved this error.
By now, I prayed things would be smooth sailing. Turns out, S4 threw another error in my face. A function called getAmplitude had an error with one of its parameters. The file with the error ‘main_lua.c,’ had a daunting amount of 3300+ lines of C, a language I was completely unfamiliar with. Thankfully, GitHub had already encountered this issue. A quick fix resolved all the errors, and S4 successfully compiled! So that documents my journey in implementing S4.
Dependancies
S4 recommends the installation of five packages: OpenBLAS, FFTW3, CHOLMOD, POSIX Threads, and MPI. The latter two were not manually installed for my build. OpenBLAS is a basic linear algebra subprogram that enables speedier operations. FFTW3 reduces fast Fourier transform times by half. CHOLMOD or suite-sparse provides algorithms for sparse matrices, reduces computational time for the Fourier modal method.
My S4 build installed every dependancy. Each could be installed through home-brew, except Lua. As mentioned above, the acceptable versions of Lua were 5.2.x. This required me to build that specific version of Lua directly from source. That concludes the introduction to S4.
In the next blog, I’ll describe specific examples within the S4 directory before my modification to nonlinear regimes.
See you next blog!
[1] https://web.stanford.edu/group/fan/S4/
Leave a Reply
You must be logged in to post a comment.