Changeset 1681 for trunk/LMDZ.TITAN/libf


Ignore:
Timestamp:
Mar 30, 2017, 4:54:02 PM (8 years ago)
Author:
jvatant
Message:

Update deftank + correct a bug in extrapolation in haze opacity table routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.TITAN/libf/phytitan/disr_haze.F90

    r1672 r1681  
    3030integer             :: i, j, iw, ip, ierr
    3131real*8              :: wln, factw, factp
    32 real*8              :: tmp_p, fact_t, fact_s, fact_c
     32real*8              :: tmp_p, fact_t
    3333integer,parameter   :: nbwl_PL=328, nblev_PL=162
    3434real*8,save         :: ext_PL(nblev_PL,nbwl_PL), ssa_PL(nblev_PL,nbwl_PL)
     
    8282
    8383!----------------- Interpolate values from the hazetable  --------------------
     84if (iw.ne. nbwl_PL) then
     85  factw = (wln-wl_PL(iw)) / (wl_PL(iw+1)-wl_PL(iw))
     86endif
    8487
    85 if(iw.ne.nbwl_PL) then
    86   factw = (wln-wl_PL(iw)) / (wl_PL(iw+1)-wl_PL(iw))
    87 else
    88   factw = 0. ! If we reach the end of the table we keep the last value
    89 endif
    90 if(ip.ne.nblev_PL) then
     88if (ip .ne. nblev_PL) then
    9189  factp = (press-press_PL(ip)) / (press_PL(ip+1)-press_PL(ip))
    92 else
    93   factp=0.
    9490endif
    9591
    9692! Lin-Log interpolation : linear on wln, logarithmic on press
    9793
    98 if ((iw.ne.nbwl_PL).and.(ip.ne.nblev_PL)) then
     94if((ip.ne.nblev_PL) .and. (iw.ne.nbwl_PL)) then
     95
    9996taeros = ( ext_PL(ip,iw)*(1.-factw)   + ext_PL(ip,iw+1)  *factw ) ** (1.-factp) &
    10097        *( ext_PL(ip+1,iw)*(1.-factw) + ext_PL(ip+1,iw+1)*factw ) ** factp
     
    105102cbar   = ( asf_PL(ip,iw)*(1.-factw)   + asf_PL(ip,iw+1)  *factw ) ** (1.-factp) &
    106103        *( asf_PL(ip+1,iw)*(1.-factw) + asf_PL(ip+1,iw+1)*factw ) ** factp
    107 else if ((iw.eq.nbwl_PL).and.(ip.ne.nblev_PL)) then
    108 taeros =  ext_PL(ip,iw) ** (1.-factp) * ext_PL(ip+1,iw) ** factp
    109104
    110 ssa    =  ssa_PL(ip,iw) ** (1.-factp) * ssa_PL(ip+1,iw) ** factp
     105else if ((ip.ne.nblev_PL) .and. (iw.eq.nbwl_PL)) then
    111106
    112 cbar   =  asf_PL(ip,iw) ** (1.-factp) * asf_PL(ip+1,iw) ** factp
     107taeros =  ext_PL(ip,iw)**(1.-factp)  * ext_PL(ip+1,iw)**factp
     108       
     109ssa    =  ssa_PL(ip,iw)**(1.-factp) * ssa_PL(ip+1,iw)**factp
     110       
     111cbar   =  asf_PL(ip,iw)**(1.-factp) * asf_PL(ip+1,iw)**factp
     112
    113113
    114114! In case of vertical extension over the max of the table
    115115! We take the scale height on the last 5 levels (more it's not quite log)
    116116! Arbitray threshold pressure value, just to deal with the last level press=0
     117! We do not touch to ssa and cbar and let them at the value of last level
     118! (extrap would lead to too dark aerosols)
    117119
    118120else if(ip.eq.nblev_PL) then
     
    124126  endif
    125127
    126   if (iw.ne.nbwl_PL) then
    127     fact_t = log10( ( ext_PL(ip,iw)*(1.-factw) + ext_PL(ip,iw+1)  *factw )   &
    128              / ( ext_PL(ip-5,iw)*(1.-factw) + ext_PL(ip-5,iw+1)  *factw ) )
    129     fact_s = log10( ( ssa_PL(ip,iw)*(1.-factw) + ssa_PL(ip,iw+1)  *factw )   &
    130              / ( ssa_PL(ip-5,iw)*(1.-factw) + ssa_PL(ip-5,iw+1)  *factw ) )
    131     fact_c = log10( ( asf_PL(ip,iw)*(1.-factw) + asf_PL(ip,iw+1)  *factw )   &
    132              / ( asf_PL(ip-5,iw)*(1.-factw) + asf_PL(ip-5,iw+1)  *factw ) )
    133   else
    134     fact_t = log10( ext_PL(ip,iw) / ext_PL(ip-5,iw) )
    135     fact_s = log10( ssa_PL(ip,iw) / ssa_PL(ip-5,iw) )
    136     fact_c = log10( asf_PL(ip,iw) / asf_PL(ip-5,iw) )
    137   endif           
     128  if(iw.ne.nbwl_PL) then 
     129
     130     fact_t = log10( ( ext_PL(ip,iw)*(1.-factw) + ext_PL(ip,iw+1)  *factw )   &
     131           / ( ext_PL(ip-5,iw)*(1.-factw) + ext_PL(ip-5,iw+1)  *factw ) )
     132
     133  else if (iw.eq.nbwl_PL) then
     134
     135     fact_t = log10( ext_PL(ip,iw) / ext_PL(ip-5,iw) ) 
     136
     137  endif
    138138
    139139  fact_t = fact_t / log10( press_PL(ip) / press_PL(ip-5) )
    140   fact_s = fact_s / log10( press_PL(ip) / press_PL(ip-5) )
    141   fact_c = fact_c / log10( press_PL(ip) / press_PL(ip-5) )
    142140
    143141  taeros = taeros * ( tmp_p / press_PL(ip) ) ** fact_t
    144   ssa    = ssa    * ( tmp_p / press_PL(ip) ) ** fact_s
    145   cbar   = cbar   * ( tmp_p / press_PL(ip) ) ** fact_c
    146142
    147143endif
Note: See TracChangeset for help on using the changeset viewer.