- Timestamp:
- Mar 19, 2024, 3:34:21 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/trunk/libf/phylmd/ecrad/radiation/radiation_aerosol_optics_description.F90
r4773 r4853 13 13 ! Email: r.j.hogan@ecmwf.int 14 14 ! 15 16 #include "ecrad_config.h" 15 17 16 18 module radiation_aerosol_optics_description … … 60 62 logical, allocatable :: is_preferred_philic(:) 61 63 64 ! Verbosity level 65 integer :: iverbose 66 62 67 contains 63 68 procedure :: read … … 75 80 76 81 use yomhook, only : lhook, dr_hook, jphook 82 #ifdef EASY_NETCDF_READ_MPI 83 use easy_netcdf_read_mpi, only : netcdf_file 84 #else 77 85 use easy_netcdf, only : netcdf_file 86 #endif 78 87 79 88 class(aerosol_optics_description_type), intent(inout) :: this … … 84 93 type(netcdf_file) :: file 85 94 86 real(jphook) :: hook_handle95 real(jphook) :: hook_handle 87 96 88 97 if (lhook) call dr_hook('radiation_aerosol_optics_description:load',0,hook_handle) … … 108 117 call file%close() 109 118 119 if (present(iverbose)) then 120 this%iverbose = iverbose 121 else 122 this%iverbose = 3 123 end if 124 110 125 if (lhook) call dr_hook('radiation_aerosol_optics_description:load',1,hook_handle) 111 126 … … 124 139 125 140 use yomhook, only : lhook, dr_hook, jphook 126 141 use radiation_io, only : nulout, nulerr, radiation_abort 142 127 143 class(aerosol_optics_description_type), intent(inout) :: this 128 144 character(len=2), intent(in) :: code_str … … 132 148 integer :: ja 133 149 134 real(jphook) :: hook_handle 150 logical :: is_found, is_philic, is_phobic 151 152 real(jphook) :: hook_handle 135 153 136 154 if (lhook) call dr_hook('radiation_aerosol_optics_description:preferred_optical_model',0,hook_handle) … … 138 156 ! Check for empty string 139 157 if (optical_model_str == ' ') then 158 if (lhook) call dr_hook('radiation_aerosol_optics_description:preferred_optical_model',1,hook_handle) 140 159 return 141 160 end if 161 162 is_found = .false. 163 is_philic = .false. 164 is_phobic = .false. 142 165 143 166 ! Loop over hydrophilic types … … 145 168 ! Check if we have a match 146 169 if (to_string(this%code_philic(:,ja)) == code_str & 147 & .and. t o_string(this%optical_model_philic(1:len(optical_model_str),ja)) &170 & .and. trim(to_string(this%optical_model_philic(:,ja))) & 148 171 & == optical_model_str) then 149 172 this%is_preferred_philic(ja) = .true. 173 is_found = .true. 174 is_philic = .true. 150 175 end if 151 176 end do … … 153 178 do ja = 1,size(this%bin_phobic) 154 179 if (to_string(this%code_phobic(:,ja)) == code_str & 155 & .and. t o_string(this%optical_model_phobic(1:len(optical_model_str),ja)) &180 & .and. trim(to_string(this%optical_model_phobic(:,ja))) & 156 181 & == optical_model_str) then 157 182 this%is_preferred_phobic(ja) = .true. 183 is_found = .true. 184 is_phobic = .true. 158 185 end if 159 186 end do 160 187 188 if (.not. is_found) then 189 write(nulerr,'(a,a2,a,a,a)') '*** Error: Preferred "', code_str ,'" aerosol optical model "', & 190 & trim(optical_model_str), '" not found in file' 191 call radiation_abort() 192 else if (this%iverbose > 2) then 193 write(nulout,'(a,a2,a,a,a)',advance='no') 'Preferred "', code_str, '" aerosol optical model set to "', & 194 & trim(optical_model_str), '" (' 195 if (is_phobic) then 196 write(nulout,'(a)',advance='no') ' hydrophobic' 197 end if 198 if (is_philic) then 199 write(nulout,'(a)',advance='no') ' hydrophilic' 200 end if 201 write(nulout,'(a)') ' )' 202 end if 203 161 204 if (lhook) call dr_hook('radiation_aerosol_optics_description:preferred_optical_model',1,hook_handle) 162 205 163 206 end subroutine preferred_optical_model 164 207 208 165 209 !--------------------------------------------------------------------- 166 210 ! Return the index to the aerosol optical properties corresponding … … 179 223 180 224 use yomhook, only : lhook, dr_hook, jphook 181 use easy_netcdf, only : netcdf_file182 225 use radiation_io, only : nulout 183 226 … … 234 277 end if 235 278 if (present(optical_model_str)) then 236 if (t o_string(this%optical_model_philic(1:len(optical_model_str),ja)) &279 if (trim(to_string(this%optical_model_philic(:,ja))) & 237 280 & == optical_model_str) then 238 281 ! Requested optical model matches … … 285 328 end if 286 329 if (present(optical_model_str)) then 287 if (t o_string(this%optical_model_phobic(1:len(optical_model_str),ja)) &330 if (trim(to_string(this%optical_model_phobic(:,ja))) & 288 331 & == optical_model_str) then 289 332 ! Requested optical model matches … … 315 358 316 359 if (is_ambiguous) then 317 write(nulout,'(a,a2,a,l1,a)') 'Warning: get_index("', code_str, '",', lhydrophilic, & 360 write(nulout,'(a,a2,a,l,a)') 'Warning: radiation_aerosol_optics_description:get_index("', & 361 & code_str, '",', lhydrophilic, & 318 362 & ',...) does not unambiguously identify an aerosol optical property index' 319 363 end if 320 364 321 365 if (lhook) call dr_hook('radiation_aerosol_optics_description:get_index',1,hook_handle) 322 366 … … 325 369 !--------------------------------------------------------------------- 326 370 ! Utility function to convert an array of single characters to a 327 ! character string (yes Fortran's string handling is a bit rubbish) 371 ! character string (yes Fortran's string handling is a bit 372 ! rubbish). We set NULL characters (ASCII code 0) returned from the 373 ! NetCDF library to spaces, so that TRIM can remove them. 328 374 pure function to_string(arr) result(str) 329 375 character, intent(in) :: arr(:) … … 331 377 integer :: jc 332 378 do jc = 1,size(arr) 333 str(jc:jc) = arr(jc) 379 if (ichar(arr(jc)) == 0) then 380 ! Replace NULL character with a space 381 str(jc:jc) = ' ' 382 else 383 str(jc:jc) = arr(jc) 384 end if 334 385 end do 335 386 end function to_string
Note: See TracChangeset
for help on using the changeset viewer.