@@ -264,7 +264,6 @@ struct RRTMGPModel{R, I, B, L, P, LWS, SWS, AS, V}
264
264
radiation_mode:: R
265
265
interpolation:: I
266
266
bottom_extrapolation:: B
267
- implied_values:: Symbol
268
267
lookups:: L
269
268
params:: P
270
269
lw_solver:: LWS
@@ -303,11 +302,8 @@ After constructing an `RRTMGPModel`, use it as follows:
303
302
- use the values of any fluxes of interest; e.g.,
304
303
`field2array(face_flux_field) .= model.face_flux`
305
304
306
- To construct the `RRTMGPModel`, one must specify `center_pressure` and
307
- `center_temperature`, or `face_pressure` and `face_temperature`, or all four
308
- values. If only the values at cell centers are specified, the values at cell
309
- faces are "implied values". Likewise, if only the values at faces are specified,
310
- the values at centers are "implied values".
305
+ The `RRTMGPModel` assumes that pressure and temperature live on cell centers,
306
+ and internally interpolates data to cell faces when needed.
311
307
312
308
Every keyword argument that corresponds to an array of cell center or cell face
313
309
values can be specified as a scalar (corresponding to a constant value
@@ -408,7 +404,7 @@ array.
408
404
- `center_z`: z-coordinate in m at cell centers
409
405
- `face_z`: z-coordinate in m at cell faces
410
406
"""
411
- function RRTMGPModel (
407
+ RRTMGPModel (
412
408
params:: RRTMGP.Parameters.ARP ,
413
409
context;
414
410
ncol:: Int ,
@@ -418,6 +414,29 @@ function RRTMGPModel(
418
414
bottom_extrapolation:: AbstractBottomExtrapolation = SameAsInterpolation (),
419
415
use_global_means_for_well_mixed_gases:: Bool = false ,
420
416
kwargs... ,
417
+ ) = _RRTMGPModel (
418
+ params,
419
+ context,
420
+ radiation_mode;
421
+ ncol,
422
+ domain_nlay,
423
+ interpolation,
424
+ bottom_extrapolation,
425
+ use_global_means_for_well_mixed_gases,
426
+ kwargs... ,
427
+ )
428
+
429
+ # TODO : make this the new interface for the next breaking release.
430
+ function _RRTMGPModel (
431
+ params:: RRTMGP.Parameters.ARP ,
432
+ context,
433
+ radiation_mode:: AbstractRRTMGPMode = ClearSkyRadiation ();
434
+ ncol:: Int ,
435
+ domain_nlay:: Int ,
436
+ interpolation:: AbstractInterpolation = NoInterpolation (),
437
+ bottom_extrapolation:: AbstractBottomExtrapolation = SameAsInterpolation (),
438
+ use_global_means_for_well_mixed_gases:: Bool = false ,
439
+ kwargs... ,
421
440
)
422
441
device = ClimaComms. device (context)
423
442
DA = ClimaComms. array_type (device)
@@ -430,49 +449,9 @@ function RRTMGPModel(
430
449
GrayRadiation"
431
450
end
432
451
433
- if (
434
- :center_pressure in keys (dict) &&
435
- :center_temperature in keys (dict) &&
436
- :face_pressure in keys (dict) &&
437
- :face_temperature in keys (dict)
438
- )
439
- if ! (interpolation isa NoInterpolation)
440
- @warn " interpolation is ignored if both center and face pressures/\
441
- temperatures are specified"
442
- end
443
- implied_values = :none
444
- elseif (
445
- :center_pressure in keys (dict) &&
446
- :center_temperature in keys (dict) &&
447
- ! (:face_pressure in keys (dict)) &&
448
- ! (:face_temperature in keys (dict))
449
- )
450
- if interpolation isa NoInterpolation
451
- error (" interpolation cannot be NoInterpolation if only center \
452
- pressures/temperatures are specified" )
453
- end
454
- implied_values = :face
455
- elseif (
456
- ! (:center_pressure in keys (dict)) &&
457
- ! (:center_temperature in keys (dict)) &&
458
- :face_pressure in keys (dict) &&
459
- :face_temperature in keys (dict)
460
- )
461
- if interpolation isa NoInterpolation
462
- error (" interpolation cannot be NoInterpolation if only face \
463
- pressures/temperatures are specified" )
464
- end
465
- implied_values = :center
466
- else
467
- error (" please specify either center_pressure and center_temperature, \
468
- or face_pressure and face_temperature, or all four values" )
469
- end
470
-
471
- if implied_values != :face
472
- if ! (bottom_extrapolation isa SameAsInterpolation)
473
- @warn " bottom_extrapolation is ignored if face_pressure and \
474
- face_temperature are specified"
475
- end
452
+ if interpolation isa NoInterpolation
453
+ error (" interpolation cannot be NoInterpolation if only center \
454
+ pressures/temperatures are specified" )
476
455
end
477
456
478
457
lookups = NamedTuple ()
@@ -652,20 +631,14 @@ function RRTMGPModel(
652
631
653
632
p_lev = DA {FT} (undef, nlay + 1 , ncol)
654
633
t_lev = DA {FT} (undef, nlay + 1 , ncol)
655
- if implied_values != :face
656
- set_and_save! (p_lev, " face_pressure" , t... , dict)
657
- set_and_save! (t_lev, " face_temperature" , t... , dict)
658
- end
659
634
t_sfc = DA {FT} (undef, ncol)
660
635
set_and_save! (t_sfc, " surface_temperature" , t... , dict)
661
636
662
637
if radiation_mode isa GrayRadiation
663
638
p_lay = DA {FT} (undef, nlay, ncol)
664
639
t_lay = DA {FT} (undef, nlay, ncol)
665
- if implied_values != :center
666
- set_and_save! (p_lay, " center_pressure" , t... , dict)
667
- set_and_save! (t_lay, " center_temperature" , t... , dict)
668
- end
640
+ set_and_save! (p_lay, " center_pressure" , t... , dict)
641
+ set_and_save! (t_lay, " center_temperature" , t... , dict)
669
642
670
643
z_lev = DA {FT} (undef, nlay + 1 , ncol) # TODO : z_lev required but unused
671
644
@@ -696,11 +669,9 @@ function RRTMGPModel(
696
669
p_lay = view (layerdata, 2 , :, :)
697
670
t_lay = view (layerdata, 3 , :, :)
698
671
rh_lay = view (layerdata, 4 , :, :)
699
- if implied_values != :center
700
- set_and_save! (p_lay, " center_pressure" , t... , dict)
701
- set_and_save! (t_lay, " center_temperature" , t... , dict)
702
- set_and_save! (rh_lay, " center_relative_humidity" , t... , dict)
703
- end
672
+ set_and_save! (p_lay, " center_pressure" , t... , dict)
673
+ set_and_save! (t_lay, " center_temperature" , t... , dict)
674
+ set_and_save! (rh_lay, " center_relative_humidity" , t... , dict)
704
675
vmr_str = " volume_mixing_ratio_"
705
676
gas_names = filter (
706
677
gas_name ->
@@ -899,7 +870,6 @@ function RRTMGPModel(
899
870
radiation_mode,
900
871
interpolation,
901
872
bottom_extrapolation,
902
- implied_values,
903
873
lookups,
904
874
params,
905
875
lw_solver,
@@ -988,7 +958,7 @@ NVTX.@annotate function update_fluxes!(model, seedval)
988
958
)
989
959
radiation_mode. reset_rng_seed && Random. seed! (seedval)
990
960
end
991
- model . implied_values != :none && update_implied_values! (model)
961
+ update_implied_values! (model)
992
962
model. radiation_mode. add_isothermal_boundary_layer &&
993
963
update_boundary_layer! (model)
994
964
clip_values! (model)
@@ -1015,25 +985,18 @@ function update_implied_values!(model)
1015
985
z_lay = parent (model. center_z)
1016
986
z_lev = parent (model. face_z)
1017
987
end
1018
- if model. implied_values == :center
1019
- mode = model. interpolation
1020
- outs = requires_z (mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
1021
- ins = requires_z (mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
1022
- update_views (interp!, mode, outs, ins, (), 1 : nlay, 1 : nlay, 2 : (nlay + 1 ))
1023
- else # model.implied_values == :face
1024
- mode = model. interpolation
1025
- outs = requires_z (mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
1026
- ins = requires_z (mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
1027
- update_views (interp!, mode, outs, ins, (), 2 : nlay, 1 : (nlay - 1 ), 2 : nlay)
1028
- others = (t_sfc, model. params)
1029
- update_views (extrap!, mode, outs, ins, others, nlay + 1 , nlay, nlay - 1 )
1030
- mode =
1031
- model. bottom_extrapolation isa SameAsInterpolation ?
1032
- model. interpolation : model. bottom_extrapolation
1033
- outs = requires_z (mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
1034
- ins = requires_z (mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
1035
- update_views (extrap!, mode, outs, ins, others, 1 , 1 , 2 )
1036
- end
988
+ mode = model. interpolation
989
+ outs = requires_z (mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
990
+ ins = requires_z (mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
991
+ update_views (interp!, mode, outs, ins, (), 2 : nlay, 1 : (nlay - 1 ), 2 : nlay)
992
+ others = (t_sfc, model. params)
993
+ update_views (extrap!, mode, outs, ins, others, nlay + 1 , nlay, nlay - 1 )
994
+ mode =
995
+ model. bottom_extrapolation isa SameAsInterpolation ?
996
+ model. interpolation : model. bottom_extrapolation
997
+ outs = requires_z (mode) ? (p_lev, t_lev, z_lev) : (p_lev, t_lev)
998
+ ins = requires_z (mode) ? (p_lay, t_lay, z_lay) : (p_lay, t_lay)
999
+ update_views (extrap!, mode, outs, ins, others, 1 , 1 , 2 )
1037
1000
end
1038
1001
1039
1002
update_views (f, mode, outs, ins, others, out_range, in_range1, in_range2) = f (
0 commit comments