I have some experience writing fortran codes but I have never seen something like this.
I am using a large HPC code (~10K lines) in which I am modifying a subroutine. I used print statements to verify that everything was done correctly and debug if necessary. When I run my code with the last PRINT statement I used, the code is giving me real numbers everywhere. Once I comment this last PRINT statement, the code is giving me NaN is some of my variables. Since my code is too big, I obviously can't post it here, but I'll post the PRINT statement:
PRINT*, "outletBC up1    ", SUM(ABS(up(nptsx,:,:)))
where up is some velocity array. 
QUESTION:
How is that possible? How can a PRINT statement possibly affect any variable?
 
     
    