Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

FORALL vs. nested DO construct / Compare - Contrast

$
0
0

I have code which has the following block:

FORALL(I = 1:II, J = 1:JJ, K = 1:KK, NULL(I, J, K) == 1)
    V(I, J, K) = FRAC(I, J, K) * DX(I, J, K) * DY(I, J, K) * DZ(I, J, K)
    VN(I, J, K) = DX(I, J, K) * DY(I, J, K) * DZ(I, J, K)
END FORALL

In compiling / running the code after turning off my StackReserveSize number, I was noting this code was eating up stack.  So, I replaced it with

DO K = 1, KK
    DO J = 1, JJ
        DO I = 1, II
            IF (NULL(I, J, K) == 1) THEN
                V(I, J, K) = FRAC(I, J, K) * DX(I, J, K) * DY(I, J, K) * DZ(I, J, K)
                VN(I, J, K) = DX(I, J, K) * DY(I, J, K) * DZ(I, J, K)
            END IF
        END DO
    END DO
END DO

The code no longer gave me stack overflow errors, but it ran differently.  How can that be?

Perplexed


Viewing all articles
Browse latest Browse all 3108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>