Phase 1 of rk_stratiform CCPPization; CCPPize cldfrc
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
- Closes #1267
- Fixes #1274 for incorrect vertical dimension of
tphysbc_cmfmcin snapshots - Partial completion of https://github.com/ESCOMP/CAM/issues/1267; most code has been moved to atmospheric_physics.
Companion PR in atmospheric_physics: https://github.com/ESCOMP/atmospheric_physics/pull/219
Changes are expected to be B4B for CAM regression tests Roundoff changes to CAM4 diagnostics
Describe any changes made to build system: N/A
Describe any changes made to the namelist:
- build-namelist updated to add
rk_stratiform_tendsnapshot point
List any changes to the defaults for the boundary datasets: N/A
Describe any substantial timing or memory changes: N/A
Code reviewed by: TBD
List all files eliminated:
D src/physics/cam/cldwat.F90
D src/physics/cam/pkg_cldoptics.F90
- moved to atmospheric_physics: prognostic_cloud_water CCPPized scheme
- moved to atmospheric_physics: cloud_optical_properties to-be-ccppized library; dechunkized
List all files added and what they do: N/A
List all existing files that have been modified, and describe the changes:
M .gitmodules
M src/atmos_phys
- new atmos_phys external to include CCPPized schemes
M bld/configure
- include atmos_phys/schemes/rasch_kristjansson
M bld/build-namelist
M bld/namelist_files/namelist_definition.xml
M src/physics/cam/physpkg.F90
- add rk_stratiform_tend snapshot point
R068 src/physics/cam/rk_stratiform.F90 src/physics/cam/rk_stratiform_cam.F90
M src/control/runtime_opts.F90
M src/physics/cam/const_init.F90
- rename CAM interface to rk_stratiform_cam
- CCPPize most logic and moved into atmos_phys
M src/physics/cam/cloud_diagnostics.F90
- changes to support move of pkg_cldoptics to atmos_phys
M src/physics/cam/cloud_fraction.F90
- CCPPized cldfrc and moved to atmos_phys: compute_cloud_fraction
- shallow and deep convective cloud cover logic separated into CCPPized scheme in atmos_phys: convective_cloud_cover
M src/physics/cam/macrop_driver.F90
- changes to support CCPPization of cldfrc
M src/physics/cam/pkg_cld_sediment.F90
- CCPPized logic and moved into atmos_phys: cloud_particle_sedimendation
M src/physics/cam7/cam_snapshot.F90
M src/physics/cam/cam_snapshot.F90
- fix #1274 vertical dimension of tphysbc_cmfmc
There is an answer change to some (but not all) of the QPC4 regression tests introduced by reformulating the stratiform condensate repartitioning code.
Currently:
! Perform repartitioning of stratiform condensate.
! Corresponding heating tendency will be added later.
lq(:) = .FALSE.
lq(ixcldice) = .true.
lq(ixcldliq) = .true.
call physics_ptend_init( ptend_loc, state1%psetcols, 'cldwat-repartition', lq=lq )
totcw(:ncol,:pver) = state1%q(:ncol,:pver,ixcldice) + state1%q(:ncol,:pver,ixcldliq)
repartht(:ncol,:pver) = state1%q(:ncol,:pver,ixcldice)
ptend_loc%q(:ncol,:pver,ixcldice) = rdtime * ( totcw(:ncol,:pver)*fice(:ncol,:pver) - state1%q(:ncol,:pver,ixcldice) )
ptend_loc%q(:ncol,:pver,ixcldliq) = rdtime * ( totcw(:ncol,:pver)*(1.0_r8-fice(:ncol,:pver)) - state1%q(:ncol,:pver,ixcldliq) )
call outfld( 'REPARTICE', ptend_loc%q(:,:,ixcldice), pcols, lchnk )
call outfld( 'REPARTLIQ', ptend_loc%q(:,:,ixcldliq), pcols, lchnk )
call physics_ptend_sum( ptend_loc, ptend_all, ncol )
call physics_update( state1, ptend_loc, dtime )
! Determine repartition heating from change in cloud ice.
repartht(:ncol,:pver) = (latice/dtime) * ( state1%q(:ncol,:pver,ixcldice) - repartht(:ncol,:pver) )
This uses repartht (repartitioning heat [J kg-1 s-1]) as a temporary variable to store the pre-repartitioning q(cldice) (which is in [kg kg-1]), then after physics_update, repartht is computed to its final form.
As this is problematic to implement in a CCPPized scheme, the formulation is updated to the following in rk_stratiform_condensate_repartitioning_run:
totcw(:ncol,:) = cldice(:ncol,:) + cldliq(:ncol,:)
tend_cldice(:ncol,:) = 1.0_kind_phys / dtime * ( totcw(:ncol,:)*fice(:ncol,:) - cldice(:ncol,:) )
tend_cldliq(:ncol,:) = 1.0_kind_phys / dtime * ( totcw(:ncol,:)*(1.0_kind_phys-fice(:ncol,:)) - cldliq(:ncol,:) )
repartht(:ncol,:pver) = latice * tend_cldice(:ncol,:pver)
This leads to ~1e-17 differences in the final heating rate (ptend%s) in every time step. After about ~10 timesteps due to chaos other quantities will start to diverge due to the noise introduced in the heating rate over timesteps. Some, but not all of the QPC4 tests will capture this change and thus answer changes are introduced.
It can be verified that this is responsible for all the answer changes by reintroducing the original formulation of repartht after call rk_stratiform_condensate_repartitioning_run in rk_stratiform_cam.F90:
! call rk_stratiform_condensate_repartioning_run( & ...
call outfld( 'REPARTICE', ptend_loc%q(:,:,ixcldice), pcols, lchnk )
call outfld( 'REPARTLIQ', ptend_loc%q(:,:,ixcldliq), pcols, lchnk )
! add change to restore original formulation:
repartht(:ncol,:pver) = state1%q(:ncol,:pver,ixcldice)
! / change
call physics_ptend_sum( ptend_loc, ptend_all, ncol )
call physics_update( state1, ptend_loc, dtime )
! add change to restore original formulation:
repartht(:ncol,:pver) = (latice/dtime) * ( state1%q(:ncol,:pver,ixcldice) - repartht(:ncol,:pver) )
! / change
This will result in bit-for-bit in all history files and diagnostics and passing all regression tests, showing that it was the only cause of the answer changes.
Note: even if repartht temporary is changed to (latice/dtime) * state1%q(:ncol,:pver,ixcldice) to "keep the right units", then changing the post-repartitioning calculation to repartht(:ncol,:pver) = (latice/dtime) * state1%q(:ncol,:pver,ixcldice) - repartht(:ncol,:pver) will introduce answer changes.
Thus if there is no way around this I would just recommend changing it for a cleaner code.