|
| 1 | +! Copyright (C) 2024 National Science Foundation-National Center for Atmospheric Research |
| 2 | +! SPDX-License-Identifier: Apache-2.0 |
| 3 | +module musica_ccpp_tuvx_aerosol_optics |
| 4 | + implicit none |
| 5 | + |
| 6 | + private |
| 7 | + public :: create_aerosol_optics_radiator, set_aerosol_optics_values |
| 8 | + |
| 9 | + !> Label for aerosol optical properties in TUV-x |
| 10 | + character(len=*), parameter, public :: aerosol_optics_label = "aerosols" |
| 11 | + !> Label |
| 12 | + character(len=*), parameter, public :: \ |
| 13 | + aerosol_optical_depth_label = "optical depths" |
| 14 | + character(len=*), parameter, public :: \ |
| 15 | + aerosol_single_scattering_albedo_label = "single scattering albedos" |
| 16 | + character(len=*), parameter, public :: \ |
| 17 | + aerosol_asymmetry_factor_label = "asymmetry factor" |
| 18 | + !> Unit |
| 19 | + character(len=*), parameter, public :: aerosol_optical_depth_unit = "none" |
| 20 | + character(len=*), parameter, public :: aerosol_single_scattering_albedo_unit = "none" |
| 21 | + character(len=*), parameter, public :: aerosol_asymmetry_factor_unit = "none" |
| 22 | + !> Default value of number of vertical levels |
| 23 | + integer, parameter :: DEFAULT_NUM_VERTICAL_LEVELS = 0 |
| 24 | + !> Number of vertical levels |
| 25 | + integer, protected :: num_vertical_levels = DEFAULT_NUM_VERTICAL_LEVELS |
| 26 | + !> Default value of number of wavelength bins |
| 27 | + integer, parameter :: DEFAULT_NUM_WAVELENGTH_BINS = 0 |
| 28 | + !> Number of wavelength bins |
| 29 | + integer, protected :: num_wavelength_bins = DEFAULT_NUM_WAVELENGTH_BINS |
| 30 | + !> Default value of number of streams |
| 31 | + integer, parameter :: DEFAULT_NUM_STREAMS = 1 |
| 32 | + !> Number of streams |
| 33 | + integer, protected :: num_streams = DEFAULT_NUM_STREAMS |
| 34 | + |
| 35 | +contains |
| 36 | + |
| 37 | + !> Creates a TUV-x aerosol optics radiator |
| 38 | + function create_aerosol_optics_radiator( height_grid, wavelength_grid, & |
| 39 | + errmsg, errcode ) result( radiator ) |
| 40 | + use musica_ccpp_util, only: has_error_occurred |
| 41 | + use musica_tuvx_grid, only: grid_t |
| 42 | + use musica_tuvx_radiator, only: radiator_t |
| 43 | + use musica_util, only: error_t |
| 44 | + |
| 45 | + type(grid_t), intent(inout) :: height_grid |
| 46 | + type(grid_t), intent(inout) :: wavelength_grid |
| 47 | + character(len=*), intent(out) :: errmsg |
| 48 | + integer, intent(out) :: errcode |
| 49 | + type(radiator_t), pointer :: radiator |
| 50 | + |
| 51 | + ! local variables |
| 52 | + type(error_t) :: error |
| 53 | + |
| 54 | + num_vertical_levels = height_grid%number_of_sections( error ) |
| 55 | + if ( has_error_occurred( error, errmsg, errcode ) ) return |
| 56 | + |
| 57 | + num_wavelength_bins = wavelength_grid%number_of_sections( error ) |
| 58 | + if ( has_error_occurred( error, errmsg, errcode ) ) return |
| 59 | + |
| 60 | + radiator => radiator_t( aerosol_optics_label, height_grid, wavelength_grid, & |
| 61 | + error ) |
| 62 | + if ( has_error_occurred( error, errmsg, errcode ) ) return |
| 63 | + |
| 64 | + end function create_aerosol_optics_radiator |
| 65 | + |
| 66 | + !> Sets TUV-x aerosol optics values |
| 67 | + ! Temporarily setting optical properties to zero until aerosol optical |
| 68 | + ! property calculations are ported to CAM-SIMA. |
| 69 | + subroutine set_aerosol_optics_values( radiator, errmsg, errcode ) |
| 70 | + use ccpp_kinds, only: kind_phys |
| 71 | + use musica_ccpp_util, only: has_error_occurred |
| 72 | + use musica_tuvx_radiator, only: radiator_t |
| 73 | + use musica_util, only: error_t |
| 74 | + |
| 75 | + type(radiator_t), intent(inout) :: radiator |
| 76 | + character(len=*), intent(out) :: errmsg |
| 77 | + integer, intent(out) :: errcode |
| 78 | + |
| 79 | + ! local variables |
| 80 | + type(error_t) :: error |
| 81 | + real(kind_phys) :: \ |
| 82 | + aerosol_optical_depth(num_vertical_levels, num_wavelength_bins) |
| 83 | + real(kind_phys) :: \ |
| 84 | + aerosol_single_scattering_albedo(num_vertical_levels, num_wavelength_bins) |
| 85 | + real(kind_phys) :: \ |
| 86 | + aerosol_asymmetry_factor(num_vertical_levels, num_wavelength_bins, num_streams) |
| 87 | + |
| 88 | + aerosol_optical_depth(:,:) = 0.0_kind_phys |
| 89 | + aerosol_single_scattering_albedo(:,:) = 0.0_kind_phys |
| 90 | + aerosol_asymmetry_factor(:,:,:) = 0.0_kind_phys |
| 91 | + |
| 92 | + call radiator%set_optical_depths( aerosol_optical_depth, error ) |
| 93 | + if ( has_error_occurred( error, errmsg, errcode ) ) return |
| 94 | + |
| 95 | + call radiator%set_single_scattering_albedos( aerosol_single_scattering_albedo, error ) |
| 96 | + if ( has_error_occurred( error, errmsg, errcode ) ) return |
| 97 | + |
| 98 | + call radiator%set_asymmetry_factors( aerosol_asymmetry_factor, error ) |
| 99 | + if ( has_error_occurred( error, errmsg, errcode ) ) return |
| 100 | + |
| 101 | + end subroutine set_aerosol_optics_values |
| 102 | + |
| 103 | +end module musica_ccpp_tuvx_aerosol_optics |
0 commit comments