Hello Ricardo,
As told in other posts, when getting NaN in your listing (Not a Number), you should use a debug configuration with debug options to investigate.
See e.g. the S9.gfortran.debug configuration in the $HOMETEL/configs/systel.edf.cfg configuration file, in particular the flag fflags_debug_gfo for gfortran compiler.
fflags_debug_gfo: -g -Wall -fcheck=all -fbacktrace -fbounds-check -finit-integer=-1 -finit-real=nan -ffpe-trap=invalid,zero,overflow
It will show in which subroutine the issue/nan occurs and may help you to change something in your computation.
Hope this helps,
Chi-Tuan