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

Redundant surface variable cleanup #659

Closed
wants to merge 9 commits into from
Closed

Conversation

mzhangw
Copy link
Collaborator

@mzhangw mzhangw commented May 17, 2021

This effort is to address the issue.
Associated PR: NOAA-EMC/fv3atm#317

@mzhangw mzhangw changed the title Redundant surface variable cleanup (WORK IN PROGRESS) Redundant surface variable cleanup May 27, 2021
@mzhangw mzhangw marked this pull request as ready for review May 27, 2021 18:57
Copy link
Collaborator

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

This is looking good! A couple of changes (mainly reversing whitespace changes), please. Hopefully all regression tests pass on Hera with both compilers.

snowd_lnd(i) = snowd(i)
semis_lnd(i) = semis_rad(i)
qss_lnd(i) = qss(i)
hflx_lnd(i) = hflx(i)
qss_lnd(i) = qss(i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert indentation changes in lines 198 and 199

@@ -209,8 +206,7 @@ subroutine GFS_surface_composites_pre_run (im, lkm, frac_grid, flag_cice, cplflx
if (icy(i)) then ! Ice
uustar_ice(i) = uustar(i)
weasd_ice(i) = weasd(i)
tsfc_ice(i) = tisfc(i)
tsurf_ice(i) = tisfc(i)
tsfci(i) = tisfc(i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, = were aligned previously.

evap(i) = evap_ice(i)
hflx(i) = hflx_ice(i)
qss(i) = qss_ice(i)
tisfc(i) = tice(i)
if (.not. flag_cice(i)) then
! tisfc(i) = tice(i) ! over lake ice (and sea ice when uncoupled)
zorl(i) = cice(i) * zorli(i) + (one - cice(i)) * zorlo(i)
tsfc(i) = tsfc_ice(i) ! over lake (and ocean when uncoupled)
tsfc(i) = tsfci(i) ! over lake (and ocean when uncoupled)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove extra blank line

@@ -27,7 +27,7 @@ end subroutine GFS_surface_generic_pre_finalize
!!
subroutine GFS_surface_generic_pre_run (im, levs, vfrac, islmsk, isot, ivegsrc, stype, vtype, slope, &
prsik_1, prslk_1, tsfc, phil, con_g, &
sigmaf, soiltyp, vegtype, slopetyp, work3, tsurf, zlvl, &
sigmaf, soiltyp, vegtype, slopetyp, work3, zlvl, &
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change has been made in a previous PR (#627 I think), you will see the merge conflict when you update your code.

@@ -187,7 +187,7 @@ subroutine sfc_noah_wrfv4_pre_run (im, nsoil, ialb, isice, land, &
if (land(i) .and. flag_guess(i)) then
weasd_save(i) = weasd(i)
snwdph_save(i) = snwdph(i)
tsfc_save(i) = tsfc(i)
!mz tsfc_save(i) = tsfc(i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please delete instead of commenting out if really not needed (did you check the gsd diag 3d test)?

@@ -738,7 +738,7 @@ subroutine sfc_noah_wrfv4_post_run (im, nsoil, land, flag_guess, flag_lsm, &
if (flag_guess(i)) then
weasd(i) = weasd_save(i)
snwdph(i) = snwdph_save(i)
tsfc(i) = tsfc_save(i)
!mz tsfc(i) = tsfc_save(i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, pease delete instead of commenting out if really not needed.

Copy link
Collaborator

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for updating the formatting. I will combine this PR with other PRs, so that you don't have to keep updating the PRs from main all the time.

@climbfuji
Copy link
Collaborator

@mzhangw I just discovered that the changes in your PR lead to situations where you are passing the SAME variable (i.e. same standard name) to the scheme twice with different local name. That is forbidden, not just by CCPP but also by Fortran standards. See for example sfc_nst and sfc_drv_ruc. I'll fix that in my effort to bring it up to date with the current code and combine it with Xia's changes.

@climbfuji
Copy link
Collaborator

I also get those errors from the host model variable definitions:

ERROR: Multiple definitions of standard_name surface_longwave_emissivity_over_ice in type/variable defintions

Will work on it.

@mzhangw
Copy link
Collaborator Author

mzhangw commented Jul 23, 2021 via email

@climbfuji
Copy link
Collaborator

I actually don't understand how this code compiled, ran and verified against the existing baselines. The metadata parser immediately threw errors about duplicate standard names in several ccpp-physics routines. I don't remember adding this check recently, but maybe I did.

@mzhangw
Copy link
Collaborator Author

mzhangw commented Jul 23, 2021 via email

@climbfuji climbfuji self-requested a review July 27, 2021 20:54
@mzhangw
Copy link
Collaborator Author

mzhangw commented Jul 28, 2021

Recent code update causes some conflicts with this PR. I need revisit this PR.

@climbfuji
Copy link
Collaborator

Thanks, agreed. The code should never have compiled or run. Passing the same variable twice to a subroutine is dangerous and can have bad consequences. This PR is therefore on hold until the issues are resolved. Thanks for working on it, and sorry for not catching the problems in the first review (GitHub diff view isn't any good for this type of changes).

@mzhangw
Copy link
Collaborator Author

mzhangw commented Jul 29, 2021 via email

@climbfuji
Copy link
Collaborator

The PRs did pass all RTs back in May (See my attached log). However, the surface codes have been updated significantly since then. It won't hurt to revisit it with new updates.

Even if they passed, the code was incorrect. You are not allowed to pass the same variable (e.g. same standard name) twice to a Fortran function or subroutine. Fortunately, the CCPP framework now catches these errors.

@climbfuji
Copy link
Collaborator

This PR will be replaced with a new one.

@climbfuji climbfuji closed this Aug 5, 2021
@mzhangw mzhangw deleted the redund_surface branch December 15, 2021 21:16
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.

None yet

2 participants