LFortran example and request to development team

I am trying my hand in lfortran and came across this example (example 4) in documentation

Somehow that example is not working for me. I have installed lfortran on my ubuntu 22.04 LTS laptop via the Miniconda installation and using jupyter notebook.

Also can someone guide me in calling fortran library (will prefer .a file) from lfortran script. Though am an adept user of Modern fortran but this is new to me. I am looking for simpler option to get simple plots from fortran (lfortran and combine it with old fortran libraries). Till now I have experimented with Python-Fortran integration. But if simple plots and the mandelbrot example are possible in lfortran that will solve my problem and encourage me to shift back fully to fortran. Also if an explanation of manderbot example is added in lfortran web app, that would be very helpful.


Hi @apoorv01, thanks for the feedback. We need to update the design documentation, I created an issue for it at Update the design documentation · Issue #3392 · lfortran/lfortran · GitHub.

You can call a module interactively like this:

>>> use test_M, only: f                                                                                                       1,20  ]
>>> call f()                                                                                                                  1,9   ]

Where you compile the module using:

lfortran a.f90 -c

And the source code of it is:

module test_M

    subroutine f()
    print *, "OK"
    end subroutine

end module

However LFortran is still alpha, you can follow our progress towards beta at https://lfortran.org/, there is a nice progress bar there. Until then the expectation is that you will discover bugs. The interactive feature especially will have bugs, as we are first focusing on compiling existing codes, and once we reach beta quality for that, we plan to get interactivity and other features up to par as well.

We are always looking for new contributors and for help. The more people, the sooner we’ll get there.

Hi @certik, thanks for your message. I think I am facing issue because F95 style derived types are missing in lfortran.

Following is the code I am trying

Main file

T2.f90 (272 Bytes)

the module file

TTT.f90 (619 Bytes)

The error I am getting is the following
code generation error: Printing support is not available for input01 type.

As I am from Computational Aerodynamics background, I cannot contribute directly to development of lfortran. Once it is in beta phase; I will try it for simple problems first and may be contribute few examples.

Best Regards

1 Like

For now change write (*,*) to print *,, then it works. I reported this bug at Printing derived types works with `print` but not `write` · Issue #3413 · lfortran/lfortran · GitHub.

For your example I am getting:

$ lfortran TTT.f90 -c && lfortran T2.f90
Inside Subroutine 3.00000000000000000e+01 2.00000000000000000e+01 2.40000000000000000e+01
$ gfortran TTT.f90 T2.f90 && ./a.out
 Inside Subroutine   30.000000000000000        20.000000000000000        24.000000000000000
1 Like

Thanks for you help, it worked now

1 Like