I am writing a FORTRAN program for the Monte Carlo Simulation of polymer melts. While checking the value of the sum of the fractional Boltzmann weights in my Monte Carlo subroutine at certain points, I'm getting NAN after printing the variable in the subroutines. The subroutine is quite large. I'm unable to post it here. If anyone has an idea, what is the reason of getting NAN after printing the value of the variable ??. Please help as I'm unable to proceed further.
How can we overcome such a situation to avoid getting NAN ? I'm using a gfortran compiler to write my program.