source: LMDZ6/trunk/libf/phylmd/ecrad/setup_aerosol_optics_lmdz_m.F90 @ 4517

Last change on this file since 4517 was 4517, checked in by lguez, 14 months ago

Bug fix: correct SW properties of aerosols

The values are correct in the input NetCDF file but they were assigned
to the wrong variables in ECRad, so shortwave properties of aerosols
were completely wrong. This bug comes from commit r4182.

File size: 4.9 KB
Line 
1module setup_aerosol_optics_lmdz_m
2
3  implicit none
4
5contains
6
7  subroutine setup_aerosol_optics_lmdz(ao, file_name)
8
9    ! Read aerosol optical properties. Note differences with
10    ! "radiation_aerosol_optics_data::setup_aerosol_optics":
11
12    ! -- The input NetCDF file is not flat, it contains NetCDF groups.
13
14    ! -- We do not define ao%ssa_mono_phobic, ao%g_mono_phobic,
15    ! ao%lidar_ratio_mono_phobic, ao%ssa_mono_philic,
16    ! ao%g_mono_philic, ao%lidar_ratio_mono_philic. They are not in
17    ! the input NetCDF file and they are not used by ECRad.
18
19    ! -- We do not define ao%description_phobic_str and
20    ! ao%description_philic_str. We just leave the initialization
21    ! value, which is a blank.
22
23    ! -- We have to cshift the shortwave fields because the the
24    ! shortwave bands are in ascending order in the NetCDF file while
25    ! they are not in ECRad.
26
27    use radiation_aerosol_optics_data, only: aerosol_optics_type, &
28         IAerosolClassUndefined
29    use netcdf95, only: nf95_open, nf95_inq_grp_full_ncid, nf95_close, &
30         nf95_inq_dimid, nf95_inq_varid, nf95_inquire_dimension, &
31         nf95_get_var, nf95_gw_var
32    use netcdf, only: nf90_nowrite
33
34    type(aerosol_optics_type), intent(out):: ao
35
36    character(len=*), intent(in):: file_name
37    ! NetCDF file containing the aerosol optics data
38
39    ! Local:
40    integer ncid, grpid, dimid, varid
41
42    !-----------------------------------------------------------------------
43
44    ao%use_hydrophilic = .true.
45    ao%use_monochromatic = .true.
46    print*,'file_name= ',file_name
47    call nf95_open(file_name, nf90_nowrite, ncid)
48    call nf95_inq_grp_full_ncid(ncid, "Hydrophilic", grpid)
49    call nf95_inq_dimid(grpid, "hur", dimid)
50    call nf95_inquire_dimension(grpid, dimid, nclen = ao%nrh)
51    allocate(ao%rh_lower(ao%nrh))
52    call nf95_inq_varid(grpid, "hur_bounds", varid)
53    call nf95_get_var(grpid, varid, ao%rh_lower, count_nc = [1, ao%nrh])
54
55    ! Hydrophilic/LW_bands:
56    call nf95_inq_grp_full_ncid(ncid, "Hydrophilic/LW_bands", grpid)
57    call nf95_inq_varid(grpid, "asymmetry", varid)
58    call nf95_gw_var(grpid, varid, ao%g_lw_philic)
59    call nf95_inq_varid(grpid, "single_scat_alb", varid)
60    call nf95_gw_var(grpid, varid, ao%ssa_lw_philic)
61    call nf95_inq_varid(grpid, "mass_ext", varid)
62    call nf95_gw_var(grpid, varid, ao%mass_ext_lw_philic)
63
64    ! Hydrophilic/SW_bands:
65    call nf95_inq_grp_full_ncid(ncid, "Hydrophilic/SW_bands", grpid)
66    call nf95_inq_varid(grpid, "asymmetry", varid)
67    call nf95_gw_var(grpid, varid, ao%g_sw_philic)
68    ao%g_sw_philic = cshift(ao%g_sw_philic, 1)
69    call nf95_inq_varid(grpid, "single_scat_alb", varid)
70    call nf95_gw_var(grpid, varid, ao%ssa_sw_philic)
71    ao%ssa_sw_philic = cshift(ao%ssa_sw_philic, 1)
72    call nf95_inq_varid(grpid, "mass_ext", varid)
73    call nf95_gw_var(grpid, varid, ao%mass_ext_sw_philic)
74    ao%mass_ext_sw_philic = cshift(ao%mass_ext_sw_philic, 1)
75
76    ! Hydrophilic/Monochromatic:
77    call nf95_inq_grp_full_ncid(ncid, "Hydrophilic/Monochromatic", grpid)
78    call nf95_inq_varid(grpid, "mass_ext", varid)
79    call nf95_gw_var(grpid, varid, ao%mass_ext_mono_philic)
80
81    ! Hydrophobic/LW_bands:
82    call nf95_inq_grp_full_ncid(ncid, "Hydrophobic/LW_bands", grpid)
83    call nf95_inq_varid(grpid, "asymmetry", varid)
84    call nf95_gw_var(grpid, varid, ao%g_lw_phobic)
85    call nf95_inq_varid(grpid, "single_scat_alb", varid)
86    call nf95_gw_var(grpid, varid, ao%ssa_lw_phobic)
87    call nf95_inq_varid(grpid, "mass_ext", varid)
88    call nf95_gw_var(grpid, varid, ao%mass_ext_lw_phobic)
89
90    ! Hydrophobic/SW_bands:
91    call nf95_inq_grp_full_ncid(ncid, "Hydrophobic/SW_bands", grpid)
92    call nf95_inq_varid(grpid, "asymmetry", varid)
93    call nf95_gw_var(grpid, varid, ao%g_sw_phobic)
94    ao%g_sw_phobic = cshift(ao%g_sw_phobic, 1)
95    call nf95_inq_varid(grpid, "single_scat_alb", varid)
96    call nf95_gw_var(grpid, varid, ao%ssa_sw_phobic)
97    ao%ssa_sw_phobic = cshift(ao%ssa_sw_phobic, 1)
98    call nf95_inq_varid(grpid, "mass_ext", varid)
99    call nf95_gw_var(grpid, varid, ao%mass_ext_sw_phobic)
100    ao%mass_ext_sw_phobic = cshift(ao%mass_ext_sw_phobic, 1)
101
102    ! Hydrophobic/Monochromatic:
103    call nf95_inq_grp_full_ncid(ncid, "Hydrophobic/Monochromatic", grpid)
104    call nf95_inq_varid(grpid, "mass_ext", varid)
105    call nf95_gw_var(grpid, varid, ao%mass_ext_mono_phobic)
106
107    call nf95_close(ncid)
108
109    ! Get array sizes
110    ao%n_bands_lw = size(ao%mass_ext_lw_phobic, 1)
111    ao%n_bands_sw = size(ao%mass_ext_sw_phobic, 1)
112    ao%n_mono_wl = size(ao%mass_ext_mono_phobic, 1)
113    ao%n_type_phobic = size(ao%mass_ext_lw_phobic, 2)
114    ao%n_type_philic = size(ao%mass_ext_lw_philic, 3)
115
116    ! Allocate memory for mapping arrays
117    ao%ntype = ao%n_type_phobic + ao%n_type_philic
118    allocate(ao%iclass(ao%ntype))
119    allocate(ao%itype(ao%ntype))
120
121    ao%iclass = IAerosolClassUndefined
122    ao%itype  = 0
123
124  end subroutine setup_aerosol_optics_lmdz
125
126end module setup_aerosol_optics_lmdz_m
Note: See TracBrowser for help on using the repository browser.