Changes between Version 10 and Version 11 of Documentation/UserGuide/flags


Ignore:
Timestamp:
2020-02-28T15:36:12+01:00 (4 years ago)
Author:
jgipsl
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/UserGuide/flags

    v10 v11  
    33You are running ORCHIDEE, just like every other day, when it stops for no apparent reason.  You don't have output files from the simulation, and the run.card lists "Fatal".  What can you do? 
    44 
    5 == Compile ORCHIDEE and XIOS in debug mode == 
    6 In order to pin down exactly what the problem is, you can recompile ORCHIDEE with debug flags.  These flags enable extra checks on code execution to identify unwanted behavior. 
     5== Compile in debug mode == 
     6In order to pin down exactly what the problem is, you can recompile ORCHIDEE with debug flags. These flags enable extra checks on code execution to identify unwanted behavior. 
    77 
    8 Why aren't these checks enabled by default?  Speed.  If you make certain assumptions, things will go much faster. For example, let's say we have a one-dimensional array with ten elements: ARRAY(1:10).  Asking the question, "Are we correctly accessing this array?" is not too difficult to ask (checking to see if the element number we are trying to access is between 1 and 10), and Fortran is actually ahead of other languages here in requiring that each element of the array be within bounds (See Section 6.5.3 of the Fortran 2008 standard, for example: "The value of a subscript in an array element shall be within the bounds for its dimension.").  Fortran should die with a segmentation fault if you have an array A(1:10,1:5) and you try to access A(11,1), while other languages will accept it because the offset of that address is still within the memory allocated for the array.  In general, checks like this take time, in particular if you want to know exactly which line number is causing the crash.   
     8Why aren't these checks enabled by default?  Speed. If you make certain assumptions, things will go much faster. For example, let's say we have a one-dimensional array with ten elements: ARRAY(1:10).  Asking the question, "Are we correctly accessing this array?" is not too difficult to ask (checking to see if the element number we are trying to access is between 1 and 10), and Fortran is actually ahead of other languages here in requiring that each element of the array be within bounds (See Section 6.5.3 of the Fortran 2008 standard, for example: "The value of a subscript in an array element shall be within the bounds for its dimension.").  Fortran should die with a segmentation fault if you have an array A(1:10,1:5) and you try to access A(11,1), while other languages will accept it because the offset of that address is still within the memory allocated for the array.  In general, checks like this take time, in particular if you want to know exactly which line number is causing the crash.   
    99 
    10 To turn on all these checks, we change the compiler flags.  Adding these checks can make your code run 10 times slower, so after turning on these flags, the first step is often to find the conditions that reproduce your crash in the shortest time possible (reducing the number of processors, reducing the spatial domain or using restart files to start the simulation the day before the crash). 
     10To turn on all these checks, we change the compiler flags. Adding these checks can make your code run 10 times slower, so after turning on these flags, the first step is often to find the conditions that reproduce your crash in the shortest time possible (reducing the number of processors, reducing the spatial domain or using restart files to start the simulation the day before the crash). 
    1111 
    12 With [https://forge.ipsl.jussieu.fr/orchidee/wiki/Documentation/UserGuide/CompileMethods makeorchidee_fcm], adding debug flags is fairly straightforward.   
    13  
    14 {{{ 
    15 cd modipsl/config/ORCHIDEE_OL 
    16 vi AA_make                       => change -prod into -debug everywhere you see it (three locations) 
    17 ../../util/ins_make 
    18 gmake clean && gmake 
    19 }}} 
    20  
    21 While the lines are scrolling by, you can look for things like, "-DBZ_DEBUG -g -fno-inline" and "-fpe0 -O0 -g -traceback -fp-stack-check -ftrapuv -check bounds -check all -check noarg_temp_created" to reassure yourself that the debug flags are being used. 
    22  
     12On the page [https://forge.ipsl.jussieu.fr/orchidee/wiki/Documentation/UserGuide/CompileMethods More about compile methods], it is described how to compile using debug options. In short, for newer configurations (such as ORCHIDEE_3 or LMDZOR_v6.2 and newer), compilation is done by a script compile_X.sh and adding argument '''-debug''' activates the debug options.  
     13   
    2314 
    2415= Other useful tips for debugging =