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

Dephy on trunk archer 2 #56

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d677350
#344 major commit including new fft solver, significant CASIM updates…
Aug 20, 2020
02205f3
#352: Correction of Lower BC options in global_config.
Sep 3, 2020
1ded51b
#351 Bug fix: Permit meaningful specification of rad_interval when l_…
Sep 3, 2020
51f46a5
#367 commit the changes relating to this ticket, since testing looks …
Jun 21, 2021
ae54c01
#368 merge bug fixes from the archer2 port onto the monc-main trunk. …
Jul 1, 2021
96f97ea
#365 merge development branch onto the trunk
Sep 23, 2021
f52aa1e
#376 merged collection of various bug fixes and model updates onto th…
Nov 29, 2021
8f672d1
#381 ARCHER2 support, bug fixes, and enhancements related to #369, #3…
Feb 17, 2022
09fdf7b
#391 commit casim component modifications so that MONC builds with CA…
Aug 19, 2022
5df3532
Porting changes from r9437 to make MONC compile on archer
Nov 1, 2023
24e2816
#408 for saracusworth - Remove unnecessary height arrays from CASIM i…
Aug 14, 2023
afdec9a
Adding existing tendencies to pw advection, so it does not need to be…
Oct 31, 2023
4497d4f
Changes to make functions available to DEPHY
Oct 31, 2023
626a6fc
Adding DEPHY code
Oct 31, 2023
a8e5e6d
Adding DEPHY to component registrations
Oct 31, 2023
ce5e54f
Make sure to add components with DEPHY as last component
Oct 31, 2023
8884368
DEPHY additions to global config
Oct 31, 2023
91862bc
Using local version of null string terminator
stevenleeds Oct 31, 2023
2436deb
Revert "#408 for saracusworth - Remove unnecessary height arrays from…
stevenleeds Oct 31, 2023
cda23a3
Fixing dephy_forcing naming in global config
stevenleeds Nov 1, 2023
c5cc2cd
Change to order of components (DEPHY)
stevenleeds Dec 1, 2023
15a4994
Adding utilities for archer2 and arc
stevenleeds Dec 1, 2023
aebde20
ARCHER compilation files
stevenleeds Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 8 additions & 12 deletions components/buoyancy/src/buoyancy.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ module buoyancy_mod
real(kind=DEFAULT_PRECISION), dimension(:), allocatable :: tend_pr_tot_w
logical :: l_tend_pr_tot_w

integer :: diagnostic_generation_frequency

public buoyancy_get_descriptor

contains
Expand Down Expand Up @@ -170,9 +168,6 @@ subroutine initialisation_callback(current_state)
allocate( tend_pr_tot_w(current_state%local_grid%size(Z_INDEX)) )
endif

! Save the sampling_frequency to force diagnostic calculation on select time steps
diagnostic_generation_frequency=options_get_integer(current_state%options_database, "sampling_frequency")

end subroutine initialisation_callback


Expand All @@ -197,6 +192,10 @@ subroutine timestep_callback(current_state)

integer :: k, n
integer :: current_x_index, current_y_index, target_x_index, target_y_index
logical :: calculate_diagnostics

calculate_diagnostics = current_state%diagnostic_sample_timestep &
.and. .not. current_state%halo_column

current_x_index=current_state%column_local_x
current_y_index=current_state%column_local_y
Expand All @@ -210,10 +209,8 @@ subroutine timestep_callback(current_state)
endif
endif ! zero totals

if (mod(current_state%timestep, diagnostic_generation_frequency) == 0 .and. .not. current_state%halo_column) then
call save_precomponent_tendencies(current_state, current_x_index, current_y_index, target_x_index, target_y_index)
end if

if (calculate_diagnostics) &
call save_precomponent_tendencies(current_state, current_x_index, current_y_index, target_x_index, target_y_index)

#ifdef W_ACTIVE
if (.not. current_state%passive_th .and. current_state%th%active) then
Expand Down Expand Up @@ -252,9 +249,8 @@ subroutine timestep_callback(current_state)
end if
#endif

if (mod(current_state%timestep, diagnostic_generation_frequency) == 0 .and. .not. current_state%halo_column) then
call compute_component_tendencies(current_state, current_x_index, current_y_index, target_x_index, target_y_index)
end if
if (calculate_diagnostics) &
call compute_component_tendencies(current_state, current_x_index, current_y_index, target_x_index, target_y_index)

end subroutine timestep_callback

Expand Down
111 changes: 95 additions & 16 deletions components/casim/src/casim.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module casim_mod
! casim modules...
use variable_precision, ONLY: wp
use initialize, only: mphys_init
use mphys_parameters, only: cloud_params
use mphys_switches, only: set_mphys_switches, &
l_warm, &
nq_l, nq_r, nq_i, nq_s, nq_g, &
Expand Down Expand Up @@ -74,7 +75,19 @@ module casim_mod
, l_pssub & ! sublimation of snow
, l_pgsub & ! sublimation of graupel
, l_pisub & ! sublimation of ice
, l_pimlt ! ice melting
, l_pimlt & ! ice melting
! New switches for sedimentation (these are sort-of temporary)
, l_gamma_online & ! when true use standard vn0.3.3 sed, when false use precalced gamma
, l_subseds_maxv & ! Use a CFL criteria based on max terminal velocity
! and sed_1M_2M
, l_sed_eulexp & ! switch for eulexp sed based on UM. Default is false
! so standard casim sed used
, cfl_vt_max & ! cfl limit for sedimentation (default = 1.0)
, l_kfsm & ! single moment based on wilson-ballard
, l_adjust_D0

use mphys_constants, only: fixed_cloud_number ! number/m**3, overrides mphys_constants value


use micro_main, only: shipway_microphysics
use generic_diagnostic_variables, ONLY: casdiags, allocate_diagnostic_space, &
Expand All @@ -93,7 +106,12 @@ module casim_mod
, nc(:,:,:), qr(:,:,:), nr(:,:,:), m3r(:,:,:),rho(:,:,:) &
, exner(:,:,:), w(:,:,:), tke(:,:,:) &
, qi(:,:,:), ni(:,:,:), qs(:,:,:), ns(:,:,:), m3s(:,:,:) &
, qg(:,:,:), ng(:,:,:), m3g(:,:,:)
, qg(:,:,:), ng(:,:,:), m3g(:,:,:)
! declare a fraction for each hydrometeor category. All fractions are
! initialised set to 1 if cloud is present, since MONC does not include
! subgrid cloud fraction scheme (yet!)
REAL(wp), allocatable :: cfliq(:,:,:), cfice(:,:,:) &
, cfsnow(:,:,:), cfrain(:,:,:), cfgr(:,:,:)

REAL(wp), allocatable :: AccumSolMass(:,:,:), AccumSolNumber(:,:,:) ! Accumulation mode aerosol
REAL(wp), allocatable :: ActiveSolLiquid(:,:,:) ! Activated aerosol
Expand Down Expand Up @@ -138,6 +156,8 @@ module casim_mod
REAL(wp), allocatable :: dActiveInsolNumber(:,:,:) ! Activated insoluble number (if we need a tracer)

REAL(wp), allocatable :: surface_precip(:,:)
REAL(wp), allocatable :: surface_cloudsed(:,:)
REAL(wp), allocatable :: surface_rainsed(:,:)

INTEGER :: ils,ile, jls,jle, kls,kle, &
its,ite, jts,jte, kts,kte
Expand Down Expand Up @@ -187,7 +207,7 @@ type(component_descriptor_type) function casim_get_descriptor()
casim_get_descriptor%field_value_retrieval=>field_value_retrieval_callback
casim_get_descriptor%field_information_retrieval=>field_information_retrieval_callback

allocate(casim_get_descriptor%published_fields(27))
allocate(casim_get_descriptor%published_fields(29))

casim_get_descriptor%published_fields(1)="surface_precip"
casim_get_descriptor%published_fields(2)="homogeneous_freezing_rate"
Expand Down Expand Up @@ -216,6 +236,8 @@ type(component_descriptor_type) function casim_get_descriptor()
casim_get_descriptor%published_fields(25)="graup_sed_rate"
casim_get_descriptor%published_fields(26)="cloud_sed_rate"
casim_get_descriptor%published_fields(27)="condensation_rate"
casim_get_descriptor%published_fields(28)="surface_cloudsed"
casim_get_descriptor%published_fields(29)="surface_rainsed"

end function casim_get_descriptor

Expand Down Expand Up @@ -277,6 +299,11 @@ subroutine initialisation_callback(current_state)
allocate(qg(kte,1,1))
allocate(ng(kte,1,1))
allocate(m3g(kte,1,1))
allocate(cfliq(kte,1,1))
allocate(cfice(kte,1,1))
allocate(cfsnow(kte,1,1))
allocate(cfrain(kte,1,1))
allocate(cfgr(kte,1,1))

allocate(AccumSolMass(kte,1,1))
allocate(AccumSolNumber(kte,1,1))
Expand Down Expand Up @@ -380,12 +407,27 @@ subroutine initialisation_callback(current_state)
end if

! Number
if (l_2mc)inl = get_q_index(standard_q_names%CLOUD_LIQUID_NUMBER, 'casim')
if (l_2mr)inr = get_q_index(standard_q_names%RAIN_NUMBER, 'casim')
if (l_2mc) then
inl = get_q_index(standard_q_names%CLOUD_LIQUID_NUMBER, 'casim')
current_state%liquid_water_nc_index=inl
endif
if (l_2mr) then
inr = get_q_index(standard_q_names%RAIN_NUMBER, 'casim')
current_state%rain_water_nc_index = inr
endif
if (.not. l_warm)then
if (l_2mi)ini = get_q_index(standard_q_names%ICE_NUMBER, 'casim')
if (l_2ms)ins = get_q_index(standard_q_names%SNOW_NUMBER, 'casim')
if (l_2mg)ing = get_q_index(standard_q_names%GRAUPEL_NUMBER, 'casim')
if (l_2mi) then
ini = get_q_index(standard_q_names%ICE_NUMBER, 'casim')
current_state%ice_water_nc_index=ini
endif
if (l_2ms) then
ins = get_q_index(standard_q_names%SNOW_NUMBER, 'casim')
current_state%snow_water_nc_index=ins
endif
if (l_2mg) then
ing = get_q_index(standard_q_names%GRAUPEL_NUMBER, 'casim')
current_state%graupel_water_nc_index = ing
endif
end if

! Third moments
Expand Down Expand Up @@ -440,6 +482,7 @@ subroutine initialisation_callback(current_state)
if ( l_psedl ) then
casdiags % l_psedl = .TRUE.
casdiags % l_surface_rain = .TRUE.
casdiags % l_surface_cloud = .TRUE.
casdiags % l_precip = .TRUE.
endif
if ( l_praut ) casdiags % l_praut = .TRUE.
Expand Down Expand Up @@ -492,6 +535,8 @@ subroutine initialisation_callback(current_state)
CALL allocate_diagnostic_space(its, ite, jts, jte, kts, kte)
! this is no longer needed since can use cas_monc_dgs structure but keep for now
allocate(surface_precip(y_size_local, x_size_local))
allocate(surface_cloudsed(y_size_local, x_size_local))
allocate(surface_rainsed(y_size_local, x_size_local))
! allocate diagnostic space for MONC fields to export to IO server
call allocate_casim_monc_dgs_space(current_state, casdiags)

Expand All @@ -515,7 +560,11 @@ subroutine timestep_callback(current_state)
! pcond_tot(:)= 0.0_DEFAULT_PRECISION
!endif

if (current_state%halo_column .or. current_state%timestep < 2) return

! No need to do casim calculations in the halos or on the first timestep
! unless this is a reconfiguration run
if (current_state%halo_column .or. &
(current_state%timestep < 2 .and. (.not. current_state%reconfig_run)) ) return

if (current_state%field_stepping == FORWARD_STEPPING)then
call log_master_log(LOG_ERROR, 'Currently, CASIM assumes CENTERED_STEPPING')
Expand Down Expand Up @@ -576,16 +625,24 @@ subroutine timestep_callback(current_state)
qv(:,1,1) = current_state%zq(iqx)%data(:,jcol,icol)
dqv(:,1,1) = current_state%sq(iqx)%data(:,jcol,icol)

cfliq(:,1,1) = 1.0_wp
cfice(:,1,1) = 1.0_wp
cfsnow(:,1,1) = 1.0_wp
cfrain(:,1,1) = 1.0_wp
cfgr(:,1,1) = 1.0_wp

