leonfoks / coretran

An easy to follow library to make Fortran easier in general with wrapped interfaces, sorting routines, kD-Trees, and other algorithms to handle scientific data and concepts. The library contains core fortran routines and object-oriented classes.
BSD 3-Clause "New" or "Revised" License
98 stars 12 forks source link

Mean example is too verbose #6

Open milancurcic opened 6 years ago

milancurcic commented 6 years ago

I understand the advantage of demonstrating the power of coretran on a very simple example, however the native Fortran code for the mean example is unnecessarily verbose and misrepresents the level of verbosity of Fortran. The following can make it much more succinct:

The equivalent and correct example:

program theMean_program
use, intrinsic :: iso_fortran_env, only: real64, int32
implicit none
real(real64), allocatable :: a(:)
real(real64) :: theMean
integer(int32) :: i, istat, N
N=1000

! Create numbers from 1 to N
a = [(real(i,kind=real64), i=1,N)]

! Compute the mean
theMean = sum(a)/N

end program
leonfoks commented 6 years ago

Thanks for the great points and I agree that the small example doesn't even do the idea of coretran any justice let alone newer aspects of Fortran. I've been meaning to update this for a while.

In my opinion, I would consider your use of the very succinct aspects of Fortran to be modern. Since i'm coming from a back ground of teaching modern Fortran to people who are not used to modern Fortran at all, I left the older styles in. This makes the example more accessible to people who get confused by implicit do loops on assignment and even vectorized notation.

Perhaps I should just take out the comparison of "old" and "coretran" code, and simply show some examples of using coretran like in the rest of the docs.

leonfoks commented 6 years ago

Also, just to comment on your three points above.

Thanks for your feedback!