Teaching Fortran with Jupyter

Can you open up a thread on this? Do you want to teach it using Jupyter notebooks or in some other format?

1 Like

I want to wait a few more days or weeks before I start a thread on this, because I want to get some more information beforehand.
Jupyter for teaching is a great idea! I’ll try it.

1 Like

It looks like your time-frame is to use this in 1 year from now which is perfect, LFortran should work great by then. I am happy to help you with any technical issues as well as to fix any bugs that you might encounter.


You are right. For the hands-on-sessions in February 2022 it might be a little bit too late, but for the lecture next year there should be enough time.
Anyway I am currently experimenting with the Jupyter kernels for gcc and gfortran. My goal is to have modules and executable program in separate cells.
I haven’t tried your LFortran kernel yet, but I’m very thankful for any support! I think we can discuss on that later in another thread.

Edit: Thank you @awvwgk for moving us!

1 Like

Thanks @awvwgk! I didn’t know you can move topics like that! That’s a great feature.

I managed to modify the kernel to allow subroutines, modules and program to be in separate cells. Functions don’t work yet and it’s still only a proof of concept but I will share my progress in a few days.


I think this could be a great approach for the Carpentries course I was thinking about in this thread too: Modern Fortran Carpentries course - #2 by awvwgk. In my experience with courses, as soon as you start getting people to set up software environments or compile code, you run into problems. So being able to provide a Jupyter server with LFortran already set up as a kernel would be perfect!

1 Like

I would like to have an online workspace where all the single-file programs from FortranTip are present and where the user can just load a program and click it to compile it and run it. One can do this for a single code at OnlineGDB and other places, creating a link that can be shared, but it’s tedious to do this for dozens of programs.

For compiling and running single-file programs with gfortran on Windows, I use a CMD (.bat) script that looks for file foo.f90, foo.f, or foo to compile and run. Probably people have bash equivalents.

@ echo off
:: compile a Fortran main program with gfortran and run the executable
set src=%1.f90
if not exist %src% (set src=%1.f)
if not exist %src% (set src=%1)
set exec=gfort_%1.exe
if exist %exec% del %exec%
gfortran -o %exec% -Wall -fbounds-check %src%
if exist %exec% %exec%

subroutine, module containing a function and program in separate cells works! There are some problems to be solved, e.g. after executing a cell with a module or a subroutine twice the module/subroutine also is defined twice, resulting in an error. In this case the kernel has to be restarted.


Please consider enabling the submission of issue reports to your GitHub project. Aiming to replicate the installation procedure, I failed for the second step. Is install_fortran_kernel actually an argument of a function (similar to install in the earlier line for pip), or a program itself?

I don’t know why they were turned off, maybe because I forked the repo. Anyway, issues are turned on now!
install_fortran_kernel is a python script. I run it with
python install_fortran_kernel [--user]

Edit: I changed the permissions, now the file should be executable on its own.