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

Rayleigh Friction to CCPP #1245

Open
wants to merge 14 commits into
base: cam_development
Choose a base branch
from

Conversation

Katetc
Copy link
Collaborator

@Katetc Katetc commented Feb 4, 2025

I need to merge this one up too, but here's the PR for Rayleigh Friction to CCPP!

Fixes #1153

@Katetc Katetc requested review from peverwhee and nusbaume February 4, 2025 00:57
@Katetc Katetc self-assigned this Feb 4, 2025
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks good @Katetc! Just had one request with regards to the CAM subroutine names.

Copy link
Collaborator

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

I took a quick peek back at this PR, and realized that it does not have the update to .gitmodules to bring in the atmospheric_physics PR which will come in along with this one

@Katetc Katetc requested a review from nusbaume April 4, 2025 21:06
Copy link
Collaborator

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

I realized that I never did a full review, so I have done that now. @nusbaume - please chime in your thoughts on the _cam routines. I believe they add an unnecessary layer, but it might be a convention which are trying to implement?

Comment on lines 110 to 111
subroutine rayleigh_friction_cam_tend( &
ztodt ,state ,ptend )
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this routine does not need to be made and the call to rayleigh_friction_run can be made directly in physpkg. See the important note below on the individual elements in the call.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My proposed changes have been made assuming the elimination of this routine.

ptend%v(:ncol,k) = c1 * state%v(:ncol,k)
ptend%s(:ncol,k) = c3 * (state%u(:ncol,k)**2 + state%v(:ncol,k)**2)
enddo
call rayleigh_friction_run(ncol, pver, ztodt, state%u, state%v, ptend%u, ptend%v, ptend%s, errmsg, errflg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe these arrays need to be subset by :ncol in the appropriate dimensions. For instance, state%u(:ncol,:), instead of just state%u. I'm surprised this is working without this subsetting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this works because the subsetting is done inside the repo, but I agree that it would be safest to do it at the calling-level as well!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't believe the CCPP level should be doing the subsetting. I've made that request in the atmospheric_physics PR and then this subsetting will be required. I'm indicating where this call to rayleigh_friction_run should go if this routine is eliminated.


subroutine rayleigh_friction_init()
subroutine rayleigh_friction_cam_init()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest that this routine should be eliminated and rayleigh_friction_init be called directly in the physpkg.F90 routines

Copy link
Collaborator

Choose a reason for hiding this comment

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

My proposed changes have been made assuming the elimination of this routine.

Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks great to me now (assuming you also make @cacraigucar's changes, as I agree just calling the CCPP-ized subroutines directly is probably the best approach in this case)!

Copy link
Collaborator

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

I believe I have found all the lines that need to be changed, but I might have missed something. If you encounter problems with these changes, let me know and I can help you debug.

ptend%v(:ncol,k) = c1 * state%v(:ncol,k)
ptend%s(:ncol,k) = c3 * (state%u(:ncol,k)**2 + state%v(:ncol,k)**2)
enddo
call rayleigh_friction_run(ncol, pver, ztodt, state%u, state%v, ptend%u, ptend%v, ptend%s, errmsg, errflg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't believe the CCPP level should be doing the subsetting. I've made that request in the atmospheric_physics PR and then this subsetting will be required. I'm indicating where this call to rayleigh_friction_run should go if this routine is eliminated.

if (trim(cam_take_snapshot_before) == "rayleigh_friction_tend") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat)
end if
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add:
call physics_ptend_init(ptend, state%psetcols, 'rayleigh friction', ls=.true., lu=.true., lv=.true.)

! Initialize ptend variables to zero
!REMOVECAM - no longer need these when CAM is retired and pcols no longer exists
ptend%u(:,:) = 0._r8
ptend%v(:,:) = 0._r8
ptend%s(:,:) = 0._r8
!REMOVECAM_END

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat)
end if
call rayleigh_friction_cam_tend( ztodt, state, ptend)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Call rayleigh_friction_run here.

call rayleigh_friction_run pver, ztodt, state%u(:ncol,:), state%v(:ncol,:), ptend%u(:ncol,:), ptend%v(:ncol,:), ptend%s(:ncol,:), errmsg, errflg)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated with appropriate subsetting

call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf, &
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
end if
call rayleigh_friction_tendO( ztodt, state, ptend)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace this line with:
call rayleigh_friction_run pver, ztodt, state%u(:ncol,:), state%v(:ncol,:), ptend%u(:ncol,:), ptend%v(:ncol,:), ptend%s(:ncol,:), errmsg, errflg)

I couldn't find the code for rayleigh_friction_tendO, but it exists, I would suggest it be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed the name to "_cam_tend" for Jesse's review, but forgot to update the cam7 physpkg. I have updated that file and tested both cam7 and camdev physics.

@@ -877,7 +877,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )

call gw_init()

call rayleigh_friction_init()
call rayleigh_friction_initO()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Call rayleigh_friction_init directly.

If the routine rayleigh_friction_init0 exists, I suggest it be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed the name to "_cam_init" for Jesse's review but forgot about the camdev physpkg. It's all changed over to the ccpp code now.

if (trim(cam_take_snapshot_before) == "rayleigh_friction_tend") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf, &
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
end if
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add:
call physics_ptend_init(ptend, state%psetcols, 'rayleigh friction', ls=.true., lu=.true., lv=.true.)

! Initialize ptend variables to zero
!REMOVECAM - no longer need these when CAM is retired and pcols no longer exists
ptend%u(:,:) = 0._r8
ptend%v(:,:) = 0._r8
ptend%s(:,:) = 0._r8
!REMOVECAM_END

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made these changes


subroutine rayleigh_friction_init()
subroutine rayleigh_friction_cam_init()
Copy link
Collaborator

Choose a reason for hiding this comment

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

My proposed changes have been made assuming the elimination of this routine.

Comment on lines 110 to 111
subroutine rayleigh_friction_cam_tend( &
ztodt ,state ,ptend )
Copy link
Collaborator

Choose a reason for hiding this comment

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

My proposed changes have been made assuming the elimination of this routine.

@Katetc Katetc requested a review from cacraigucar April 11, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants