Bug encountered and investigated by @zhanglikate with debugging help from @DusanJovic-NOAA and myself. Credit goes mostly to zhanglikate who did a fantastic amount of debugging and testing in an impressively short time.
There is an out-of-bounds access (element 0) if one forgets to set these variables in ufs.configure:
flds_scalar_index_nx
flds_scalar_index_ny
flds_scalar_index_ntile
This bug is in State_SetScalar here in cpl/module_cplscalars.F90:
if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then ! <--- bug is here, not detecting scalar_id=0
call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO)
rc = ESMF_FAILURE
return
endif
farrayptr(scalar_id,1) = scalar_value ! <--- crash is here with scalar_id=0
When one of the three flds_scalar_index_ variables is missing, scalar_id is 0. The "if" block doesn't catch it because it looks for scalar_id < 0 instead of scalar_id <= 0
To Reproduce:
What compilers/machines are you seeing this with?
Irrelevant. The bug is clear in the code.
Description
Bug encountered and investigated by @zhanglikate with debugging help from @DusanJovic-NOAA and myself. Credit goes mostly to zhanglikate who did a fantastic amount of debugging and testing in an impressively short time.
There is an out-of-bounds access (element 0) if one forgets to set these variables in ufs.configure:
flds_scalar_index_nx
flds_scalar_index_ny
flds_scalar_index_ntile
This bug is in
State_SetScalar
here incpl/module_cplscalars.F90
:When one of the three
flds_scalar_index_
variables is missing, scalar_id is 0. The "if" block doesn't catch it because it looks forscalar_id < 0
instead ofscalar_id <= 0
To Reproduce:
What compilers/machines are you seeing this with? Irrelevant. The bug is clear in the code.
Give explicit steps to reproduce the behavior.
Additional context
The bug started with this commit:
Output
The stack trace: