issue in traldf_iso_blp
Context
Please provide informations on how to reproduce the bug:
-
Branches impacted: main -
Reference configuration/test case: ~orca025-like from BENCH test case (and I suppose other cfgs/test cases using bilaplacian operator)
Analysis
Into the traldf_iso_blp routine there is a double-nested loop on jn/jk. Inside this loop the 1st and the 2nd pass of the laplacian are called. When jk==i the variable zlap is written in zlap(:,:,i) inside the 1st pass. Then it is used in the 2nd pass for the computation of zdit and zdjt, but the computation of these variables needs of zlap(:,:,i) and zlap(:,:,i+1) that is not initialized. This results in a floating invalid - possible uninitialized real/complex variable error that kills the run.
Fix
Inside the first pass compute zlap(:,:,i) and zlap(:,:,i+1)
IF( 1 <= jk .AND. jk <= jpk-2 ) THEN ! ocean level except the deepest one (jpkm1)
...
zlap(ji,jj,jk) = & ! store in zlap
& ( ( zfu(ji,jj) - zfu(ji-1,jj) ) &
& + ( zfv(ji,jj) - zfv(ji,jj-1) ) &
& + ( zfw(ji,jj) - zfw_kp1 ) ) &
& * r1_e1e2t(ji,jj) / (e3t_1d(jk) *(1._wp+r3t(ji,jj,Kmm)*tmask(ji,jj,jk)))
! code to be added - start
IF ( jk < jpk-2 ) THEN
zlap(ji,jj,jk+1) = &
& ( ( zfu(ji,jj) - zfu(ji-1,jj) ) &
& + ( zfv(ji,jj) - zfv(ji,jj-1) ) &
& + ( zfw(ji,jj) - zfw_kp1 ) ) &
& * r1_e1e2t(ji,jj) / (e3t_1d(jk+1) *(1._wp+r3t(ji,jj,Kmm)*tmask(ji,jj,jk+1)))
ELSE
zlap(ji,jj,jk+1) = &
& ( ( zfu(ji,jj) - zfu(ji-1,jj) ) &
& + ( zfv(ji,jj) - zfv(ji,jj-1) ) &
& + ( zfw(ji,jj) ) ) &
& * r1_e1e2t(ji,jj) / (e3t_1d(jk+1) *(1._wp+r3t(ji,jj,Kmm)*tmask(ji,jj,jk+1)))
ENDIF
! code to be added - end
Edited by Francesca Mele