Can you help please me with some of these problems?
Is there any way to access the ith character in character (let say of length = 9).
string = ‘spiderman’
(I assume that fortran uses 1-based indexing.)
can I access the character at index 1 (which is ‘s’) without using string(1:1)?
Is fortran a “call by reference” (“pass by reference”) language?
Many people say that python is “call by object deference”, some argues that python is actually “call by value” because every variable stores reference and this reference is copied whenever called.
I wrote some code to understand. The below written might be irrelevant in concluding that it is call by reference.
program factorial implicit none integer, dimension(5) :: a, b, c a = (/1, 2, 3, 4, 5/) b = (/2, 2, 2, 2, 2/) c = (/3, 3, 3, 3, 3/) print *, LOC(a), LOC(b), LOC(c) a = b a(1) = 100 b(1) = 274 print *, LOC(a), LOC(b), LOC(c), a, b end program factorial
6422252 6422232 6422212 6422252 6422232 6422212 100 2 2 2 2 274 2 2 2 2
So, I can conclude that when a = b was done, a new copy of the array (stored at the memory location of b) was created which was then overwritten at memory location of a. Same phenomenon was observed for basic data types like integer, etc.
Are characters (let’s say of length = 10) mutable in Fortran? Which means that can I directly go and change the character at index 1 without affecting the rest of the indexes?
In python strings are immutable just like tuples, so I will have to create a totally new character if I want to make any change.
How does fortran store character of length greater than 1. Does it use an array to store?