-
Notifications
You must be signed in to change notification settings - Fork 155
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
base: cam_development
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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
There was a problem hiding this 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?
subroutine rayleigh_friction_cam_tend( & | ||
ztodt ,state ,ptend ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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)!
There was a problem hiding this 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/physics/cam/physpkg.F90
Outdated
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with appropriate subsetting
src/physics/cam7/physpkg.F90
Outdated
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/physics/cam7/physpkg.F90
Outdated
@@ -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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
subroutine rayleigh_friction_cam_tend( & | ||
ztodt ,state ,ptend ) |
There was a problem hiding this comment.
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.
I need to merge this one up too, but here's the PR for Rayleigh Friction to CCPP!
Fixes #1153