Skip to content

The `qsr3d` diagnostic can cause an XIOS numeric conversion error

Context

  • Branches impacted: branch_4.2, main
  • Reference configuration/test case: ORCA2
  • Computing architecture:
  • Dependencies: XIOS 2.5, ln_traqsr = .TRUE., key_qco

Analysis

The qsr3d diagnostic sometimes causes numerical conversion errors in XIOS. This usually implies NaNs or other floating point values that can't be written to the netCDF file.

In this case, it seems to be caused by undefined values due to halo points not being initialised above depth nksr+1:

IF( iom_use('qsr3d') ) THEN      ! output the shortwave Radiation distribution
   ALLOCATE( zetot(T2D(nn_hls),jpk) )
   zetot(:,:,nksr+1:jpk) = 0._wp     ! below ~400m set to zero
   DO_3DS(0, 0, 0, 0, nksr, 1, -1)
      zetot(ji,jj,jk) = zetot(ji,jj,jk+1) + qsr_hc(ji,jj,jk) * rho0_rcp
   END_3D
   CALL iom_put( 'qsr3d', zetot )   ! 3D distribution of shortwave Radiation
   DEALLOCATE( zetot )
ENDIF

Fix

For both branch_4.2 and the main, the solution is to define this diagnostic on the grid_T_3D_inner grid in the field_def.xml file, allowing:

- ALLOCATE( zetot(T2D(nn_hls),jpk) )
+ ALLOCATE( zetot(T2D(0),jpk) )

In the main, the RK3 version of this diagnostic reuses an array that would require the grid_T_3D grid to be used:

IF( l_trdtra ) THEN     ! trends diagnostic: save the input temperature trend
   ALLOCATE( ztrdt(jpi,jpj,jpk) )
   ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs)
ENDIF
#if defined key_RK3
!                             ! RK3 : diagnostics/output
IF( l_trdtra .OR. iom_use('qsr3d') ) THEN     ! qsr diagnostics
   ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:)
   !                                         ! qsr tracers trends saved for diagnostics
   IF( l_trdtra )   CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_qsr, ztrdt )
   IF( iom_use('qsr3d') ) THEN               ! qsr distribution
      DO jk = nkV, 1, -1
         ztrdt(:,:,jk) = ztrdt(:,:,jk+1) + qsr_hc(:,:,jk) * rho0_rcp
      END DO
      CALL iom_put( 'qsr3d', ztrdt )   ! 3D distribution of shortwave Radiation
   ENDIF
   DEALLOCATE( ztrdt )
ENDIF
#else

As this seems to be broken anyway (if iom_use('qsr3d') = .TRUE. and l_trdtra = .FALSE., ztrdt is unallocated), the RK3-specific code for the trends and qsr3d diagnostics should probably just be removed.

Edited by Daley Calvert
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information