# Nan when calculating solar radiation absorption

**URL:** <https://nemo-ocean.discourse.group/t/nan-when-calculating-solar-radiation-absorption/975>\
**Category:** Uncategorized\
**Created:** [23 December 2025 09:33 UTC](https://nemo-ocean.discourse.group/t/nan-when-calculating-solar-radiation-absorption/975 "2025-12-23T09:33:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pysh](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@Pysh](https://nemo-ocean.discourse.group/u/Pysh)\
**Post date:** [23 December 2025 09:33 UTC](https://nemo-ocean.discourse.group/t/nan-when-calculating-solar-radiation-absorption/975/1 "2025-12-23T09:33:24Z")

</div>

Hello!

I encountered the following case while running a program version 4.2.3: In algorithm of the absorption of solar radiation in the **CdN\_f\_LG15\_light** function from the s **bcblk\_algo\_ice\_cdn.F90** value of **zfri** (== **at\_i\_b** ) exceeded one. And the expression in the function **(1.\_wp - zfri)** turned out to be less than zero. This led to the beginning of NaN propagation to all arrays **u\_ice, v\_ice, a\_i, ssh** , and others. Similar problems seem to be possible in other functions in this module. The functions are the same in version 5.0. Perhaps **at\_i\_b** shouldn’t exceed 1, but I made the following edit anyway:

! zfri = pfrice(ji,jj)

zfri = min(pfrice(ji,jj), 1.\_wp - 1.e-6)

or

! CdN\_f\_LG15\_light(ji,jj) = rce10\_i\_0 \*zrlog\*zrlog \* zfri \* (1.\_wp - zfri)\*\*rbeta\_0

CdN\_f\_LG15\_light(ji,jj) = rce10\_i\_0 \*zrlog\*zrlog \* zfri \* ( **abs** (1.\_wp - zfri))\*\*rbeta\_0

And there is unpleasant effect of NaN propagation. For example, in the radiation absorption algorithm (traqsr.F90 module)

!\* interior equi-partition in R-G-B depending on vertical profile of Chl

DO jk = 2, nksr + 1 ; DO jj = ntsj-( nn\_hls-( nn\_hls+ nn\_hls)\*nthb), ntej+( nn\_hls-( nn\_hls+ nn\_hls)\*ntht) ; DO ji = ntsi-( nn\_hls-( nn\_hls+ nn\_hls)\*nthl), ntei+( nn\_hls-( nn\_hls+ nn\_hls)\*nthr)

ze3t = (e3t\_0(ji,jj,jk-1)\*(1.\_wp+r3t(ji,jj,Kmm)\*tmask(ji,jj,jk-1)))

irgb = NINT( ztmp3d(ji,jj,jk) )

zc0 = ze0(ji,jj) \* EXP( - ze3t \* xsi0r )

…

ztmp3d(ji,jj,jk) = ( zc0 + zc1 + zc2 + zc3 ) \* wmask(ji,jj,jk)

END DO ; END DO ; END DO

when **r3t** = NaN, the **irgb** array index becomes undefined, and the program terminates with an uninformative message before reaching NEMO’s standard error abort output. Perhaps this section of the code should not be executed when **r3t** = NaN with the addition of **nstop** = **nstop** +1
