The parameter thickness_diffuse_CS@Use_KH_in_MEKE is given a value only if use_meke is true:
Lines 2385-2388 in MOM_thickness_diffuse.F90
if (use_meke) then
call get_param(param_file, mdl, "USE_KH_IN_MEKE", CS%Use_KH_in_MEKE, &
"If true, uses the thickness diffusivity calculated here to diffuse MEKE.", &
default=.false.)
However, Use_KH_in_MEKE is later tested in a way that doens't depend on the value of use_meke:
Line 553
if (CS%id_KH_t > 0 .or. CS%id_KH_t1 > 0 .or. CS%Use_KH_in_MEKE) then
and lines 581-582
if (CS%Use_KH_in_MEKE) then
MEKE%Kh_diff(:,:) = 0.0
This last instance can lead to a segmentation fault since MEKE%Kh_diff is only allocated if use_meke is true. Note that lines 581-582 are only reached if the user requests diffusivity diagnostics (so line 553 evaluates to true), but I don't see any reason why diffusivity diagnostics should require MEKE.
The actual outcome seems to depend on the compiler, which is probably due to how they give uninitialized logical variables values. I get a crash due to segfault with the GNU compiler, but not with the Intel compiler.
The simplest solution would be to move the get_param call above the if (use_meke) then test. I could do a pull request with this change, but it'd probably be faster to have a more active developer do this than for me to try to figure out the respository & pull request policies.
The parameter
thickness_diffuse_CS@Use_KH_in_MEKEis given a value only ifuse_mekeis true:Lines 2385-2388 in
MOM_thickness_diffuse.F90However,
Use_KH_in_MEKEis later tested in a way that doens't depend on the value ofuse_meke:Line 553
and lines 581-582
This last instance can lead to a segmentation fault since
MEKE%Kh_diffis only allocated ifuse_mekeis true. Note that lines 581-582 are only reached if the user requests diffusivity diagnostics (so line 553 evaluates to true), but I don't see any reason why diffusivity diagnostics should require MEKE.The actual outcome seems to depend on the compiler, which is probably due to how they give uninitialized logical variables values. I get a crash due to segfault with the GNU compiler, but not with the Intel compiler.
The simplest solution would be to move the
get_paramcall above theif (use_meke) thentest. I could do a pull request with this change, but it'd probably be faster to have a more active developer do this than for me to try to figure out the respository & pull request policies.