Tcl/Tk 8.6 for Fortran 2018


I’ve written an ISO_C_BINDING interface library for Fortran 2018 that provides access to the C API of Tcl/Tk 8.6:

It is still work-in-progress, but already useful to embed Tcl into Fortran, to create custom Tcl commands in Fortran, or to write stand-alone Tk-based GUI applications in Fortran.

Access to Tcl/Tk should work on all supported operating systems. However, I’m not into MS Windows and can’t tell how to link the libraries there. If someone wants to post their compilation steps I would be happy to extend the build instructions accordingly. Also, an fpm build manifest is still missing.

Further links:


Cool! I started programming after Tcl’s heyday, but it looks like a nice choice as a front-end/config language. Thanks especially for the examples!

Wonderful! If only because it proves I am not the only one who combines Tcl and Fortran ;). I have been attempting to combine the two for many years now, but the C interfacing is muich eaiser since Fortran 2003. And here is a recent experiment of mine.

1 Like

Can you give us more details about the C interoperability features specific to Fortran 2018 that were useful in your binding?

The interface bindings do not make much use of new Fortran 2018 C interoperability features. I’ve declared implicit none (type, external) in all modules, as the compiler then throws errors that would normally be noticed at link stage first. Apart from that there are only two additions to the language standard that might come handy: optional arguments and type(*) arguments for interfaces. But these probably don’t make a difference for the Tcl/Tk bindings.