37 subroutine mosaic_init(env_state, aero_data, del_t, do_optical)
40 use module_data_mosaic_aero
, only: alpha_astem, rtol_eqb_astem, &
41 ptol_mol_astem, mgas_aer_xfer, mdynamic_solver
43 use module_data_mosaic_main
, only: tbeg_sec, dt_sec, rlon, rlat, &
44 zalt_m, rh, te, pr_atm, cair_mlc, cair_molm3, ppb, avogad, &
45 mmode, mgas, maer, mcld, maeroptic, mshellcore, &
46 msolar, mphoto, lun_aeroptic, naerbin
54 real(kind=dp),
intent(in) :: del_t
56 logical,
intent(in) :: do_optical
61 subroutine loadperoxyparameters()
62 end subroutine loadperoxyparameters
63 subroutine init_data_modules()
64 end subroutine init_data_modules
65 subroutine allocatememory()
66 end subroutine allocatememory
69 call init_data_modules
92 rtol_eqb_astem = 0.01d0
93 ptol_mol_astem = 0.01d0
97 tbeg_sec = env_state%start_day*24*3600 + &
98 nint(env_state%start_time)
101 rlon =
deg2rad(env_state%longitude)
102 rlat =
deg2rad(env_state%latitude)
103 zalt_m = env_state%altitude
106 rh = env_state%rel_humid * 100.d0
108 pr_atm = env_state%pressure /
const%air_std_press
109 cair_mlc = avogad*pr_atm/(82.056d0*te)
110 cair_molm3 = 1d6*pr_atm/(82.056d0*te)
113 call loadperoxyparameters
116 if (lun_aeroptic <= 0 ) lun_aeroptic =
get_unit()
119 call assert_msg(111041803, aero_data%i_water > 0, &
120 "MOSAIC requires H2O as an aerosol species")
131 #ifdef PMC_USE_MOSAIC 134 subroutine deallocatememory()
135 end subroutine deallocatememory
138 call deallocatememory()
147 aero_state, gas_data, gas_state)
149 #ifdef PMC_USE_MOSAIC 150 use module_data_mosaic_aero
, only: nbin_a, aer, num_a, jhyst_leg, &
153 use module_data_mosaic_main
, only: tbeg_sec, tcur_sec, tmid_sec, &
154 dt_sec, dt_min, dt_aeroptic_min, rh, te, pr_atm, cnn, cair_mlc, &
155 cair_molm3, ppb, avogad, msolar, naerbin
169 #ifdef PMC_USE_MOSAIC 171 real(kind=dp) :: time_UTC
172 real(kind=dp) :: tmar21_sec
174 integer :: i_part, i_spec, i_spec_mosaic
175 real(kind=dp) :: num_conc
179 subroutine allocatememory()
180 end subroutine allocatememory
181 subroutine deallocatememory()
182 end subroutine deallocatememory
186 tmar21_sec =
real((79*24 + 12)*3600, kind=dp) 187 tcur_sec =
real(tbeg_sec, kind=dp) + env_state%elapsed_time
190 time_utc = env_state%start_time/3600d0
191 time_utc = time_utc + dt_sec/3600d0
193 do while (time_utc >= 24d0)
194 time_utc = time_utc - 24d0
197 tmid_sec = tcur_sec + 0.5d0*dt_sec
198 if(tmid_sec .ge. tmar21_sec)
then 199 tmid_sec = tmid_sec - tmar21_sec
201 tmid_sec = tmid_sec &
202 + dble(((365-79)*24 - 12)*3600)
208 dt_aeroptic_min = 0d0
213 conv_fac(i_spec) = 1.d9 * aero_data%density(i_spec) &
214 / aero_data%molec_weight(i_spec)
218 rh = env_state%rel_humid * 100.d0
220 pr_atm = env_state%pressure /
const%air_std_press
221 cair_mlc = avogad*pr_atm/(82.056d0*te)
222 cair_molm3 = 1d6*pr_atm/(82.056d0*te)
227 if (nbin_a > naerbin)
then 228 call deallocatememory()
230 call allocatememory()
236 num_conc = aero_weight_array_num_conc(aero_state%awa, &
237 aero_state%apa%particle(i_part), aero_data)
239 i_spec_mosaic = aero_data%mosaic_index(i_spec)
240 if (i_spec_mosaic > 0)
then 242 aer(i_spec_mosaic, 3, i_part) &
243 = aero_state%apa%particle(i_part)%vol(i_spec) &
244 * conv_fac(i_spec) * num_conc
250 aero_state%apa%particle(i_part)%vol(aero_data%i_water) &
251 * aero_data%density(aero_data%i_water) * num_conc
252 num_a(i_part) = 1d-6 * num_conc
253 jhyst_leg(i_part) = aero_state%apa%particle(i_part)%water_hyst_leg
259 i_spec_mosaic = gas_data%mosaic_index(i_spec)
260 if (i_spec_mosaic > 0)
then 262 cnn(i_spec_mosaic) = gas_state%mix_rat(i_spec) * cair_mlc / ppb
275 #ifdef PMC_USE_MOSAIC 276 use module_data_mosaic_aero
, only: nbin_a, aer, num_a, jhyst_leg, &
279 use module_data_mosaic_main
, only: tbeg_sec, tcur_sec, tmid_sec, &
280 dt_sec, dt_min, dt_aeroptic_min, rh, te, pr_atm, cnn, cair_mlc, &
281 cair_molm3, ppb, avogad, msolar, cos_sza
295 #ifdef PMC_USE_MOSAIC 298 integer :: i_part, i_spec, i_spec_mosaic
304 conv_fac(i_spec) = 1d9 * aero_data%density(i_spec) &
305 / aero_data%molec_weight(i_spec)
309 env_state%rel_humid = rh / 100d0
311 env_state%pressure = pr_atm *
const%air_std_press
312 if (msolar == 1)
then 313 env_state%solar_zenith_angle = acos(cos_sza)
315 cair_mlc = avogad*pr_atm/(82.056d0*te)
316 cair_molm3 = 1d6*pr_atm/(82.056d0*te)
320 aero_state%valid_sort = .false.
326 num_conc = aero_weight_array_num_conc(aero_state%awa, &
327 aero_state%apa%particle(i_part), aero_data)
329 i_spec_mosaic = aero_data%mosaic_index(i_spec)
330 if (i_spec_mosaic > 0)
then 331 aero_state%apa%particle(i_part)%vol(i_spec) = &
333 aer(i_spec_mosaic, 3, i_part) / (conv_fac(i_spec) * num_conc)
336 aero_state%apa%particle(i_part)%water_hyst_leg = jhyst_leg(i_part)
339 aero_state%apa%particle(i_part)%vol(aero_data%i_water) = &
340 water_a(i_part) / aero_data%density(aero_data%i_water) / num_conc
347 i_spec_mosaic = gas_data%mosaic_index(i_spec)
348 if (i_spec_mosaic > 0)
then 350 gas_state%mix_rat(i_spec) = cnn(i_spec_mosaic) / cair_mlc * ppb
366 subroutine mosaic_timestep(env_state, aero_data, aero_state, gas_data, &
367 gas_state, do_optical)
369 #ifdef PMC_USE_MOSAIC 370 use module_data_mosaic_main
, only: msolar
384 logical,
intent(in) :: do_optical
386 #ifdef PMC_USE_MOSAIC 389 subroutine solarzenithangle()
390 end subroutine solarzenithangle
391 subroutine integratechemistry()
392 end subroutine integratechemistry
393 subroutine aerosol_optical()
394 end subroutine aerosol_optical
401 if (msolar == 1)
then 402 call solarzenithangle
405 call integratechemistry
413 aero_state, gas_data, gas_state)
431 aero_state, gas_data, gas_state)
433 #ifdef PMC_USE_MOSAIC 434 use module_data_mosaic_aero
, only: ri_shell_a, ri_core_a, &
435 ext_cross, scat_cross, asym_particle, dp_core_a
449 #ifdef PMC_USE_MOSAIC 452 subroutine aerosol_optical()
453 end subroutine aerosol_optical
468 aero_state%apa%particle(i_part)%absorb_cross_sect = (ext_cross(i_part) &
469 - scat_cross(i_part)) / 1d4
470 aero_state%apa%particle(i_part)%scatter_cross_sect = &
471 scat_cross(i_part) / 1d4
472 aero_state%apa%particle(i_part)%asymmetry = asym_particle(i_part)
473 aero_state%apa%particle(i_part)%refract_shell = &
474 cmplx(ri_shell_a(i_part), kind=
dc)
475 aero_state%apa%particle(i_part)%refract_core =&
476 cmplx(ri_core_a(i_part), kind=
dc)
477 aero_state%apa%particle(i_part)%core_vol = &
489 aero_state, gas_data, gas_state)
491 #ifdef PMC_USE_MOSAIC 492 use module_data_mosaic_aero
, only: ri_shell_a, ri_core_a, &
493 ext_cross, scat_cross, asym_particle, dp_core_a
507 #ifdef PMC_USE_MOSAIC 510 subroutine load_mosaic_parameters()
511 end subroutine load_mosaic_parameters
512 subroutine aerosol_optical()
513 end subroutine aerosol_optical
516 call load_mosaic_parameters
525 aero_state, gas_data, gas_state)
subroutine assert_msg(code, condition_ok, error_msg)
Errors unless condition_ok is true.
subroutine mosaic_aero_optical(env_state, aero_data, aero_state, gas_data, gas_state)
Compute the optical properties of each aerosol particle. FIXME: currently disabled.
real(kind=dp) elemental function aero_data_diam2vol(aero_data, d)
Convert geometric diameter (m) to mass-equivalent volume (m^3).
subroutine mosaic_to_partmc(env_state, aero_data, aero_state, gas_data, gas_state)
Map all data MOSAIC -> PartMC.
The env_state_t structure and associated subroutines.
The gas_data_t structure and associated subroutines.
elemental integer function aero_state_n_part(aero_state)
Return the current number of particles.
Interface to the MOSAIC aerosol and gas phase chemistry code.
subroutine mosaic_from_partmc(env_state, aero_data, aero_state, gas_data, gas_state)
Map all data PartMC -> MOSAIC.
subroutine mosaic_cleanup()
Clean-up after running MOSAIC, deallocating memory.
The aero_state_t structure and assocated subroutines.
subroutine aero_state_reweight(aero_state, aero_data, reweight_num_conc)
Reweight all particles after their constituent volumes have been altered.
Current environment state.
subroutine mosaic_aero_optical_init(env_state, aero_data, aero_state, gas_data, gas_state)
Compute the optical properties of each aerosol particle for initial timestep.
integer function aero_state_total_particles(aero_state, i_group, i_class)
Returns the total number of particles in an aerosol distribution.
integer function get_unit()
Returns an available unit number. This should be freed by free_unit().
The current collection of aerosol particles.
elemental integer function gas_data_n_spec(gas_data)
Return the number of gas species.
The aero_data_t structure and associated subroutines.
The gas_state_t structure and associated subroutines.
subroutine aero_state_num_conc_for_reweight(aero_state, aero_data, reweight_num_conc)
Save the correct number concentrations for later use by aero_state_reweight().
subroutine mosaic_timestep(env_state, aero_data, aero_state, gas_data, gas_state, do_optical)
Do one timestep with MOSAIC.
Current state of the gas mixing ratios in the system.
type(const_t), save const
Fixed variable for accessing the constant's values.
elemental integer function aero_data_n_spec(aero_data)
Return the number of aerosol species, or -1 if uninitialized.
logical function mosaic_support()
Whether MOSAIC support is compiled in.
Aerosol material properties and associated data.
real(kind=dp) function deg2rad(deg)
Convert degrees to radians.
Common utility subroutines.
integer, parameter dc
Kind of a double precision complex number.
subroutine mosaic_init(env_state, aero_data, del_t, do_optical)
Initialize all MOSAIC data-structures.