Hi CCPP Physics developers,
Today we are merging/merged PR
https://github.com/ufs-community/ufs-weather-model/pull/527, which has two important updates for CCPP physics developers.
1. We switched from explicit array dimensions in the variable declaration section to assumed-size arrays. For example:
subroutine the_best_microphysics_scheme_ever_in_the_history_of_mankind(im,km,t,errmsg,errflg)
integer, intent(in) :: im, km
real, dimension(1:im,1:km), intent(inout) :: t
...
end subroutine the_best_microphysics_scheme_ever_in_the_history_of_mankind
becomes/became
subroutine the_best_microphysics_scheme_ever_in_the_history_of_mankind(im,km,t,errmsg,errflg)
integer, intent(in) :: im, km
real, dimension(:,:), intent(inout) :: t
...
end subroutine the_best_microphysics_scheme_ever_in_the_history_of_mankind
The benefit of this method is that it enables compiler array bounds checking, which the previous approach prevented.
It does not impact the runtime negatively, we confirmed that (and NCAR CISL in the past investigated this as well).
There is one situation where you have to be careful, and that is if the lower bound for your array is not 1 (because that is what Fortran assumes when you just use ':').
For example, four of the Noah-MP subsurface arrays are allocated in GFS_typedefs.F90 with a lower bound of Model%lsnow_lsm_lbound = -2:
allocate (Sfcprop%snicexy (IM, Model%lsnow_lsm_lbound:Model%lsnow_lsm_ubound))
In this case, CCPP schemes should use
real(kind_phys), intent(inout) :: snicexy(:,lsnow_lsm_lbound:)
so that at least you get bounds checks on the first dimension and on the extent of the second dimension
2. The order of arguments of a CCPP routine to match the order in the metadata file
Right now, this is not strictly required. However, when we will switch to the new CCPP code generator (
capgen) from the current one (
ccpp_prebuild) in the next few months, this will become a requirement. In PR
https://github.com/ufs-community/ufs-weather-model/pull/527, we made sure that all CCPP schemes comply with this rule.
We will try to do our best to catch non-compliant code changes in the future, but please help us by taking care of this when you develop or modify CCPP schemes. Thank you!
Ligia