! Warm microphysical fields
IF (nq_l > 0)then
iqx = iql
qc(:,1,1) = current_state%zq(iqx)%data(:,jcol,icol)
dqc(:,1,1) = current_state%sq(iqx)%data(:,jcol,icol)
cfliq(:,1,1) = 1.0
end IF
IF (nq_r > 0)then
iqx = iqr
qr(:,1,1) = current_state%zq(iqx)%data(:,jcol,icol)
dqr(:,1,1) = current_state%sq(iqx)%data(:,jcol,icol)
cfrain(:,1,1) = 1.0
end IF
IF (nq_l > 1)then
iqx = inl
Expand All @@ -608,16 +665,19 @@ subroutine timestep_callback(current_state)
iqx = iqi
qi(:,1,1) = current_state%zq(iqx)%data(:,jcol,icol)
dqi(:,1,1) = current_state%sq(iqx)%data(:,jcol,icol)
cfice(:,1,1) = 1.0
end IF
IF (nq_s > 0)then
iqx = iqs
qs(:,1,1) = current_state%zq(iqx)%data(:,jcol,icol)
dqs(:,1,1) = current_state%sq(iqx)%data(:,jcol,icol)
cfsnow(:,1,1) = 1.0
end IF
IF (nq_g > 0)then
iqx = iqg
qg(:,1,1) = current_state%zq(iqx)%data(:,jcol,icol)
dqg(:,1,1) = current_state%sq(iqx)%data(:,jcol,icol)
cfgr(:,1,1) = 1.0
end IF
IF (nq_i > 1)then
iqx = ini
Expand Down Expand Up @@ -712,7 +772,7 @@ subroutine timestep_callback(current_state)
pressure, rho, &
w, tke, &
z_half, z_centre, &
dz, &
dz, cfliq, cfice, cfsnow, cfrain, cfgr, &
! in/out
dqv, dqc, dqr, dnc, dnr, dm3r, &
dqi, dqs, dqg, dni, dns, dng, dm3s, dm3g, &
Expand All @@ -731,9 +791,7 @@ subroutine timestep_callback(current_state)
dActiveSolNumber, &
dActiveInsolNumber, &
ils, ile, &
jls, jle, &
kls, kle, &
l_tendency=.TRUE. &
jls, jle &
)

! write back the tendencies
Expand Down Expand Up @@ -838,9 +896,14 @@ subroutine timestep_callback(current_state)
! and surface
! snow rate (precip_s), which is the sum of ice, snow and graupel (See micromain.F90 in casim for
! calculation).
if (l_warm) then
if (l_warm .or. .not. casdiags % l_surface_snow ) then
surface_precip(target_y_index,target_x_index) = &
casdiags % SurfaceRainR(1,1)
surface_cloudsed(target_y_index,target_x_index) = &
casdiags % SurfaceCloudR(1,1)
surface_rainsed(target_y_index,target_x_index) = &
casdiags % SurfaceRainR(1,1) - casdiags % SurfaceCloudR(1,1)

else
surface_precip(target_y_index,target_x_index) = &
casdiags % SurfaceRainR(1,1) + casdiags % SurfaceSnowR(1,1)
Expand Down Expand Up @@ -877,7 +940,7 @@ subroutine read_configuration(current_state)
sp2 = options_get_real(current_state%options_database, 'sp2')
sp3 = options_get_real(current_state%options_database, 'sp3')
max_mu = options_get_real(current_state%options_database, 'max_mu')
fix_mu = options_get_real(current_state%options_database, 'fix_mu')
cloud_params%fix_mu = options_get_real(current_state%options_database, 'fix_mu')

l_aaut = options_get_logical(current_state%options_database, 'l_aaut')
l_aacc = options_get_logical(current_state%options_database, 'l_aacc')
Expand Down Expand Up @@ -947,6 +1010,13 @@ subroutine read_configuration(current_state)
l_pgsub = options_get_logical(current_state%options_database, 'l_pgsub')
l_pisub = options_get_logical(current_state%options_database, 'l_pisub')
l_pimlt = options_get_logical(current_state%options_database, 'l_pimlt')
l_gamma_online = options_get_logical(current_state%options_database, 'l_gamma_online')
l_subseds_maxv = options_get_logical(current_state%options_database, 'l_subseds_maxv')
l_sed_eulexp = options_get_logical(current_state%options_database, 'l_sed_eulexp')
cfl_vt_max = options_get_real(current_state%options_database, 'cfl_vt_max')
l_kfsm = options_get_logical(current_state%options_database, 'l_kfsm')
l_adjust_D0 = options_get_logical(current_state%options_database, 'l_adjust_D0')
fixed_cloud_number = options_get_real(current_state%options_database, 'fixed_cloud_number')

end subroutine read_configuration

