'Fortran access / store data correctly in a nested loop
I have a rather simple question on an iteration in a nested loop. I show the necessary code at the end. The first iteration over the node dimension works fine. I do some calculation which results I store in T_int and P_int. But when I want to access the data in the second loop over the nobs dimension I can not handle to access the data. When I output the dimension of T_int it is correct as it has the length of nobs. But my print T_int within loop just shows the same value for every nobs respectively for each node. Can anyone give me a hint how to handle that? I have the feeling it must be rather easy, but I have not left any patience on that. So, I would be very grateful for any help.
Thanks in advance!
! Start loop over node dimension
N = Solver%Mesh%NumberOfNodes
Do ii=1,N
SURF = SurfValues(SurfPerm(ii))
!! Step 1: Interpolate AWS Station Data on grid - Temp all values, Prec only if /=0
T_int = TEMPobs(ii) - ((SURF-aws) * lapseT)
Where (PRECobs /= 0)
P_int = PRECobs(ii) - ((SURF-aws) * lapseRRR)
End Where
print *,'Dimension T_int', size(T_int)
! Start loop over nobs dimension
Do oo = 1,nobs
print *,'Number of Node and NOBS', ii,oo
If (T_int(nobs) > 0) Then
T_mpl(nobs) = T_int(nobs)
Else if (T_int(nobs) <= 0) Then
T_mpl(nobs) = 0
End if
print *,'T_int within loop', T_int(oo)
End do
End do
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
