CAM icon indicating copy to clipboard operation
CAM copied to clipboard

Bad logic in SE dycore "interpolate_vector" subroutines

Open nusbaume opened this issue 1 year ago • 2 comments

What happened?

In the interpolate_vector2d and interpolate_vector3d subroutines located in the src/dynamics/se/dycore/interpolate_mod.F90 source file there are checks that look like this:

if (npts==np) then
   interp => interp_p
else if (npts==np) then
   call endrun('interpolate_vector3d: Error in interpolate_vector(): input must be on velocity grid')
endif

However, with this setup the endrun call will never be made, because the else if check is performing the exact same logic as the original if-statement.

I have no idea if this check is actually necessary or important, but if it is then it would be good to change it so that the endrun is actually called when expected.

What are the steps to reproduce the bug?

Look at the code?

What CAM tag were you using?

cam6_3_161

What machine were you running CAM on?

Other (please explain below)

What compiler were you using?

Other (please specify below)

Path to a case directory, if applicable

No response

Will you be addressing this bug yourself?

Any CAM SE can do this

Extra info

No case was run to demonstrate this problem, I simply found it when looking at the code.

nusbaume avatar May 31 '24 17:05 nusbaume

@PeterHjortLauritzen - Should the else statement error message be printed out?

cacraigucar avatar Jun 03 '24 21:06 cacraigucar

I don't think npts is ever not np in our configurations (I think it is legacy code where SE was supporting other than Arakawa A-grids). Recommend to remove the second

if (npts==np) then

but still leave the endrun.

PeterHjortLauritzen avatar Jun 04 '24 15:06 PeterHjortLauritzen