[Nek5000-users] Method to detect NaNs

nek5000-users at lists.mcs.anl.gov nek5000-users at lists.mcs.anl.gov
Tue Mar 8 16:02:57 CST 2011


Thanks for the tip Josh!

It's a clever one that I had not thought of.

I typically am running on a machine where I've set the compiler
to halt execution on occurance of 1st NaN, but that doesn't address
the issue you raise.   Your solution is great.

Paul


On Tue, 8 Mar 2011, nek5000-users at lists.mcs.anl.gov wrote:

> Hi Neks,
>
> I just wanted to pass on a method that may or may not be useful to you all.
>
> I'm sure manyf NEK simulations are run on machines where the hours
> aren't "free."  Thus, it's nice to try and minimize any wasted hours
> as much as possible.  So, if a simulation blows up, you want to end
> the simulation as quickly as possible so as to not waste any more
> precious computational time.
>
> While there are probably better solutions, I end up putting the
> following snippet into my userchk()
>
> if (u_max.ne.u_max) then
>           if (nid.eq.0) print *,'Sim is blowing up!!'
>           call exitt()
> endif
>
> where u_max is something I calculated before hand.  An interesting
> property of NaNs I found after doing some googling is that NaNs are
> not equal to anything..even themselves.  So, if you take some
> quantity, and compare it to itself, the only time it isn't equal to
> itself is if it is Not a Number.  You can use this property to tell
> your simulation to quit.  I've tested this out on a case that I knew
> would blow up on me and it worked perfectly.
>
> Hope you all find this helpful for "hazardous" jobs when you can't
> spare the time to monitor its progress at all times.
>
> -- 
> Josh Camp
>
> "All that is necessary for the triumph of evil is that good men do
> nothing" -- Edmund Burke
> _______________________________________________
> Nek5000-users mailing list
> Nek5000-users at lists.mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/nek5000-users
>



More information about the Nek5000-users mailing list