Index: /NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/ICE/icedyn_rdgrft.F90
===================================================================
--- /NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/ICE/icedyn_rdgrft.F90 (revision 13191)
+++ /NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/ICE/icedyn_rdgrft.F90 (revision 13192)
@@ -300,5 +300,13 @@
! ! Ice thickness needed for rafting
+ ! In single precision there were floating point invalids due a sqrt of zhi which happens to have negative values
+ ! To solve that an extra check about the value of pv_i was added.
+ ! Although adding this condition is safe, the double definition (one for single other for double) has been kept to preserve the results of the sette test.
+#if defined key_single
+
WHERE( pa_i(1:npti,:) > epsi10 .and. pv_i(1:npti,:) > epsi10 ) ; zhi(1:npti,:) = pv_i(1:npti,:) / pa_i(1:npti,:)
+#else
+ WHERE( pa_i(1:npti,:) > epsi10 ) ; zhi(1:npti,:) = pv_i(1:npti,:) / pa_i(1:npti,:)
+#endif
ELSEWHERE ; zhi(1:npti,:) = 0._wp
END WHERE