Changeset 1819 for trunk/LMDZ.TITAN/libf


Ignore:
Timestamp:
Nov 8, 2017, 4:45:50 PM (7 years ago)
Author:
jvatant
Message:

Commit various bugs leading to negative tracer tendencies
Also deleted some useless cfg files
--JVO

Location:
trunk/LMDZ.TITAN/libf
Files:
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.TITAN/libf/muphytitan/mm_haze.f90

    r1793 r1819  
    743743        IF ((ratio <= 0.9_mm_wp .OR. ratio >= 1.1_mm_wp) .AND. wth(i) /= 0._mm_wp) THEN
    744744          wdt = wth(i)*dt
    745           zcorf(i) = dzb/wdt * (exp(-wdt*log(ratio)/dzb)-1._mm_wp) / (1._mm_wp-ratio)
     745          ! bugfix: max exponential arg to 30)
     746          zcorf(i) = dzb/wdt * (exp(MIN(30._mm_wp,-wdt*log(ratio)/dzb))-1._mm_wp) / (1._mm_wp-ratio)
     747          !zcorf(i) = dzb/wdt * (exp(-wdt*log(ratio)/dzb)-1._mm_wp) / (1._mm_wp-ratio)
    746748        ENDIF
    747749      ENDIF
  • trunk/LMDZ.TITAN/libf/muphytitan/mm_microphysic.f90

    r1793 r1819  
    111111      ! add temporary aerosols tendencies (-> m-3)
    112112      dm0a_f = dm0a_f + zdm0a_f  ; dm3a_f = dm3a_f + zdm3a_f
     113      ! sanity check for clouds tendencies
     114      WHERE (mm_m0ccn+dm0n*mm_dzlev < 0) ; dm0n = -mm_m0ccn/mm_dzlev ; END WHERE
     115      WHERE (mm_m3ccn+dm3n*mm_dzlev < 0) ; dm3n = -mm_m3ccn/mm_dzlev ; END WHERE
     116
    113117      ! reverse directly clouds tendencies (-> m-2)
    114118      dm0n   = dm0n(mm_nla:1:-1) * mm_dzlev(mm_nla:1:-1)
     
    116120      DO i=1,mm_nesp
    117121        dm3i(:,i)  = dm3i(mm_nla:1:-1,i)  * mm_dzlev(mm_nla:1:-1)
    118         dgazs(:,i) = dgazs(mm_nla:1:-1,i) * mm_dzlev(mm_nla:1:-1)
     122        WHERE (mm_m3ccn+dm3n*mm_dzlev < 0) ; dm3n = -mm_m3ccn/mm_dzlev ; END WHERE
     123        dgazs(:,i) = dgazs(mm_nla:1:-1,i)
     124        ! no sanity check for gazs, let's prey.
    119125      ENDDO
    120126    ELSE
    121127      dm0n = 0._mm_wp ; dm3n = 0._mm_wp ; dm3i = 0._mm_wp ; dgazs = 0._mm_wp
    122128    ENDIF
    123     ! multiply by altitude thickness and reverse vectors so they go
    124     ! from ground to top :)
     129    ! sanity check
     130    WHERE (mm_m0aer_s+dm0a_s*mm_dzlev < 0) ; dm0a_s = -mm_m0aer_s/mm_dzlev ; END WHERE
     131    WHERE (mm_m3aer_s+dm3a_f*mm_dzlev < 0) ; dm3a_s = -mm_m3aer_s/mm_dzlev ; END WHERE
     132    WHERE (mm_m0aer_f+dm0a_f*mm_dzlev < 0) ; dm0a_f = -mm_m0aer_f/mm_dzlev ; END WHERE
     133    WHERE (mm_m3aer_f+dm3a_f*mm_dzlev < 0) ; dm3a_f = -mm_m3aer_f/mm_dzlev ; END WHERE
     134
     135    ! multiply by altitude thickness and reverse vectors so they go from ground to top :)
    125136    dm0a_s = dm0a_s(mm_nla:1:-1) * mm_dzlev(mm_nla:1:-1)
    126137    dm3a_s = dm3a_s(mm_nla:1:-1) * mm_dzlev(mm_nla:1:-1)
    127138    dm0a_f = dm0a_f(mm_nla:1:-1) * mm_dzlev(mm_nla:1:-1)
    128139    dm3a_f = dm3a_f(mm_nla:1:-1) * mm_dzlev(mm_nla:1:-1)
     140   
    129141    RETURN
    130142  END FUNCTION muphys_all
     
    155167    ! Calls haze microphysics
    156168    call mm_haze_microphysics(dm0a_s,dm3a_s,dm0a_f,dm3a_f)
     169    ! sanity check
     170    WHERE (mm_m0aer_s+dm0a_s*mm_dzlev < 0) ; dm0a_s = -mm_m0aer_s/mm_dzlev ; END WHERE
     171    WHERE (mm_m3aer_s+dm3a_f*mm_dzlev < 0) ; dm3a_s = -mm_m3aer_s/mm_dzlev ; END WHERE
     172    WHERE (mm_m0aer_f+dm0a_f*mm_dzlev < 0) ; dm0a_f = -mm_m0aer_f/mm_dzlev ; END WHERE
     173    WHERE (mm_m3aer_f+dm3a_f*mm_dzlev < 0) ; dm3a_f = -mm_m3aer_f/mm_dzlev ; END WHERE
    157174    ! reverse vectors so they go from ground to top :)
    158175    dm0a_s = dm0a_s(mm_nla:1:-1) * mm_dzlev(mm_nla:1:-1)
  • trunk/LMDZ.TITAN/libf/muphytitan/mmp_gcm.f90

    r1793 r1819  
    2727    REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE :: c
    2828  END TYPE
     29
     30  !> Size distribution parameters derived type.
     31  !!
     32  !! It stores the parameters of the size distribution law for Titan.
     33  !!
     34  !! The size distribution law is represented by the minimization of a sum of
     35  !! power law functions:
     36  !!
     37  !! $$
     38  !! \displaystyle n\left(r\right) = \frac{A_{0}}{C+\sum_{i=1}^{n} A_{i}\times
     39  !!                                    \left(\frac{r}{r_{c}}\right)^{-b_{i}}}
     40  !! $$
     41  TYPE, PUBLIC :: nprm
     42    !> Scaling factor.
     43    REAL(kind=mm_wp)                            :: a0
     44    !> Characterisitic radius.
     45    REAL(kind=mm_wp)                            :: rc
     46    !> Additional constant to the sum of power law.
     47    REAL(kind=mm_wp)                            :: c
     48    !> Scaling factor of each power law.
     49    REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE :: a
     50    !> Power of each power law.
     51    REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE :: b
     52  END TYPE
     53
    2954  !> Inter-moment relation set of parameters for the spherical mode.
    3055  TYPE(aprm), PUBLIC, SAVE :: mmp_asp
     
    3257  TYPE(aprm), PUBLIC, SAVE :: mmp_afp
    3358
     59  !> Size-distribution law parameters of the spherical mode.
     60  TYPE(nprm), PUBLIC, SAVE :: mmp_pns
     61  !> Size-distribution law parameters of the fractal mode.
     62  TYPE(nprm), PUBLIC, SAVE :: mmp_pnf
     63
    3464  !> Data set for @f$<Q>_{SF}^{M0}@f$.
    3565  TYPE(dset2d), PUBLIC, SAVE, TARGET             :: mmp_qbsf0
    36   !> Extended values of [[mmp_globals(module):mmp_qbsf0(variable)]] dataset.
     66  !> Extended values of [[mmp_gcm(module):mmp_qbsf0(variable)]] dataset.
    3767  REAL(kind=mm_wp), PUBLIC, SAVE, DIMENSION(2,2) :: mmp_qbsf0_e
    3868  !> Data set for @f$<Q>_{SF}^{M3}@f$.
    3969  TYPE(dset2d), PUBLIC, SAVE, TARGET             :: mmp_qbsf3
    40   !> Extended values of [[mmp_globals(module):mmp_qbsf3(variable)]] dataset.
     70  !> Extended values of [[mmp_gcm(module):mmp_qbsf3(variable)]] dataset.
    4171  REAL(kind=mm_wp), PUBLIC, SAVE, DIMENSION(2,2) :: mmp_qbsf3_e
    4272  !> Data set for @f$<Q>_{FF}^{M0}@f$.
    4373  TYPE(dset2d), PUBLIC, SAVE, TARGET             :: mmp_qbff0
    44   !> Extended values of [[mmp_globals(module):mmp_qbff0(variable)]] dataset.
     74  !> Extended values of [[mmp_gcm(module):mmp_qbff0(variable)]] dataset.
    4575  REAL(kind=mm_wp), PUBLIC, SAVE, DIMENSION(2,2) :: mmp_qbff0_e
    4676 
     
    247277    err = read_aprm(cparser,'alpha_f',mmp_afp)
    248278    IF (err /= 0) call abort_program(error("alpha_s: "//TRIM(err%msg),-1))
     279
     280    ! get size-distribution laws parameters
     281    IF (.NOT.cfg_has_section(cparser,'dndr_s')) call abort_program(error("Cannot find [dndr_s] section",-2))
     282    err = read_nprm(cparser,'dndr_s',mmp_pns)
     283    IF (err /= 0) call abort_program(error("dndr_s: "//TRIM(err%msg),-2))
     284    IF (.NOT.cfg_has_section(cparser,'dndr_f')) call abort_program(error("Cannot find [dndr_f] section",-2))
     285    err = read_nprm(cparser,'dndr_f',mmp_pnf)
     286    IF (err /= 0) call abort_program(error("dndr_f: "//TRIM(err%msg),-2))
     287
    249288    ! btk coefficients
    250289    IF (.NOT.cfg_has_section(cparser,'btks')) call abort_program(error("Cannot find [btks] section",-1))
     
    265304
    266305  FUNCTION read_aprm(parser,sec,pp) RESULT(err)
    267     !! Read and store [[mmp_globals(module):aprm(type)]] parameters.
     306    !! Read and store [[mmp_gcm(module):aprm(type)]] parameters.
    268307    TYPE(cfgparser), INTENT(in)  :: parser !! Configuration parser
    269308    CHARACTER(len=*), INTENT(in) :: sec    !! Name of the section that contains the parameters.
    270     TYPE(aprm), INTENT(out)      :: pp     !! [[mmp_globals(module):aprm(type)]] object that stores the parameters values.
     309    TYPE(aprm), INTENT(out)      :: pp     !! [[mmp_gcm(module):aprm(type)]] object that stores the parameters values.
    271310    TYPE(error) :: err                     !! Error status of the function.
    272311    err = cfg_get_value(parser,TRIM(sec)//'/a',pp%a) ; IF (err /= 0) RETURN
     
    278317  END FUNCTION read_aprm
    279318
     319  FUNCTION read_nprm(parser,sec,pp) RESULT(err)
     320    !! Read and store [[mmp_gcm(module):nprm(type)]] parameters.
     321    TYPE(cfgparser), INTENT(in)  :: parser !! Configuration parser
     322    CHARACTER(len=*), INTENT(in) :: sec    !! Name of the section that contains the parameters.
     323    TYPE(nprm), INTENT(out)      :: pp     !! [[mmp_gcm(module):nprm(type)]] object that stores the parameters values.
     324    TYPE(error) :: err                     !! Error status of the function.
     325    err = cfg_get_value(parser,TRIM(sec)//'/rc',pp%rc) ; IF (err /= 0) RETURN
     326    err = cfg_get_value(parser,TRIM(sec)//'/a0',pp%a0) ; IF (err /= 0) RETURN
     327    err = cfg_get_value(parser,TRIM(sec)//'/c',pp%c)   ; IF (err /= 0) RETURN
     328    err = cfg_get_value(parser,TRIM(sec)//'/a',pp%a)   ; IF (err /= 0) RETURN
     329    err = cfg_get_value(parser,TRIM(sec)//'/b',pp%b)   ; IF (err /= 0) RETURN
     330    IF (SIZE(pp%a) /= SIZE(pp%b)) &
     331      err = error("Inconsistent number of coefficients (a and b must have the same size)",3)
     332    RETURN
     333  END FUNCTION read_nprm
     334
    280335END MODULE MMP_GCM
    281336
  • trunk/LMDZ.TITAN/libf/phytitan/calmufi.F90

    r1795 r1819  
    8989    ! Convert tracers to extensive ( except for gazs where we work with molar mass ratio )
    9090    ! We suppose a given order of tracers !
    91     int2ext(:) = ( plev(ilon,2:nlay+1) - plev(ilon,1:nlay) ) / g
     91    int2ext(:) = ( plev(ilon,1:nlay) - plev(ilon,2:nlay+1) ) / g
    9292
    9393    m0as(:) = pq(ilon,:,1) * int2ext(:)
Note: See TracChangeset for help on using the changeset viewer.