Skip to content

Fix threading and pe-layout NBFB issues in UCI-chem codes - #69

Open
wlin7 wants to merge 1 commit into
NGD_v3atmfrom
wlin/atm/fix_pet_pem_nbfb
Open

Fix threading and pe-layout NBFB issues in UCI-chem codes#69
wlin7 wants to merge 1 commit into
NGD_v3atmfrom
wlin/atm/fix_pet_pem_nbfb

Conversation

@wlin7

@wlin7 wlin7 commented May 4, 2023

Copy link
Copy Markdown
Collaborator

. Fixed array shape pdeldry in lin_strat_chem.F90 that would failed debug mode . Replaced ch4max calculation with a global constant. A tentative fix for NBFB
that would otherwise have
. Fixed codes for surface emission section in mo_gas_phase_chemdr.F90 that
cause round-off NBFB when threading or pe-layout changes

[NBFB]

. Fixed array shape pdeldry in lin_strat_chem.F90 that would failed debug mode
. Replaced ch4max calculation with a global constant. A tentative fix for NBFB
  that would otherwise have
. Fixed codes for surface emission section in mo_gas_phase_chemdr.F90 that
   cause round-off NBFB when threading or pe-layout changes

[NBFB]
@wlin7
wlin7 requested review from jinboxie and keziming May 4, 2023 04:57
@wlin7 wlin7 self-assigned this May 4, 2023
@wlin7

wlin7 commented May 4, 2023

Copy link
Copy Markdown
Collaborator Author

@keziming , @jinboxie , though these fixes are already merged in master, it is still useful to also apply to NGD_v3atm, for testing new branches based off NGD_v3atm. Please help take a look if I mis-typed anything. You may refer to the same block of codes in E3SM master as a comparison.

*pdeldry(:ncol,k)*rga
tmp(:ncol) = wrk(:ncol,k) + cflx(:ncol,m)*delt/dble(srf_emit_nlayer)
vmr(:ncol,k,n) = tmp(:ncol)*mbar(:ncol,k)/adv_mass(n)/pdeldry(:ncol,k)/rga
wrk(i,k) = adv_mass(n)*vmr(i,k,n)/mbar(i,k) &

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wlin7 I understand you modification. But I just curious why wrk(:,k) can cause issue. I mean we have a lot fortran code like this

@wlin7 wlin7 May 4, 2023

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keziming , this is explained in more detail on the special meeting note page. (number 25 of the first table there). The problem is not with wrk itself. The problem is, for columns with cflx=0, vmr should not change. But in the old array operation format, via wrk, vmr is converted back and forth. Analytically, the multiplier followed by multiplying the inverse of the multipliers should cancel out. But in floating calculation, the round-off during each arithmetic operation causing the cancellation to be not exact. When threading or pe-layout change, where (in terms of chunks) the cflx=0 columns belong would change, for example, from a chunk with all cflx=0 to a chunk with partially non-zero, the zero cflx column would see NBFB due to the round-off.

@jinboxie jinboxie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to what we have done. The new commit has no ch4max as fixed.

@keziming

keziming commented May 4, 2023

Copy link
Copy Markdown

@wlin7 Thank you for this explanation.

@wlin7

wlin7 commented May 4, 2023

Copy link
Copy Markdown
Collaborator Author

Closed and use #70 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants