[MITgcm-support] NaN - stop running?

Gus Correa gus at ldeo.columbia.edu
Thu Nov 16 15:12:02 EST 2017


Hi Yangxin

Yes, I do have the same -ffpe-trap options that you listed.
That should stop the execution on NaNs or Infinity,
division by zero, and overflows.

I use gfortran, and it seems to me that you're also using it, right?
Intel and PGI are likely to have different flags, if you're using
either one, check the compiler man page and MITgcm example option files
for those compilers.

Suggestion: If not yet there, add -fbacktrace to the FFLAGS.
It helps much to find the source file and line where code failed.

I hope this helps.
Gus Correa

On 11/16/2017 12:22 PM, Yangxin He wrote:
> Hi Gus,
> 
> 
> Thanks for your reply.
> 
> 
> I added a flag in my optfile " -ffpe-trap=invalid,zero,overflow", will 
> this solve my problem too? how does this compare with your solution?
> 
> 
> Yangxin
> 
> ------------------------------------------------------------------------
> *From:* MITgcm-support <mitgcm-support-bounces at mitgcm.org> on behalf of 
> Gus Correa <gus at ldeo.columbia.edu>
> *Sent:* Thursday, November 16, 2017 12:14:38 PM
> *To:* MITgcm Support
> *Subject:* Re: [MITgcm-support] NaN - stop running?
> Hi Yangxin
> 
> Pass the --ieee and --devel flags to genmake2,
> when you build the model (do a 'make CLEAN' beforehand).
> Something like this (assuming you use MPI):
> 
> /path/to/MITgcm/tools/genmake2 \
> --rootdir=/path/to/MITgcm \
> --optfile= /path/to/MITgcm/tools/build_options/your_build_options_file \
> --mods=/path/to/your/experiment/code \
> --mpi \
> --ieee \
> --devel \
> 
> 
> If your build_options file was properly written, it will
> turn on your compiler's floating point exceptions (as Jody suggested),
> and the model will crash at the first NaN.
> 
> Besides, it is also useful to turn on "traceback"
> (or "backtrace", check the compiler man page) compiler flag,
> which will tell you in which preprocessed ".f" file
> (in your build directory)
> and on which line of code line the problem happened.
> BTW, keep the ".f" files, don't do a 'make clean' while you're
> chasing the error.
> 
> If your build_options file doesn't have these features,
> you can find some example files that do have that
> in the MITgcm original build_options directory.
> Look there for "macros" such as IEEE, and DEVEL.
> Copy the corresponding blocks to your build_options file,
> and adjust to your compiler's specific flags.
> 
> I hope this helps,
> Gus Correa
> 
> On 11/15/2017 01:33 PM, Jody Klymak wrote:
>> You want to look up floating-point exception handling for your compiler.
>> 
>> Cheers,   Jody
>> 
>> 
>> 
>>> On 15 Nov 2017, at  10:18 AM, Yangxin He <y67he at uwaterloo.ca 
>>> <mailto:y67he at uwaterloo.ca>> wrote:
>>>
>>> Hey,
>>>
>>> I am having a (probably) small problem. Sometimes my output data gives 
>>> all NaN for various reasons. But it still kept running until the end. 
>>> Is there any way that I can make the model stop running once it starts 
>>> to generate NaNs?
>>>
>>> Thanks
>>>
>>> Yangxin
>>> _______________________________________________
>>> MITgcm-support mailing list
>>> MITgcm-support at mitgcm.org <mailto:MITgcm-support at mitgcm.org>
>>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>> 
>> --
>> Jody Klymak
>> http://web.uvic.ca/~jklymak/
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> MITgcm-support mailing list
>> MITgcm-support at mitgcm.org
>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>> 
> 
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
> 
> 
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
> 



More information about the MITgcm-support mailing list