# \[v4.0.x\] \*p4zopt.f90\* crash: out of lower bound value for \`rkrgb\`

**URL:** <https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290>\
**Category:** v4.0.x\
**Tags:** P4Z, PISCES\
**Created:** [28 April 2022 21:58 UTC](https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290 "2022-04-28T21:58:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ukocean](https://avatars.discourse-cdn.com/v4/letter/u/e480ec/32.png) [@ukocean](https://nemo-ocean.discourse.group/u/ukocean)\
**Post date:** [28 April 2022 21:58 UTC](https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290/1 "2022-04-28T21:58:03Z")

</div>

Dear users,

I’m trying to run r4.0.7 version of nemo using r05 resolution and get the error message:

```nohighlight
forrtl: severe (408): fort: (3): Subscript #2 of the array RKRGB has value "-2147483648" which is less than the lower bound of 1

```

Default version of nemo-r4.0.7 and 4.0.x runs ok without the problems described below.  
Forcing input data for r05 worked ok with nemo v3.6.  
The problem could be input data remapped from input for r2 default version?  
Or maybe there may be inconsistencies of nemo compiled with mpiifort with MPI, netcdf, HDF, xios-2.5 and others ?  
I’d appreciate any suggestions as to how to solve this problem.  
Thanks

> **ocean.output**
>
> ```nohighlight
> ..........
> dyn_nxt : time stepping
> ~~~~~~~
> 
> ssh_swp : Asselin time filter and swap of sea surface height
> ~~~~~~~
> 
> dom_vvl_sf_swp : - time filter and swap of scale factors
> ~~~~~~~~~~~~~~ - interpolate scale factors and compute depths for next time s
> tep
> 
> stp_ctl : time-stepping control
> ~~~~~~~
> file : time.step open ok
> unit = 31
> status = REPLACE
> form = FORMATTED
> access = SEQUENTIAL
> 
> fld_read: var dust kt = 2 ( 0.0375 days), Y/M/D = 2000/01/01, records b/a: 0012/ 0001 (days -15.5000/ 15.5000)
> it_offset is : 0
> fld_read: var riverdic kt = 2 ( 0.0375 days), Y/M/D = 2000/01/01, records b/a: 0073/ 0001 (days -2.5000/ 2.5000)
> it_offset is : 0
> fld_read: var riverdoc kt = 2 ( 0.0375 days), Y/M/D = 2000/01/01, records b/a: 0073/ 0001 (days -2.5000/ 2.5000)
> it_offset is : 0
> fld_read: var riverdin kt = 2 ( 0.0375 days), Y/M/D = 2000/01/01, records b/a: 0073/ 0001 (days -2.5000/ 2.5000)
> it_offset is : 0
> fld_read: var riverdon kt = 2 ( 0.0375 days), Y/M/D = 2000/01/01, records b/a: 0073/ 0001 (days -2.5000/ 2.5000)
> it_offset is : 0
> ==== >>>
> ==== >>> run ends here <<< ====
> 
> ```

> **terminal**
>
> ```nohighlight
> -> info : CClientBuffer: allocated 2 x 547150440 bytes for server 0 with a maximum of 58 buffered events
> ........................................................................................
> forrtl: severe (408): fort: (3): Subscript #2 of the array RKRGB has value -2147483648 which is less than the lower bound of 1
>  
> Image PC Routine Line Source
> nemo.exe 0000000002BB7A76 Unknown Unknown Unknown
> nemo.exe 0000000001339D61 p4zopt_mp_p4z_opt 101 p4zopt.f90
> nemo.exe 0000000001BDE609 p4zbio_mp_p4z_bio 90 p4zbio.f90
> nemo.exe 0000000001426AE5 p4zsms_mp_p4z_sms 132 p4zsms.f90
> nemo.exe 0000000001731109 trcsms_mp_trc_sms 61 trcsms.f90
> nemo.exe 0000000000682DB6 trcstp_mp_trc_stp 113 trcstp.f90
> nemo.exe 00000000004B47E4 step_mp_stp_ 207 step.f90
> nemo.exe 000000000043CFC0 nemogcm_mp_nemo_g 161 nemogcm.f90
> nemo.exe 000000000043CED0 MAIN__ 18 nemo.f90
> nemo.exe 000000000043CE9E Unknown Unknown Unknown
> libc-2.17.so 00002B2B07828555 __libc_start_main Unknown Unknown
> nemo.exe 000000000043CDA9 Unknown Unknown Unknown
> forrtl: severe (408): fort: (3): Subscript #2 of the array RKRGB has value -2147483648 which is less than the lower bound of 1
> 
> ```

> **p4zopt.f90**
>
> ```fortran
> SUBROUTINE p4z_opt( kt, knt )
> !!---------------------------------------------------------------------
> !! ***ROUTINE p4z_opt***
> !!
> !! ** Purpose : Compute the light availability in the water column
> !! depending on the depth and the chlorophyll concentration
> !!
> !! ** Method : - ???
> !!---------------------------------------------------------------------
> INTEGER, INTENT(in) :: kt, knt ! ocean time step
> !
> INTEGER :: ji, jj, jk
> INTEGER :: irgb
> REAL(wp) :: zchl
> REAL(wp) :: zc0 , zc1 , zc2, zc3, z1_dep
> REAL(wp), ALLOCATABLE, DIMENSION(:,: ) :: zetmp5
> REAL(wp), DIMENSION(jpi,jpj ) :: zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4
> REAL(wp), DIMENSION(jpi,jpj ) :: zqsr100, zqsr_corr
> REAL(wp), DIMENSION(jpi,jpj,jpk) :: zpar, ze0, ze1, ze2, ze3, zchl3d
> !!---------------------------------------------------------------------
> !
> IF( ln_timing ) CALL timing_start('p4z_opt')
> 
> IF( knt == 1 .AND. ln_varpar ) CALL p4z_opt_sbc( kt )
> 
> ! Initialisation of variables used to compute PAR
> ! -----------------------------------------------
> ze1(:,:,:) = 0._wp
> ze2(:,:,:) = 0._wp
> ze3(:,:,:) = 0._wp
> !
> ! !* attenuation coef. function of Chlorophyll and wavelength (Red-Green-Blue)
> ! ! --------------------------------------------------------
> zchl3d(:,:,:) = trb(:,:,:,jpnch) + trb(:,:,:,jpdch)
> IF( ln_p5z ) zchl3d(:,:,:) = zchl3d(:,:,:) + trb(:,:,:,jppch)
> !
> DO jk = 1, jpkm1
> DO jj = 1, jpj
> DO ji = 1, jpi
> zchl = ( zchl3d(ji,jj,jk) + rtrn ) * 1.e6
> zchl = MIN( 10. , MAX( 0.05, zchl ) )
> irgb = NINT( 41 + 20.* LOG10( zchl ) + rtrn )
> !
> ekb(ji,jj,jk) = rkrgb(1,irgb) * e3t_n(ji,jj,jk) <<<< ===========================================
> ekg(ji,jj,jk) = rkrgb(2,irgb) * e3t_n(ji,jj,jk)
> ekr(ji,jj,jk) = rkrgb(3,irgb) * e3t_n(ji,jj,jk)
> END DO
> END DO
> END DO
> 
> ```

> **rkrgb**
>
> _oce\_trc.f90_
> 
> ```fortran
> USE traqsr , ONLY : rkrgb => rkrgb !: tabulated attenuation coefficients for RGB absorption
> 
> ```
> 
> _traqsr.f90_
> 
> ```fortran
> REAL(wp) , PUBLIC, DIMENSION(3,61) :: rkrgb ! tabulated attenuation coefficients for RGB absorption
> zekb(ji,jj) = rkrgb(1,irgb)
> zekg(ji,jj) = rkrgb(2,irgb)
> zekr(ji,jj) = rkrgb(3,irgb)
> CALL trc_oce_rgb( rkrgb ) ! tabulated attenuation coef.
> CALL trc_oce_rgb( rkrgb ) ! tabulated attenuation coef.
> 
> ```

> **zchl**
>
> _p4zopt.f90_
> 
> ```fortran
> zchl = ( zchl3d(ji,jj,jk) + rtrn ) * 1.e6
> zchl = MIN( 10. , MAX( 0.05, zchl ) )
> 
> ```
> 
> _trc\_oce.f90_
> 
> ```fortran
> REAL(wp) :: zchl ! temporary scalar
> zchl = zrgb(1,jc)
> 
> ```
> 
> _traqsr.f90_:
> 
> ```fortran
> REAL(wp) :: zchl, zcoef, z1_2 ! local scalars
> zchl = MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) )
> zchl = MIN( 10. , MAX( 0.03, zchl3d(ji,jj,jk) ) )
> 
> ```

> **zrgb**
>
> _trc\_oce.f90_
> 
> ```fortran
> REAL(wp), DIMENSION(4,61) :: zrgb ! tabulated attenuation coefficient (formerly read in 'kRGB61.txt')
> zrgb(1, 1) = 0.010 ; zrgb(2, 1) = 0.01618 ; zrgb(3, 1) = 0.07464 ; zrgb(4, 1) = 0.37807
> zrgb(1, 2) = 0.011 ; zrgb(2, 2) = 0.01654 ; zrgb(3, 2) = 0.07480 ; zrgb(4, 2) = 0.37823
> zrgb(1, 3) = 0.013 ; zrgb(2, 3) = 0.01693 ; zrgb(3, 3) = 0.07499 ; zrgb(4, 3) = 0.37840
> ...
> zrgb(1,60) = 8.912 ; zrgb(2,60) = 0.44336 ; zrgb(3,60) = 0.25725 ; zrgb(4,60) = 0.55457
> zrgb(1,61) = 10.000 ; zrgb(2,61) = 0.47804 ; zrgb(3,61) = 0.27178 ; zrgb(4,61) = 0.56870
> prgb(:,:) = zrgb(2:4,:)
> r_si2 = 1.e0 / zrgb(2, 1) ! blue with the smallest chlorophyll concentration)
> 
> DO jc = 1, 61 ! check
> zchl = zrgb(1,jc)
> 
> ```

> **zchl3d**
>
> _p4zopt.f90_
> 
> ```fortran
> REAL(wp), DIMENSION(jpi,jpj,jpk) :: zpar, ze0, ze1, ze2, ze3, zchl3d
> zchl3d(:,:,:) = trb(:,:,:,jpnch) + trb(:,:,:,jpdch)
> IF( ln_p5z ) zchl3d(:,:,:) = zchl3d(:,:,:) + trb(:,:,:,jppch)
> zchl = ( zchl3d(ji,jj,jk) + rtrn ) * 1.e6
> 
> ```
> 
> _traqsr.f90_
> 
> ```fortran
> REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zetot, zchl3d
> & ze3 (jpi,jpj,jpk) , zea (jpi,jpj,jpk) , zchl3d(jpi,jpj,jpk) )
> zchl3d(ji,jj,jk) = zCze * ( zCb + zCmax * EXP( -( (zpsi - zpsimax) / zdelpsi )**2 ) )
> zchl3d(:,:,jk) = 0.05
> zchl = MIN( 10. , MAX( 0.03, zchl3d(ji,jj,jk) ) )
> DEALLOCATE( zekb , zekg , zekr , ze0 , ze1 , ze2 , ze3 , zea , zchl3d )
> 
> ```

* * *

---

<div class="post-metadata">

**Author:** ![ntmlod](https://yyz2.discourse-cdn.com/free1/user_avatar/nemo-ocean.discourse.group/ntmlod/32/6_2.png) [@ntmlod](https://nemo-ocean.discourse.group/u/ntmlod)\
**Post date:** [29 April 2022 07:22 UTC](https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290/3 "2022-04-29T07:22:57Z")

</div>



---

<div class="post-metadata">

**Author:** ![Guillaume\_Mercator](https://yyz2.discourse-cdn.com/free1/user_avatar/nemo-ocean.discourse.group/guillaume_mercator/32/252_2.png) [@Guillaume\_Mercator](https://nemo-ocean.discourse.group/u/Guillaume_Mercator)\
**Post date:** [5 May 2022 08:55 UTC](https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290/4 "2022-05-05T08:55:33Z")

</div>

Hello, just to mention that I can also reproduce this issue with Nemo 4.2 and Nemo main using ORCA025 + PISCES, I will open an issue on Gitlab to keep track of it.

> **[Floating invalid in p4zopt.f90 with RGB traqsr (#45) · Issues · NEMO Sources...](https://forge.nemo-ocean.eu/nemo/nemo/-/issues/45)**
>
> The issue reported on https://nemo-ocean.discourse.group/t/v4-0-x-r05-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290 can also be reproduced with Nemo 4.2 and Nemo main branches using ORCA025+PISCES configuration. I don't know yet...

Guillaume

---

<div class="post-metadata">

**Author:** ![Jin](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jin](https://nemo-ocean.discourse.group/u/Jin)\
**Post date:** [12 May 2022 07:39 UTC](https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290/5 "2022-05-12T07:39:28Z")

</div>

Hello,

I also have a similar error. I’m trying to run ORCA2\_ICE\_PISCES in NEMO4.0.6 using gfortran compiler. There was no `E R R O R` flag in _ocean.output_. I read the posting on Gitlab… Please let me know anyone know how to fix it.

```nohighlight
Error termination. Backtrace:
At line 132 of file /media/cmlws/Data1/hjc/NEMO/r4.0.6/cfgs/ORCA_test4/BLD/ppsrc/nemo/p4zopt.f90
Fortran runtime error: Index '0' of dimension 2 of array 'rkrgb' below lower bound of 1

```

_namelist\_cfg_

```fortran
!-----------------------------------------------------------------------
&namtra_qsr ! penetrative solar radiation (ln_traqsr =T)
!-----------------------------------------------------------------------
   ! ! type of penetration (default: NO selection)
   ln_qsr_rgb = .true. ! RGB light penetration (Red-Green-Blue)
   !
   nn_chldta = 0 ! RGB : Chl data (=1) or cst value (=0)

   cn_dir = './' ! root directory for the chlorophyl data location
   ! ___________!_________________________! ___________________!___________! _____________!________! ___________!__________________! __________!_______________!
   ! ! file name ! frequency (hours) ! variable ! time interp.! clim ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
   ! ! ! (if <0 months) ! name ! (logical) ! (T/F) ! 'monthly' ! ! pairing ! filename !
   sn_chl ='chl_clim_seawifs_modis_199710-202112', -1. , 'chlor_a' , .true. , .true. , 'yearly' , 'weights_chl_nemo2_bilin.nc' , '' , ''
/

```

_p4zopt.f90_

```fortran
! !* attenuation coef. function of Chlorophyll and wavelength (Red-Green-Blue)
      ! ! --------------------------------------------------------
                     zchl3d(:,:,:) = trb(:,:,:,jpnch) + trb(:,:,:,jpdch)
      IF( ln_p5z ) zchl3d(:,:,:) = zchl3d(:,:,:) + trb(:,:,:,jppch)
      !
      DO jk = 1, jpkm1
         DO jj = 1, jpj
            DO ji = 1, jpi
               zchl = ( zchl3d(ji,jj,jk) + rtrn ) * 1.e6
               zchl = MIN( 10. , MAX( 0.05, zchl ) )
               irgb = NINT( 41 + 20.* LOG10( zchl ) + rtrn )
               !
               ekb(ji,jj,jk) = rkrgb(1,irgb) * e3t_n(ji,jj,jk) ! <<== 132 line
               ekg(ji,jj,jk) = rkrgb(2,irgb) * e3t_n(ji,jj,jk)
               ekr(ji,jj,jk) = rkrgb(3,irgb) * e3t_n(ji,jj,jk)
            END DO
         END DO
      END DO

```

the last part of _ocean.output_ :

```nohighlight
======>> time-step = 1225 New day, DATE Y/M/D = 2006/01/18 nday_year = 018
         nsec_year = 1469400 nsec_month = 1469400 nsec_day = 600
   nsec_week = 346200
           read UGRD_GDS0_HTGL (rec: 69) in ./anl_surf125_ugrd_y2006.nc ok
           read VGRD_GDS0_HTGL (rec: 69) in ./anl_surf125_vgrd_y2006.nc ok
           read TMP_GDS0_HTGL (rec: 69) in ./anl_surf125_tmp_y2006.nc ok
           read SPFH_GDS0_HTGL (rec: 69) in ./anl_surf125_spfh_y2006.nc ok
           read dswrf (rec: 18) in ./fcst_phy2m125_dswrf_y2006.nc ok
           read dlwrf (rec: 18) in ./fcst_phy2m125_dlwrf_y2006.nc ok
           read PRMSL_GDS0_MSL (rec: 69) in ./anl_surf125_prmsl_y2006.nc ok
           read UGRD_GDS0_HTGL (rec: 70) in ./anl_surf125_ugrd_y2006.nc ok
           read VGRD_GDS0_HTGL (rec: 70) in ./anl_surf125_vgrd_y2006.nc ok
           read TMP_GDS0_HTGL (rec: 70) in ./anl_surf125_tmp_y2006.nc ok

```

Thank you in advance.  
Best regards,

Hwa-Jin Choi

---

<div class="post-metadata">

**Author:** ![robinson](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@robinson](https://nemo-ocean.discourse.group/u/robinson)\
**Post date:** [24 August 2026 05:21 UTC](https://nemo-ocean.discourse.group/t/v4-0-x-p4zopt-f90-crash-out-of-lower-bound-value-for-rkrgb/290/6 "2026-08-24T05:21:51Z")

</div>

Hei,

I have a similar problem. It occurs because PISCES produces NaNs, so the ikrgb index is nonsens.

What i do not understand is that the physics (active tracers) run just fine, so there is something specific to pisces that diverges.

Any update is welcome,

Cheers,

Robinson