Expand All @@ -957,7 +1027,8 @@ subroutine field_information_retrieval_callback(current_state, name, field_infor

field_information%field_type=COMPONENT_ARRAY_FIELD_TYPE
field_information%data_type=COMPONENT_DOUBLE_DATA_TYPE
if (name .eq. "surface_precip") then
if (name .eq. "surface_precip" .or. name .eq. "surface_cloudsed" .or. &
name .eq. "surface_rainsed") then
field_information%number_dimensions=2
field_information%dimension_sizes(1)=current_state%local_grid%size(Y_INDEX)
field_information%dimension_sizes(2)=current_state%local_grid%size(X_INDEX)
Expand Down Expand Up @@ -990,6 +1061,14 @@ subroutine field_value_retrieval_callback(current_state, name, field_value)
allocate(field_value%real_2d_array(current_state%local_grid%size(Y_INDEX), &
current_state%local_grid%size(X_INDEX)))
field_value%real_2d_array(:,:)= surface_precip(:,:)
else if (name .eq. "surface_cloudsed") then
allocate(field_value%real_2d_array(current_state%local_grid%size(Y_INDEX), &
current_state%local_grid%size(X_INDEX)))
field_value%real_2d_array(:,:)= surface_cloudsed(:,:)
else if (name .eq. "surface_rainsed") then
allocate(field_value%real_2d_array(current_state%local_grid%size(Y_INDEX), &
current_state%local_grid%size(X_INDEX)))
field_value%real_2d_array(:,:)= surface_rainsed(:,:)
else if (name .eq. "condensation_rate") then
allocate(field_value%real_3d_array(current_state%local_grid%size(Z_INDEX), &
current_state%local_grid%size(Y_INDEX), &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module casim_monc_dgs_space
!--------------------------------
! Surface Precipitation rates
REAL, ALLOCATABLE :: precip(:,:)
REAL, ALLOCATABLE :: SurfaceCloudR(:,:)
REAL, ALLOCATABLE :: SurfaceRainR(:,:)
REAL, ALLOCATABLE :: SurfaceSnowR(:,:)
REAL, ALLOCATABLE :: SurfaceGraupR(:,:)
Expand Down Expand Up @@ -98,6 +99,11 @@ subroutine allocate_casim_monc_dgs_space(current_state, casdiags)
casim_monc_dgs % precip(:,:) = 0.0_DEFAULT_PRECISION
endif

if ( casdiags % l_surface_cloud ) then
allocate ( casim_monc_dgs % SurfaceCloudR(y_size_local, x_size_local) )
casim_monc_dgs % SurfaceCloudR(:, :) = 0.0_DEFAULT_PRECISION
endif

if ( casdiags % l_surface_rain ) then
allocate ( casim_monc_dgs % SurfaceRainR(y_size_local, x_size_local) )
casim_monc_dgs % SurfaceRainR(:, :) = 0.0_DEFAULT_PRECISION
Expand Down Expand Up @@ -314,6 +320,10 @@ subroutine populate_casim_monc_dg(current_state, casdiags )
casim_monc_dgs % SurfaceRainR(target_y_index,target_x_index) = &
casdiags % SurfaceRainR(1,1)

if ( casdiags % l_surface_cloud ) &
casim_monc_dgs % SurfaceCloudR(target_y_index,target_x_index) = &
casdiags % SurfaceCloudR(1,1)

if ( casdiags % l_pcond ) &
casim_monc_dgs % pcond(:,target_y_index,target_x_index) = &
casdiags % pcond(1,1,:)
Expand Down Expand Up @@ -354,9 +364,12 @@ subroutine populate_casim_monc_dg(current_state, casdiags )
casdiags % dqr(1,1,:)

if (.not. l_warm) then
if ( casdiags % l_precip ) &
casim_monc_dgs % precip(target_y_index,target_x_index) = &
if ( casdiags % l_precip .and. casdiags % l_surface_snow ) &
casim_monc_dgs % precip(target_y_index,target_x_index) = &
casdiags % SurfaceRainR(1,1) + casdiags % SurfaceSnowR(1,1)
if ( casdiags % l_precip .and. .not. casdiags % l_surface_snow ) &
casim_monc_dgs % precip(target_y_index,target_x_index) = &
casdiags % SurfaceRainR(1,1)
if ( casdiags % l_surface_snow ) &
casim_monc_dgs % SurfaceSnowR(target_y_index,target_x_index) = &
casdiags % SurfaceSnowR(1,1)
Expand All @@ -365,7 +378,7 @@ subroutine populate_casim_monc_dg(current_state, casdiags )
casdiags % SurfaceGraupR(1,1)
if ( casdiags % l_phomc ) &
casim_monc_dgs % phomc(:,target_y_index,target_x_index) = &
casdiags % psedr(1,1,:)
casdiags % phomc(1,1,:)
if ( casdiags % l_pinuc ) &
casim_monc_dgs % pinuc(:,target_y_index,target_x_index) = &
casdiags % pinuc(1,1,:)
Expand Down
Loading