nn_stock = 0 incompatible with MOD function
Context and Analysis
nn_stock is used to control the restart writing frequency. In the nemo namelist, it is advised to use nn_stock =0 when the user only wants to write an output at the end of the simulation. However, nn_stock is used as the denominator of a MOD function. Therefore, setting nn_stock to zero is not compliant with the arguments expected by the compiler: the second argument of the MOD function "Shall be a scalar of the same type and kind as A and not equal to zero" (from https://gcc.gnu.org/onlinedocs/gfortran/MOD.html)
Fix
I proposed to change the code in restart.F90/rst_opn from:
! frequency-based restart dumping (nn_stock)
IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN
! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
nitrst = kt + nn_stock - 1 ! define the next value of nitrst for restart writing
IF( nitrst > nitend ) nitrst = nitend ! make sure we write a restart at the end of the run
ENDIF
to
! frequency-based restart dumping (nn_stock)
IF( .NOT. ln_rst_list ) THEN
! Users seem to be used to that
IF ( nn_stock == 0 ) THEN
nitrst = nitend
ELSEIF (MOD( kt - 1, nn_stock ) == 0 ) THEN
! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
nitrst = kt + nn_stock - 1 ! define the next value of nitrst for restart writing
IF( nitrst > nitend ) nitrst = nitend ! make sure we write a restart at the end of the run
ENDIF
ENDIF