I tried to use forall
to allocate dynamic arrays, but gfortran didn't like that. I also found out that write
statements are forbidden in a forall
block ,and I suspect read
statements are too.
What other functions/operations are not permitted in a forall
block?
Exactly what is this construct for, besides sometimes replacing do
loops when order doesn't matter? I thought it would make coding more legible and elegant, especially showing when the order of operations are not important, but it seems quite restrictive with what operations can be done inside a forall
.
What are the reasons for these restrictions, i.e. what do they protect/prevent the user from messing up? Is it a good idea to use forall
? If so, for what purposes?
Right now in the code I'm working on there is only one forall
block, and if I translated it all out in do
loops it would give four nested loops. Which way is better?