I have a working code. The code simply opens and reads the node IDs to an array using a loop, then uses simple array logic to determine which layers head losses are applied to. It works fine for my low resolution mesh in serial. However, when I increase the number of nodes to loop through then Telemac crashes. A sample code is:
OPEN(12,FILE='../0.1_SER.dat')
DO I=1,8189
READ(12,*) SEID(I)
! write(*,*)I, SEID(I)
END DO
CLOSE(12)
DO I = 1, 8189 !for each NODE
I1=SEID(I)
write(*,*)I1
A = 24.3816D0
DO IPLAN = NPLAN-9,NPLAN !for layers at that node
I3D = I1+NPOIN2*(IPLAN-1) !get the 3D node IDs
NORM =SQRT(UN3%R(I3D)**2+VN3%R(I3D)**2+WN3%R(I3D)**2)
S1U%R(I3D)=0.5D0*A*CD2*NORM
S1V%R(I3D)=0.5D0*A*CD2*NORM
S1W%R(I3D)=0.5D0*A*CD2*NORM
END DO
END DO
I get a "*.exe has stopped working" error followed by:
_____________
runcode::main:
:
|runCode: Fail to run
|C:\TELEMAC\VEG\May\PRIVEtest.cas_2018-05-08-12h14min40s\out_MworkER_3.exe
|~~~~~~~~~~~~~~~~~~
|
|~~~~~~~~~~~~~~~~~~
I receive warnings that I don't otherwise see when looping through fewer nodes:
t3dfort.f:662:0: warning: iteration 60 invokes undefined behavior [-Waggressive-
loop-optimizations]
I3=PNID(I)
^
t3dfort.f:661:0: note: containing loop
DO I = 1, 877 !for each NODE
^
t3dfort.f:646:0: warning: iteration 80 invokes undefined behavior [-Waggressive-
loop-optimizations]
I2=SMID(I)
^
t3dfort.f:645:0: note: containing loop
DO I = 1, 2215 !for each NODE
^
t3dfort.f:630:0: warning: iteration 700 invokes undefined behavior [-Waggressive
-loop-optimizations]
I1=SEID(I)
^
t3dfort.f:629:0: note: containing loop
DO I = 1, 8189 !for each NODE
^
I think with a larger number of iterations the program fails because it is optimised into an infinite loop. Or at least something is changing the loop condition. I would have assumed that the code is impossible to execute given a previous case, but there isn't one.
I think. Is this the case - Is the loop poorly defined for this case?