CoCalc supports various ways to run Fortran code.
They’re provided by GNU
f95) in the Linux Terminal.
You can also view an
.f90 file next to a terminal,
by splitting the editor window and switching to a Terminal in a Frame Editor.
Read more in the GFortran doc page.
A more convenient way to explore Fortran is to mix it with Python by using the
In a Jupyter Notebook running Python 3, there is also the fortranmagic extension available.
Write a function in a cell like that:
%%fortran -v subroutine f1(x, y, z) real, intent(in) :: x,y real, intent(out) :: z z = sin(x / 3 * y / 3) + cos(x * y) end subroutine f1
Use that new function
f1in Python, e.g.
Here is an example worksheet:
- Defining the function
- Using it in a plot: