Skip to content

Commit

Permalink
Merge pull request #6 from climbfuji/bugfix_b4b_identical_restarts
Browse files Browse the repository at this point in the history
Bugfix for bit-for-bit identical restart runs
  • Loading branch information
DomHeinzeller authored Jan 12, 2020
2 parents 4eaa560 + ff02358 commit 44f9e59
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
43 changes: 28 additions & 15 deletions physics/mp_thompson.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module mp_thompson
!! \section arg_table_mp_thompson_init Argument Table
!! \htmlinclude mp_thompson_init.html
!!
subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, &
subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, restart, &
imp_physics, imp_physics_thompson, &
spechum, qc, qr, qi, qs, qg, ni, nr, &
is_aerosol_aware, nc, nwfa2d, nifa2d, &
Expand All @@ -39,11 +39,12 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, &
implicit none

! Interface variables
integer, intent(in) :: ncol
integer, intent(in) :: nlev
real(kind_phys), intent(in) :: con_g, con_rd
integer, intent(in) :: imp_physics
integer, intent(in) :: imp_physics_thompson
integer, intent(in ) :: ncol
integer, intent(in ) :: nlev
real(kind_phys), intent(in ) :: con_g, con_rd
logical, intent(in ) :: restart
integer, intent(in ) :: imp_physics
integer, intent(in ) :: imp_physics_thompson
! Hydrometeors
real(kind_phys), intent(inout) :: spechum(:,:)
real(kind_phys), intent(inout) :: qc(:,:)
Expand All @@ -66,16 +67,16 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, &
real(kind_phys), intent(in ) :: phil(:,:)
real(kind_phys), intent(in ) :: area(:)
! Cloud effective radii
real(kind_phys), optional, intent( out) :: re_cloud(:,:)
real(kind_phys), optional, intent( out) :: re_ice(:,:)
real(kind_phys), optional, intent( out) :: re_snow(:,:)
real(kind_phys), optional, intent(inout) :: re_cloud(:,:)
real(kind_phys), optional, intent(inout) :: re_ice(:,:)
real(kind_phys), optional, intent(inout) :: re_snow(:,:)
! MPI information
integer, intent(in) :: mpicomm
integer, intent(in) :: mpirank
integer, intent(in) :: mpiroot
integer, intent(in ) :: mpicomm
integer, intent(in ) :: mpirank
integer, intent(in ) :: mpiroot
! Threading/blocking information
integer, intent(in) :: threads
integer, intent(in) :: blkno
integer, intent(in ) :: threads
integer, intent(in ) :: blkno
! CCPP error handling
character(len=*), intent( out) :: errmsg
integer, intent( out) :: errflg
Expand Down Expand Up @@ -174,6 +175,12 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, &
if (errflg /= 0) return
end if

! For restart runs, the init is done here
if (restart) then
is_initialized = .true.
return
end if

! Fix initial values of hydrometeors
where(spechum<0) spechum = 0.0
where(qc<0) qc = 0.0
Expand Down Expand Up @@ -361,7 +368,7 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, &
do k = 1, nlev
re_cloud(i,k) = 2.49E-6
re_ice(i,k) = 4.99E-6
re_snow(i,k) = 9.99E-6
re_snow(i,k) = 9.99E-6
end do
end do
do i = 1, ncol
Expand All @@ -376,6 +383,12 @@ subroutine mp_thompson_init(ncol, nlev, con_g, con_rd, &
re_snow(i,k) = MAX(9.99E-6, MIN(re_snow(i,k), 999.E-6))
end do
end do
! Convert to micron: required for bit-for-bit identical restarts;
! otherwise entering mp_thompson_init and converting mu to m and
! back (without updating re_*) introduces b4b differences.
re_cloud = 1.0E6*re_cloud
re_ice = 1.0E6*re_ice
re_snow = 1.0E6*re_snow
else if (.not.present(re_cloud) .and. .not.present(re_ice) .and. .not.present(re_snow)) then
! Do nothing
else
Expand Down
26 changes: 17 additions & 9 deletions physics/mp_thompson.meta
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
kind = kind_phys
intent = in
optional = F
[restart]
standard_name = flag_for_restart
long_name = flag for restart (warmstart) or coldstart
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[imp_physics]
standard_name = flag_for_microphysics_scheme
long_name = choice of microphysics scheme
Expand Down Expand Up @@ -214,30 +222,30 @@
optional = F
[re_cloud]
standard_name = effective_radius_of_stratiform_cloud_liquid_water_particle_in_um
long_name = eff. radius of cloud liquid water particle in micrometer (meter here)
units = m
long_name = eff. radius of cloud liquid water particle in micrometer
units = um
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = out
intent = inout
optional = T
[re_ice]
standard_name = effective_radius_of_stratiform_cloud_ice_particle_in_um
long_name = eff. radius of cloud ice water particle in micrometer (meter here)
units = m
long_name = eff. radius of cloud ice water particle in micrometer
units = um
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = out
intent = inout
optional = T
[re_snow]
standard_name = effective_radius_of_stratiform_cloud_snow_particle_in_um
long_name = effective radius of cloud snow particle in micrometer (meter here)
units = m
long_name = effective radius of cloud snow particle in micrometer
units = um
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = out
intent = inout
optional = T
[mpicomm]
standard_name = mpi_comm
Expand Down

0 comments on commit 44f9e59

Please sign in to comment.