It looks great, thanks! Here are some comments.
For your Python
from numpy import array, size, shape, min, max, sum
a = array([1, 2, 3])
print(shape(a))
print(size(a))
print(max(a))
print(min(a))
print(sum(a))
You give the Fortran equivalent as
integer :: a(3)
a = [1, 2, 3]
print *, shape(a)
print *, size(a)
print *, maxval(a)
print *, minval(a)
print *, sum(a)
end program
But I suggest the declaration
integer, allocatable :: a(:)
since the Python counterpart a
can later be resized.
When you are showing Python and Fortran output, I suggest labeling the boxes Python output
and Fortran output
.
I don’t agree with
Strings and Formatting#
The functionality of both Python and Fortran is pretty much equivalent, only the syntax is a litte different.
In Python can write s = ["boy", "girl"]
and have two elements of length 3 and 4, but the closest Fortran equivalents are s = [character(len=4) :: "boy", "girl"]
or s = ["boy ", "girl"]
, which gives you two elements of length 4.
I suggest mentioning that return
has a different role in a Python function and a Fortran procedure.
Numpy has a function random.uniform
. Maybe compare that to Fortran’s random_number()
. Fortran has no equivalent to np.random.normal
, but such a function could be written. But maybe the current Rosetta Stone should be left as is to avoid clutter, and links can be added to further discussion of Fortran equivalents to Python/NumPy.
Spelling: “ommit” should be “omit”, “litte” should be “little”.