Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust logic in gw_drag.F90 when deep_scheme='off' #1108

Closed
adamrher opened this issue Jul 25, 2024 · 3 comments
Closed

More robust logic in gw_drag.F90 when deep_scheme='off' #1108

adamrher opened this issue Jul 25, 2024 · 3 comments
Assignees
Labels
bug Something isn't working correctly

Comments

@adamrher
Copy link

adamrher commented Jul 25, 2024

What happened?

When I run a configuration with deep_scheme='off' and use_gw_convect_dp=.true., it errors out as gw_drag.F90 is doing a pbuf_get_index for a ZM pbuf variable that doesn't exist. So I just run with use_gw_convect_dp=.false, which is fine. However, with the new moving mountains gw sources that came in recently, it's using that same pbuf index ttend_dp_idx to perform a pbuf_get_field call in the moving mountains code block. If use_gw_convect_dp=.false, then that index retains its initialized value of -1 and the model errors out in the pbuf_get_field call.

I propose:

(1) Move the pbuf_get_index outside the use_gw_convect_dp conditional
(2) Create logic to only call pbuf_get_index if deep_scheme /= 'off', otherwise ttend_dp_idx retains its initialized value of -1
(3) Put a kill switch in if use_gw_convect_dp=.true. and ttend_dp_idx= -1
(4) Add logic around the moving mountain code block use_gw_movmtn_pbl to only perform the pbuf_get_field when ttend_dp_idx/= -1, else fill an array of the same size as that ZM pbuf variable with zeros, and pass that into the subroutine call gw_movmtn_src (the ZM array is not actually used by the moving mountains at this time, so making it zero doesn't change answers).

What are the steps to reproduce the bug?

see above.

What CAM tag were you using?

cam6_4_015

What machine were you running CAM on?

CISL machine (e.g. cheyenne)

What compiler were you using?

Intel

Path to a case directory, if applicable

No response

Will you be addressing this bug yourself?

Any CAM SE can do this

Extra info

@JulioTBacmeister

@adamrher adamrher added the bug Something isn't working correctly label Jul 25, 2024
@adamrher
Copy link
Author

adamrher commented Jul 26, 2024

Just remembering something @brian-eaton explained to me was the "correct" way to call a pbuf field. I don't remember exactly but I think the optional "ierr" argument is used in the pbuf_get_index call, and that it could be used as a "proxy" for the deep_scheme = 'off' case (i.e, if the ZM pbuf variable doesn't exists, then deep_scheme must be 'off').

This is relevant to step (2) above.

@brian-eaton
Copy link
Collaborator

Hi @adamrher. I propose that we have build-namelist set use_gw_convect_dp=.false. when deep_scheme='off'. In the moving mountain code block check whether ttend_dp_idx>0 before trying to associate ttend_dp with the pbuf. Otherwise allocate ttend_dp and fill with zeros. Sound OK?

@brian-eaton brian-eaton self-assigned this Aug 8, 2024
@adamrher
Copy link
Author

adamrher commented Aug 8, 2024

Yes @brian-eaton, that sounds like a plan!

brian-eaton added a commit to brian-eaton/CAM that referenced this issue Aug 9, 2024
brian-eaton added a commit to brian-eaton/CAM that referenced this issue Aug 20, 2024
nusbaume added a commit that referenced this issue Sep 9, 2024
cam6_4_031: fix issues #1108, #1106, #1058, #1051, #1050; merge PR#1101
@nusbaume nusbaume closed this as completed Sep 9, 2024
@github-project-automation github-project-automation bot moved this from To Do to Done in CAM Development Sep 9, 2024
gold2718 pushed a commit to gold2718/CAM that referenced this issue Oct 16, 2024
Merge pull request ESCOMP#1131 from brian-eaton/misc05

cam6_4_031: fix issues ESCOMP#1108, ESCOMP#1106, ESCOMP#1058, ESCOMP#1051, ESCOMP#1050; merge PR#1101

ESCOMP commit: 9f0cb73
gold2718 pushed a commit to gold2718/CAM that referenced this issue Oct 16, 2024
Merge pull request ESCOMP#1131 from brian-eaton/misc05

cam6_4_031: fix issues ESCOMP#1108, ESCOMP#1106, ESCOMP#1058, ESCOMP#1051, ESCOMP#1050; merge PR#1101

ESCOMP commit: 9f0cb73
gold2718 pushed a commit to gold2718/CAM that referenced this issue Nov 8, 2024
Merge pull request ESCOMP#1131 from brian-eaton/misc05

cam6_4_031: fix issues ESCOMP#1108, ESCOMP#1106, ESCOMP#1058, ESCOMP#1051, ESCOMP#1050; merge PR#1101

ESCOMP commit: 9f0cb73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
Status: Done
Development

No branches or pull requests

3 participants