Ignore:
Timestamp:
Mar 19, 2024, 3:34:21 PM (2 months ago)
Author:
idelkadi
Message:

Ecrad update in LMDZ / Implementation of Ecrad double call in LMDZ

  • version 1.6.1 (commit 210d7911380f53a788c3cad73b3cf9b4e022ef87)
  • interface routines between lmdz and ecrad grouped in a new "lmdz" directory
  • double call method redesigned so as to go through the Ecrad initialization and configuration part only once for the entire simulation
  • clean-up in the read.F routine: delete unitules arguments
  • modification of default gas model in namelist (default: ECCKD)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/ecrad/radiation/radiation_aerosol_optics_description.F90

    r4773 r4853  
    1313! Email:   r.j.hogan@ecmwf.int
    1414!
     15
     16#include "ecrad_config.h"
    1517
    1618module radiation_aerosol_optics_description
     
    6062    logical, allocatable :: is_preferred_philic(:)
    6163
     64    ! Verbosity level
     65    integer :: iverbose
     66   
    6267  contains
    6368    procedure :: read
     
    7580
    7681    use yomhook,              only : lhook, dr_hook, jphook
     82#ifdef EASY_NETCDF_READ_MPI
     83    use easy_netcdf_read_mpi, only : netcdf_file
     84#else
    7785    use easy_netcdf,          only : netcdf_file
     86#endif
    7887
    7988    class(aerosol_optics_description_type), intent(inout) :: this
     
    8493    type(netcdf_file)  :: file
    8594
    86     real(jphook) :: hook_handle
     95    real(jphook)       :: hook_handle
    8796
    8897    if (lhook) call dr_hook('radiation_aerosol_optics_description:load',0,hook_handle)
     
    108117    call file%close()
    109118
     119    if (present(iverbose)) then
     120      this%iverbose = iverbose
     121    else
     122      this%iverbose = 3
     123    end if
     124   
    110125    if (lhook) call dr_hook('radiation_aerosol_optics_description:load',1,hook_handle)
    111126
     
    124139
    125140    use yomhook,              only : lhook, dr_hook, jphook
    126 
     141    use radiation_io,         only : nulout, nulerr, radiation_abort
     142   
    127143    class(aerosol_optics_description_type), intent(inout) :: this
    128144    character(len=2), intent(in) :: code_str
     
    132148    integer :: ja
    133149
    134     real(jphook) :: hook_handle
     150    logical :: is_found, is_philic, is_phobic
     151
     152    real(jphook)         :: hook_handle
    135153
    136154    if (lhook) call dr_hook('radiation_aerosol_optics_description:preferred_optical_model',0,hook_handle)
     
    138156    ! Check for empty string
    139157    if (optical_model_str == ' ') then
     158      if (lhook) call dr_hook('radiation_aerosol_optics_description:preferred_optical_model',1,hook_handle)
    140159      return
    141160    end if
     161
     162    is_found  = .false.
     163    is_philic = .false.
     164    is_phobic = .false.
    142165   
    143166    ! Loop over hydrophilic types
     
    145168      ! Check if we have a match
    146169      if (to_string(this%code_philic(:,ja)) == code_str &
    147            &  .and. to_string(this%optical_model_philic(1:len(optical_model_str),ja)) &
     170           &  .and. trim(to_string(this%optical_model_philic(:,ja))) &
    148171           &          == optical_model_str) then
    149172        this%is_preferred_philic(ja) = .true.
     173        is_found  = .true.
     174        is_philic = .true.
    150175      end if
    151176    end do
     
    153178    do ja = 1,size(this%bin_phobic)
    154179      if (to_string(this%code_phobic(:,ja)) == code_str &
    155            &  .and. to_string(this%optical_model_phobic(1:len(optical_model_str),ja)) &
     180           &  .and. trim(to_string(this%optical_model_phobic(:,ja))) &
    156181           &          == optical_model_str) then
    157182        this%is_preferred_phobic(ja) = .true.
     183        is_found  = .true.
     184        is_phobic = .true.
    158185      end if
    159186    end do
    160187
     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   
    161204    if (lhook) call dr_hook('radiation_aerosol_optics_description:preferred_optical_model',1,hook_handle)
    162205
    163206  end subroutine preferred_optical_model
    164207
     208 
    165209  !---------------------------------------------------------------------
    166210  ! Return the index to the aerosol optical properties corresponding
     
    179223   
    180224    use yomhook,              only : lhook, dr_hook, jphook
    181     use easy_netcdf,          only : netcdf_file
    182225    use radiation_io,         only : nulout
    183226
     
    234277          end if
    235278          if (present(optical_model_str)) then
    236             if (to_string(this%optical_model_philic(1:len(optical_model_str),ja)) &
     279            if (trim(to_string(this%optical_model_philic(:,ja))) &
    237280                 &  == optical_model_str) then
    238281              ! Requested optical model matches
     
    285328          end if
    286329          if (present(optical_model_str)) then
    287             if (to_string(this%optical_model_phobic(1:len(optical_model_str),ja)) &
     330            if (trim(to_string(this%optical_model_phobic(:,ja))) &
    288331                 &  == optical_model_str) then
    289332              ! Requested optical model matches
     
    315358
    316359    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, &
    318362           &  ',...) does not unambiguously identify an aerosol optical property index'
    319363    end if
    320 
     364   
    321365    if (lhook) call dr_hook('radiation_aerosol_optics_description:get_index',1,hook_handle)
    322366
     
    325369  !---------------------------------------------------------------------
    326370  ! 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.
    328374  pure function to_string(arr) result(str)
    329375    character, intent(in)  :: arr(:)
     
    331377    integer :: jc
    332378    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
    334385    end do
    335386  end function to_string
Note: See TracChangeset for help on using the changeset viewer.