I tried your code with LFortran, and just by commenting our the execute_command_line
and the open
/write
/close
which we haven’t implemented in the backend yet, it works! I am super happy about it.
I then modified your code to take a little longer to have a more meaningful benchmark:
program simple_num_prob
implicit none
integer :: i
integer,parameter :: tf=25,n=100000000
real,allocatable :: t(:),u(:)
real :: dt
real(kind=8) :: t1,t2
character(len=*),parameter :: plt_file='simple_num_prob.gp'
allocate(t(n))
allocate(u(n))
! Assigning step value
dt=real(tf)/real(n)
! Initial u value assigned
u(1)=1.0E-5
! Population of t vector
do i=1,n
t(i)=real(i)
end do
call cpu_time(t1)
! Calculating and populating the function vector
do i=1,n-1
u(i+1) = u(i) + (dt*(u(i)*(1.0-u(i))))
end do
call cpu_time(t2)
print *, "Elapsed time",t2-t1
print *, "u(n) = ", u(n)
end program simple_num_prob
Then I timed it with LFortran and GFortran on my Apple M1 Max:
$ lfortran --fast b.f90
$ ./a.out
Elapsed time 0.37257999999999997
u(n) = 0.861650
$ gfortran -O3 -march=native -ffast-math -funroll-loops b.f90
$ ./a.out
Elapsed time 0.46585100000000002
u(n) = 0.861649990
So I’ll take these results.
If anyone of you want to help us with LFortran, we are always looking for new contributors. LFortran is in alpha, but for simple code like this I would say it’s quite close to beta. I think we have a very solid design of the compiler that will allow us to deliver on performance that will not disappoint, among other things. We’ve been making excellent, steady progress in implementing all Fortran features.
P.S. Regarding implicit none
, LFortran already does what was proposed above, that is, it will not allow you to do implicit typing (unless you explicitly ask for it either with the implicit
statement or a compiler option, which is not implemented yet, but we’ll get it done soon), try this:
program test_implicit_none
print *, i
end program
which prints:
$ lfortran b.f90
semantic error: Variable 'i' is not declared
--> b.f90:2:10
|
2 | print *, i
| ^ 'i' is undeclared
Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that needs to be fixed).