← Back to Documentation Home
CCPP SciDoc v8.0.0  v8.0.0
Common Community Physics Package Developed at DTC
 
Loading...
Searching...
No Matches
rrtmgp_lw_cloud_optics.F90
1
3
10 use mo_rte_kind, only: wl, wp
11 use mo_cloud_optics_rrtmgp, only: ty_cloud_optics => ty_cloud_optics_rrtmgp
12 use rrtmgp_lw_gas_optics, only: lw_gas_props
13 use radiation_tools, only: check_error_msg
14 use netcdf
15 use mpi_f08
16
17 implicit none
18
19 type(ty_cloud_optics) :: lw_cloud_props
20 integer :: &
21 nrghice_fromfileLW, nBandLW, nSize_liqLW, nSize_iceLW, nSizeRegLW, &
22 nCoeff_extLW, nCoeff_ssa_gLW, nBoundLW, npairsLW
23 real(wp), dimension(:,:), allocatable :: &
24 lut_extliqlw, & !< LUT shortwave liquid extinction coefficient
25 lut_ssaliqlw, & !< LUT shortwave liquid single scattering albedo
26 lut_asyliqlw, & !< LUT shortwave liquid asymmetry parameter
27 band_limscldlw
28 real(wp), dimension(:,:,:), allocatable :: &
29 lut_exticelw, & !< LUT shortwave ice extinction coefficient
30 lut_ssaicelw, & !< LUT shortwave ice single scattering albedo
31 lut_asyicelw
32
33 ! Parameters used for rain and snow(+groupel) RRTMGP cloud-optics
34 real(wp), parameter :: &
35 absrain = 0.33e-3, &
36 abssnow0 = 1.5, &
37 abssnow1 = 2.34e-3
38 real(wp) :: &
39 radliq_lwrlw, & !< Liquid particle size lower bound for LUT interpolation
40 radliq_uprlw, & !< Liquid particle size upper bound for LUT interpolation
41 radice_lwrlw, & !< Ice particle size upper bound for LUT interpolation
42 radice_uprlw
43
44contains
45
46 ! ######################################################################################
47 ! SUBROUTINE rrtmgp_lw_cloud_optics_init()
48 ! ######################################################################################
50 subroutine rrtmgp_lw_cloud_optics_init(rrtmgp_root_dir, rrtmgp_lw_file_clouds, &
51 nrghice, mpicomm, mpirank, mpiroot, is_initialized, errmsg, errflg)
52
53 ! Inputs
54 character(len=128),intent(in) :: &
55 rrtmgp_root_dir, & !< RTE-RRTMGP root directory
56 rrtmgp_lw_file_clouds
57
58 integer, intent(inout) :: &
59 nrghice
60 type(mpi_comm), intent(in) :: &
61 mpicomm
62 integer, intent(in) :: &
63 mpirank, & !< Current MPI rank
64 mpiroot
65
66 ! Outputs
67 logical, intent(inout) :: &
68 is_initialized
69 character(len=*), intent( out) :: &
70 errmsg
71 integer, intent( out) :: &
72 errflg
73
74 ! Local variables
75 integer :: dimID,varID,status,ncid,mpierr
76 character(len=264) :: lw_cloud_props_file
77
78 ! Initialize
79 errmsg = ''
80 errflg = 0
81
82 if (is_initialized) return
83
84 ! Filenames are set in the physics_nml
85 lw_cloud_props_file = trim(rrtmgp_root_dir)//trim(rrtmgp_lw_file_clouds)
86
87 ! #######################################################################################
88 !
89 ! Read dimensions for longwave cloud-optics fields...
90 ! (ONLY master processor(0), if MPI enabled)
91 !
92 ! #######################################################################################
93 if (mpirank .eq. mpiroot) then
94 write (*,*) 'Reading RRTMGP longwave cloud-optics metadata ... '
95
96 ! Open file
97 status = nf90_open(trim(lw_cloud_props_file), nf90_nowrite, ncid)
98
99 ! Read dimensions
100 status = nf90_inq_dimid(ncid, 'nband', dimid)
101 status = nf90_inquire_dimension(ncid, dimid, len=nbandlw)
102 status = nf90_inq_dimid(ncid, 'nrghice', dimid)
103 status = nf90_inquire_dimension(ncid, dimid, len=nrghice_fromfilelw)
104 status = nf90_inq_dimid(ncid, 'nsize_liq', dimid)
105 status = nf90_inquire_dimension(ncid, dimid, len=nsize_liqlw)
106 status = nf90_inq_dimid(ncid, 'nsize_ice', dimid)
107 status = nf90_inquire_dimension(ncid, dimid, len=nsize_icelw)
108 status = nf90_inq_dimid(ncid, 'nsizereg', dimid)
109 status = nf90_inquire_dimension(ncid, dimid, len=nsizereglw)
110 status = nf90_inq_dimid(ncid, 'ncoeff_ext', dimid)
111 status = nf90_inquire_dimension(ncid, dimid, len=ncoeff_extlw)
112 status = nf90_inq_dimid(ncid, 'ncoeff_ssa_g', dimid)
113 status = nf90_inquire_dimension(ncid, dimid, len=ncoeff_ssa_glw)
114 status = nf90_inq_dimid(ncid, 'nbound', dimid)
115 status = nf90_inquire_dimension(ncid, dimid, len=nboundlw)
116 status = nf90_inq_dimid(ncid, 'pair', dimid)
117 status = nf90_inquire_dimension(ncid, dimid, len=npairslw)
118
119 endif ! On master processor
120
121 ! Other processors waiting...
122 call mpi_barrier(mpicomm, mpierr)
123
124 ! #######################################################################################
125 !
126 ! Broadcast dimensions...
127 ! (ALL processors)
128 !
129 ! #######################################################################################
130 call mpi_bcast(nbandlw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
131 call mpi_bcast(nsize_liqlw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
132 call mpi_bcast(nsize_icelw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
133 call mpi_bcast(nsizereglw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
134 call mpi_bcast(ncoeff_extlw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
135 call mpi_bcast(ncoeff_ssa_glw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
136 call mpi_bcast(nboundlw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
137 call mpi_bcast(npairslw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
138
139 ! Has the number of ice-roughnesses to use been provided from the namelist?
140 ! If so, override nrghice from cloud-optics file
141 if (nrghice .ne. 0) nrghice_fromfilelw = nrghice
142 call mpi_bcast(nrghice_fromfilelw, 1, mpi_integer, mpiroot, mpicomm, mpierr)
143
144 ! #######################################################################################
145 !
146 ! Allocate space for arrays...
147 ! (ALL processors)
148 !
149 ! #######################################################################################
150 if (.not. allocated(lut_extliqlw)) allocate(lut_extliqlw(nsize_liqlw, nbandlw))
151 if (.not. allocated(lut_ssaliqlw)) allocate(lut_ssaliqlw(nsize_liqlw, nbandlw))
152 if (.not. allocated(lut_asyliqlw)) allocate(lut_asyliqlw(nsize_liqlw, nbandlw))
153 if (.not. allocated(lut_exticelw)) allocate(lut_exticelw(nsize_icelw, nbandlw, nrghice_fromfilelw))
154 if (.not. allocated(lut_ssaicelw)) allocate(lut_ssaicelw(nsize_icelw, nbandlw, nrghice_fromfilelw))
155 if (.not. allocated(lut_asyicelw)) allocate(lut_asyicelw(nsize_icelw, nbandlw, nrghice_fromfilelw))
156 if (.not. allocated(band_limscldlw)) allocate(band_limscldlw(2,nbandlw))
157
158 ! #######################################################################################
159 !
160 ! Read in data ...
161 ! (ONLY master processor(0), if MPI enabled)
162 !
163 ! #######################################################################################
164 if (mpirank .eq. mpiroot) then
165 ! Read in fields from file
166 write (*,*) 'Reading RRTMGP longwave cloud data (LUT) ... '
167 status = nf90_inq_varid(ncid,'radliq_lwr',varid)
168 status = nf90_get_var(ncid,varid,radliq_lwrlw)
169 status = nf90_inq_varid(ncid,'radliq_upr',varid)
170 status = nf90_get_var(ncid,varid,radliq_uprlw)
171 status = nf90_inq_varid(ncid,'radice_lwr',varid)
172 status = nf90_get_var(ncid,varid,radice_lwrlw)
173 status = nf90_inq_varid(ncid,'radice_upr',varid)
174 status = nf90_get_var(ncid,varid,radice_uprlw)
175 status = nf90_inq_varid(ncid,'lut_extliq',varid)
176 status = nf90_get_var(ncid,varid,lut_extliqlw)
177 status = nf90_inq_varid(ncid,'lut_ssaliq',varid)
178 status = nf90_get_var(ncid,varid,lut_ssaliqlw)
179 status = nf90_inq_varid(ncid,'lut_asyliq',varid)
180 status = nf90_get_var(ncid,varid,lut_asyliqlw)
181 status = nf90_inq_varid(ncid,'lut_extice',varid)
182 status = nf90_get_var(ncid,varid,lut_exticelw)
183 status = nf90_inq_varid(ncid,'lut_ssaice',varid)
184 status = nf90_get_var(ncid,varid,lut_ssaicelw)
185 status = nf90_inq_varid(ncid,'lut_asyice',varid)
186 status = nf90_get_var(ncid,varid,lut_asyicelw)
187 status = nf90_inq_varid(ncid,'bnd_limits_wavenumber',varid)
188 status = nf90_get_var(ncid,varid,band_limscldlw)
189
190 ! Close file
191 status = nf90_close(ncid)
192 endif ! Master process
193
194 ! Other processors waiting...
195 call mpi_barrier(mpicomm, mpierr)
196
197 ! #######################################################################################
198 !
199 ! Broadcast data...
200 ! (ALL processors)
201 !
202 ! #######################################################################################
203
204 ! Real scalars
205#ifdef RTE_USE_SP
206 call mpi_bcast(radliq_lwrlw, 1, mpi_real, mpiroot, mpicomm, mpierr)
207 call mpi_bcast(radliq_uprlw, 1, mpi_real, mpiroot, mpicomm, mpierr)
208 call mpi_bcast(radice_lwrlw, 1, mpi_real, mpiroot, mpicomm, mpierr)
209 call mpi_bcast(radice_uprlw, 1, mpi_real, mpiroot, mpicomm, mpierr)
210#else
211 call mpi_bcast(radliq_lwrlw, 1, mpi_double_precision, mpiroot, mpicomm, mpierr)
212 call mpi_bcast(radliq_uprlw, 1, mpi_double_precision, mpiroot, mpicomm, mpierr)
213 call mpi_bcast(radice_lwrlw, 1, mpi_double_precision, mpiroot, mpicomm, mpierr)
214 call mpi_bcast(radice_uprlw, 1, mpi_double_precision, mpiroot, mpicomm, mpierr)
215#endif
216
217 ! Real arrays
218#ifdef RTE_USE_SP
219 call mpi_bcast(band_limscldlw, size(band_limscldlw), mpi_real, mpiroot, mpicomm, mpierr)
220 call mpi_bcast(lut_extliqlw, size(lut_extliqlw), mpi_real, mpiroot, mpicomm, mpierr)
221 call mpi_bcast(lut_ssaliqlw, size(lut_ssaliqlw), mpi_real, mpiroot, mpicomm, mpierr)
222 call mpi_bcast(lut_asyliqlw, size(lut_asyliqlw), mpi_real, mpiroot, mpicomm, mpierr)
223 call mpi_bcast(lut_exticelw, size(lut_exticelw), mpi_real, mpiroot, mpicomm, mpierr)
224 call mpi_bcast(lut_ssaicelw, size(lut_ssaicelw), mpi_real, mpiroot, mpicomm, mpierr)
225 call mpi_bcast(lut_asyicelw, size(lut_asyicelw), mpi_real, mpiroot, mpicomm, mpierr)
226#else
227 call mpi_bcast(band_limscldlw, size(band_limscldlw), mpi_double_precision, mpiroot, mpicomm, mpierr)
228 call mpi_bcast(lut_extliqlw, size(lut_extliqlw), mpi_double_precision, mpiroot, mpicomm, mpierr)
229 call mpi_bcast(lut_ssaliqlw, size(lut_ssaliqlw), mpi_double_precision, mpiroot, mpicomm, mpierr)
230 call mpi_bcast(lut_asyliqlw, size(lut_asyliqlw), mpi_double_precision, mpiroot, mpicomm, mpierr)
231 call mpi_bcast(lut_exticelw, size(lut_exticelw), mpi_double_precision, mpiroot, mpicomm, mpierr)
232 call mpi_bcast(lut_ssaicelw, size(lut_ssaicelw), mpi_double_precision, mpiroot, mpicomm, mpierr)
233 call mpi_bcast(lut_asyicelw, size(lut_asyicelw), mpi_double_precision, mpiroot, mpicomm, mpierr)
234#endif
235
236 ! #######################################################################################
237 !
238 ! Initialize RRTMGP DDT's...
239 !
240 ! #######################################################################################
241 call check_error_msg('lw_cloud_optics_init',lw_cloud_props%load(band_limscldlw, &
242 radliq_lwrlw, radliq_uprlw, radice_lwrlw, radice_uprlw, &
243 lut_extliqlw, lut_ssaliqlw, lut_asyliqlw, &
244 lut_exticelw, lut_ssaicelw, lut_asyicelw))
245
246 call check_error_msg('lw_cloud_optics_init',lw_cloud_props%set_ice_roughness(nrghice))
247
248 is_initialized = .true.
249
250 end subroutine rrtmgp_lw_cloud_optics_init
251end module rrtmgp_lw_cloud_optics
This module contains tools for radiation.
This module contains two routines: The first initializes data and functions needed to compute the lon...
This module contains two routines: One to initialize the k-distribution data and functions needed to ...