Ignore:
Timestamp:
Jul 22, 2024, 6:53:44 PM (4 months ago)
Author:
abarral
Message:

Remove CRAY key (obsolete calls to functions that don't exist anymore, bugs in some implementations, irrelevant now)
Replace usage of CPP_XIOS key by using_xios logical
Remove always unused testcpu bits
Replace most uses of CPP_StratAer by the corresponding logical defined in lmdz_cppkeys_wrapper.F90 [this breaks iso compilation because phyiso doesn't define all aerosols - to be fixed later]
Replaces uses of include "yomcst.h" by the lmdz_yomcst.f90 module in .[fF]90 files

Location:
LMDZ6/branches/Amaury_dev
Files:
1 added
46 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/vlsplt.F

    r5082 r5098  
    210210
    211211            DO ij=iip2+1,ip1jm
    212 #ifdef CRAY
    213                dxq(ij,l)=
    214      ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
    215 #else
    216212               IF(dxqu(ij-1)*dxqu(ij)>0) THEN
    217213                  dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
     
    220216                  dxq(ij,l)=0.
    221217               ENDIF
    222 #endif
    223218               dxq(ij,l)=0.5*dxq(ij,l)
    224219               dxq(ij,l)=
     
    274269c   calcul des flux a gauche et a droite
    275270
    276 #ifdef CRAY
    277 
    278       DO l=1,llm
    279        DO ij=iip2,ip1jm-1
    280           zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l,iq),
    281      ,                     1.+u_m(ij,l)/masse(ij+1,l,iq),
    282      ,                     u_m(ij,l))
    283           zdum(ij,l)=0.5*zdum(ij,l)
    284           u_mq(ij,l)=cvmgp(
    285      ,                q(ij,l,iq)+zdum(ij,l)*dxq(ij,l),
    286      ,                q(ij+1,l,iq)-zdum(ij,l)*dxq(ij+1,l),
    287      ,                u_m(ij,l))
    288           u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
    289        ENDDO
    290       ENDDO
    291 #else
    292271c   on cumule le flux correspondant a toutes les mailles dont la masse
    293272c   au travers de la paroi pENDant le pas de temps.
     
    307286       ENDDO
    308287      ENDDO
    309 #endif
    310288
    311289c       go to 9999
     
    883861      INTEGER ifils,iq2 ! CRisi
    884862
    885       LOGICAL testcpu
    886       SAVE testcpu
    887 
    888863#ifdef BIDON
    889864      REAL temps0,temps1,second
    890865      SAVE temps0,temps1
    891866
    892       DATA testcpu/.false./
    893867      DATA temps0,temps1/0.,0./
    894868#endif
     
    899873      !write(*,*) 'vlz 923: entree'
    900874
    901 #ifdef BIDON
    902       IF(testcpu) THEN
    903          temps0=second(0.)
    904       ENDIF
    905 #endif
    906875      DO l=2,llm
    907876         DO ij=1,ip1jmp1
     
    913882      DO l=2,llm-1
    914883         DO ij=1,ip1jmp1
    915 #ifdef CRAY
    916             dzq(ij,l)=0.5*
    917      ,      cvmgp(dzqw(ij,l)+dzqw(ij,l+1),0.,dzqw(ij,l)*dzqw(ij,l+1))
    918 #else
    919884            IF(dzqw(ij,l)*dzqw(ij,l+1)>0.) THEN
    920885                dzq(ij,l)=0.5*(dzqw(ij,l)+dzqw(ij,l+1))
     
    922887                dzq(ij,l)=0.
    923888            ENDIF
    924 #endif
    925889            dzqmax=pente_max*min(adzqw(ij,l),adzqw(ij,l+1))
    926890            dzq(ij,l)=sign(min(abs(dzq(ij,l)),dzqmax),dzq(ij,l))
     
    934898      ENDDO
    935899
    936 #ifdef BIDON
    937       IF(testcpu) THEN
    938          temps1=temps1+second(0.)-temps0
    939       ENDIF
    940 #endif
    941900c ---------------------------------------------------------------
    942901c   .... calcul des termes d'advection verticale  .......
  • LMDZ6/branches/Amaury_dev/libf/dyn3d/vlspltqs.F

    r5082 r5098  
    5555      REAL temps1,temps2,temps3
    5656      REAL zzpbar, zzw
    57       LOGICAL testcpu
    58       SAVE testcpu
    5957      SAVE temps1,temps2,temps3
    6058
    6159      REAL qmin,qmax
    6260      DATA qmin,qmax/0.,1.e33/
    63       DATA testcpu/.false./
    6461      DATA temps1,temps2,temps3/0.,0.,0./
    6562
     
    220217      INTEGER ifils,iq2 ! CRisi
    221218
    222       Logical first,testcpu
    223       SAVE first,testcpu
     219      Logical first
     220      SAVE first
    224221
    225222      REAL      SSUM
     
    228225
    229226
    230       DATA first,testcpu/.true.,.false./
     227      DATA first/.true./
    231228
    232229      IF(first) THEN
     
    278275
    279276            DO ij=iip2+1,ip1jm
    280 #ifdef CRAY
    281                dxq(ij,l)=
    282      ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
    283 #else
    284277               IF(dxqu(ij-1)*dxqu(ij)>0) THEN
    285278                  dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
     
    288281                  dxq(ij,l)=0.
    289282               ENDIF
    290 #endif
    291283               dxq(ij,l)=0.5*dxq(ij,l)
    292284               dxq(ij,l)=
     
    341333c   calcul des flux a gauche et a droite
    342334
    343 #ifdef CRAY
    344 c--pas encore modification sur Qsat
    345       DO l=1,llm
    346        DO ij=iip2,ip1jm-1
    347           zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l,iq),
    348      ,                     1.+u_m(ij,l)/masse(ij+1,l,iq),
    349      ,                     u_m(ij,l))
    350           zdum(ij,l)=0.5*zdum(ij,l)
    351           u_mq(ij,l)=cvmgp(
    352      ,                q(ij,l,iq)+zdum(ij,l)*dxq(ij,l),
    353      ,                q(ij+1,l,iq)-zdum(ij,l)*dxq(ij+1,l),
    354      ,                u_m(ij,l))
    355           u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
    356        ENDDO
    357       ENDDO
    358 #else
    359335c   on cumule le flux correspondant a toutes les mailles dont la masse
    360336c   au travers de la paroi pENDant le pas de temps.
     
    373349       ENDDO
    374350      ENDDO
    375 #endif
    376351
    377352
     
    581556      REAL qpns,qpsn,dyn1,dys1,dyn2,dys2,newmasse,fn,fs
    582557c     REAL newq,oldmasse
    583       Logical first,testcpu
     558      Logical first
    584559      REAL temps0,temps1,temps2,temps3,temps4,temps5
    585560      SAVE temps0,temps1,temps2,temps3,temps4,temps5
    586       SAVE first,testcpu
     561      SAVE first
    587562
    588563      REAL convpn,convps,convmpn,convmps
     
    598573      REAL      SSUM
    599574
    600       DATA first,testcpu/.true.,.false./
     575      DATA first/.true./
    601576      DATA temps0,temps1,temps2,temps3,temps4,temps5/0.,0.,0.,0.,0.,0./
    602577
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/advn.F

    r5082 r5098  
    3131      REAL w(ip1jmp1,llm),pdt
    3232c
    33 c      Local 
     33c      Local
    3434c   ---------
    3535c
     
    4747      real zqh(ip1jmp1,llm),zqb(ip1jmp1,llm)
    4848      real temps0,temps1,temps2,temps3
    49       real ztemps1,ztemps2,ztemps3,ssum
    50       logical testcpu
    51       save testcpu
     49      real ztemps1,ztemps2,ssum
    5250      save temps1,temps2,temps3
    5351      real zzpbar,zzw
    5452
    55 #ifdef CRAY
    56       real second
    57 #endif
    58 
    5953      real qmin,qmax
    6054      data qmin,qmax/0.,1./
    61       data testcpu/.false./
    6255      data temps1,temps2,temps3/0.,0.,0./
    6356
     
    120113c     call minmaxq(zq,qmin,qmax,'apres vlx     ')
    121114
    122 #ifdef CRAY
    123       if(testcpu) then
    124          ztemps1=second(0.)
    125          temps1=temps1+ztemps1-ztemps2
    126             print*,'VLSPLT X:',temps1,'   Y:',temps2,'   Z:',temps3
    127       endif
    128 #endif
    129115      do l=1,llm
    130116         do ij=1,ip1jmp1
     
    155141      real q(ip1jmp1,llm),qg(ip1jmp1,llm),qd(ip1jmp1,llm)
    156142c
    157 c      Local 
     143c      Local
    158144c   ---------
    159145c
     
    272258      real q(ip1jmp1,llm),qs(ip1jmp1,llm),qn(ip1jmp1,llm)
    273259c
    274 c      Local 
     260c      Local
    275261c   ---------
    276262c
     
    368354      real q(ip1jmp1,llm),qh(ip1jmp1,llm),qb(ip1jmp1,llm)
    369355c
    370 c      Local 
     356c      Local
    371357c   ---------
    372358c
     
    493479      real q(ip1jmp1,llm),qd(ip1jmp1,llm),qg(ip1jmp1,llm)
    494480c
    495 c      Local 
     481c      Local
    496482c   ---------
    497483c
     
    510496      save prec
    511497
    512 #ifdef CRAY
    513       data prec/1.e-24/
    514 #else
    515498      data prec/1.e-15/
    516 #endif
    517499
    518500      do l=1,llm
     
    573555                 u_mq(ij,l)=
    574556     s           sign(zm,u_m(ij,l))*(zsigp*zqp+(zsig-zsigp)*zqm)
    575              endif 
     557             endif
    576558          else
    577559             if (zsig<=zsigp) then
     
    703685            endif
    704686         enddo
    705       endif  ! n0.gt.0 
     687      endif  ! n0.gt.0
    706688
    707689c   bouclage en latitude
     
    758740      real q(ip1jmp1,llm),qn(ip1jmp1,llm),qs(ip1jmp1,llm)
    759741c
    760 c      Local 
     742c      Local
    761743c   ---------
    762744c
     
    772754      save prec
    773755
    774 #ifdef CRAY
    775       data prec/1.e-24/
    776 #else
    777756      data prec/1.e-15/
    778 #endif
    779757      do l=1,llm
    780758            do ij=1,ip1jmp1
     
    825803          else
    826804              zz=0.5*(zsig-zsigp)/zsigm
    827               v_mq(ij,l)=sign(zm,v_m(ij,l))*( 0.5*(zq+zqp)*zsigp 
     805              v_mq(ij,l)=sign(zm,v_m(ij,l))*( 0.5*(zq+zqp)*zsigp
    828806     s        +(zsig-zsigp)*(zq+zz*(zqm-zq)) )
    829807          endif
     
    890868
    891869c
    892 c      Local 
     870c      Local
    893871c   ---------
    894872c
     
    902880      save prec
    903881
    904 #ifdef CRAY
    905       data prec/1.e-24/
    906 #else
    907882      data prec/1.e-13/
    908 #endif
    909883
    910884      do l=1,llm
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/infotrac.F90

    r5091 r5098  
    33MODULE infotrac
    44
    5    USE       strings_mod, ONLY: msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse
    6    USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, tracers, setGeneration, itZonIso, nzone, tran0, isoZone, &
    7         delPhase, niso, getKey, isot_type, processIsotopes, isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
    8         addPhase, iH2O, addKey, isoSelect, testTracersFiles, isoKeys, indexUpdate, iqWIsoPha, nbIso, ntiso, isoName, isoCheck
    9    IMPLICIT NONE
    10 
    11    PRIVATE
    12 
    13    !=== FOR TRACERS:
    14    PUBLIC :: init_infotrac                                 !--- Initialization of the tracers
    15    PUBLIC :: tracers, type_trac                            !--- Full tracers database, tracers type keyword
    16    PUBLIC :: nqtot,   nbtr,   nqo,   nqCO2,  nqtottr      !--- Main dimensions
    17    PUBLIC :: conv_flg, pbl_flg                             !--- Convection & boundary layer activation keys
    18 
    19    !=== FOR ISOTOPES: General
    20    PUBLIC :: isot_type, nbIso                              !--- Derived type, full isotopes families database + nb of families
    21    PUBLIC :: isoSelect, ixIso                              !--- Isotopes family selection tool + selected family index
    22    !=== FOR ISOTOPES: Specific to water
    23    PUBLIC :: iH2O                                          !--- H2O isotopes class index
    24    PUBLIC :: min_qParent, min_qMass, min_ratio             !--- Min. values for various isotopic quantities
    25    !=== FOR ISOTOPES: Depending on the selected isotopes family
    26    PUBLIC :: isotope, isoKeys                              !--- Selected isotopes database + associated keys (cf. getKey)
    27    PUBLIC :: isoName, isoZone, isoPhas                     !--- Isotopes and tagging zones names, phases
    28    PUBLIC :: niso,    nzone,   nphas,  ntiso              !---  " " numbers + isotopes & tagging tracers number
    29    PUBLIC :: itZonIso                                      !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
    30    PUBLIC :: iqIsoPha                                      !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
    31    PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
    32    !=== FOR BOTH TRACERS AND ISOTOPES
    33    PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
    34 
    35 !=== CONVENTIONS FOR TRACERS NUMBERS:
    36 !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
    37 !  | water in different |    water tagging      |  water isotopes | other tracers | additional tracers moments |
    38 !  | phases: H2O_[gls]  |      isotopes         |                 |               |  for higher order schemes  |
    39 !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
    40 !  |                    |                       |                 |               |                            |
    41 !  |<--     nqo      -->|<-- nqo*niso* nzone -->|<-- nqo*niso  -->|<--  nbtr   -->|<--        (nmom)        -->|         
    42 !  |                    |                                         |                                            |
    43 !  |                    |<-- nqo*niso*(nzone+1)  =   nqo*ntiso -->|<--    nqtottr = nbtr + nmom             -->|
    44 !  |                                                                              = nqtot - nqo*(ntiso+1)      |
    45 !  |                                                                                                           |
    46 !  |<--                        nqtrue  =  nbtr + nqo*(ntiso+1)                 -->|                            |
    47 !  |                                                                                                           |
    48 !  |<--                        nqtot   =  nqtrue + nmom                                                     -->|
    49 !  |                                                                                                           |
    50 !  |-----------------------------------------------------------------------------------------------------------|
    51 !  NOTES FOR THIS TABLE:
    52 !  * Used "niso", "nzone" and "ntiso" are components of "isotopes(ip)" for water (isotopes(ip)%parent == 'H2O'),
    53 !    since water is so far the sole tracers family, except passive CO2, removed from the main tracers table.
    54 !  * For water, "nqo" is equal to the more general field "isotopes(ip)%nphas".
    55 !  * "niso", "nzone", "ntiso", "nphas" are defined for other isotopic tracers families, if any.
    56 !
    57 !=== DERIVED TYPE EMBEDDING MOST OF THE TRACERS-RELATED QUANTITIES (LENGTH: nqtot)
    58 !    Each entry is accessible using "%" sign.
    59 !  |-------------+------------------------------------------------------+-------------+------------------------+
    60 !  |  entry      | Meaning                                              | Former name | Possible values        |
    61 !  |-------------+------------------------------------------------------+-------------+------------------------+
    62 !  | name        | Name (short)                                         | tname       |                        |
    63 !  | gen0Name    | Name of the 1st generation ancestor                  | /           |                        |
    64 !  | parent      | Name of the parent                                   | /           |                        |
    65 !  | longName    | Long name (with adv. scheme suffix) for outputs      | ttext       |                        |
    66 !  | type        | Type (so far: tracer or tag)                         | /           | tracer,tag             |
    67 !  | phase       | Phases list ("g"as / "l"iquid / "s"olid)             | /           | [g][l][s]              |
    68 !  | component   | Name(s) of the merged/cumulated section(s)           | /           | coma-separated names   |
    69 !  | iGeneration | Generation (>=1)                                     | /           |                        |
    70 !  | iqParent    | Index of the parent tracer                           | iqpere      | 1:nqtot                |
    71 !  | iqDescen    | Indexes of the childs       (all generations)        | iqfils      | 1:nqtot                |
    72 !  | nqDescen    | Number of the descendants   (all generations)        | nqdesc      | 1:nqtot                |
    73 !  | nqChildren  | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
    74 !  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
    75 !  | iadv        | Advection scheme number                              | iadv        | 1,2,10-20(exc.15,19),30|
    76 !  | isAdvected  | advected tracers flag (.TRUE. if iadv >= 0)          | /           | nqtrue  .TRUE. values  |
    77 !  | isInPhysics | tracers not extracted from the main table in physics | /           | nqtottr .TRUE. values  |
    78 !  | iso_iGroup  | Isotopes group index in isotopes(:)                  | /           | 1:nbIso                |
    79 !  | iso_iName   | Isotope  name  index in isotopes(iso_iGroup)%trac(:) | iso_indnum  | 1:niso                 |
    80 !  | iso_iZone   | Isotope  zone  index in isotopes(iso_iGroup)%zone(:) | zone_num    | 1:nzone                |
    81 !  | iso_iPhas   | Isotope  phase index in isotopes(iso_iGroup)%phas(:) | phase_num   | 1:nphas                |
    82 !  +-------------+------------------------------------------------------+-------------+------------------------+
    83 !
    84 !=== DERIVED TYPE EMBEDDING MOST OF THE ISOTOPES-RELATED QUANTITIES (LENGTH: nbIso, NUMBER OF ISOTOPES FAMILIES)
    85 !    Each entry is accessible using "%" sign.
    86 !  |-----------------+--------------------------------------------------+--------------------+-----------------+
    87 !  |  entry | length | Meaning                                          |    Former name     | Possible values |
    88 !  |-----------------+--------------------------------------------------+--------------------+-----------------+
    89 !  | parent          | Parent tracer (isotopes family name)             |                    |                 |
    90 !  | keys   | niso   | Isotopes keys/values pairs list + number         |                    |                 |
    91 !  | trac   | ntiso  | Isotopes + tagging tracers list + number         | / | ntraciso       |                 |
    92 !  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
    93 !  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
    94 !  | iqIsoPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
    95 !  | itZonIso        | Index in "trac(1:ntiso)"= f(zone, name(1:niso))  | index_trac         | 1:ntiso         |
    96 !  +-----------------+--------------------------------------------------+--------------------+-----------------+
    97 
    98    REAL, PARAMETER :: min_qParent = 1.e-30, min_qMass = 1.e-18, min_ratio = 1.e-16 ! MVals et CRisi
    99 
    100    !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES
    101    INTEGER,               SAVE :: nqtot, &                     !--- Tracers nb in dynamics (incl. higher moments + H2O)
    102                                   nbtr,  &                     !--- Tracers nb in physics  (excl. higher moments + H2O)
    103                                   nqo,    &                     !--- Number of water phases
    104                                   nqtottr, &                    !--- Number of tracers passed to phytrac (TO BE DELETED ?)
    105                                   nqCO2                         !--- Number of tracers of CO2  (ThL)
    106    CHARACTER(LEN=maxlen), SAVE :: type_trac                     !--- Keyword for tracers type
    107 
    108    !=== VARIABLES FOR INCA
    109    INTEGER,              SAVE, ALLOCATABLE :: conv_flg(:), &   !--- Convection     activation ; needed for INCA        (nbtr)
    110                                                 pbl_flg(:)      !--- Boundary layer activation ; needed for INCA        (nbtr)
     5  USE       strings_mod, ONLY : msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse
     6  USE readTracFiles_mod, ONLY : trac_type, readTracersFiles, tracers, setGeneration, itZonIso, nzone, tran0, isoZone, &
     7          delPhase, niso, getKey, isot_type, processIsotopes, isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
     8          addPhase, iH2O, addKey, isoSelect, testTracersFiles, isoKeys, indexUpdate, iqWIsoPha, nbIso, ntiso, isoName, isoCheck
     9  IMPLICIT NONE
     10
     11  PRIVATE
     12
     13  !=== FOR TRACERS:
     14  PUBLIC :: init_infotrac                                 !--- Initialization of the tracers
     15  PUBLIC :: tracers, type_trac                            !--- Full tracers database, tracers type keyword
     16  PUBLIC :: nqtot, nbtr, nqo, nqCO2, nqtottr      !--- Main dimensions
     17  PUBLIC :: conv_flg, pbl_flg                             !--- Convection & boundary layer activation keys
     18
     19  !=== FOR ISOTOPES: General
     20  PUBLIC :: isot_type, nbIso                              !--- Derived type, full isotopes families database + nb of families
     21  PUBLIC :: isoSelect, ixIso                              !--- Isotopes family selection tool + selected family index
     22  !=== FOR ISOTOPES: Specific to water
     23  PUBLIC :: iH2O                                          !--- H2O isotopes class index
     24  PUBLIC :: min_qParent, min_qMass, min_ratio             !--- Min. values for various isotopic quantities
     25  !=== FOR ISOTOPES: Depending on the selected isotopes family
     26  PUBLIC :: isotope, isoKeys                              !--- Selected isotopes database + associated keys (cf. getKey)
     27  PUBLIC :: isoName, isoZone, isoPhas                     !--- Isotopes and tagging zones names, phases
     28  PUBLIC :: niso, nzone, nphas, ntiso              !---  " " numbers + isotopes & tagging tracers number
     29  PUBLIC :: itZonIso                                      !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
     30  PUBLIC :: iqIsoPha                                      !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
     31  PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
     32  !=== FOR BOTH TRACERS AND ISOTOPES
     33  PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
     34
     35  !=== CONVENTIONS FOR TRACERS NUMBERS:
     36  !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
     37  !  | water in different |    water tagging      |  water isotopes | other tracers | additional tracers moments |
     38  !  | phases: H2O_[gls]  |      isotopes         |                 |               |  for higher order schemes  |
     39  !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
     40  !  |                    |                       |                 |               |                            |
     41  !  |<--     nqo      -->|<-- nqo*niso* nzone -->|<-- nqo*niso  -->|<--  nbtr   -->|<--        (nmom)        -->|
     42  !  |                    |                                         |                                            |
     43  !  |                    |<-- nqo*niso*(nzone+1)  =   nqo*ntiso -->|<--    nqtottr = nbtr + nmom             -->|
     44  !  |                                                                              = nqtot - nqo*(ntiso+1)      |
     45  !  |                                                                                                           |
     46  !  |<--                        nqtrue  =  nbtr + nqo*(ntiso+1)                 -->|                            |
     47  !  |                                                                                                           |
     48  !  |<--                        nqtot   =  nqtrue + nmom                                                     -->|
     49  !  |                                                                                                           |
     50  !  |-----------------------------------------------------------------------------------------------------------|
     51  !  NOTES FOR THIS TABLE:
     52  !  * Used "niso", "nzone" and "ntiso" are components of "isotopes(ip)" for water (isotopes(ip)%parent == 'H2O'),
     53  !    since water is so far the sole tracers family, except passive CO2, removed from the main tracers table.
     54  !  * For water, "nqo" is equal to the more general field "isotopes(ip)%nphas".
     55  !  * "niso", "nzone", "ntiso", "nphas" are defined for other isotopic tracers families, if any.
     56  !
     57  !=== DERIVED TYPE EMBEDDING MOST OF THE TRACERS-RELATED QUANTITIES (LENGTH: nqtot)
     58  !    Each entry is accessible using "%" sign.
     59  !  |-------------+------------------------------------------------------+-------------+------------------------+
     60  !  |  entry      | Meaning                                              | Former name | Possible values        |
     61  !  |-------------+------------------------------------------------------+-------------+------------------------+
     62  !  | name        | Name (short)                                         | tname       |                        |
     63  !  | gen0Name    | Name of the 1st generation ancestor                  | /           |                        |
     64  !  | parent      | Name of the parent                                   | /           |                        |
     65  !  | longName    | Long name (with adv. scheme suffix) for outputs      | ttext       |                        |
     66  !  | type        | Type (so far: tracer or tag)                         | /           | tracer,tag             |
     67  !  | phase       | Phases list ("g"as / "l"iquid / "s"olid)             | /           | [g][l][s]              |
     68  !  | component   | Name(s) of the merged/cumulated section(s)           | /           | coma-separated names   |
     69  !  | iGeneration | Generation (>=1)                                     | /           |                        |
     70  !  | iqParent    | Index of the parent tracer                           | iqpere      | 1:nqtot                |
     71  !  | iqDescen    | Indexes of the childs       (all generations)        | iqfils      | 1:nqtot                |
     72  !  | nqDescen    | Number of the descendants   (all generations)        | nqdesc      | 1:nqtot                |
     73  !  | nqChildren  | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
     74  !  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
     75  !  | iadv        | Advection scheme number                              | iadv        | 1,2,10-20(exc.15,19),30|
     76  !  | isAdvected  | advected tracers flag (.TRUE. if iadv >= 0)          | /           | nqtrue  .TRUE. values  |
     77  !  | isInPhysics | tracers not extracted from the main table in physics | /           | nqtottr .TRUE. values  |
     78  !  | iso_iGroup  | Isotopes group index in isotopes(:)                  | /           | 1:nbIso                |
     79  !  | iso_iName   | Isotope  name  index in isotopes(iso_iGroup)%trac(:) | iso_indnum  | 1:niso                 |
     80  !  | iso_iZone   | Isotope  zone  index in isotopes(iso_iGroup)%zone(:) | zone_num    | 1:nzone                |
     81  !  | iso_iPhas   | Isotope  phase index in isotopes(iso_iGroup)%phas(:) | phase_num   | 1:nphas                |
     82  !  +-------------+------------------------------------------------------+-------------+------------------------+
     83  !
     84  !=== DERIVED TYPE EMBEDDING MOST OF THE ISOTOPES-RELATED QUANTITIES (LENGTH: nbIso, NUMBER OF ISOTOPES FAMILIES)
     85  !    Each entry is accessible using "%" sign.
     86  !  |-----------------+--------------------------------------------------+--------------------+-----------------+
     87  !  |  entry | length | Meaning                                          |    Former name     | Possible values |
     88  !  |-----------------+--------------------------------------------------+--------------------+-----------------+
     89  !  | parent          | Parent tracer (isotopes family name)             |                    |                 |
     90  !  | keys   | niso   | Isotopes keys/values pairs list + number         |                    |                 |
     91  !  | trac   | ntiso  | Isotopes + tagging tracers list + number         | / | ntraciso       |                 |
     92  !  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
     93  !  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
     94  !  | iqIsoPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
     95  !  | itZonIso        | Index in "trac(1:ntiso)"= f(zone, name(1:niso))  | index_trac         | 1:ntiso         |
     96  !  +-----------------+--------------------------------------------------+--------------------+-----------------+
     97
     98  REAL, PARAMETER :: min_qParent = 1.e-30, min_qMass = 1.e-18, min_ratio = 1.e-16 ! MVals et CRisi
     99
     100  !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES
     101  INTEGER, SAVE :: nqtot, &                     !--- Tracers nb in dynamics (incl. higher moments + H2O)
     102          nbtr, &                     !--- Tracers nb in physics  (excl. higher moments + H2O)
     103          nqo, &                     !--- Number of water phases
     104          nqtottr, &                    !--- Number of tracers passed to phytrac (TO BE DELETED ?)
     105          nqCO2                         !--- Number of tracers of CO2  (ThL)
     106  CHARACTER(LEN = maxlen), SAVE :: type_trac                     !--- Keyword for tracers type
     107
     108  !=== VARIABLES FOR INCA
     109  INTEGER, SAVE, ALLOCATABLE :: conv_flg(:), &   !--- Convection     activation ; needed for INCA        (nbtr)
     110          pbl_flg(:)      !--- Boundary layer activation ; needed for INCA        (nbtr)
    111111
    112112CONTAINS
    113113
    114 SUBROUTINE init_infotrac
    115    USE control_mod, ONLY: planet_type
     114  SUBROUTINE init_infotrac
     115    USE control_mod, ONLY : planet_type
    116116#ifdef REPROBUS
    117117   USE CHEM_REP,    ONLY: Init_chem_rep_trac
    118118#endif
    119    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    120    IMPLICIT NONE
    121 !==============================================================================================================================
    122 !
    123 !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
    124 !   -------
    125 !
    126 !   Modifications:
    127 !   --------------
    128 !   05/94: F.Forget      Modif special traceur
    129 !   02/02: M-A Filiberti Lecture de traceur.def
    130 !   01/22: D. Cugnet     Nouveaux tracer.def et tracer_*.def + encapsulation (types trac_type et isot_type)
    131 !
    132 !   Objet:
    133 !   ------
    134 !   GCM LMD nouvelle grille
    135 !
    136 !==============================================================================================================================
    137 !   ... modification de l'integration de q ( 26/04/94 ) ....
    138 !------------------------------------------------------------------------------------------------------------------------------
    139 ! Declarations:
    140    INCLUDE "dimensions.h"
    141    INCLUDE "iniprint.h"
    142 
    143 !------------------------------------------------------------------------------------------------------------------------------
    144 ! Local variables
    145    INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
    146    INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
    147                            vad (:), vadv_inca(:), pbl_flg_inca(:)
    148    CHARACTER(LEN=8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
    149    INTEGER :: nqINCA
    150    CHARACTER(LEN=2)      ::  suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
    151    CHARACTER(LEN=3)      :: descrq(30)                               !--- Advection scheme description tags
    152    CHARACTER(LEN=maxlen) :: msg1, texp, ttp                          !--- Strings for messages and expanded tracers type
    153    INTEGER :: fType                                                  !--- Tracers description file type ; 0: none
    154                                                                      !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def"
    155    INTEGER :: nqtrue                                                 !--- Tracers nb from tracer.def (no higher order moments)
    156    INTEGER :: iad                                                    !--- Advection scheme number
    157    INTEGER :: iq, jq, nt, im, nm                                     !--- Indexes and temporary variables
    158    LOGICAL :: lerr, ll
    159    TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:)
    160    TYPE(trac_type), POINTER            :: t1, t(:)
    161    CHARACTER(LEN=maxlen),  ALLOCATABLE :: types_trac(:)  !--- Keyword for tracers type(s), parsed version
    162 
    163    CHARACTER(LEN=*), PARAMETER :: modname="init_infotrac"
    164 !------------------------------------------------------------------------------------------------------------------------------
    165 ! Initialization :
    166 !------------------------------------------------------------------------------------------------------------------------------
    167    suff          = ['x ','y ','z ','xx','xy','xz','yy','yz','zz']
    168    descrq( 1:30) = '   '
    169    descrq( 1: 2) = ['LMV','BAK']
    170    descrq(10:20) = ['VL1','VLP','FH1','FH2','VLH','   ','PPM','PPS','PPP','   ','SLP']
    171    descrq(30)    = 'PRA'
    172    
    173    CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname)
    174 
    175    lerr=strParse(type_trac, '|', types_trac, n=nt)
    176    IF (nt > 1) THEN
     119    USE lmdz_cppkeys_wrapper, ONLY : CPPKEY_INCA, CPPKEY_STRATAER
     120    IMPLICIT NONE
     121    !==============================================================================================================================
     122    !
     123    !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
     124    !   -------
     125    !
     126    !   Modifications:
     127    !   --------------
     128    !   05/94: F.Forget      Modif special traceur
     129    !   02/02: M-A Filiberti Lecture de traceur.def
     130    !   01/22: D. Cugnet     Nouveaux tracer.def et tracer_*.def + encapsulation (types trac_type et isot_type)
     131    !
     132    !   Objet:
     133    !   ------
     134    !   GCM LMD nouvelle grille
     135    !
     136    !==============================================================================================================================
     137    !   ... modification de l'integration de q ( 26/04/94 ) ....
     138    !------------------------------------------------------------------------------------------------------------------------------
     139    ! Declarations:
     140    INCLUDE "dimensions.h"
     141    INCLUDE "iniprint.h"
     142
     143    !------------------------------------------------------------------------------------------------------------------------------
     144    ! Local variables
     145    INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
     146    INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
     147            vad (:), vadv_inca(:), pbl_flg_inca(:)
     148    CHARACTER(LEN = 8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
     149    INTEGER :: nqINCA
     150    CHARACTER(LEN = 2) :: suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
     151    CHARACTER(LEN = 3) :: descrq(30)                               !--- Advection scheme description tags
     152    CHARACTER(LEN = maxlen) :: msg1, texp, ttp                          !--- Strings for messages and expanded tracers type
     153    INTEGER :: fType                                                  !--- Tracers description file type ; 0: none
     154    !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def"
     155    INTEGER :: nqtrue                                                 !--- Tracers nb from tracer.def (no higher order moments)
     156    INTEGER :: iad                                                    !--- Advection scheme number
     157    INTEGER :: iq, jq, nt, im, nm                                     !--- Indexes and temporary variables
     158    LOGICAL :: lerr, ll
     159    TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:)
     160    TYPE(trac_type), POINTER :: t1, t(:)
     161    CHARACTER(LEN = maxlen), ALLOCATABLE :: types_trac(:)  !--- Keyword for tracers type(s), parsed version
     162
     163    CHARACTER(LEN = *), PARAMETER :: modname = "init_infotrac"
     164    !------------------------------------------------------------------------------------------------------------------------------
     165    ! Initialization :
     166    !------------------------------------------------------------------------------------------------------------------------------
     167    suff = ['x ', 'y ', 'z ', 'xx', 'xy', 'xz', 'yy', 'yz', 'zz']
     168    descrq(1:30) = '   '
     169    descrq(1:2) = ['LMV', 'BAK']
     170    descrq(10:20) = ['VL1', 'VLP', 'FH1', 'FH2', 'VLH', '   ', 'PPM', 'PPS', 'PPP', '   ', 'SLP']
     171    descrq(30) = 'PRA'
     172
     173    CALL msg('type_trac = "' // TRIM(type_trac) // '"', modname)
     174
     175    lerr = strParse(type_trac, '|', types_trac, n = nt)
     176    IF (nt > 1) THEN
    177177      IF (nt > 2) CALL abort_gcm(modname, 'you need to modify type_trac, this version is not supported by lmdz', 1)
    178       if (nt == 2) type_trac=types_trac(2)
    179    ENDIF
    180 
    181 
    182    
    183    !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
    184    msg1 = 'For type_trac = "'//TRIM(type_trac)//'":'
    185    SELECT CASE(type_trac)
    186       CASE('inca'); CALL msg(TRIM(msg1)//' coupling with INCA chemistry model',        modname)
    187       CASE('inco'); CALL msg(TRIM(msg1)//' coupling jointly with INCA and CO2 cycle', modname)
    188       CASE('repr'); CALL msg(TRIM(msg1)//' coupling with REPROBUS chemistry model',    modname)
    189       CASE('co2i'); CALL msg(TRIM(msg1)//' you have chosen to run with CO2 cycle',    modname)
    190       CASE('coag'); CALL msg(TRIM(msg1)//' tracers are treated for COAGULATION tests', modname)
    191       CASE('lmdz'); CALL msg(TRIM(msg1)//' tracers are treated in LMDZ only',          modname)
    192       CASE DEFAULT; CALL abort_gcm(modname,'type_trac='//TRIM(type_trac)//' not possible yet.',1)
    193    END SELECT
    194 
    195    !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
    196    SELECT CASE(type_trac)
    197       CASE('inca', 'inco')
     178      if (nt == 2) type_trac = types_trac(2)
     179    ENDIF
     180
     181
     182
     183    !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
     184    msg1 = 'For type_trac = "' // TRIM(type_trac) // '":'
     185    SELECT CASE(type_trac)
     186    CASE('inca'); CALL msg(TRIM(msg1) // ' coupling with INCA chemistry model', modname)
     187    CASE('inco'); CALL msg(TRIM(msg1) // ' coupling jointly with INCA and CO2 cycle', modname)
     188    CASE('repr'); CALL msg(TRIM(msg1) // ' coupling with REPROBUS chemistry model', modname)
     189    CASE('co2i'); CALL msg(TRIM(msg1) // ' you have chosen to run with CO2 cycle', modname)
     190    CASE('coag'); CALL msg(TRIM(msg1) // ' tracers are treated for COAGULATION tests', modname)
     191    CASE('lmdz'); CALL msg(TRIM(msg1) // ' tracers are treated in LMDZ only', modname)
     192    CASE DEFAULT; CALL abort_gcm(modname, 'type_trac=' // TRIM(type_trac) // ' not possible yet.', 1)
     193    END SELECT
     194
     195    !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
     196    SELECT CASE(type_trac)
     197    CASE('inca', 'inco')
    198198      IF (CPPKEY_INCA) THEN
    199          CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code', 1)
     199        CALL abort_gcm(modname, 'You must add cpp key INCA and compile with INCA code', 1)
    200200      END IF
    201       CASE('repr')
     201    CASE('repr')
    202202#ifndef REPROBUS
    203          CALL abort_gcm(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
     203      CALL abort_gcm(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
    204204#endif
    205       CASE('coag')
    206 #ifndef CPP_StratAer
    207          CALL abort_gcm(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
    208 #endif
    209    END SELECT
    210 
    211    nqCO2 = COUNT( [type_trac == 'inco', type_trac == 'co2i'] )
    212 
    213 !==============================================================================================================================
    214 ! 1) Get the numbers of: true (first order only) tracers "nqtrue", water tracers "nqo" (vapor/liquid/solid)
    215 !==============================================================================================================================
    216    texp = type_trac                                                  !=== EXPANDED VERSION OF "type_trac", WITH "|" SEPARATOR
    217    IF(texp == 'inco') texp = 'co2i|inca'
    218    IF(texp /= 'lmdz') texp = 'lmdz|'//TRIM(texp)
    219 
    220    !=== DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE
    221    IF(testTracersFiles(modname, texp, fType, .TRUE.)) CALL abort_gcm(modname, 'problem with tracers file(s)',1)
    222    ttp = type_trac; IF(fType /= 1) ttp = texp
    223 
    224    IF(readTracersFiles(ttp, lRepr=type_trac=='repr')) CALL abort_gcm(modname, 'problem with tracers file(s)',1)
    225    !---------------------------------------------------------------------------------------------------------------------------
    226    IF(fType == 0) CALL abort_gcm(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.',1)
    227    !---------------------------------------------------------------------------------------------------------------------------
    228    IF(fType == 1 .AND. ANY(['inca','inco']==type_trac)) THEN         !=== FOUND OLD STYLE INCA "traceur.def"
    229    !---------------------------------------------------------------------------------------------------------------------------
    230    IF (CPPKEY_INCA) THEN
    231       nqo = SIZE(tracers) - nqCO2
    232       CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
    233       nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
    234       nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
    235       IF(ALL([2,3] /= nqo)) CALL abort_gcm(modname, 'Only 2 or 3 water phases allowed ; found nqo='//TRIM(int2str(nqo)), 1)
    236       ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
    237       ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA), pbl_flg_inca(nqINCA))
    238       CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
    239       ALLOCATE(ttr(nqtrue))
    240       ttr(1:nqo+nqCO2)                  = tracers
    241       ttr(1    :      nqo   )%component = 'lmdz'
    242       ttr(1+nqo:nqCO2+nqo   )%component = 'co2i'
    243       ttr(1+nqo+nqCO2:nqtrue)%component = 'inca'
    244       ttr(1+nqo      :nqtrue)%name      = [('CO2     ', iq=1, nqCO2), solsym_inca]
    245       ttr(1+nqo+nqCO2:nqtrue)%parent    = tran0
    246       ttr(1+nqo+nqCO2:nqtrue)%phase    = 'g'
    247       lerr = getKey('hadv', had, ky=tracers(:)%keys)
    248       lerr = getKey('vadv', vad, ky=tracers(:)%keys)
    249       hadv(1:nqo+nqCO2) = had(:); hadv(1+nqo+nqCO2:nqtrue) = hadv_inca
    250       vadv(1:nqo+nqCO2) = vad(:); vadv(1+nqo+nqCO2:nqtrue) = vadv_inca
    251       CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
    252       DO iq = 1, nqtrue
    253          t1 => tracers(iq)
    254          CALL addKey('name',      t1%name,      t1%keys)
    255          CALL addKey('component', t1%component, t1%keys)
    256          CALL addKey('parent',    t1%parent,    t1%keys)
    257          CALL addKey('phase',     t1%phase,    t1%keys)
    258       END DO
    259       IF(setGeneration(tracers)) CALL abort_gcm(modname,'See above',1) !- SET FIELDS %iGeneration, %gen0Name
    260       DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
    261    END IF
    262    !---------------------------------------------------------------------------------------------------------------------------
    263    ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
    264    !---------------------------------------------------------------------------------------------------------------------------
    265       nqo    =        COUNT(delPhase(tracers(:)%name)     == 'H2O' &
    266                                .AND. tracers(:)%component == 'lmdz') !--- Number of water phases
     205    CASE('coag')
     206      IF (.NOT. CPPKEY_STRATAER) THEN
     207        CALL abort_gcm(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
     208      END IF
     209    END SELECT
     210
     211    nqCO2 = COUNT([type_trac == 'inco', type_trac == 'co2i'])
     212
     213    !==============================================================================================================================
     214    ! 1) Get the numbers of: true (first order only) tracers "nqtrue", water tracers "nqo" (vapor/liquid/solid)
     215    !==============================================================================================================================
     216    texp = type_trac                                                  !=== EXPANDED VERSION OF "type_trac", WITH "|" SEPARATOR
     217    IF(texp == 'inco') texp = 'co2i|inca'
     218    IF(texp /= 'lmdz') texp = 'lmdz|' // TRIM(texp)
     219
     220    !=== DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE
     221    IF(testTracersFiles(modname, texp, fType, .TRUE.)) CALL abort_gcm(modname, 'problem with tracers file(s)', 1)
     222    ttp = type_trac; IF(fType /= 1) ttp = texp
     223
     224    IF(readTracersFiles(ttp, lRepr = type_trac=='repr')) CALL abort_gcm(modname, 'problem with tracers file(s)', 1)
     225    !---------------------------------------------------------------------------------------------------------------------------
     226    IF(fType == 0) CALL abort_gcm(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.', 1)
     227    !---------------------------------------------------------------------------------------------------------------------------
     228    IF(fType == 1 .AND. ANY(['inca', 'inco']==type_trac)) THEN         !=== FOUND OLD STYLE INCA "traceur.def"
     229      !---------------------------------------------------------------------------------------------------------------------------
     230      IF (CPPKEY_INCA) THEN
     231        nqo = SIZE(tracers) - nqCO2
     232        CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
     233        nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
     234        nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
     235        IF(ALL([2, 3] /= nqo)) CALL abort_gcm(modname, 'Only 2 or 3 water phases allowed ; found nqo=' // TRIM(int2str(nqo)), 1)
     236        ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
     237        ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA), pbl_flg_inca(nqINCA))
     238        CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
     239        ALLOCATE(ttr(nqtrue))
     240        ttr(1:nqo + nqCO2) = tracers
     241        ttr(1:nqo)%component = 'lmdz'
     242        ttr(1 + nqo:nqCO2 + nqo)%component = 'co2i'
     243        ttr(1 + nqo + nqCO2:nqtrue)%component = 'inca'
     244        ttr(1 + nqo:nqtrue)%name = [('CO2     ', iq = 1, nqCO2), solsym_inca]
     245        ttr(1 + nqo + nqCO2:nqtrue)%parent = tran0
     246        ttr(1 + nqo + nqCO2:nqtrue)%phase = 'g'
     247        lerr = getKey('hadv', had, ky = tracers(:)%keys)
     248        lerr = getKey('vadv', vad, ky = tracers(:)%keys)
     249        hadv(1:nqo + nqCO2) = had(:); hadv(1 + nqo + nqCO2:nqtrue) = hadv_inca
     250        vadv(1:nqo + nqCO2) = vad(:); vadv(1 + nqo + nqCO2:nqtrue) = vadv_inca
     251        CALL MOVE_ALLOC(FROM = ttr, TO = tracers)
     252        DO iq = 1, nqtrue
     253          t1 => tracers(iq)
     254          CALL addKey('name', t1%name, t1%keys)
     255          CALL addKey('component', t1%component, t1%keys)
     256          CALL addKey('parent', t1%parent, t1%keys)
     257          CALL addKey('phase', t1%phase, t1%keys)
     258        END DO
     259        IF(setGeneration(tracers)) CALL abort_gcm(modname, 'See above', 1) !- SET FIELDS %iGeneration, %gen0Name
     260        DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
     261      END IF
     262      !---------------------------------------------------------------------------------------------------------------------------
     263    ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
     264      !---------------------------------------------------------------------------------------------------------------------------
     265      nqo = COUNT(delPhase(tracers(:)%name)     == 'H2O' &
     266              .AND. tracers(:)%component == 'lmdz') !--- Number of water phases
    267267      nqtrue = SIZE(tracers)                                         !--- Total number of "true" tracers
    268       nbtr   = nqtrue-COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
    269                                .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
    270    IF (CPPKEY_INCA) THEN
    271       nqINCA = COUNT(tracers(:)%component == 'inca')
    272    END IF
    273       lerr = getKey('hadv', hadv, ky=tracers(:)%keys)
    274       lerr = getKey('vadv', vadv, ky=tracers(:)%keys)
    275    !---------------------------------------------------------------------------------------------------------------------------
    276    END IF
    277    !---------------------------------------------------------------------------------------------------------------------------
     268      nbtr = nqtrue - COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
     269              .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
     270      IF (CPPKEY_INCA) THEN
     271        nqINCA = COUNT(tracers(:)%component == 'inca')
     272      END IF
     273      lerr = getKey('hadv', hadv, ky = tracers(:)%keys)
     274      lerr = getKey('vadv', vadv, ky = tracers(:)%keys)
     275      !---------------------------------------------------------------------------------------------------------------------------
     276    END IF
     277    !---------------------------------------------------------------------------------------------------------------------------
    278278
    279279#ifdef REPROBUS
     
    282282
    283283#endif
    284 !==============================================================================================================================
    285 ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
    286 !==============================================================================================================================
    287    DO iq = 1, nqtrue
    288       IF( hadv(iq)<20 .OR. (ANY(hadv(iq)==[20,30]) .AND. hadv(iq)==vadv(iq)) ) CYCLE
    289       WRITE(msg1,'("The choice hadv=",i0,", vadv=",i0,a)')hadv(iq),vadv(iq),' for "'//TRIM(tracers(iq)%name)//'" is not available'
     284    !==============================================================================================================================
     285    ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
     286    !==============================================================================================================================
     287    DO iq = 1, nqtrue
     288      IF(hadv(iq)<20 .OR. (ANY(hadv(iq)==[20, 30]) .AND. hadv(iq)==vadv(iq))) CYCLE
     289      WRITE(msg1, '("The choice hadv=",i0,", vadv=",i0,a)')hadv(iq), vadv(iq), ' for "' // TRIM(tracers(iq)%name) // '" is not available'
    290290      CALL abort_gcm(modname, TRIM(msg1), 1)
    291    END DO
    292    nqtot =    COUNT( hadv< 20 .AND. vadv< 20 ) &                     !--- No additional tracer
    293          +  4*COUNT( hadv==20 .AND. vadv==20 ) &                     !--- 3  additional tracers
    294          + 10*COUNT( hadv==30 .AND. vadv==30 )                       !--- 9  additional tracers
    295 
    296    !--- More tracers due to the choice of advection scheme => assign total number of tracers
    297    IF( nqtot /= nqtrue ) THEN
     291    END DO
     292    nqtot = COUNT(hadv< 20 .AND. vadv< 20) &                     !--- No additional tracer
     293            + 4 * COUNT(hadv==20 .AND. vadv==20) &                     !--- 3  additional tracers
     294            + 10 * COUNT(hadv==30 .AND. vadv==30)                       !--- 9  additional tracers
     295
     296    !--- More tracers due to the choice of advection scheme => assign total number of tracers
     297    IF(nqtot /= nqtrue) THEN
    298298      CALL msg('The choice of advection scheme for one or more tracers makes it necessary to add tracers')
    299       CALL msg('The number of true tracers is '//TRIM(int2str(nqtrue)))
    300       CALL msg('The total number of tracers needed is '//TRIM(int2str(nqtot)))
    301    END IF
    302 
    303 !==============================================================================================================================
    304 ! 3) Determine the advection scheme choice for water and tracers "iadv" and the fields long name, isAdvected.
    305 !     iadv = 1    "LMDZ-specific humidity transport" (for H2O vapour)          LMV
    306 !     iadv = 2    backward                           (for H2O liquid)          BAK
    307 !     iadv = 14   Van-Leer + specific humidity, modified by Francis Codron     VLH
    308 !     iadv = 10   Van-Leer (chosen for vapour and liquid water)                VL1
    309 !     iadv = 11   Van-Leer for hadv and PPM version (Monotonic) for vadv       VLP
    310 !     iadv = 12   Frederic Hourdin I                                           FH1
    311 !     iadv = 13   Frederic Hourdin II                                          FH2
    312 !     iadv = 16   Monotonic         PPM (Collela & Woodward 1984)              PPM
    313 !     iadv = 17   Semi-monotonic    PPM (overshoots allowed)                   PPS
    314 !     iadv = 18   Definite positive PPM (overshoots and undershoots allowed)   PPP
    315 !     iadv = 20   Slopes                                                       SLP
    316 !     iadv = 30   Prather                                                      PRA
    317 !
    318 !        In array q(ij,l,iq) : iq = 1/2[/3]    for vapour/liquid[/ice] water
    319 !        And optionaly:        iq = 3[4],nqtot for other tracers
    320 !==============================================================================================================================
    321    ALLOCATE(ttr(nqtot))
    322    jq = nqtrue+1; tracers(:)%iadv = -1
    323    DO iq = 1, nqtrue
     299      CALL msg('The number of true tracers is ' // TRIM(int2str(nqtrue)))
     300      CALL msg('The total number of tracers needed is ' // TRIM(int2str(nqtot)))
     301    END IF
     302
     303    !==============================================================================================================================
     304    ! 3) Determine the advection scheme choice for water and tracers "iadv" and the fields long name, isAdvected.
     305    !     iadv = 1    "LMDZ-specific humidity transport" (for H2O vapour)          LMV
     306    !     iadv = 2    backward                           (for H2O liquid)          BAK
     307    !     iadv = 14   Van-Leer + specific humidity, modified by Francis Codron     VLH
     308    !     iadv = 10   Van-Leer (chosen for vapour and liquid water)                VL1
     309    !     iadv = 11   Van-Leer for hadv and PPM version (Monotonic) for vadv       VLP
     310    !     iadv = 12   Frederic Hourdin I                                           FH1
     311    !     iadv = 13   Frederic Hourdin II                                          FH2
     312    !     iadv = 16   Monotonic         PPM (Collela & Woodward 1984)              PPM
     313    !     iadv = 17   Semi-monotonic    PPM (overshoots allowed)                   PPS
     314    !     iadv = 18   Definite positive PPM (overshoots and undershoots allowed)   PPP
     315    !     iadv = 20   Slopes                                                       SLP
     316    !     iadv = 30   Prather                                                      PRA
     317    !
     318    !        In array q(ij,l,iq) : iq = 1/2[/3]    for vapour/liquid[/ice] water
     319    !        And optionaly:        iq = 3[4],nqtot for other tracers
     320    !==============================================================================================================================
     321    ALLOCATE(ttr(nqtot))
     322    jq = nqtrue + 1; tracers(:)%iadv = -1
     323    DO iq = 1, nqtrue
    324324      t1 => tracers(iq)
    325325
    326326      !--- VERIFY THE CHOICE OF ADVECTION SCHEME
    327327      iad = -1
    328       IF(hadv(iq)     ==    vadv(iq)    ) iad = hadv(iq)
     328      IF(hadv(iq)     ==    vadv(iq)) iad = hadv(iq)
    329329      IF(hadv(iq)==10 .AND. vadv(iq)==16) iad = 11
    330       WRITE(msg1,'("Bad choice of advection scheme for ",a,": hadv = ",i0,", vadv = ",i0)')TRIM(t1%name), hadv(iq), vadv(iq)
     330      WRITE(msg1, '("Bad choice of advection scheme for ",a,": hadv = ",i0,", vadv = ",i0)')TRIM(t1%name), hadv(iq), vadv(iq)
    331331      IF(iad == -1) CALL abort_gcm(modname, msg1, 1)
    332332
    333333      !--- SET FIELDS %longName, %iadv, %isAdvected, %isInPhysics
    334       t1%longName   = t1%name; IF(iad > 0) t1%longName=TRIM(t1%name)//descrq(iad)
    335       t1%iadv       = iad
     334      t1%longName = t1%name; IF(iad > 0) t1%longName = TRIM(t1%name) // descrq(iad)
     335      t1%iadv = iad
    336336      t1%isAdvected = iad >= 0
    337       t1%isInPhysics= delPhase(t1%gen0Name) /= 'H2O' &
    338                           .OR. t1%component /= 'lmdz' !=== OTHER EXCEPTIONS TO BE ADDED: CO2i, SURSATURATED WATER CLOUD...
    339       ttr(iq)       = t1
     337      t1%isInPhysics = delPhase(t1%gen0Name) /= 'H2O' &
     338              .OR. t1%component /= 'lmdz' !=== OTHER EXCEPTIONS TO BE ADDED: CO2i, SURSATURATED WATER CLOUD...
     339      ttr(iq) = t1
    340340
    341341      !--- DEFINE THE HIGHER ORDER TRACERS, IF ANY
     
    344344      IF(iad == 30) nm = 9                                           !--- 3rd order scheme
    345345      IF(nm == 0) CYCLE                                              !--- No higher moments
    346       ttr(jq+1:jq+nm)            = t1
    347       ttr(jq+1:jq+nm)%name        = [ (TRIM(t1%name)    //'-'//TRIM(suff(im)), im=1, nm) ]
    348       ttr(jq+1:jq+nm)%parent      = [ (TRIM(t1%parent)  //'-'//TRIM(suff(im)), im=1, nm) ]
    349       ttr(jq+1:jq+nm)%longName    = [ (TRIM(t1%longName)//'-'//TRIM(suff(im)), im=1, nm) ]
    350       ttr(jq+1:jq+nm)%iadv        = [ (-iad,    im=1, nm) ]
    351       ttr(jq+1:jq+nm)%isAdvected  = [ (.FALSE., im=1, nm) ]
     346      ttr(jq + 1:jq + nm) = t1
     347      ttr(jq + 1:jq + nm)%name = [ (TRIM(t1%name) // '-' // TRIM(suff(im)), im = 1, nm) ]
     348      ttr(jq + 1:jq + nm)%parent = [ (TRIM(t1%parent) // '-' // TRIM(suff(im)), im = 1, nm) ]
     349      ttr(jq + 1:jq + nm)%longName = [ (TRIM(t1%longName) // '-' // TRIM(suff(im)), im = 1, nm) ]
     350      ttr(jq + 1:jq + nm)%iadv = [ (-iad, im = 1, nm) ]
     351      ttr(jq + 1:jq + nm)%isAdvected = [ (.FALSE., im = 1, nm) ]
    352352      jq = jq + nm
    353    END DO
    354    DEALLOCATE(hadv, vadv)
    355    CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
    356 
    357    !--- SET FIELDS %iqParent, %nqChildren, %iGeneration, %iqDescen, %nqDescen
    358    IF(indexUpdate(tracers)) CALL abort_gcm(modname, 'problem with tracers indices update', 1)
    359 
    360    !=== TEST ADVECTION SCHEME
    361    DO iq=1,nqtot ; t1 => tracers(iq); iad = t1%iadv
    362 
    363       !--- ONLY TESTED VALUES FOR TRACERS FOR NOW:               iadv = 14, 10 (and 0 for non-transported tracers)
    364       IF(ALL([10,14,0] /= iad)) &
    365          CALL abort_gcm(modname, 'Not tested for iadv='//TRIM(int2str(iad))//' ; 10 or 14 only are allowed !', 1)
    366 
    367       !--- ONLY TESTED VALUES FOR PARENTS HAVING CHILDS FOR NOW: iadv = 14, 10 (PARENTS: TRACERS OF GENERATION 1)
    368       IF(ALL([10,14] /= iad) .AND. t1%iGeneration == 1 .AND. ANY(tracers(:)%iGeneration > 1)) &
    369          CALL abort_gcm(modname, 'iadv='//TRIM(int2str(iad))//' not implemented for parents ; 10 or 14 only are allowed !', 1)
    370 
    371       !--- ONLY TESTED VALUES FOR CHILDS FOR NOW:                iadv = 10     (CHILDS:  TRACERS OF GENERATION GREATER THAN 1)
    372       IF(fmsg('WARNING ! iadv='//TRIM(int2str(iad))//' not implemented for childs. Setting iadv=10 for "'//TRIM(t1%name)//'"',&
    373          modname, iad /= 10 .AND. t1%iGeneration > 1)) t1%iadv = 10
    374 
    375       !--- ONLY VALID SCHEME NUMBER FOR WATER VAPOUR:            iadv = 14
    376       ll = t1%name /= addPhase('H2O','g')
    377       IF(fmsg('WARNING ! iadv=14 is valid for water vapour only. Setting iadv=10 for "'//TRIM(t1%name)//'".', &
    378          modname, iad == 14 .AND. ll))                 t1%iadv = 10
    379    END DO
    380 
    381    !=== READ PHYSICAL PARAMETERS FOR ISOTOPES ; DONE HERE BECAUSE dynetat0 AND iniacademic NEED "tnat" AND "alpha_ideal"
    382    niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE.
    383    IF(processIsotopes()) CALL abort_gcm(modname, 'problem when processing isotopes parameters', 1)
    384 
    385    !--- Convection / boundary layer activation for all tracers
    386    ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1
    387    ALLOCATE( pbl_flg(nbtr));  pbl_flg(1:nbtr) = 1
    388 
    389    !--- Note: nqtottr can differ from nbtr when nmom/=0
    390    nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz')
    391    IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
    392       CALL abort_gcm(modname, 'problem with the computation of nqtottr', 1)
    393 
    394    !=== DISPLAY THE RESULTS
    395    CALL msg('nqo    = '//TRIM(int2str(nqo)),    modname)
    396    CALL msg('nbtr   = '//TRIM(int2str(nbtr)),  modname)
    397    CALL msg('nqtrue = '//TRIM(int2str(nqtrue)), modname)
    398    CALL msg('nqtot  = '//TRIM(int2str(nqtot)), modname)
    399    CALL msg('niso   = '//TRIM(int2str(niso)),  modname)
    400    CALL msg('ntiso  = '//TRIM(int2str(ntiso)), modname)
    401    IF (CPPKEY_INCA) THEN
    402       CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)), modname)
    403       CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
    404    END IF
    405    t => tracers
    406    CALL msg('Information stored in infotrac :', modname)
    407 
    408    IF(dispTable('isssssssssiiiiiiiii', ['iq  ', 'name', 'lNam', 'g0Nm', 'prnt', 'type', 'phas', 'comp',    &
    409                 'isPh', 'isAd', 'iadv', 'iGen', 'iqPr', 'nqDe', 'nqCh', 'iGrp', 'iNam', 'iZon', 'iPha'],  &
    410       cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics), &
    411                                                                                   bool2str(t%isAdvected)), &
    412       cat([(iq, iq=1, nqtot)], t%iadv, t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup, &
    413                   t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax=maxTableWidth, nHead=2, sub=modname))   &
    414       CALL abort_gcm(modname, "problem with the tracers table content", 1)
    415    IF(niso > 0) THEN
    416       CALL msg('Where, for isotopes family "'//TRIM(isotope%parent)//'":', modname)
    417       CALL msg('  isoKeys%name = '//strStack(isoKeys%name), modname)
    418       CALL msg('  isoName = '//strStack(isoName),      modname)
    419       CALL msg('  isoZone = '//strStack(isoZone),      modname)
    420       CALL msg('  isoPhas = '//TRIM(isoPhas),          modname)
    421    ELSE
     353    END DO
     354    DEALLOCATE(hadv, vadv)
     355    CALL MOVE_ALLOC(FROM = ttr, TO = tracers)
     356
     357    !--- SET FIELDS %iqParent, %nqChildren, %iGeneration, %iqDescen, %nqDescen
     358    IF(indexUpdate(tracers)) CALL abort_gcm(modname, 'problem with tracers indices update', 1)
     359
     360    !=== TEST ADVECTION SCHEME
     361    DO iq = 1, nqtot ; t1 => tracers(iq); iad = t1%iadv
     362
     363    !--- ONLY TESTED VALUES FOR TRACERS FOR NOW:               iadv = 14, 10 (and 0 for non-transported tracers)
     364    IF(ALL([10, 14, 0] /= iad)) &
     365            CALL abort_gcm(modname, 'Not tested for iadv=' // TRIM(int2str(iad)) // ' ; 10 or 14 only are allowed !', 1)
     366
     367    !--- ONLY TESTED VALUES FOR PARENTS HAVING CHILDS FOR NOW: iadv = 14, 10 (PARENTS: TRACERS OF GENERATION 1)
     368    IF(ALL([10, 14] /= iad) .AND. t1%iGeneration == 1 .AND. ANY(tracers(:)%iGeneration > 1)) &
     369            CALL abort_gcm(modname, 'iadv=' // TRIM(int2str(iad)) // ' not implemented for parents ; 10 or 14 only are allowed !', 1)
     370
     371    !--- ONLY TESTED VALUES FOR CHILDS FOR NOW:                iadv = 10     (CHILDS:  TRACERS OF GENERATION GREATER THAN 1)
     372    IF(fmsg('WARNING ! iadv=' // TRIM(int2str(iad)) // ' not implemented for childs. Setting iadv=10 for "' // TRIM(t1%name) // '"', &
     373            modname, iad /= 10 .AND. t1%iGeneration > 1)) t1%iadv = 10
     374
     375    !--- ONLY VALID SCHEME NUMBER FOR WATER VAPOUR:            iadv = 14
     376    ll = t1%name /= addPhase('H2O', 'g')
     377    IF(fmsg('WARNING ! iadv=14 is valid for water vapour only. Setting iadv=10 for "' // TRIM(t1%name) // '".', &
     378            modname, iad == 14 .AND. ll))                 t1%iadv = 10
     379    END DO
     380
     381    !=== READ PHYSICAL PARAMETERS FOR ISOTOPES ; DONE HERE BECAUSE dynetat0 AND iniacademic NEED "tnat" AND "alpha_ideal"
     382    niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE.
     383    IF(processIsotopes()) CALL abort_gcm(modname, 'problem when processing isotopes parameters', 1)
     384
     385    !--- Convection / boundary layer activation for all tracers
     386    ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1
     387    ALLOCATE(pbl_flg(nbtr));  pbl_flg(1:nbtr) = 1
     388
     389    !--- Note: nqtottr can differ from nbtr when nmom/=0
     390    nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz')
     391    IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
     392            CALL abort_gcm(modname, 'problem with the computation of nqtottr', 1)
     393
     394    !=== DISPLAY THE RESULTS
     395    CALL msg('nqo    = ' // TRIM(int2str(nqo)), modname)
     396    CALL msg('nbtr   = ' // TRIM(int2str(nbtr)), modname)
     397    CALL msg('nqtrue = ' // TRIM(int2str(nqtrue)), modname)
     398    CALL msg('nqtot  = ' // TRIM(int2str(nqtot)), modname)
     399    CALL msg('niso   = ' // TRIM(int2str(niso)), modname)
     400    CALL msg('ntiso  = ' // TRIM(int2str(ntiso)), modname)
     401    IF (CPPKEY_INCA) THEN
     402      CALL msg('nqCO2  = ' // TRIM(int2str(nqCO2)), modname)
     403      CALL msg('nqINCA = ' // TRIM(int2str(nqINCA)), modname)
     404    END IF
     405    t => tracers
     406    CALL msg('Information stored in infotrac :', modname)
     407
     408    IF(dispTable('isssssssssiiiiiiiii', ['iq  ', 'name', 'lNam', 'g0Nm', 'prnt', 'type', 'phas', 'comp', &
     409            'isPh', 'isAd', 'iadv', 'iGen', 'iqPr', 'nqDe', 'nqCh', 'iGrp', 'iNam', 'iZon', 'iPha'], &
     410            cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics), &
     411                    bool2str(t%isAdvected)), &
     412            cat([(iq, iq = 1, nqtot)], t%iadv, t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup, &
     413                    t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax = maxTableWidth, nHead = 2, sub = modname))   &
     414            CALL abort_gcm(modname, "problem with the tracers table content", 1)
     415    IF(niso > 0) THEN
     416      CALL msg('Where, for isotopes family "' // TRIM(isotope%parent) // '":', modname)
     417      CALL msg('  isoKeys%name = ' // strStack(isoKeys%name), modname)
     418      CALL msg('  isoName = ' // strStack(isoName), modname)
     419      CALL msg('  isoZone = ' // strStack(isoZone), modname)
     420      CALL msg('  isoPhas = ' // TRIM(isoPhas), modname)
     421    ELSE
    422422      CALL msg('No isotopes identified.', modname)
    423    END IF
    424    CALL msg('end', modname)
    425 
    426 END SUBROUTINE init_infotrac
     423    END IF
     424    CALL msg('end', modname)
     425
     426  END SUBROUTINE init_infotrac
    427427
    428428END MODULE infotrac
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/limx.F

    r5082 r5098  
    4343      save first
    4444
    45       REAL      SSUM,CVMGP,CVMGT
     45      REAL      SSUM
    4646      integer ismax,ismin
    4747      EXTERNAL  SSUM, ismin,ismax
  • LMDZ6/branches/Amaury_dev/libf/dyn3d_common/limz.F

    r5082 r5098  
    4343      save first
    4444
    45       REAL      SSUM,CVMGP,CVMGT
     45      REAL      SSUM
    4646      integer ismax,ismin
    4747      EXTERNAL  SSUM, ismin,ismax
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlsplt_loc.F

    r5082 r5098  
    44      RECURSIVE SUBROUTINE vlx_loc(q,pente_max,masse,u_m,ijb_x,ije_x,iq)
    55
    6 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
     6c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
    77c
    88c    ********************************************************************
     
    2828      REAL u_m( ijb_u:ije_u,llm),pbarv( iip1,jjb_v:jje_v,llm)
    2929      REAL q(ijb_u:ije_u,llm,nqtot) ! CRisi: ajout dimension nqtot
    30       REAL w(ijb_u:ije_u,llm) 
     30      REAL w(ijb_u:ije_u,llm)
    3131      INTEGER iq ! CRisi
    3232c
    33 c      Local 
     33c      Local
    3434c   ---------
    3535c
     
    4949
    5050      REAL      SSUM
    51       EXTERNAL  SSUM
    5251
    5352      REAL z1,z2,z3
    5453
    5554      INTEGER ijb,ije,ijb_x,ije_x
    56      
     55
    5756      !write(*,*) 'vlsplt 58: entree dans vlx_loc, iq,ijb_x=',
    5857!     &   iq,ijb_x
     
    6160      ijb=ijb_x
    6261      ije=ije_x
    63        
     62
    6463      if (pole_nord.and.ijb==1) ijb=ijb+iip1
    6564      if (pole_sud.and.ije==ip1jmp1)  ije=ije-iip1
    66          
     65
    6766      IF (pente_max>-1.e-5) THEN
    6867c       IF (pente_max.gt.10) THEN
     
    7271      ! on a besoin de q entre ijb et ije
    7372c   calcul de la pente aux points u
    74 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)         
     73c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    7574         DO l = 1, llm
    76            
     75
    7776            DO ij=ijb,ije-1
    7877               dxqu(ij)=q(ij+1,l,iq)-q(ij,l,iq)
     
    9695c limitation subtile
    9796c    ,      min(adxqu(ij-1)/sigu(ij-1),adxqu(ij)/(1.-sigu(ij)))
    98          
     97
    9998
    10099            ENDDO
     
    105104
    106105            DO ij=ijb+1,ije
    107 #ifdef CRAY
    108                dxq(ij,l)=
    109      ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
    110 #else
    111106               IF(dxqu(ij-1)*dxqu(ij)>0) THEN
    112107                  dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
     
    115110                  dxq(ij,l)=0.
    116111               ENDIF
    117 #endif
    118112               dxq(ij,l)=0.5*dxq(ij,l)
    119113               dxq(ij,l)=
     
    172166c   calcul des flux a gauche et a droite
    173167
    174 #ifdef CRAY
    175 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    176       DO l=1,llm
    177        DO ij=ijb,ije-1
    178           zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l,iq),
    179      ,                     1.+u_m(ij,l)/masse(ij+1,l,iq),
    180      ,                     u_m(ij,l,iq))
    181           zdum(ij,l)=0.5*zdum(ij,l)
    182           u_mq(ij,l)=cvmgp(
    183      ,                q(ij,l,iq)+zdum(ij,l)*dxq(ij,l),
    184      ,                q(ij+1,l,iq)-zdum(ij,l)*dxq(ij+1,l),
    185      ,                u_m(ij,l))
    186           u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
    187        ENDDO
    188       ENDDO
    189 c$OMP END DO NOWAIT
    190 #else
     168
    191169c   on cumule le flux correspondant a toutes les mailles dont la masse
    192170c   au travers de la paroi pENDant le pas de temps.
     
    209187      ENDDO
    210188c$OMP END DO NOWAIT
    211 #endif
    212 
    213 c       go to 9999
     189
    214190c   detection des points ou on advecte plus que la masse de la
    215191c   maille
     
    234210c$OMP END DO NOWAIT
    235211c        print*,'Ok test 2'
    236        
     212
    237213
    238214c   traitement special pour le cas ou on advecte en longitude plus que le
     
    313289         ENDDO
    314290c$OMP END DO NOWAIT
    315 cym      ENDIF  ! n0.gt.0
    316 9999    continue
     291cym      ENDIF  ! n0.gt.0
    317292
    318293c   bouclage en latitude
     
    346321              Ratio(ij,l,iq2)=min_ratio
    347322            endif
    348           enddo   
     323          enddo
    349324        enddo
    350325c$OMP END DO NOWAIT
     
    377352
    378353! retablir les fils en rapport de melange par rapport a l'air:
    379       ! On calcule q entre ijb+1 et ije -> on fait pareil pour ratio 
     354      ! On calcule q entre ijb+1 et ije -> on fait pareil pour ratio
    380355      ! puis on boucle en longitude
    381356      do ifils=1,tracers(iq)%nqDescen
    382357        iq2=tracers(iq)%iqDescen(ifils)
    383 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
     358c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    384359        DO l=1,llm
    385360          DO ij=ijb+1,ije
    386             q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)           
     361            q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)
    387362          enddo
    388363          DO ij=ijb+iip1-1,ije,iip1
     
    404379      RECURSIVE SUBROUTINE vly_loc(q,pente_max,masse,masse_adv_v,iq)
    405380c
    406 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
     381c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
    407382c
    408383c    ********************************************************************
     
    416391      USE parallel_lmdz
    417392      USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
    418      &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi   
     393     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
    419394      USE comconst_mod, ONLY: pi
    420395      IMPLICIT NONE
     
    432407      INTEGER iq ! CRisi
    433408c
    434 c      Local 
     409c      Local
    435410c   ---------
    436411c
     
    444419      REAL qpns,qpsn,appn,apps,dyn1,dys1,dyn2,dys2,newmasse,fn,fs
    445420c     REAL newq,oldmasse
    446       Logical extremum,first,testcpu
     421      Logical extremum,first
    447422      REAL temps0,temps1,temps2,temps3,temps4,temps5,second
    448423      SAVE temps0,temps1,temps2,temps3,temps4,temps5
    449424c$OMP THREADPRIVATE(temps0,temps1,temps2,temps3,temps4,temps5)
    450       SAVE first,testcpu
    451 c$OMP THREADPRIVATE(first,testcpu)
     425      SAVE first
     426c$OMP THREADPRIVATE(first)
    452427
    453428      REAL convpn,convps,convmpn,convmps
     
    467442      EXTERNAL  SSUM
    468443
    469       DATA first,testcpu/.true.,.false./
     444      DATA first/.true./
    470445      DATA temps0,temps1,temps2,temps3,temps4,temps5/0.,0.,0.,0.,0.,0./
    471446      INTEGER ijb,ije
     
    473448
    474449      ijb=ij_begin-2*iip1
    475       ije=ij_end+2*iip1 
     450      ije=ij_end+2*iip1
    476451      if (pole_nord) ijb=ij_begin
    477452      if (pole_sud)  ije=ij_end
     
    491466         sinlondlon(1)=sinlondlon(iip1)
    492467         airej2 = SSUM( iim, aire(iip2), 1 )
    493          airejjm= SSUM( iim, aire(ip1jm -iim), 1 ) 
     468         airejjm= SSUM( iim, aire(ip1jm -iim), 1 )
    494469      ENDIF
    495470
     
    497472c       PRINT*,'CALCUL EN LATITUDE'
    498473
    499 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
     474c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    500475      DO l = 1, llm
    501476c
     
    507482c   de latitude autour du pole (qpns pour le pole nord et qpsn pour
    508483c    le pole nord) qui sera utilisee pour evaluer les pentes au pole.
    509      
     484
    510485      if (pole_nord) then
    511486        DO i = 1, iim
     
    514489        qpns   = SSUM( iim,  airescb ,1 ) / airej2
    515490      endif
    516      
     491
    517492      if (pole_sud) then
    518493        DO i = 1, iim
     
    521496        qpsn   = SSUM( iim,  airesch ,1 ) / airejjm
    522497      endif
    523      
     498
    524499c   calcul des pentes aux points v
    525500
     
    528503      if (pole_nord) ijb=ij_begin
    529504      if (pole_sud)  ije=ij_end-iip1
    530      
     505
    531506      ! on a besoin de q entre ij_begin-2*iip1 et ij_end+2*iip1
    532507      ! Si pole sud, entre ij_begin-2*iip1 et ij_end
     
    536511         adyqv(ij)=abs(dyqv(ij))
    537512      ENDDO
    538  
     513
    539514
    540515c   calcul des pentes aux points scalaires
     
    543518      if (pole_nord) ijb=ij_begin+iip1
    544519      if (pole_sud)  ije=ij_end-iip1
    545      
     520
    546521      DO ij=ijb,ije
    547522         dyq(ij,l)=.5*(dyqv(ij-iip1)+dyqv(ij))
     
    555530           dyq(ij,l)=qpns-q(ij+iip1,l,iq)
    556531        ENDDO
    557        
     532
    558533        dyn1=0.
    559534        dyn2=0.
     
    565540          dyq(ij,l)=dyn1*sinlon(ij)+dyn2*coslon(ij)
    566541        ENDDO
    567        
     542
    568543        DO ij=1,iip1
    569544         dyq(ij,l)=0.
     
    571546c ym tout cela ne sert pas a grand chose
    572547      ENDIF
    573      
     548
    574549      IF (pole_sud) THEN
    575550
     
    589564          dyq(ip1jm+ij,l)=dys1*sinlon(ij)+dys2*coslon(ij)
    590565        ENDDO
    591        
     566
    592567        DO ij=1,iip1
    593568         dyq(ip1jm+ij,l)=0.
     
    619594
    620595CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    621 C  En memoire de dIFferents tests sur la 
     596C  En memoire de dIFferents tests sur la
    622597C  limitation des pentes aux poles.
    623598CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
     
    732707      ijem=ij_end+iip1
    733708      if (pole_nord) ijb=ij_begin
    734       if (pole_sud)  ije=ij_end 
     709      if (pole_sud)  ije=ij_end
    735710      if (pole_nord) ijbm=ij_begin
    736711      if (pole_sud)  ijem=ij_end
     
    738713      do ifils=1,tracers(iq)%nqDescen
    739714        iq2=tracers(iq)%iqDescen(ifils)
    740 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
     715c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    741716        DO l=1,llm
    742717        ! modif des bornes: CRisi 16 nov 2020
    743718        ! d'abord masse avec bornes corrigées
    744           DO ij=ijbm,ijem 
     719          DO ij=ijbm,ijem
    745720          !MVals: veiller a ce qu'on n'ait pas de denominateur nul
    746721            masse(ij,l,iq2)=max(masse(ij,l,iq)*q(ij,l,iq),min_qMass)
     
    753728              Ratio(ij,l,iq2)=q(ij,l,iq2)/q(ij,l,iq)
    754729            else
    755               Ratio(ij,l,iq2)=min_ratio 
    756             endif     
    757           enddo !DO ij=ijbm,ijem 
     730              Ratio(ij,l,iq2)=min_ratio
     731            endif
     732          enddo !DO ij=ijbm,ijem
    758733        enddo !DO l=1,llm
    759734c$OMP END DO NOWAIT
     
    765740      enddo
    766741! end CRisi
    767      
     742
    768743      ijb=ij_begin
    769744      ije=ij_end
    770745      if (pole_nord) ijb=ij_begin+iip1
    771746      if (pole_sud)  ije=ij_end-iip1
    772      
    773 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
     747
     748c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    774749      DO l=1,llm
    775750         DO ij=ijb,ije
     
    801776           enddo
    802777         endif
    803          
     778
    804779c        convps=-SSUM(iim,qbyv(ip1jm-iim,l),1)/apols
    805780c        convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)/apols
    806          
     781
    807782         if (pole_sud) then
    808          
     783
    809784           convps=-SSUM(iim,qbyv(ip1jm-iim,l),1)
    810785           convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)
     
    854829      do ifils=1,tracers(iq)%nqDescen
    855830        iq2=tracers(iq)%iqDescen(ifils)
    856 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
     831c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    857832        DO l=1,llm
    858833          DO ij=ijb,ije
    859             q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)           
     834            q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)
    860835          enddo
    861836        enddo
     
    866841      RETURN
    867842      END
    868      
    869      
    870      
     843
     844
     845
    871846      RECURSIVE SUBROUTINE vlz_loc(q,pente_max,masse,w,ijb_x,ije_x,iq)
    872847c
    873 c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
     848c     Auteurs:   P.Le Van, F.Hourdin, F.Forget
    874849c
    875850c    ********************************************************************
     
    885860      USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
    886861     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
    887      
     862
    888863      IMPLICIT NONE
    889864c
     
    900875      INTEGER iq
    901876c
    902 c      Local 
     877c      Local
    903878c   ---------
    904879c
     
    915890      REAL sigw
    916891
    917       LOGICAL testcpu
    918       SAVE testcpu
    919 c$OMP THREADPRIVATE(testcpu)
    920892      REAL temps0,temps1,temps2,temps3,temps4,temps5,second
    921893      SAVE temps0,temps1,temps2,temps3,temps4,temps5
     
    923895
    924896      REAL      SSUM
    925       EXTERNAL  SSUM
    926 
    927       DATA testcpu/.false./
     897
    928898      DATA temps0,temps1,temps2,temps3,temps4,temps5/0.,0.,0.,0.,0.,0./
    929899      INTEGER ijb,ije,ijb_x,ije_x
     
    933903      !REAL masseq(ijb_u:ije_u,llm,nqtot),Ratio(ijb_u:ije_u,llm,nqtot) ! CRisi
    934904      ! Ces varibles doivent être déclarées en pointer et en save dans
    935       ! vlz_loc si on veut qu'elles soient vues par tous les threads. 
     905      ! vlz_loc si on veut qu'elles soient vues par tous les threads.
    936906      INTEGER ifils,iq2 ! CRisi
    937907
     
    939909      IF (first) THEN
    940910       first=.FALSE.
    941       ENDIF             
     911      ENDIF
    942912c    On oriente tout dans le sens de la pression c'est a dire dans le
    943913c    sens de W
    944914
    945915      !write(*,*) 'vlsplt 926: entree dans vlz_loc, iq=',iq
    946 #ifdef BIDON
    947       IF(testcpu) THEN
    948          temps0=second(0.)
    949       ENDIF
    950 #endif
    951916
    952917      ijb=ijb_x
    953918      ije=ije_x
    954919
    955 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)     
     920c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    956921      DO l=2,llm
    957922         DO ij=ijb,ije
     
    965930      DO l=2,llm-1
    966931         DO ij=ijb,ije
    967 #ifdef CRAY
    968             dzq(ij,l)=0.5*
    969      ,      cvmgp(dzqw(ij,l)+dzqw(ij,l+1),0.,dzqw(ij,l)*dzqw(ij,l+1))
    970 #else
    971932            IF(dzqw(ij,l)*dzqw(ij,l+1)>0.) THEN
    972933                dzq(ij,l)=0.5*(dzqw(ij,l)+dzqw(ij,l+1))
     
    974935                dzq(ij,l)=0.
    975936            ENDIF
    976 #endif
    977937            dzqmax=pente_max*min(adzqw(ij,l),adzqw(ij,l+1))
    978938            dzq(ij,l)=sign(min(abs(dzq(ij,l)),dzqmax),dzq(ij,l))
     
    988948c$OMP END MASTER
    989949c$OMP BARRIER
    990 #ifdef BIDON
    991       IF(testcpu) THEN
    992          temps1=temps1+second(0.)-temps0
    993       ENDIF
    994 #endif
    995950
    996951!--------------------------------------------------------
     
    1008963         ENDDO
    1009964      ENDDO
    1010 c$OMP END DO NOWAIT   
     965c$OMP END DO NOWAIT
    1011966
    1012967c ---------------------------------------------------------------
     
    1041996         ENDDO
    1042997       ENDDO
    1043 c$OMP END DO NOWAIT   
    1044        !write(*,*) 'vlz 1001'   
     998c$OMP END DO NOWAIT
     999       !write(*,*) 'vlz 1001'
    10451000
    10461001      ELSE ! countcfl>=1
     
    10791034c  on itère jusqu'à ce que tous les poins satisfassent
    10801035c  le critère
    1081       DO WHILE (countcfl>=1) 
     1036      DO WHILE (countcfl>=1)
    10821037        IF (prt_level>9) THEN
    10831038          WRITE(lunout,*)'On viole le CFL Vertical sur ',countcfl,' pts'
     
    11301085         ENDDO
    11311086       ENDDO
    1132 c$OMP END DO NOWAIT   
     1087c$OMP END DO NOWAIT
    11331088
    11341089
     
    11621117            !wq(ij,l,iq2)=wq(ij,l,iq) ! correction bug le 15mai2015
    11631118            w(ij,l,iq2)=wq(ij,l,iq)
    1164           enddo   
     1119          enddo
    11651120        enddo
    11661121c$OMP END DO NOWAIT
     
    11721127        call vlz_loc(Ratio,pente_max,masse,w,ijb_x,ije_x,iq2)
    11731128      enddo
    1174 ! end CRisi 
     1129! end CRisi
    11751130
    11761131! CRisi: On rajoute ici une barrière car on veut être sur que tous les
     
    11901145c$OMP END DO NOWAIT
    11911146
    1192      
     1147
    11931148! retablir les fils en rapport de melange par rapport a l'air:
    11941149      do ifils=1,tracers(iq)%nqDescen
    11951150        iq2=tracers(iq)%iqDescen(ifils)
    1196 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)   
     1151c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    11971152        DO l=1,llm
    11981153          DO ij=ijb,ije
    1199             q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)           
     1154            q(ij,l,iq2)=q(ij,l,iq)*Ratio(ij,l,iq2)
    12001155          enddo
    12011156        enddo
  • LMDZ6/branches/Amaury_dev/libf/dyn3dmem/vlspltqs_loc.F

    r5081 r5098  
    1313      USE parallel_lmdz
    1414      USE infotrac, ONLY : nqtot,tracers, ! CRisi                 &
    15      &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi
     15     &                     min_qParent,min_qMass,min_ratio ! MVals et CRisi7
    1616      IMPLICIT NONE
    1717c
     
    9191c limitation subtile
    9292c    ,      min(adxqu(ij-1)/sigu(ij-1),adxqu(ij)/(1.-sigu(ij)))
    93          
     93
    9494
    9595            ENDDO
     
    100100
    101101            DO ij=ijb+1,ije
    102 #ifdef CRAY
    103                dxq(ij,l)=
    104      ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
    105 #else
    106102               IF(dxqu(ij-1)*dxqu(ij)>0) THEN
    107103                  dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
     
    110106                  dxq(ij,l)=0.
    111107               ENDIF
    112 #endif
    113108               dxq(ij,l)=0.5*dxq(ij,l)
    114109               dxq(ij,l)=
     
    179174             
    180175c   calcul des flux a gauche et a droite
    181 
    182 #ifdef CRAY
    183 c--pas encore modification sur Qsat
    184 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
    185       DO l=1,llm
    186        DO ij=ijb,ije-1
    187           zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l,iq),
    188      ,                     1.+u_m(ij,l)/masse(ij+1,l,iq),
    189      ,                     u_m(ij,l))
    190           zdum(ij,l)=0.5*zdum(ij,l)
    191           u_mq(ij,l)=cvmgp(
    192      ,                q(ij,l,iq)+zdum(ij,l)*dxq(ij,l),
    193      ,                q(ij+1,l,iq)-zdum(ij,l)*dxq(ij+1,l),
    194      ,                u_m(ij,l))
    195           u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
    196        ENDDO
    197       ENDDO
    198 c$OMP END DO NOWAIT
    199 
    200 #else
    201176c   on cumule le flux correspondant a toutes les mailles dont la masse
    202177c   au travers de la paroi pENDant le pas de temps.
     
    217192      ENDDO
    218193c$OMP END DO NOWAIT
    219 #endif
    220194
    221195
     
    466440      INTEGER ifils,iq2 ! CRisi
    467441
    468       REAL      SSUM
    469 
    470442      DATA first/.true./
    471443      INTEGER ijb,ije
    472444      INTEGER ijbm,ijem
     445
     446      REAL ssum
    473447
    474448      ijb=ij_begin-2*iip1
  • LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90

    r5091 r5098  
    1717  USE vertical_layers_mod, ONLY : init_vertical_layers
    1818  USE infotrac, ONLY: nbtr, type_trac
    19 #ifdef CPP_StratAer
    20   USE infotrac_phy, ONLY: nbtr_bin, nbtr_sulgas, id_OCS_strat, &
    21                       id_SO2_strat, id_H2SO4_strat, id_BIN01_strat
    2219
    23 #endif
    2420#ifdef REPROBUS
    2521  USE CHEM_REP, ONLY : Init_chem_rep_phys
  • LMDZ6/branches/Amaury_dev/libf/filtrez/filtreg_mod.F90

    r5082 r5098  
    4343    LOGICAL, SAVE :: first_call_inifilr = .TRUE.
    4444
    45 #ifdef CRAY
    4645    INTEGER   ISMIN
    4746    EXTERNAL  ISMIN
    4847    INTEGER iymin
    4948    INTEGER ixmineq
    50 #endif
    5149    !
    5250    ! ------------------------------------------------------------
     
    104102    ENDDO
    105103    !
    106 #ifdef CRAY
    107     iymin   = ISMIN( jjm, dlatu, 1 )
    108     ixmineq = ISMIN( iim, dlonu, 1 )
    109     dymin   = dlatu( iymin )
    110     dxmin   = dlonu( ixmineq )
    111 #else
     104
    112105    dxmin   =  dlonu(1)
    113106    DO  i  = 2, iim
     
    118111       dymin = MIN( dymin,dlatu(j) )
    119112    ENDDO
    120 #endif
    121113    !
    122114    ! For a regular grid, we want the filter to start at latitudes
     
    372364          ENDDO
    373365       ENDDO ! of DO i=1,iim
    374 #ifdef CRAY
    375        CALL MXM( eignfnv,iim,eignft,iim,matriceun(1,1,j),iim )
    376 #else
     366
    377367#ifdef BLAS
    378368       CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
     
    389379       ENDDO ! of DO k = 1, iim
    390380#endif
    391 #endif
    392381
    393382    ENDDO ! of DO j = 2, jfiltnu
     
    402391          ENDDO
    403392       ENDDO ! of DO i=1,iim
    404 #ifdef CRAY
    405        CALL MXM(eignfnv,iim,eignft,iim,matriceus(1,1,j-jfiltsu+1),iim)
    406 #else
    407393#ifdef BLAS
    408394       CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
     
    420406       ENDDO ! of DO k = 1, iim
    421407#endif
    422 #endif
    423408
    424409    ENDDO ! of DO j = jfiltsu, jjm
     
    439424          ENDDO
    440425       ENDDO
    441 #ifdef CRAY
    442        CALL MXM( eignfnu,iim,eignft,iim,matricevn(1,1,j),iim )
    443 #else
     426
    444427#ifdef BLAS
    445428       CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
     
    456439       ENDDO
    457440#endif
    458 #endif
    459441
    460442    ENDDO ! of DO j = 1, jfiltnv
     
    469451          ENDDO
    470452       ENDDO
    471 #ifdef CRAY
    472        CALL MXM(eignfnu,iim,eignft,iim,matricevs(1,1,j-jfiltsv+1),iim)
    473 #else
     453
    474454#ifdef BLAS
    475455       CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
     
    487467       ENDDO
    488468#endif
    489 #endif
    490469
    491470    ENDDO ! of DO j = jfiltsv, jjm
     
    506485          ENDDO
    507486       ENDDO
    508 #ifdef CRAY
    509        CALL MXM( eignfnv,iim,eignft,iim,matrinvn(1,1,j),iim )
    510 #else
     487
    511488#ifdef BLAS
    512489       CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
     
    523500       ENDDO
    524501#endif
    525 #endif
    526502
    527503    ENDDO ! of DO j = 2, jfiltnu
     
    536512          ENDDO
    537513       ENDDO
    538 #ifdef CRAY
    539        CALL MXM(eignfnv,iim,eignft,iim,matrinvs(1,1,j-jfiltsu+1),iim)
    540 #else
    541514#ifdef BLAS
    542515       CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
     
    553526       ENDDO
    554527#endif
    555 #endif
    556528
    557529    ENDDO ! of DO j = jfiltsu, jjm
     
    569541    !
    570542334 FORMAT(1x,24i3)
    571 755 FORMAT(1x,6f10.3,i3)
    572 
    573     RETURN
     543
    574544  END SUBROUTINE inifilr
    575545
  • LMDZ6/branches/Amaury_dev/libf/filtrez/inifgn.F

    r5079 r5098  
    6767      END DO
    6868c
    69 #ifdef CRAY
    70       CALL MXM(eignfnu,iim,eignfnv,iim,vec ,iim)
    71       CALL MXM(eignfnv,iim,eignfnu,iim,vec1,iim)
    72 #else
    7369      DO j = 1, iim
    7470      DO i = 1, iim
     
    8177      ENDDO
    8278      ENDDO
    83 #endif
    8479
    8580c
  • LMDZ6/branches/Amaury_dev/libf/misc/lmdz_TO_MOVE_ssum_scopy.f90

    r5097 r5098  
    1 !
    2 ! $Header$
    3 !
    4 #ifdef CRAY
    5       SUBROUTINE riencray
    6       END
    7 #else
    8       subroutine scopy(n,sx,incx,sy,incy)
    9 c
    10       IMPLICIT NONE
    11 c
    12       integer n,incx,incy,ix,iy,i
    13       real sx((n-1)*incx+1),sy((n-1)*incy+1)
    14 c
    15       iy=1
    16       ix=1
    17       DO i=1,n
    18          sy(iy)=sx(ix)
    19          ix=ix+incx
    20          iy=iy+incy
    21       END DO
    22 c
    23       return
    24       end
     1! TO MOVE SOMEWHERE ELSE !! (Amaury - 07/2024)
     2! Move with other vector/math functions
     3! Those are old legacy CRAY replacement functions, that are now used in several parts of the code.
    254
    26       function ssum(n,sx,incx)
    27 c
    28       IMPLICIT NONE
    29 c
    30       integer n,incx,i,ix
    31       real ssum,sx((n-1)*incx+1)
    32 c
    33       ssum=0.
    34       ix=1
    35       do i=1,n
    36          ssum=ssum+sx(ix)
    37          ix=ix+incx
    38       END DO
    39 c
    40       return
    41       end
    42 #endif
     5subroutine scopy(n, sx, incx, sy, incy)
     6
     7  IMPLICIT NONE
     8
     9  integer n, incx, incy, ix, iy, i
     10  real sx((n - 1) * incx + 1), sy((n - 1) * incy + 1)
     11
     12  iy = 1
     13  ix = 1
     14  DO i = 1, n
     15    sy(iy) = sx(ix)
     16    ix = ix + incx
     17    iy = iy + incy
     18  END DO
     19
     20end
     21
     22function ssum(n, sx, incx)
     23
     24  IMPLICIT NONE
     25
     26  integer n, incx, i, ix
     27  real ssum, sx((n - 1) * incx + 1)
     28
     29  ssum = 0.
     30  ix = 1
     31  do i = 1, n
     32    ssum = ssum + sx(ix)
     33    ix = ix + incx
     34  END DO
     35
     36end
     37
  • LMDZ6/branches/Amaury_dev/libf/misc/lmdz_cppkeys_wrapper.F90

    r5091 r5098  
    22! This file is part of an effort to replace most uses of preprocessor CPP keys by fortran variables,
    33! to improve readability, compilation coverage, and linting.
    4 ! CPP keys used here should ONLY be used here,
     4! CPP keys used here should ONLY be used here (unless specified explicitely),
    55! and imported through USE ..., ONLY: ... elsewhere
    66! CPP keys supported (key -> fortran variables associated):
     
    88!      CPP_PHYS  -> CPPKEY_PHYS
    99!      INCA      -> CPPKEY_INCA
     10!      CPP_StratAer-> CPPKEY_STRATAER
    1011! ---------------------------------------------
    1112
     
    1415  USE netcdf, ONLY: nf90_float, nf90_double
    1516  IMPLICIT NONE; PRIVATE
    16   PUBLIC nf90_format, CPPKEY_PHYS, CPPKEY_INCA
     17  PUBLIC nf90_format, CPPKEY_PHYS, CPPKEY_INCA, CPPKEY_STRATAER
    1718
    1819#ifdef NC_DOUBLE
     
    3435#endif
    3536
     37#ifdef CPP_StratAer
     38  LOGICAL, PARAMETER :: CPPKEY_STRATAER = .TRUE.
     39#else
     40  LOGICAL, PARAMETER :: CPPKEY_STRATAER = .FALSE.
     41#endif
     42
    3643END MODULE lmdz_cppkeys_wrapper
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/aer_sedimnt.F90

    r5087 r5098  
    2222  USE infotrac_phy
    2323  USE aerophys
    24   USE YOMCST
     24  USE lmdz_yomcst
    2525
    2626IMPLICIT NONE
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90

    r5082 r5098  
    99  USE dimphy
    1010  USE temps_mod
    11   USE YOMCST
     11  USE lmdz_yomcst
    1212
    1313  IMPLICIT NONE
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/coagulate.F90

    r5087 r5098  
    2828  USE phys_local_var_mod, ONLY: DENSO4, DENSO4B, f_r_wet, f_r_wetB
    2929  USE strataer_local_var_mod, ONLY: flag_new_strat_compo
     30  USE lmdz_yomcst
    3031 
    3132  IMPLICIT NONE
     
    8384  REAL                                          :: EvdW
    8485
    85   include "YOMCST.h"
    86 
    8786! ff(i,j,k): Volume fraction of Vi,j that is partitioned to each model bin k
    8887! just need to be calculated in model initialization because mdw(:) size is fixed
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/cond_evap_tstep_mod.F90

    r5087 r5098  
    2828      USE aerophys
    2929      USE infotrac_phy
    30       USE YOMCST, ONLY : RPI
     30      USE lmdz_yomcst, ONLY : RPI
    3131      USE sulfate_aer_mod, ONLY : wph2so4, surftension, solh2so4, rpmvh2so4
    3232      USE strataer_local_var_mod, ONLY : ALPH2SO4, RRSI
    3333     
    3434      IMPLICIT NONE
    35      
     35
    3636      REAL, PARAMETER :: third=1./3.
    3737     
     
    177177      USE aerophys
    178178      USE infotrac_phy
    179       USE YOMCST, ONLY : RPI
     179      USE lmdz_yomcst, ONLY : RPI
    180180      USE strataer_local_var_mod, ONLY : ALPH2SO4, RRSI
    181181
     
    290290      USE aerophys
    291291      USE infotrac_phy
    292       USE YOMCST, ONLY : RPI
     292      USE lmdz_yomcst, ONLY : RPI
    293293      USE strataer_local_var_mod, ONLY : RRSI,Vbin
    294294     
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/interp_sulf_input.F90

    r5088 r5098  
    1818  USE infotrac_phy
    1919  USE aerophys
    20   USE YOMCST
     20  USE lmdz_yomcst
    2121  USE strataer_local_var_mod, ONLY : flag_newclim_file,flag_verbose_strataer
    2222
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/micphy_tstep.F90

    r5087 r5098  
    1313  USE cond_evap_tstep_mod
    1414  USE sulfate_aer_mod, ONLY : STRAACT
    15   USE YOMCST, ONLY : RPI, RD, RG
     15  USE lmdz_yomcst, ONLY : RPI, RD, RG
    1616  USE print_control_mod, ONLY: lunout
    1717  USE strataer_local_var_mod ! contains also RRSI and Vbin
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/miecalc_aer.F90

    r5087 r5098  
    2020  USE infotrac_phy, ONLY : nbtr, nbtr_bin, nbtr_sulgas, id_SO2_strat
    2121  USE dimphy
    22   USE YOMCST  , ONLY : RG, RPI
     22  USE lmdz_yomcst  , ONLY : RG, RPI
    2323  USE mod_phys_lmdz_para, only: gather, scatter, bcast
    2424  USE mod_grid_phy_lmdz, ONLY : klon_glo
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/nucleation_tstep_mod.F90

    r5087 r5098  
    1111  USE infotrac_phy
    1212  USE strataer_local_var_mod, ONLY : flag_new_nucl
     13  USE lmdz_yomcst
    1314 
    1415  IMPLICIT NONE
     
    3738  REAL airn    ! Air molecule concentration in (cm-3) NOT IN USE
    3839  REAL ipr     ! Ion pair production rate (cm-3 s-1) NOT IN USE
    39 
    40   include "YOMCST.h"
    4140
    4241  ! call nucleation routine
     
    332331
    333332  USE aerophys
     333  USE lmdz_yomcst
    334334
    335335  IMPLICIT NONE
     
    385385  DOUBLE PRECISION :: xloss       ! Ion loss rate
    386386  DOUBLE PRECISION :: recomb      ! Ion-ion recombination rate
    387 
    388   include "YOMCST.h"
    389387
    390388  !--- 0) Initializations:
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/ocs_to_so2.F90

    r5082 r5098  
    77  USE aerophys
    88  USE infotrac_phy
    9   USE YOMCST, ONLY : RG
     9  USE lmdz_yomcst, ONLY : RG
    1010  USE phys_local_var_mod, ONLY : OCS_lifetime, budg_3D_ocs_to_so2, budg_ocs_to_so2
    1111  USE strataer_local_var_mod, ONLY : flag_min_rreduce
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/so2_to_h2so4.F90

    r5087 r5098  
    77  USE aerophys
    88  USE infotrac_phy
    9   USE YOMCST, ONLY : RG, RD
     9  USE lmdz_yomcst, ONLY : RG, RD
    1010  ! lifetime (sec) et O3_clim (VMR)
    1111  USE phys_local_var_mod, ONLY : SO2_lifetime, H2SO4_lifetime, O3_clim, budg_3D_so2_to_h2so4, budg_so2_to_h2so4
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/stratH2O_methox.F90

    r5088 r5098  
    1919  USE infotrac_phy
    2020  USE aerophys
    21   USE YOMCST
     21  USE lmdz_yomcst
    2222  USE strataer_local_var_mod, ONLY : flag_newclim_file
    2323 
    2424  IMPLICIT NONE
    25  
     25
    2626  include "dimensions.h"
    2727 
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/strataer_emiss_mod.F90

    r5082 r5098  
    219219    USE print_control_mod, ONLY : lunout
    220220    USE strataer_local_var_mod
    221 
    222     INCLUDE "YOMCST.h"  !--RPI
     221    USE lmdz_yomcst, ONLY: RPI
    223222
    224223    ! local var
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/strataer_local_var_mod.F90

    r5082 r5098  
    11MODULE strataer_local_var_mod
    2 ! This module contains strato microphysic model parameters & variables
    3  
     2  ! This module contains strato microphysic model parameters & variables
     3
    44  IMPLICIT NONE
    5  
     5
    66  !============= GENERAL PARAMS =============
    77  !flag for type emission scenario: (0) background aer ; (1) volcanic eruption with Sulfur ;
    88  !(2,3) strato aer injections (SAI) ; (4) volcanic eruption chimistry; (5) rocket
    9   INTEGER,SAVE :: flag_emit
     9  INTEGER, SAVE :: flag_emit
    1010  !$OMP THREADPRIVATE(flag_emit)
    11  
     11
    1212  ! flag for emission altitude distribution: (0) gaussian; (1) uniform
    13   INTEGER,SAVE :: flag_emit_distrib
     13  INTEGER, SAVE :: flag_emit_distrib
    1414  !$OMP THREADPRIVATE(flag_emit_distrib)
    15  
     15
    1616  ! flag to choose nucleation nucleation method
    17   LOGICAL,SAVE :: flag_new_nucl   ! T=new routine from A. Maattanen (LATMOS), F=older routine from H. Vehkamäki (FMI)
     17  LOGICAL, SAVE :: flag_new_nucl   ! T=new routine from A. Maattanen (LATMOS), F=older routine from H. Vehkamäki (FMI)
    1818  !$OMP THREADPRIVATE(flag_new_nucl)
    19  
     19
    2020  ! Use relative humidity from 2D model stratospheric H2O because LMDz is too dry in the stratosphere
    2121  ! (no CH4 oxidation)
    22   LOGICAL,SAVE :: flag_H2O2d_nucleation
     22  LOGICAL, SAVE :: flag_H2O2d_nucleation
    2323  !$OMP THREADPRIVATE(flag_H2O2d_nucleation)
    24  
     24
    2525  ! OH reduction from SO2. OH is reduced when its reaction with SO2 competes sufficiently with its reaction
    2626  ! with O3 (Bekki, 1995). As a result, SO2 lifetime is extended. 2D model O3 climatologies are needed.
    27   LOGICAL,SAVE :: flag_OH_reduced
     27  LOGICAL, SAVE :: flag_OH_reduced
    2828  !$OMP THREADPRIVATE(flag_OH_reduced)
    29  
     29
    3030  ! H2SO4 photolysis: H2SO4 is converted into SO2 by complex photolytic processes. Here simplified approach
    3131  ! by setting H2SO4 cross-sections = 0.3*HCl cross-sections (Rinsland et al., 1995)
    32   LOGICAL,SAVE :: flag_H2SO4_photolysis
     32  LOGICAL, SAVE :: flag_H2SO4_photolysis
    3333  !$OMP THREADPRIVATE(flag_H2SO4_photolysis)
    34  
     34
    3535  ! flag for minimum lifetime (=1.5 pdt phys)
    36   LOGICAL,SAVE :: flag_min_rreduce
     36  LOGICAL, SAVE :: flag_min_rreduce
    3737  !$OMP THREADPRIVATE(flag_min_rreduce)
    38  
     38
    3939  ! flag to read new climato (O3, H2O & H2SO4_LIFET)
    40   LOGICAL,SAVE :: flag_newclim_file
     40  LOGICAL, SAVE :: flag_newclim_file
    4141  !$OMP THREADPRIVATE(flag_newclim_file)
    42  
     42
    4343  ! flag to choose new H2SO4 density and weight percent from Tabazadeh et al. (1994).
    44   LOGICAL,SAVE :: flag_new_strat_compo
     44  LOGICAL, SAVE :: flag_new_strat_compo
    4545  !$OMP THREADPRIVATE(flag_new_strat_compo)
    46  
     46
    4747  ! Verbose mode to get more print info
    4848  LOGICAL, SAVE :: flag_verbose_strataer
    4949  !$OMP THREADPRIVATE(flag_verbose_strataer)
    50  
    51  
     50
     51
    5252  !============= NUCLEATION VARS =============
    5353  ! MOLECULAR ACCOMODATION OF H2SO4 (Raes and Van Dingen)
    54   REAL,SAVE    :: ALPH2SO4               ! H2SO4 accommodation  coefficient [condensation/evaporation]
     54  REAL, SAVE :: ALPH2SO4               ! H2SO4 accommodation  coefficient [condensation/evaporation]
    5555  !$OMP THREADPRIVATE(ALPH2SO4)
    56  
     56
    5757  ! flag to constraint nucleation rate in a lat/pres box
    58   LOGICAL,SAVE :: flag_nuc_rate_box      ! Nucleation rate limit or not to a lat/pres
     58  LOGICAL, SAVE :: flag_nuc_rate_box      ! Nucleation rate limit or not to a lat/pres
    5959  !$OMP THREADPRIVATE(flag_nuc_rate_box)
    60   REAL,SAVE    :: nuclat_min             ! min lat to activate nuc rate
    61   REAL,SAVE    :: nuclat_max             ! max lat to activate nuc rate
    62   REAL,SAVE    :: nucpres_min            ! min pres to activate nuc rate
    63   REAL,SAVE    :: nucpres_max            ! max pres to activate nuc rate
     60  REAL, SAVE :: nuclat_min             ! min lat to activate nuc rate
     61  REAL, SAVE :: nuclat_max             ! max lat to activate nuc rate
     62  REAL, SAVE :: nucpres_min            ! min pres to activate nuc rate
     63  REAL, SAVE :: nucpres_max            ! max pres to activate nuc rate
    6464  !$OMP THREADPRIVATE(nuclat_min, nuclat_max, nucpres_min, nucpres_max)
    6565
    66   LOGICAL,SAVE :: ok_qemiss
     66  LOGICAL, SAVE :: ok_qemiss
    6767  !$OMP THREADPRIVATE(ok_qemiss)
    68   INTEGER,SAVE :: flh2o  ! ds stratemit : flh2o =0 (tr_seri), flh2o=1 (dq)
     68  INTEGER, SAVE :: flh2o  ! ds stratemit : flh2o =0 (tr_seri), flh2o=1 (dq)
    6969  !$OMP THREADPRIVATE(flh2o)
    70  
    71   REAL,ALLOCATABLE,SAVE    :: budg_emi(:,:)            !DIMENSION(klon,n)
     70
     71  REAL, ALLOCATABLE, SAVE :: budg_emi(:, :)            !DIMENSION(klon,n)
    7272  !$OMP THREADPRIVATE(budg_emi)
    73  
    74  
     73
     74
    7575  !============= EMISSION VARS =============
    7676  !--flag_emit=1 OR == 4 -- Volcanic eruption(s)
    77   INTEGER,SAVE            :: nErupt                    ! number of eruptions specs
    78   REAL,SAVE                :: injdur                    ! volcanic injection duration
     77  INTEGER, SAVE :: nErupt                    ! number of eruptions specs
     78  REAL, SAVE :: injdur                    ! volcanic injection duration
    7979  !$OMP THREADPRIVATE(nErupt, injdur)
    80   INTEGER,ALLOCATABLE,SAVE :: year_emit_vol(:)          ! year of emission date
    81   INTEGER,ALLOCATABLE,SAVE :: mth_emit_vol(:)           ! month of emission date
    82   INTEGER,ALLOCATABLE,SAVE :: day_emit_vol(:)           ! day of emission date
     80  INTEGER, ALLOCATABLE, SAVE :: year_emit_vol(:)          ! year of emission date
     81  INTEGER, ALLOCATABLE, SAVE :: mth_emit_vol(:)           ! month of emission date
     82  INTEGER, ALLOCATABLE, SAVE :: day_emit_vol(:)           ! day of emission date
    8383  !$OMP THREADPRIVATE(year_emit_vol, mth_emit_vol, day_emit_vol)
    84   REAL,ALLOCATABLE,SAVE    :: altemiss_vol(:)           ! emission altitude in m
    85   REAL,ALLOCATABLE,SAVE    :: sigma_alt_vol(:)          ! standard deviation of emission altitude in m
     84  REAL, ALLOCATABLE, SAVE :: altemiss_vol(:)           ! emission altitude in m
     85  REAL, ALLOCATABLE, SAVE :: sigma_alt_vol(:)          ! standard deviation of emission altitude in m
    8686  !$OMP THREADPRIVATE(altemiss_vol, sigma_alt_vol)
    87   INTEGER,ALLOCATABLE,SAVE :: ponde_lonlat_vol(:)       ! lon/lat ponderation factor
    88   REAL,ALLOCATABLE,SAVE    :: xlat_min_vol(:)           ! min latitude of volcano in degree
    89   REAL,ALLOCATABLE,SAVE    :: xlat_max_vol(:)           ! max latitude of volcano in degree
    90   REAL,ALLOCATABLE,SAVE    :: xlon_min_vol(:)           ! min longitude of volcano in degree
    91   REAL,ALLOCATABLE,SAVE    :: xlon_max_vol(:)           ! max longitude of volcano in degree
     87  INTEGER, ALLOCATABLE, SAVE :: ponde_lonlat_vol(:)       ! lon/lat ponderation factor
     88  REAL, ALLOCATABLE, SAVE :: xlat_min_vol(:)           ! min latitude of volcano in degree
     89  REAL, ALLOCATABLE, SAVE :: xlat_max_vol(:)           ! max latitude of volcano in degree
     90  REAL, ALLOCATABLE, SAVE :: xlon_min_vol(:)           ! min longitude of volcano in degree
     91  REAL, ALLOCATABLE, SAVE :: xlon_max_vol(:)           ! max longitude of volcano in degree
    9292  !$OMP THREADPRIVATE(ponde_lonlat_vol, xlat_min_vol, xlat_max_vol, xlon_min_vol, xlon_max_vol)
    93  
     93
    9494  !--flag_emit=1
    95   INTEGER,SAVE             :: nAerErupt                 ! number Aerosol
     95  INTEGER, SAVE :: nAerErupt                 ! number Aerosol
    9696  !$OMP THREADPRIVATE(nAerErupt)
    97   REAL,ALLOCATABLE,SAVE    :: m_sulf_emiss_vol(:)        ! emitted sulfur mass in kgS, e.g. 7Tg(S)=14Tg(SO2)
    98   REAL,ALLOCATABLE,SAVE    :: m_aer_emiss_vol(:,:)
     97  REAL, ALLOCATABLE, SAVE :: m_sulf_emiss_vol(:)        ! emitted sulfur mass in kgS, e.g. 7Tg(S)=14Tg(SO2)
     98  REAL, ALLOCATABLE, SAVE :: m_aer_emiss_vol(:, :)
    9999  !$OMP THREADPRIVATE(m_sulf_emiss_vol,m_aer_emiss_vol)
    100  
     100
    101101  !--flag_emit=2 --SAI
    102   REAL,SAVE    :: m_aer_emiss_sai        ! emitted sulfur mass in kgS, eg 1e9=1TgS, 1e10=10TgS
    103   REAL,SAVE    :: altemiss_sai           ! emission altitude in m
    104   REAL,SAVE    :: sigma_alt_sai          ! standard deviation of emission altitude in m
     102  REAL, SAVE :: m_aer_emiss_sai        ! emitted sulfur mass in kgS, eg 1e9=1TgS, 1e10=10TgS
     103  REAL, SAVE :: altemiss_sai           ! emission altitude in m
     104  REAL, SAVE :: sigma_alt_sai          ! standard deviation of emission altitude in m
    105105  !$OMP THREADPRIVATE(m_aer_emiss_sai, altemiss_sai, sigma_alt_sai)
    106   INTEGER,SAVE    :: year_emit_sai_start
    107   INTEGER,SAVE    :: year_emit_sai_end
    108   INTEGER,SAVE    :: mth_emit_sai_start
    109   INTEGER,SAVE    :: mth_emit_sai_end
    110   INTEGER,SAVE    :: day_emit_sai_start
    111   INTEGER,SAVE    :: day_emit_sai_end
     106  INTEGER, SAVE :: year_emit_sai_start
     107  INTEGER, SAVE :: year_emit_sai_end
     108  INTEGER, SAVE :: mth_emit_sai_start
     109  INTEGER, SAVE :: mth_emit_sai_end
     110  INTEGER, SAVE :: day_emit_sai_start
     111  INTEGER, SAVE :: day_emit_sai_end
    112112  !$OMP THREADPRIVATE(year_emit_sai_start, year_emit_sai_end)
    113113  !$OMP THREADPRIVATE(mth_emit_sai_start, mth_emit_sai_end)
    114114  !$OMP THREADPRIVATE(day_emit_sai_start, day_emit_sai_end)
    115   REAL,SAVE    :: xlat_sai               ! latitude of SAI in degree
    116   REAL,SAVE    :: xlon_sai               ! longitude of SAI in degree
     115  REAL, SAVE :: xlat_sai               ! latitude of SAI in degree
     116  REAL, SAVE :: xlon_sai               ! longitude of SAI in degree
    117117  !$OMP THREADPRIVATE(xlat_sai, xlon_sai)
    118  
     118
    119119  !--flag_emit=3 -- SAI
    120   REAL,SAVE    :: xlat_max_sai           ! maximum latitude of SAI in degrees
    121   REAL,SAVE    :: xlat_min_sai           ! minimum latitude of SAI in degrees
     120  REAL, SAVE :: xlat_max_sai           ! maximum latitude of SAI in degrees
     121  REAL, SAVE :: xlat_min_sai           ! minimum latitude of SAI in degrees
    122122  !$OMP THREADPRIVATE(xlat_min_sai,xlat_max_sai)
    123  
     123
    124124  !--flag_emit=4 -- volc species
    125   INTEGER,SAVE            :: nSpeciesErupt            ! number of species Repr
    126   INTEGER,ALLOCATABLE,SAVE :: id_species(:)            ! indice species Repr
    127   REAL,ALLOCATABLE,SAVE    :: m_species_emiss_vol(:,:) ! emitted species
     125  INTEGER, SAVE :: nSpeciesErupt            ! number of species Repr
     126  INTEGER, ALLOCATABLE, SAVE :: id_species(:)            ! indice species Repr
     127  REAL, ALLOCATABLE, SAVE :: m_species_emiss_vol(:, :) ! emitted species
    128128  !$OMP THREADPRIVATE(nSpeciesErupt,id_species,m_species_emiss_vol)
    129   INTEGER,ALLOCATABLE,SAVE :: id_HCl
    130   INTEGER,ALLOCATABLE,SAVE :: id_HBr
    131   INTEGER,ALLOCATABLE,SAVE :: id_NOx
    132   INTEGER,ALLOCATABLE,SAVE :: id_H2O
     129  INTEGER, ALLOCATABLE, SAVE :: id_HCl
     130  INTEGER, ALLOCATABLE, SAVE :: id_HBr
     131  INTEGER, ALLOCATABLE, SAVE :: id_NOx
     132  INTEGER, ALLOCATABLE, SAVE :: id_H2O
    133133  !$OMP THREADPRIVATE(id_HCl,id_HBr,id_NOx,id_H2O)
    134   REAL,ALLOCATABLE,SAVE    :: m_Chlore_emiss_vol(:)   ! emitted Chlore mass
    135   REAL,ALLOCATABLE,SAVE    :: m_Brome_emiss_vol(:)    ! emitted Brome mass
    136   REAL,ALLOCATABLE,SAVE    :: m_NOx_emiss_vol(:)      ! emitted NOx mass
    137   REAL,ALLOCATABLE,SAVE    :: m_H2O_emiss_vol(:)      ! emitted H2O mass
    138   REAL,ALLOCATABLE,SAVE    :: m_H2O_emiss_vol_daily(:)
     134  REAL, ALLOCATABLE, SAVE :: m_Chlore_emiss_vol(:)   ! emitted Chlore mass
     135  REAL, ALLOCATABLE, SAVE :: m_Brome_emiss_vol(:)    ! emitted Brome mass
     136  REAL, ALLOCATABLE, SAVE :: m_NOx_emiss_vol(:)      ! emitted NOx mass
     137  REAL, ALLOCATABLE, SAVE :: m_H2O_emiss_vol(:)      ! emitted H2O mass
     138  REAL, ALLOCATABLE, SAVE :: m_H2O_emiss_vol_daily(:)
    139139  !$OMP THREADPRIVATE(m_Chlore_emiss_vol,m_Brome_emiss_vol,m_NOx_emiss_vol,m_H2O_emiss_vol)
    140140  !$OMP THREADPRIVATE(m_H2O_emiss_vol_daily)
    141  
     141
    142142  !--flag_emit=5 -- Rockets Emitted
    143   INTEGER, SAVE            :: ifreqroc        ! frequence (=2 ex: tous les 2 mois)
     143  INTEGER, SAVE :: ifreqroc        ! frequence (=2 ex: tous les 2 mois)
    144144  !$OMP THREADPRIVATE(ifreqroc)
    145   INTEGER,ALLOCATABLE,SAVE :: day_emit_roc(:) ! day of emission date
     145  INTEGER, ALLOCATABLE, SAVE :: day_emit_roc(:) ! day of emission date
    146146  !$OMP THREADPRIVATE(day_emit_roc)
    147  
    148   REAL,ALLOCATABLE,SAVE    :: RRSI(:) ! radius [cm] for each aerosol size
    149   REAL,ALLOCATABLE,SAVE    :: Vbin(:) ! volume [m3] for each aerosol size 
     147
     148  REAL, ALLOCATABLE, SAVE :: RRSI(:) ! radius [cm] for each aerosol size
     149  REAL, ALLOCATABLE, SAVE :: Vbin(:) ! volume [m3] for each aerosol size
    150150  !$OMP THREADPRIVATE(RRSI, Vbin)
    151   REAL,SAVE    :: dlat, dlon             ! delta latitude and d longitude of grid in degree
     151  REAL, SAVE :: dlat, dlon             ! delta latitude and d longitude of grid in degree
    152152  !$OMP THREADPRIVATE(dlat, dlon)
    153  
     153
    154154CONTAINS
    155    
     155
    156156  SUBROUTINE strataer_init()
    157     USE ioipsl_getin_p_mod, ONLY : getin_p
    158     USE print_control_mod, ONLY : lunout
    159     USE mod_phys_lmdz_para, ONLY : is_master
    160     USE infotrac_phy, ONLY: id_OCS_strat,id_SO2_strat,id_H2SO4_strat,nbtr_sulgas,nbtr_bin
    161     USE phys_local_var_mod, ONLY : mdw
     157    USE ioipsl_getin_p_mod, ONLY: getin_p
     158    USE print_control_mod, ONLY: lunout
     159    USE mod_phys_lmdz_para, ONLY: is_master
     160    USE infotrac_phy, ONLY: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, nbtr_sulgas, nbtr_bin
     161    USE phys_local_var_mod, ONLY: mdw
    162162    USE aerophys, ONLY: mdwmin, V_rat
    163     USE YOMCST  , ONLY : RPI
    164    
     163    USE lmdz_yomcst, ONLY: RPI
     164
    165165    INTEGER :: it
    166    
    167     WRITE(lunout,*) 'IN STRATAER_LOCAL_VAR INIT WELCOME!'
    168    
     166
     167    WRITE(lunout, *) 'IN STRATAER_LOCAL_VAR INIT WELCOME!'
     168
    169169    !============= Check Sulfur aerosols ID =============
    170     WRITE(lunout,*) 'STRATAER_LOCAL_VAR INIT: id_OCS_strat=',id_OCS_strat,' id_SO2_strat=',id_SO2_strat,' id_H2SO4_strat=',id_H2SO4_strat
    171    
     170    WRITE(lunout, *) 'STRATAER_LOCAL_VAR INIT: id_OCS_strat=', id_OCS_strat, ' id_SO2_strat=', id_SO2_strat, ' id_H2SO4_strat=', id_H2SO4_strat
     171
    172172    IF(id_OCS_strat < 0 .OR. id_OCS_strat > nbtr_sulgas) THEN
    173        WRITE(lunout,*) 'ERROR : OCS index id_OCS_strat=',id_OCS_strat,' is negative or superior than the total sulfur gases !'
    174        CALL abort_physic('strataer_local_var_mod','Wrong OCS index, check your tracer.def file.',1)
     173      WRITE(lunout, *) 'ERROR : OCS index id_OCS_strat=', id_OCS_strat, ' is negative or superior than the total sulfur gases !'
     174      CALL abort_physic('strataer_local_var_mod', 'Wrong OCS index, check your tracer.def file.', 1)
    175175    ELSEIF(id_SO2_strat < 0 .OR. id_SO2_strat > nbtr_sulgas) THEN
    176        WRITE(lunout,*) 'ERROR : SO2 index id_SO2_strat=',id_SO2_strat,' is negative or superior than the total sulfur gases !'
    177        CALL abort_physic('strataer_local_var_mod','Wrong SO2 index, check your tracer.def file.',1)
     176      WRITE(lunout, *) 'ERROR : SO2 index id_SO2_strat=', id_SO2_strat, ' is negative or superior than the total sulfur gases !'
     177      CALL abort_physic('strataer_local_var_mod', 'Wrong SO2 index, check your tracer.def file.', 1)
    178178    ELSEIF(id_H2SO4_strat < 0 .OR. id_H2SO4_strat > nbtr_sulgas) THEN
    179        WRITE(lunout,*) 'ERROR : H2SO4 index id_H2SO4_strat=',id_H2SO4_strat,' is negative or superior than the total sulfur gases !'
    180        CALL abort_physic('strataer_local_var_mod','Wrong H2SO4 index, check your tracer.def file.',1)
    181     ENDIF
    182    
     179      WRITE(lunout, *) 'ERROR : H2SO4 index id_H2SO4_strat=', id_H2SO4_strat, ' is negative or superior than the total sulfur gases !'
     180      CALL abort_physic('strataer_local_var_mod', 'Wrong H2SO4 index, check your tracer.def file.', 1)
     181    ENDIF
     182
    183183    !============= Init params =============
    184184    flag_emit = 0                   ! Background (default)
     
    191191    flag_H2SO4_photolysis = .FALSE. ! H2SO4 photolysis (default: No)
    192192    flag_min_rreduce = .TRUE.       ! Minimum lifetime=1.5 pdt phys (default: Yes)
    193     flag_new_strat_compo =.TRUE.    ! H2SO4/H2O weight percent & density routine (default: S. Bekki)
     193    flag_new_strat_compo = .TRUE.    ! H2SO4/H2O weight percent & density routine (default: S. Bekki)
    194194    ok_qemiss = .FALSE.             ! H2O emission flag
    195    
     195
    196196    ! nuc init
    197197    ALPH2SO4 = 0.1
    198198    flag_nuc_rate_box = .FALSE.
    199     nuclat_min=0  ; nuclat_max=0
    200     nucpres_min=0 ; nucpres_max=0
    201    
     199    nuclat_min = 0  ; nuclat_max = 0
     200    nucpres_min = 0 ; nucpres_max = 0
     201
    202202    ! emiss init
    203203    nErupt = 0 ! eruption number
    204204    injdur = 0 ! init injection duration
    205205    nAerErupt = 1 ; nSpeciesErupt = 1
    206     ifreqroc=2 ; flh2o=0
    207    
     206    ifreqroc = 2 ; flh2o = 0
     207
    208208    !============= Read params =============
    209     CALL getin_p('flag_emit',flag_emit)
    210     CALL getin_p('flag_emit_distrib',flag_emit_distrib)
    211     CALL getin_p('flag_verbose_strataer',flag_verbose_strataer)
    212     CALL getin_p('flag_new_nucl',flag_new_nucl)
    213     CALL getin_p('flag_newclim_file',flag_newclim_file)
    214     CALL getin_p('flag_H2O2d_nucleation',flag_H2O2d_nucleation)
    215     CALL getin_p('flag_OH_reduced',flag_OH_reduced)
    216     CALL getin_p('flag_H2SO4_photolysis',flag_H2SO4_photolysis)
    217     CALL getin_p('flag_min_rreduce',flag_min_rreduce)
    218     CALL getin_p('flag_new_strat_compo',flag_new_strat_compo)
    219     CALL getin_p('ok_qemiss',ok_qemiss)
    220    
     209    CALL getin_p('flag_emit', flag_emit)
     210    CALL getin_p('flag_emit_distrib', flag_emit_distrib)
     211    CALL getin_p('flag_verbose_strataer', flag_verbose_strataer)
     212    CALL getin_p('flag_new_nucl', flag_new_nucl)
     213    CALL getin_p('flag_newclim_file', flag_newclim_file)
     214    CALL getin_p('flag_H2O2d_nucleation', flag_H2O2d_nucleation)
     215    CALL getin_p('flag_OH_reduced', flag_OH_reduced)
     216    CALL getin_p('flag_H2SO4_photolysis', flag_H2SO4_photolysis)
     217    CALL getin_p('flag_min_rreduce', flag_min_rreduce)
     218    CALL getin_p('flag_new_strat_compo', flag_new_strat_compo)
     219    CALL getin_p('ok_qemiss', ok_qemiss)
     220
    221221    !============= Test flag coherence =============
    222222    IF (.NOT. flag_newclim_file) THEN
    223        IF (flag_H2SO4_photolysis .OR. flag_OH_reduced .OR. flag_H2O2d_nucleation) THEN
    224           WRITE(lunout,*) 'ERROR : flag_newclim_file=',flag_newclim_file, &
    225                ' whereas flag_H2SO4_photolysis=',flag_H2SO4_photolysis,', flag_OH_reduced=',flag_OH_reduced, &
    226                ' and flag_H2O2d_nucleation=',flag_H2O2d_nucleation
    227           CALL abort_physic('strataer_local_var_mod','Incompatible options in physiq_def file !',1)
    228        ENDIF
    229        IF(flag_min_rreduce) THEN
    230           WRITE(lunout,*) 'Warning : flag_min_rreduce will be ignored with old climato file !'
    231        ENDIF
    232     ENDIF
    233    
     223      IF (flag_H2SO4_photolysis .OR. flag_OH_reduced .OR. flag_H2O2d_nucleation) THEN
     224        WRITE(lunout, *) 'ERROR : flag_newclim_file=', flag_newclim_file, &
     225                ' whereas flag_H2SO4_photolysis=', flag_H2SO4_photolysis, ', flag_OH_reduced=', flag_OH_reduced, &
     226                ' and flag_H2O2d_nucleation=', flag_H2O2d_nucleation
     227        CALL abort_physic('strataer_local_var_mod', 'Incompatible options in physiq_def file !', 1)
     228      ENDIF
     229      IF(flag_min_rreduce) THEN
     230        WRITE(lunout, *) 'Warning : flag_min_rreduce will be ignored with old climato file !'
     231      ENDIF
     232    ENDIF
     233
    234234    !============= Print params =============
    235235    IF (is_master) THEN
    236        WRITE(lunout,*) 'flag_emit = ',flag_emit
    237        WRITE(lunout,*) 'IN STRATAER : flag_new_nucl = ',flag_new_nucl
    238        WRITE(lunout,*) 'IN STRATAER : flag_newclim_file = ',flag_newclim_file
    239        WRITE(lunout,*) 'IN STRATAER : flag_emit_distrib = ',flag_emit_distrib
    240        WRITE(lunout,*) 'IN STRATAER : flag_verbose_strataer = ',flag_verbose_strataer
    241        IF (flag_emit == 1 .OR. flag_emit == 4) THEN
    242           WRITE(lunout,*) 'IN STRATAER : flag_H2O2d_nucleation = ',flag_H2O2d_nucleation
    243           WRITE(lunout,*) 'IN STRATAER : flag_OH_reduced = ',flag_OH_reduced
    244           WRITE(lunout,*) 'IN STRATAER : flag_H2SO4_photolysis = ',flag_H2SO4_photolysis
    245           WRITE(lunout,*) 'IN STRATAER : flag_min_rreduce = ',flag_min_rreduce
    246           WRITE(lunout,*) 'IN STRATAER : flag_new_strat_compo = ',flag_new_strat_compo
    247           WRITE(lunout,*) 'IN STRATAER : ok_qemiss = ',ok_qemiss
    248        ENDIF
     236      WRITE(lunout, *) 'flag_emit = ', flag_emit
     237      WRITE(lunout, *) 'IN STRATAER : flag_new_nucl = ', flag_new_nucl
     238      WRITE(lunout, *) 'IN STRATAER : flag_newclim_file = ', flag_newclim_file
     239      WRITE(lunout, *) 'IN STRATAER : flag_emit_distrib = ', flag_emit_distrib
     240      WRITE(lunout, *) 'IN STRATAER : flag_verbose_strataer = ', flag_verbose_strataer
     241      IF (flag_emit == 1 .OR. flag_emit == 4) THEN
     242        WRITE(lunout, *) 'IN STRATAER : flag_H2O2d_nucleation = ', flag_H2O2d_nucleation
     243        WRITE(lunout, *) 'IN STRATAER : flag_OH_reduced = ', flag_OH_reduced
     244        WRITE(lunout, *) 'IN STRATAER : flag_H2SO4_photolysis = ', flag_H2SO4_photolysis
     245        WRITE(lunout, *) 'IN STRATAER : flag_min_rreduce = ', flag_min_rreduce
     246        WRITE(lunout, *) 'IN STRATAER : flag_new_strat_compo = ', flag_new_strat_compo
     247        WRITE(lunout, *) 'IN STRATAER : ok_qemiss = ', ok_qemiss
     248      ENDIF
    249249    ENDIF ! if master
    250    
     250
    251251    !--initialising dry diameters to geometrically spaced mass/volume (see Jacobson 1994)
    252     mdw(1)=mdwmin
     252    mdw(1) = mdwmin
    253253    IF (V_rat<1.62) THEN ! compensate for dip in second bin for lower volume ratio
    254        mdw(2)=mdw(1)*2.**(1./3.)
    255        DO it=3, nbtr_bin
    256           mdw(it)=mdw(it-1)*V_rat**(1./3.)
    257        ENDDO
     254      mdw(2) = mdw(1) * 2.**(1. / 3.)
     255      DO it = 3, nbtr_bin
     256        mdw(it) = mdw(it - 1) * V_rat**(1. / 3.)
     257      ENDDO
    258258    ELSE
    259        DO it=2, nbtr_bin
    260           mdw(it)=mdw(it-1)*V_rat**(1./3.)
    261        ENDDO
    262     ENDIF
    263     IF (is_master) WRITE(lunout,*) 'init mdw=', mdw
    264    
     259      DO it = 2, nbtr_bin
     260        mdw(it) = mdw(it - 1) * V_rat**(1. / 3.)
     261      ENDDO
     262    ENDIF
     263    IF (is_master) WRITE(lunout, *) 'init mdw=', mdw
     264
    265265    !   compute particle radius RRSI [cm] and volume Vbin [m3] from diameter mdw [m]
    266266    ALLOCATE(RRSI(nbtr_bin), Vbin(nbtr_bin))
    267    
    268     DO it=1,nbtr_bin
    269        !     [cm]
    270        RRSI(it)=mdw(it)/2.*100.
    271        !     [m3]
    272        Vbin(it)=4.0*RPI*((mdw(it)/2.)**3)/3.0
     267
     268    DO it = 1, nbtr_bin
     269      !     [cm]
     270      RRSI(it) = mdw(it) / 2. * 100.
     271      !     [m3]
     272      Vbin(it) = 4.0 * RPI * ((mdw(it) / 2.)**3) / 3.0
    273273    ENDDO
    274    
     274
    275275    IF (is_master) THEN
    276        WRITE(lunout,*) 'init RRSI=', RRSI
    277        WRITE(lunout,*) 'init Vbin=', Vbin
    278     ENDIF
    279    
    280     WRITE(lunout,*) 'IN STRATAER INIT END'
    281    
     276      WRITE(lunout, *) 'init RRSI=', RRSI
     277      WRITE(lunout, *) 'init Vbin=', Vbin
     278    ENDIF
     279
     280    WRITE(lunout, *) 'IN STRATAER INIT END'
     281
    282282  END SUBROUTINE strataer_init
    283  
     283
    284284END MODULE strataer_local_var_mod
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/stratdistrib.F90

    r5087 r5098  
    66  USE dimphy, ONLY : klon,klev
    77  USE strataer_local_var_mod
    8   USE YOMCST, only : RPI
     8  USE lmdz_yomcst, only : RPI
    99
    1010  IMPLICIT NONE
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/stratemit.F90

    r5087 r5098  
    1010  USE phys_cal_mod
    1111  USE phys_local_var_mod, ONLY: d_q_emiss
    12   USE YOMCST, only : RD, RPI, RG
     12  USE lmdz_yomcst, only : RD, RPI, RG
    1313  USE geometry_mod, ONLY : cell_area, boundslat
    1414  USE aerophys
  • LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/traccoag_mod.F90

    r5087 r5098  
    2424    USE sulfate_aer_mod
    2525    USE phys_local_var_mod, ONLY: stratomask
    26     USE YOMCST
     26    USE lmdz_yomcst
    2727    USE print_control_mod, ONLY: lunout
    2828    USE strataer_local_var_mod
  • LMDZ6/branches/Amaury_dev/libf/phylmd/coare30_flux_cnrm_mod.F90

    r5061 r5098  
    147147!
    148148
    149 !INCLUDE "YOMCST.h"
    150 !INCLUDE "clesphys.h"
    151 
    152149!*      0.2    declarations of local variables
    153150!
  • LMDZ6/branches/Amaury_dev/libf/phylmd/conf_phys_m.F90

    r5081 r5098  
    1111
    1212  SUBROUTINE conf_phys(ok_journe, ok_mensuel, ok_instan, ok_hf, &
    13        ok_LES,&
    14        callstats,&
    15        solarlong0,seuil_inversion, &
    16        fact_cldcon, facttemps,ok_newmicro,iflag_radia,&
    17        iflag_cld_th, &
    18        ratqsbas,ratqshaut,tau_ratqs, &
    19        ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan, flag_volc_surfstrat, aerosol_couple, &
    20        chemistry_couple, flag_aerosol, flag_aerosol_strat, flag_aer_feedback, &
    21        flag_bc_internal_mixture, bl95_b0, bl95_b1,&
    22        read_climoz, &
    23        alp_offset)
     13          ok_LES, &
     14          callstats, &
     15          solarlong0, seuil_inversion, &
     16          fact_cldcon, facttemps, ok_newmicro, iflag_radia, &
     17          iflag_cld_th, &
     18          ratqsbas, ratqshaut, tau_ratqs, &
     19          ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan, flag_volc_surfstrat, aerosol_couple, &
     20          chemistry_couple, flag_aerosol, flag_aerosol_strat, flag_aer_feedback, &
     21          flag_bc_internal_mixture, bl95_b0, bl95_b1, &
     22          read_climoz, &
     23          alp_offset)
    2424
    2525    USE IOIPSL
    2626    USE surface_data
    2727    USE phys_cal_mod
    28     USE carbon_cycle_mod,  ONLY: carbon_cycle_tr, carbon_cycle_cpl, carbon_cycle_rad, level_coupling_esm
    29     USE carbon_cycle_mod,  ONLY: read_fco2_ocean_cor,var_fco2_ocean_cor
    30     USE carbon_cycle_mod,  ONLY: read_fco2_land_cor,var_fco2_land_cor
    31     USE chemistry_cycle_mod, ONLY: dms_cycle_cpl, n2o_cycle_cpl
    32     USE mod_grid_phy_lmdz, ONLY: klon_glo
    33     USE print_control_mod, ONLY: lunout
    34     use config_ocean_skin_m, only: config_ocean_skin
    35     USE phys_state_var_mod, ONLY: phys_tstep
    36     USE infotrac_phy, ONLY: type_trac
     28    USE carbon_cycle_mod, ONLY : carbon_cycle_tr, carbon_cycle_cpl, carbon_cycle_rad, level_coupling_esm
     29    USE carbon_cycle_mod, ONLY : read_fco2_ocean_cor, var_fco2_ocean_cor
     30    USE carbon_cycle_mod, ONLY : read_fco2_land_cor, var_fco2_land_cor
     31    USE chemistry_cycle_mod, ONLY : dms_cycle_cpl, n2o_cycle_cpl
     32    USE mod_grid_phy_lmdz, ONLY : klon_glo
     33    USE print_control_mod, ONLY : lunout
     34    use config_ocean_skin_m, only : config_ocean_skin
     35    USE phys_state_var_mod, ONLY : phys_tstep
     36    USE infotrac_phy, ONLY : type_trac
     37    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
    3738
    3839    INCLUDE "conema3.h"
     
    7273
    7374    ! Sortie:
    74     LOGICAL              :: ok_newmicro
    75     INTEGER              :: iflag_radia
    76     LOGICAL              :: ok_journe, ok_mensuel, ok_instan, ok_hf
    77     LOGICAL              :: ok_LES
    78     LOGICAL              :: callstats
    79     LOGICAL              :: ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan
    80     LOGICAL              :: aerosol_couple, chemistry_couple
    81     INTEGER              :: flag_aerosol
    82     INTEGER              :: flag_aerosol_strat
    83     INTEGER              :: flag_volc_surfstrat
    84     LOGICAL              :: flag_aer_feedback
    85     LOGICAL              :: flag_bc_internal_mixture
    86     REAL                 :: bl95_b0, bl95_b1
    87     REAL                 :: fact_cldcon, facttemps,ratqsbas,ratqshaut,tau_ratqs
    88     INTEGER              :: iflag_cld_th
    89      
    90 
    91     CHARACTER (len = 6), SAVE  :: type_ocean_omp, version_ocean_omp, ocean_omp
    92     CHARACTER (len = 10),SAVE  :: type_veget_omp
    93     CHARACTER (len = 8), SAVE  :: aer_type_omp
    94     INTEGER, SAVE       :: landice_opt_omp
    95     INTEGER, SAVE       :: iflag_tsurf_inlandsis_omp,iflag_temp_inlandsis_omp
    96     INTEGER, SAVE       :: iflag_albcalc_omp,iflag_z0m_snow_omp   
    97     LOGICAL, SAVE       :: SnoMod_omp,BloMod_omp,ok_outfor_omp,ok_zsn_ii_omp
    98     LOGICAL, SAVE       :: discret_xf_omp,opt_runoff_ac_omp 
    99     LOGICAL, SAVE       :: is_ok_slush_omp,is_ok_z0h_rn_omp,is_ok_density_kotlyakov_omp
    100     REAL, SAVE          :: prescribed_z0m_snow_omp,correc_alb_omp
    101     REAL, SAVE          :: buf_sph_pol_omp,buf_siz_pol_omp
    102     LOGICAL, SAVE       :: ok_newmicro_omp
    103     LOGICAL, SAVE       :: ok_all_xml_omp
    104     LOGICAL, SAVE       :: ok_lwoff_omp
    105     LOGICAL, SAVE       :: ok_journe_omp, ok_mensuel_omp, ok_instan_omp, ok_hf_omp       
    106     LOGICAL, SAVE       :: ok_LES_omp   
    107     LOGICAL, SAVE       :: callstats_omp
    108     LOGICAL, SAVE       :: ok_ade_omp, ok_aie_omp, ok_alw_omp, ok_cdnc_omp, ok_volcan_omp
    109     LOGICAL, SAVE       :: aerosol_couple_omp, chemistry_couple_omp
    110     INTEGER, SAVE       :: flag_aerosol_omp
    111     INTEGER, SAVE       :: flag_aerosol_strat_omp
    112     INTEGER, SAVE       :: flag_volc_surfstrat_omp
    113     LOGICAL, SAVE       :: flag_aer_feedback_omp
    114     LOGICAL, SAVE       :: flag_bc_internal_mixture_omp
    115     REAL,SAVE           :: bl95_b0_omp, bl95_b1_omp
    116     REAL,SAVE           :: freq_ISCCP_omp, ecrit_ISCCP_omp
    117     REAL,SAVE           :: freq_COSP_omp, freq_AIRS_omp
    118     REAL,SAVE           :: fact_cldcon_omp, facttemps_omp,ratqsbas_omp
    119     REAL,SAVE           :: tau_cld_cv_omp, coefw_cld_cv_omp
    120     INTEGER, SAVE       :: iflag_cld_cv_omp
    121 
    122     REAL, SAVE          :: ratqshaut_omp
    123     REAL, SAVE          :: tau_ratqs_omp
    124     REAL, SAVE          :: t_coupl_omp
    125     INTEGER, SAVE       :: iflag_radia_omp
    126     INTEGER, SAVE       :: iflag_rrtm_omp
    127     INTEGER, SAVE       :: iflag_albedo_omp !albedo SB
    128     LOGICAL, SAVE       :: ok_chlorophyll_omp ! albedo SB 
    129     INTEGER, SAVE       :: NSW_omp
    130     INTEGER, SAVE       :: iflag_cld_th_omp, ip_ebil_phy_omp
    131     INTEGER, SAVE       :: iflag_ratqs_omp
    132 
    133     REAL, SAVE          :: f_cdrag_ter_omp,f_cdrag_oce_omp
    134     REAL, SAVE          :: f_rugoro_omp   , z0min_omp
    135     REAL, SAVE          :: z0m_seaice_omp,z0h_seaice_omp
    136     REAL, SAVE          :: z0m_landice_omp,z0h_landice_omp
    137     REAL, SAVE          :: min_wind_speed_omp,f_gust_wk_omp,f_gust_bl_omp,f_qsat_oce_omp, f_z0qh_oce_omp
    138     INTEGER, SAVE       :: iflag_gusts_omp,iflag_z0_oce_omp
     75    LOGICAL :: ok_newmicro
     76    INTEGER :: iflag_radia
     77    LOGICAL :: ok_journe, ok_mensuel, ok_instan, ok_hf
     78    LOGICAL :: ok_LES
     79    LOGICAL :: callstats
     80    LOGICAL :: ok_ade, ok_aie, ok_alw, ok_cdnc, ok_volcan
     81    LOGICAL :: aerosol_couple, chemistry_couple
     82    INTEGER :: flag_aerosol
     83    INTEGER :: flag_aerosol_strat
     84    INTEGER :: flag_volc_surfstrat
     85    LOGICAL :: flag_aer_feedback
     86    LOGICAL :: flag_bc_internal_mixture
     87    REAL :: bl95_b0, bl95_b1
     88    REAL :: fact_cldcon, facttemps, ratqsbas, ratqshaut, tau_ratqs
     89    INTEGER :: iflag_cld_th
     90
     91    CHARACTER (len = 6), SAVE :: type_ocean_omp, version_ocean_omp, ocean_omp
     92    CHARACTER (len = 10), SAVE :: type_veget_omp
     93    CHARACTER (len = 8), SAVE :: aer_type_omp
     94    INTEGER, SAVE :: landice_opt_omp
     95    INTEGER, SAVE :: iflag_tsurf_inlandsis_omp, iflag_temp_inlandsis_omp
     96    INTEGER, SAVE :: iflag_albcalc_omp, iflag_z0m_snow_omp
     97    LOGICAL, SAVE :: SnoMod_omp, BloMod_omp, ok_outfor_omp, ok_zsn_ii_omp
     98    LOGICAL, SAVE :: discret_xf_omp, opt_runoff_ac_omp
     99    LOGICAL, SAVE :: is_ok_slush_omp, is_ok_z0h_rn_omp, is_ok_density_kotlyakov_omp
     100    REAL, SAVE :: prescribed_z0m_snow_omp, correc_alb_omp
     101    REAL, SAVE :: buf_sph_pol_omp, buf_siz_pol_omp
     102    LOGICAL, SAVE :: ok_newmicro_omp
     103    LOGICAL, SAVE :: ok_all_xml_omp
     104    LOGICAL, SAVE :: ok_lwoff_omp
     105    LOGICAL, SAVE :: ok_journe_omp, ok_mensuel_omp, ok_instan_omp, ok_hf_omp
     106    LOGICAL, SAVE :: ok_LES_omp
     107    LOGICAL, SAVE :: callstats_omp
     108    LOGICAL, SAVE :: ok_ade_omp, ok_aie_omp, ok_alw_omp, ok_cdnc_omp, ok_volcan_omp
     109    LOGICAL, SAVE :: aerosol_couple_omp, chemistry_couple_omp
     110    INTEGER, SAVE :: flag_aerosol_omp
     111    INTEGER, SAVE :: flag_aerosol_strat_omp
     112    INTEGER, SAVE :: flag_volc_surfstrat_omp
     113    LOGICAL, SAVE :: flag_aer_feedback_omp
     114    LOGICAL, SAVE :: flag_bc_internal_mixture_omp
     115    REAL, SAVE :: bl95_b0_omp, bl95_b1_omp
     116    REAL, SAVE :: freq_ISCCP_omp, ecrit_ISCCP_omp
     117    REAL, SAVE :: freq_COSP_omp, freq_AIRS_omp
     118    REAL, SAVE :: fact_cldcon_omp, facttemps_omp, ratqsbas_omp
     119    REAL, SAVE :: tau_cld_cv_omp, coefw_cld_cv_omp
     120    INTEGER, SAVE :: iflag_cld_cv_omp
     121
     122    REAL, SAVE :: ratqshaut_omp
     123    REAL, SAVE :: tau_ratqs_omp
     124    REAL, SAVE :: t_coupl_omp
     125    INTEGER, SAVE :: iflag_radia_omp
     126    INTEGER, SAVE :: iflag_rrtm_omp
     127    INTEGER, SAVE :: iflag_albedo_omp !albedo SB
     128    LOGICAL, SAVE :: ok_chlorophyll_omp ! albedo SB
     129    INTEGER, SAVE :: NSW_omp
     130    INTEGER, SAVE :: iflag_cld_th_omp, ip_ebil_phy_omp
     131    INTEGER, SAVE :: iflag_ratqs_omp
     132
     133    REAL, SAVE :: f_cdrag_ter_omp, f_cdrag_oce_omp
     134    REAL, SAVE :: f_rugoro_omp, z0min_omp
     135    REAL, SAVE :: z0m_seaice_omp, z0h_seaice_omp
     136    REAL, SAVE :: z0m_landice_omp, z0h_landice_omp
     137    REAL, SAVE :: min_wind_speed_omp, f_gust_wk_omp, f_gust_bl_omp, f_qsat_oce_omp, f_z0qh_oce_omp
     138    INTEGER, SAVE :: iflag_gusts_omp, iflag_z0_oce_omp
    139139
    140140    REAL :: seuil_inversion
    141     REAL,SAVE :: seuil_inversion_omp
    142 
    143     INTEGER,SAVE :: iflag_thermals_omp,nsplit_thermals_omp
    144     REAL,SAVE :: tau_thermals_omp,alp_bl_k_omp
     141    REAL, SAVE :: seuil_inversion_omp
     142
     143    INTEGER, SAVE :: iflag_thermals_omp, nsplit_thermals_omp
     144    REAL, SAVE :: tau_thermals_omp, alp_bl_k_omp
    145145    ! nrlmd le 10/04/2012
    146     INTEGER,SAVE :: iflag_trig_bl_omp,iflag_clos_bl_omp,iflag_strig_omp
    147     INTEGER,SAVE :: tau_trig_shallow_omp,tau_trig_deep_omp
    148     REAL,SAVE    :: s_trig_omp,h_trig_omp
     146    INTEGER, SAVE :: iflag_trig_bl_omp, iflag_clos_bl_omp, iflag_strig_omp
     147    INTEGER, SAVE :: tau_trig_shallow_omp, tau_trig_deep_omp
     148    REAL, SAVE :: s_trig_omp, h_trig_omp
    149149    ! fin nrlmd le 10/04/2012
    150150    REAL :: alp_offset
    151151    REAL, SAVE :: alp_offset_omp
    152     INTEGER,SAVE :: iflag_coupl_omp,iflag_clos_omp,iflag_wake_omp
    153     INTEGER,SAVE :: iflag_cvl_sigd_omp
     152    INTEGER, SAVE :: iflag_coupl_omp, iflag_clos_omp, iflag_wake_omp
     153    INTEGER, SAVE :: iflag_cvl_sigd_omp
    154154    REAL, SAVE :: coef_clos_ls_omp
    155155    REAL, SAVE :: supcrit1_omp, supcrit2_omp
     
    159159    REAL, SAVE :: tmax_fonte_cv_omp
    160160
    161     REAL,SAVE :: R_ecc_omp,R_peri_omp,R_incl_omp,solaire_omp
    162     REAL,SAVE :: solaire_omp_init
    163     LOGICAL,SAVE :: ok_suntime_rrtm_omp
    164     REAL,SAVE :: co2_ppm_omp, RCO2_omp, co2_ppm_per_omp, RCO2_per_omp
    165     REAL,SAVE :: co2_ppm0_omp
    166     REAL,SAVE :: CH4_ppb_omp, RCH4_omp, CH4_ppb_per_omp, RCH4_per_omp
    167     REAL,SAVE :: N2O_ppb_omp, RN2O_omp, N2O_ppb_per_omp, RN2O_per_omp
    168     REAL,SAVE :: CFC11_ppt_omp,RCFC11_omp,CFC11_ppt_per_omp,RCFC11_per_omp
    169     REAL,SAVE :: CFC12_ppt_omp,RCFC12_omp,CFC12_ppt_per_omp,RCFC12_per_omp
    170     REAL,SAVE :: epmax_omp
    171     REAL,SAVE :: coef_epmax_cape_omp
    172     LOGICAL,SAVE :: ok_adj_ema_omp
    173     INTEGER,SAVE :: iflag_clw_omp
    174     INTEGER,SAVE :: iflag_ice_thermo_omp
    175     LOGICAL,SAVE :: ok_ice_sursat_omp
    176     LOGICAL,SAVE :: ok_plane_h2o_omp, ok_plane_contrail_omp
    177     REAL,SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
    178     INTEGER,SAVE :: iflag_sic_omp, iflag_inertie_omp
    179     REAL,SAVE :: inertie_sol_omp,inertie_sno_omp,inertie_sic_omp
    180     REAL,SAVE :: inertie_lic_omp
    181     REAL,SAVE :: qsol0_omp
    182     REAL,SAVE :: evap0_omp
    183     REAL,SAVE :: albsno0_omp
    184     REAL      :: solarlong0
    185     REAL,SAVE :: solarlong0_omp
    186     INTEGER,SAVE :: top_height_omp,overlap_omp
    187     REAL,SAVE :: cdmmax_omp,cdhmax_omp,ksta_omp,ksta_ter_omp,f_ri_cd_min_omp
    188     LOGICAL,SAVE :: ok_kzmin_omp
    189     REAL, SAVE ::  fmagic_omp, pmagic_omp
    190     INTEGER,SAVE :: iflag_pbl_omp,lev_histhf_omp,lev_histday_omp,lev_histmth_omp
    191     INTEGER,SAVE :: iflag_pbl_split_omp,iflag_physiq_omp
    192 !FC
    193     INTEGER,SAVE :: ifl_pbltree_omp
    194     REAL,SAVE :: Cd_frein_omp
    195 !FC
    196     INTEGER,SAVE :: iflag_order2_sollw_omp
    197     INTEGER, SAVE :: lev_histins_omp, lev_histLES_omp 
     161    REAL, SAVE :: R_ecc_omp, R_peri_omp, R_incl_omp, solaire_omp
     162    REAL, SAVE :: solaire_omp_init
     163    LOGICAL, SAVE :: ok_suntime_rrtm_omp
     164    REAL, SAVE :: co2_ppm_omp, RCO2_omp, co2_ppm_per_omp, RCO2_per_omp
     165    REAL, SAVE :: co2_ppm0_omp
     166    REAL, SAVE :: CH4_ppb_omp, RCH4_omp, CH4_ppb_per_omp, RCH4_per_omp
     167    REAL, SAVE :: N2O_ppb_omp, RN2O_omp, N2O_ppb_per_omp, RN2O_per_omp
     168    REAL, SAVE :: CFC11_ppt_omp, RCFC11_omp, CFC11_ppt_per_omp, RCFC11_per_omp
     169    REAL, SAVE :: CFC12_ppt_omp, RCFC12_omp, CFC12_ppt_per_omp, RCFC12_per_omp
     170    REAL, SAVE :: epmax_omp
     171    REAL, SAVE :: coef_epmax_cape_omp
     172    LOGICAL, SAVE :: ok_adj_ema_omp
     173    INTEGER, SAVE :: iflag_clw_omp
     174    INTEGER, SAVE :: iflag_ice_thermo_omp
     175    LOGICAL, SAVE :: ok_ice_sursat_omp
     176    LOGICAL, SAVE :: ok_plane_h2o_omp, ok_plane_contrail_omp
     177    REAL, SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
     178    INTEGER, SAVE :: iflag_sic_omp, iflag_inertie_omp
     179    REAL, SAVE :: inertie_sol_omp, inertie_sno_omp, inertie_sic_omp
     180    REAL, SAVE :: inertie_lic_omp
     181    REAL, SAVE :: qsol0_omp
     182    REAL, SAVE :: evap0_omp
     183    REAL, SAVE :: albsno0_omp
     184    REAL :: solarlong0
     185    REAL, SAVE :: solarlong0_omp
     186    INTEGER, SAVE :: top_height_omp, overlap_omp
     187    REAL, SAVE :: cdmmax_omp, cdhmax_omp, ksta_omp, ksta_ter_omp, f_ri_cd_min_omp
     188    LOGICAL, SAVE :: ok_kzmin_omp
     189    REAL, SAVE :: fmagic_omp, pmagic_omp
     190    INTEGER, SAVE :: iflag_pbl_omp, lev_histhf_omp, lev_histday_omp, lev_histmth_omp
     191    INTEGER, SAVE :: iflag_pbl_split_omp, iflag_physiq_omp
     192    !FC
     193    INTEGER, SAVE :: ifl_pbltree_omp
     194    REAL, SAVE :: Cd_frein_omp
     195    !FC
     196    INTEGER, SAVE :: iflag_order2_sollw_omp
     197    INTEGER, SAVE :: lev_histins_omp, lev_histLES_omp
    198198    INTEGER, SAVE :: lev_histdayNMC_omp
    199199    INTEGER, SAVE :: levout_histNMC_omp(3)
    200200    LOGICAL, SAVE :: ok_histNMC_omp(3)
    201     REAL, SAVE    :: freq_outNMC_omp(3), freq_calNMC_omp(3)
     201    REAL, SAVE :: freq_outNMC_omp(3), freq_calNMC_omp(3)
    202202    CHARACTER*4, SAVE :: type_run_omp
    203203    LOGICAL, SAVE :: ok_cosp_omp, ok_airs_omp
    204     LOGICAL, SAVE :: ok_mensuelCOSP_omp,ok_journeCOSP_omp,ok_hfCOSP_omp
    205     REAL, SAVE    :: lonmin_ins_omp, lonmax_ins_omp, latmin_ins_omp, latmax_ins_omp
    206     REAL, SAVE    :: ecrit_hf_omp, ecrit_day_omp, ecrit_mth_omp, ecrit_reg_omp
    207     REAL, SAVE    :: ecrit_ins_omp
    208     REAL, SAVE    :: ecrit_LES_omp
    209     REAL, SAVE    :: ecrit_tra_omp
    210     REAL, SAVE    :: cvl_comp_threshold_omp
    211     REAL, SAVE    :: cvl_sig2feed_omp
    212     REAL, SAVE    :: cvl_corr_omp
     204    LOGICAL, SAVE :: ok_mensuelCOSP_omp, ok_journeCOSP_omp, ok_hfCOSP_omp
     205    REAL, SAVE :: lonmin_ins_omp, lonmax_ins_omp, latmin_ins_omp, latmax_ins_omp
     206    REAL, SAVE :: ecrit_hf_omp, ecrit_day_omp, ecrit_mth_omp, ecrit_reg_omp
     207    REAL, SAVE :: ecrit_ins_omp
     208    REAL, SAVE :: ecrit_LES_omp
     209    REAL, SAVE :: ecrit_tra_omp
     210    REAL, SAVE :: cvl_comp_threshold_omp
     211    REAL, SAVE :: cvl_sig2feed_omp
     212    REAL, SAVE :: cvl_corr_omp
    213213    LOGICAL, SAVE :: ok_lic_melt_omp
    214214    LOGICAL, SAVE :: ok_lic_cond_omp
    215215    !
    216     REAL, SAVE    :: zrel_oro_t_omp, zstd_orodr_t_omp
    217     REAL, SAVE    :: zpmm_orodr_t_omp, zpmm_orolf_t_omp
     216    REAL, SAVE :: zrel_oro_t_omp, zstd_orodr_t_omp
     217    REAL, SAVE :: zpmm_orodr_t_omp, zpmm_orolf_t_omp
    218218    INTEGER, SAVE :: iflag_cycle_diurne_omp
    219     LOGICAL, SAVE :: soil_model_omp,new_oliq_omp
     219    LOGICAL, SAVE :: soil_model_omp, new_oliq_omp
    220220    LOGICAL, SAVE :: ok_orodr_omp, ok_orolf_omp, ok_limitvrai_omp
    221221    INTEGER, SAVE :: nbapp_rad_omp, iflag_con_omp
     
    223223    INTEGER, SAVE :: iflag_ener_conserv_omp
    224224    LOGICAL, SAVE :: ok_conserv_q_omp
    225     LOGICAL,SAVE :: ok_strato_omp
    226     LOGICAL,SAVE :: ok_hines_omp, ok_gwd_rando_omp
    227     REAL, SAVE    :: gwd_rando_ruwmax_omp, gwd_rando_sat_omp
    228     REAL, SAVE    :: gwd_front_ruwmax_omp, gwd_front_sat_omp
    229     REAL, SAVE    :: sso_gkdrag_omp,sso_grahil_omp,sso_grcrit_omp
    230     REAL, SAVE    :: sso_gfrcri_omp,sso_gkwake_omp,sso_gklift_omp
     225    LOGICAL, SAVE :: ok_strato_omp
     226    LOGICAL, SAVE :: ok_hines_omp, ok_gwd_rando_omp
     227    REAL, SAVE :: gwd_rando_ruwmax_omp, gwd_rando_sat_omp
     228    REAL, SAVE :: gwd_front_ruwmax_omp, gwd_front_sat_omp
     229    REAL, SAVE :: sso_gkdrag_omp, sso_grahil_omp, sso_grcrit_omp
     230    REAL, SAVE :: sso_gfrcri_omp, sso_gkwake_omp, sso_gklift_omp
    231231    LOGICAL, SAVE :: ok_qch4_omp
    232232    LOGICAL, SAVE :: carbon_cycle_tr_omp
     
    236236    INTEGER, SAVE :: level_coupling_esm_omp
    237237    LOGICAL, SAVE :: read_fco2_ocean_cor_omp
    238     REAL, SAVE    :: var_fco2_ocean_cor_omp
     238    REAL, SAVE :: var_fco2_ocean_cor_omp
    239239    LOGICAL, SAVE :: read_fco2_land_cor_omp
    240     REAL, SAVE    :: var_fco2_land_cor_omp
     240    REAL, SAVE :: var_fco2_land_cor_omp
    241241    LOGICAL, SAVE :: adjust_tropopause_omp
    242242    LOGICAL, SAVE :: ok_daily_climoz_omp
     
    244244    LOGICAL, SAVE :: ok_icefra_lscp_omp
    245245    !rajout de choix_bulk et nit_bulk par Olivier Torres
    246     INTEGER,SAVE :: choix_bulk_omp
    247     INTEGER,SAVE :: nit_bulk_omp
    248     INTEGER,SAVE :: kz0_omp
     246    INTEGER, SAVE :: choix_bulk_omp
     247    INTEGER, SAVE :: nit_bulk_omp
     248    INTEGER, SAVE :: kz0_omp
    249249    LOGICAL, SAVE :: ok_bs_omp, ok_rad_bs_omp
    250250
    251 
    252     INTEGER, INTENT(OUT):: read_climoz ! read ozone climatology, OpenMP shared
     251    INTEGER, INTENT(OUT) :: read_climoz ! read ozone climatology, OpenMP shared
    253252    ! Allowed values are 0, 1 and 2
    254253    ! 0: do not read an ozone climatology
     
    259258    !-----------------------------------------------------------------
    260259
    261     print*,'CONFPHYS ENTREE'
     260    print*, 'CONFPHYS ENTREE'
    262261    !$OMP MASTER
    263262    !Config Key  = type_ocean
     
    285284    CALL getin('OCEAN', ocean_omp)
    286285    IF (ocean_omp /= 'yyyyyy') THEN
    287        WRITE(lunout,*)'ERROR! Old variable name OCEAN used in parmeter file.'
    288        WRITE(lunout,*)'Variable OCEAN has been replaced by the variable type_ocean.'
    289        WRITE(lunout,*)'You have to update your parameter file physiq.def to succed running'
    290        CALL abort_physic('conf_phys','Variable OCEAN no longer existing, use variable name type_ocean',1)
     286      WRITE(lunout, *)'ERROR! Old variable name OCEAN used in parmeter file.'
     287      WRITE(lunout, *)'Variable OCEAN has been replaced by the variable type_ocean.'
     288      WRITE(lunout, *)'You have to update your parameter file physiq.def to succed running'
     289      CALL abort_physic('conf_phys', 'Variable OCEAN no longer existing, use variable name type_ocean', 1)
    291290    ENDIF
    292291
     
    299298    CALL getin('t_coupl', t_coupl_omp)
    300299    IF (t_coupl_omp == 0) THEN
    301        WRITE(lunout,*)'ERROR! Timestep of coupling between atmosphere and ocean'
    302        WRITE(lunout,*)'cannot be zero.'
    303        CALL abort_physic('conf_phys','t_coupl = 0.',1)
     300      WRITE(lunout, *)'ERROR! Timestep of coupling between atmosphere and ocean'
     301      WRITE(lunout, *)'cannot be zero.'
     302      CALL abort_physic('conf_phys', 't_coupl = 0.', 1)
    304303    ENDIF
    305304
     
    329328    !Config Help = Type de modele de vegetation utilise
    330329    !
    331     type_veget_omp ='orchidee'
     330    type_veget_omp = 'orchidee'
    332331    CALL getin('VEGET', type_veget_omp)
    333332    !
     
    454453    !Config Desc = correction term for albedo
    455454    !Config Def  = 1.01
    456     correc_alb_omp=1.01
     455    correc_alb_omp = 1.01
    457456    CALL getin('correc_alb', correc_alb_omp)
    458457
     
    462461    !Config Desc = sphericity of buffer layer in polar regions
    463462    !Config Def  = 99.
    464     buf_sph_pol_omp=99.
     463    buf_sph_pol_omp = 99.
    465464    CALL getin('buf_sph_pol', buf_sph_pol_omp)
    466465
     
    469468    !Config Desc = grain size of buffer layer in polar regions in e-4m
    470469    !Config Def  = 4.
    471     buf_siz_pol_omp=4.
     470    buf_siz_pol_omp = 4.
    472471    CALL getin('buf_siz_pol', buf_siz_pol_omp)
    473472
    474473    !==================================================================
    475    
     474
    476475    !Config Key  = OK_journe
    477476    !Config Desc = Pour des sorties journalieres
     
    561560    !
    562561    flag_volc_surfstrat_omp = 0 ! NL: SURFSTRAT
    563     CALL getin('flag_volc_surfstrat', flag_volc_surfstrat_omp) 
     562    CALL getin('flag_volc_surfstrat', flag_volc_surfstrat_omp)
    564563
    565564    !
     
    570569    !
    571570    aerosol_couple_omp = .FALSE.
    572     CALL getin('aerosol_couple',aerosol_couple_omp)
     571    CALL getin('aerosol_couple', aerosol_couple_omp)
    573572    !
    574573    !Config Key  = chemistry_couple
     
    578577    !
    579578    chemistry_couple_omp = .FALSE.
    580     CALL getin('chemistry_couple',chemistry_couple_omp)
     579    CALL getin('chemistry_couple', chemistry_couple_omp)
    581580    !
    582581    !Config Key  = flag_aerosol
     
    596595
    597596    flag_aerosol_omp = 0
    598     CALL getin('flag_aerosol',flag_aerosol_omp)
     597    CALL getin('flag_aerosol', flag_aerosol_omp)
    599598
    600599    !
     
    607606    !
    608607    flag_bc_internal_mixture_omp = .FALSE.
    609     CALL getin('flag_bc_internal_mixture',flag_bc_internal_mixture_omp)
     608    CALL getin('flag_bc_internal_mixture', flag_bc_internal_mixture_omp)
    610609
    611610    !
     
    615614    !Config Help = Used in readaerosol.F90
    616615    !
    617     aer_type_omp = 'scenario' 
    618     CALL getin('aer_type', aer_type_omp) 
     616    aer_type_omp = 'scenario'
     617    CALL getin('aer_type', aer_type_omp)
    619618
    620619    !
     
    681680    CALL getin('ip_ebil_phy', ip_ebil_phy_omp)
    682681    IF (ip_ebil_phy_omp/=0) THEN
    683        CALL abort_physic('conf_phys','ip_ebil_phy_omp doit etre 0 sur cette version',1)
     682      CALL abort_physic('conf_phys', 'ip_ebil_phy_omp doit etre 0 sur cette version', 1)
    684683    ENDIF
    685684
     
    784783    !               
    785784    CFC11_ppt_omp = 280.
    786     CALL getin('CFC11_ppt',CFC11_ppt_omp)
     785    CALL getin('CFC11_ppt', CFC11_ppt_omp)
    787786    !conversion en rapport de mélange massique
    788     RCFC11_omp=CFC11_ppt_omp* 1.0E-12 * RMCFC11 / RMD
     787    RCFC11_omp = CFC11_ppt_omp * 1.0E-12 * RMCFC11 / RMD
    789788    !
    790789    !Config Key  = RCFC12
     
    794793    !               
    795794    CFC12_ppt_omp = 484.
    796     CALL getin('CFC12_ppt',CFC12_ppt_omp)
     795    CALL getin('CFC12_ppt', CFC12_ppt_omp)
    797796    !conversion en rapport de mélange massique
    798797    RCFC12_omp = CFC12_ppt_omp * 1.0E-12 * RMCFC12 / RMD
     
    835834    !               
    836835    CFC11_ppt_per_omp = CFC11_ppt_omp
    837     CALL getin('CFC11_ppt_per',CFC11_ppt_per_omp)
     836    CALL getin('CFC11_ppt_per', CFC11_ppt_per_omp)
    838837    !conversion en rapport de mélange massique
    839     RCFC11_per_omp=CFC11_ppt_per_omp* 1.0E-12 * RMCFC11 / RMD
     838    RCFC11_per_omp = CFC11_ppt_per_omp * 1.0E-12 * RMCFC11 / RMD
    840839    !
    841840    !Config Key  = RCFC12_per
     
    845844    !               
    846845    CFC12_ppt_per_omp = CFC12_ppt_omp
    847     CALL getin('CFC12_ppt_per',CFC12_ppt_per_omp)
     846    CALL getin('CFC12_ppt_per', CFC12_ppt_per_omp)
    848847    !conversion en rapport de mélange massique
    849848    RCFC12_per_omp = CFC12_ppt_per_omp * 1.0E-12 * RMCFC12 / RMD
     
    859858    !Config         Peut etre util pour accelerer le code !
    860859    iflag_cycle_diurne_omp = 1
    861     CALL getin('iflag_cycle_diurne',iflag_cycle_diurne_omp)
     860    CALL getin('iflag_cycle_diurne', iflag_cycle_diurne_omp)
    862861
    863862    !Config  Key  = soil_model
     
    868867    !Config         plus de choix ! Ou meme une liste d'options !
    869868    soil_model_omp = .TRUE.
    870     CALL getin('soil_model',soil_model_omp)
     869    CALL getin('soil_model', soil_model_omp)
    871870
    872871    !Config  Key  = new_oliq
     
    876875    !Config         nouvelle parametrisation de l'eau liquide !
    877876    new_oliq_omp = .TRUE.
    878     CALL getin('new_oliq',new_oliq_omp)
     877    CALL getin('new_oliq', new_oliq_omp)
    879878
    880879    !Config  Key  = ok_orodr
     
    884883    !Config         
    885884    ok_orodr_omp = .TRUE.
    886     CALL getin('ok_orodr',ok_orodr_omp)
     885    CALL getin('ok_orodr', ok_orodr_omp)
    887886
    888887    !Config  Key  =  ok_orolf
     
    931930    !Config         idee, pourquoi ne pas mettre toujours a y ???
    932931    ok_limitvrai_omp = .FALSE.
    933     CALL getin('ok_limitvrai',ok_limitvrai_omp)
     932    CALL getin('ok_limitvrai', ok_limitvrai_omp)
    934933
    935934    !Config  Key  = nbapp_rad
     
    939938    !Config         par jour.
    940939    nbapp_rad_omp = 12
    941     CALL getin('nbapp_rad',nbapp_rad_omp)
     940    CALL getin('nbapp_rad', nbapp_rad_omp)
    942941
    943942    !rajout Olivier Torres
     
    950949    !Config         3 -> CORE-"mixte" (avec z_0 et C_T^N donnees par Smith 88)
    951950    choix_bulk_omp = 0
    952     CALL getin('choix_bulk',choix_bulk_omp)
     951    CALL getin('choix_bulk', choix_bulk_omp)
    953952
    954953    !Config  Key  = nit_bulk
     
    956955    !Config  Def  = 5
    957956    nit_bulk_omp = 1
    958     CALL getin('nit_bulk',nit_bulk_omp)
     957    CALL getin('nit_bulk', nit_bulk_omp)
    959958
    960959    !Config  Key  = kz0
     
    965964    !Config         2 -> Direct computation using the stability functions
    966965    kz0_omp = 0
    967     CALL getin('kz0',kz0_omp)
     966    CALL getin('kz0', kz0_omp)
    968967
    969968
     
    976975    !Config         3 pour CCM(NCAR) 
    977976    iflag_con_omp = 2
    978     CALL getin('iflag_con',iflag_con_omp)
     977    CALL getin('iflag_con', iflag_con_omp)
    979978
    980979    !Config  Key  = nbapp_cv
     
    984983    !Config         par jour. Si =0, appel a chaque pas de temps physique.
    985984    nbapp_cv_omp = 0
    986     CALL getin('nbapp_cv',nbapp_cv_omp)
     985    CALL getin('nbapp_cv', nbapp_cv_omp)
    987986
    988987    !Config  Key  = nbapp_wk
     
    992991    !Config         par jour. Si =0, appel a chaque pas de temps physique.
    993992    nbapp_wk_omp = 0
    994     CALL getin('nbapp_wk',nbapp_wk_omp)
     993    CALL getin('nbapp_wk', nbapp_wk_omp)
    995994
    996995    !Config  Key  = iflag_ener_conserv
     
    10011000    !Config         1  conservation kinetic and enthalpy
    10021001    iflag_ener_conserv_omp = -1
    1003     CALL getin('iflag_ener_conserv',iflag_ener_conserv_omp)
     1002    CALL getin('iflag_ener_conserv', iflag_ener_conserv_omp)
    10041003
    10051004    !Config  Key  = ok_conserv_q
     
    10101009    !Config         n -> conformite avec versions anterieures au 1/4/2014
    10111010    ok_conserv_q_omp = .FALSE.
    1012     CALL getin('ok_conserv_q',ok_conserv_q_omp)
     1011    CALL getin('ok_conserv_q', ok_conserv_q_omp)
    10131012
    10141013    !
     
    10521051    CALL getin('epmax', epmax_omp)
    10531052
    1054     coef_epmax_cape_omp = 0.0   
    1055     CALL getin('coef_epmax_cape', coef_epmax_cape_omp)       
     1053    coef_epmax_cape_omp = 0.0
     1054    CALL getin('coef_epmax_cape', coef_epmax_cape_omp)
    10561055    !
    10571056    !Config Key  = ok_adj_ema
     
    10611060    !
    10621061    ok_adj_ema_omp = .FALSE.
    1063     CALL getin('ok_adj_ema',ok_adj_ema_omp)
     1062    CALL getin('ok_adj_ema', ok_adj_ema_omp)
    10641063    !
    10651064    !Config Key  = iflag_clw
     
    10691068    !
    10701069    iflag_clw_omp = 0
    1071     CALL getin('iflag_clw',iflag_clw_omp)
    1072    
     1070    CALL getin('iflag_clw', iflag_clw_omp)
     1071
    10731072
    10741073    !Config Key  = iflag_ratqs
     
    10781077    !
    10791078    iflag_ratqs_omp = 1
    1080     CALL getin('iflag_ratqs',iflag_ratqs_omp)
     1079    CALL getin('iflag_ratqs', iflag_ratqs_omp)
    10811080
    10821081    !
     
    10871086    !
    10881087    iflag_radia_omp = 1
    1089     CALL getin('iflag_radia',iflag_radia_omp)
     1088    CALL getin('iflag_radia', iflag_radia_omp)
    10901089
    10911090    !
     
    10961095    !
    10971096    iflag_rrtm_omp = 0
    1098     CALL getin('iflag_rrtm',iflag_rrtm_omp)
     1097    CALL getin('iflag_rrtm', iflag_rrtm_omp)
    10991098
    11001099    !
     
    11051104    !
    11061105    NSW_omp = 2
    1107     CALL getin('NSW',NSW_omp)
     1106    CALL getin('NSW', NSW_omp)
    11081107    !albedo SB >>>
    11091108    iflag_albedo_omp = 0
    1110     CALL getin('iflag_albedo',iflag_albedo_omp)
    1111 
    1112     ok_chlorophyll_omp=.FALSE.
    1113     CALL getin('ok_chlorophyll',ok_chlorophyll_omp)
     1109    CALL getin('iflag_albedo', iflag_albedo_omp)
     1110
     1111    ok_chlorophyll_omp = .FALSE.
     1112    CALL getin('ok_chlorophyll', ok_chlorophyll_omp)
    11141113    !albedo SB <<<
    11151114    !
     
    11231122    ok_suntime_rrtm_omp = .FALSE.
    11241123    IF (iflag_rrtm_omp==1) THEN
    1125       CALL getin('ok_suntime_rrtm',ok_suntime_rrtm_omp)
     1124      CALL getin('ok_suntime_rrtm', ok_suntime_rrtm_omp)
    11261125    ENDIF
    1127    
     1126
    11281127    !Config Key  = flag_aerosol_strat
    11291128    !Config Desc = use stratospheric aerosols 0, 1, 2
     
    11361135    !
    11371136    flag_aerosol_strat_omp = 0
    1138     CALL getin('flag_aerosol_strat',flag_aerosol_strat_omp)
     1137    CALL getin('flag_aerosol_strat', flag_aerosol_strat_omp)
    11391138
    11401139    !Config Key  = flag_aer_feedback
     
    11451144    !Config Help = Used in physiq.F
    11461145    !
    1147     flag_aer_feedback_omp = .TRUE. 
     1146    flag_aer_feedback_omp = .TRUE.
    11481147    IF (iflag_rrtm_omp==1) THEN
    1149        CALL getin('flag_aer_feedback',flag_aer_feedback_omp)
     1148      CALL getin('flag_aer_feedback', flag_aer_feedback_omp)
    11501149    ENDIF
    11511150
     
    11591158    ! pour assurer une retrocompatiblite.
    11601159    ! A abandonner un jour
    1161     CALL getin('iflag_cldcon',iflag_cld_th_omp)
    1162     CALL getin('iflag_cld_th',iflag_cld_th_omp)
    1163     iflag_cld_cv_omp = 0 
    1164     CALL getin('iflag_cld_cv',iflag_cld_cv_omp)
     1160    CALL getin('iflag_cldcon', iflag_cld_th_omp)
     1161    CALL getin('iflag_cld_th', iflag_cld_th_omp)
     1162    iflag_cld_cv_omp = 0
     1163    CALL getin('iflag_cld_cv', iflag_cld_cv_omp)
    11651164
    11661165    !
     
    11711170    !
    11721171    tau_cld_cv_omp = 10.
    1173     CALL getin('tau_cld_cv',tau_cld_cv_omp)
     1172    CALL getin('tau_cld_cv', tau_cld_cv_omp)
    11741173
    11751174    !
     
    11801179    !
    11811180    coefw_cld_cv_omp = 0.1
    1182     CALL getin('coefw_cld_cv',coefw_cld_cv_omp)
     1181    CALL getin('coefw_cld_cv', coefw_cld_cv_omp)
    11831182
    11841183
     
    11921191    !
    11931192    fact_cldcon_omp = 0.375
    1194     CALL getin('fact_cldcon',fact_cldcon_omp)
     1193    CALL getin('fact_cldcon', fact_cldcon_omp)
    11951194
    11961195    !
     
    12011200    !
    12021201    facttemps_omp = 1.e-4
    1203     CALL getin('facttemps',facttemps_omp)
     1202    CALL getin('facttemps', facttemps_omp)
    12041203
    12051204    !
     
    12101209    !
    12111210    ok_newmicro_omp = .TRUE.
    1212     CALL getin('ok_newmicro',ok_newmicro_omp)
     1211    CALL getin('ok_newmicro', ok_newmicro_omp)
    12131212    !
    12141213    !Config Key  = ratqsbas
     
    12181217    !
    12191218    ratqsbas_omp = 0.01
    1220     CALL getin('ratqsbas',ratqsbas_omp)
     1219    CALL getin('ratqsbas', ratqsbas_omp)
    12211220    !
    12221221    !Config Key  = ratqshaut
     
    12261225    !
    12271226    ratqshaut_omp = 0.3
    1228     CALL getin('ratqshaut',ratqshaut_omp)
     1227    CALL getin('ratqshaut', ratqshaut_omp)
    12291228
    12301229    !Config Key  = tau_ratqs
     
    12341233    !
    12351234    tau_ratqs_omp = 1800.
    1236     CALL getin('tau_ratqs',tau_ratqs_omp)
     1235    CALL getin('tau_ratqs', tau_ratqs_omp)
    12371236
    12381237    !
     
    12461245    !
    12471246    solarlong0_omp = -999.999
    1248     CALL getin('solarlong0',solarlong0_omp)
     1247    CALL getin('solarlong0', solarlong0_omp)
    12491248    !
    12501249    !-----------------------------------------------------------------------
     
    12531252    ! Default value -1 to activate the full computation
    12541253    qsol0_omp = -1.
    1255     CALL getin('qsol0',qsol0_omp)
     1254    CALL getin('qsol0', qsol0_omp)
    12561255    evap0_omp = -1.
    1257     CALL getin('evap0',evap0_omp)
     1256    CALL getin('evap0', evap0_omp)
    12581257    albsno0_omp = -1.
    1259     CALL getin('albsno0',albsno0_omp)
     1258    CALL getin('albsno0', albsno0_omp)
    12601259    !
    12611260    !-----------------------------------------------------------------------
     
    12671266    !
    12681267    iflag_sic_omp = 0
    1269     CALL getin('iflag_sic',iflag_sic_omp)
     1268    CALL getin('iflag_sic', iflag_sic_omp)
    12701269    !
    12711270    !Config Key  = iflag_inertie
     
    12751274    !
    12761275    iflag_inertie_omp = 0
    1277     CALL getin('iflag_inertie',iflag_inertie_omp)
     1276    CALL getin('iflag_inertie', iflag_inertie_omp)
    12781277    !
    12791278    !Config Key  = inertie_sic
     
    12831282    !
    12841283    inertie_sic_omp = 2000.
    1285     CALL getin('inertie_sic',inertie_sic_omp)
     1284    CALL getin('inertie_sic', inertie_sic_omp)
    12861285    !
    12871286    !Config Key  = inertie_lic
     
    12911290    !
    12921291    inertie_lic_omp = 2000.
    1293     CALL getin('inertie_lic',inertie_lic_omp)
     1292    CALL getin('inertie_lic', inertie_lic_omp)
    12941293    !
    12951294    !Config Key  = inertie_sno
     
    12991298    !
    13001299    inertie_sno_omp = 2000.
    1301     CALL getin('inertie_sno',inertie_sno_omp)
     1300    CALL getin('inertie_sno', inertie_sno_omp)
    13021301    !
    13031302    !Config Key  = inertie_sol
     
    13071306    !
    13081307    inertie_sol_omp = 2000.
    1309     CALL getin('inertie_sol',inertie_sol_omp)
     1308    CALL getin('inertie_sol', inertie_sol_omp)
    13101309
    13111310    !
     
    13161315    !
    13171316    rad_froid_omp = 35.0
    1318     CALL getin('rad_froid',rad_froid_omp)
     1317    CALL getin('rad_froid', rad_froid_omp)
    13191318
    13201319    !
     
    13251324    !
    13261325    rad_chau1_omp = 13.0
    1327     CALL getin('rad_chau1',rad_chau1_omp)
     1326    CALL getin('rad_chau1', rad_chau1_omp)
    13281327
    13291328    !
     
    13341333    !
    13351334    rad_chau2_omp = 9.0
    1336     CALL getin('rad_chau2',rad_chau2_omp)
     1335    CALL getin('rad_chau2', rad_chau2_omp)
    13371336
    13381337
     
    13441343    !
    13451344    iflag_ice_thermo_omp = 0
    1346     CALL getin('iflag_ice_thermo',iflag_ice_thermo_omp)
     1345    CALL getin('iflag_ice_thermo', iflag_ice_thermo_omp)
    13471346
    13481347    !
     
    13531352    !
    13541353    ok_ice_sursat_omp = .FALSE.
    1355     CALL getin('ok_ice_sursat',ok_ice_sursat_omp)
     1354    CALL getin('ok_ice_sursat', ok_ice_sursat_omp)
    13561355
    13571356    !Config Key  = ok_plane_h2o
     
    13611360    !
    13621361    ok_plane_h2o_omp = .FALSE.
    1363     CALL getin('ok_plane_h2o',ok_plane_h2o_omp)
     1362    CALL getin('ok_plane_h2o', ok_plane_h2o_omp)
    13641363
    13651364    !Config Key  = ok_plane_contrail
     
    13691368    !
    13701369    ok_plane_contrail_omp = .FALSE.
    1371     CALL getin('ok_plane_contrail',ok_plane_contrail_omp)
     1370    CALL getin('ok_plane_contrail', ok_plane_contrail_omp)
    13721371
    13731372    !
     
    13781377    !
    13791378    top_height_omp = 3
    1380     CALL getin('top_height',top_height_omp)
     1379    CALL getin('top_height', top_height_omp)
    13811380
    13821381    !
     
    13871386    !
    13881387    overlap_omp = 3
    1389     CALL getin('overlap',overlap_omp)
     1388    CALL getin('overlap', overlap_omp)
    13901389
    13911390    !
     
    13961395    !
    13971396    cdmmax_omp = 1.3E-3
    1398     CALL getin('cdmmax',cdmmax_omp)
     1397    CALL getin('cdmmax', cdmmax_omp)
    13991398
    14001399    !
     
    14051404    !
    14061405    cdhmax_omp = 1.1E-3
    1407     CALL getin('cdhmax',cdhmax_omp)
     1406    CALL getin('cdhmax', cdhmax_omp)
    14081407
    14091408    !261103
     
    14151414    !
    14161415    ksta_omp = 1.0e-10
    1417     CALL getin('ksta',ksta_omp)
     1416    CALL getin('ksta', ksta_omp)
    14181417
    14191418    !
     
    14241423    !
    14251424    ksta_ter_omp = 1.0e-10
    1426     CALL getin('ksta_ter',ksta_ter_omp)
     1425    CALL getin('ksta_ter', ksta_ter_omp)
    14271426
    14281427    !Config Key  = f_ri_cd_min
     
    14321431    !
    14331432    f_ri_cd_min_omp = 0.1
    1434     CALL getin('f_ri_cd_min',f_ri_cd_min_omp)
     1433    CALL getin('f_ri_cd_min', f_ri_cd_min_omp)
    14351434
    14361435    !
     
    14411440    !
    14421441    ok_kzmin_omp = .TRUE.
    1443     CALL getin('ok_kzmin',ok_kzmin_omp)
     1442    CALL getin('ok_kzmin', ok_kzmin_omp)
    14441443
    14451444    !
     
    14501449    !
    14511450    fmagic_omp = 1.
    1452     CALL getin('fmagic',fmagic_omp)
     1451    CALL getin('fmagic', fmagic_omp)
    14531452
    14541453    !
     
    14591458    !
    14601459    pmagic_omp = 0.
    1461     CALL getin('pmagic',pmagic_omp)
     1460    CALL getin('pmagic', pmagic_omp)
    14621461
    14631462
     
    14871486    !
    14881487    iflag_pbl_omp = 1
    1489     CALL getin('iflag_pbl',iflag_pbl_omp)
     1488    CALL getin('iflag_pbl', iflag_pbl_omp)
    14901489
    14911490    iflag_physiq_omp = 0 ! 0: std, 1: with physiqex output, 2: for physiqex
    1492     CALL getin('iflag_physiq',iflag_physiq_omp)
    1493 
    1494 !FC
     1491    CALL getin('iflag_physiq', iflag_physiq_omp)
     1492
     1493    !FC
    14951494    !Config Key  = ifl_pbltree
    14961495    !Config Desc = drag from trees 0 no activated
     
    14991498    !
    15001499    ifl_pbltree_omp = 0
    1501     CALL getin('ifl_pbltree',ifl_pbltree_omp)
    1502 !FC
     1500    CALL getin('ifl_pbltree', ifl_pbltree_omp)
     1501    !FC
    15031502    !Config Key  = Cd_frein
    15041503    !Config Desc = drag from trees
     
    15071506    !
    15081507    Cd_frein_omp = 7.5E-02
    1509     CALL getin('Cd_frein',Cd_frein_omp)
     1508    CALL getin('Cd_frein', Cd_frein_omp)
    15101509
    15111510    !
     
    15161515    !
    15171516    iflag_pbl_split_omp = 0
    1518     call getin('iflag_pbl_split',iflag_pbl_split_omp)
     1517    call getin('iflag_pbl_split', iflag_pbl_split_omp)
    15191518    !
    15201519    !Config Key  = iflag_order2_sollw
     
    15241523    !
    15251524    iflag_order2_sollw_omp = 0
    1526     CALL getin('iflag_order2_sollw',iflag_order2_sollw_omp)
     1525    CALL getin('iflag_order2_sollw', iflag_order2_sollw_omp)
    15271526    !
    15281527    !Config Key  = iflag_thermals
     
    15321531    !
    15331532    iflag_thermals_omp = 0
    1534     CALL getin('iflag_thermals',iflag_thermals_omp)
     1533    CALL getin('iflag_thermals', iflag_thermals_omp)
    15351534    !
    15361535    !Config Key  = nsplit_thermals
     
    15401539    !
    15411540    nsplit_thermals_omp = 1
    1542     CALL getin('nsplit_thermals',nsplit_thermals_omp)
     1541    CALL getin('nsplit_thermals', nsplit_thermals_omp)
    15431542    !
    15441543    !Config Key  = nsplit_thermals
     
    15471546    !Config Help =
    15481547    alp_bl_k_omp = 1.
    1549     CALL getin('alp_bl_k',alp_bl_k_omp)
     1548    CALL getin('alp_bl_k', alp_bl_k_omp)
    15501549
    15511550    ! nrlmd le 10/04/2012
     
    15571556    !
    15581557    iflag_trig_bl_omp = 0
    1559     CALL getin('iflag_trig_bl',iflag_trig_bl_omp)
     1558    CALL getin('iflag_trig_bl', iflag_trig_bl_omp)
    15601559
    15611560    !Config Key  = iflag_strig
     
    15651564    !
    15661565    iflag_strig_omp = 0
    1567     CALL getin('iflag_strig',iflag_strig_omp)
     1566    CALL getin('iflag_strig', iflag_strig_omp)
    15681567
    15691568    !Config Key  = s_trig_bl
     
    15731572    !
    15741573    s_trig_omp = 2e7
    1575     CALL getin('s_trig',s_trig_omp)
     1574    CALL getin('s_trig', s_trig_omp)
    15761575
    15771576    !Config Key  = h_trig
     
    15811580    !
    15821581    h_trig_omp = 6000.
    1583     CALL getin('h_trig',h_trig_omp)
     1582    CALL getin('h_trig', h_trig_omp)
    15841583
    15851584    !Config Key  = tau_trig_shallow
     
    15891588    !
    15901589    tau_trig_shallow_omp = 600
    1591     CALL getin('tau_trig_shallow',tau_trig_shallow_omp)
     1590    CALL getin('tau_trig_shallow', tau_trig_shallow_omp)
    15921591
    15931592    !Config Key  = tau_trig_deep
     
    15971596    !
    15981597    tau_trig_deep_omp = 1800
    1599     CALL getin('tau_trig_deep',tau_trig_deep_omp)
     1598    CALL getin('tau_trig_deep', tau_trig_deep_omp)
    16001599
    16011600    !Config Key  = iflag_clos_bl
     
    16051604    !
    16061605    iflag_clos_bl_omp = 0
    1607     CALL getin('iflag_clos_bl',iflag_clos_bl_omp)
     1606    CALL getin('iflag_clos_bl', iflag_clos_bl_omp)
    16081607
    16091608    ! fin nrlmd le 10/04/2012
     
    16161615    !
    16171616    tau_thermals_omp = 0.
    1618     CALL getin('tau_thermals',tau_thermals_omp)
     1617    CALL getin('tau_thermals', tau_thermals_omp)
    16191618
    16201619    !
     
    16251624    !
    16261625    iflag_coupl_omp = 0
    1627     CALL getin('iflag_coupl',iflag_coupl_omp)
     1626    CALL getin('iflag_coupl', iflag_coupl_omp)
    16281627
    16291628    !
     
    16341633    !
    16351634    iflag_clos_omp = 1
    1636     CALL getin('iflag_clos',iflag_clos_omp)
     1635    CALL getin('iflag_clos', iflag_clos_omp)
    16371636    !
    16381637    !Config Key  = coef_clos_ls
     
    16421641    !
    16431642    coef_clos_ls_omp = 0.
    1644     CALL getin('coef_clos_ls',coef_clos_ls_omp)
     1643    CALL getin('coef_clos_ls', coef_clos_ls_omp)
    16451644
    16461645    !
     
    16511650    !
    16521651    iflag_cvl_sigd_omp = 0
    1653     CALL getin('iflag_cvl_sigd',iflag_cvl_sigd_omp)
     1652    CALL getin('iflag_cvl_sigd', iflag_cvl_sigd_omp)
    16541653
    16551654    !Config Key  = iflag_wake
     
    16591658    !
    16601659    iflag_wake_omp = 0
    1661     CALL getin('iflag_wake',iflag_wake_omp)
     1660    CALL getin('iflag_wake', iflag_wake_omp)
    16621661
    16631662    !Config Key  = alp_offset
     
    16671666    !
    16681667    alp_offset_omp = 0.
    1669     CALL getin('alp_offset',alp_offset_omp)
     1668    CALL getin('alp_offset', alp_offset_omp)
    16701669
    16711670    !
     
    16761675    !
    16771676    lev_histhf_omp = 1
    1678     CALL getin('lev_histhf',lev_histhf_omp)
     1677    CALL getin('lev_histhf', lev_histhf_omp)
    16791678
    16801679    !
     
    16851684    !
    16861685    lev_histday_omp = 1
    1687     CALL getin('lev_histday',lev_histday_omp)
     1686    CALL getin('lev_histday', lev_histday_omp)
    16881687
    16891688    !
     
    16941693    !
    16951694    lev_histmth_omp = 2
    1696     CALL getin('lev_histmth',lev_histmth_omp)
     1695    CALL getin('lev_histmth', lev_histmth_omp)
    16971696    !
    16981697    !Config Key  = lev_histins
     
    17021701    !
    17031702    lev_histins_omp = 1
    1704     CALL getin('lev_histins',lev_histins_omp)
     1703    CALL getin('lev_histins', lev_histins_omp)
    17051704    !
    17061705    !Config Key  = lev_histLES
     
    17101709    !
    17111710    lev_histLES_omp = 1
    1712     CALL getin('lev_histLES',lev_histLES_omp)
     1711    CALL getin('lev_histLES', lev_histLES_omp)
    17131712    !
    17141713    !Config Key  = lev_histdayNMC
     
    17181717    !
    17191718    lev_histdayNMC_omp = 8
    1720     CALL getin('lev_histdayNMC',lev_histdayNMC_omp)
     1719    CALL getin('lev_histdayNMC', lev_histdayNMC_omp)
    17211720    !
    17221721    !Config Key  = levout_histNMC
     
    17281727    levout_histNMC_omp(2) = 5
    17291728    levout_histNMC_omp(3) = 5
    1730     CALL getin('levout_histNMC',levout_histNMC_omp)
     1729    CALL getin('levout_histNMC', levout_histNMC_omp)
    17311730    !
    17321731    !histNMC BEG
     
    17411740    ok_histNMC_omp(2) = .FALSE.
    17421741    ok_histNMC_omp(3) = .FALSE.
    1743     CALL getin('ok_histNMC',ok_histNMC_omp)
     1742    CALL getin('ok_histNMC', ok_histNMC_omp)
    17441743    !
    17451744    !Config Key  = freq_outNMC
     
    17521751    freq_outNMC_omp(1) = mth_len
    17531752    freq_outNMC_omp(2) = 1.
    1754     freq_outNMC_omp(3) = 1./4.
    1755     CALL getin('freq_outNMC',freq_outNMC_omp)
     1753    freq_outNMC_omp(3) = 1. / 4.
     1754    CALL getin('freq_outNMC', freq_outNMC_omp)
    17561755    !
    17571756    !Config Key  = freq_calNMC
     
    17651764    freq_calNMC_omp(2) = phys_tstep
    17661765    freq_calNMC_omp(3) = phys_tstep
    1767     CALL getin('freq_calNMC',freq_calNMC_omp)
     1766    CALL getin('freq_calNMC', freq_calNMC_omp)
    17681767    !
    17691768    !Config Key  = type_run
     
    17731772    !
    17741773    type_run_omp = 'AMIP'
    1775     CALL getin('type_run',type_run_omp)
     1774    CALL getin('type_run', type_run_omp)
    17761775
    17771776    !
     
    17821781    !
    17831782    ok_cosp_omp = .FALSE.
    1784     CALL getin('ok_cosp',ok_cosp_omp)
     1783    CALL getin('ok_cosp', ok_cosp_omp)
    17851784
    17861785    !
     
    17911790    !
    17921791    ok_airs_omp = .FALSE.
    1793     CALL getin('ok_airs',ok_airs_omp)
     1792    CALL getin('ok_airs', ok_airs_omp)
    17941793
    17951794    !
     
    18001799    !
    18011800    ok_mensuelCOSP_omp = .TRUE.
    1802     CALL getin('ok_mensuelCOSP',ok_mensuelCOSP_omp)
     1801    CALL getin('ok_mensuelCOSP', ok_mensuelCOSP_omp)
    18031802
    18041803    !
     
    18091808    !
    18101809    ok_journeCOSP_omp = .TRUE.
    1811     CALL getin('ok_journeCOSP',ok_journeCOSP_omp)
     1810    CALL getin('ok_journeCOSP', ok_journeCOSP_omp)
    18121811
    18131812    !
     
    18181817    !
    18191818    ok_hfCOSP_omp = .FALSE.
    1820     CALL getin('ok_hfCOSP',ok_hfCOSP_omp)
     1819    CALL getin('ok_hfCOSP', ok_hfCOSP_omp)
    18211820
    18221821    !
     
    18301829    !
    18311830    lonmin_ins_omp = 100.
    1832     CALL getin('lonmin_ins',lonmin_ins_omp)
     1831    CALL getin('lonmin_ins', lonmin_ins_omp)
    18331832    !
    18341833    !Config Key  = lonmax_ins
     
    18381837    !
    18391838    lonmax_ins_omp = 130.
    1840     CALL getin('lonmax_ins',lonmax_ins_omp)
     1839    CALL getin('lonmax_ins', lonmax_ins_omp)
    18411840    !
    18421841    !Config Key  = latmin_ins
     
    18461845    !
    18471846    latmin_ins_omp = -20.
    1848     CALL getin('latmin_ins',latmin_ins_omp)
     1847    CALL getin('latmin_ins', latmin_ins_omp)
    18491848    !
    18501849    !Config Key  = latmax_ins
     
    18541853    !
    18551854    latmax_ins_omp = 20.
    1856     CALL getin('latmax_ins',latmax_ins_omp)
     1855    CALL getin('latmax_ins', latmax_ins_omp)
    18571856    !
    18581857    !Config Key  = ecrit_hf
     
    18611860    !Config Help =
    18621861    !
    1863     ecrit_hf_omp = 1./8.
    1864     CALL getin('ecrit_hf',ecrit_hf_omp)
     1862    ecrit_hf_omp = 1. / 8.
     1863    CALL getin('ecrit_hf', ecrit_hf_omp)
    18651864    !
    18661865    !Config Key  = ecrit_ins
     
    18691868    !Config Help =
    18701869    !
    1871     ecrit_ins_omp = 1./48.
    1872     CALL getin('ecrit_ins',ecrit_ins_omp)
     1870    ecrit_ins_omp = 1. / 48.
     1871    CALL getin('ecrit_ins', ecrit_ins_omp)
    18731872    !
    18741873    !Config Key  = ecrit_day
     
    18781877    !
    18791878    ecrit_day_omp = 1.0
    1880     CALL getin('ecrit_day',ecrit_day_omp)
     1879    CALL getin('ecrit_day', ecrit_day_omp)
    18811880    !
    18821881    !Config Key  = ecrit_mth
     
    18861885    !
    18871886    ecrit_mth_omp = 30.
    1888     CALL getin('ecrit_mth',ecrit_mth_omp)
     1887    CALL getin('ecrit_mth', ecrit_mth_omp)
    18891888    !
    18901889    !Config Key  = ecrit_tra
     
    18941893    !
    18951894    ecrit_tra_omp = 0.
    1896     CALL getin('ecrit_tra',ecrit_tra_omp)
     1895    CALL getin('ecrit_tra', ecrit_tra_omp)
    18971896    !
    18981897    !Config Key  = ecrit_reg
     
    19021901    !
    19031902    ecrit_reg_omp = 0.25   !4 fois par jour
    1904     CALL getin('ecrit_reg',ecrit_reg_omp)
    1905     !
    1906     !
    1907     print*,'CONFPHYS OOK avant drag_ter'
     1903    CALL getin('ecrit_reg', ecrit_reg_omp)
     1904    !
     1905    !
     1906    print*, 'CONFPHYS OOK avant drag_ter'
    19081907    !
    19091908    ! PARAMETRES CDRAG
    19101909    !
    19111910    f_cdrag_ter_omp = 0.8
    1912     CALL getin('f_cdrag_ter',f_cdrag_ter_omp)
     1911    CALL getin('f_cdrag_ter', f_cdrag_ter_omp)
    19131912    !
    19141913    f_cdrag_oce_omp = 0.8
    1915     CALL getin('f_cdrag_oce',f_cdrag_oce_omp)
     1914    CALL getin('f_cdrag_oce', f_cdrag_oce_omp)
    19161915    !
    19171916
    19181917    ! Gustiness flags
    19191918    f_z0qh_oce_omp = 1.
    1920     CALL getin('f_z0qh_oce',f_z0qh_oce_omp)
     1919    CALL getin('f_z0qh_oce', f_z0qh_oce_omp)
    19211920    !
    19221921    f_qsat_oce_omp = 1.
    1923     CALL getin('f_qsat_oce',f_qsat_oce_omp)
     1922    CALL getin('f_qsat_oce', f_qsat_oce_omp)
    19241923    !
    19251924    f_gust_bl_omp = 0.
    1926     CALL getin('f_gust_bl',f_gust_bl_omp)
     1925    CALL getin('f_gust_bl', f_gust_bl_omp)
    19271926    !
    19281927    f_gust_wk_omp = 0.
    1929     CALL getin('f_gust_wk',f_gust_wk_omp)
     1928    CALL getin('f_gust_wk', f_gust_wk_omp)
    19301929    !
    19311930    !Config Key  = iflag_z0_oce
     
    19341933    !Config Help =
    19351934    !
    1936     iflag_z0_oce_omp=0
    1937     CALL getin('iflag_z0_oce',iflag_z0_oce_omp)
    1938     !
    1939     iflag_gusts_omp=0
    1940     CALL getin('iflag_gusts',iflag_gusts_omp)
     1935    iflag_z0_oce_omp = 0
     1936    CALL getin('iflag_z0_oce', iflag_z0_oce_omp)
     1937    !
     1938    iflag_gusts_omp = 0
     1939    CALL getin('iflag_gusts', iflag_gusts_omp)
    19411940    !
    19421941    min_wind_speed_omp = 1.
    1943     CALL getin('min_wind_speed',min_wind_speed_omp)
    1944 
    1945     z0m_seaice_omp = 0.002 ; CALL getin('z0m_seaice',z0m_seaice_omp)
    1946     z0h_seaice_omp = 0.002 ; CALL getin('z0h_seaice',z0h_seaice_omp)
    1947 
    1948 
    1949     z0m_landice_omp = 0.001 ; CALL getin('z0m_landice',z0m_landice_omp)
    1950     z0h_landice_omp = 0.001 ; CALL getin('z0h_landice',z0h_landice_omp)
     1942    CALL getin('min_wind_speed', min_wind_speed_omp)
     1943
     1944    z0m_seaice_omp = 0.002 ; CALL getin('z0m_seaice', z0m_seaice_omp)
     1945    z0h_seaice_omp = 0.002 ; CALL getin('z0h_seaice', z0h_seaice_omp)
     1946
     1947    z0m_landice_omp = 0.001 ; CALL getin('z0m_landice', z0m_landice_omp)
     1948    z0h_landice_omp = 0.001 ; CALL getin('z0h_landice', z0h_landice_omp)
    19511949
    19521950    f_rugoro_omp = 0.
    1953     CALL getin('f_rugoro',f_rugoro_omp)
     1951    CALL getin('f_rugoro', f_rugoro_omp)
    19541952
    19551953    z0min_omp = 0.000015
    1956     CALL getin('z0min',z0min_omp)
     1954    CALL getin('z0min', z0min_omp)
    19571955
    19581956
     
    19651963    !
    19661964    supcrit1_omp = .540
    1967     CALL getin('supcrit1',supcrit1_omp)
     1965    CALL getin('supcrit1', supcrit1_omp)
    19681966
    19691967    !
     
    19741972    !
    19751973    supcrit2_omp = .600
    1976     CALL getin('supcrit2',supcrit2_omp)
     1974    CALL getin('supcrit2', supcrit2_omp)
    19771975
    19781976    !
     
    19891987    !
    19901988    iflag_mix_omp = 1
    1991     CALL getin('iflag_mix',iflag_mix_omp)
    1992 
    1993 !
     1989    CALL getin('iflag_mix', iflag_mix_omp)
     1990
     1991    !
    19941992    ! PARAMETERS FOR THE EROSION OF THE ADIABATIC ASCENTS
    19951993    ! iflag_mix_adiab: 0=OLD,
     
    20032001    !
    20042002    iflag_mix_adiab_omp = 0
    2005     CALL getin('iflag_mix_adiab',iflag_mix_adiab_omp)
     2003    CALL getin('iflag_mix_adiab', iflag_mix_adiab_omp)
    20062004
    20072005    !
     
    20122010    !
    20132011    scut_omp = 0.95
    2014     CALL getin('scut',scut_omp)
     2012    CALL getin('scut', scut_omp)
    20152013
    20162014    !
     
    20212019    !
    20222020    qqa1_omp = 1.0
    2023     CALL getin('qqa1',qqa1_omp)
     2021    CALL getin('qqa1', qqa1_omp)
    20242022
    20252023    !
     
    20302028    !
    20312029    qqa2_omp = 0.0
    2032     CALL getin('qqa2',qqa2_omp)
     2030    CALL getin('qqa2', qqa2_omp)
    20332031
    20342032    !
     
    20392037    !
    20402038    gammas_omp = 0.05
    2041     CALL getin('gammas',gammas_omp)
     2039    CALL getin('gammas', gammas_omp)
    20422040
    20432041    !
     
    20482046    !
    20492047    Fmax_omp = 0.65
    2050     CALL getin('Fmax',Fmax_omp)
     2048    CALL getin('Fmax', Fmax_omp)
    20512049
    20522050    !
     
    20572055    !
    20582056    tmax_fonte_cv_omp = 275.15
    2059     CALL getin('tmax_fonte_cv',tmax_fonte_cv_omp)
     2057    CALL getin('tmax_fonte_cv', tmax_fonte_cv_omp)
    20602058
    20612059    !
     
    20662064    !
    20672065    alphas_omp = -5.
    2068     CALL getin('alphas',alphas_omp)
     2066    CALL getin('alphas', alphas_omp)
    20692067
    20702068    !Config key = ok_strato
     
    20742072    !               Et la sponge layer (Runs Stratospheriques)
    20752073
    2076     ok_strato_omp=.FALSE.
    2077     CALL getin('ok_strato',ok_strato_omp)
     2074    ok_strato_omp = .FALSE.
     2075    CALL getin('ok_strato', ok_strato_omp)
    20782076
    20792077    !Config  key = ok_hines
     
    20822080    !Config  Help = Clefs controlant la parametrization de Hines
    20832081
    2084     ok_hines_omp=.FALSE.
    2085     CALL getin('ok_hines',ok_hines_omp)
     2082    ok_hines_omp = .FALSE.
     2083    CALL getin('ok_hines', ok_hines_omp)
    20862084
    20872085    !  Parametres pour les ondes de gravite
     
    20922090    CALL getin('sso_gkdrag', sso_gkdrag_omp)
    20932091
    2094     sso_grahil_omp=merge(0.1,1.,ok_strato_omp)
     2092    sso_grahil_omp = merge(0.1, 1., ok_strato_omp)
    20952093    CALL getin('sso_grahil', sso_grahil_omp)
    20962094
    2097     sso_grcrit_omp =merge(1.,0.01,ok_strato_omp)
     2095    sso_grcrit_omp = merge(1., 0.01, ok_strato_omp)
    20982096    CALL getin('sso_grcrit', sso_grcrit_omp)
    20992097
     
    21042102    CALL getin('sso_gkwake', sso_gkwake_omp)
    21052103
    2106     sso_gklift_omp = merge(0.25,0.50,ok_strato_omp)
     2104    sso_gklift_omp = merge(0.25, 0.50, ok_strato_omp)
    21072105    CALL getin('sso_gklift', sso_gklift_omp)
    21082106
     
    21102108
    21112109    ok_gwd_rando_omp = .FALSE.
    2112     IF ( klon_glo == 1 ) THEN
    2113        print*,'La parametrisation des ondes de gravites non orographiques'
    2114        print*,'ne fonctionne pas en 1D'
     2110    IF (klon_glo == 1) THEN
     2111      print*, 'La parametrisation des ondes de gravites non orographiques'
     2112      print*, 'ne fonctionne pas en 1D'
    21152113    ELSE
    2116        CALL getin('ok_gwd_rando', ok_gwd_rando_omp)
     2114      CALL getin('ok_gwd_rando', ok_gwd_rando_omp)
    21172115    ENDIF
    21182116
     
    21362134    !               de l'humidite due a oxydation+photolyse du methane strato
    21372135
    2138     ok_qch4_omp=.FALSE.
    2139     CALL getin('ok_qch4',ok_qch4_omp)
     2136    ok_qch4_omp = .FALSE.
     2137    CALL getin('ok_qch4', ok_qch4_omp)
    21402138
    21412139    !Config Key  = OK_LES                                               
     
    21452143    !              LES                                                 
    21462144    !                                                                   
    2147     ok_LES_omp = .FALSE.                                             
    2148     CALL getin('OK_LES', ok_LES_omp)                                 
     2145    ok_LES_omp = .FALSE.
     2146    CALL getin('OK_LES', ok_LES_omp)
    21492147
    21502148    !Config Key  = callstats                                               
     
    21542152    !              stats                                                 
    21552153    !                                                                   
    2156     callstats_omp = .FALSE.                                             
    2157     CALL getin('callstats', callstats_omp)                                 
     2154    callstats_omp = .FALSE.
     2155    CALL getin('callstats', callstats_omp)
    21582156    !
    21592157    !Config Key  = ecrit_LES
     
    21832181    !Config Help = .FALSE. ensure much fewer (no calendar dependency)
    21842182    !  and lighter monthly climoz files, inetrpolated in time at gcm run time.
    2185    
     2183
    21862184    ok_new_lscp_omp = .FALSE.
    21872185    CALL getin('ok_new_lscp', ok_new_lscp_omp)
     
    21922190    !Config Help = ...
    21932191
    2194 
    2195 
    21962192    ok_icefra_lscp_omp = .FALSE.
    21972193    CALL getin('ok_icefra_lscp', ok_icefra_lscp_omp)
     
    22022198    !Config Help = ...
    22032199
    2204 
    2205 
    22062200    ok_bs_omp = .FALSE.
    22072201    CALL getin('ok_bs', ok_bs_omp)
     
    22122206    !Config Help = ...
    22132207
    2214 
    22152208    ok_rad_bs_omp = .FALSE.
    22162209    CALL getin('ok_rad_bs', ok_rad_bs_omp)
     
    22212214    !Config Help = ...
    22222215
    2223     ecrit_LES_omp = 1./8.
     2216    ecrit_LES_omp = 1. / 8.
    22242217    CALL getin('ecrit_LES', ecrit_LES_omp)
    22252218    !
     
    22272220    CALL getin('read_climoz', read_climoz)
    22282221
    2229     carbon_cycle_tr_omp=.FALSE.
    2230     CALL getin('carbon_cycle_tr',carbon_cycle_tr_omp)
    2231 
    2232     carbon_cycle_cpl_omp=.FALSE.
    2233     CALL getin('carbon_cycle_cpl',carbon_cycle_cpl_omp)
    2234 
    2235     carbon_cycle_rad_omp=.FALSE.
    2236     CALL getin('carbon_cycle_rad',carbon_cycle_rad_omp)
    2237 
    2238     read_fco2_ocean_cor_omp=.FALSE.
    2239     CALL getin('read_fco2_ocean_cor',read_fco2_ocean_cor_omp)
    2240 
    2241     var_fco2_ocean_cor_omp=0. ! default value
    2242     CALL getin('var_fco2_ocean_cor',var_fco2_ocean_cor_omp)
    2243 
    2244     read_fco2_land_cor_omp=.FALSE.
    2245     CALL getin('read_fco2_land_cor',read_fco2_land_cor_omp)
    2246 
    2247     var_fco2_land_cor_omp=0. ! default value
    2248     CALL getin('var_fco2_land_cor',var_fco2_land_cor_omp)
     2222    carbon_cycle_tr_omp = .FALSE.
     2223    CALL getin('carbon_cycle_tr', carbon_cycle_tr_omp)
     2224
     2225    carbon_cycle_cpl_omp = .FALSE.
     2226    CALL getin('carbon_cycle_cpl', carbon_cycle_cpl_omp)
     2227
     2228    carbon_cycle_rad_omp = .FALSE.
     2229    CALL getin('carbon_cycle_rad', carbon_cycle_rad_omp)
     2230
     2231    read_fco2_ocean_cor_omp = .FALSE.
     2232    CALL getin('read_fco2_ocean_cor', read_fco2_ocean_cor_omp)
     2233
     2234    var_fco2_ocean_cor_omp = 0. ! default value
     2235    CALL getin('var_fco2_ocean_cor', var_fco2_ocean_cor_omp)
     2236
     2237    read_fco2_land_cor_omp = .FALSE.
     2238    CALL getin('read_fco2_land_cor', read_fco2_land_cor_omp)
     2239
     2240    var_fco2_land_cor_omp = 0. ! default value
     2241    CALL getin('var_fco2_land_cor', var_fco2_land_cor_omp)
    22492242
    22502243    ! level_coupling_esm : level of coupling of the biogeochemical fields between LMDZ, ORCHIDEE and NEMO
     
    22582251    ! level_coupling_esm = 3  ! Field exchange between LMDZ and ORCHIDEE models
    22592252    !                         ! Field exchange between LMDZ and NEMO models
    2260     level_coupling_esm_omp=0 ! default value
    2261     CALL getin('level_coupling_esm',level_coupling_esm_omp)
    2262 
    2263 
    2264     dms_cycle_cpl_omp=.FALSE.
    2265     CALL getin('transm_dms_oa',dms_cycle_cpl_omp)
     2253    level_coupling_esm_omp = 0 ! default value
     2254    CALL getin('level_coupling_esm', level_coupling_esm_omp)
     2255
     2256    dms_cycle_cpl_omp = .FALSE.
     2257    CALL getin('transm_dms_oa', dms_cycle_cpl_omp)
    22662258    !
    22672259    !Config Key  = dms_cycle_cpl
     
    22702262    !Config Help = can be activated only if lmdz use inca for the atmospheric chemistry
    22712263
    2272     n2o_cycle_cpl_omp=.FALSE.
    2273     CALL getin('transm_n2o_oa',n2o_cycle_cpl_omp)
     2264    n2o_cycle_cpl_omp = .FALSE.
     2265    CALL getin('transm_n2o_oa', n2o_cycle_cpl_omp)
    22742266    !
    22752267    !Config Key  = n2o_cycle_cpl
     
    22772269    !Config Def  = .FALSE.
    22782270    !Config Help = can be activated only if lmdz use inca for the atmospheric chemistry
    2279    
    2280    
     2271
     2272
    22812273    !$OMP END MASTER
    22822274    !$OMP BARRIER
     
    23142306    ok_orodr = ok_orodr_omp
    23152307    ok_orolf = ok_orolf_omp
    2316     zrel_oro_t=zrel_oro_t_omp
    2317     zstd_orodr_t=zstd_orodr_t_omp
    2318     zpmm_orodr_t=zpmm_orodr_t_omp
    2319     zpmm_orolf_t=zpmm_orolf_t_omp
     2308    zrel_oro_t = zrel_oro_t_omp
     2309    zstd_orodr_t = zstd_orodr_t_omp
     2310    zpmm_orodr_t = zpmm_orodr_t_omp
     2311    zpmm_orolf_t = zpmm_orolf_t_omp
    23202312    ok_limitvrai = ok_limitvrai_omp
    23212313    nbapp_rad = nbapp_rad_omp
     
    23402332    inertie_sno = inertie_sno_omp
    23412333    ok_bs = ok_bs_omp
    2342     ok_rad_bs=ok_rad_bs_omp
     2334    ok_rad_bs = ok_rad_bs_omp
    23432335    rad_froid = rad_froid_omp
    23442336    rad_chau1 = rad_chau1_omp
     
    23612353    iflag_physiq = iflag_physiq_omp
    23622354    iflag_pbl_split = iflag_pbl_split_omp
    2363 !FC
     2355    !FC
    23642356    ifl_pbltree = ifl_pbltree_omp
    2365     Cd_frein    =Cd_frein_omp
     2357    Cd_frein = Cd_frein_omp
    23662358    iflag_order2_sollw = iflag_order2_sollw_omp
    23672359    lev_histhf = lev_histhf_omp
     
    23802372    t_coupl = t_coupl_omp
    23812373
    2382     ok_veget=.TRUE.
    2383     type_veget=type_veget_omp
     2374    ok_veget = .TRUE.
     2375    type_veget = type_veget_omp
    23842376    IF (type_veget=='n' .or. type_veget=='bucket' .or. type_veget=='betaclim') THEN
    2385        ok_veget=.FALSE.
     2377      ok_veget = .FALSE.
    23862378    ENDIF
    23872379    ! INLANDSIS
     
    23912383    iflag_temp_inlandsis = iflag_temp_inlandsis_omp
    23922384    iflag_albcalc = iflag_albcalc_omp
    2393     SnoMod=SnoMod_omp
    2394     BloMod=BloMod_omp
    2395     ok_outfor=ok_outfor_omp
    2396     is_ok_slush=is_ok_slush_omp
    2397     opt_runoff_ac=opt_runoff_ac_omp
    2398     is_ok_z0h_rn=is_ok_z0h_rn_omp
    2399     is_ok_density_kotlyakov=is_ok_density_kotlyakov_omp
    2400     prescribed_z0m_snow=prescribed_z0m_snow_omp
    2401     correc_alb=correc_alb_omp
    2402     iflag_z0m_snow=iflag_z0m_snow_omp
    2403     ok_zsn_ii=ok_zsn_ii_omp
    2404     discret_xf=discret_xf_omp
    2405     buf_sph_pol=buf_sph_pol_omp
    2406     buf_siz_pol=buf_siz_pol_omp
     2385    SnoMod = SnoMod_omp
     2386    BloMod = BloMod_omp
     2387    ok_outfor = ok_outfor_omp
     2388    is_ok_slush = is_ok_slush_omp
     2389    opt_runoff_ac = opt_runoff_ac_omp
     2390    is_ok_z0h_rn = is_ok_z0h_rn_omp
     2391    is_ok_density_kotlyakov = is_ok_density_kotlyakov_omp
     2392    prescribed_z0m_snow = prescribed_z0m_snow_omp
     2393    correc_alb = correc_alb_omp
     2394    iflag_z0m_snow = iflag_z0m_snow_omp
     2395    ok_zsn_ii = ok_zsn_ii_omp
     2396    discret_xf = discret_xf_omp
     2397    buf_sph_pol = buf_sph_pol_omp
     2398    buf_siz_pol = buf_siz_pol_omp
    24072399    !=================================================
    24082400    ok_all_xml = ok_all_xml_omp
     
    24282420    flag_aerosol_strat = flag_aerosol_strat_omp
    24292421    flag_aer_feedback = flag_aer_feedback_omp
    2430     flag_bc_internal_mixture=flag_bc_internal_mixture_omp
     2422    flag_bc_internal_mixture = flag_bc_internal_mixture_omp
    24312423    aer_type = aer_type_omp
    24322424    bl95_b0 = bl95_b0_omp
     
    24752467    ok_journeCOSP = ok_journeCOSP_omp
    24762468    ok_hfCOSP = ok_hfCOSP_omp
    2477     seuil_inversion=seuil_inversion_omp
     2469    seuil_inversion = seuil_inversion_omp
    24782470    lonmin_ins = lonmin_ins_omp
    24792471    lonmax_ins = lonmax_ins_omp
    24802472    latmin_ins = latmin_ins_omp
    24812473    latmax_ins = latmax_ins_omp
    2482     ecrit_hf   = ecrit_hf_omp
    2483     ecrit_ins   = ecrit_ins_omp
     2474    ecrit_hf = ecrit_hf_omp
     2475    ecrit_ins = ecrit_ins_omp
    24842476    ecrit_day = ecrit_day_omp
    24852477    ecrit_mth = ecrit_mth_omp
     
    24912483    ok_lic_melt = ok_lic_melt_omp
    24922484    ok_lic_cond = ok_lic_cond_omp
    2493     f_cdrag_ter=f_cdrag_ter_omp
    2494     f_cdrag_oce=f_cdrag_oce_omp
    2495 
    2496     f_gust_wk=f_gust_wk_omp
    2497     f_gust_bl=f_gust_bl_omp
    2498     f_qsat_oce=f_qsat_oce_omp
    2499     f_z0qh_oce=f_z0qh_oce_omp
    2500     min_wind_speed=min_wind_speed_omp
    2501     iflag_gusts=iflag_gusts_omp
    2502     iflag_z0_oce=iflag_z0_oce_omp
    2503 
    2504     z0m_seaice=z0m_seaice_omp
    2505     z0h_seaice=z0h_seaice_omp
    2506     z0m_landice=z0m_landice_omp
    2507     z0h_landice=z0h_landice_omp
    2508 
    2509     f_rugoro=f_rugoro_omp
    2510 
    2511     z0min=z0min_omp
     2485    f_cdrag_ter = f_cdrag_ter_omp
     2486    f_cdrag_oce = f_cdrag_oce_omp
     2487
     2488    f_gust_wk = f_gust_wk_omp
     2489    f_gust_bl = f_gust_bl_omp
     2490    f_qsat_oce = f_qsat_oce_omp
     2491    f_z0qh_oce = f_z0qh_oce_omp
     2492    min_wind_speed = min_wind_speed_omp
     2493    iflag_gusts = iflag_gusts_omp
     2494    iflag_z0_oce = iflag_z0_oce_omp
     2495
     2496    z0m_seaice = z0m_seaice_omp
     2497    z0h_seaice = z0h_seaice_omp
     2498    z0m_landice = z0m_landice_omp
     2499    z0h_landice = z0h_landice_omp
     2500
     2501    f_rugoro = f_rugoro_omp
     2502
     2503    z0min = z0min_omp
    25122504    supcrit1 = supcrit1_omp
    25132505    supcrit2 = supcrit2_omp
     
    25222514    alphas = alphas_omp
    25232515
    2524     gkdrag=sso_gkdrag_omp
    2525     grahilo=sso_grahil_omp
    2526     grcrit=sso_grcrit_omp
    2527     gfrcrit=sso_gfrcri_omp
    2528     gkwake=sso_gkwake_omp
    2529     gklift=sso_gklift_omp
     2516    gkdrag = sso_gkdrag_omp
     2517    grahilo = sso_grahil_omp
     2518    grcrit = sso_grcrit_omp
     2519    gfrcrit = sso_gfrcri_omp
     2520    gkwake = sso_gkwake_omp
     2521    gklift = sso_gklift_omp
    25302522
    25312523    ok_strato = ok_strato_omp
     
    25472539    level_coupling_esm = level_coupling_esm_omp
    25482540    ok_new_lscp = ok_new_lscp_omp
    2549     ok_icefra_lscp=ok_icefra_lscp_omp
     2541    ok_icefra_lscp = ok_icefra_lscp_omp
    25502542    read_fco2_ocean_cor = read_fco2_ocean_cor_omp
    25512543    var_fco2_ocean_cor = var_fco2_ocean_cor_omp
     
    25552547    n2o_cycle_cpl = n2o_cycle_cpl_omp
    25562548    !rajout Olivier Torres
    2557     kz0=kz0_omp
     2549    kz0 = kz0_omp
    25582550    choix_bulk = choix_bulk_omp
    25592551    nit_bulk = nit_bulk_omp
    25602552
    25612553    ! Test of coherence between type_ocean and version_ocean
    2562     IF (type_ocean=='couple' .AND. (version_ocean/='opa8' .AND. version_ocean/='nemo') ) THEN
    2563        WRITE(lunout,*)' ERROR version_ocean=',version_ocean,' not valid in coupled configuration'
    2564        CALL abort_physic('conf_phys','version_ocean not valid',1)
     2554    IF (type_ocean=='couple' .AND. (version_ocean/='opa8' .AND. version_ocean/='nemo')) THEN
     2555      WRITE(lunout, *)' ERROR version_ocean=', version_ocean, ' not valid in coupled configuration'
     2556      CALL abort_physic('conf_phys', 'version_ocean not valid', 1)
    25652557    ENDIF
    25662558
    25672559    IF (type_ocean=='slab' .AND. version_ocean=='xxxxxx') THEN
    2568        version_ocean='sicOBS'
     2560      version_ocean = 'sicOBS'
    25692561    ELSE IF (type_ocean=='slab' .AND. version_ocean/='sicOBS' &
    2570          .AND. version_ocean/='sicINT' .AND. version_ocean/='sicNO') THEN
    2571        WRITE(lunout,*)' ERROR version_ocean=',version_ocean,' not valid with slab ocean'
    2572        CALL abort_physic('conf_phys','version_ocean not valid',1)
     2562            .AND. version_ocean/='sicINT' .AND. version_ocean/='sicNO') THEN
     2563      WRITE(lunout, *)' ERROR version_ocean=', version_ocean, ' not valid with slab ocean'
     2564      CALL abort_physic('conf_phys', 'version_ocean not valid', 1)
    25732565    ENDIF
    25742566
     
    25762568    IF (iflag_rrtm == 0) THEN
    25772569      IF (NSW/=2) THEN
    2578         WRITE(lunout,*) ' ERROR iflag_rrtm=0 and NSW<>2 not possible'
    2579         CALL abort_physic('conf_phys','choice NSW not valid',1)
     2570        WRITE(lunout, *) ' ERROR iflag_rrtm=0 and NSW<>2 not possible'
     2571        CALL abort_physic('conf_phys', 'choice NSW not valid', 1)
    25802572      ENDIF
    25812573    ELSE IF (iflag_rrtm == 1) THEN
    25822574      IF (NSW/=2.AND.NSW/=4.AND.NSW/=6) THEN
    2583         WRITE(lunout,*) ' ERROR iflag_rrtm=1 and NSW<>2,4,6 not possible'
    2584         CALL abort_physic('conf_phys','choice NSW not valid',1)
     2575        WRITE(lunout, *) ' ERROR iflag_rrtm=1 and NSW<>2,4,6 not possible'
     2576        CALL abort_physic('conf_phys', 'choice NSW not valid', 1)
    25852577      ENDIF
    2586    ELSE IF (iflag_rrtm == 2) THEN
     2578    ELSE IF (iflag_rrtm == 2) THEN
    25872579      IF (NSW/=2.AND.NSW/=4.AND.NSW/=6) THEN
    2588         WRITE(lunout,*) ' ERROR iflag_rrtm=1 and NSW<>2,4,6 not possible'
    2589         CALL abort_physic('conf_phys','choice NSW not valid',1)
     2580        WRITE(lunout, *) ' ERROR iflag_rrtm=1 and NSW<>2,4,6 not possible'
     2581        CALL abort_physic('conf_phys', 'choice NSW not valid', 1)
    25902582      ENDIF
    2591     ELSE 
    2592        WRITE(lunout,*) ' ERROR iflag_rrtm<>0,1'
    2593        CALL abort_physic('conf_phys','choice iflag_rrtm not valid',1)
     2583    ELSE
     2584      WRITE(lunout, *) ' ERROR iflag_rrtm<>0,1'
     2585      CALL abort_physic('conf_phys', 'choice iflag_rrtm not valid', 1)
    25942586    ENDIF
    25952587    !--here we test that solaire has not been changed if ok_suntime_rrtm is activated
    2596 !    IF (ok_suntime_rrtm.AND.ABS(solaire-solaire_omp_init).GT.1.E-7) THEN
    2597 !       WRITE(lunout,*) ' ERROR ok_suntime_rrtm=y and solaire is provided in def file'
    2598 !       CALL abort_physic('conf_phys','ok_suntime_rrtm=y and solaire is provided',1)
    2599 !    ENDIF
    2600 #ifdef CPP_StratAer
    2601     IF (iflag_rrtm .NE. 1) THEN
    2602        WRITE(lunout,*) ' ERROR iflag_rrtm<>1 but StratAer activated'
    2603        CALL abort_physic('conf_phys','iflag_rrtm not valid for StratAer',1)
    2604     ENDIF
    2605     IF (NSW .NE. 6) THEN
    2606        WRITE(lunout,*) ' ERROR NSW<>6 but StratAer activated'
    2607        CALL abort_physic('conf_phys','NSW not valid for StratAer',1)
    2608     ENDIF
    2609 #endif
     2588    !    IF (ok_suntime_rrtm.AND.ABS(solaire-solaire_omp_init).GT.1.E-7) THEN
     2589    !       WRITE(lunout,*) ' ERROR ok_suntime_rrtm=y and solaire is provided in def file'
     2590    !       CALL abort_physic('conf_phys','ok_suntime_rrtm=y and solaire is provided',1)
     2591    !    ENDIF
     2592    IF (CPPKEY_STRATAER) THEN
     2593      IF (iflag_rrtm /= 1) THEN
     2594        WRITE(lunout, *) ' ERROR iflag_rrtm<>1 but StratAer activated'
     2595        CALL abort_physic('conf_phys', 'iflag_rrtm not valid for StratAer', 1)
     2596      ENDIF
     2597      IF (NSW /= 6) THEN
     2598        WRITE(lunout, *) ' ERROR NSW<>6 but StratAer activated'
     2599        CALL abort_physic('conf_phys', 'NSW not valid for StratAer', 1)
     2600      ENDIF
     2601    END IF
    26102602
    26112603    !--test on ocean surface albedo
    26122604    IF (iflag_albedo<0.OR.iflag_albedo>2) THEN
    2613        WRITE(lunout,*) ' ERROR iflag_albedo<>0,1'
    2614        CALL abort_physic('conf_phys','choice iflag_albedo not valid',1)
     2605      WRITE(lunout, *) ' ERROR iflag_albedo<>0,1'
     2606      CALL abort_physic('conf_phys', 'choice iflag_albedo not valid', 1)
    26152607    ENDIF
    26162608
    26172609    ! Flag_aerosol cannot be set to zero if aerosol direct effect (ade) or aerosol indirect effect (aie) are activated
    2618     IF (ok_ade .OR. ok_aie) THEN 
    2619        IF ( flag_aerosol == 0 ) THEN
    2620           CALL abort_physic('conf_phys','flag_aerosol=0 not compatible avec ok_ade ou ok_aie=.TRUE.',1)
    2621        ENDIF
     2610    IF (ok_ade .OR. ok_aie) THEN
     2611      IF (flag_aerosol == 0) THEN
     2612        CALL abort_physic('conf_phys', 'flag_aerosol=0 not compatible avec ok_ade ou ok_aie=.TRUE.', 1)
     2613      ENDIF
    26222614    ENDIF
    26232615
    26242616    ! Flag_aerosol cannot be set to zero if we are in coupled mode for aerosol
    2625     IF (aerosol_couple .AND. flag_aerosol == 0 ) THEN
    2626        CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if aerosol_couple=y ', 1)
     2617    IF (aerosol_couple .AND. flag_aerosol == 0) THEN
     2618      CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if aerosol_couple=y ', 1)
    26272619    ENDIF
    26282620
    26292621    ! Read_climoz needs to be set zero if we are in couple mode for chemistry
    26302622    IF (chemistry_couple .AND. read_climoz /= 0) THEN
    2631        CALL abort_physic('conf_phys', 'read_climoz need to be to zero if chemistry_couple=y ', 1)
     2623      CALL abort_physic('conf_phys', 'read_climoz need to be to zero if chemistry_couple=y ', 1)
    26322624    ENDIF
    26332625
    26342626    ! flag_aerosol need to be different to zero if ok_cdnc is activated
    26352627    IF (ok_cdnc .AND. flag_aerosol == 0) THEN
    2636        CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if ok_cdnc is activated ', 1)
     2628      CALL abort_physic('conf_phys', 'flag_aerosol cannot be to zero if ok_cdnc is activated ', 1)
    26372629    ENDIF
    26382630
    26392631    ! ok_cdnc must be set to y if ok_aie is activated
    26402632    IF (ok_aie .AND. .NOT. ok_cdnc) THEN
    2641        CALL abort_physic('conf_phys', 'ok_cdnc must be set to y if ok_aie is activated',1)
     2633      CALL abort_physic('conf_phys', 'ok_cdnc must be set to y if ok_aie is activated', 1)
    26422634    ENDIF
    26432635
    26442636    ! flag_aerosol=7 => MACv2SP climatology
    26452637    IF (flag_aerosol==7.AND. iflag_rrtm/=1) THEN
    2646        CALL abort_physic('conf_phys', 'flag_aerosol=7 (MACv2SP) can only be activated with RRTM',1)
     2638      CALL abort_physic('conf_phys', 'flag_aerosol=7 (MACv2SP) can only be activated with RRTM', 1)
    26472639    ENDIF
    26482640    IF (flag_aerosol==7.AND. NSW/=6) THEN
    2649        CALL abort_physic('conf_phys', 'flag_aerosol=7 (MACv2SP) can only be activated with NSW=6',1)
     2641      CALL abort_physic('conf_phys', 'flag_aerosol=7 (MACv2SP) can only be activated with NSW=6', 1)
    26502642    ENDIF
    26512643
    26522644    ! BC internal mixture is only possible with RRTM & NSW=6 & flag_aerosol=6 or aerosol_couple
    26532645    IF (flag_bc_internal_mixture .AND. NSW/=6) THEN
    2654        CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with NSW=6',1)
     2646      CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with NSW=6', 1)
    26552647    ENDIF
    26562648    IF (flag_bc_internal_mixture .AND. iflag_rrtm/=1) THEN
    2657        CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with RRTM',1)
     2649      CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with RRTM', 1)
    26582650    ENDIF
    26592651    IF (flag_bc_internal_mixture .AND. flag_aerosol/=6) THEN
    2660        CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with flag_aerosol=6',1)
     2652      CALL abort_physic('conf_phys', 'flag_bc_internal_mixture can only be activated with flag_aerosol=6', 1)
    26612653    ENDIF
    26622654
    26632655    ! test sur flag_volc_surfstrat
    26642656    IF (flag_volc_surfstrat<0.OR.flag_volc_surfstrat>2) THEN
    2665        CALL abort_physic('conf_phys', 'flag_volc_surfstrat can only be 0 1 or 2',1)
    2666     ENDIF 
     2657      CALL abort_physic('conf_phys', 'flag_volc_surfstrat can only be 0 1 or 2', 1)
     2658    ENDIF
    26672659    IF ((.NOT.ok_volcan.OR..NOT.ok_ade.OR..NOT.ok_aie).AND.flag_volc_surfstrat>0) THEN
    2668        CALL abort_physic('conf_phys', 'ok_ade, ok_aie, ok_volcan need to be activated if flag_volc_surfstrat is 1 or 2',1)
    2669     ENDIF 
     2660      CALL abort_physic('conf_phys', 'ok_ade, ok_aie, ok_volcan need to be activated if flag_volc_surfstrat is 1 or 2', 1)
     2661    ENDIF
    26702662
    26712663    ! Test on carbon cycle
    26722664    IF (carbon_cycle_tr .AND. .NOT. carbon_cycle_cpl) THEN
    2673        CALL abort_physic('conf_phys', 'carbon_cycle_cpl has to be TRUE if carbon_cycle_tr is on',1)
     2665      CALL abort_physic('conf_phys', 'carbon_cycle_cpl has to be TRUE if carbon_cycle_tr is on', 1)
    26742666    ENDIF
    26752667    IF (carbon_cycle_rad .AND. .NOT. carbon_cycle_cpl) THEN
    2676        CALL abort_physic('conf_phys', 'carbon_cycle_cpl has to be TRUE if carbon_cycle_rad is on',1)
     2668      CALL abort_physic('conf_phys', 'carbon_cycle_cpl has to be TRUE if carbon_cycle_rad is on', 1)
    26772669    ENDIF
    26782670
    26792671
    26802672    ! Test on chemistry cycle
    2681     IF ((type_trac /= "inca" .AND. type_trac /= "inco") .AND. ( dms_cycle_cpl .OR. n2o_cycle_cpl)  ) THEN
    2682        CALL abort_physic('conf_phys', 'dms_cycle_cpl or n2o_cycle_cpl has to be TRUE only with INCA coupling model',1)
     2673    IF ((type_trac /= "inca" .AND. type_trac /= "inco") .AND. (dms_cycle_cpl .OR. n2o_cycle_cpl)) THEN
     2674      CALL abort_physic('conf_phys', 'dms_cycle_cpl or n2o_cycle_cpl has to be TRUE only with INCA coupling model', 1)
    26832675    ENDIF
    2684    
     2676
    26852677    ! ORCHIDEE must be activated for ifl_pbltree=1
    26862678    IF (.NOT. ok_veget .AND. ifl_pbltree==1) THEN
    2687        WRITE(lunout,*)'Warning: ORCHIDEE must be activated for ifl_pbltree=1'
    2688        WRITE(lunout,*)'ifl_pbltree is now changed to zero'
    2689        ifl_pbltree=0
     2679      WRITE(lunout, *)'Warning: ORCHIDEE must be activated for ifl_pbltree=1'
     2680      WRITE(lunout, *)'ifl_pbltree is now changed to zero'
     2681      ifl_pbltree = 0
    26902682    ENDIF
    26912683
    26922684    !$OMP MASTER
    26932685
    2694     WRITE(lunout,*) ' ##############################################'
    2695     WRITE(lunout,*) ' Configuration des parametres de la physique: '
    2696     WRITE(lunout,*) ' Type ocean = ', type_ocean
    2697     WRITE(lunout,*) ' Version ocean = ', version_ocean
    2698     WRITE(lunout,*) ' Config veget = ', ok_veget,type_veget
    2699     WRITE(lunout,*) ' Snow model landice : landice_opt = ', landice_opt
    2700     WRITE(lunout,*) ' Config xml pour XIOS : ok_all_xml = ', ok_all_xml
    2701     WRITE(lunout,*) ' Sortie journaliere = ', ok_journe
    2702     WRITE(lunout,*) ' Sortie haute frequence = ', ok_hf
    2703     WRITE(lunout,*) ' Sortie mensuelle = ', ok_mensuel
    2704     WRITE(lunout,*) ' Sortie instantanee = ', ok_instan
    2705     WRITE(lunout,*) ' Frequence appel simulateur ISCCP, freq_ISCCP =', freq_ISCCP
    2706     WRITE(lunout,*) ' Frequence appel simulateur ISCCP, ecrit_ISCCP =', ecrit_ISCCP
    2707     WRITE(lunout,*) ' Frequence appel simulateur COSP, freq_COSP =', freq_COSP
    2708     WRITE(lunout,*) ' Frequence appel simulateur AIRS, freq_AIRS =', freq_AIRS
    2709     WRITE(lunout,*) ' Sortie bilan d''energie, ip_ebil_phy =', ip_ebil_phy
    2710     WRITE(lunout,*) ' Excentricite = ',R_ecc
    2711     WRITE(lunout,*) ' Equinoxe = ',R_peri
    2712     WRITE(lunout,*) ' Inclinaison =',R_incl
    2713     WRITE(lunout,*) ' Constante solaire =',solaire
    2714     WRITE(lunout,*) ' ok_suntime_rrtm =',ok_suntime_rrtm
    2715     WRITE(lunout,*) ' co2_ppm =',co2_ppm
    2716     WRITE(lunout,*) ' co2_ppm0 =',co2_ppm0
    2717     WRITE(lunout,*) ' RCO2_act = ',RCO2_act
    2718     WRITE(lunout,*) ' CH4_ppb =',CH4_ppb,' RCH4_act = ',RCH4_act
    2719     WRITE(lunout,*) ' N2O_ppb =',N2O_ppb,' RN2O_act=  ',RN2O_act
    2720     WRITE(lunout,*) ' CFC11_ppt=',CFC11_ppt,' RCFC11_act=  ',RCFC11_act
    2721     WRITE(lunout,*) ' CFC12_ppt=',CFC12_ppt,' RCFC12_act=  ',RCFC12_act
    2722     WRITE(lunout,*) ' RCO2_per = ',RCO2_per,' RCH4_per = ', RCH4_per
    2723     WRITE(lunout,*) ' RN2O_per = ',RN2O_per,' RCFC11_per = ', RCFC11_per
    2724     WRITE(lunout,*) ' RCFC12_per = ',RCFC12_per
    2725     WRITE(lunout,*) ' cvl_comp_threshold=', cvl_comp_threshold
    2726     WRITE(lunout,*) ' cvl_sig2feed=', cvl_sig2feed
    2727     WRITE(lunout,*) ' cvl_corr=', cvl_corr
    2728     WRITE(lunout,*) ' ok_lic_melt=', ok_lic_melt
    2729     WRITE(lunout,*) ' ok_lic_cond=', ok_lic_cond
    2730     WRITE(lunout,*) ' iflag_cycle_diurne=',iflag_cycle_diurne
    2731     WRITE(lunout,*) ' soil_model=',soil_model
    2732     WRITE(lunout,*) ' new_oliq=',new_oliq
    2733     WRITE(lunout,*) ' ok_orodr=',ok_orodr
    2734     WRITE(lunout,*) ' ok_orolf=',ok_orolf
    2735     WRITE(lunout,*) ' zrel_oro_t=',zrel_oro_t
    2736     WRITE(lunout,*) ' zstd_orodr_t=',zstd_orodr_t
    2737     WRITE(lunout,*) ' zpmm_orodr_t=',zpmm_orodr_t
    2738     WRITE(lunout,*) ' zpmm_orolf_t=',zpmm_orolf_t
    2739     WRITE(lunout,*) ' ok_limitvrai=',ok_limitvrai
    2740     WRITE(lunout,*) ' nbapp_rad=',nbapp_rad
    2741     WRITE(lunout,*) ' iflag_con=',iflag_con
    2742     WRITE(lunout,*) ' nbapp_cv=',nbapp_cv
    2743     WRITE(lunout,*) ' nbapp_wk=',nbapp_wk
    2744     WRITE(lunout,*) ' iflag_ener_conserv=',iflag_ener_conserv
    2745     WRITE(lunout,*) ' ok_conserv_q=',ok_conserv_q
    2746     WRITE(lunout,*) ' epmax = ', epmax
    2747     WRITE(lunout,*) ' coef_epmax_cape = ', coef_epmax_cape
    2748     WRITE(lunout,*) ' ok_adj_ema = ', ok_adj_ema
    2749     WRITE(lunout,*) ' iflag_clw = ', iflag_clw
    2750     WRITE(lunout,*) ' iflag_cld_th = ', iflag_cld_th
    2751     WRITE(lunout,*) ' iflag_cld_cv = ', iflag_cld_cv
    2752     WRITE(lunout,*) ' tau_cld_cv = ', tau_cld_cv
    2753     WRITE(lunout,*) ' coefw_cld_cv = ', coefw_cld_cv
    2754     WRITE(lunout,*) ' iflag_radia = ', iflag_radia
    2755     WRITE(lunout,*) ' iflag_rrtm = ', iflag_rrtm
    2756     WRITE(lunout,*) ' NSW = ', NSW
    2757     WRITE(lunout,*) ' iflag_albedo = ', iflag_albedo !albedo SB
    2758     WRITE(lunout,*) ' ok_chlorophyll =',ok_chlorophyll ! albedo SB
    2759     WRITE(lunout,*) ' iflag_ratqs = ', iflag_ratqs
    2760     WRITE(lunout,*) ' seuil_inversion = ', seuil_inversion
    2761     WRITE(lunout,*) ' fact_cldcon = ', fact_cldcon
    2762     WRITE(lunout,*) ' facttemps = ', facttemps
    2763     WRITE(lunout,*) ' ok_newmicro = ',ok_newmicro
    2764     WRITE(lunout,*) ' ratqsbas = ',ratqsbas
    2765     WRITE(lunout,*) ' ratqshaut = ',ratqshaut
    2766     WRITE(lunout,*) ' tau_ratqs = ',tau_ratqs
    2767     WRITE(lunout,*) ' top_height = ',top_height
    2768     WRITE(lunout,*) ' rad_froid = ',rad_froid
    2769     WRITE(lunout,*) ' rad_chau1 = ',rad_chau1
    2770     WRITE(lunout,*) ' rad_chau2 = ',rad_chau2
    2771     WRITE(lunout,*) ' iflag_ice_thermo = ',iflag_ice_thermo
    2772     WRITE(lunout,*) ' ok_ice_sursat = ',ok_ice_sursat
    2773     WRITE(lunout,*) ' ok_plane_h2o = ',ok_plane_h2o
    2774     WRITE(lunout,*) ' ok_plane_contrail = ',ok_plane_contrail
    2775     WRITE(lunout,*) ' overlap = ',overlap
    2776     WRITE(lunout,*) ' cdmmax = ',cdmmax
    2777     WRITE(lunout,*) ' cdhmax = ',cdhmax
    2778     WRITE(lunout,*) ' ksta = ',ksta
    2779     WRITE(lunout,*) ' ksta_ter = ',ksta_ter
    2780     WRITE(lunout,*) ' f_ri_cd_min = ',f_ri_cd_min
    2781     WRITE(lunout,*) ' ok_kzmin = ',ok_kzmin
    2782     WRITE(lunout,*) ' fmagic = ',fmagic
    2783     WRITE(lunout,*) ' pmagic = ',pmagic
    2784     WRITE(lunout,*) ' ok_ade = ',ok_ade
    2785     WRITE(lunout,*) ' ok_volcan = ',ok_volcan
    2786     WRITE(lunout,*) ' flag_volc_surfstrat = ',flag_volc_surfstrat
    2787     WRITE(lunout,*) ' ok_aie = ',ok_aie
    2788     WRITE(lunout,*) ' ok_alw = ',ok_alw
    2789     WRITE(lunout,*) ' aerosol_couple = ', aerosol_couple
    2790     WRITE(lunout,*) ' chemistry_couple = ', chemistry_couple
    2791     WRITE(lunout,*) ' flag_aerosol = ', flag_aerosol
    2792     WRITE(lunout,*) ' flag_aerosol_strat= ', flag_aerosol_strat
    2793     WRITE(lunout,*) ' flag_aer_feedback= ', flag_aer_feedback
    2794     WRITE(lunout,*) ' aer_type = ',aer_type
    2795     WRITE(lunout,*) ' bl95_b0 = ',bl95_b0
    2796     WRITE(lunout,*) ' bl95_b1 = ',bl95_b1
    2797     WRITE(lunout,*) ' lev_histhf = ',lev_histhf
    2798     WRITE(lunout,*) ' lev_histday = ',lev_histday
    2799     WRITE(lunout,*) ' lev_histmth = ',lev_histmth
    2800     WRITE(lunout,*) ' lev_histins = ',lev_histins
    2801     WRITE(lunout,*) ' lev_histLES = ',lev_histLES
    2802     WRITE(lunout,*) ' lev_histdayNMC = ',lev_histdayNMC
    2803     WRITE(lunout,*) ' levout_histNMC = ',levout_histNMC
    2804     WRITE(lunout,*) ' ok_histNMC = ',ok_histNMC
    2805     WRITE(lunout,*) ' freq_outNMC = ',freq_outNMC
    2806     WRITE(lunout,*) ' freq_calNMC = ',freq_calNMC
    2807     WRITE(lunout,*) ' iflag_pbl = ', iflag_pbl
    2808     WRITE(lunout,*) ' iflag_physiq = ', iflag_physiq
    2809 !FC
    2810     WRITE(lunout,*) ' ifl_pbltree = ', ifl_pbltree
    2811     WRITE(lunout,*) ' Cd_frein = ', Cd_frein
    2812     WRITE(lunout,*) ' iflag_pbl_split = ', iflag_pbl_split
    2813     WRITE(lunout,*) ' iflag_order2_sollw = ', iflag_order2_sollw
    2814     WRITE(lunout,*) ' iflag_thermals = ', iflag_thermals
    2815     WRITE(lunout,*) ' iflag_clos = ', iflag_clos
    2816     WRITE(lunout,*) ' coef_clos_ls = ', coef_clos_ls
    2817     WRITE(lunout,*) ' type_run = ',type_run
    2818     WRITE(lunout,*) ' ok_cosp = ',ok_cosp
    2819     WRITE(lunout,*) ' ok_airs = ',ok_airs
    2820 
    2821     WRITE(lunout,*) ' ok_mensuelCOSP = ',ok_mensuelCOSP
    2822     WRITE(lunout,*) ' ok_journeCOSP = ',ok_journeCOSP
    2823     WRITE(lunout,*) ' ok_hfCOSP =',ok_hfCOSP
    2824     WRITE(lunout,*) ' solarlong0 = ', solarlong0
    2825     WRITE(lunout,*) ' qsol0 = ', qsol0
    2826     WRITE(lunout,*) ' evap0 = ', evap0
    2827     WRITE(lunout,*) ' albsno0 = ', albsno0
    2828     WRITE(lunout,*) ' iflag_sic = ', iflag_sic
    2829     WRITE(lunout,*) ' iflag_inertie = ', iflag_inertie
    2830     WRITE(lunout,*) ' inertie_sol = ', inertie_sol
    2831     WRITE(lunout,*) ' inertie_sic = ', inertie_sic
    2832     WRITE(lunout,*) ' inertie_lic = ', inertie_lic
    2833     WRITE(lunout,*) ' inertie_sno = ', inertie_sno
    2834     WRITE(lunout,*) ' ok_bs = ', ok_bs
    2835     WRITE(lunout,*) ' ok_rad_bs = ', ok_rad_bs
    2836     WRITE(lunout,*) ' f_cdrag_ter = ',f_cdrag_ter
    2837     WRITE(lunout,*) ' f_cdrag_oce = ',f_cdrag_oce
    2838     WRITE(lunout,*) ' f_rugoro = ',f_rugoro
    2839     WRITE(lunout,*) ' z0min = ',z0min
    2840     WRITE(lunout,*) ' supcrit1 = ', supcrit1
    2841     WRITE(lunout,*) ' supcrit2 = ', supcrit2
    2842     WRITE(lunout,*) ' iflag_mix = ', iflag_mix
    2843     WRITE(lunout,*) ' iflag_mix_adiab = ', iflag_mix_adiab
    2844     WRITE(lunout,*) ' scut = ', scut
    2845     WRITE(lunout,*) ' qqa1 = ', qqa1
    2846     WRITE(lunout,*) ' qqa2 = ', qqa2
    2847     WRITE(lunout,*) ' gammas = ', gammas
    2848     WRITE(lunout,*) ' Fmax = ', Fmax
    2849     WRITE(lunout,*) ' tmax_fonte_cv = ', tmax_fonte_cv
    2850     WRITE(lunout,*) ' alphas = ', alphas
    2851     WRITE(lunout,*) ' iflag_wake = ', iflag_wake
    2852     WRITE(lunout,*) ' alp_offset = ', alp_offset
     2686    WRITE(lunout, *) ' ##############################################'
     2687    WRITE(lunout, *) ' Configuration des parametres de la physique: '
     2688    WRITE(lunout, *) ' Type ocean = ', type_ocean
     2689    WRITE(lunout, *) ' Version ocean = ', version_ocean
     2690    WRITE(lunout, *) ' Config veget = ', ok_veget, type_veget
     2691    WRITE(lunout, *) ' Snow model landice : landice_opt = ', landice_opt
     2692    WRITE(lunout, *) ' Config xml pour XIOS : ok_all_xml = ', ok_all_xml
     2693    WRITE(lunout, *) ' Sortie journaliere = ', ok_journe
     2694    WRITE(lunout, *) ' Sortie haute frequence = ', ok_hf
     2695    WRITE(lunout, *) ' Sortie mensuelle = ', ok_mensuel
     2696    WRITE(lunout, *) ' Sortie instantanee = ', ok_instan
     2697    WRITE(lunout, *) ' Frequence appel simulateur ISCCP, freq_ISCCP =', freq_ISCCP
     2698    WRITE(lunout, *) ' Frequence appel simulateur ISCCP, ecrit_ISCCP =', ecrit_ISCCP
     2699    WRITE(lunout, *) ' Frequence appel simulateur COSP, freq_COSP =', freq_COSP
     2700    WRITE(lunout, *) ' Frequence appel simulateur AIRS, freq_AIRS =', freq_AIRS
     2701    WRITE(lunout, *) ' Sortie bilan d''energie, ip_ebil_phy =', ip_ebil_phy
     2702    WRITE(lunout, *) ' Excentricite = ', R_ecc
     2703    WRITE(lunout, *) ' Equinoxe = ', R_peri
     2704    WRITE(lunout, *) ' Inclinaison =', R_incl
     2705    WRITE(lunout, *) ' Constante solaire =', solaire
     2706    WRITE(lunout, *) ' ok_suntime_rrtm =', ok_suntime_rrtm
     2707    WRITE(lunout, *) ' co2_ppm =', co2_ppm
     2708    WRITE(lunout, *) ' co2_ppm0 =', co2_ppm0
     2709    WRITE(lunout, *) ' RCO2_act = ', RCO2_act
     2710    WRITE(lunout, *) ' CH4_ppb =', CH4_ppb, ' RCH4_act = ', RCH4_act
     2711    WRITE(lunout, *) ' N2O_ppb =', N2O_ppb, ' RN2O_act=  ', RN2O_act
     2712    WRITE(lunout, *) ' CFC11_ppt=', CFC11_ppt, ' RCFC11_act=  ', RCFC11_act
     2713    WRITE(lunout, *) ' CFC12_ppt=', CFC12_ppt, ' RCFC12_act=  ', RCFC12_act
     2714    WRITE(lunout, *) ' RCO2_per = ', RCO2_per, ' RCH4_per = ', RCH4_per
     2715    WRITE(lunout, *) ' RN2O_per = ', RN2O_per, ' RCFC11_per = ', RCFC11_per
     2716    WRITE(lunout, *) ' RCFC12_per = ', RCFC12_per
     2717    WRITE(lunout, *) ' cvl_comp_threshold=', cvl_comp_threshold
     2718    WRITE(lunout, *) ' cvl_sig2feed=', cvl_sig2feed
     2719    WRITE(lunout, *) ' cvl_corr=', cvl_corr
     2720    WRITE(lunout, *) ' ok_lic_melt=', ok_lic_melt
     2721    WRITE(lunout, *) ' ok_lic_cond=', ok_lic_cond
     2722    WRITE(lunout, *) ' iflag_cycle_diurne=', iflag_cycle_diurne
     2723    WRITE(lunout, *) ' soil_model=', soil_model
     2724    WRITE(lunout, *) ' new_oliq=', new_oliq
     2725    WRITE(lunout, *) ' ok_orodr=', ok_orodr
     2726    WRITE(lunout, *) ' ok_orolf=', ok_orolf
     2727    WRITE(lunout, *) ' zrel_oro_t=', zrel_oro_t
     2728    WRITE(lunout, *) ' zstd_orodr_t=', zstd_orodr_t
     2729    WRITE(lunout, *) ' zpmm_orodr_t=', zpmm_orodr_t
     2730    WRITE(lunout, *) ' zpmm_orolf_t=', zpmm_orolf_t
     2731    WRITE(lunout, *) ' ok_limitvrai=', ok_limitvrai
     2732    WRITE(lunout, *) ' nbapp_rad=', nbapp_rad
     2733    WRITE(lunout, *) ' iflag_con=', iflag_con
     2734    WRITE(lunout, *) ' nbapp_cv=', nbapp_cv
     2735    WRITE(lunout, *) ' nbapp_wk=', nbapp_wk
     2736    WRITE(lunout, *) ' iflag_ener_conserv=', iflag_ener_conserv
     2737    WRITE(lunout, *) ' ok_conserv_q=', ok_conserv_q
     2738    WRITE(lunout, *) ' epmax = ', epmax
     2739    WRITE(lunout, *) ' coef_epmax_cape = ', coef_epmax_cape
     2740    WRITE(lunout, *) ' ok_adj_ema = ', ok_adj_ema
     2741    WRITE(lunout, *) ' iflag_clw = ', iflag_clw
     2742    WRITE(lunout, *) ' iflag_cld_th = ', iflag_cld_th
     2743    WRITE(lunout, *) ' iflag_cld_cv = ', iflag_cld_cv
     2744    WRITE(lunout, *) ' tau_cld_cv = ', tau_cld_cv
     2745    WRITE(lunout, *) ' coefw_cld_cv = ', coefw_cld_cv
     2746    WRITE(lunout, *) ' iflag_radia = ', iflag_radia
     2747    WRITE(lunout, *) ' iflag_rrtm = ', iflag_rrtm
     2748    WRITE(lunout, *) ' NSW = ', NSW
     2749    WRITE(lunout, *) ' iflag_albedo = ', iflag_albedo !albedo SB
     2750    WRITE(lunout, *) ' ok_chlorophyll =', ok_chlorophyll ! albedo SB
     2751    WRITE(lunout, *) ' iflag_ratqs = ', iflag_ratqs
     2752    WRITE(lunout, *) ' seuil_inversion = ', seuil_inversion
     2753    WRITE(lunout, *) ' fact_cldcon = ', fact_cldcon
     2754    WRITE(lunout, *) ' facttemps = ', facttemps
     2755    WRITE(lunout, *) ' ok_newmicro = ', ok_newmicro
     2756    WRITE(lunout, *) ' ratqsbas = ', ratqsbas
     2757    WRITE(lunout, *) ' ratqshaut = ', ratqshaut
     2758    WRITE(lunout, *) ' tau_ratqs = ', tau_ratqs
     2759    WRITE(lunout, *) ' top_height = ', top_height
     2760    WRITE(lunout, *) ' rad_froid = ', rad_froid
     2761    WRITE(lunout, *) ' rad_chau1 = ', rad_chau1
     2762    WRITE(lunout, *) ' rad_chau2 = ', rad_chau2
     2763    WRITE(lunout, *) ' iflag_ice_thermo = ', iflag_ice_thermo
     2764    WRITE(lunout, *) ' ok_ice_sursat = ', ok_ice_sursat
     2765    WRITE(lunout, *) ' ok_plane_h2o = ', ok_plane_h2o
     2766    WRITE(lunout, *) ' ok_plane_contrail = ', ok_plane_contrail
     2767    WRITE(lunout, *) ' overlap = ', overlap
     2768    WRITE(lunout, *) ' cdmmax = ', cdmmax
     2769    WRITE(lunout, *) ' cdhmax = ', cdhmax
     2770    WRITE(lunout, *) ' ksta = ', ksta
     2771    WRITE(lunout, *) ' ksta_ter = ', ksta_ter
     2772    WRITE(lunout, *) ' f_ri_cd_min = ', f_ri_cd_min
     2773    WRITE(lunout, *) ' ok_kzmin = ', ok_kzmin
     2774    WRITE(lunout, *) ' fmagic = ', fmagic
     2775    WRITE(lunout, *) ' pmagic = ', pmagic
     2776    WRITE(lunout, *) ' ok_ade = ', ok_ade
     2777    WRITE(lunout, *) ' ok_volcan = ', ok_volcan
     2778    WRITE(lunout, *) ' flag_volc_surfstrat = ', flag_volc_surfstrat
     2779    WRITE(lunout, *) ' ok_aie = ', ok_aie
     2780    WRITE(lunout, *) ' ok_alw = ', ok_alw
     2781    WRITE(lunout, *) ' aerosol_couple = ', aerosol_couple
     2782    WRITE(lunout, *) ' chemistry_couple = ', chemistry_couple
     2783    WRITE(lunout, *) ' flag_aerosol = ', flag_aerosol
     2784    WRITE(lunout, *) ' flag_aerosol_strat= ', flag_aerosol_strat
     2785    WRITE(lunout, *) ' flag_aer_feedback= ', flag_aer_feedback
     2786    WRITE(lunout, *) ' aer_type = ', aer_type
     2787    WRITE(lunout, *) ' bl95_b0 = ', bl95_b0
     2788    WRITE(lunout, *) ' bl95_b1 = ', bl95_b1
     2789    WRITE(lunout, *) ' lev_histhf = ', lev_histhf
     2790    WRITE(lunout, *) ' lev_histday = ', lev_histday
     2791    WRITE(lunout, *) ' lev_histmth = ', lev_histmth
     2792    WRITE(lunout, *) ' lev_histins = ', lev_histins
     2793    WRITE(lunout, *) ' lev_histLES = ', lev_histLES
     2794    WRITE(lunout, *) ' lev_histdayNMC = ', lev_histdayNMC
     2795    WRITE(lunout, *) ' levout_histNMC = ', levout_histNMC
     2796    WRITE(lunout, *) ' ok_histNMC = ', ok_histNMC
     2797    WRITE(lunout, *) ' freq_outNMC = ', freq_outNMC
     2798    WRITE(lunout, *) ' freq_calNMC = ', freq_calNMC
     2799    WRITE(lunout, *) ' iflag_pbl = ', iflag_pbl
     2800    WRITE(lunout, *) ' iflag_physiq = ', iflag_physiq
     2801    !FC
     2802    WRITE(lunout, *) ' ifl_pbltree = ', ifl_pbltree
     2803    WRITE(lunout, *) ' Cd_frein = ', Cd_frein
     2804    WRITE(lunout, *) ' iflag_pbl_split = ', iflag_pbl_split
     2805    WRITE(lunout, *) ' iflag_order2_sollw = ', iflag_order2_sollw
     2806    WRITE(lunout, *) ' iflag_thermals = ', iflag_thermals
     2807    WRITE(lunout, *) ' iflag_clos = ', iflag_clos
     2808    WRITE(lunout, *) ' coef_clos_ls = ', coef_clos_ls
     2809    WRITE(lunout, *) ' type_run = ', type_run
     2810    WRITE(lunout, *) ' ok_cosp = ', ok_cosp
     2811    WRITE(lunout, *) ' ok_airs = ', ok_airs
     2812
     2813    WRITE(lunout, *) ' ok_mensuelCOSP = ', ok_mensuelCOSP
     2814    WRITE(lunout, *) ' ok_journeCOSP = ', ok_journeCOSP
     2815    WRITE(lunout, *) ' ok_hfCOSP =', ok_hfCOSP
     2816    WRITE(lunout, *) ' solarlong0 = ', solarlong0
     2817    WRITE(lunout, *) ' qsol0 = ', qsol0
     2818    WRITE(lunout, *) ' evap0 = ', evap0
     2819    WRITE(lunout, *) ' albsno0 = ', albsno0
     2820    WRITE(lunout, *) ' iflag_sic = ', iflag_sic
     2821    WRITE(lunout, *) ' iflag_inertie = ', iflag_inertie
     2822    WRITE(lunout, *) ' inertie_sol = ', inertie_sol
     2823    WRITE(lunout, *) ' inertie_sic = ', inertie_sic
     2824    WRITE(lunout, *) ' inertie_lic = ', inertie_lic
     2825    WRITE(lunout, *) ' inertie_sno = ', inertie_sno
     2826    WRITE(lunout, *) ' ok_bs = ', ok_bs
     2827    WRITE(lunout, *) ' ok_rad_bs = ', ok_rad_bs
     2828    WRITE(lunout, *) ' f_cdrag_ter = ', f_cdrag_ter
     2829    WRITE(lunout, *) ' f_cdrag_oce = ', f_cdrag_oce
     2830    WRITE(lunout, *) ' f_rugoro = ', f_rugoro
     2831    WRITE(lunout, *) ' z0min = ', z0min
     2832    WRITE(lunout, *) ' supcrit1 = ', supcrit1
     2833    WRITE(lunout, *) ' supcrit2 = ', supcrit2
     2834    WRITE(lunout, *) ' iflag_mix = ', iflag_mix
     2835    WRITE(lunout, *) ' iflag_mix_adiab = ', iflag_mix_adiab
     2836    WRITE(lunout, *) ' scut = ', scut
     2837    WRITE(lunout, *) ' qqa1 = ', qqa1
     2838    WRITE(lunout, *) ' qqa2 = ', qqa2
     2839    WRITE(lunout, *) ' gammas = ', gammas
     2840    WRITE(lunout, *) ' Fmax = ', Fmax
     2841    WRITE(lunout, *) ' tmax_fonte_cv = ', tmax_fonte_cv
     2842    WRITE(lunout, *) ' alphas = ', alphas
     2843    WRITE(lunout, *) ' iflag_wake = ', iflag_wake
     2844    WRITE(lunout, *) ' alp_offset = ', alp_offset
    28532845    ! nrlmd le 10/04/2012
    2854     WRITE(lunout,*) ' iflag_trig_bl = ', iflag_trig_bl
    2855     WRITE(lunout,*) ' iflag_strig = ', iflag_strig
    2856     WRITE(lunout,*) ' s_trig = ', s_trig
    2857     WRITE(lunout,*) ' h_trig = ', h_trig
    2858     WRITE(lunout,*) ' tau_trig_shallow = ', tau_trig_shallow
    2859     WRITE(lunout,*) ' tau_trig_deep = ', tau_trig_deep
    2860     WRITE(lunout,*) ' iflag_clos_bl = ', iflag_clos_bl
     2846    WRITE(lunout, *) ' iflag_trig_bl = ', iflag_trig_bl
     2847    WRITE(lunout, *) ' iflag_strig = ', iflag_strig
     2848    WRITE(lunout, *) ' s_trig = ', s_trig
     2849    WRITE(lunout, *) ' h_trig = ', h_trig
     2850    WRITE(lunout, *) ' tau_trig_shallow = ', tau_trig_shallow
     2851    WRITE(lunout, *) ' tau_trig_deep = ', tau_trig_deep
     2852    WRITE(lunout, *) ' iflag_clos_bl = ', iflag_clos_bl
    28612853    ! fin nrlmd le 10/04/2012
    28622854
    2863     WRITE(lunout,*) ' lonmin lonmax latmin latmax bilKP_ins =',&
    2864          lonmin_ins, lonmax_ins, latmin_ins, latmax_ins
    2865     WRITE(lunout,*) ' ecrit_ hf, ins, day, mth, reg, tra, ISCCP, LES',&
    2866          ecrit_hf, ecrit_ins, ecrit_day, ecrit_mth, ecrit_reg, ecrit_tra, ecrit_ISCCP, ecrit_LES
    2867 
    2868     WRITE(lunout,*) ' ok_strato = ', ok_strato
    2869     WRITE(lunout,*) ' ok_hines = ', ok_hines
    2870     WRITE(lunout,*) ' ok_gwd_rando = ', ok_gwd_rando
    2871     WRITE(lunout,*) ' ok_qch4 = ', ok_qch4
    2872     WRITE(lunout,*) ' gwd_rando_ruwmax = ', gwd_rando_ruwmax
    2873     WRITE(lunout,*) ' gwd_rando_sat = ', gwd_rando_sat
    2874     WRITE(lunout,*) ' gwd_front_ruwmax = ', gwd_front_ruwmax
    2875     WRITE(lunout,*) ' gwd_front_sat = ', gwd_front_sat
    2876     WRITE(lunout,*) ' SSO gkdrag =',gkdrag
    2877     WRITE(lunout,*) ' SSO grahilo=',grahilo
    2878     WRITE(lunout,*) ' SSO grcrit=',grcrit
    2879     WRITE(lunout,*) ' SSO gfrcrit=',gfrcrit
    2880     WRITE(lunout,*) ' SSO gkwake=',gkwake
    2881     WRITE(lunout,*) ' SSO gklift=',gklift
    2882     WRITE(lunout,*) ' adjust_tropopause = ', adjust_tropopause
    2883     WRITE(lunout,*) ' ok_daily_climoz = ',ok_daily_climoz
    2884     WRITE(lunout,*) ' ok_new_lscp = ', ok_new_lscp
    2885     WRITE(lunout,*) ' ok_icefra_lscp = ', ok_icefra_lscp
    2886     WRITE(lunout,*) ' read_climoz = ', read_climoz
    2887     WRITE(lunout,*) ' carbon_cycle_tr = ', carbon_cycle_tr
    2888     WRITE(lunout,*) ' carbon_cycle_cpl = ', carbon_cycle_cpl
    2889     WRITE(lunout,*) ' carbon_cycle_rad = ', carbon_cycle_rad
    2890     WRITE(lunout,*) ' level_coupling_esm = ', level_coupling_esm
    2891     WRITE(lunout,*) ' read_fco2_ocean_cor = ', read_fco2_ocean_cor
    2892     WRITE(lunout,*) ' var_fco2_ocean_cor = ', var_fco2_ocean_cor
    2893     WRITE(lunout,*) ' read_fco2_land_cor = ', read_fco2_land_cor
    2894     WRITE(lunout,*) ' var_fco2_land_cor = ', var_fco2_land_cor
    2895     WRITE(lunout,*) ' dms_cycle_cpl = ', dms_cycle_cpl
    2896     WRITE(lunout,*) ' n2o_cycle_cpl = ', n2o_cycle_cpl
    2897     WRITE(lunout,*) ' iflag_tsurf_inlandsis = ', iflag_tsurf_inlandsis
    2898     WRITE(lunout,*) ' iflag_temp_inlandsis = ', iflag_temp_inlandsis
    2899     WRITE(lunout,*) ' iflag_albcalc = ', iflag_albcalc
    2900     WRITE(lunout,*) ' SnoMod = ', SnoMod
    2901     WRITE(lunout,*) ' BloMod = ', BloMod
    2902     WRITE(lunout,*) ' ok_outfor = ', ok_outfor
    2903     WRITE(lunout,*) ' is_ok_slush = ', is_ok_slush
    2904     WRITE(lunout,*) ' opt_runoff_ac = ', opt_runoff_ac
    2905     WRITE(lunout,*) ' is_ok_z0h_rn = ', is_ok_z0h_rn
    2906     WRITE(lunout,*) ' is_ok_density_kotlyakov = ', is_ok_density_kotlyakov
    2907     WRITE(lunout,*) ' prescribed_z0m_snow = ', prescribed_z0m_snow
    2908     WRITE(lunout,*) ' iflag_z0m_snow = ', iflag_z0m_snow
    2909     WRITE(lunout,*) ' ok_zsn_ii = ', ok_zsn_ii
    2910     WRITE(lunout,*) ' discret_xf = ', discret_xf
    2911     WRITE(lunout,*) ' correc_alb= ', correc_alb
    2912     WRITE(lunout,*) ' buf_sph_pol = ', buf_sph_pol
    2913     WRITE(lunout,*) ' buf_siz_pol= ', buf_siz_pol
     2855    WRITE(lunout, *) ' lonmin lonmax latmin latmax bilKP_ins =', &
     2856            lonmin_ins, lonmax_ins, latmin_ins, latmax_ins
     2857    WRITE(lunout, *) ' ecrit_ hf, ins, day, mth, reg, tra, ISCCP, LES', &
     2858            ecrit_hf, ecrit_ins, ecrit_day, ecrit_mth, ecrit_reg, ecrit_tra, ecrit_ISCCP, ecrit_LES
     2859
     2860    WRITE(lunout, *) ' ok_strato = ', ok_strato
     2861    WRITE(lunout, *) ' ok_hines = ', ok_hines
     2862    WRITE(lunout, *) ' ok_gwd_rando = ', ok_gwd_rando
     2863    WRITE(lunout, *) ' ok_qch4 = ', ok_qch4
     2864    WRITE(lunout, *) ' gwd_rando_ruwmax = ', gwd_rando_ruwmax
     2865    WRITE(lunout, *) ' gwd_rando_sat = ', gwd_rando_sat
     2866    WRITE(lunout, *) ' gwd_front_ruwmax = ', gwd_front_ruwmax
     2867    WRITE(lunout, *) ' gwd_front_sat = ', gwd_front_sat
     2868    WRITE(lunout, *) ' SSO gkdrag =', gkdrag
     2869    WRITE(lunout, *) ' SSO grahilo=', grahilo
     2870    WRITE(lunout, *) ' SSO grcrit=', grcrit
     2871    WRITE(lunout, *) ' SSO gfrcrit=', gfrcrit
     2872    WRITE(lunout, *) ' SSO gkwake=', gkwake
     2873    WRITE(lunout, *) ' SSO gklift=', gklift
     2874    WRITE(lunout, *) ' adjust_tropopause = ', adjust_tropopause
     2875    WRITE(lunout, *) ' ok_daily_climoz = ', ok_daily_climoz
     2876    WRITE(lunout, *) ' ok_new_lscp = ', ok_new_lscp
     2877    WRITE(lunout, *) ' ok_icefra_lscp = ', ok_icefra_lscp
     2878    WRITE(lunout, *) ' read_climoz = ', read_climoz
     2879    WRITE(lunout, *) ' carbon_cycle_tr = ', carbon_cycle_tr
     2880    WRITE(lunout, *) ' carbon_cycle_cpl = ', carbon_cycle_cpl
     2881    WRITE(lunout, *) ' carbon_cycle_rad = ', carbon_cycle_rad
     2882    WRITE(lunout, *) ' level_coupling_esm = ', level_coupling_esm
     2883    WRITE(lunout, *) ' read_fco2_ocean_cor = ', read_fco2_ocean_cor
     2884    WRITE(lunout, *) ' var_fco2_ocean_cor = ', var_fco2_ocean_cor
     2885    WRITE(lunout, *) ' read_fco2_land_cor = ', read_fco2_land_cor
     2886    WRITE(lunout, *) ' var_fco2_land_cor = ', var_fco2_land_cor
     2887    WRITE(lunout, *) ' dms_cycle_cpl = ', dms_cycle_cpl
     2888    WRITE(lunout, *) ' n2o_cycle_cpl = ', n2o_cycle_cpl
     2889    WRITE(lunout, *) ' iflag_tsurf_inlandsis = ', iflag_tsurf_inlandsis
     2890    WRITE(lunout, *) ' iflag_temp_inlandsis = ', iflag_temp_inlandsis
     2891    WRITE(lunout, *) ' iflag_albcalc = ', iflag_albcalc
     2892    WRITE(lunout, *) ' SnoMod = ', SnoMod
     2893    WRITE(lunout, *) ' BloMod = ', BloMod
     2894    WRITE(lunout, *) ' ok_outfor = ', ok_outfor
     2895    WRITE(lunout, *) ' is_ok_slush = ', is_ok_slush
     2896    WRITE(lunout, *) ' opt_runoff_ac = ', opt_runoff_ac
     2897    WRITE(lunout, *) ' is_ok_z0h_rn = ', is_ok_z0h_rn
     2898    WRITE(lunout, *) ' is_ok_density_kotlyakov = ', is_ok_density_kotlyakov
     2899    WRITE(lunout, *) ' prescribed_z0m_snow = ', prescribed_z0m_snow
     2900    WRITE(lunout, *) ' iflag_z0m_snow = ', iflag_z0m_snow
     2901    WRITE(lunout, *) ' ok_zsn_ii = ', ok_zsn_ii
     2902    WRITE(lunout, *) ' discret_xf = ', discret_xf
     2903    WRITE(lunout, *) ' correc_alb= ', correc_alb
     2904    WRITE(lunout, *) ' buf_sph_pol = ', buf_sph_pol
     2905    WRITE(lunout, *) ' buf_siz_pol= ', buf_siz_pol
    29142906    !rajout Olivier Torres
    2915     write(lunout,*) 'choix_bulk = ', choix_bulk
    2916     write(lunout,*) 'nit_bulk = ', nit_bulk
    2917     write(lunout,*) 'kz0 = ', kz0
     2907    write(lunout, *) 'choix_bulk = ', choix_bulk
     2908    write(lunout, *) 'nit_bulk = ', nit_bulk
     2909    write(lunout, *) 'kz0 = ', kz0
    29182910
    29192911    !$OMP END MASTER
     
    29302922
    29312923  USE IOIPSL
    2932   USE print_control_mod, ONLY: lunout
     2924  USE print_control_mod, ONLY : lunout
    29332925  IMPLICIT NONE
    29342926  ! Configuration de l'interace atm/surf
     
    29362928  ! tau_calv:    temps de relaxation pour la fonte des glaciers
    29372929  !
    2938   REAL          :: tau_calv
    2939   REAL, SAVE    :: tau_calv_omp
     2930  REAL :: tau_calv
     2931  REAL, SAVE :: tau_calv_omp
    29402932  !
    29412933  !Config Key  = tau_calv
     
    29442936  !Config Help =
    29452937  !
    2946   tau_calv_omp = 360.*10.
     2938  tau_calv_omp = 360. * 10.
    29472939  !$OMP MASTER
    2948   CALL getin('tau_calv',tau_calv_omp)
     2940  CALL getin('tau_calv', tau_calv_omp)
    29492941  !$OMP END MASTER
    29502942  !$OMP BARRIER
    29512943  !
    2952   tau_calv=tau_calv_omp
     2944  tau_calv = tau_calv_omp
    29532945  !
    29542946  !$OMP MASTER
    2955   WRITE(lunout,*)' ##############################################'
    2956   WRITE(lunout,*)' Configuration de l''interface atm/surfaces  : '
    2957   WRITE(lunout,*)' tau_calv = ',tau_calv
     2947  WRITE(lunout, *)' ##############################################'
     2948  WRITE(lunout, *)' Configuration de l''interface atm/surfaces  : '
     2949  WRITE(lunout, *)' tau_calv = ', tau_calv
    29582950  !$OMP END MASTER
    29592951  !
  • LMDZ6/branches/Amaury_dev/libf/phylmd/hgardfou.F90

    r2399 r5098  
    4141      zt(i) = t(i, k)
    4242    END DO
    43 #ifdef CRAY
    44     CALL whenfgt(klon, zt, 1, 370.0, jadrs, jbad)
    45 #else
    4643    jbad = 0
    4744    DO i = 1, klon
     
    5148      END IF
    5249    END DO
    53 #endif
    5450    IF (jbad>0) THEN
    5551      ok = .FALSE.
     
    6056      END DO
    6157    END IF
    62 #ifdef CRAY
    63     CALL whenflt(klon, zt, 1, 100.0, jadrs, jbad)
    64 #else
    6558    jbad = 0
    6659    DO i = 1, klon
     
    7164      END IF
    7265    END DO
    73 #endif
    7466    IF (jbad>0) THEN
    7567      ok = .FALSE.
     
    8678      zt(i) = tsol(i, nsrf)
    8779    END DO
    88 #ifdef CRAY
    89     CALL whenfgt(klon, zt, 1, 370.0, jadrs, jbad)
    90 #else
    9180    jbad = 0
    9281    DO i = 1, klon
     
    9685      END IF
    9786    END DO
    98 #endif
    9987    IF (jbad>0) THEN
    10088      ok = .FALSE.
     
    10694      END DO
    10795    END IF
    108 #ifdef CRAY
    109     CALL whenflt(klon, zt, 1, 100.0, jadrs, jbad)
    110 #else
    11196    jbad = 0
    11297    DO i = 1, klon
     
    117102      END IF
    118103    END DO
    119 #endif
    120104    IF (jbad>0) THEN
    121105      ok = .FALSE.
  • LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90

    r5091 r5098  
    33MODULE infotrac_phy
    44
    5    USE       strings_mod, ONLY: msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse, strIdx
    6    USE readTracFiles_mod, ONLY: trac_type, readTracersFiles, tracers, setGeneration, itZonIso, nzone, tran0, isoZone, &
    7         delPhase, niso, getKey, isot_type, processIsotopes,  isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
    8         addPhase, iH2O, addKey, isoSelect, testTracersFiles, isoKeys, indexUpdate,  iqWIsoPha, nbIso, ntiso, isoName, isoCheck
    9    IMPLICIT NONE
    10 
    11    PRIVATE
    12 
    13    !=== FOR TRACERS:
    14    PUBLIC :: init_infotrac_phy                             !--- Initialization of the tracers
    15    PUBLIC :: tracers, type_trac                            !--- Full tracers database, tracers type keyword
    16    PUBLIC :: nqtot,   nbtr,   nqo,   nqCO2,   nqtottr      !--- Main dimensions
    17    PUBLIC :: conv_flg, pbl_flg                             !--- Convection & boundary layer activation keys
    18 #ifdef CPP_StratAer
    19    PUBLIC :: nbtr_bin, nbtr_sulgas                         !--- Number of aerosols bins and sulfur gases for StratAer model
    20    PUBLIC :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
    21 #endif
    22 
    23    !=== FOR WATER
    24    PUBLIC :: ivap, iliq, isol
    25    !=== FOR ISOTOPES: General
    26    PUBLIC :: isot_type, nbIso                              !--- Derived type, full isotopes families database + nb of families
    27    PUBLIC :: isoSelect, ixIso                              !--- Isotopes family selection tool + selected family index
    28    !=== FOR ISOTOPES: Specific to water
    29    PUBLIC :: iH2O                                          !--- H2O isotopes class index
    30    !=== FOR ISOTOPES: Depending on the selected isotopes family
    31    PUBLIC :: isotope, isoKeys                              !--- Selected isotopes database + associated keys (cf. getKey)
    32    PUBLIC :: isoName, isoZone, isoPhas                     !--- Isotopes and tagging zones names, phases
    33    PUBLIC :: niso,    nzone,   nphas,   ntiso              !---  " " numbers + isotopes & tagging tracers number
    34    PUBLIC :: itZonIso                                      !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
    35    PUBLIC :: iqIsoPha                                      !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
    36    PUBLIC :: iqWIsoPha                                      !--- Same as iqIsoPha but with normal water phases
    37 
    38    PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
    39    !=== FOR BOTH TRACERS AND ISOTOPES
    40    PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
    41 
    42 !=== CONVENTIONS FOR TRACERS NUMBERS:
    43 !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
    44 !  | water in different |    water tagging      |  water isotopes | other tracers | additional tracers moments |
    45 !  | phases: H2O_[gls]  |      isotopes         |                 |               |  for higher order schemes  |
    46 !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
    47 !  |                    |                       |                 |               |                            |
    48 !  |<--     nqo      -->|<-- nqo*niso* nzone -->|<-- nqo*niso  -->|<--  nbtr   -->|<--        (nmom)        -->|         
    49 !  |                    |                                         |                                            |
    50 !  |                    |<-- nqo*niso*(nzone+1)  =   nqo*ntiso -->|<--    nqtottr = nbtr + nmom             -->|
    51 !  |                                                                              = nqtot - nqo*(ntiso+1)      |
    52 !  |                                                                                                           |
    53 !  |<--                        nqtrue  =  nbtr + nqo*(ntiso+1)                 -->|                            |
    54 !  |                                                                                                           |
    55 !  |<--                        nqtot   =  nqtrue + nmom                                                     -->|
    56 !  |                                                                                                           |
    57 !  |-----------------------------------------------------------------------------------------------------------|
    58 !  NOTES FOR THIS TABLE:
    59 !  * Used "niso", "nzone" and "ntiso" are components of "isotopes(ip)" for water (isotopes(ip)%parent == 'H2O'),
    60 !    since water is so far the sole tracers family, except passive CO2, removed from the main tracers table.
    61 !  * For water, "nqo" is equal to the more general field "isotopes(ip)%nphas".
    62 !  * "niso", "nzone", "ntiso", "nphas" are defined for other isotopic tracers families, if any.
    63 !
    64 !=== DERIVED TYPE EMBEDDING MOST OF THE TRACERS-RELATED QUANTITIES (LENGTH: nqtot)
    65 !    Each entry is accessible using "%" sign.
    66 !  |-------------+------------------------------------------------------+-------------+------------------------+
    67 !  |  entry      | Meaning                                              | Former name | Possible values        |
    68 !  |-------------+------------------------------------------------------+-------------+------------------------+
    69 !  | name        | Name (short)                                         | tname       |                        |
    70 !  | gen0Name    | Name of the 1st generation ancestor                  | /           |                        |
    71 !  | parent      | Name of the parent                                   | /           |                        |
    72 !  | longName    | Long name (with adv. scheme suffix) for outputs      | ttext       |                        |
    73 !  | type        | Type (so far: tracer or tag)                         | /           | tracer,tag             |
    74 !  | phase       | Phases list ("g"as / "l"iquid / "s"olid)             | /           | [g][l][s]              |
    75 !  | component   | Name(s) of the merged/cumulated section(s)           | /           | coma-separated names   |
    76 !  | iGeneration | Generation (>=1)                                     | /           |                        |
    77 !  | iqParent    | Index of the parent tracer                           | iqpere      | 1:nqtot                |
    78 !  | iqDescen    | Indexes of the childs       (all generations)        | iqfils      | 1:nqtot                |
    79 !  | nqDescen    | Number of the descendants   (all generations)        | nqdesc      | 1:nqtot                |
    80 !  | nqChildren  | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
    81 !  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
    82 !  | isAdvected  | advected tracers flag (.TRUE. if iadv >= 0)          | /           | nqtrue  .TRUE. values  |
    83 !  | isInPhysics | tracers not extracted from the main table in physics | /           | nqtottr .TRUE. values  |
    84 !  | iso_iGroup  | Isotopes group index in isotopes(:)                  | /           | 1:nbIso                |
    85 !  | iso_iName   | Isotope  name  index in isotopes(iso_iGroup)%trac(:) | iso_indnum  | 1:niso                 |
    86 !  | iso_iZone   | Isotope  zone  index in isotopes(iso_iGroup)%zone(:) | zone_num    | 1:nzone                |
    87 !  | iso_iPhas   | Isotope  phase index in isotopes(iso_iGroup)%phas(:) | phase_num   | 1:nphas                |
    88 !  +-------------+------------------------------------------------------+-------------+------------------------+
    89 !
    90 !=== DERIVED TYPE EMBEDDING MOST OF THE ISOTOPES-RELATED QUANTITIES (LENGTH: nbIso, NUMBER OF ISOTOPES FAMILIES)
    91 !    Each entry is accessible using "%" sign.
    92 !  |-----------------+--------------------------------------------------+--------------------+-----------------+
    93 !  |  entry | length | Meaning                                          |    Former name     | Possible values |
    94 !  |-----------------+--------------------------------------------------+--------------------+-----------------+
    95 !  | parent          | Parent tracer (isotopes family name)             |                    |                 |
    96 !  | keys   | niso   | Isotopes keys/values pairs list + number         |                    |                 |
    97 !  | trac   | ntiso  | Isotopes + tagging tracers list + number         | / | ntraciso       |                 |
    98 !  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
    99 !  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
    100 !  | iqIsoPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
    101 !  | iqWIsoPha       | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
    102 !  | itZonIso        | Index in "trac(1:ntiso)"= f(zone, name(1:niso))  | index_trac         | 1:ntiso         |
    103 !  +-----------------+--------------------------------------------------+--------------------+-----------------+
    104 
    105    !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES
    106    INTEGER,               SAVE :: nqtot,  &                     !--- Tracers nb in dynamics (incl. higher moments + H2O)
    107                                   nbtr,   &                     !--- Tracers nb in physics  (excl. higher moments + H2O)
    108                                   nqo,    &                     !--- Number of water phases
    109                                   nqtottr, &                    !--- Number of tracers passed to phytrac (TO BE DELETED ?)
    110                                   nqCO2                         !--- Number of tracers of CO2  (ThL)
    111    CHARACTER(LEN=maxlen), SAVE :: type_trac                     !--- Keyword for tracers type(s)
    112 !$OMP THREADPRIVATE(nqtot, nbtr, nqo, nqtottr, nqCO2, type_trac)
    113 
    114    !=== INDICES OF WATER
    115    INTEGER,               SAVE :: ivap,iliq,isol ! Indices for vap, liq and ice
    116 !$OMP THREADPRIVATE(ivap,iliq,isol)
    117 
    118    !=== VARIABLES FOR INCA
    119    INTEGER,               SAVE, ALLOCATABLE :: conv_flg(:), &   !--- Convection     activation ; needed for INCA        (nbtr)
    120                                                 pbl_flg(:)      !--- Boundary layer activation ; needed for INCA        (nbtr)
    121 !$OMP THREADPRIVATE(conv_flg, pbl_flg)
    122 
    123 #ifdef CPP_StratAer
     5  USE       strings_mod, ONLY : msg, fmsg, maxlen, cat, dispTable, int2str, bool2str, strStack, strParse, strIdx
     6  USE readTracFiles_mod, ONLY : trac_type, readTracersFiles, tracers, setGeneration, itZonIso, nzone, tran0, isoZone, &
     7          delPhase, niso, getKey, isot_type, processIsotopes, isotope, maxTableWidth, iqIsoPha, nphas, ixIso, isoPhas, &
     8          addPhase, iH2O, addKey, isoSelect, testTracersFiles, isoKeys, indexUpdate, iqWIsoPha, nbIso, ntiso, isoName, isoCheck
     9  IMPLICIT NONE
     10
     11  PRIVATE
     12
     13  !=== FOR TRACERS:
     14  PUBLIC :: init_infotrac_phy                             !--- Initialization of the tracers
     15  PUBLIC :: tracers, type_trac                            !--- Full tracers database, tracers type keyword
     16  PUBLIC :: nqtot, nbtr, nqo, nqCO2, nqtottr      !--- Main dimensions
     17  PUBLIC :: conv_flg, pbl_flg                             !--- Convection & boundary layer activation keys
     18  PUBLIC :: nbtr_bin, nbtr_sulgas                         !--- Number of aerosols bins and sulfur gases for StratAer model
     19  PUBLIC :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
     20
     21  !=== FOR WATER
     22  PUBLIC :: ivap, iliq, isol
     23  !=== FOR ISOTOPES: General
     24  PUBLIC :: isot_type, nbIso                              !--- Derived type, full isotopes families database + nb of families
     25  PUBLIC :: isoSelect, ixIso                              !--- Isotopes family selection tool + selected family index
     26  !=== FOR ISOTOPES: Specific to water
     27  PUBLIC :: iH2O                                          !--- H2O isotopes class index
     28  !=== FOR ISOTOPES: Depending on the selected isotopes family
     29  PUBLIC :: isotope, isoKeys                              !--- Selected isotopes database + associated keys (cf. getKey)
     30  PUBLIC :: isoName, isoZone, isoPhas                     !--- Isotopes and tagging zones names, phases
     31  PUBLIC :: niso, nzone, nphas, ntiso              !---  " " numbers + isotopes & tagging tracers number
     32  PUBLIC :: itZonIso                                      !--- idx "it" (in "isoName(1:niso)") = function(tagging idx, isotope idx)
     33  PUBLIC :: iqIsoPha                                      !--- idx "iq" (in "qx") = function(isotope idx, phase idx) + aliases
     34  PUBLIC :: iqWIsoPha                                      !--- Same as iqIsoPha but with normal water phases
     35
     36  PUBLIC :: isoCheck                                      !--- Run isotopes checking routines
     37  !=== FOR BOTH TRACERS AND ISOTOPES
     38  PUBLIC :: getKey                                        !--- Get a key from "tracers" or "isotope"
     39
     40  !=== CONVENTIONS FOR TRACERS NUMBERS:
     41  !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
     42  !  | water in different |    water tagging      |  water isotopes | other tracers | additional tracers moments |
     43  !  | phases: H2O_[gls]  |      isotopes         |                 |               |  for higher order schemes  |
     44  !  |--------------------+-----------------------+-----------------+---------------+----------------------------|
     45  !  |                    |                       |                 |               |                            |
     46  !  |<--     nqo      -->|<-- nqo*niso* nzone -->|<-- nqo*niso  -->|<--  nbtr   -->|<--        (nmom)        -->|
     47  !  |                    |                                         |                                            |
     48  !  |                    |<-- nqo*niso*(nzone+1)  =   nqo*ntiso -->|<--    nqtottr = nbtr + nmom             -->|
     49  !  |                                                                              = nqtot - nqo*(ntiso+1)      |
     50  !  |                                                                                                           |
     51  !  |<--                        nqtrue  =  nbtr + nqo*(ntiso+1)                 -->|                            |
     52  !  |                                                                                                           |
     53  !  |<--                        nqtot   =  nqtrue + nmom                                                     -->|
     54  !  |                                                                                                           |
     55  !  |-----------------------------------------------------------------------------------------------------------|
     56  !  NOTES FOR THIS TABLE:
     57  !  * Used "niso", "nzone" and "ntiso" are components of "isotopes(ip)" for water (isotopes(ip)%parent == 'H2O'),
     58  !    since water is so far the sole tracers family, except passive CO2, removed from the main tracers table.
     59  !  * For water, "nqo" is equal to the more general field "isotopes(ip)%nphas".
     60  !  * "niso", "nzone", "ntiso", "nphas" are defined for other isotopic tracers families, if any.
     61  !
     62  !=== DERIVED TYPE EMBEDDING MOST OF THE TRACERS-RELATED QUANTITIES (LENGTH: nqtot)
     63  !    Each entry is accessible using "%" sign.
     64  !  |-------------+------------------------------------------------------+-------------+------------------------+
     65  !  |  entry      | Meaning                                              | Former name | Possible values        |
     66  !  |-------------+------------------------------------------------------+-------------+------------------------+
     67  !  | name        | Name (short)                                         | tname       |                        |
     68  !  | gen0Name    | Name of the 1st generation ancestor                  | /           |                        |
     69  !  | parent      | Name of the parent                                   | /           |                        |
     70  !  | longName    | Long name (with adv. scheme suffix) for outputs      | ttext       |                        |
     71  !  | type        | Type (so far: tracer or tag)                         | /           | tracer,tag             |
     72  !  | phase       | Phases list ("g"as / "l"iquid / "s"olid)             | /           | [g][l][s]              |
     73  !  | component   | Name(s) of the merged/cumulated section(s)           | /           | coma-separated names   |
     74  !  | iGeneration | Generation (>=1)                                     | /           |                        |
     75  !  | iqParent    | Index of the parent tracer                           | iqpere      | 1:nqtot                |
     76  !  | iqDescen    | Indexes of the childs       (all generations)        | iqfils      | 1:nqtot                |
     77  !  | nqDescen    | Number of the descendants   (all generations)        | nqdesc      | 1:nqtot                |
     78  !  | nqChildren  | Number of childs            (1st generation only)    | nqfils      | 1:nqtot                |
     79  !  | keys        | key/val pairs accessible with "getKey" routine       | /           |                        |
     80  !  | isAdvected  | advected tracers flag (.TRUE. if iadv >= 0)          | /           | nqtrue  .TRUE. values  |
     81  !  | isInPhysics | tracers not extracted from the main table in physics | /           | nqtottr .TRUE. values  |
     82  !  | iso_iGroup  | Isotopes group index in isotopes(:)                  | /           | 1:nbIso                |
     83  !  | iso_iName   | Isotope  name  index in isotopes(iso_iGroup)%trac(:) | iso_indnum  | 1:niso                 |
     84  !  | iso_iZone   | Isotope  zone  index in isotopes(iso_iGroup)%zone(:) | zone_num    | 1:nzone                |
     85  !  | iso_iPhas   | Isotope  phase index in isotopes(iso_iGroup)%phas(:) | phase_num   | 1:nphas                |
     86  !  +-------------+------------------------------------------------------+-------------+------------------------+
     87  !
     88  !=== DERIVED TYPE EMBEDDING MOST OF THE ISOTOPES-RELATED QUANTITIES (LENGTH: nbIso, NUMBER OF ISOTOPES FAMILIES)
     89  !    Each entry is accessible using "%" sign.
     90  !  |-----------------+--------------------------------------------------+--------------------+-----------------+
     91  !  |  entry | length | Meaning                                          |    Former name     | Possible values |
     92  !  |-----------------+--------------------------------------------------+--------------------+-----------------+
     93  !  | parent          | Parent tracer (isotopes family name)             |                    |                 |
     94  !  | keys   | niso   | Isotopes keys/values pairs list + number         |                    |                 |
     95  !  | trac   | ntiso  | Isotopes + tagging tracers list + number         | / | ntraciso       |                 |
     96  !  | zone   | nzone  | Geographic tagging zones   list + number         | / | ntraceurs_zone |                 |
     97  !  | phase  | nphas  | Phases                     list + number         |                    | [g][l][s], 1:3  |
     98  !  | iqIsoPha        | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
     99  !  | iqWIsoPha       | Index in "qx"           = f(name(1:ntiso)),phas) | iqiso              | 1:nqtot         |
     100  !  | itZonIso        | Index in "trac(1:ntiso)"= f(zone, name(1:niso))  | index_trac         | 1:ntiso         |
     101  !  +-----------------+--------------------------------------------------+--------------------+-----------------+
     102
     103  !=== DIMENSIONS OF THE TRACERS TABLES AND OTHER SCALAR VARIABLES
     104  INTEGER, SAVE :: nqtot, &                     !--- Tracers nb in dynamics (incl. higher moments + H2O)
     105          nbtr, &                     !--- Tracers nb in physics  (excl. higher moments + H2O)
     106          nqo, &                     !--- Number of water phases
     107          nqtottr, &                    !--- Number of tracers passed to phytrac (TO BE DELETED ?)
     108          nqCO2                         !--- Number of tracers of CO2  (ThL)
     109  CHARACTER(LEN = maxlen), SAVE :: type_trac                     !--- Keyword for tracers type(s)
     110  !$OMP THREADPRIVATE(nqtot, nbtr, nqo, nqtottr, nqCO2, type_trac)
     111
     112  !=== INDICES OF WATER
     113  INTEGER, SAVE :: ivap, iliq, isol ! Indices for vap, liq and ice
     114  !$OMP THREADPRIVATE(ivap,iliq,isol)
     115
     116  !=== VARIABLES FOR INCA
     117  INTEGER, SAVE, ALLOCATABLE :: conv_flg(:), &   !--- Convection     activation ; needed for INCA        (nbtr)
     118          pbl_flg(:)      !--- Boundary layer activation ; needed for INCA        (nbtr)
     119  !$OMP THREADPRIVATE(conv_flg, pbl_flg)
     120
    124121  !=== SPECIFIC TO STRATOSPHERIC AEROSOLS (CK/OB)
    125   INTEGER, SAVE ::  nbtr_bin, nbtr_sulgas         !--- number of aerosols bins and sulfur gases for StratAer model
    126 !$OMP THREADPRIVATE(nbtr_bin, nbtr_sulgas)
    127   INTEGER, SAVE ::  id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
    128 !$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat)
    129 #endif
     122  INTEGER, SAVE :: nbtr_bin, nbtr_sulgas         !--- number of aerosols bins and sulfur gases for StratAer model
     123  !$OMP THREADPRIVATE(nbtr_bin, nbtr_sulgas)
     124  INTEGER, SAVE :: id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat
     125  !$OMP THREADPRIVATE(id_OCS_strat, id_SO2_strat, id_H2SO4_strat, id_BIN01_strat, id_TEST_strat)
    130126
    131127CONTAINS
    132128
    133 SUBROUTINE init_infotrac_phy
    134    USE ioipsl_getin_p_mod, ONLY: getin_p
     129  SUBROUTINE init_infotrac_phy
     130    USE ioipsl_getin_p_mod, ONLY : getin_p
    135131#ifdef REPROBUS
    136132   USE CHEM_REP, ONLY: Init_chem_rep_trac
    137133#endif
    138    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    139    IMPLICIT NONE
    140 !==============================================================================================================================
    141 !
    142 !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
    143 !   -------
    144 !
    145 !   Modifications:
    146 !   --------------
    147 !   05/94: F.Forget      Modif special traceur
    148 !   02/02: M-A Filiberti Lecture de traceur.def
    149 !   01/22: D. Cugnet     Nouveaux tracer.def et tracer_*.def + encapsulation (types trac_type et isot_type)
    150 !
    151 !   Objet:
    152 !   ------
    153 !   GCM LMD nouvelle grille
    154 !
    155 !==============================================================================================================================
    156 !   ... modification de l'integration de q ( 26/04/94 ) ....
    157 !------------------------------------------------------------------------------------------------------------------------------
    158 ! Declarations:
    159    INCLUDE "dimensions.h"
    160    INCLUDE "iniprint.h"
    161 
    162 !------------------------------------------------------------------------------------------------------------------------------
    163 ! Local variables
    164    INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
    165    INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
    166                            vad (:), vadv_inca(:),  pbl_flg_inca(:)
    167    CHARACTER(LEN=8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
    168    INTEGER :: nqINCA
    169 #ifdef CPP_StratAer
    170    CHARACTER(LEN=maxlen), ALLOCATABLE :: tnames(:)
    171 #endif
    172    CHARACTER(LEN=2)      ::   suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
    173    CHARACTER(LEN=3)      :: descrq(30)                               !--- Advection scheme description tags
    174    CHARACTER(LEN=maxlen) :: msg1, texp, ttp                          !--- String for messages and expanded tracers type
    175    INTEGER :: fType                                                  !--- Tracers description file type ; 0: none
    176                                                                      !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def"
    177    INTEGER :: nqtrue                                                 !--- Tracers nb from tracer.def (no higher order moments)
    178    INTEGER :: iad                                                    !--- Advection scheme number
    179    INTEGER :: iq, jq, nt, im, nm, k                                 !--- Indexes and temporary variables
    180    LOGICAL :: lerr, lInit
    181    TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:)
    182    TYPE(trac_type), POINTER             :: t1, t(:)
    183    CHARACTER(LEN=maxlen),   ALLOCATABLE :: types_trac(:)  !--- Keyword for tracers type(s), parsed version
    184    
    185    CHARACTER(LEN=*), PARAMETER :: modname="init_infotrac_phy"
    186 !------------------------------------------------------------------------------------------------------------------------------
    187 ! Initialization :
    188 !------------------------------------------------------------------------------------------------------------------------------
    189    suff          = ['x ','y ','z ','xx','xy','xz','yy','yz','zz']
    190    descrq( 1:30) =  '   '
    191    descrq( 1: 2) = ['LMV','BAK']
    192    descrq(10:20) = ['VL1','VLP','FH1','FH2','VLH','   ','PPM','PPS','PPP','   ','SLP']
    193    descrq(30)    =  'PRA'
    194 
    195    CALL getin_p('type_trac',type_trac)
    196 
    197    lerr=strParse(type_trac, '|', types_trac, n=nt)
    198    IF (nt > 1) THEN
     134    USE lmdz_cppkeys_wrapper, ONLY : CPPKEY_INCA, CPPKEY_STRATAER
     135    IMPLICIT NONE
     136    !==============================================================================================================================
     137    !
     138    !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
     139    !   -------
     140    !
     141    !   Modifications:
     142    !   --------------
     143    !   05/94: F.Forget      Modif special traceur
     144    !   02/02: M-A Filiberti Lecture de traceur.def
     145    !   01/22: D. Cugnet     Nouveaux tracer.def et tracer_*.def + encapsulation (types trac_type et isot_type)
     146    !
     147    !   Objet:
     148    !   ------
     149    !   GCM LMD nouvelle grille
     150    !
     151    !==============================================================================================================================
     152    !   ... modification de l'integration de q ( 26/04/94 ) ....
     153    !------------------------------------------------------------------------------------------------------------------------------
     154    ! Declarations:
     155    INCLUDE "dimensions.h"
     156    INCLUDE "iniprint.h"
     157
     158    !------------------------------------------------------------------------------------------------------------------------------
     159    ! Local variables
     160    INTEGER, ALLOCATABLE :: hadv(:), vadv(:)                          !--- Horizontal/vertical transport scheme number
     161    INTEGER, ALLOCATABLE :: had (:), hadv_inca(:), conv_flg_inca(:), &!--- Variables specific to INCA
     162            vad (:), vadv_inca(:), pbl_flg_inca(:)
     163    CHARACTER(LEN = 8), ALLOCATABLE :: solsym_inca(:)                   !--- Tracers names for INCA
     164    INTEGER :: nqINCA
     165    CHARACTER(LEN = maxlen), ALLOCATABLE :: tnames(:)
     166    CHARACTER(LEN = 2) :: suff(9)                                !--- Suffixes for schemes of order 3 or 4 (Prather)
     167    CHARACTER(LEN = 3) :: descrq(30)                               !--- Advection scheme description tags
     168    CHARACTER(LEN = maxlen) :: msg1, texp, ttp                          !--- String for messages and expanded tracers type
     169    INTEGER :: fType                                                  !--- Tracers description file type ; 0: none
     170    !--- 1/2/3: "traceur.def"/"tracer.def"/"tracer_*.def"
     171    INTEGER :: nqtrue                                                 !--- Tracers nb from tracer.def (no higher order moments)
     172    INTEGER :: iad                                                    !--- Advection scheme number
     173    INTEGER :: iq, jq, nt, im, nm, k                                 !--- Indexes and temporary variables
     174    LOGICAL :: lerr, lInit
     175    TYPE(trac_type), ALLOCATABLE, TARGET :: ttr(:)
     176    TYPE(trac_type), POINTER :: t1, t(:)
     177    CHARACTER(LEN = maxlen), ALLOCATABLE :: types_trac(:)  !--- Keyword for tracers type(s), parsed version
     178
     179    CHARACTER(LEN = *), PARAMETER :: modname = "init_infotrac_phy"
     180    !------------------------------------------------------------------------------------------------------------------------------
     181    ! Initialization :
     182    !------------------------------------------------------------------------------------------------------------------------------
     183    suff = ['x ', 'y ', 'z ', 'xx', 'xy', 'xz', 'yy', 'yz', 'zz']
     184    descrq(1:30) = '   '
     185    descrq(1:2) = ['LMV', 'BAK']
     186    descrq(10:20) = ['VL1', 'VLP', 'FH1', 'FH2', 'VLH', '   ', 'PPM', 'PPS', 'PPP', '   ', 'SLP']
     187    descrq(30) = 'PRA'
     188
     189    CALL getin_p('type_trac', type_trac)
     190
     191    lerr = strParse(type_trac, '|', types_trac, n = nt)
     192    IF (nt > 1) THEN
    199193      IF (nt > 2) CALL abort_physic(modname, 'you need to modify type_trac, this version is not supported by lmdz', 1)
    200       IF (nt == 2) type_trac=types_trac(2)
    201    ENDIF
    202 
    203    
    204    CALL msg('type_trac = "'//TRIM(type_trac)//'"', modname)
    205    lInit = .NOT.ALLOCATED(tracers)
    206 
    207 !##############################################################################################################################
    208    IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
    209 !##############################################################################################################################
    210    !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
    211    msg1 = 'For type_trac = "'//TRIM(type_trac)//'":'
    212    SELECT CASE(type_trac)
    213       CASE('inca'); CALL msg(TRIM(msg1)//' coupling with INCA chemistry model',        modname)
    214       CASE('inco'); CALL msg(TRIM(msg1)//' coupling jointly with INCA and CO2 cycle',  modname)
    215       CASE('repr'); CALL msg(TRIM(msg1)//' coupling with REPROBUS chemistry model',    modname)
    216       CASE('co2i'); CALL msg(TRIM(msg1)//' you have chosen to run with CO2 cycle',     modname)
    217       CASE('coag'); CALL msg(TRIM(msg1)//' tracers are treated for COAGULATION tests', modname)
    218       CASE('lmdz'); CALL msg(TRIM(msg1)//' tracers are treated in LMDZ only',          modname)
    219       CASE DEFAULT; CALL abort_physic(modname,'type_trac='//TRIM(type_trac)//' not possible yet.',1)
    220    END SELECT
    221 
    222    !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
    223    SELECT CASE(type_trac)
     194      IF (nt == 2) type_trac = types_trac(2)
     195    ENDIF
     196
     197    CALL msg('type_trac = "' // TRIM(type_trac) // '"', modname)
     198    lInit = .NOT.ALLOCATED(tracers)
     199
     200    !##############################################################################################################################
     201    IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
     202      !##############################################################################################################################
     203      !--- MESSAGE ABOUT THE CHOSEN CONFIGURATION
     204      msg1 = 'For type_trac = "' // TRIM(type_trac) // '":'
     205      SELECT CASE(type_trac)
     206      CASE('inca'); CALL msg(TRIM(msg1) // ' coupling with INCA chemistry model', modname)
     207      CASE('inco'); CALL msg(TRIM(msg1) // ' coupling jointly with INCA and CO2 cycle', modname)
     208      CASE('repr'); CALL msg(TRIM(msg1) // ' coupling with REPROBUS chemistry model', modname)
     209      CASE('co2i'); CALL msg(TRIM(msg1) // ' you have chosen to run with CO2 cycle', modname)
     210      CASE('coag'); CALL msg(TRIM(msg1) // ' tracers are treated for COAGULATION tests', modname)
     211      CASE('lmdz'); CALL msg(TRIM(msg1) // ' tracers are treated in LMDZ only', modname)
     212      CASE DEFAULT; CALL abort_physic(modname, 'type_trac=' // TRIM(type_trac) // ' not possible yet.', 1)
     213      END SELECT
     214
     215      !--- COHERENCE TEST BETWEEN "type_trac" AND PREPROCESSING KEYS
     216      SELECT CASE(type_trac)
    224217      CASE('inca', 'inco')
    225    IF (CPPKEY_INCA) THEN
    226          CALL abort_physic(modname, 'You must add cpp key INCA and compile with INCA code', 1)
    227    END IF
     218        IF (CPPKEY_INCA) THEN
     219          CALL abort_physic(modname, 'You must add cpp key INCA and compile with INCA code', 1)
     220        END IF
    228221      CASE('repr')
    229222#ifndef REPROBUS
    230          CALL abort_physic(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
     223        CALL abort_physic(modname, 'You must add cpp key REPROBUS and compile with REPROBUS code', 1)
    231224#endif
    232225      CASE('coag')
    233 #ifndef CPP_StratAer
    234          CALL abort_physic(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
    235 #endif
    236    END SELECT
    237 !##############################################################################################################################
    238    END IF
    239 !##############################################################################################################################
    240 
    241    nqCO2 = COUNT( [type_trac == 'inco', type_trac == 'co2i'] )
    242 
    243 !==============================================================================================================================
    244 ! 1) Get the numbers of: true (first order only) tracers "nqtrue", water tracers "nqo" (vapor/liquid/solid)
    245 !==============================================================================================================================
    246    texp = type_trac                                                  !=== EXPANDED VERSION OF "type_trac", WITH "|" SEPARATOR
    247    IF(texp == 'inco') texp = 'co2i|inca'
    248    IF(texp /= 'lmdz') texp = 'lmdz|'//TRIM(texp)
    249 
    250    !=== DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE
    251    IF(testTracersFiles(modname, texp, fType, lInit)) CALL abort_physic(modname, 'problem with tracers file(s)',1)
    252 
    253    ttp = type_trac; IF(fType /= 1) ttp = texp
    254 
    255 !##############################################################################################################################
    256    IF(lInit) THEN
    257       IF(readTracersFiles(ttp, lRepr=type_trac=='repr')) CALL abort_physic(modname, 'problem with tracers file(s)',1)
    258    ELSE
     226        IF (.NOT. CPPKEY_STRATAER) THEN
     227          CALL abort_physic(modname, 'You must add cpp key StratAer and compile with StratAer code', 1)
     228        END IF
     229      END SELECT
     230      !##############################################################################################################################
     231    END IF
     232    !##############################################################################################################################
     233
     234    nqCO2 = COUNT([type_trac == 'inco', type_trac == 'co2i'])
     235
     236    !==============================================================================================================================
     237    ! 1) Get the numbers of: true (first order only) tracers "nqtrue", water tracers "nqo" (vapor/liquid/solid)
     238    !==============================================================================================================================
     239    texp = type_trac                                                  !=== EXPANDED VERSION OF "type_trac", WITH "|" SEPARATOR
     240    IF(texp == 'inco') texp = 'co2i|inca'
     241    IF(texp /= 'lmdz') texp = 'lmdz|' // TRIM(texp)
     242
     243    !=== DETERMINE THE TYPE OF THE INPUT TRACERS DESCRIPTION FILE
     244    IF(testTracersFiles(modname, texp, fType, lInit)) CALL abort_physic(modname, 'problem with tracers file(s)', 1)
     245
     246    ttp = type_trac; IF(fType /= 1) ttp = texp
     247
     248    !##############################################################################################################################
     249    IF(lInit) THEN
     250      IF(readTracersFiles(ttp, lRepr = type_trac=='repr')) CALL abort_physic(modname, 'problem with tracers file(s)', 1)
     251    ELSE
    259252      CALL msg('No tracers description file(s) reading needed: already done in the dynamics', modname)
    260    END IF
    261 !##############################################################################################################################
    262 
    263    !---------------------------------------------------------------------------------------------------------------------------
    264    IF(fType == 0) CALL abort_physic(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.',1)
    265    !---------------------------------------------------------------------------------------------------------------------------
    266    IF(fType == 1 .AND. ANY(['inca','inco']==type_trac) .AND. lInit) THEN  !=== FOUND OLD STYLE INCA "traceur.def"
    267    !---------------------------------------------------------------------------------------------------------------------------
    268    IF (CPPKEY_INCA) THEN
    269       nqo = SIZE(tracers) - nqCO2
    270       CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
    271       nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
    272       nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
    273       IF(ALL([2,3] /= nqo)) CALL abort_physic(modname, 'Only 2 or 3 water phases allowed ; found nqo='//TRIM(int2str(nqo)), 1)
    274       ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
    275       ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA), pbl_flg_inca(nqINCA))
    276       CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
    277       ALLOCATE(ttr(nqtrue))
    278       ttr(1:nqo+nqCO2)                  = tracers
    279       ttr(1    :      nqo   )%component = 'lmdz'
    280       ttr(1+nqo:nqCO2+nqo   )%component = 'co2i'
    281       ttr(1+nqo+nqCO2:nqtrue)%component = 'inca'
    282       ttr(1+nqo      :nqtrue)%name      = [('CO2     ', k=1, nqCO2), solsym_inca]
    283       ttr(1+nqo+nqCO2:nqtrue)%parent    = tran0
    284       ttr(1+nqo+nqCO2:nqtrue)%phase    = 'g'
    285       lerr = getKey('hadv', had, ky=tracers(:)%keys)
    286       lerr = getKey('vadv', vad, ky=tracers(:)%keys)
    287       hadv(1:nqo+nqCO2) = had(:); hadv(1+nqo+nqCO2:nqtrue) = hadv_inca
    288       vadv(1:nqo+nqCO2) = vad(:); vadv(1+nqo+nqCO2:nqtrue) = vadv_inca
    289       CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
    290       DO iq = 1, nqtrue
    291          t1 => tracers(iq)
    292          CALL addKey('name',      t1%name,      t1%keys)
    293          CALL addKey('component', t1%component, t1%keys)
    294          CALL addKey('parent',    t1%parent,    t1%keys)
    295          CALL addKey('phase',     t1%phase,    t1%keys)
    296       END DO
    297       IF(setGeneration(tracers)) CALL abort_physic(modname,'See below',1) !- SET FIELDS %iGeneration, %gen0Name
    298       DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
    299    END IF
    300    !---------------------------------------------------------------------------------------------------------------------------
    301    ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
    302    !---------------------------------------------------------------------------------------------------------------------------
    303       nqo    =        COUNT(delPhase(tracers(:)%name)     == 'H2O' &
    304                                .AND. tracers(:)%component == 'lmdz') !--- Number of water phases
     253    END IF
     254    !##############################################################################################################################
     255
     256    !---------------------------------------------------------------------------------------------------------------------------
     257    IF(fType == 0) CALL abort_physic(modname, 'Missing tracers file: "traceur.def", "tracer.def" or "tracer_<keyword>.def file.', 1)
     258    !---------------------------------------------------------------------------------------------------------------------------
     259    IF(fType == 1 .AND. ANY(['inca', 'inco']==type_trac) .AND. lInit) THEN  !=== FOUND OLD STYLE INCA "traceur.def"
     260      !---------------------------------------------------------------------------------------------------------------------------
     261      IF (CPPKEY_INCA) THEN
     262        nqo = SIZE(tracers) - nqCO2
     263        CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
     264        nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
     265        nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
     266        IF(ALL([2, 3] /= nqo)) CALL abort_physic(modname, 'Only 2 or 3 water phases allowed ; found nqo=' // TRIM(int2str(nqo)), 1)
     267        ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
     268        ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA), pbl_flg_inca(nqINCA))
     269        CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
     270        ALLOCATE(ttr(nqtrue))
     271        ttr(1:nqo + nqCO2) = tracers
     272        ttr(1:nqo)%component = 'lmdz'
     273        ttr(1 + nqo:nqCO2 + nqo)%component = 'co2i'
     274        ttr(1 + nqo + nqCO2:nqtrue)%component = 'inca'
     275        ttr(1 + nqo:nqtrue)%name = [('CO2     ', k = 1, nqCO2), solsym_inca]
     276        ttr(1 + nqo + nqCO2:nqtrue)%parent = tran0
     277        ttr(1 + nqo + nqCO2:nqtrue)%phase = 'g'
     278        lerr = getKey('hadv', had, ky = tracers(:)%keys)
     279        lerr = getKey('vadv', vad, ky = tracers(:)%keys)
     280        hadv(1:nqo + nqCO2) = had(:); hadv(1 + nqo + nqCO2:nqtrue) = hadv_inca
     281        vadv(1:nqo + nqCO2) = vad(:); vadv(1 + nqo + nqCO2:nqtrue) = vadv_inca
     282        CALL MOVE_ALLOC(FROM = ttr, TO = tracers)
     283        DO iq = 1, nqtrue
     284          t1 => tracers(iq)
     285          CALL addKey('name', t1%name, t1%keys)
     286          CALL addKey('component', t1%component, t1%keys)
     287          CALL addKey('parent', t1%parent, t1%keys)
     288          CALL addKey('phase', t1%phase, t1%keys)
     289        END DO
     290        IF(setGeneration(tracers)) CALL abort_physic(modname, 'See below', 1) !- SET FIELDS %iGeneration, %gen0Name
     291        DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
     292      END IF
     293      !---------------------------------------------------------------------------------------------------------------------------
     294    ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
     295      !---------------------------------------------------------------------------------------------------------------------------
     296      nqo = COUNT(delPhase(tracers(:)%name)     == 'H2O' &
     297              .AND. tracers(:)%component == 'lmdz') !--- Number of water phases
    305298      nqtrue = SIZE(tracers)                                         !--- Total number of "true" tracers
    306       nbtr   = nqtrue-COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
    307                                .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
    308    IF (CPPKEY_INCA) THEN
    309       nqINCA = COUNT(tracers(:)%component == 'inca')
    310    END IF
    311       lerr = getKey('hadv', hadv, ky=tracers(:)%keys)
    312       lerr = getKey('vadv', vadv, ky=tracers(:)%keys)
    313    !---------------------------------------------------------------------------------------------------------------------------
    314    END IF
    315    !---------------------------------------------------------------------------------------------------------------------------
    316 
    317    !--- Transfert the number of tracers to Reprobus
     299      nbtr = nqtrue - COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
     300              .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
     301      IF (CPPKEY_INCA) THEN
     302        nqINCA = COUNT(tracers(:)%component == 'inca')
     303      END IF
     304      lerr = getKey('hadv', hadv, ky = tracers(:)%keys)
     305      lerr = getKey('vadv', vadv, ky = tracers(:)%keys)
     306      !---------------------------------------------------------------------------------------------------------------------------
     307    END IF
     308    !---------------------------------------------------------------------------------------------------------------------------
     309
     310    !--- Transfert the number of tracers to Reprobus
    318311#ifdef REPROBUS
    319312   CALL Init_chem_rep_trac(nbtr, nqo, tracers(:)%name)
    320313#endif
    321314
    322 !##############################################################################################################################
    323    IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
    324 !##############################################################################################################################
    325 
    326 !==============================================================================================================================
    327 ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
    328 !==============================================================================================================================
    329    DO iq = 1, nqtrue
    330       IF( hadv(iq)<20 .OR. (ANY(hadv(iq)==[20,30]) .AND. hadv(iq)==vadv(iq)) ) CYCLE
    331       WRITE(msg1,'("The choice hadv=",i0,", vadv=",i0,a)')hadv(iq),vadv(iq),' for "'//TRIM(tracers(iq)%name)//'" is not available'
    332       CALL abort_physic(modname, TRIM(msg1), 1)
    333    END DO
    334    nqtot =    COUNT( hadv< 20 .AND. vadv< 20 ) &                     !--- No additional tracer
    335          +  4*COUNT( hadv==20 .AND. vadv==20 ) &                     !--- 3  additional tracers
    336          + 10*COUNT( hadv==30 .AND. vadv==30 )                       !--- 9  additional tracers
    337 
    338    !--- More tracers due to the choice of advection scheme => assign total number of tracers
    339    IF( nqtot /= nqtrue ) THEN
    340       CALL msg('The choice of advection scheme for one or more tracers makes it necessary to add tracers')
    341       CALL msg('The number of true tracers is '//TRIM(int2str(nqtrue)))
    342       CALL msg('The total number of tracers needed is '//TRIM(int2str(nqtot)))
    343    END IF
    344 
    345 !==============================================================================================================================
    346 ! 3) Determine the advection scheme ; needed to compute the full tracers list, the long names, nqtot and %isAdvected
    347 !==============================================================================================================================
    348    ALLOCATE(ttr(nqtot))
    349    jq = nqtrue+1; tracers(:)%iadv = -1
    350    DO iq = 1, nqtrue
    351       t1 => tracers(iq)
    352 
    353       !--- VERIFY THE CHOICE OF ADVECTION SCHEME
    354       iad = -1
    355       IF(hadv(iq)     ==    vadv(iq)    ) iad = hadv(iq)
    356       IF(hadv(iq)==10 .AND. vadv(iq)==16) iad = 11
    357       WRITE(msg1,'("Bad choice of advection scheme for ",a,": hadv = ",i0,", vadv = ",i0)')TRIM(t1%name), hadv(iq), vadv(iq)
    358       IF(iad == -1) CALL abort_physic(modname, msg1, 1)
    359 
    360       !--- SET FIELDS %longName, %isAdvected, %isInPhysics
    361       t1%longName   = t1%name; IF(iad > 0) t1%longName=TRIM(t1%name)//descrq(iad)
    362       t1%isAdvected = iad >= 0
    363       t1%isInPhysics= delPhase(t1%gen0Name) /= 'H2O' &
    364                           .OR. t1%component /= 'lmdz' !=== OTHER EXCEPTIONS TO BE ADDED: CO2i, SURSATURATED WATER CLOUD...
    365       ttr(iq)      = t1
    366 
    367       !--- DEFINE THE HIGHER ORDER TRACERS, IF ANY
    368       nm = 0
    369       IF(iad == 20) nm = 3                                           !--- 2nd order scheme
    370       IF(iad == 30) nm = 9                                           !--- 3rd order scheme
    371       IF(nm == 0) CYCLE                                              !--- No higher moments
    372       ttr(jq+1:jq+nm)            = t1
    373       ttr(jq+1:jq+nm)%name        = [(TRIM(t1%name)    //'-'//TRIM(suff(im)), im=1, nm) ]
    374       ttr(jq+1:jq+nm)%parent      = [(TRIM(t1%parent)  //'-'//TRIM(suff(im)), im=1, nm) ]
    375       ttr(jq+1:jq+nm)%longName    = [(TRIM(t1%longName)//'-'//TRIM(suff(im)), im=1, nm) ]
    376       ttr(jq+1:jq+nm)%isAdvected  = [(.FALSE., im=1, nm) ]
    377       jq = jq + nm
    378    END DO
    379    DEALLOCATE(hadv, vadv)
    380    CALL MOVE_ALLOC(FROM=ttr, TO=tracers)
    381 
    382    !--- SET FIELDS %iqParent, %nqChildren, %iGeneration, %iqDescen, %nqDescen
    383    IF(indexUpdate(tracers)) CALL abort_gcm(modname, 'problem when processing isotopes parameters', 1)
    384 
    385 !##############################################################################################################################
    386    END IF
    387 !##############################################################################################################################
    388 
    389 !##############################################################################################################################
    390    IF(.NOT.lInit) THEN
    391 !##############################################################################################################################
    392      nqtot = SIZE(tracers)
    393 !##############################################################################################################################
    394    ELSE
    395 !##############################################################################################################################
    396 
    397    !=== READ PHYSICAL PARAMETERS FOR ISOTOPES
    398    niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE.
    399    IF(processIsotopes()) CALL abort_physic(modname, 'Problem when processing isotopes parameters', 1)
    400 
    401 !##############################################################################################################################
    402    END IF
    403 !##############################################################################################################################
    404    !--- Convection / boundary layer activation for all tracers
    405    IF (.NOT.ALLOCATED(conv_flg)) ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1
    406    IF (.NOT.ALLOCATED(pbl_flg)) ALLOCATE( pbl_flg(nbtr));  pbl_flg(1:nbtr) = 1
    407 
    408    !--- Note: nqtottr can differ from nbtr when nmom/=0
    409    nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz')
    410    IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
    411       CALL abort_physic(modname, 'problem with the computation of nqtottr', 1)
    412 
    413    !=== DISPLAY THE RESULTS
    414    CALL msg('nqo    = '//TRIM(int2str(nqo)),    modname)
    415    CALL msg('nbtr   = '//TRIM(int2str(nbtr)),  modname)
    416    CALL msg('nqtrue = '//TRIM(int2str(nqtrue)), modname)
    417    CALL msg('nqtot  = '//TRIM(int2str(nqtot)), modname)
    418    CALL msg('niso   = '//TRIM(int2str(niso)),  modname)
    419    CALL msg('ntiso  = '//TRIM(int2str(ntiso)), modname)
    420    IF (CPPKEY_INCA) THEN
    421       CALL msg('nqCO2  = '//TRIM(int2str(nqCO2)), modname)
    422       CALL msg('nqINCA = '//TRIM(int2str(nqINCA)), modname)
    423    END IF
    424    t => tracers
    425    CALL msg('Information stored in infotrac_phy :', modname)
    426    IF(dispTable('issssssssiiiiiiii', ['iq  ', 'name', 'lNam', 'g0Nm', 'prnt', 'type', 'phas', 'comp',      &
    427                               'isPh', 'iGen', 'iqPr', 'nqDe', 'nqCh', 'iGrp', 'iNam', 'iZon', 'iPha'],    &
    428       cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics)),&
    429       cat([(iq, iq=1, nqtot)], t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup,          &
    430                   t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax=maxTableWidth, nHead=2, sub=modname))   &
    431       CALL abort_physic(modname, "problem with the tracers table content", 1)
    432    IF(niso > 0) THEN
    433       CALL msg('Where, for isotopes family "'//TRIM(isotope%parent)//'":', modname)
    434       CALL msg('  isoKeys%name = '//strStack(isoKeys%name), modname)
    435       CALL msg('  isoName = '//strStack(isoName),      modname)
    436       CALL msg('  isoZone = '//strStack(isoZone),      modname)
    437       CALL msg('  isoPhas = '//TRIM(isoPhas),          modname)
    438    ELSE
     315    !##############################################################################################################################
     316    IF(lInit) THEN                                                    !=== SKIPED IF ALREADY DONE IN dyn3d_common/infotrac  ####
     317      !##############################################################################################################################
     318
     319      !==============================================================================================================================
     320      ! 2) Calculate nqtot, number of tracers needed (greater if advection schemes 20 or 30 have been chosen).
     321      !==============================================================================================================================
     322      DO iq = 1, nqtrue
     323        IF(hadv(iq)<20 .OR. (ANY(hadv(iq)==[20, 30]) .AND. hadv(iq)==vadv(iq))) CYCLE
     324        WRITE(msg1, '("The choice hadv=",i0,", vadv=",i0,a)')hadv(iq), vadv(iq), ' for "' // TRIM(tracers(iq)%name) // '" is not available'
     325        CALL abort_physic(modname, TRIM(msg1), 1)
     326      END DO
     327      nqtot = COUNT(hadv< 20 .AND. vadv< 20) &                     !--- No additional tracer
     328              + 4 * COUNT(hadv==20 .AND. vadv==20) &                     !--- 3  additional tracers
     329              + 10 * COUNT(hadv==30 .AND. vadv==30)                       !--- 9  additional tracers
     330
     331      !--- More tracers due to the choice of advection scheme => assign total number of tracers
     332      IF(nqtot /= nqtrue) THEN
     333        CALL msg('The choice of advection scheme for one or more tracers makes it necessary to add tracers')
     334        CALL msg('The number of true tracers is ' // TRIM(int2str(nqtrue)))
     335        CALL msg('The total number of tracers needed is ' // TRIM(int2str(nqtot)))
     336      END IF
     337
     338      !==============================================================================================================================
     339      ! 3) Determine the advection scheme ; needed to compute the full tracers list, the long names, nqtot and %isAdvected
     340      !==============================================================================================================================
     341      ALLOCATE(ttr(nqtot))
     342      jq = nqtrue + 1; tracers(:)%iadv = -1
     343      DO iq = 1, nqtrue
     344        t1 => tracers(iq)
     345
     346        !--- VERIFY THE CHOICE OF ADVECTION SCHEME
     347        iad = -1
     348        IF(hadv(iq)     ==    vadv(iq)) iad = hadv(iq)
     349        IF(hadv(iq)==10 .AND. vadv(iq)==16) iad = 11
     350        WRITE(msg1, '("Bad choice of advection scheme for ",a,": hadv = ",i0,", vadv = ",i0)')TRIM(t1%name), hadv(iq), vadv(iq)
     351        IF(iad == -1) CALL abort_physic(modname, msg1, 1)
     352
     353        !--- SET FIELDS %longName, %isAdvected, %isInPhysics
     354        t1%longName = t1%name; IF(iad > 0) t1%longName = TRIM(t1%name) // descrq(iad)
     355        t1%isAdvected = iad >= 0
     356        t1%isInPhysics = delPhase(t1%gen0Name) /= 'H2O' &
     357                .OR. t1%component /= 'lmdz' !=== OTHER EXCEPTIONS TO BE ADDED: CO2i, SURSATURATED WATER CLOUD...
     358        ttr(iq) = t1
     359
     360        !--- DEFINE THE HIGHER ORDER TRACERS, IF ANY
     361        nm = 0
     362        IF(iad == 20) nm = 3                                           !--- 2nd order scheme
     363        IF(iad == 30) nm = 9                                           !--- 3rd order scheme
     364        IF(nm == 0) CYCLE                                              !--- No higher moments
     365        ttr(jq + 1:jq + nm) = t1
     366        ttr(jq + 1:jq + nm)%name = [(TRIM(t1%name) // '-' // TRIM(suff(im)), im = 1, nm) ]
     367        ttr(jq + 1:jq + nm)%parent = [(TRIM(t1%parent) // '-' // TRIM(suff(im)), im = 1, nm) ]
     368        ttr(jq + 1:jq + nm)%longName = [(TRIM(t1%longName) // '-' // TRIM(suff(im)), im = 1, nm) ]
     369        ttr(jq + 1:jq + nm)%isAdvected = [(.FALSE., im = 1, nm) ]
     370        jq = jq + nm
     371      END DO
     372      DEALLOCATE(hadv, vadv)
     373      CALL MOVE_ALLOC(FROM = ttr, TO = tracers)
     374
     375      !--- SET FIELDS %iqParent, %nqChildren, %iGeneration, %iqDescen, %nqDescen
     376      IF(indexUpdate(tracers)) CALL abort_gcm(modname, 'problem when processing isotopes parameters', 1)
     377
     378      !##############################################################################################################################
     379    END IF
     380    !##############################################################################################################################
     381
     382    !##############################################################################################################################
     383    IF(.NOT.lInit) THEN
     384      !##############################################################################################################################
     385      nqtot = SIZE(tracers)
     386      !##############################################################################################################################
     387    ELSE
     388      !##############################################################################################################################
     389
     390      !=== READ PHYSICAL PARAMETERS FOR ISOTOPES
     391      niso = 0; nzone = 0; nphas = nqo; ntiso = 0; isoCheck = .FALSE.
     392      IF(processIsotopes()) CALL abort_physic(modname, 'Problem when processing isotopes parameters', 1)
     393
     394      !##############################################################################################################################
     395    END IF
     396    !##############################################################################################################################
     397    !--- Convection / boundary layer activation for all tracers
     398    IF (.NOT.ALLOCATED(conv_flg)) ALLOCATE(conv_flg(nbtr)); conv_flg(1:nbtr) = 1
     399    IF (.NOT.ALLOCATED(pbl_flg)) ALLOCATE(pbl_flg(nbtr));  pbl_flg(1:nbtr) = 1
     400
     401    !--- Note: nqtottr can differ from nbtr when nmom/=0
     402    nqtottr = nqtot - COUNT(delPhase(tracers%gen0Name) == 'H2O' .AND. tracers%component == 'lmdz')
     403    IF(COUNT(tracers%iso_iName == 0) - COUNT(delPhase(tracers%name) == 'H2O' .AND. tracers%component == 'lmdz') /= nqtottr) &
     404            CALL abort_physic(modname, 'problem with the computation of nqtottr', 1)
     405
     406    !=== DISPLAY THE RESULTS
     407    CALL msg('nqo    = ' // TRIM(int2str(nqo)), modname)
     408    CALL msg('nbtr   = ' // TRIM(int2str(nbtr)), modname)
     409    CALL msg('nqtrue = ' // TRIM(int2str(nqtrue)), modname)
     410    CALL msg('nqtot  = ' // TRIM(int2str(nqtot)), modname)
     411    CALL msg('niso   = ' // TRIM(int2str(niso)), modname)
     412    CALL msg('ntiso  = ' // TRIM(int2str(ntiso)), modname)
     413    IF (CPPKEY_INCA) THEN
     414      CALL msg('nqCO2  = ' // TRIM(int2str(nqCO2)), modname)
     415      CALL msg('nqINCA = ' // TRIM(int2str(nqINCA)), modname)
     416    END IF
     417    t => tracers
     418    CALL msg('Information stored in infotrac_phy :', modname)
     419    IF(dispTable('issssssssiiiiiiii', ['iq  ', 'name', 'lNam', 'g0Nm', 'prnt', 'type', 'phas', 'comp', &
     420            'isPh', 'iGen', 'iqPr', 'nqDe', 'nqCh', 'iGrp', 'iNam', 'iZon', 'iPha'], &
     421            cat(t%name, t%longName, t%gen0Name, t%parent, t%type, t%phase, t%component, bool2str(t%isInPhysics)), &
     422            cat([(iq, iq = 1, nqtot)], t%iGeneration, t%iqParent, t%nqDescen, t%nqChildren, t%iso_iGroup, &
     423                    t%iso_iName, t%iso_iZone, t%iso_iPhase), nColMax = maxTableWidth, nHead = 2, sub = modname))   &
     424            CALL abort_physic(modname, "problem with the tracers table content", 1)
     425    IF(niso > 0) THEN
     426      CALL msg('Where, for isotopes family "' // TRIM(isotope%parent) // '":', modname)
     427      CALL msg('  isoKeys%name = ' // strStack(isoKeys%name), modname)
     428      CALL msg('  isoName = ' // strStack(isoName), modname)
     429      CALL msg('  isoZone = ' // strStack(isoZone), modname)
     430      CALL msg('  isoPhas = ' // TRIM(isoPhas), modname)
     431    ELSE
    439432      CALL msg('No isotopes identified.', modname)
    440    END IF
     433    END IF
    441434
    442435#ifdef ISOVERIF
    443436   CALL msg('iso_iName = '//strStack(int2str(PACK(tracers(:)%iso_iName, MASK=tracers(:)%iso_iGroup==iH2O))), modname)
    444437#endif
    445 #ifdef CPP_StratAer
    446    IF (type_trac == 'coag') THEN
    447       nbtr_bin    = COUNT([(tracers(iq)%name(1:3)=='BIN', iq=1, nqtot)])
    448       nbtr_sulgas = COUNT([(tracers(iq)%name(1:3)=='GAS', iq=1, nqtot)])
    449       tnames = PACK(tracers(:)%name, MASK=tracers(:)%isInPhysics)
    450       id_BIN01_strat = strIdx(tnames, 'BIN01'   )
    451       id_OCS_strat   = strIdx(tnames, 'GASOCS'  )
    452       id_SO2_strat   = strIdx(tnames, 'GASSO2'  )
    453       id_H2SO4_strat = strIdx(tnames, 'GASH2SO4')
    454       id_TEST_strat  = strIdx(tnames, 'GASTEST' )
    455       CALL msg('nbtr_bin       ='//TRIM(int2str(nbtr_bin      )), modname)
    456       CALL msg('nbtr_sulgas    ='//TRIM(int2str(nbtr_sulgas   )), modname)
    457       CALL msg('id_BIN01_strat ='//TRIM(int2str(id_BIN01_strat)), modname)
    458       CALL msg('id_OCS_strat   ='//TRIM(int2str(id_OCS_strat  )), modname)
    459       CALL msg('id_SO2_strat   ='//TRIM(int2str(id_SO2_strat  )), modname)
    460       CALL msg('id_H2SO4_strat ='//TRIM(int2str(id_H2SO4_strat)), modname)
    461       CALL msg('id_TEST_strat  ='//TRIM(int2str(id_TEST_strat )), modname)
    462    END IF
    463 #endif
    464    CALL msg('end', modname)
    465 
    466 END SUBROUTINE init_infotrac_phy
     438    IF (CPPKEY_STRATAER) THEN
     439      IF (type_trac == 'coag') THEN
     440        nbtr_bin = COUNT([(tracers(iq)%name(1:3)=='BIN', iq = 1, nqtot)])
     441        nbtr_sulgas = COUNT([(tracers(iq)%name(1:3)=='GAS', iq = 1, nqtot)])
     442        tnames = PACK(tracers(:)%name, MASK = tracers(:)%isInPhysics)
     443        id_BIN01_strat = strIdx(tnames, 'BIN01')
     444        id_OCS_strat = strIdx(tnames, 'GASOCS')
     445        id_SO2_strat = strIdx(tnames, 'GASSO2')
     446        id_H2SO4_strat = strIdx(tnames, 'GASH2SO4')
     447        id_TEST_strat = strIdx(tnames, 'GASTEST')
     448        CALL msg('nbtr_bin       =' // TRIM(int2str(nbtr_bin)), modname)
     449        CALL msg('nbtr_sulgas    =' // TRIM(int2str(nbtr_sulgas)), modname)
     450        CALL msg('id_BIN01_strat =' // TRIM(int2str(id_BIN01_strat)), modname)
     451        CALL msg('id_OCS_strat   =' // TRIM(int2str(id_OCS_strat)), modname)
     452        CALL msg('id_SO2_strat   =' // TRIM(int2str(id_SO2_strat)), modname)
     453        CALL msg('id_H2SO4_strat =' // TRIM(int2str(id_H2SO4_strat)), modname)
     454        CALL msg('id_TEST_strat  =' // TRIM(int2str(id_TEST_strat)), modname)
     455      END IF
     456    END IF
     457    CALL msg('end', modname)
     458
     459  END SUBROUTINE init_infotrac_phy
    467460
    468461END MODULE infotrac_phy
  • LMDZ6/branches/Amaury_dev/libf/phylmd/ini_csts.F90

    r4722 r5098  
    7878!IF (LHOOK) CALL DR_HOOK('INI_CSTS',0,ZHOOK_HANDLE)
    7979
    80 !#ifdef SFX_MNH
    81 !#ifdef MNH_MPI_DOUBLE_PRECISION
    8280XSURF_TINY    = 1.0e-80
    8381!#else
    84 !XSURF_TINY    = TINY    (XSURF_TINY    )
    85 !#endif
    86 !#else
    8782XSURF_TINY    = 1.0e-80
    88 !#endif
    8983XSURF_TINY_12 = SQRT    (XSURF_TINY    )
    9084XSURF_EPSILON = EPSILON (XSURF_EPSILON ) * 10.0
  • LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_yomcst.f90

    r5095 r5098  
    1 !
    2 ! $Header$
    3 !
    4 !  ATTENTION!!!!: ce fichier include est compatible format fixe/format libre
    5 !                 veillez à n'utiliser que des ! pour les commentaires
    6 !                 et à bien positionner les & des lignes de continuation
    7 !                 (les placer en colonne 6 et en colonne 73)
    8 !
    9 !
    10 ! A1.0 Fundamental constants
    11       REAL RPI,RCLUM,RHPLA,RKBOL,RNAVO
    12 ! A1.1 Astronomical constants
    13       REAL RDAY,REA,REPSM,RSIYEA,RSIDAY,ROMEGA
    14 ! A1.1.bis Constantes concernant l'orbite de la Terre:
    15       REAL R_ecc, R_peri, R_incl
    16 ! A1.2 Geoide
    17       REAL RA,RG,R1SA
    18 ! A1.3 Radiation
    19 !     REAL RSIGMA,RI0
    20       REAL RSIGMA
    21 ! A1.4 Thermodynamic gas phase
    22       REAL RMO3,RMCO2,RMC,RMCH4,RMN2O,RMCFC11,RMCFC12
    23       REAL R,RMD,RMV,RD,RV,RCPD,RCPV,RCVD,RCVV
    24       REAL RKAPPA,RETV, eps_w
    25 ! A1.5,6 Thermodynamic liquid,solid phases
    26       REAL RCW,RCS
    27 ! A1.7 Thermodynamic transition of phase
    28       REAL RLVTT,RLSTT,RLMLT,RTT,RATM
    29 ! A1.8 Curve of saturation
    30       REAL RESTT,RALPW,RBETW,RGAMW,RALPS,RBETS,RGAMS
    31       REAL RALPD,RBETD,RGAMD
    32 !
    33       COMMON/YOMCST/RPI   ,RCLUM ,RHPLA ,RKBOL ,RNAVO                   &
    34      &      ,RDAY  ,REA   ,REPSM ,RSIYEA,RSIDAY,ROMEGA                  &
    35      &      ,R_ecc, R_peri, R_incl                                      &
    36      &      ,RA    ,RG    ,R1SA                                         &
    37      &      ,RSIGMA                                                     &
    38      &      ,R     ,RMD   ,RMV   ,RD    ,RV    ,RCPD                    &
    39      &      ,RMO3  ,RMCO2 ,RMC   ,RMCH4 ,RMN2O ,RMCFC11 ,RMCFC12        &
    40      &      ,RCPV  ,RCVD  ,RCVV  ,RKAPPA,RETV, eps_w                    &
    41      &      ,RCW   ,RCS                                                 &
    42      &      ,RLVTT ,RLSTT ,RLMLT ,RTT   ,RATM                           &
    43      &      ,RESTT ,RALPW ,RBETW ,RGAMW ,RALPS ,RBETS ,RGAMS            &
    44      &      ,RALPD ,RBETD ,RGAMD
    45 !    ------------------------------------------------------------------
    46 !$OMP THREADPRIVATE(/YOMCST/)
     1! TODO: REPLACE YOMCST.h ONCE .F -> .f90 !
     2
     3module lmdz_yomcst
     4  ! A1.0 Fundamental constants
     5  REAL RPI, RCLUM, RHPLA, RKBOL, RNAVO
     6  ! A1.1 Astronomical constants
     7  REAL RDAY, REA, REPSM, RSIYEA, RSIDAY, ROMEGA
     8  ! A1.1.bis Constantes concernant l'orbite de la Terre:
     9  REAL R_ecc, R_peri, R_incl
     10  ! A1.2 Geoide
     11  REAL RA, RG, R1SA
     12  ! A1.3 Radiation
     13  !     REAL RSIGMA,RI0
     14  REAL RSIGMA
     15  ! A1.4 Thermodynamic gas phase
     16  REAL RMO3, RMCO2, RMC, RMCH4, RMN2O, RMCFC11, RMCFC12
     17  REAL R, RMD, RMV, RD, RV, RCPD, RCPV, RCVD, RCVV
     18  REAL RKAPPA, RETV, eps_w
     19  ! A1.5,6 Thermodynamic liquid,solid phases
     20  REAL RCW, RCS
     21  ! A1.7 Thermodynamic transition of phase
     22  REAL RLVTT, RLSTT, RLMLT, RTT, RATM
     23  ! A1.8 Curve of saturation
     24  REAL RESTT, RALPW, RBETW, RGAMW, RALPS, RBETS, RGAMS
     25  REAL RALPD, RBETD, RGAMD
     26
     27  COMMON/YOMCST/RPI, RCLUM, RHPLA, RKBOL, RNAVO                   &
     28          , RDAY, REA, REPSM, RSIYEA, RSIDAY, ROMEGA                  &
     29          , R_ecc, R_peri, R_incl                                      &
     30          , RA, RG, R1SA                                         &
     31          , RSIGMA                                                     &
     32          , R, RMD, RMV, RD, RV, RCPD                    &
     33          , RMO3, RMCO2, RMC, RMCH4, RMN2O, RMCFC11, RMCFC12        &
     34          , RCPV, RCVD, RCVV, RKAPPA, RETV, eps_w                    &
     35          , RCW, RCS                                                 &
     36          , RLVTT, RLSTT, RLMLT, RTT, RATM                           &
     37          , RESTT, RALPW, RBETW, RGAMW, RALPS, RBETS, RGAMS            &
     38          , RALPD, RBETD, RGAMD
     39  !$OMP THREADPRIVATE(/YOMCST/)
     40
     41end module lmdz_yomcst
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phys_local_var_mod.F90

    r5066 r5098  
    22! $Id$
    33!
    4       MODULE phys_local_var_mod
    5 ! Variables locales pour effectuer les appels en serie
    6 !======================================================================
    7 !
    8 !
    9 !======================================================================
    10 ! Declaration des variables
    11 
    12       REAL, SAVE, ALLOCATABLE :: t_seri(:,:), q_seri(:,:)
    13       !$OMP THREADPRIVATE(t_seri, q_seri)
    14       REAL, SAVE, ALLOCATABLE :: ql_seri(:,:),qs_seri(:,:)
    15       !$OMP THREADPRIVATE(ql_seri,qs_seri)
    16 ! SN 15/07/2024 ISO 4D
    17       REAL, SAVE, ALLOCATABLE :: qx_seri(:,:,:)
    18       !$OMP THREADPRIVATE(qx_seri)
    19 ! SN
    20       REAL, SAVE, ALLOCATABLE :: qbs_seri(:,:)
    21       !$OMP THREADPRIVATE(qbs_seri)
    22       REAL, SAVE, ALLOCATABLE :: u_seri(:,:), v_seri(:,:)
    23       !$OMP THREADPRIVATE(u_seri, v_seri)
    24       REAL, SAVE, ALLOCATABLE :: rneb_seri(:,:)
    25       !$OMP THREADPRIVATE(rneb_seri)
    26       REAL, SAVE, ALLOCATABLE :: d_rneb_dyn(:,:)
    27       !$OMP THREADPRIVATE(d_rneb_dyn)
    28       REAL, SAVE, ALLOCATABLE :: l_mixmin(:,:,:),l_mix(:,:,:),wprime(:,:,:)
    29       !$OMP THREADPRIVATE(l_mixmin, l_mix, wprime)
    30       REAL, SAVE, ALLOCATABLE :: pbl_eps(:,:,:)
    31       !$OMP THREADPRIVATE(pbl_eps)
    32       REAL, SAVE, ALLOCATABLE :: tke_shear(:,:,:), tke_buoy(:,:,:), tke_trans(:,:,:)
    33       !$OMP THREADPRIVATE(tke_shear,tke_buoy,tke_trans)
    34       REAL, SAVE, ALLOCATABLE :: tr_seri(:,:,:)
    35       !$OMP THREADPRIVATE(tr_seri)
    36       REAL, SAVE, ALLOCATABLE :: rhcl(:,:)
    37       !$OMP THREADPRIVATE(rhcl)
    38       REAL, SAVE, ALLOCATABLE :: d_t_dyn(:,:), d_q_dyn(:,:)
    39       !$OMP THREADPRIVATE(d_t_dyn, d_q_dyn)
    40       REAL, SAVE, ALLOCATABLE :: d_ql_dyn(:,:), d_qs_dyn(:,:), d_qbs_dyn(:,:)
    41       !$OMP THREADPRIVATE(d_ql_dyn, d_qs_dyn, d_qbs_dyn)
    42       REAL, SAVE, ALLOCATABLE :: d_q_dyn2d(:), d_ql_dyn2d(:), d_qs_dyn2d(:), d_qbs_dyn2d(:)
    43       !$OMP THREADPRIVATE(d_q_dyn2d, d_ql_dyn2d, d_qs_dyn2d, d_qbs_dyn2d)
    44       REAL, SAVE, ALLOCATABLE :: d_u_dyn(:,:), d_v_dyn(:,:)
    45       !$OMP THREADPRIVATE(d_u_dyn, d_v_dyn)
    46       REAL, SAVE, ALLOCATABLE :: d_tr_dyn(:,:,:)
    47       !$OMP THREADPRIVATE(d_tr_dyn)
    48       REAL, SAVE, ALLOCATABLE :: d_t_con(:,:),d_q_con(:,:),d_q_con_zmasse(:,:)
    49       !$OMP THREADPRIVATE(d_t_con,d_q_con,d_q_con_zmasse)
    50       REAL, SAVE, ALLOCATABLE :: d_u_con(:,:),d_v_con(:,:)
    51       !$OMP THREADPRIVATE(d_u_con,d_v_con)
    52       REAL, SAVE, ALLOCATABLE :: d_t_wake(:,:),d_q_wake(:,:)
    53       !$OMP THREADPRIVATE( d_t_wake,d_q_wake)
    54       REAL, SAVE, ALLOCATABLE :: d_t_lsc(:,:),d_q_lsc(:,:),d_ql_lsc(:,:),d_qi_lsc(:,:)
    55       !$OMP THREADPRIVATE(d_t_lsc,d_q_lsc,d_ql_lsc,d_qi_lsc)
    56       REAL, SAVE, ALLOCATABLE :: d_t_lwr(:,:),d_t_lw0(:,:),d_t_swr(:,:),d_t_sw0(:,:)
    57       !$OMP THREADPRIVATE(d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0)
    58       REAL, SAVE, ALLOCATABLE :: d_t_ajsb(:,:), d_q_ajsb(:,:)
    59       !$OMP THREADPRIVATE(d_t_ajsb, d_q_ajsb)
    60       REAL, SAVE, ALLOCATABLE :: d_t_ajs(:,:), d_q_ajs(:,:)
    61       !$OMP THREADPRIVATE(d_t_ajs, d_q_ajs)
    62       REAL, SAVE, ALLOCATABLE :: d_u_ajs(:,:), d_v_ajs(:,:)
    63       !$OMP THREADPRIVATE(d_u_ajs, d_v_ajs)
    64 !nrlmd<
    65       REAL, SAVE, ALLOCATABLE :: d_t_ajs_w(:,:), d_q_ajs_w(:,:)
    66       !$OMP THREADPRIVATE(d_t_ajs_w, d_q_ajs_w)
    67       REAL, SAVE, ALLOCATABLE :: d_t_ajs_x(:,:), d_q_ajs_x(:,:)
    68       !$OMP THREADPRIVATE(d_t_ajs_x, d_q_ajs_x)
    69 !>nrlmd
    70       REAL, SAVE, ALLOCATABLE :: d_t_eva(:,:),d_q_eva(:,:),d_ql_eva(:,:),d_qi_eva(:,:)
    71       !$OMP THREADPRIVATE(d_t_eva,d_q_eva,d_ql_eva,d_qi_eva)
    72 ! SN 15/07/2024 ISO 4D
    73       REAL, SAVE, ALLOCATABLE :: d_qx_eva(:,:,:)
    74       !$OMP THREADPRIVATE(d_qx_eva)
    75 ! SN
    76       REAL, SAVE, ALLOCATABLE :: d_t_lscst(:,:),d_q_lscst(:,:)
    77       !$OMP THREADPRIVATE(d_t_lscst,d_q_lscst)
    78       REAL, SAVE, ALLOCATABLE :: d_t_lscth(:,:),d_q_lscth(:,:)
    79       !$OMP THREADPRIVATE(d_t_lscth,d_q_lscth)
    80       REAL, SAVE, ALLOCATABLE :: plul_th(:),plul_st(:)
    81       !$OMP THREADPRIVATE(plul_th,plul_st)
    82 !tendances dues a oro et lif
    83       REAL, SAVE, ALLOCATABLE :: d_t_oli(:,:)
    84       !$OMP THREADPRIVATE(d_t_oli)
    85       REAL, SAVE, ALLOCATABLE :: d_u_oli(:,:), d_v_oli(:,:)
    86       !$OMP THREADPRIVATE(d_u_oli, d_v_oli)
    87       REAL, SAVE, ALLOCATABLE :: d_t_vdf(:,:), d_q_vdf(:,:), d_qbs_vdf(:,:), d_t_diss(:,:)
    88       !$OMP THREADPRIVATE( d_t_vdf, d_q_vdf, d_qbs_vdf, d_t_diss)
    89       REAL, SAVE, ALLOCATABLE :: d_u_vdf(:,:), d_v_vdf(:,:)
    90       !$OMP THREADPRIVATE(d_u_vdf, d_v_vdf)
    91 !nrlmd+jyg<
    92       REAL, SAVE, ALLOCATABLE :: d_t_vdf_w(:,:), d_q_vdf_w(:,:)
    93       !$OMP THREADPRIVATE( d_t_vdf_w, d_q_vdf_w)
    94       REAL, SAVE, ALLOCATABLE :: d_t_vdf_x(:,:), d_q_vdf_x(:,:)
    95       !$OMP THREADPRIVATE( d_t_vdf_x, d_q_vdf_x)
    96       REAL, SAVE, ALLOCATABLE :: d_t_bsss(:,:), d_q_bsss(:,:), d_qbs_bsss(:,:)
    97       !$OMP THREADPRIVATE( d_t_bsss,d_q_bsss, d_qbs_bsss)
    98 !>nrlmd+jyg
    99       REAL, SAVE, ALLOCATABLE :: d_t_oro(:,:)
    100       !$OMP THREADPRIVATE(d_t_oro)
    101       REAL, SAVE, ALLOCATABLE :: d_u_oro(:,:), d_v_oro(:,:)
    102       !$OMP THREADPRIVATE(d_u_oro, d_v_oro)
    103       REAL, SAVE, ALLOCATABLE :: d_t_oro_gw(:,:)
    104       !$OMP THREADPRIVATE(d_t_oro_gw)
    105       REAL, SAVE, ALLOCATABLE :: d_u_oro_gw(:,:), d_v_oro_gw(:,:)
    106       !$OMP THREADPRIVATE(d_u_oro_gw, d_v_oro_gw)
    107       REAL, SAVE, ALLOCATABLE :: d_t_lif(:,:)
    108       !$OMP THREADPRIVATE(d_t_lif)
    109       REAL, SAVE, ALLOCATABLE :: d_u_lif(:,:), d_v_lif(:,:)
    110       !$OMP THREADPRIVATE(d_u_lif, d_v_lif)
    111 ! Tendances Ondes de G non oro (runs strato).
    112       REAL, SAVE, ALLOCATABLE :: du_gwd_hines(:,:)
    113       !$OMP THREADPRIVATE(du_gwd_hines)
    114       REAL, SAVE, ALLOCATABLE :: dv_gwd_hines(:,:)
    115       !$OMP THREADPRIVATE(dv_gwd_hines)
    116       REAL, SAVE, ALLOCATABLE :: dv_gwd_rando(:,:)
    117       !$OMP THREADPRIVATE(dv_gwd_rando)
    118       REAL, SAVE, ALLOCATABLE :: dv_gwd_front(:,:)
    119       !$OMP THREADPRIVATE(dv_gwd_front)
    120       REAL, SAVE, ALLOCATABLE :: east_gwstress(:,:)
    121       !$OMP THREADPRIVATE(east_gwstress)
    122       REAL, SAVE, ALLOCATABLE :: west_gwstress(:,:)
    123       !$OMP THREADPRIVATE(west_gwstress)
    124       REAL, SAVE, ALLOCATABLE :: d_t_hin(:,:)
    125       !$OMP THREADPRIVATE(d_t_hin)
    126 ! tendance due a l'oxydation du methane
    127       REAL, SAVE, ALLOCATABLE :: d_q_ch4(:,:)
    128       !$OMP THREADPRIVATE(d_q_ch4)
     4MODULE phys_local_var_mod
     5  USE lmdz_cppkeys_wrapper, ONLY : CPPKEY_STRATAER
     6  ! Variables locales pour effectuer les appels en serie
     7  !======================================================================
     8  !
     9  !
     10  !======================================================================
     11  ! Declaration des variables
     12
     13  REAL, SAVE, ALLOCATABLE :: t_seri(:, :), q_seri(:, :)
     14  !$OMP THREADPRIVATE(t_seri, q_seri)
     15  REAL, SAVE, ALLOCATABLE :: ql_seri(:, :), qs_seri(:, :)
     16  !$OMP THREADPRIVATE(ql_seri,qs_seri)
     17  ! SN 15/07/2024 ISO 4D
     18  REAL, SAVE, ALLOCATABLE :: qx_seri(:, :, :)
     19  !$OMP THREADPRIVATE(qx_seri)
     20  ! SN
     21  REAL, SAVE, ALLOCATABLE :: qbs_seri(:, :)
     22  !$OMP THREADPRIVATE(qbs_seri)
     23  REAL, SAVE, ALLOCATABLE :: u_seri(:, :), v_seri(:, :)
     24  !$OMP THREADPRIVATE(u_seri, v_seri)
     25  REAL, SAVE, ALLOCATABLE :: rneb_seri(:, :)
     26  !$OMP THREADPRIVATE(rneb_seri)
     27  REAL, SAVE, ALLOCATABLE :: d_rneb_dyn(:, :)
     28  !$OMP THREADPRIVATE(d_rneb_dyn)
     29  REAL, SAVE, ALLOCATABLE :: l_mixmin(:, :, :), l_mix(:, :, :), wprime(:, :, :)
     30  !$OMP THREADPRIVATE(l_mixmin, l_mix, wprime)
     31  REAL, SAVE, ALLOCATABLE :: pbl_eps(:, :, :)
     32  !$OMP THREADPRIVATE(pbl_eps)
     33  REAL, SAVE, ALLOCATABLE :: tke_shear(:, :, :), tke_buoy(:, :, :), tke_trans(:, :, :)
     34  !$OMP THREADPRIVATE(tke_shear,tke_buoy,tke_trans)
     35  REAL, SAVE, ALLOCATABLE :: tr_seri(:, :, :)
     36  !$OMP THREADPRIVATE(tr_seri)
     37  REAL, SAVE, ALLOCATABLE :: rhcl(:, :)
     38  !$OMP THREADPRIVATE(rhcl)
     39  REAL, SAVE, ALLOCATABLE :: d_t_dyn(:, :), d_q_dyn(:, :)
     40  !$OMP THREADPRIVATE(d_t_dyn, d_q_dyn)
     41  REAL, SAVE, ALLOCATABLE :: d_ql_dyn(:, :), d_qs_dyn(:, :), d_qbs_dyn(:, :)
     42  !$OMP THREADPRIVATE(d_ql_dyn, d_qs_dyn, d_qbs_dyn)
     43  REAL, SAVE, ALLOCATABLE :: d_q_dyn2d(:), d_ql_dyn2d(:), d_qs_dyn2d(:), d_qbs_dyn2d(:)
     44  !$OMP THREADPRIVATE(d_q_dyn2d, d_ql_dyn2d, d_qs_dyn2d, d_qbs_dyn2d)
     45  REAL, SAVE, ALLOCATABLE :: d_u_dyn(:, :), d_v_dyn(:, :)
     46  !$OMP THREADPRIVATE(d_u_dyn, d_v_dyn)
     47  REAL, SAVE, ALLOCATABLE :: d_tr_dyn(:, :, :)
     48  !$OMP THREADPRIVATE(d_tr_dyn)
     49  REAL, SAVE, ALLOCATABLE :: d_t_con(:, :), d_q_con(:, :), d_q_con_zmasse(:, :)
     50  !$OMP THREADPRIVATE(d_t_con,d_q_con,d_q_con_zmasse)
     51  REAL, SAVE, ALLOCATABLE :: d_u_con(:, :), d_v_con(:, :)
     52  !$OMP THREADPRIVATE(d_u_con,d_v_con)
     53  REAL, SAVE, ALLOCATABLE :: d_t_wake(:, :), d_q_wake(:, :)
     54  !$OMP THREADPRIVATE( d_t_wake,d_q_wake)
     55  REAL, SAVE, ALLOCATABLE :: d_t_lsc(:, :), d_q_lsc(:, :), d_ql_lsc(:, :), d_qi_lsc(:, :)
     56  !$OMP THREADPRIVATE(d_t_lsc,d_q_lsc,d_ql_lsc,d_qi_lsc)
     57  REAL, SAVE, ALLOCATABLE :: d_t_lwr(:, :), d_t_lw0(:, :), d_t_swr(:, :), d_t_sw0(:, :)
     58  !$OMP THREADPRIVATE(d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0)
     59  REAL, SAVE, ALLOCATABLE :: d_t_ajsb(:, :), d_q_ajsb(:, :)
     60  !$OMP THREADPRIVATE(d_t_ajsb, d_q_ajsb)
     61  REAL, SAVE, ALLOCATABLE :: d_t_ajs(:, :), d_q_ajs(:, :)
     62  !$OMP THREADPRIVATE(d_t_ajs, d_q_ajs)
     63  REAL, SAVE, ALLOCATABLE :: d_u_ajs(:, :), d_v_ajs(:, :)
     64  !$OMP THREADPRIVATE(d_u_ajs, d_v_ajs)
     65  !nrlmd<
     66  REAL, SAVE, ALLOCATABLE :: d_t_ajs_w(:, :), d_q_ajs_w(:, :)
     67  !$OMP THREADPRIVATE(d_t_ajs_w, d_q_ajs_w)
     68  REAL, SAVE, ALLOCATABLE :: d_t_ajs_x(:, :), d_q_ajs_x(:, :)
     69  !$OMP THREADPRIVATE(d_t_ajs_x, d_q_ajs_x)
     70  !>nrlmd
     71  REAL, SAVE, ALLOCATABLE :: d_t_eva(:, :), d_q_eva(:, :), d_ql_eva(:, :), d_qi_eva(:, :)
     72  !$OMP THREADPRIVATE(d_t_eva,d_q_eva,d_ql_eva,d_qi_eva)
     73  ! SN 15/07/2024 ISO 4D
     74  REAL, SAVE, ALLOCATABLE :: d_qx_eva(:, :, :)
     75  !$OMP THREADPRIVATE(d_qx_eva)
     76  ! SN
     77  REAL, SAVE, ALLOCATABLE :: d_t_lscst(:, :), d_q_lscst(:, :)
     78  !$OMP THREADPRIVATE(d_t_lscst,d_q_lscst)
     79  REAL, SAVE, ALLOCATABLE :: d_t_lscth(:, :), d_q_lscth(:, :)
     80  !$OMP THREADPRIVATE(d_t_lscth,d_q_lscth)
     81  REAL, SAVE, ALLOCATABLE :: plul_th(:), plul_st(:)
     82  !$OMP THREADPRIVATE(plul_th,plul_st)
     83  !tendances dues a oro et lif
     84  REAL, SAVE, ALLOCATABLE :: d_t_oli(:, :)
     85  !$OMP THREADPRIVATE(d_t_oli)
     86  REAL, SAVE, ALLOCATABLE :: d_u_oli(:, :), d_v_oli(:, :)
     87  !$OMP THREADPRIVATE(d_u_oli, d_v_oli)
     88  REAL, SAVE, ALLOCATABLE :: d_t_vdf(:, :), d_q_vdf(:, :), d_qbs_vdf(:, :), d_t_diss(:, :)
     89  !$OMP THREADPRIVATE( d_t_vdf, d_q_vdf, d_qbs_vdf, d_t_diss)
     90  REAL, SAVE, ALLOCATABLE :: d_u_vdf(:, :), d_v_vdf(:, :)
     91  !$OMP THREADPRIVATE(d_u_vdf, d_v_vdf)
     92  !nrlmd+jyg<
     93  REAL, SAVE, ALLOCATABLE :: d_t_vdf_w(:, :), d_q_vdf_w(:, :)
     94  !$OMP THREADPRIVATE( d_t_vdf_w, d_q_vdf_w)
     95  REAL, SAVE, ALLOCATABLE :: d_t_vdf_x(:, :), d_q_vdf_x(:, :)
     96  !$OMP THREADPRIVATE( d_t_vdf_x, d_q_vdf_x)
     97  REAL, SAVE, ALLOCATABLE :: d_t_bsss(:, :), d_q_bsss(:, :), d_qbs_bsss(:, :)
     98  !$OMP THREADPRIVATE( d_t_bsss,d_q_bsss, d_qbs_bsss)
     99  !>nrlmd+jyg
     100  REAL, SAVE, ALLOCATABLE :: d_t_oro(:, :)
     101  !$OMP THREADPRIVATE(d_t_oro)
     102  REAL, SAVE, ALLOCATABLE :: d_u_oro(:, :), d_v_oro(:, :)
     103  !$OMP THREADPRIVATE(d_u_oro, d_v_oro)
     104  REAL, SAVE, ALLOCATABLE :: d_t_oro_gw(:, :)
     105  !$OMP THREADPRIVATE(d_t_oro_gw)
     106  REAL, SAVE, ALLOCATABLE :: d_u_oro_gw(:, :), d_v_oro_gw(:, :)
     107  !$OMP THREADPRIVATE(d_u_oro_gw, d_v_oro_gw)
     108  REAL, SAVE, ALLOCATABLE :: d_t_lif(:, :)
     109  !$OMP THREADPRIVATE(d_t_lif)
     110  REAL, SAVE, ALLOCATABLE :: d_u_lif(:, :), d_v_lif(:, :)
     111  !$OMP THREADPRIVATE(d_u_lif, d_v_lif)
     112  ! Tendances Ondes de G non oro (runs strato).
     113  REAL, SAVE, ALLOCATABLE :: du_gwd_hines(:, :)
     114  !$OMP THREADPRIVATE(du_gwd_hines)
     115  REAL, SAVE, ALLOCATABLE :: dv_gwd_hines(:, :)
     116  !$OMP THREADPRIVATE(dv_gwd_hines)
     117  REAL, SAVE, ALLOCATABLE :: dv_gwd_rando(:, :)
     118  !$OMP THREADPRIVATE(dv_gwd_rando)
     119  REAL, SAVE, ALLOCATABLE :: dv_gwd_front(:, :)
     120  !$OMP THREADPRIVATE(dv_gwd_front)
     121  REAL, SAVE, ALLOCATABLE :: east_gwstress(:, :)
     122  !$OMP THREADPRIVATE(east_gwstress)
     123  REAL, SAVE, ALLOCATABLE :: west_gwstress(:, :)
     124  !$OMP THREADPRIVATE(west_gwstress)
     125  REAL, SAVE, ALLOCATABLE :: d_t_hin(:, :)
     126  !$OMP THREADPRIVATE(d_t_hin)
     127  ! tendance due a l'oxydation du methane
     128  REAL, SAVE, ALLOCATABLE :: d_q_ch4(:, :)
     129  !$OMP THREADPRIVATE(d_q_ch4)
    129130#ifdef ISO
    130131      REAL, SAVE, ALLOCATABLE :: xt_seri(:,:,:)
     
    172173#endif
    173174
    174 ! tendance du a la conersion Ec -> E thermique
    175       REAL, SAVE, ALLOCATABLE :: d_t_ec(:,:)
    176       !$OMP THREADPRIVATE(d_t_ec)
    177       REAL, SAVE, ALLOCATABLE :: d_ts(:,:), d_tr(:,:,:)
    178       !$OMP THREADPRIVATE(d_ts, d_tr)
    179 
    180 ! diagnostique pour le rayonnement
    181       REAL, SAVE, ALLOCATABLE :: topswad_aero(:), solswad_aero(:)      ! diag
    182       !$OMP THREADPRIVATE(topswad_aero,solswad_aero)
    183       REAL, SAVE, ALLOCATABLE :: topswai_aero(:), solswai_aero(:)      ! diag
    184       !$OMP THREADPRIVATE(topswai_aero,solswai_aero)
    185       REAL, SAVE, ALLOCATABLE :: topswad0_aero(:), solswad0_aero(:)     ! diag
    186       !$OMP THREADPRIVATE(topswad0_aero,solswad0_aero)
    187       REAL, SAVE, ALLOCATABLE :: topsw_aero(:,:),  solsw_aero(:,:)      ! diag
    188       !$OMP THREADPRIVATE(topsw_aero,solsw_aero)
    189       REAL, SAVE, ALLOCATABLE :: topsw0_aero(:,:), solsw0_aero(:,:)     ! diag
    190       !$OMP THREADPRIVATE(topsw0_aero,solsw0_aero)
    191       REAL, SAVE, ALLOCATABLE :: topswcf_aero(:,:),  solswcf_aero(:,:)  ! diag
    192       !$OMP THREADPRIVATE(topswcf_aero,solswcf_aero)
    193 ! LW radiation diagnostics CK
    194       REAL, SAVE, ALLOCATABLE :: toplwad_aero(:), sollwad_aero(:)      ! diag
    195       !$OMP THREADPRIVATE(toplwad_aero,sollwad_aero)
    196       REAL, SAVE, ALLOCATABLE :: toplwai_aero(:), sollwai_aero(:)      ! diag
    197       !$OMP THREADPRIVATE(toplwai_aero,sollwai_aero)
    198       REAL, SAVE, ALLOCATABLE :: toplwad0_aero(:), sollwad0_aero(:)     ! diag
    199       !$OMP THREADPRIVATE(toplwad0_aero,sollwad0_aero)
    200 ! Special RRTM
    201       REAL, SAVE, ALLOCATABLE :: ZLWFT0_i(:,:),  ZSWFT0_i(:,:)      ! diag
    202       !$OMP THREADPRIVATE(ZLWFT0_i,ZSWFT0_i)
    203       REAL, SAVE, ALLOCATABLE :: ZFLDN0(:,:),  ZFLUP0(:,:)      ! diag
    204       !$OMP THREADPRIVATE(ZFLDN0,ZFLUP0)
    205       REAL, SAVE, ALLOCATABLE :: ZFSDN0(:,:),  ZFSUP0(:,:)      ! diag
    206       !$OMP THREADPRIVATE(ZFSDN0,ZFSUP0)
    207 !
    208       REAL, SAVE, ALLOCATABLE :: stratomask(:,:)
    209       !$OMP THREADPRIVATE(stratomask)
    210       REAL, SAVE, ALLOCATABLE :: tausum_aero(:,:,:)
    211       !$OMP THREADPRIVATE(tausum_aero)
    212       REAL, SAVE, ALLOCATABLE :: drytausum_aero(:,:)
    213       !$OMP THREADPRIVATE(drytausum_aero)
    214       REAL, SAVE, ALLOCATABLE :: tau3d_aero(:,:,:,:)
    215       !$OMP THREADPRIVATE(tau3d_aero)
    216       REAL, SAVE, ALLOCATABLE :: dNovrN(:)
    217       !$OMP THREADPRIVATE(dNovrN)
    218       REAL, SAVE, ALLOCATABLE :: zfice(:,:)
    219       !$OMP THREADPRIVATE(zfice)
    220       REAL, SAVE, ALLOCATABLE :: od443aer(:)
    221       !$OMP THREADPRIVATE(od443aer)
    222       REAL, SAVE, ALLOCATABLE :: od550aer(:)
    223       !$OMP THREADPRIVATE(od550aer)
    224       REAL, SAVE, ALLOCATABLE :: dryod550aer(:)
    225       !$OMP THREADPRIVATE(dryod550aer)
    226       REAL, SAVE, ALLOCATABLE :: abs550aer(:)
    227       !$OMP THREADPRIVATE(abs550aer)
    228       REAL, SAVE, ALLOCATABLE :: od865aer(:)
    229       !$OMP THREADPRIVATE(od865aer)
    230       REAL, SAVE, ALLOCATABLE :: ec550aer(:,:)
    231       !$OMP THREADPRIVATE(ec550aer)
    232       REAL, SAVE, ALLOCATABLE :: od550lt1aer(:)
    233       !$OMP THREADPRIVATE(od550lt1aer)
    234       REAL, SAVE, ALLOCATABLE :: sconcso4(:)
    235       !$OMP THREADPRIVATE(sconcso4)
    236       REAL, SAVE, ALLOCATABLE :: sconcno3(:)
    237       !$OMP THREADPRIVATE(sconcno3)
    238       REAL, SAVE, ALLOCATABLE :: sconcoa(:)
    239       !$OMP THREADPRIVATE(sconcoa)
    240       REAL, SAVE, ALLOCATABLE :: sconcbc(:)
    241       !$OMP THREADPRIVATE(sconcbc)
    242       REAL, SAVE, ALLOCATABLE :: sconcss(:)
    243       !$OMP THREADPRIVATE(sconcss)
    244       REAL, SAVE, ALLOCATABLE :: sconcdust(:)
    245       !$OMP THREADPRIVATE(sconcdust)
    246       REAL, SAVE, ALLOCATABLE :: concso4(:,:)
    247       !$OMP THREADPRIVATE(concso4)
    248       REAL, SAVE, ALLOCATABLE :: concno3(:,:)
    249       !$OMP THREADPRIVATE(concno3)
    250       REAL, SAVE, ALLOCATABLE :: concoa(:,:)
    251       !$OMP THREADPRIVATE(concoa)
    252       REAL, SAVE, ALLOCATABLE :: concbc(:,:)
    253       !$OMP THREADPRIVATE(concbc)
    254       REAL, SAVE, ALLOCATABLE :: concss(:,:)
    255       !$OMP THREADPRIVATE(concss)
    256       REAL, SAVE, ALLOCATABLE :: concdust(:,:)
    257       !$OMP THREADPRIVATE(concdust)
    258       REAL, SAVE, ALLOCATABLE :: loadso4(:)
    259       !$OMP THREADPRIVATE(loadso4)
    260       REAL, SAVE, ALLOCATABLE :: loadoa(:)
    261       !$OMP THREADPRIVATE(loadoa)
    262       REAL, SAVE, ALLOCATABLE :: loadbc(:)
    263       !$OMP THREADPRIVATE(loadbc)
    264       REAL, SAVE, ALLOCATABLE :: loadss(:)
    265       !$OMP THREADPRIVATE(loadss)
    266       REAL, SAVE, ALLOCATABLE :: loaddust(:)
    267       !$OMP THREADPRIVATE(loaddust)
    268       REAL, SAVE, ALLOCATABLE :: loadno3(:)
    269       !$OMP THREADPRIVATE(loadno3)
    270       REAL, SAVE, ALLOCATABLE :: load_tmp1(:), load_tmp2(:)
    271       !$OMP THREADPRIVATE(load_tmp1, load_tmp2)
    272       REAL, SAVE, ALLOCATABLE :: load_tmp3(:), load_tmp4(:)
    273       !$OMP THREADPRIVATE(load_tmp3, load_tmp4)
    274       REAL, SAVE, ALLOCATABLE :: load_tmp5(:), load_tmp6(:)
    275       !$OMP THREADPRIVATE(load_tmp5, load_tmp6)
    276       REAL, SAVE, ALLOCATABLE :: load_tmp7(:), load_tmp8(:)
    277       !$OMP THREADPRIVATE(load_tmp7, load_tmp8)
    278       REAL, SAVE, ALLOCATABLE :: load_tmp9(:), load_tmp10(:)
    279       !$OMP THREADPRIVATE(load_tmp9, load_tmp10)
    280 
    281 !IM ajout variables CFMIP2/CMIP5
    282       REAL,ALLOCATABLE,SAVE :: topswad_aerop(:), solswad_aerop(:)
    283 !$OMP THREADPRIVATE(topswad_aerop, solswad_aerop)
    284       REAL,ALLOCATABLE,SAVE :: topswai_aerop(:), solswai_aerop(:)
    285 !$OMP THREADPRIVATE(topswai_aerop, solswai_aerop)
    286       REAL,ALLOCATABLE,SAVE :: topswad0_aerop(:), solswad0_aerop(:)
    287 !$OMP THREADPRIVATE(topswad0_aerop, solswad0_aerop)
    288       REAL,ALLOCATABLE,SAVE :: topsw_aerop(:,:), topsw0_aerop(:,:) 
    289 !$OMP THREADPRIVATE(topsw_aerop, topsw0_aerop)
    290       REAL,ALLOCATABLE,SAVE :: solsw_aerop(:,:), solsw0_aerop(:,:)
    291 !$OMP THREADPRIVATE(solsw_aerop, solsw0_aerop)
    292       REAL,ALLOCATABLE,SAVE :: topswcf_aerop(:,:), solswcf_aerop(:,:)
    293 !$OMP THREADPRIVATE(topswcf_aerop, solswcf_aerop)
    294 
    295 ! additional LW variables CK
    296       REAL,ALLOCATABLE,SAVE :: toplwad_aerop(:), sollwad_aerop(:)
    297 !$OMP THREADPRIVATE(toplwad_aerop, sollwad_aerop)
    298       REAL,ALLOCATABLE,SAVE :: toplwai_aerop(:), sollwai_aerop(:)
    299 !$OMP THREADPRIVATE(toplwai_aerop, sollwai_aerop)
    300       REAL,ALLOCATABLE,SAVE :: toplwad0_aerop(:), sollwad0_aerop(:)
    301 !$OMP THREADPRIVATE(toplwad0_aerop, sollwad0_aerop)
    302 
    303 !AI 08 2023 ajout pour Ecrad
    304       REAL,ALLOCATABLE,SAVE :: topswad_aero_s2(:), solswad_aero_s2(:)
    305 !$OMP THREADPRIVATE(topswad_aero_s2, solswad_aero_s2)
    306       REAL,ALLOCATABLE,SAVE :: topswai_aero_s2(:), solswai_aero_s2(:)
    307 !$OMP THREADPRIVATE(topswai_aero_s2, solswai_aero_s2)
    308       REAL,ALLOCATABLE,SAVE :: topswad0_aero_s2(:), solswad0_aero_s2(:)
    309 !$OMP THREADPRIVATE(topswad0_aero_s2, solswad0_aero_s2)
    310       REAL,ALLOCATABLE,SAVE :: topsw_aero_s2(:,:), topsw0_aero_s2(:,:)
    311 !$OMP THREADPRIVATE(topsw_aero_s2, topsw0_aero_s2)
    312       REAL,ALLOCATABLE,SAVE :: solsw_aero_s2(:,:), solsw0_aero_s2(:,:)
    313 !$OMP THREADPRIVATE(solsw_aero_s2, solsw0_aero_s2)
    314       REAL,ALLOCATABLE,SAVE :: topswcf_aero_s2(:,:), solswcf_aero_s2(:,:)
    315 !$OMP THREADPRIVATE(topswcf_aero_s2, solswcf_aero_s2)
    316 ! additional LW variables CK
    317       REAL,ALLOCATABLE,SAVE :: toplwad_aero_s2(:), sollwad_aero_s2(:)
    318 !$OMP THREADPRIVATE(toplwad_aero_s2, sollwad_aero_s2)
    319       REAL,ALLOCATABLE,SAVE :: toplwai_aero_s2(:), sollwai_aero_s2(:)
    320 !$OMP THREADPRIVATE(toplwai_aero_s2, sollwai_aero_s2)
    321       REAL,ALLOCATABLE,SAVE :: toplwad0_aero_s2(:), sollwad0_aero_s2(:)
    322 !$OMP THREADPRIVATE(toplwad0_aero_s2, sollwad0_aero_s2)
    323 
    324 !Ajout de celles n??cessaires au phys_output_write_mod
    325       REAL, SAVE, ALLOCATABLE :: tal1(:), pal1(:), pab1(:), pab2(:)
    326 !$OMP THREADPRIVATE(tal1, pal1, pab1, pab2)
    327       REAL, SAVE, ALLOCATABLE :: ptstar(:), pt0(:), slp(:)
    328 !$OMP THREADPRIVATE(ptstar, pt0, slp)
    329       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: sens, flwp, fiwp
    330 !$OMP THREADPRIVATE(sens, flwp, fiwp)
    331 !!
    332 !FC
    333       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zxfluxt, zxfluxq
    334 !$OMP THREADPRIVATE(zxfluxt, zxfluxq)
    335 !FC
    336 !!         Wake variables
    337       REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: alp_wake
    338 !$OMP THREADPRIVATE(alp_wake)           
    339 !!jyg!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: wake_h,wake_k
    340       REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: wake_h
    341       INTEGER,ALLOCATABLE,SAVE,DIMENSION(:)        :: wake_k
    342 !$OMP THREADPRIVATE(wake_h,wake_k)                       
    343     REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)            :: wake_omg
    344 !$OMP THREADPRIVATE(wake_omg)                     
    345     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_wk, d_deltaq_wk
    346 !$OMP THREADPRIVATE(d_deltat_wk, d_deltaq_wk)
    347       REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: d_s_wk, d_s_a_wk, d_dens_wk, d_dens_a_wk
    348 !$OMP THREADPRIVATE(d_s_wk, d_s_a_wk, d_dens_wk, d_dens_a_wk)
    349     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_wk_gw, d_deltaq_wk_gw
    350 !$OMP THREADPRIVATE(d_deltat_wk_gw, d_deltaq_wk_gw)
    351     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_vdf, d_deltaq_vdf
    352 !$OMP THREADPRIVATE(d_deltat_vdf, d_deltaq_vdf)
    353 !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_vdf, d_dens_vdf
    354 !!!$OMP THREADPRIVATE(d_s_vdf, d_dens_vdf)
    355     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_the, d_deltaq_the
    356 !$OMP THREADPRIVATE(d_deltat_the, d_deltaq_the)
    357 !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_the, d_dens_the
    358 !!!$OMP THREADPRIVATE(d_s_the, d_dens_the)
    359       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)          :: d_deltat_ajs_cv, d_deltaq_ajs_cv
    360 !$OMP THREADPRIVATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
     175  ! tendance du a la conersion Ec -> E thermique
     176  REAL, SAVE, ALLOCATABLE :: d_t_ec(:, :)
     177  !$OMP THREADPRIVATE(d_t_ec)
     178  REAL, SAVE, ALLOCATABLE :: d_ts(:, :), d_tr(:, :, :)
     179  !$OMP THREADPRIVATE(d_ts, d_tr)
     180
     181  ! diagnostique pour le rayonnement
     182  REAL, SAVE, ALLOCATABLE :: topswad_aero(:), solswad_aero(:)      ! diag
     183  !$OMP THREADPRIVATE(topswad_aero,solswad_aero)
     184  REAL, SAVE, ALLOCATABLE :: topswai_aero(:), solswai_aero(:)      ! diag
     185  !$OMP THREADPRIVATE(topswai_aero,solswai_aero)
     186  REAL, SAVE, ALLOCATABLE :: topswad0_aero(:), solswad0_aero(:)     ! diag
     187  !$OMP THREADPRIVATE(topswad0_aero,solswad0_aero)
     188  REAL, SAVE, ALLOCATABLE :: topsw_aero(:, :), solsw_aero(:, :)      ! diag
     189  !$OMP THREADPRIVATE(topsw_aero,solsw_aero)
     190  REAL, SAVE, ALLOCATABLE :: topsw0_aero(:, :), solsw0_aero(:, :)     ! diag
     191  !$OMP THREADPRIVATE(topsw0_aero,solsw0_aero)
     192  REAL, SAVE, ALLOCATABLE :: topswcf_aero(:, :), solswcf_aero(:, :)  ! diag
     193  !$OMP THREADPRIVATE(topswcf_aero,solswcf_aero)
     194  ! LW radiation diagnostics CK
     195  REAL, SAVE, ALLOCATABLE :: toplwad_aero(:), sollwad_aero(:)      ! diag
     196  !$OMP THREADPRIVATE(toplwad_aero,sollwad_aero)
     197  REAL, SAVE, ALLOCATABLE :: toplwai_aero(:), sollwai_aero(:)      ! diag
     198  !$OMP THREADPRIVATE(toplwai_aero,sollwai_aero)
     199  REAL, SAVE, ALLOCATABLE :: toplwad0_aero(:), sollwad0_aero(:)     ! diag
     200  !$OMP THREADPRIVATE(toplwad0_aero,sollwad0_aero)
     201  ! Special RRTM
     202  REAL, SAVE, ALLOCATABLE :: ZLWFT0_i(:, :), ZSWFT0_i(:, :)      ! diag
     203  !$OMP THREADPRIVATE(ZLWFT0_i,ZSWFT0_i)
     204  REAL, SAVE, ALLOCATABLE :: ZFLDN0(:, :), ZFLUP0(:, :)      ! diag
     205  !$OMP THREADPRIVATE(ZFLDN0,ZFLUP0)
     206  REAL, SAVE, ALLOCATABLE :: ZFSDN0(:, :), ZFSUP0(:, :)      ! diag
     207  !$OMP THREADPRIVATE(ZFSDN0,ZFSUP0)
     208  !
     209  REAL, SAVE, ALLOCATABLE :: stratomask(:, :)
     210  !$OMP THREADPRIVATE(stratomask)
     211  REAL, SAVE, ALLOCATABLE :: tausum_aero(:, :, :)
     212  !$OMP THREADPRIVATE(tausum_aero)
     213  REAL, SAVE, ALLOCATABLE :: drytausum_aero(:, :)
     214  !$OMP THREADPRIVATE(drytausum_aero)
     215  REAL, SAVE, ALLOCATABLE :: tau3d_aero(:, :, :, :)
     216  !$OMP THREADPRIVATE(tau3d_aero)
     217  REAL, SAVE, ALLOCATABLE :: dNovrN(:)
     218  !$OMP THREADPRIVATE(dNovrN)
     219  REAL, SAVE, ALLOCATABLE :: zfice(:, :)
     220  !$OMP THREADPRIVATE(zfice)
     221  REAL, SAVE, ALLOCATABLE :: od443aer(:)
     222  !$OMP THREADPRIVATE(od443aer)
     223  REAL, SAVE, ALLOCATABLE :: od550aer(:)
     224  !$OMP THREADPRIVATE(od550aer)
     225  REAL, SAVE, ALLOCATABLE :: dryod550aer(:)
     226  !$OMP THREADPRIVATE(dryod550aer)
     227  REAL, SAVE, ALLOCATABLE :: abs550aer(:)
     228  !$OMP THREADPRIVATE(abs550aer)
     229  REAL, SAVE, ALLOCATABLE :: od865aer(:)
     230  !$OMP THREADPRIVATE(od865aer)
     231  REAL, SAVE, ALLOCATABLE :: ec550aer(:, :)
     232  !$OMP THREADPRIVATE(ec550aer)
     233  REAL, SAVE, ALLOCATABLE :: od550lt1aer(:)
     234  !$OMP THREADPRIVATE(od550lt1aer)
     235  REAL, SAVE, ALLOCATABLE :: sconcso4(:)
     236  !$OMP THREADPRIVATE(sconcso4)
     237  REAL, SAVE, ALLOCATABLE :: sconcno3(:)
     238  !$OMP THREADPRIVATE(sconcno3)
     239  REAL, SAVE, ALLOCATABLE :: sconcoa(:)
     240  !$OMP THREADPRIVATE(sconcoa)
     241  REAL, SAVE, ALLOCATABLE :: sconcbc(:)
     242  !$OMP THREADPRIVATE(sconcbc)
     243  REAL, SAVE, ALLOCATABLE :: sconcss(:)
     244  !$OMP THREADPRIVATE(sconcss)
     245  REAL, SAVE, ALLOCATABLE :: sconcdust(:)
     246  !$OMP THREADPRIVATE(sconcdust)
     247  REAL, SAVE, ALLOCATABLE :: concso4(:, :)
     248  !$OMP THREADPRIVATE(concso4)
     249  REAL, SAVE, ALLOCATABLE :: concno3(:, :)
     250  !$OMP THREADPRIVATE(concno3)
     251  REAL, SAVE, ALLOCATABLE :: concoa(:, :)
     252  !$OMP THREADPRIVATE(concoa)
     253  REAL, SAVE, ALLOCATABLE :: concbc(:, :)
     254  !$OMP THREADPRIVATE(concbc)
     255  REAL, SAVE, ALLOCATABLE :: concss(:, :)
     256  !$OMP THREADPRIVATE(concss)
     257  REAL, SAVE, ALLOCATABLE :: concdust(:, :)
     258  !$OMP THREADPRIVATE(concdust)
     259  REAL, SAVE, ALLOCATABLE :: loadso4(:)
     260  !$OMP THREADPRIVATE(loadso4)
     261  REAL, SAVE, ALLOCATABLE :: loadoa(:)
     262  !$OMP THREADPRIVATE(loadoa)
     263  REAL, SAVE, ALLOCATABLE :: loadbc(:)
     264  !$OMP THREADPRIVATE(loadbc)
     265  REAL, SAVE, ALLOCATABLE :: loadss(:)
     266  !$OMP THREADPRIVATE(loadss)
     267  REAL, SAVE, ALLOCATABLE :: loaddust(:)
     268  !$OMP THREADPRIVATE(loaddust)
     269  REAL, SAVE, ALLOCATABLE :: loadno3(:)
     270  !$OMP THREADPRIVATE(loadno3)
     271  REAL, SAVE, ALLOCATABLE :: load_tmp1(:), load_tmp2(:)
     272  !$OMP THREADPRIVATE(load_tmp1, load_tmp2)
     273  REAL, SAVE, ALLOCATABLE :: load_tmp3(:), load_tmp4(:)
     274  !$OMP THREADPRIVATE(load_tmp3, load_tmp4)
     275  REAL, SAVE, ALLOCATABLE :: load_tmp5(:), load_tmp6(:)
     276  !$OMP THREADPRIVATE(load_tmp5, load_tmp6)
     277  REAL, SAVE, ALLOCATABLE :: load_tmp7(:), load_tmp8(:)
     278  !$OMP THREADPRIVATE(load_tmp7, load_tmp8)
     279  REAL, SAVE, ALLOCATABLE :: load_tmp9(:), load_tmp10(:)
     280  !$OMP THREADPRIVATE(load_tmp9, load_tmp10)
     281
     282  !IM ajout variables CFMIP2/CMIP5
     283  REAL, ALLOCATABLE, SAVE :: topswad_aerop(:), solswad_aerop(:)
     284  !$OMP THREADPRIVATE(topswad_aerop, solswad_aerop)
     285  REAL, ALLOCATABLE, SAVE :: topswai_aerop(:), solswai_aerop(:)
     286  !$OMP THREADPRIVATE(topswai_aerop, solswai_aerop)
     287  REAL, ALLOCATABLE, SAVE :: topswad0_aerop(:), solswad0_aerop(:)
     288  !$OMP THREADPRIVATE(topswad0_aerop, solswad0_aerop)
     289  REAL, ALLOCATABLE, SAVE :: topsw_aerop(:, :), topsw0_aerop(:, :)
     290  !$OMP THREADPRIVATE(topsw_aerop, topsw0_aerop)
     291  REAL, ALLOCATABLE, SAVE :: solsw_aerop(:, :), solsw0_aerop(:, :)
     292  !$OMP THREADPRIVATE(solsw_aerop, solsw0_aerop)
     293  REAL, ALLOCATABLE, SAVE :: topswcf_aerop(:, :), solswcf_aerop(:, :)
     294  !$OMP THREADPRIVATE(topswcf_aerop, solswcf_aerop)
     295
     296  ! additional LW variables CK
     297  REAL, ALLOCATABLE, SAVE :: toplwad_aerop(:), sollwad_aerop(:)
     298  !$OMP THREADPRIVATE(toplwad_aerop, sollwad_aerop)
     299  REAL, ALLOCATABLE, SAVE :: toplwai_aerop(:), sollwai_aerop(:)
     300  !$OMP THREADPRIVATE(toplwai_aerop, sollwai_aerop)
     301  REAL, ALLOCATABLE, SAVE :: toplwad0_aerop(:), sollwad0_aerop(:)
     302  !$OMP THREADPRIVATE(toplwad0_aerop, sollwad0_aerop)
     303
     304  !AI 08 2023 ajout pour Ecrad
     305  REAL, ALLOCATABLE, SAVE :: topswad_aero_s2(:), solswad_aero_s2(:)
     306  !$OMP THREADPRIVATE(topswad_aero_s2, solswad_aero_s2)
     307  REAL, ALLOCATABLE, SAVE :: topswai_aero_s2(:), solswai_aero_s2(:)
     308  !$OMP THREADPRIVATE(topswai_aero_s2, solswai_aero_s2)
     309  REAL, ALLOCATABLE, SAVE :: topswad0_aero_s2(:), solswad0_aero_s2(:)
     310  !$OMP THREADPRIVATE(topswad0_aero_s2, solswad0_aero_s2)
     311  REAL, ALLOCATABLE, SAVE :: topsw_aero_s2(:, :), topsw0_aero_s2(:, :)
     312  !$OMP THREADPRIVATE(topsw_aero_s2, topsw0_aero_s2)
     313  REAL, ALLOCATABLE, SAVE :: solsw_aero_s2(:, :), solsw0_aero_s2(:, :)
     314  !$OMP THREADPRIVATE(solsw_aero_s2, solsw0_aero_s2)
     315  REAL, ALLOCATABLE, SAVE :: topswcf_aero_s2(:, :), solswcf_aero_s2(:, :)
     316  !$OMP THREADPRIVATE(topswcf_aero_s2, solswcf_aero_s2)
     317  ! additional LW variables CK
     318  REAL, ALLOCATABLE, SAVE :: toplwad_aero_s2(:), sollwad_aero_s2(:)
     319  !$OMP THREADPRIVATE(toplwad_aero_s2, sollwad_aero_s2)
     320  REAL, ALLOCATABLE, SAVE :: toplwai_aero_s2(:), sollwai_aero_s2(:)
     321  !$OMP THREADPRIVATE(toplwai_aero_s2, sollwai_aero_s2)
     322  REAL, ALLOCATABLE, SAVE :: toplwad0_aero_s2(:), sollwad0_aero_s2(:)
     323  !$OMP THREADPRIVATE(toplwad0_aero_s2, sollwad0_aero_s2)
     324
     325  !Ajout de celles n??cessaires au phys_output_write_mod
     326  REAL, SAVE, ALLOCATABLE :: tal1(:), pal1(:), pab1(:), pab2(:)
     327  !$OMP THREADPRIVATE(tal1, pal1, pab1, pab2)
     328  REAL, SAVE, ALLOCATABLE :: ptstar(:), pt0(:), slp(:)
     329  !$OMP THREADPRIVATE(ptstar, pt0, slp)
     330  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sens, flwp, fiwp
     331  !$OMP THREADPRIVATE(sens, flwp, fiwp)
     332  !!
     333  !FC
     334  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: zxfluxt, zxfluxq
     335  !$OMP THREADPRIVATE(zxfluxt, zxfluxq)
     336  !FC
     337  !!         Wake variables
     338  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_wake
     339  !$OMP THREADPRIVATE(alp_wake)
     340  !!jyg!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: wake_h,wake_k
     341  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: wake_h
     342  INTEGER, ALLOCATABLE, SAVE, DIMENSION(:) :: wake_k
     343  !$OMP THREADPRIVATE(wake_h,wake_k)
     344  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wake_omg
     345  !$OMP THREADPRIVATE(wake_omg)
     346  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_wk, d_deltaq_wk
     347  !$OMP THREADPRIVATE(d_deltat_wk, d_deltaq_wk)
     348  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: d_s_wk, d_s_a_wk, d_dens_wk, d_dens_a_wk
     349  !$OMP THREADPRIVATE(d_s_wk, d_s_a_wk, d_dens_wk, d_dens_a_wk)
     350  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_wk_gw, d_deltaq_wk_gw
     351  !$OMP THREADPRIVATE(d_deltat_wk_gw, d_deltaq_wk_gw)
     352  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_vdf, d_deltaq_vdf
     353  !$OMP THREADPRIVATE(d_deltat_vdf, d_deltaq_vdf)
     354  !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_vdf, d_dens_vdf
     355  !!!$OMP THREADPRIVATE(d_s_vdf, d_dens_vdf)
     356  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_the, d_deltaq_the
     357  !$OMP THREADPRIVATE(d_deltat_the, d_deltaq_the)
     358  !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_the, d_dens_the
     359  !!!$OMP THREADPRIVATE(d_s_the, d_dens_the)
     360  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: d_deltat_ajs_cv, d_deltaq_ajs_cv
     361  !$OMP THREADPRIVATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
    361362#ifdef ISO
    362363    REAL, SAVE, ALLOCATABLE,DIMENSION(:,:,:)          :: d_deltaxt_wk
     
    371372!$OMP THREADPRIVATE(d_deltaxt_ajs_cv)
    372373#endif                       
    373 !!         End of Wake variables
    374 !!
    375       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: bils
    376 !$OMP THREADPRIVATE(bils)
    377       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragm, cdragh
    378 !$OMP THREADPRIVATE(cdragm, cdragh)
    379       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cldh, cldl, cldm, cldq, cldt, qsat2m
    380 !$OMP THREADPRIVATE(cldh, cldl, cldm, cldq, cldt, qsat2m)
    381 !AS: cldhjn, cldljn, cldmjn,cldtjn pas utilisés en tant que variables, juste noms de diagnostics
    382       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: JrNt
    383 !$OMP THREADPRIVATE(JrNt)
    384       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget
    385 !$OMP THREADPRIVATE(dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget)
    386       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zustar, zu10m, zv10m, rh2m
    387 !$OMP THREADPRIVATE(zustar, zu10m, zv10m, rh2m)
    388       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_lcl, s_pblh, s_pblt, s_therm
    389 !$OMP THREADPRIVATE(s_lcl, s_pblh, s_pblt, s_therm)
    390 !
    391 !nrlmd+jyg<
    392       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_pblh_x, s_pblh_w
    393 !$OMP THREADPRIVATE(s_pblh_x, s_pblh_w)
    394       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_lcl_x, s_lcl_w
    395 !$OMP THREADPRIVATE(s_lcl_x, s_lcl_w)
    396 !>nrlmd+jyg
    397 !
    398       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: slab_wfbils
    399 !$OMP THREADPRIVATE(slab_wfbils)
    400       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte
    401 !$OMP THREADPRIVATE(tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte)
    402       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxustartlic, zxrhoslic, zxqsaltlic
    403 !$OMP THREADPRIVATE(zxustartlic, zxrhoslic, zxqsaltlic)
    404       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfqcalving
    405 !$OMP THREADPRIVATE(zxfqcalving)
    406       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfluxlat, zxtsol, snow_lsc, zxfqfonte
    407 !$OMP THREADPRIVATE(zxfluxlat, zxtsol, snow_lsc, zxfqfonte)
    408       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxrunofflic
    409 !$OMP THREADPRIVATE(zxrunofflic)
    410       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxqsurf, rain_lsc, rain_num
    411 !$OMP THREADPRIVATE(zxqsurf, rain_lsc, rain_num)
     374  !!         End of Wake variables
     375  !!
     376  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: bils
     377  !$OMP THREADPRIVATE(bils)
     378  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cdragm, cdragh
     379  !$OMP THREADPRIVATE(cdragm, cdragh)
     380  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cldh, cldl, cldm, cldq, cldt, qsat2m
     381  !$OMP THREADPRIVATE(cldh, cldl, cldm, cldq, cldt, qsat2m)
     382  !AS: cldhjn, cldljn, cldmjn,cldtjn pas utilisés en tant que variables, juste noms de diagnostics
     383  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: JrNt
     384  !$OMP THREADPRIVATE(JrNt)
     385  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget
     386  !$OMP THREADPRIVATE(dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget)
     387  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zustar, zu10m, zv10m, rh2m
     388  !$OMP THREADPRIVATE(zustar, zu10m, zv10m, rh2m)
     389  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: s_lcl, s_pblh, s_pblt, s_therm
     390  !$OMP THREADPRIVATE(s_lcl, s_pblh, s_pblt, s_therm)
     391  !
     392  !nrlmd+jyg<
     393  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: s_pblh_x, s_pblh_w
     394  !$OMP THREADPRIVATE(s_pblh_x, s_pblh_w)
     395  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: s_lcl_x, s_lcl_w
     396  !$OMP THREADPRIVATE(s_lcl_x, s_lcl_w)
     397  !>nrlmd+jyg
     398  !
     399  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: slab_wfbils
     400  !$OMP THREADPRIVATE(slab_wfbils)
     401  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte
     402  !$OMP THREADPRIVATE(tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte)
     403  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxustartlic, zxrhoslic, zxqsaltlic
     404  !$OMP THREADPRIVATE(zxustartlic, zxrhoslic, zxqsaltlic)
     405  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfqcalving
     406  !$OMP THREADPRIVATE(zxfqcalving)
     407  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfluxlat, zxtsol, snow_lsc, zxfqfonte
     408  !$OMP THREADPRIVATE(zxfluxlat, zxtsol, snow_lsc, zxfqfonte)
     409  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxrunofflic
     410  !$OMP THREADPRIVATE(zxrunofflic)
     411  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxqsurf, rain_lsc, rain_num
     412  !$OMP THREADPRIVATE(zxqsurf, rain_lsc, rain_num)
    412413#ifdef ISO
    413414      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtevap,xtprw
     
    425426!$OMP THREADPRIVATE(xtrain_lsc)
    426427#endif
    427 !
    428 !jyg+nrlmd<
    429 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    430 !                                                                          c
    431 !       Declarations liees a la couche limite differentiee w-x             c
    432 !                                                                          c
    433 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    434       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: sens_x, sens_w
    435 !$OMP THREADPRIVATE(sens_x, sens_w)
    436       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfluxlat_x, zxfluxlat_w
    437 !$OMP THREADPRIVATE(zxfluxlat_x, zxfluxlat_w)
    438       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: delta_qsurf
    439 !$OMP THREADPRIVATE(delta_qsurf)
    440 !jyg<
    441 !!! Entrees supplementaires couche-limite
    442 !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: t_x, t_w
    443 !!!$OMP THREADPRIVATE(t_x, t_w)
    444 !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: q_x, q_w
    445 !!!$OMP THREADPRIVATE(q_x, q_w)
    446 !>jyg
    447 !!! Sorties ferret
    448       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dtvdf_x, dtvdf_w
    449 !$OMP THREADPRIVATE(dtvdf_x, dtvdf_w)
    450       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dqvdf_x, dqvdf_w
    451 !$OMP THREADPRIVATE(dqvdf_x, dqvdf_w)
    452 ! Variables supplementaires dans physiq.F relative au splitting de la surface
    453       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: pbl_tke_input
    454 !$OMP THREADPRIVATE(pbl_tke_input)
    455 ! Entree supplementaire Thermiques :
    456       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: t_therm, q_therm, u_therm, v_therm
    457 !$OMP THREADPRIVATE(t_therm, q_therm, u_therm, v_therm)
    458       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragh_x, cdragh_w
    459 !$OMP THREADPRIVATE(cdragh_x, cdragh_w)
    460       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragm_x, cdragm_w
    461 !$OMP THREADPRIVATE(cdragm_x, cdragm_w)
    462       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: kh, kh_x, kh_w
    463 !$OMP THREADPRIVATE(kh, kh_x, kh_w)
     428  !
     429  !jyg+nrlmd<
     430  !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     431  !                                                                          c
     432  !       Declarations liees a la couche limite differentiee w-x             c
     433  !                                                                          c
     434  !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     435  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sens_x, sens_w
     436  !$OMP THREADPRIVATE(sens_x, sens_w)
     437  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfluxlat_x, zxfluxlat_w
     438  !$OMP THREADPRIVATE(zxfluxlat_x, zxfluxlat_w)
     439  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: delta_qsurf
     440  !$OMP THREADPRIVATE(delta_qsurf)
     441  !jyg<
     442  !!! Entrees supplementaires couche-limite
     443  !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: t_x, t_w
     444  !!!$OMP THREADPRIVATE(t_x, t_w)
     445  !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: q_x, q_w
     446  !!!$OMP THREADPRIVATE(q_x, q_w)
     447  !>jyg
     448  !!! Sorties ferret
     449  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dtvdf_x, dtvdf_w
     450  !$OMP THREADPRIVATE(dtvdf_x, dtvdf_w)
     451  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dqvdf_x, dqvdf_w
     452  !$OMP THREADPRIVATE(dqvdf_x, dqvdf_w)
     453  ! Variables supplementaires dans physiq.F relative au splitting de la surface
     454  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: pbl_tke_input
     455  !$OMP THREADPRIVATE(pbl_tke_input)
     456  ! Entree supplementaire Thermiques :
     457  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: t_therm, q_therm, u_therm, v_therm
     458  !$OMP THREADPRIVATE(t_therm, q_therm, u_therm, v_therm)
     459  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cdragh_x, cdragh_w
     460  !$OMP THREADPRIVATE(cdragh_x, cdragh_w)
     461  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cdragm_x, cdragm_w
     462  !$OMP THREADPRIVATE(cdragm_x, cdragm_w)
     463  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: kh, kh_x, kh_w
     464  !$OMP THREADPRIVATE(kh, kh_x, kh_w)
    464465#ifdef ISO
    465466      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: dxtvdf_x, dxtvdf_w
     
    468469!$OMP THREADPRIVATE(xt_therm)
    469470#endif
    470 !!!
    471 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    472       LOGICAL, SAVE, ALLOCATABLE :: ptconv(:,:)
    473       !$OMP THREADPRIVATE(ptconv)
    474       REAL, SAVE, ALLOCATABLE :: ratqsc(:,:)
    475       !$OMP THREADPRIVATE(ratqsc)
    476 !>jyg+nrlmd
     471  !!!
     472  !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     473  LOGICAL, SAVE, ALLOCATABLE :: ptconv(:, :)
     474  !$OMP THREADPRIVATE(ptconv)
     475  REAL, SAVE, ALLOCATABLE :: ratqsc(:, :)
     476  !$OMP THREADPRIVATE(ratqsc)
     477  !>jyg+nrlmd
    477478  !
    478       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: wbeff, convoccur, zmax_th, zq2m, zt2m
    479 !$OMP THREADPRIVATE(wbeff, convoccur, zmax_th, zq2m, zt2m)
    480       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zt2m_min_mon, zt2m_max_mon
    481 !$OMP THREADPRIVATE(zt2m_min_mon, zt2m_max_mon)
    482       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: t2m_min_mon, t2m_max_mon
    483 !$OMP THREADPRIVATE(t2m_min_mon, t2m_max_mon)
    484       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: weak_inversion
    485 !$OMP THREADPRIVATE(weak_inversion)
    486       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_conv,alp_bl_det
    487 !$OMP THREADPRIVATE(alp_bl_conv,alp_bl_det)
    488       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_fluct_m,alp_bl_fluct_tke
    489 !$OMP THREADPRIVATE(alp_bl_fluct_m,alp_bl_fluct_tke)
    490       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_stat, n2, s2, strig, zcong, zlcl_th
    491 !$OMP THREADPRIVATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
    492       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: proba_notrig, random_notrig
    493 !$OMP THREADPRIVATE(proba_notrig, random_notrig)
    494       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: fsolsw, wfbils
    495 !$OMP THREADPRIVATE(fsolsw, wfbils)
    496       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wfevap
    497 !$OMP THREADPRIVATE(wfevap)
    498       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: t2m, fluxlat, fsollw,evap_pot
    499 !$OMP THREADPRIVATE(t2m, fluxlat, fsollw,evap_pot)
    500       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dnwd0, omega
    501 !$OMP THREADPRIVATE(dnwd0, omega)
    502       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: epmax_diag ! epmax_cape
    503 !$OMP THREADPRIVATE(epmax_diag)
    504 !
    505 !  Deep convective variables used in phytrac
    506       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ep ! epmax_cape
    507 !$OMP THREADPRIVATE(ep)
    508       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dnwd, upwd
    509 !$OMP THREADPRIVATE(dnwd, upwd)
    510       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: pmflxr, pmflxs
    511 !$OMP THREADPRIVATE(pmflxr, pmflxs)
    512       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wdtrainA, wdtrainS, wdtrainM
    513 !$OMP THREADPRIVATE(wdtrainA, wdtrainS, wdtrainM)
    514       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: da, mp
    515 !$OMP THREADPRIVATE(da, mp)
    516       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wght_cvfd
    517 !$OMP THREADPRIVATE(wght_cvfd)
    518       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:):: phi, phi2, elij, epmlmMm
    519 !$OMP THREADPRIVATE(phi, phi2, elij, epmlmMm)
    520       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: d1a, dam
    521 !$OMP THREADPRIVATE(d1a, dam)
    522       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ev
    523 !$OMP THREADPRIVATE(ev)
    524       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: qtaa
    525 !$OMP THREADPRIVATE(qtaa)
    526       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: clw
    527 !$OMP THREADPRIVATE(clw)
    528       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: eplaMm
    529 !$OMP THREADPRIVATE(eplaMm)
    530       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:):: sij
    531 !$OMP THREADPRIVATE(sij)
     479  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: wbeff, convoccur, zmax_th, zq2m, zt2m
     480  !$OMP THREADPRIVATE(wbeff, convoccur, zmax_th, zq2m, zt2m)
     481  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zt2m_min_mon, zt2m_max_mon
     482  !$OMP THREADPRIVATE(zt2m_min_mon, zt2m_max_mon)
     483  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: t2m_min_mon, t2m_max_mon
     484  !$OMP THREADPRIVATE(t2m_min_mon, t2m_max_mon)
     485  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: weak_inversion
     486  !$OMP THREADPRIVATE(weak_inversion)
     487  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_bl_conv, alp_bl_det
     488  !$OMP THREADPRIVATE(alp_bl_conv,alp_bl_det)
     489  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_bl_fluct_m, alp_bl_fluct_tke
     490  !$OMP THREADPRIVATE(alp_bl_fluct_m,alp_bl_fluct_tke)
     491  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_bl_stat, n2, s2, strig, zcong, zlcl_th
     492  !$OMP THREADPRIVATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
     493  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: proba_notrig, random_notrig
     494  !$OMP THREADPRIVATE(proba_notrig, random_notrig)
     495  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: fsolsw, wfbils
     496  !$OMP THREADPRIVATE(fsolsw, wfbils)
     497  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wfevap
     498  !$OMP THREADPRIVATE(wfevap)
     499  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: t2m, fluxlat, fsollw, evap_pot
     500  !$OMP THREADPRIVATE(t2m, fluxlat, fsollw,evap_pot)
     501  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dnwd0, omega
     502  !$OMP THREADPRIVATE(dnwd0, omega)
     503  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: epmax_diag ! epmax_cape
     504  !$OMP THREADPRIVATE(epmax_diag)
     505  !
     506  !  Deep convective variables used in phytrac
     507  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ep ! epmax_cape
     508  !$OMP THREADPRIVATE(ep)
     509  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dnwd, upwd
     510  !$OMP THREADPRIVATE(dnwd, upwd)
     511  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: pmflxr, pmflxs
     512  !$OMP THREADPRIVATE(pmflxr, pmflxs)
     513  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wdtrainA, wdtrainS, wdtrainM
     514  !$OMP THREADPRIVATE(wdtrainA, wdtrainS, wdtrainM)
     515  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: da, mp
     516  !$OMP THREADPRIVATE(da, mp)
     517  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wght_cvfd
     518  !$OMP THREADPRIVATE(wght_cvfd)
     519  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: phi, phi2, elij, epmlmMm
     520  !$OMP THREADPRIVATE(phi, phi2, elij, epmlmMm)
     521  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: d1a, dam
     522  !$OMP THREADPRIVATE(d1a, dam)
     523  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ev
     524  !$OMP THREADPRIVATE(ev)
     525  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: qtaa
     526  !$OMP THREADPRIVATE(qtaa)
     527  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: clw
     528  !$OMP THREADPRIVATE(clw)
     529  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: eplaMm
     530  !$OMP THREADPRIVATE(eplaMm)
     531  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: sij
     532  !$OMP THREADPRIVATE(sij)
    532533#ifdef ISO
    533534      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtwdtrainA
     
    576577#endif
    577578#endif
    578 !
    579 !      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: coefh, coefm, lambda_th
    580       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: lambda_th
    581 !$OMP THREADPRIVATE(lambda_th)
    582       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: cldemi, cldfra, cldtau, fiwc, fl, re, flwc
    583 !$OMP THREADPRIVATE(cldemi, cldfra, cldtau, fiwc, fl, re, flwc)
    584       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: qlth, qith, qsith, wiceth
    585 !$OMP THREADPRIVATE(qlth, qith, qsith, wiceth)
    586       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ref_liq, ref_ice, theta, zphi
    587 !$OMP THREADPRIVATE(ref_liq, ref_ice, theta, zphi)
    588       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ref_liq_pi, ref_ice_pi
    589 !$OMP THREADPRIVATE(ref_liq_pi, ref_ice_pi)
    590       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zx_rh, zx_rhl, zx_rhi
    591 !$OMP THREADPRIVATE(zx_rh, zx_rhl, zx_rhi)
    592       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: prfl, psfl, fraca, bsfl
    593 !$OMP THREADPRIVATE(prfl, psfl, fraca, bsfl)
    594       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: Vprecip, zw2
    595 !$OMP THREADPRIVATE(Vprecip, zw2)
    596       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: pmfd, pmfu
    597 !$OMP THREADPRIVATE(pmfd, pmfu)
    598       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: fluxt, fluxu, fluxv
    599 !$OMP THREADPRIVATE(fluxt, fluxu, fluxv)
    600       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: uwriteSTD, vwriteSTD, wwriteSTD
    601 !$OMP THREADPRIVATE(uwriteSTD, vwriteSTD, wwriteSTD)
    602       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD
    603 !$OMP THREADPRIVATE(phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD)
    604 
    605 
    606 ! ug et d'autres encore:
    607       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: beta_prec
    608 !$OMP THREADPRIVATE(beta_prec)
    609       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: rneb,rnebjn,rneblsvol
    610 !$OMP THREADPRIVATE(rneb,rnebjn,rneblsvol)
    611       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: pfraclr,pfracld
    612 !$OMP THREADPRIVATE(pfraclr,pfracld)
    613       REAL, SAVE, ALLOCATABLE :: cldfraliq(:,:)
    614 !$OMP THREADPRIVATE(cldfraliq)
    615       REAL, SAVE, ALLOCATABLE ::mean_icefracturb(:,:)
    616 !$OMP THREADPRIVATE(mean_icefracturb)
    617       REAL, SAVE, ALLOCATABLE :: sigma2_icefracturb(:,:)
    618 !$OMP THREADPRIVATE(sigma2_icefracturb)
    619 
    620 ! variables de sorties MM
    621       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxsnow,snowhgt,qsnow,to_ice
    622       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sissnow,runoff,albsol3_lic
    623 !$OMP THREADPRIVATE(zxsnow,snowhgt,qsnow,to_ice)
    624 !$OMP THREADPRIVATE(sissnow,runoff,albsol3_lic)
     579  !
     580  !      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: coefh, coefm, lambda_th
     581  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: lambda_th
     582  !$OMP THREADPRIVATE(lambda_th)
     583  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: cldemi, cldfra, cldtau, fiwc, fl, re, flwc
     584  !$OMP THREADPRIVATE(cldemi, cldfra, cldtau, fiwc, fl, re, flwc)
     585  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: qlth, qith, qsith, wiceth
     586  !$OMP THREADPRIVATE(qlth, qith, qsith, wiceth)
     587  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ref_liq, ref_ice, theta, zphi
     588  !$OMP THREADPRIVATE(ref_liq, ref_ice, theta, zphi)
     589  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ref_liq_pi, ref_ice_pi
     590  !$OMP THREADPRIVATE(ref_liq_pi, ref_ice_pi)
     591  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: zx_rh, zx_rhl, zx_rhi
     592  !$OMP THREADPRIVATE(zx_rh, zx_rhl, zx_rhi)
     593  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: prfl, psfl, fraca, bsfl
     594  !$OMP THREADPRIVATE(prfl, psfl, fraca, bsfl)
     595  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: Vprecip, zw2
     596  !$OMP THREADPRIVATE(Vprecip, zw2)
     597  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: pmfd, pmfu
     598  !$OMP THREADPRIVATE(pmfd, pmfu)
     599  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: fluxt, fluxu, fluxv
     600  !$OMP THREADPRIVATE(fluxt, fluxu, fluxv)
     601  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: uwriteSTD, vwriteSTD, wwriteSTD
     602  !$OMP THREADPRIVATE(uwriteSTD, vwriteSTD, wwriteSTD)
     603  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD
     604  !$OMP THREADPRIVATE(phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD)
     605
     606
     607  ! ug et d'autres encore:
     608  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: beta_prec
     609  !$OMP THREADPRIVATE(beta_prec)
     610  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: rneb, rnebjn, rneblsvol
     611  !$OMP THREADPRIVATE(rneb,rnebjn,rneblsvol)
     612  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: pfraclr, pfracld
     613  !$OMP THREADPRIVATE(pfraclr,pfracld)
     614  REAL, SAVE, ALLOCATABLE :: cldfraliq(:, :)
     615  !$OMP THREADPRIVATE(cldfraliq)
     616  REAL, SAVE, ALLOCATABLE :: mean_icefracturb(:, :)
     617  !$OMP THREADPRIVATE(mean_icefracturb)
     618  REAL, SAVE, ALLOCATABLE :: sigma2_icefracturb(:, :)
     619  !$OMP THREADPRIVATE(sigma2_icefracturb)
     620
     621  ! variables de sorties MM
     622  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxsnow, snowhgt, qsnow, to_ice
     623  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sissnow, runoff, albsol3_lic
     624  !$OMP THREADPRIVATE(zxsnow,snowhgt,qsnow,to_ice)
     625  !$OMP THREADPRIVATE(sissnow,runoff,albsol3_lic)
    625626#ifdef ISO
    626627      REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: zxxtsnow
     
    632633#endif
    633634
    634       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause, z_tropopause, t_tropopause
    635 !$OMP THREADPRIVATE(p_tropopause, z_tropopause, t_tropopause)
    636 
    637       INTEGER,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zn2mout
    638 !$OMP THREADPRIVATE(zn2mout)
    639 
    640       REAL, SAVE, ALLOCATABLE :: qclr(:,:)
    641       !$OMP THREADPRIVATE(qclr)
    642       REAL, SAVE, ALLOCATABLE :: qcld(:,:)
    643       !$OMP THREADPRIVATE(qcld)
    644       REAL, SAVE, ALLOCATABLE :: qss(:,:)
    645       !$OMP THREADPRIVATE(qss)
    646       REAL, SAVE, ALLOCATABLE :: qvc(:,:)
    647       !$OMP THREADPRIVATE(qvc)
    648       REAL, SAVE, ALLOCATABLE :: rnebclr(:,:)
    649       !$OMP THREADPRIVATE(rnebclr)
    650       REAL, SAVE, ALLOCATABLE :: rnebss(:,:)
    651       !$OMP THREADPRIVATE(rnebss)
    652       REAL, SAVE, ALLOCATABLE :: gamma_ss(:,:)
    653       !$OMP THREADPRIVATE(gamma_ss)
    654       REAL, SAVE, ALLOCATABLE :: N1_ss(:,:)
    655       !$OMP THREADPRIVATE(N1_ss)
    656       REAL, SAVE, ALLOCATABLE :: N2_ss(:,:)
    657       !$OMP THREADPRIVATE(N2_ss)
    658       REAL, SAVE, ALLOCATABLE :: drneb_sub(:,:)
    659       !$OMP THREADPRIVATE(drneb_sub)
    660       REAL, SAVE, ALLOCATABLE :: drneb_con(:,:)
    661       !$OMP THREADPRIVATE(drneb_con)
    662       REAL, SAVE, ALLOCATABLE :: drneb_tur(:,:)
    663       !$OMP THREADPRIVATE(drneb_tur)
    664       REAL, SAVE, ALLOCATABLE :: drneb_avi(:,:)
    665       !$OMP THREADPRIVATE(drneb_avi)
    666       REAL, SAVE, ALLOCATABLE :: zqsatl(:,:)
    667       !$OMP THREADPRIVATE(zqsatl)
    668       REAL, SAVE, ALLOCATABLE :: zqsats(:,:)
    669       !$OMP THREADPRIVATE(zqsats)
    670       REAL, SAVE, ALLOCATABLE :: Tcontr(:,:)
    671       !$OMP THREADPRIVATE(Tcontr)
    672       REAL, SAVE, ALLOCATABLE :: qcontr(:,:)
    673       !$OMP THREADPRIVATE(qcontr)
    674       REAL, SAVE, ALLOCATABLE :: qcontr2(:,:)
    675       !$OMP THREADPRIVATE(qcontr2)
    676       REAL, SAVE, ALLOCATABLE :: fcontrN(:,:)
    677       !$OMP THREADPRIVATE(fcontrN)
    678       REAL, SAVE, ALLOCATABLE :: fcontrP(:,:)
    679       !$OMP THREADPRIVATE(fcontrP)
    680       REAL, SAVE, ALLOCATABLE :: distcltop(:,:)
    681       !$OMP THREADPRIVATE(distcltop)
    682       REAL, SAVE, ALLOCATABLE :: temp_cltop(:,:)
    683       !$OMP THREADPRIVATE(temp_cltop)
    684 
    685 
    686 !--POPRECIP variables
    687       REAL, SAVE, ALLOCATABLE :: qraindiag(:,:)
    688       !$OMP THREADPRIVATE(qraindiag)
    689       REAL, SAVE, ALLOCATABLE :: qsnowdiag(:,:)
    690       !$OMP THREADPRIVATE(qsnowdiag)
    691       REAL, SAVE, ALLOCATABLE :: dqreva(:,:)
    692       !$OMP THREADPRIVATE(dqreva)
    693       REAL, SAVE, ALLOCATABLE :: dqrauto(:,:)
    694       !$OMP THREADPRIVATE(dqrauto)
    695       REAL, SAVE, ALLOCATABLE :: dqrcol(:,:)
    696       !$OMP THREADPRIVATE(dqrcol)
    697       REAL, SAVE, ALLOCATABLE :: dqrmelt(:,:)
    698       !$OMP THREADPRIVATE(dqrmelt)
    699        REAL, SAVE, ALLOCATABLE :: dqrfreez(:,:)
    700       !$OMP THREADPRIVATE(dqrfreez)
    701       REAL, SAVE, ALLOCATABLE :: dqssub(:,:)
    702       !$OMP THREADPRIVATE(dqssub)
    703       REAL, SAVE, ALLOCATABLE :: dqsauto(:,:)
    704       !$OMP THREADPRIVATE(dqsauto)
    705       REAL, SAVE, ALLOCATABLE :: dqsagg(:,:)
    706       !$OMP THREADPRIVATE(dqsagg)
    707       REAL, SAVE, ALLOCATABLE :: dqsrim(:,:)
    708       !$OMP THREADPRIVATE(dqsrim)
    709       REAL, SAVE, ALLOCATABLE :: dqsmelt(:,:)
    710       !$OMP THREADPRIVATE(dqsmelt)
    711       REAL, SAVE, ALLOCATABLE :: dqsfreez(:,:)
    712       !$OMP THREADPRIVATE(dqsfreez)
    713 
    714 
    715      
    716 
    717 
    718 #ifdef CPP_StratAer
    719 !
    720 ! variables for stratospheric aerosol
    721       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: d_q_emiss
    722 !$OMP THREADPRIVATE(d_q_emiss)
    723       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: R2SO4
    724 !$OMP THREADPRIVATE(R2SO4)
    725       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: R2SO4B
    726 !$OMP THREADPRIVATE(R2SO4B)
    727       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: DENSO4
    728 !$OMP THREADPRIVATE(DENSO4)
    729       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:, :) :: DENSO4B
    730 !$OMP THREADPRIVATE(DENSO4B)     
    731       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: f_r_wet
    732 !$OMP THREADPRIVATE(f_r_wet)
    733       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:, :) :: f_r_wetB
    734 !$OMP THREADPRIVATE(f_r_wetB)
    735       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: decfluxaer
    736 !$OMP THREADPRIVATE(decfluxaer)
    737       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: mdw
    738 !$OMP THREADPRIVATE(mdw)
    739       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: OCS_lifetime
    740 !$OMP THREADPRIVATE(OCS_lifetime)
    741       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: SO2_lifetime
    742 !$OMP THREADPRIVATE(SO2_lifetime)
    743       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: H2SO4_lifetime
    744 !$OMP THREADPRIVATE(H2SO4_lifetime)
    745       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: O3_clim
    746 !$OMP THREADPRIVATE(O3_clim)
    747       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: alpha_bin
    748 !$OMP THREADPRIVATE(alpha_bin)
    749       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: piz_bin
    750 !$OMP THREADPRIVATE(piz_bin)
    751       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: cg_bin
    752 !$OMP THREADPRIVATE(cg_bin)
    753       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tau_strat_550
    754 !$OMP THREADPRIVATE(tau_strat_550)
    755       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tau_strat_1020
    756 !$OMP THREADPRIVATE(tau_strat_1020)
    757       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tausum_strat
    758 !$OMP THREADPRIVATE(tausum_strat)
    759       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: surf_PM25_sulf
    760 !$OMP THREADPRIVATE(surf_PM25_sulf)
    761       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: vsed_aer
    762 !$OMP THREADPRIVATE(vsed_aer)
    763 !     Sulfate aerosol concentration (dry mixing ratio) (condensed H2SO4 mmr)
    764       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: sulfmmr
    765 !$OMP THREADPRIVATE(sulfmmr)
    766 !     SAD all aerosols (cm2/cm3)
    767       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: SAD_sulfate
    768 !$OMP THREADPRIVATE(SAD_sulfate)
    769 !     sulfate MMR in different modes (based on sulfmmr, it must be dry mmr)
    770       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: sulfmmr_mode
    771 !$OMP THREADPRIVATE(sulfmmr_mode)
    772 !     particle concentration in different modes (part/m3)
    773       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: nd_mode
    774 !$OMP THREADPRIVATE(nd_mode)
    775 !
    776 !---3D budget variables
    777       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_nucl
    778 !$OMP THREADPRIVATE(budg_3D_nucl)
    779       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_cond_evap
    780 !$OMP THREADPRIVATE(budg_3D_cond_evap)
    781       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_ocs_to_so2
    782 !$OMP THREADPRIVATE(budg_3D_ocs_to_so2)
    783       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_so2_to_h2so4
    784 !$OMP THREADPRIVATE(budg_3D_so2_to_h2so4)
    785       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_backgr_ocs
    786 !$OMP THREADPRIVATE(budg_3D_backgr_ocs)
    787       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_backgr_so2
    788 !$OMP THREADPRIVATE(budg_3D_backgr_so2)
    789 !
    790 !---2D budget variables
    791       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_ocs
    792       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_so2
    793       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_h2so4
    794       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_part
    795 !$OMP THREADPRIVATE(budg_dep_dry_ocs,budg_dep_dry_so2,budg_dep_dry_h2so4,budg_dep_dry_part)
    796       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_ocs
    797       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_so2
    798       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_h2so4
    799       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_part
    800 !$OMP THREADPRIVATE(budg_dep_wet_ocs,budg_dep_wet_so2,budg_dep_wet_h2so4,budg_dep_wet_part)
    801       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_ocs
    802       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_so2
    803       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_h2so4
    804       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_part
    805 !$OMP THREADPRIVATE(budg_emi_ocs,budg_emi_so2,budg_emi_h2so4,budg_emi_part)
    806       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_ocs_to_so2
    807       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_so2_to_h2so4
    808       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_h2so4_to_part
    809 !$OMP THREADPRIVATE(budg_ocs_to_so2,budg_so2_to_h2so4,budg_h2so4_to_part)
    810       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_sed_part
    811 !$OMP THREADPRIVATE(budg_sed_part)
    812 #endif
     635  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause, z_tropopause, t_tropopause
     636  !$OMP THREADPRIVATE(p_tropopause, z_tropopause, t_tropopause)
     637
     638  INTEGER, ALLOCATABLE, SAVE, DIMENSION(:, :) :: zn2mout
     639  !$OMP THREADPRIVATE(zn2mout)
     640
     641  REAL, SAVE, ALLOCATABLE :: qclr(:, :)
     642  !$OMP THREADPRIVATE(qclr)
     643  REAL, SAVE, ALLOCATABLE :: qcld(:, :)
     644  !$OMP THREADPRIVATE(qcld)
     645  REAL, SAVE, ALLOCATABLE :: qss(:, :)
     646  !$OMP THREADPRIVATE(qss)
     647  REAL, SAVE, ALLOCATABLE :: qvc(:, :)
     648  !$OMP THREADPRIVATE(qvc)
     649  REAL, SAVE, ALLOCATABLE :: rnebclr(:, :)
     650  !$OMP THREADPRIVATE(rnebclr)
     651  REAL, SAVE, ALLOCATABLE :: rnebss(:, :)
     652  !$OMP THREADPRIVATE(rnebss)
     653  REAL, SAVE, ALLOCATABLE :: gamma_ss(:, :)
     654  !$OMP THREADPRIVATE(gamma_ss)
     655  REAL, SAVE, ALLOCATABLE :: N1_ss(:, :)
     656  !$OMP THREADPRIVATE(N1_ss)
     657  REAL, SAVE, ALLOCATABLE :: N2_ss(:, :)
     658  !$OMP THREADPRIVATE(N2_ss)
     659  REAL, SAVE, ALLOCATABLE :: drneb_sub(:, :)
     660  !$OMP THREADPRIVATE(drneb_sub)
     661  REAL, SAVE, ALLOCATABLE :: drneb_con(:, :)
     662  !$OMP THREADPRIVATE(drneb_con)
     663  REAL, SAVE, ALLOCATABLE :: drneb_tur(:, :)
     664  !$OMP THREADPRIVATE(drneb_tur)
     665  REAL, SAVE, ALLOCATABLE :: drneb_avi(:, :)
     666  !$OMP THREADPRIVATE(drneb_avi)
     667  REAL, SAVE, ALLOCATABLE :: zqsatl(:, :)
     668  !$OMP THREADPRIVATE(zqsatl)
     669  REAL, SAVE, ALLOCATABLE :: zqsats(:, :)
     670  !$OMP THREADPRIVATE(zqsats)
     671  REAL, SAVE, ALLOCATABLE :: Tcontr(:, :)
     672  !$OMP THREADPRIVATE(Tcontr)
     673  REAL, SAVE, ALLOCATABLE :: qcontr(:, :)
     674  !$OMP THREADPRIVATE(qcontr)
     675  REAL, SAVE, ALLOCATABLE :: qcontr2(:, :)
     676  !$OMP THREADPRIVATE(qcontr2)
     677  REAL, SAVE, ALLOCATABLE :: fcontrN(:, :)
     678  !$OMP THREADPRIVATE(fcontrN)
     679  REAL, SAVE, ALLOCATABLE :: fcontrP(:, :)
     680  !$OMP THREADPRIVATE(fcontrP)
     681  REAL, SAVE, ALLOCATABLE :: distcltop(:, :)
     682  !$OMP THREADPRIVATE(distcltop)
     683  REAL, SAVE, ALLOCATABLE :: temp_cltop(:, :)
     684  !$OMP THREADPRIVATE(temp_cltop)
     685
     686
     687  !--POPRECIP variables
     688  REAL, SAVE, ALLOCATABLE :: qraindiag(:, :)
     689  !$OMP THREADPRIVATE(qraindiag)
     690  REAL, SAVE, ALLOCATABLE :: qsnowdiag(:, :)
     691  !$OMP THREADPRIVATE(qsnowdiag)
     692  REAL, SAVE, ALLOCATABLE :: dqreva(:, :)
     693  !$OMP THREADPRIVATE(dqreva)
     694  REAL, SAVE, ALLOCATABLE :: dqrauto(:, :)
     695  !$OMP THREADPRIVATE(dqrauto)
     696  REAL, SAVE, ALLOCATABLE :: dqrcol(:, :)
     697  !$OMP THREADPRIVATE(dqrcol)
     698  REAL, SAVE, ALLOCATABLE :: dqrmelt(:, :)
     699  !$OMP THREADPRIVATE(dqrmelt)
     700  REAL, SAVE, ALLOCATABLE :: dqrfreez(:, :)
     701  !$OMP THREADPRIVATE(dqrfreez)
     702  REAL, SAVE, ALLOCATABLE :: dqssub(:, :)
     703  !$OMP THREADPRIVATE(dqssub)
     704  REAL, SAVE, ALLOCATABLE :: dqsauto(:, :)
     705  !$OMP THREADPRIVATE(dqsauto)
     706  REAL, SAVE, ALLOCATABLE :: dqsagg(:, :)
     707  !$OMP THREADPRIVATE(dqsagg)
     708  REAL, SAVE, ALLOCATABLE :: dqsrim(:, :)
     709  !$OMP THREADPRIVATE(dqsrim)
     710  REAL, SAVE, ALLOCATABLE :: dqsmelt(:, :)
     711  !$OMP THREADPRIVATE(dqsmelt)
     712  REAL, SAVE, ALLOCATABLE :: dqsfreez(:, :)
     713  !$OMP THREADPRIVATE(dqsfreez)
     714
     715
     716
     717
     718
     719  !
     720  ! variables for stratospheric aerosol
     721  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: d_q_emiss
     722  !$OMP THREADPRIVATE(d_q_emiss)
     723  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: R2SO4
     724  !$OMP THREADPRIVATE(R2SO4)
     725  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: R2SO4B
     726  !$OMP THREADPRIVATE(R2SO4B)
     727  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: DENSO4
     728  !$OMP THREADPRIVATE(DENSO4)
     729  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: DENSO4B
     730  !$OMP THREADPRIVATE(DENSO4B)
     731  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: f_r_wet
     732  !$OMP THREADPRIVATE(f_r_wet)
     733  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: f_r_wetB
     734  !$OMP THREADPRIVATE(f_r_wetB)
     735  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: decfluxaer
     736  !$OMP THREADPRIVATE(decfluxaer)
     737  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: mdw
     738  !$OMP THREADPRIVATE(mdw)
     739  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: OCS_lifetime
     740  !$OMP THREADPRIVATE(OCS_lifetime)
     741  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: SO2_lifetime
     742  !$OMP THREADPRIVATE(SO2_lifetime)
     743  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: H2SO4_lifetime
     744  !$OMP THREADPRIVATE(H2SO4_lifetime)
     745  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: O3_clim
     746  !$OMP THREADPRIVATE(O3_clim)
     747  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: alpha_bin
     748  !$OMP THREADPRIVATE(alpha_bin)
     749  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: piz_bin
     750  !$OMP THREADPRIVATE(piz_bin)
     751  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: cg_bin
     752  !$OMP THREADPRIVATE(cg_bin)
     753  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: tau_strat_550
     754  !$OMP THREADPRIVATE(tau_strat_550)
     755  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: tau_strat_1020
     756  !$OMP THREADPRIVATE(tau_strat_1020)
     757  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: tausum_strat
     758  !$OMP THREADPRIVATE(tausum_strat)
     759  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: surf_PM25_sulf
     760  !$OMP THREADPRIVATE(surf_PM25_sulf)
     761  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: vsed_aer
     762  !$OMP THREADPRIVATE(vsed_aer)
     763  !     Sulfate aerosol concentration (dry mixing ratio) (condensed H2SO4 mmr)
     764  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: sulfmmr
     765  !$OMP THREADPRIVATE(sulfmmr)
     766  !     SAD all aerosols (cm2/cm3)
     767  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: SAD_sulfate
     768  !$OMP THREADPRIVATE(SAD_sulfate)
     769  !     sulfate MMR in different modes (based on sulfmmr, it must be dry mmr)
     770  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: sulfmmr_mode
     771  !$OMP THREADPRIVATE(sulfmmr_mode)
     772  !     particle concentration in different modes (part/m3)
     773  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: nd_mode
     774  !$OMP THREADPRIVATE(nd_mode)
     775  !
     776  !---3D budget variables
     777  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_nucl
     778  !$OMP THREADPRIVATE(budg_3D_nucl)
     779  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_cond_evap
     780  !$OMP THREADPRIVATE(budg_3D_cond_evap)
     781  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_ocs_to_so2
     782  !$OMP THREADPRIVATE(budg_3D_ocs_to_so2)
     783  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_so2_to_h2so4
     784  !$OMP THREADPRIVATE(budg_3D_so2_to_h2so4)
     785  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_backgr_ocs
     786  !$OMP THREADPRIVATE(budg_3D_backgr_ocs)
     787  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_backgr_so2
     788  !$OMP THREADPRIVATE(budg_3D_backgr_so2)
     789  !
     790  !---2D budget variables
     791  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_ocs
     792  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_so2
     793  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_h2so4
     794  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_part
     795  !$OMP THREADPRIVATE(budg_dep_dry_ocs,budg_dep_dry_so2,budg_dep_dry_h2so4,budg_dep_dry_part)
     796  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_ocs
     797  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_so2
     798  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_h2so4
     799  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_part
     800  !$OMP THREADPRIVATE(budg_dep_wet_ocs,budg_dep_wet_so2,budg_dep_wet_h2so4,budg_dep_wet_part)
     801  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_ocs
     802  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_so2
     803  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_h2so4
     804  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_part
     805  !$OMP THREADPRIVATE(budg_emi_ocs,budg_emi_so2,budg_emi_h2so4,budg_emi_part)
     806  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_ocs_to_so2
     807  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_so2_to_h2so4
     808  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_h2so4_to_part
     809  !$OMP THREADPRIVATE(budg_ocs_to_so2,budg_so2_to_h2so4,budg_h2so4_to_part)
     810  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_sed_part
     811  !$OMP THREADPRIVATE(budg_sed_part)
    813812#ifdef REPROBUS
    814813      REAL,SAVE,ALLOCATABLE    :: d_q_emiss(:,:)
     
    818817CONTAINS
    819818
    820 !======================================================================
    821 SUBROUTINE phys_local_var_init
    822 USE dimphy
    823 USE infotrac_phy, ONLY : nbtr,nqtot
     819  !======================================================================
     820  SUBROUTINE phys_local_var_init
     821    USE dimphy
     822    USE infotrac_phy, ONLY : nbtr, nqtot
    824823#ifdef ISO
    825824USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
    826825#endif
    827 USE aero_mod
    828 USE indice_sol_mod
    829 USE phys_output_var_mod
    830 USE phys_state_var_mod
    831 #ifdef CPP_StratAer
    832 USE infotrac_phy, ONLY : nbtr_bin
    833 #endif
    834 
    835 IMPLICIT NONE
    836       ALLOCATE(t_seri(klon,klev),q_seri(klon,klev),ql_seri(klon,klev),qs_seri(klon,klev), qbs_seri(klon,klev))
    837 ! SN 4D ISO
    838       ALLOCATE(qx_seri(klon,klev,nqtot))
    839 ! SN
    840       ALLOCATE(u_seri(klon,klev),v_seri(klon,klev))
    841       ALLOCATE(l_mixmin(klon,klev+1,nbsrf),l_mix(klon,klev+1,nbsrf),wprime(klon,klev+1,nbsrf))
    842       ALLOCATE(pbl_eps(klon,klev+1,nbsrf+1))
    843       ALLOCATE(tke_shear(klon,klev+1,nbsrf), tke_buoy(klon,klev+1,nbsrf), tke_trans(klon,klev+1,nbsrf))
    844       pbl_eps(:,:,:)=0.
    845       tke_shear(:,:,:)=0.; tke_buoy(:,:,:)=0.; tke_trans(:,:,:)=0.
    846       l_mix(:,:,:)=0.;l_mixmin(:,:,:)=0.;wprime(:,:,:)=0. ! doit etre initialse car pas toujours remplis
    847       ALLOCATE(rhcl(klon,klev))
    848       ALLOCATE(tr_seri(klon,klev,nbtr))
    849       ALLOCATE(d_t_dyn(klon,klev),d_q_dyn(klon,klev))
    850       ALLOCATE(d_ql_dyn(klon,klev),d_qs_dyn(klon,klev), d_qbs_dyn(klon,klev))
    851       ALLOCATE(d_q_dyn2d(klon),d_ql_dyn2d(klon),d_qs_dyn2d(klon), d_qbs_dyn2d(klon))
    852       ALLOCATE(d_u_dyn(klon,klev),d_v_dyn(klon,klev))
    853       ALLOCATE(d_tr_dyn(klon,klev,nbtr))                   !RomP
    854       ALLOCATE(d_t_con(klon,klev),d_q_con(klon,klev),d_q_con_zmasse(klon,klev))
    855       ALLOCATE(d_u_con(klon,klev),d_v_con(klon,klev))
    856       ALLOCATE(d_t_wake(klon,klev),d_q_wake(klon,klev))
    857       ALLOCATE(d_t_lsc(klon,klev),d_q_lsc(klon,klev))
    858       ALLOCATE(d_t_lwr(klon,klev),d_t_lw0(klon,klev))
    859       ALLOCATE(d_t_swr(klon,klev),d_t_sw0(klon,klev))
    860       ALLOCATE(d_ql_lsc(klon,klev),d_qi_lsc(klon,klev))
    861       ALLOCATE(d_t_ajsb(klon,klev),d_q_ajsb(klon,klev))
    862       ALLOCATE(d_t_ajs(klon,klev),d_q_ajs(klon,klev))
    863 !nrlmd<
    864       ALLOCATE(d_t_ajs_w(klon,klev),d_q_ajs_w(klon,klev))
    865       ALLOCATE(d_t_ajs_x(klon,klev),d_q_ajs_x(klon,klev))
    866 !>nrlmd
    867       ALLOCATE(d_u_ajs(klon,klev),d_v_ajs(klon,klev))
    868       ALLOCATE(d_t_eva(klon,klev),d_q_eva(klon,klev))
    869 ! SN 4D ISO
    870       ALLOCATE(d_qx_eva(klon,klev,nqtot))
    871 ! SN
    872       ALLOCATE(d_ql_eva(klon,klev),d_qi_eva(klon,klev))
    873       ALLOCATE(d_t_lscst(klon,klev),d_q_lscst(klon,klev))
    874       ALLOCATE(d_t_lscth(klon,klev),d_q_lscth(klon,klev))
    875       ALLOCATE(plul_st(klon),plul_th(klon))
    876       ALLOCATE(d_t_vdf(klon,klev),d_q_vdf(klon,klev),d_t_diss(klon,klev))
    877       ALLOCATE (d_qbs_vdf(klon,klev))
    878       ALLOCATE(d_t_bsss(klon,klev),d_q_bsss(klon,klev),d_qbs_bsss(klon,klev))
    879       ALLOCATE(d_t_vdf_w(klon,klev),d_q_vdf_w(klon,klev))
    880       ALLOCATE(d_t_vdf_x(klon,klev),d_q_vdf_x(klon,klev))
     826    USE aero_mod
     827    USE indice_sol_mod
     828    USE phys_output_var_mod
     829    USE phys_state_var_mod
     830    USE infotrac_phy, ONLY : nbtr_bin
     831
     832    IMPLICIT NONE
     833    ALLOCATE(t_seri(klon, klev), q_seri(klon, klev), ql_seri(klon, klev), qs_seri(klon, klev), qbs_seri(klon, klev))
     834    ! SN 4D ISO
     835    ALLOCATE(qx_seri(klon, klev, nqtot))
     836    ! SN
     837    ALLOCATE(u_seri(klon, klev), v_seri(klon, klev))
     838    ALLOCATE(l_mixmin(klon, klev + 1, nbsrf), l_mix(klon, klev + 1, nbsrf), wprime(klon, klev + 1, nbsrf))
     839    ALLOCATE(pbl_eps(klon, klev + 1, nbsrf + 1))
     840    ALLOCATE(tke_shear(klon, klev + 1, nbsrf), tke_buoy(klon, klev + 1, nbsrf), tke_trans(klon, klev + 1, nbsrf))
     841    pbl_eps(:, :, :) = 0.
     842    tke_shear(:, :, :) = 0.; tke_buoy(:, :, :) = 0.; tke_trans(:, :, :) = 0.
     843    l_mix(:, :, :) = 0.;l_mixmin(:, :, :) = 0.;wprime(:, :, :) = 0. ! doit etre initialse car pas toujours remplis
     844    ALLOCATE(rhcl(klon, klev))
     845    ALLOCATE(tr_seri(klon, klev, nbtr))
     846    ALLOCATE(d_t_dyn(klon, klev), d_q_dyn(klon, klev))
     847    ALLOCATE(d_ql_dyn(klon, klev), d_qs_dyn(klon, klev), d_qbs_dyn(klon, klev))
     848    ALLOCATE(d_q_dyn2d(klon), d_ql_dyn2d(klon), d_qs_dyn2d(klon), d_qbs_dyn2d(klon))
     849    ALLOCATE(d_u_dyn(klon, klev), d_v_dyn(klon, klev))
     850    ALLOCATE(d_tr_dyn(klon, klev, nbtr))                   !RomP
     851    ALLOCATE(d_t_con(klon, klev), d_q_con(klon, klev), d_q_con_zmasse(klon, klev))
     852    ALLOCATE(d_u_con(klon, klev), d_v_con(klon, klev))
     853    ALLOCATE(d_t_wake(klon, klev), d_q_wake(klon, klev))
     854    ALLOCATE(d_t_lsc(klon, klev), d_q_lsc(klon, klev))
     855    ALLOCATE(d_t_lwr(klon, klev), d_t_lw0(klon, klev))
     856    ALLOCATE(d_t_swr(klon, klev), d_t_sw0(klon, klev))
     857    ALLOCATE(d_ql_lsc(klon, klev), d_qi_lsc(klon, klev))
     858    ALLOCATE(d_t_ajsb(klon, klev), d_q_ajsb(klon, klev))
     859    ALLOCATE(d_t_ajs(klon, klev), d_q_ajs(klon, klev))
     860    !nrlmd<
     861    ALLOCATE(d_t_ajs_w(klon, klev), d_q_ajs_w(klon, klev))
     862    ALLOCATE(d_t_ajs_x(klon, klev), d_q_ajs_x(klon, klev))
     863    !>nrlmd
     864    ALLOCATE(d_u_ajs(klon, klev), d_v_ajs(klon, klev))
     865    ALLOCATE(d_t_eva(klon, klev), d_q_eva(klon, klev))
     866    ! SN 4D ISO
     867    ALLOCATE(d_qx_eva(klon, klev, nqtot))
     868    ! SN
     869    ALLOCATE(d_ql_eva(klon, klev), d_qi_eva(klon, klev))
     870    ALLOCATE(d_t_lscst(klon, klev), d_q_lscst(klon, klev))
     871    ALLOCATE(d_t_lscth(klon, klev), d_q_lscth(klon, klev))
     872    ALLOCATE(plul_st(klon), plul_th(klon))
     873    ALLOCATE(d_t_vdf(klon, klev), d_q_vdf(klon, klev), d_t_diss(klon, klev))
     874    ALLOCATE (d_qbs_vdf(klon, klev))
     875    ALLOCATE(d_t_bsss(klon, klev), d_q_bsss(klon, klev), d_qbs_bsss(klon, klev))
     876    ALLOCATE(d_t_vdf_w(klon, klev), d_q_vdf_w(klon, klev))
     877    ALLOCATE(d_t_vdf_x(klon, klev), d_q_vdf_x(klon, klev))
    881878#ifdef ISO
    882879      allocate(xt_seri(ntraciso,klon,klev))
     
    909906#endif
    910907
    911       ALLOCATE(d_u_vdf(klon,klev),d_v_vdf(klon,klev))
    912       ALLOCATE(d_t_oli(klon,klev),d_t_oro(klon,klev))
    913       ALLOCATE(d_u_oli(klon,klev),d_v_oli(klon,klev))
    914       ALLOCATE(d_u_oro(klon,klev),d_v_oro(klon,klev))
    915       ALLOCATE(d_u_oro_gw(klon,klev),d_v_oro_gw(klon,klev))
    916       ALLOCATE(d_t_oro_gw(klon,klev))
    917       ALLOCATE(d_t_lif(klon,klev),d_t_ec(klon,klev))
    918       ALLOCATE(d_u_lif(klon,klev),d_v_lif(klon,klev))
    919       ALLOCATE(d_ts(klon,nbsrf), d_tr(klon,klev,nbtr))
    920 
    921 ! Special RRTM
    922       ALLOCATE(ZLWFT0_i(klon,klev+1),ZSWFT0_i(klon,klev+1),ZFLDN0(klon,klev+1))
    923       ZFLDN0= 0.
    924       ALLOCATE(ZFLUP0(klon,klev+1),ZFSDN0(klon,klev+1),ZFSUP0(klon,klev+1))
    925 !
    926       ALLOCATE(topswad_aero(klon), solswad_aero(klon))
    927       ALLOCATE(topswai_aero(klon), solswai_aero(klon))
    928       ALLOCATE(topswad0_aero(klon), solswad0_aero(klon))
    929       ALLOCATE(toplwad_aero(klon), sollwad_aero(klon))
    930       ALLOCATE(toplwai_aero(klon), sollwai_aero(klon))
    931       ALLOCATE(toplwad0_aero(klon), sollwad0_aero(klon))
    932       ALLOCATE(topsw_aero(klon,naero_grp), solsw_aero(klon,naero_grp))
    933       ALLOCATE(topsw0_aero(klon,naero_grp), solsw0_aero(klon,naero_grp))
    934       ALLOCATE(topswcf_aero(klon,3), solswcf_aero(klon,3))
    935       ALLOCATE(du_gwd_hines(klon,klev),dv_gwd_hines(klon,klev))
    936       ALLOCATE(dv_gwd_rando(klon,klev),dv_gwd_front(klon,klev))
    937       ALLOCATE(east_gwstress(klon,klev),west_gwstress(klon,klev))
    938       east_gwstress(:,:)=0 !ym missing init
    939       west_gwstress(:,:)=0 !ym missing init
    940       ALLOCATE(d_t_hin(klon,klev))
    941       ALLOCATE(d_q_ch4(klon,klev))
    942       ALLOCATE(stratomask(klon,klev))
    943       ALLOCATE(tausum_aero(klon,nwave,naero_tot))
    944       ALLOCATE(drytausum_aero(klon,naero_tot))
    945       ALLOCATE(tau3d_aero(klon,klev,nwave,naero_tot))
    946       ALLOCATE(dNovrN(klon))
    947       ALLOCATE(zfice(klon, klev))
    948       ALLOCATE(od443aer(klon))
    949       ALLOCATE(od550aer(klon))
    950       ALLOCATE(od865aer(klon))
    951       ALLOCATE(dryod550aer(klon))
    952       dryod550aer(:) = 0.
    953       ALLOCATE(abs550aer(klon))
    954       abs550aer(:) = 0.
    955       ALLOCATE(ec550aer(klon,klev))
    956       ALLOCATE(od550lt1aer(klon))
    957       ALLOCATE(sconcso4(klon))
    958       ALLOCATE(sconcno3(klon))
    959       ALLOCATE(sconcoa(klon))
    960       ALLOCATE(sconcbc(klon))
    961       ALLOCATE(sconcss(klon))
    962       ALLOCATE(sconcdust(klon))
    963       ALLOCATE(concso4(klon,klev))
    964       ALLOCATE(concno3(klon,klev))
    965       ALLOCATE(concoa(klon,klev))
    966       ALLOCATE(concbc(klon,klev))
    967       ALLOCATE(concss(klon,klev))
    968       ALLOCATE(concdust(klon,klev))
    969       ALLOCATE(loadso4(klon))
    970       ALLOCATE(loadoa(klon))
    971       ALLOCATE(loadbc(klon))
    972       ALLOCATE(loadss(klon))
    973       ALLOCATE(loaddust(klon))
    974       ALLOCATE(loadno3(klon))
    975       ALLOCATE(load_tmp1(klon))
    976       ALLOCATE(load_tmp2(klon))
    977       ALLOCATE(load_tmp3(klon))
    978       ALLOCATE(load_tmp4(klon))
    979       ALLOCATE(load_tmp5(klon))
    980       ALLOCATE(load_tmp6(klon))
    981       ALLOCATE(load_tmp7(klon))
    982       ALLOCATE(load_tmp8(klon))
    983       ALLOCATE(load_tmp9(klon))
    984       ALLOCATE(load_tmp10(klon))
    985 
    986 !IM ajout variables CFMIP2/CMIP5
    987       ALLOCATE(topswad_aerop(klon), solswad_aerop(klon))
    988       ALLOCATE(topswai_aerop(klon), solswai_aerop(klon))
    989       ALLOCATE(topswad0_aerop(klon), solswad0_aerop(klon))
    990       ALLOCATE(topsw_aerop(klon,naero_grp), topsw0_aerop(klon,naero_grp))
    991       ALLOCATE(solsw_aerop(klon,naero_grp), solsw0_aerop(klon,naero_grp))
    992       ALLOCATE(topswcf_aerop(klon,naero_grp), solswcf_aerop(klon,naero_grp))
    993 
    994 ! additional LW variables CK
    995       ALLOCATE(toplwad_aerop(klon), sollwad_aerop(klon))
    996       ALLOCATE(toplwai_aerop(klon), sollwai_aerop(klon))
    997       ALLOCATE(toplwad0_aerop(klon), sollwad0_aerop(klon))
    998 
    999 !AI Ajout Ecrad (3Deffect)
    1000       ALLOCATE(topswad_aero_s2(klon), solswad_aero_s2(klon))
    1001       ALLOCATE(topswai_aero_s2(klon), solswai_aero_s2(klon))
    1002       ALLOCATE(topswad0_aero_s2(klon), solswad0_aero_s2(klon))
    1003       ALLOCATE(topsw_aero_s2(klon,naero_grp), topsw0_aero_s2(klon,naero_grp))
    1004       ALLOCATE(solsw_aero_s2(klon,naero_grp), solsw0_aero_s2(klon,naero_grp))
    1005       ALLOCATE(topswcf_aero_s2(klon,naero_grp), solswcf_aero_s2(klon,naero_grp))
    1006 ! additional LW variables CK
    1007       ALLOCATE(toplwad_aero_s2(klon), sollwad_aero_s2(klon))
    1008       ALLOCATE(toplwai_aero_s2(klon), sollwai_aero_s2(klon))
    1009       ALLOCATE(toplwad0_aero_s2(klon), sollwad0_aero_s2(klon))
    1010 
    1011 ! FH Ajout de celles necessaires au phys_output_write_mod
    1012 
    1013       ALLOCATE(tal1(klon), pal1(klon), pab1(klon), pab2(klon))
    1014       ALLOCATE(ptstar(klon),pt0(klon),slp(klon))
    1015 !!
    1016 !!          Wake variables
    1017       ALLOCATE(alp_wake(klon))
    1018       ALLOCATE(wake_h(klon),wake_k(klon))
    1019       ALLOCATE(wake_omg(klon, klev))
    1020       ALLOCATE(d_deltat_wk(klon, klev), d_deltaq_wk(klon, klev))
    1021       ALLOCATE(d_s_wk(klon), d_s_a_wk(klon), d_dens_wk(klon), d_dens_a_wk(klon))
    1022       ALLOCATE(d_deltat_wk_gw(klon, klev), d_deltaq_wk_gw(klon, klev))
    1023       ALLOCATE(d_deltat_vdf(klon, klev), d_deltaq_vdf(klon, klev))
    1024 !!      ALLOCATE( d_s_vdf(klon), d_dens_vdf(klon))
    1025       ALLOCATE(d_deltat_the(klon, klev), d_deltaq_the(klon, klev))
    1026 !!      ALLOCATE( d_s_the(klon), d_dens_the(klon))
    1027       ALLOCATE(d_deltat_ajs_cv(klon, klev), d_deltaq_ajs_cv(klon, klev))
     908    ALLOCATE(d_u_vdf(klon, klev), d_v_vdf(klon, klev))
     909    ALLOCATE(d_t_oli(klon, klev), d_t_oro(klon, klev))
     910    ALLOCATE(d_u_oli(klon, klev), d_v_oli(klon, klev))
     911    ALLOCATE(d_u_oro(klon, klev), d_v_oro(klon, klev))
     912    ALLOCATE(d_u_oro_gw(klon, klev), d_v_oro_gw(klon, klev))
     913    ALLOCATE(d_t_oro_gw(klon, klev))
     914    ALLOCATE(d_t_lif(klon, klev), d_t_ec(klon, klev))
     915    ALLOCATE(d_u_lif(klon, klev), d_v_lif(klon, klev))
     916    ALLOCATE(d_ts(klon, nbsrf), d_tr(klon, klev, nbtr))
     917
     918    ! Special RRTM
     919    ALLOCATE(ZLWFT0_i(klon, klev + 1), ZSWFT0_i(klon, klev + 1), ZFLDN0(klon, klev + 1))
     920    ZFLDN0 = 0.
     921    ALLOCATE(ZFLUP0(klon, klev + 1), ZFSDN0(klon, klev + 1), ZFSUP0(klon, klev + 1))
     922    !
     923    ALLOCATE(topswad_aero(klon), solswad_aero(klon))
     924    ALLOCATE(topswai_aero(klon), solswai_aero(klon))
     925    ALLOCATE(topswad0_aero(klon), solswad0_aero(klon))
     926    ALLOCATE(toplwad_aero(klon), sollwad_aero(klon))
     927    ALLOCATE(toplwai_aero(klon), sollwai_aero(klon))
     928    ALLOCATE(toplwad0_aero(klon), sollwad0_aero(klon))
     929    ALLOCATE(topsw_aero(klon, naero_grp), solsw_aero(klon, naero_grp))
     930    ALLOCATE(topsw0_aero(klon, naero_grp), solsw0_aero(klon, naero_grp))
     931    ALLOCATE(topswcf_aero(klon, 3), solswcf_aero(klon, 3))
     932    ALLOCATE(du_gwd_hines(klon, klev), dv_gwd_hines(klon, klev))
     933    ALLOCATE(dv_gwd_rando(klon, klev), dv_gwd_front(klon, klev))
     934    ALLOCATE(east_gwstress(klon, klev), west_gwstress(klon, klev))
     935    east_gwstress(:, :) = 0 !ym missing init
     936    west_gwstress(:, :) = 0 !ym missing init
     937    ALLOCATE(d_t_hin(klon, klev))
     938    ALLOCATE(d_q_ch4(klon, klev))
     939    ALLOCATE(stratomask(klon, klev))
     940    ALLOCATE(tausum_aero(klon, nwave, naero_tot))
     941    ALLOCATE(drytausum_aero(klon, naero_tot))
     942    ALLOCATE(tau3d_aero(klon, klev, nwave, naero_tot))
     943    ALLOCATE(dNovrN(klon))
     944    ALLOCATE(zfice(klon, klev))
     945    ALLOCATE(od443aer(klon))
     946    ALLOCATE(od550aer(klon))
     947    ALLOCATE(od865aer(klon))
     948    ALLOCATE(dryod550aer(klon))
     949    dryod550aer(:) = 0.
     950    ALLOCATE(abs550aer(klon))
     951    abs550aer(:) = 0.
     952    ALLOCATE(ec550aer(klon, klev))
     953    ALLOCATE(od550lt1aer(klon))
     954    ALLOCATE(sconcso4(klon))
     955    ALLOCATE(sconcno3(klon))
     956    ALLOCATE(sconcoa(klon))
     957    ALLOCATE(sconcbc(klon))
     958    ALLOCATE(sconcss(klon))
     959    ALLOCATE(sconcdust(klon))
     960    ALLOCATE(concso4(klon, klev))
     961    ALLOCATE(concno3(klon, klev))
     962    ALLOCATE(concoa(klon, klev))
     963    ALLOCATE(concbc(klon, klev))
     964    ALLOCATE(concss(klon, klev))
     965    ALLOCATE(concdust(klon, klev))
     966    ALLOCATE(loadso4(klon))
     967    ALLOCATE(loadoa(klon))
     968    ALLOCATE(loadbc(klon))
     969    ALLOCATE(loadss(klon))
     970    ALLOCATE(loaddust(klon))
     971    ALLOCATE(loadno3(klon))
     972    ALLOCATE(load_tmp1(klon))
     973    ALLOCATE(load_tmp2(klon))
     974    ALLOCATE(load_tmp3(klon))
     975    ALLOCATE(load_tmp4(klon))
     976    ALLOCATE(load_tmp5(klon))
     977    ALLOCATE(load_tmp6(klon))
     978    ALLOCATE(load_tmp7(klon))
     979    ALLOCATE(load_tmp8(klon))
     980    ALLOCATE(load_tmp9(klon))
     981    ALLOCATE(load_tmp10(klon))
     982
     983    !IM ajout variables CFMIP2/CMIP5
     984    ALLOCATE(topswad_aerop(klon), solswad_aerop(klon))
     985    ALLOCATE(topswai_aerop(klon), solswai_aerop(klon))
     986    ALLOCATE(topswad0_aerop(klon), solswad0_aerop(klon))
     987    ALLOCATE(topsw_aerop(klon, naero_grp), topsw0_aerop(klon, naero_grp))
     988    ALLOCATE(solsw_aerop(klon, naero_grp), solsw0_aerop(klon, naero_grp))
     989    ALLOCATE(topswcf_aerop(klon, naero_grp), solswcf_aerop(klon, naero_grp))
     990
     991    ! additional LW variables CK
     992    ALLOCATE(toplwad_aerop(klon), sollwad_aerop(klon))
     993    ALLOCATE(toplwai_aerop(klon), sollwai_aerop(klon))
     994    ALLOCATE(toplwad0_aerop(klon), sollwad0_aerop(klon))
     995
     996    !AI Ajout Ecrad (3Deffect)
     997    ALLOCATE(topswad_aero_s2(klon), solswad_aero_s2(klon))
     998    ALLOCATE(topswai_aero_s2(klon), solswai_aero_s2(klon))
     999    ALLOCATE(topswad0_aero_s2(klon), solswad0_aero_s2(klon))
     1000    ALLOCATE(topsw_aero_s2(klon, naero_grp), topsw0_aero_s2(klon, naero_grp))
     1001    ALLOCATE(solsw_aero_s2(klon, naero_grp), solsw0_aero_s2(klon, naero_grp))
     1002    ALLOCATE(topswcf_aero_s2(klon, naero_grp), solswcf_aero_s2(klon, naero_grp))
     1003    ! additional LW variables CK
     1004    ALLOCATE(toplwad_aero_s2(klon), sollwad_aero_s2(klon))
     1005    ALLOCATE(toplwai_aero_s2(klon), sollwai_aero_s2(klon))
     1006    ALLOCATE(toplwad0_aero_s2(klon), sollwad0_aero_s2(klon))
     1007
     1008    ! FH Ajout de celles necessaires au phys_output_write_mod
     1009
     1010    ALLOCATE(tal1(klon), pal1(klon), pab1(klon), pab2(klon))
     1011    ALLOCATE(ptstar(klon), pt0(klon), slp(klon))
     1012    !!
     1013    !!          Wake variables
     1014    ALLOCATE(alp_wake(klon))
     1015    ALLOCATE(wake_h(klon), wake_k(klon))
     1016    ALLOCATE(wake_omg(klon, klev))
     1017    ALLOCATE(d_deltat_wk(klon, klev), d_deltaq_wk(klon, klev))
     1018    ALLOCATE(d_s_wk(klon), d_s_a_wk(klon), d_dens_wk(klon), d_dens_a_wk(klon))
     1019    ALLOCATE(d_deltat_wk_gw(klon, klev), d_deltaq_wk_gw(klon, klev))
     1020    ALLOCATE(d_deltat_vdf(klon, klev), d_deltaq_vdf(klon, klev))
     1021    !!      ALLOCATE( d_s_vdf(klon), d_dens_vdf(klon))
     1022    ALLOCATE(d_deltat_the(klon, klev), d_deltaq_the(klon, klev))
     1023    !!      ALLOCATE( d_s_the(klon), d_dens_the(klon))
     1024    ALLOCATE(d_deltat_ajs_cv(klon, klev), d_deltaq_ajs_cv(klon, klev))
    10281025#ifdef ISO
    10291026      ALLOCATE(d_deltaxt_wk(ntraciso,klon, klev))
     
    10331030      ALLOCATE(d_deltaxt_ajs_cv(ntraciso,klon, klev))
    10341031#endif
    1035 !!         End of wake variables
    1036 !!
    1037       ALLOCATE(bils(klon))
    1038       ALLOCATE(cdragm(klon), cdragh(klon), cldh(klon), cldl(klon))
    1039       ALLOCATE(cldm(klon), cldq(klon), cldt(klon), qsat2m(klon))
    1040       ALLOCATE(JrNt(klon))
    1041       ALLOCATE(dthmin(klon), evap(klon), snowerosion(klon), fder(klon), plcl(klon), plfc(klon))
    1042       ALLOCATE(prw(klon), prlw(klon), prsw(klon), prbsw(klon), water_budget(klon), zustar(klon), zu10m(klon), zv10m(klon), rh2m(klon))
    1043       ALLOCATE(s_lcl(klon))
    1044       ALLOCATE(s_pblh(klon), s_pblt(klon), s_therm(klon))
    1045 !
    1046 !nrlmd+jyg<
    1047       ALLOCATE(s_pblh_x(klon), s_pblh_w(klon))
    1048       ALLOCATE(s_lcl_x(klon), s_lcl_w(klon))
    1049 !>nrlmd+jyg
    1050 !
    1051       ALLOCATE(slab_wfbils(klon), tpot(klon), tpote(klon), ue(klon))
    1052       ALLOCATE(uq(klon), ve(klon), vq(klon), zxffonte(klon))
    1053       ALLOCATE(uwat(klon), vwat(klon))
    1054       ALLOCATE(zxfqcalving(klon), zxfluxlat(klon))
    1055       ALLOCATE(zxtsol(klon), snow_lsc(klon), zxfqfonte(klon), zxqsurf(klon))
    1056       ALLOCATE(zxrunofflic(klon))
    1057       ALLOCATE(zxustartlic(klon), zxrhoslic(klon), zxqsaltlic(klon))
    1058       zxustartlic(:)=0. ; zxrhoslic(:)=0. ; zxqsaltlic(:)=0.
    1059       ALLOCATE(rain_lsc(klon))
    1060       ALLOCATE(rain_num(klon))
    1061       ALLOCATE(qlth(klon,klev), qith(klon,klev), qsith(klon,klev), wiceth(klon,klev))
    1062       !
     1032    !!         End of wake variables
     1033    !!
     1034    ALLOCATE(bils(klon))
     1035    ALLOCATE(cdragm(klon), cdragh(klon), cldh(klon), cldl(klon))
     1036    ALLOCATE(cldm(klon), cldq(klon), cldt(klon), qsat2m(klon))
     1037    ALLOCATE(JrNt(klon))
     1038    ALLOCATE(dthmin(klon), evap(klon), snowerosion(klon), fder(klon), plcl(klon), plfc(klon))
     1039    ALLOCATE(prw(klon), prlw(klon), prsw(klon), prbsw(klon), water_budget(klon), zustar(klon), zu10m(klon), zv10m(klon), rh2m(klon))
     1040    ALLOCATE(s_lcl(klon))
     1041    ALLOCATE(s_pblh(klon), s_pblt(klon), s_therm(klon))
     1042    !
     1043    !nrlmd+jyg<
     1044    ALLOCATE(s_pblh_x(klon), s_pblh_w(klon))
     1045    ALLOCATE(s_lcl_x(klon), s_lcl_w(klon))
     1046    !>nrlmd+jyg
     1047    !
     1048    ALLOCATE(slab_wfbils(klon), tpot(klon), tpote(klon), ue(klon))
     1049    ALLOCATE(uq(klon), ve(klon), vq(klon), zxffonte(klon))
     1050    ALLOCATE(uwat(klon), vwat(klon))
     1051    ALLOCATE(zxfqcalving(klon), zxfluxlat(klon))
     1052    ALLOCATE(zxtsol(klon), snow_lsc(klon), zxfqfonte(klon), zxqsurf(klon))
     1053    ALLOCATE(zxrunofflic(klon))
     1054    ALLOCATE(zxustartlic(klon), zxrhoslic(klon), zxqsaltlic(klon))
     1055    zxustartlic(:) = 0. ; zxrhoslic(:) = 0. ; zxqsaltlic(:) = 0.
     1056    ALLOCATE(rain_lsc(klon))
     1057    ALLOCATE(rain_num(klon))
     1058    ALLOCATE(qlth(klon, klev), qith(klon, klev), qsith(klon, klev), wiceth(klon, klev))
     1059    !
    10631060#ifdef ISO
    10641061      ALLOCATE(xtevap(ntraciso,klon))
     
    10731070      runoff_diag(:)=0. ; xtrunoff_diag(:,:)=0. ! because variables are only given values on knon grid points
    10741071#endif
    1075 !
    1076       ALLOCATE(sens_x(klon), sens_w(klon))
    1077       ALLOCATE(zxfluxlat_x(klon), zxfluxlat_w(klon))
    1078       ALLOCATE(delta_qsurf(klon))
    1079 !jyg<
    1080 !!      ALLOCATE(t_x(klon,klev), t_w(klon,klev))
    1081 !!      ALLOCATE(q_x(klon,klev), q_w(klon,klev))
    1082 !>jyg
    1083       ALLOCATE(dtvdf_x(klon,klev), dtvdf_w(klon,klev))
    1084       dtvdf_x = 0 ; dtvdf_w=0 ;   !ym missing init
    1085       ALLOCATE(dqvdf_x(klon,klev), dqvdf_w(klon,klev))
    1086       dqvdf_x = 0 ; dqvdf_w=0 ;   !ym missing init
    1087       ALLOCATE(pbl_tke_input(klon,klev+1,nbsrf))
    1088       ALLOCATE(t_therm(klon,klev), q_therm(klon,klev),u_therm(klon,klev), v_therm(klon,klev))
    1089       ALLOCATE(cdragh_x(klon), cdragh_w(klon))
    1090       ALLOCATE(cdragm_x(klon), cdragm_w(klon))
    1091       ALLOCATE(kh(klon), kh_x(klon), kh_w(klon))
     1072    !
     1073    ALLOCATE(sens_x(klon), sens_w(klon))
     1074    ALLOCATE(zxfluxlat_x(klon), zxfluxlat_w(klon))
     1075    ALLOCATE(delta_qsurf(klon))
     1076    !jyg<
     1077    !!      ALLOCATE(t_x(klon,klev), t_w(klon,klev))
     1078    !!      ALLOCATE(q_x(klon,klev), q_w(klon,klev))
     1079    !>jyg
     1080    ALLOCATE(dtvdf_x(klon, klev), dtvdf_w(klon, klev))
     1081    dtvdf_x = 0 ; dtvdf_w = 0 ;
     1082    !ym missing init
     1083    ALLOCATE(dqvdf_x(klon, klev), dqvdf_w(klon, klev))
     1084    dqvdf_x = 0 ; dqvdf_w = 0 ;
     1085    !ym missing init
     1086    ALLOCATE(pbl_tke_input(klon, klev + 1, nbsrf))
     1087    ALLOCATE(t_therm(klon, klev), q_therm(klon, klev), u_therm(klon, klev), v_therm(klon, klev))
     1088    ALLOCATE(cdragh_x(klon), cdragh_w(klon))
     1089    ALLOCATE(cdragm_x(klon), cdragm_w(klon))
     1090    ALLOCATE(kh(klon), kh_x(klon), kh_w(klon))
    10921091#ifdef ISO
    10931092      ALLOCATE(dxtvdf_x(ntraciso,klon,klev), dxtvdf_w(ntraciso,klon,klev))
    10941093      ALLOCATE(xt_therm(ntraciso,klon,klev))
    10951094#endif
    1096 !
    1097       ALLOCATE(ptconv(klon,klev))
    1098       ALLOCATE(ratqsc(klon,klev))
    1099 !
    1100       ALLOCATE(wbeff(klon), convoccur(klon), zmax_th(klon))
    1101       ALLOCATE(zq2m(klon), zt2m(klon), weak_inversion(klon))
    1102       ALLOCATE(zt2m_min_mon(klon), zt2m_max_mon(klon))
    1103       ALLOCATE(t2m_min_mon(klon), t2m_max_mon(klon))
    1104       ALLOCATE(sens(klon), flwp(klon), fiwp(klon))
    1105       ALLOCATE(alp_bl_conv(klon), alp_bl_det(klon))
    1106       alp_bl_conv(:)=0 ;  alp_bl_det(:)=0
    1107       ALLOCATE(alp_bl_fluct_m(klon), alp_bl_fluct_tke(klon))
    1108       alp_bl_fluct_m(:)=0 ; alp_bl_fluct_tke(:)= 0.
    1109       ALLOCATE(alp_bl_stat(klon), n2(klon), s2(klon), strig(klon), zcong(klon), zlcl_th(klon))
    1110       alp_bl_stat(:)=0
    1111       ALLOCATE(proba_notrig(klon), random_notrig(klon))
    1112 
    1113       ALLOCATE(dnwd0(klon, klev))
    1114 !      ALLOCATE(upwd(klon, klev), omega(klon, klev), coefh(klon, klev))
    1115       ALLOCATE(omega(klon, klev))
    1116       ALLOCATE(epmax_diag(klon)) ! epmax_cape
    1117 !      ALLOCATE(coefm(klon, klev), lambda_th(klon, klev), cldemi(klon, klev))
    1118       ALLOCATE(lambda_th(klon, klev), cldemi(klon, klev))
    1119       ALLOCATE(cldfra(klon, klev), cldtau(klon, klev), fiwc(klon, klev))
    1120       ALLOCATE(fl(klon, klev), re(klon, klev), flwc(klon, klev))
    1121       ALLOCATE(ref_liq(klon, klev), ref_ice(klon, klev), theta(klon, klev))
    1122       ALLOCATE(ref_liq_pi(klon, klev), ref_ice_pi(klon, klev))
    1123       ALLOCATE(zphi(klon, klev), zx_rh(klon, klev), zx_rhl(klon,klev), zx_rhi(klon,klev))
    1124       zx_rhl(:,:)=0.; zx_rhi(:,:)=0. ! because not always defined
    1125       ALLOCATE(pmfd(klon, klev), pmfu(klon, klev))
    1126 
    1127       ALLOCATE(t2m(klon, nbsrf), fluxlat(klon, nbsrf))
    1128       ALLOCATE(fsollw(klon, nbsrf))
    1129       ALLOCATE(fsolsw(klon, nbsrf), wfbils(klon, nbsrf))
    1130       ALLOCATE(wfevap(klon, nbsrf))
    1131       ALLOCATE(evap_pot(klon, nbsrf))
    1132 ! FC
    1133       ALLOCATE(zxfluxq(klon,klev),zxfluxt(klon,klev))
    1134 !
    1135 !  Deep convective variables used in phytrac
    1136       ALLOCATE(pmflxr(klon, klev+1), pmflxs(klon, klev+1))
    1137       ALLOCATE(wdtrainA(klon,klev),wdtrainS(klon,klev),wdtrainM(klon,klev))
    1138       ALLOCATE(dnwd(klon, klev), upwd(klon, klev))
    1139       ALLOCATE(ep(klon,klev))                          ! epmax_cape
    1140       ALLOCATE(da(klon,klev), mp(klon,klev))
    1141       ALLOCATE(phi(klon,klev,klev))
    1142       ALLOCATE(wght_cvfd(klon,klev))
    1143       ALLOCATE(phi2(klon,klev,klev))
    1144       ALLOCATE(d1a(klon,klev), dam(klon,klev))
    1145       ALLOCATE(ev(klon,klev))
    1146       ALLOCATE(elij(klon,klev,klev))
    1147       ALLOCATE(qtaa(klon,klev))
    1148       ALLOCATE(clw(klon,klev))
    1149       ALLOCATE(epmlmMm(klon,klev,klev), eplaMm(klon,klev))
    1150       ALLOCATE(sij(klon,klev,klev))
     1095    !
     1096    ALLOCATE(ptconv(klon, klev))
     1097    ALLOCATE(ratqsc(klon, klev))
     1098    !
     1099    ALLOCATE(wbeff(klon), convoccur(klon), zmax_th(klon))
     1100    ALLOCATE(zq2m(klon), zt2m(klon), weak_inversion(klon))
     1101    ALLOCATE(zt2m_min_mon(klon), zt2m_max_mon(klon))
     1102    ALLOCATE(t2m_min_mon(klon), t2m_max_mon(klon))
     1103    ALLOCATE(sens(klon), flwp(klon), fiwp(klon))
     1104    ALLOCATE(alp_bl_conv(klon), alp_bl_det(klon))
     1105    alp_bl_conv(:) = 0 ;  alp_bl_det(:) = 0
     1106    ALLOCATE(alp_bl_fluct_m(klon), alp_bl_fluct_tke(klon))
     1107    alp_bl_fluct_m(:) = 0 ; alp_bl_fluct_tke(:) = 0.
     1108    ALLOCATE(alp_bl_stat(klon), n2(klon), s2(klon), strig(klon), zcong(klon), zlcl_th(klon))
     1109    alp_bl_stat(:) = 0
     1110    ALLOCATE(proba_notrig(klon), random_notrig(klon))
     1111
     1112    ALLOCATE(dnwd0(klon, klev))
     1113    !      ALLOCATE(upwd(klon, klev), omega(klon, klev), coefh(klon, klev))
     1114    ALLOCATE(omega(klon, klev))
     1115    ALLOCATE(epmax_diag(klon)) ! epmax_cape
     1116    !      ALLOCATE(coefm(klon, klev), lambda_th(klon, klev), cldemi(klon, klev))
     1117    ALLOCATE(lambda_th(klon, klev), cldemi(klon, klev))
     1118    ALLOCATE(cldfra(klon, klev), cldtau(klon, klev), fiwc(klon, klev))
     1119    ALLOCATE(fl(klon, klev), re(klon, klev), flwc(klon, klev))
     1120    ALLOCATE(ref_liq(klon, klev), ref_ice(klon, klev), theta(klon, klev))
     1121    ALLOCATE(ref_liq_pi(klon, klev), ref_ice_pi(klon, klev))
     1122    ALLOCATE(zphi(klon, klev), zx_rh(klon, klev), zx_rhl(klon, klev), zx_rhi(klon, klev))
     1123    zx_rhl(:, :) = 0.; zx_rhi(:, :) = 0. ! because not always defined
     1124    ALLOCATE(pmfd(klon, klev), pmfu(klon, klev))
     1125
     1126    ALLOCATE(t2m(klon, nbsrf), fluxlat(klon, nbsrf))
     1127    ALLOCATE(fsollw(klon, nbsrf))
     1128    ALLOCATE(fsolsw(klon, nbsrf), wfbils(klon, nbsrf))
     1129    ALLOCATE(wfevap(klon, nbsrf))
     1130    ALLOCATE(evap_pot(klon, nbsrf))
     1131    ! FC
     1132    ALLOCATE(zxfluxq(klon, klev), zxfluxt(klon, klev))
     1133    !
     1134    !  Deep convective variables used in phytrac
     1135    ALLOCATE(pmflxr(klon, klev + 1), pmflxs(klon, klev + 1))
     1136    ALLOCATE(wdtrainA(klon, klev), wdtrainS(klon, klev), wdtrainM(klon, klev))
     1137    ALLOCATE(dnwd(klon, klev), upwd(klon, klev))
     1138    ALLOCATE(ep(klon, klev))                          ! epmax_cape
     1139    ALLOCATE(da(klon, klev), mp(klon, klev))
     1140    ALLOCATE(phi(klon, klev, klev))
     1141    ALLOCATE(wght_cvfd(klon, klev))
     1142    ALLOCATE(phi2(klon, klev, klev))
     1143    ALLOCATE(d1a(klon, klev), dam(klon, klev))
     1144    ALLOCATE(ev(klon, klev))
     1145    ALLOCATE(elij(klon, klev, klev))
     1146    ALLOCATE(qtaa(klon, klev))
     1147    ALLOCATE(clw(klon, klev))
     1148    ALLOCATE(epmlmMm(klon, klev, klev), eplaMm(klon, klev))
     1149    ALLOCATE(sij(klon, klev, klev))
    11511150#ifdef ISO
    11521151      ALLOCATE(xtwdtrainA(ntraciso,klon,klev))
     
    11731172#endif
    11741173
    1175       ALLOCATE(prfl(klon, klev+1))
    1176       ALLOCATE(psfl(klon, klev+1), fraca(klon, klev+1), Vprecip(klon, klev+1))
    1177       ALLOCATE(bsfl(klon,klev+1))
    1178       ALLOCATE(zw2(klon, klev+1))
    1179 
    1180       ALLOCATE(fluxu(klon, klev, nbsrf), fluxv(klon, klev, nbsrf))
    1181       ALLOCATE(fluxt(klon, klev, nbsrf))
    1182 
    1183       ALLOCATE(uwriteSTD(klon,nlevSTD,nfiles), vwriteSTD(klon,nlevSTD,nfiles))
    1184       ALLOCATE(wwriteSTD(klon,nlevSTD,nfiles), phiwriteSTD(klon,nlevSTD,nfiles))
    1185       ALLOCATE(qwriteSTD(klon,nlevSTD,nfiles), twriteSTD(klon,nlevSTD,nfiles))
    1186       ALLOCATE(rhwriteSTD(klon,nlevSTD,nfiles))
    1187 
    1188 ! ug et d'autres encore:
    1189       ALLOCATE(beta_prec(klon,klev))
    1190       ALLOCATE(rneb(klon,klev),rnebjn(klon,klev),rneblsvol(klon,klev))
    1191       ALLOCATE(pfraclr(klon,klev),pfracld(klon,klev))
    1192       pfraclr(:,:)=0. ; pfracld(:,:)=0. ! because not always defined
    1193       ALLOCATE(cldfraliq(klon,klev))
    1194       ALLOCATE(sigma2_icefracturb(klon,klev))
    1195       ALLOCATE(mean_icefracturb(klon,klev))
    1196       ALLOCATE(distcltop(klon,klev))
    1197       ALLOCATE(temp_cltop(klon,klev))
    1198 
    1199 
    1200       ALLOCATE (zxsnow(klon),snowhgt(klon),qsnow(klon),to_ice(klon))
    1201       ALLOCATE (sissnow(klon),runoff(klon),albsol3_lic(klon))
     1174    ALLOCATE(prfl(klon, klev + 1))
     1175    ALLOCATE(psfl(klon, klev + 1), fraca(klon, klev + 1), Vprecip(klon, klev + 1))
     1176    ALLOCATE(bsfl(klon, klev + 1))
     1177    ALLOCATE(zw2(klon, klev + 1))
     1178
     1179    ALLOCATE(fluxu(klon, klev, nbsrf), fluxv(klon, klev, nbsrf))
     1180    ALLOCATE(fluxt(klon, klev, nbsrf))
     1181
     1182    ALLOCATE(uwriteSTD(klon, nlevSTD, nfiles), vwriteSTD(klon, nlevSTD, nfiles))
     1183    ALLOCATE(wwriteSTD(klon, nlevSTD, nfiles), phiwriteSTD(klon, nlevSTD, nfiles))
     1184    ALLOCATE(qwriteSTD(klon, nlevSTD, nfiles), twriteSTD(klon, nlevSTD, nfiles))
     1185    ALLOCATE(rhwriteSTD(klon, nlevSTD, nfiles))
     1186
     1187    ! ug et d'autres encore:
     1188    ALLOCATE(beta_prec(klon, klev))
     1189    ALLOCATE(rneb(klon, klev), rnebjn(klon, klev), rneblsvol(klon, klev))
     1190    ALLOCATE(pfraclr(klon, klev), pfracld(klon, klev))
     1191    pfraclr(:, :) = 0. ; pfracld(:, :) = 0. ! because not always defined
     1192    ALLOCATE(cldfraliq(klon, klev))
     1193    ALLOCATE(sigma2_icefracturb(klon, klev))
     1194    ALLOCATE(mean_icefracturb(klon, klev))
     1195    ALLOCATE(distcltop(klon, klev))
     1196    ALLOCATE(temp_cltop(klon, klev))
     1197
     1198    ALLOCATE (zxsnow(klon), snowhgt(klon), qsnow(klon), to_ice(klon))
     1199    ALLOCATE (sissnow(klon), runoff(klon), albsol3_lic(klon))
    12021200#ifdef ISO
    12031201      ALLOCATE (zxxtsnow(niso,klon))
     
    12061204#endif
    12071205
    1208       ALLOCATE (p_tropopause(klon))
    1209       ALLOCATE (z_tropopause(klon))
    1210       ALLOCATE (t_tropopause(klon))
    1211 
    1212       ALLOCATE(zn2mout(klon,6))
    1213 
    1214 ! Supersaturation
    1215       ALLOCATE(rneb_seri(klon,klev))
    1216       ALLOCATE(d_rneb_dyn(klon,klev))
    1217       ALLOCATE(qclr(klon,klev), qcld(klon,klev), qss(klon,klev), qvc(klon,klev))
    1218       ALLOCATE(rnebclr(klon,klev), rnebss(klon,klev), gamma_ss(klon,klev))
    1219       ALLOCATE(N1_ss(klon,klev), N2_ss(klon,klev))
    1220       ALLOCATE(drneb_sub(klon,klev), drneb_con(klon,klev), drneb_tur(klon,klev), drneb_avi(klon,klev))
    1221       ALLOCATE(zqsatl(klon,klev), zqsats(klon,klev))
    1222       ALLOCATE(Tcontr(klon,klev), qcontr(klon,klev), qcontr2(klon,klev), fcontrN(klon,klev), fcontrP(klon,klev))
    1223 
    1224 !--POPRECIP variables
    1225       ALLOCATE(qraindiag(klon,klev), qsnowdiag(klon,klev))
    1226       ALLOCATE(dqreva(klon,klev), dqssub(klon,klev))
    1227       ALLOCATE(dqrauto(klon,klev), dqrcol(klon,klev), dqrmelt(klon,klev), dqrfreez(klon,klev))
    1228       ALLOCATE(dqsauto(klon,klev), dqsagg(klon,klev), dqsrim(klon,klev), dqsmelt(klon,klev), dqsfreez(klon,klev))
    1229 
    1230 #ifdef CPP_StratAer
    1231       ALLOCATE (d_q_emiss(klon,klev))
    1232       ALLOCATE (R2SO4(klon,klev))
    1233       ALLOCATE (R2SO4B(klon,klev,nbtr_bin))
    1234       ALLOCATE (DENSO4(klon,klev))
    1235       ALLOCATE (DENSO4B(klon,klev,nbtr_bin))
    1236       ALLOCATE (f_r_wet(klon,klev))
    1237       ALLOCATE (f_r_wetB(klon,klev,nbtr_bin))
    1238       ALLOCATE (decfluxaer(klon,nbtr))
     1206    ALLOCATE (p_tropopause(klon))
     1207    ALLOCATE (z_tropopause(klon))
     1208    ALLOCATE (t_tropopause(klon))
     1209
     1210    ALLOCATE(zn2mout(klon, 6))
     1211
     1212    ! Supersaturation
     1213    ALLOCATE(rneb_seri(klon, klev))
     1214    ALLOCATE(d_rneb_dyn(klon, klev))
     1215    ALLOCATE(qclr(klon, klev), qcld(klon, klev), qss(klon, klev), qvc(klon, klev))
     1216    ALLOCATE(rnebclr(klon, klev), rnebss(klon, klev), gamma_ss(klon, klev))
     1217    ALLOCATE(N1_ss(klon, klev), N2_ss(klon, klev))
     1218    ALLOCATE(drneb_sub(klon, klev), drneb_con(klon, klev), drneb_tur(klon, klev), drneb_avi(klon, klev))
     1219    ALLOCATE(zqsatl(klon, klev), zqsats(klon, klev))
     1220    ALLOCATE(Tcontr(klon, klev), qcontr(klon, klev), qcontr2(klon, klev), fcontrN(klon, klev), fcontrP(klon, klev))
     1221
     1222    !--POPRECIP variables
     1223    ALLOCATE(qraindiag(klon, klev), qsnowdiag(klon, klev))
     1224    ALLOCATE(dqreva(klon, klev), dqssub(klon, klev))
     1225    ALLOCATE(dqrauto(klon, klev), dqrcol(klon, klev), dqrmelt(klon, klev), dqrfreez(klon, klev))
     1226    ALLOCATE(dqsauto(klon, klev), dqsagg(klon, klev), dqsrim(klon, klev), dqsmelt(klon, klev), dqsfreez(klon, klev))
     1227
     1228    IF (CPPKEY_STRATAER) THEN
     1229      ALLOCATE (d_q_emiss(klon, klev))
     1230      ALLOCATE (R2SO4(klon, klev))
     1231      ALLOCATE (R2SO4B(klon, klev, nbtr_bin))
     1232      ALLOCATE (DENSO4(klon, klev))
     1233      ALLOCATE (DENSO4B(klon, klev, nbtr_bin))
     1234      ALLOCATE (f_r_wet(klon, klev))
     1235      ALLOCATE (f_r_wetB(klon, klev, nbtr_bin))
     1236      ALLOCATE (decfluxaer(klon, nbtr))
    12391237      ALLOCATE (mdw(nbtr))
    1240       ALLOCATE (budg_3D_nucl(klon,klev))
    1241       ALLOCATE (budg_3D_cond_evap(klon,klev))
    1242       ALLOCATE (budg_3D_ocs_to_so2(klon,klev))
    1243       ALLOCATE (budg_3D_so2_to_h2so4(klon,klev))
    1244       ALLOCATE (budg_3D_backgr_ocs(klon,klev))
    1245       ALLOCATE (budg_3D_backgr_so2(klon,klev))
    1246       ALLOCATE (OCS_lifetime(klon,klev))
    1247       ALLOCATE (SO2_lifetime(klon,klev))
    1248       ALLOCATE (H2SO4_lifetime(klon,klev))
    1249       ALLOCATE (O3_clim(klon,klev))
    1250       ALLOCATE (alpha_bin(nbands_sw_rrtm+nbands_lw_rrtm+nwave,nbtr))
    1251       ALLOCATE (piz_bin(nbands_sw_rrtm+nbands_lw_rrtm+nwave,nbtr))
    1252       ALLOCATE (cg_bin(nbands_sw_rrtm+nbands_lw_rrtm+nwave,nbtr))
    1253       ALLOCATE (tau_strat_550(klon,klev))
    1254       ALLOCATE (tau_strat_1020(klon,klev))
    1255       ALLOCATE (tausum_strat(klon,3))
     1238      ALLOCATE (budg_3D_nucl(klon, klev))
     1239      ALLOCATE (budg_3D_cond_evap(klon, klev))
     1240      ALLOCATE (budg_3D_ocs_to_so2(klon, klev))
     1241      ALLOCATE (budg_3D_so2_to_h2so4(klon, klev))
     1242      ALLOCATE (budg_3D_backgr_ocs(klon, klev))
     1243      ALLOCATE (budg_3D_backgr_so2(klon, klev))
     1244      ALLOCATE (OCS_lifetime(klon, klev))
     1245      ALLOCATE (SO2_lifetime(klon, klev))
     1246      ALLOCATE (H2SO4_lifetime(klon, klev))
     1247      ALLOCATE (O3_clim(klon, klev))
     1248      ALLOCATE (alpha_bin(nbands_sw_rrtm + nbands_lw_rrtm + nwave, nbtr))
     1249      ALLOCATE (piz_bin(nbands_sw_rrtm + nbands_lw_rrtm + nwave, nbtr))
     1250      ALLOCATE (cg_bin(nbands_sw_rrtm + nbands_lw_rrtm + nwave, nbtr))
     1251      ALLOCATE (tau_strat_550(klon, klev))
     1252      ALLOCATE (tau_strat_1020(klon, klev))
     1253      ALLOCATE (tausum_strat(klon, 3))
    12561254      ALLOCATE (budg_dep_dry_ocs(klon))
    12571255      ALLOCATE (budg_dep_wet_ocs(klon))
     
    12711269      ALLOCATE (budg_sed_part(klon))
    12721270      ALLOCATE (surf_PM25_sulf(klon))
    1273       ALLOCATE (vsed_aer(klon,klev))
    1274       ALLOCATE (sulfmmr(klon,klev))
    1275       ALLOCATE (SAD_sulfate(klon,klev))
    1276       ALLOCATE (sulfmmr_mode(klon,klev,nbtr_bin))
    1277       ALLOCATE (nd_mode(klon,klev,nbtr_bin))
    1278 #endif
    1279 
    1280 END SUBROUTINE phys_local_var_init
    1281 
    1282 !======================================================================
    1283 SUBROUTINE phys_local_var_end
    1284 USE dimphy
    1285 USE indice_sol_mod
    1286 IMPLICIT NONE
    1287       DEALLOCATE(t_seri,q_seri,ql_seri,qs_seri, qbs_seri)
    1288 ! SN 4D ISO
    1289       DEALLOCATE(qx_seri)
    1290 ! SN
    1291       DEALLOCATE(u_seri,v_seri)
    1292       DEALLOCATE(l_mixmin,l_mix,wprime)
    1293       DEALLOCATE(tke_shear,tke_buoy,tke_trans)
    1294       DEALLOCATE(pbl_eps)
    1295       DEALLOCATE(rhcl)
    1296       DEALLOCATE(tr_seri)
    1297       DEALLOCATE(d_t_dyn,d_q_dyn)
    1298       DEALLOCATE(d_ql_dyn,d_qs_dyn, d_qbs_dyn)
    1299       DEALLOCATE(d_q_dyn2d,d_ql_dyn2d,d_qs_dyn2d, d_qbs_dyn2d)
    1300       DEALLOCATE(d_u_dyn,d_v_dyn)
    1301       DEALLOCATE(d_tr_dyn)                      !RomP
    1302       DEALLOCATE(d_t_con,d_q_con,d_q_con_zmasse)
    1303       DEALLOCATE(d_u_con,d_v_con)
    1304       DEALLOCATE(d_t_wake,d_q_wake)
    1305       DEALLOCATE(d_t_lsc,d_q_lsc)
    1306       DEALLOCATE(d_t_lwr,d_t_lw0)
    1307       DEALLOCATE(d_t_swr,d_t_sw0)
    1308       DEALLOCATE(d_ql_lsc,d_qi_lsc)
    1309       DEALLOCATE(d_t_ajsb,d_q_ajsb)
    1310       DEALLOCATE(d_t_ajs,d_q_ajs)
    1311 !nrlmd<
    1312       DEALLOCATE(d_t_ajs_w,d_q_ajs_w)
    1313       DEALLOCATE(d_t_ajs_x,d_q_ajs_x)
    1314 !>nrlmd
    1315       DEALLOCATE(d_u_ajs,d_v_ajs)
    1316       DEALLOCATE(d_t_eva,d_q_eva)
    1317 ! SN 4D ISO
    1318       DEALLOCATE(d_qx_eva)
    1319 ! SN
    1320       DEALLOCATE(d_ql_eva,d_qi_eva)
    1321       DEALLOCATE(d_t_lscst,d_q_lscst)
    1322       DEALLOCATE(d_t_lscth,d_q_lscth)
    1323       DEALLOCATE(plul_st,plul_th)
    1324       DEALLOCATE(d_t_vdf,d_q_vdf,d_t_diss)
    1325       DEALLOCATE(d_qbs_vdf)
    1326       DEALLOCATE(d_t_bsss,d_q_bsss,d_qbs_bsss)
     1271      ALLOCATE (vsed_aer(klon, klev))
     1272      ALLOCATE (sulfmmr(klon, klev))
     1273      ALLOCATE (SAD_sulfate(klon, klev))
     1274      ALLOCATE (sulfmmr_mode(klon, klev, nbtr_bin))
     1275      ALLOCATE (nd_mode(klon, klev, nbtr_bin))
     1276    END IF
     1277
     1278  END SUBROUTINE phys_local_var_init
     1279
     1280  !======================================================================
     1281  SUBROUTINE phys_local_var_end
     1282    USE dimphy
     1283    USE indice_sol_mod
     1284    IMPLICIT NONE
     1285    DEALLOCATE(t_seri, q_seri, ql_seri, qs_seri, qbs_seri)
     1286    ! SN 4D ISO
     1287    DEALLOCATE(qx_seri)
     1288    ! SN
     1289    DEALLOCATE(u_seri, v_seri)
     1290    DEALLOCATE(l_mixmin, l_mix, wprime)
     1291    DEALLOCATE(tke_shear, tke_buoy, tke_trans)
     1292    DEALLOCATE(pbl_eps)
     1293    DEALLOCATE(rhcl)
     1294    DEALLOCATE(tr_seri)
     1295    DEALLOCATE(d_t_dyn, d_q_dyn)
     1296    DEALLOCATE(d_ql_dyn, d_qs_dyn, d_qbs_dyn)
     1297    DEALLOCATE(d_q_dyn2d, d_ql_dyn2d, d_qs_dyn2d, d_qbs_dyn2d)
     1298    DEALLOCATE(d_u_dyn, d_v_dyn)
     1299    DEALLOCATE(d_tr_dyn)                      !RomP
     1300    DEALLOCATE(d_t_con, d_q_con, d_q_con_zmasse)
     1301    DEALLOCATE(d_u_con, d_v_con)
     1302    DEALLOCATE(d_t_wake, d_q_wake)
     1303    DEALLOCATE(d_t_lsc, d_q_lsc)
     1304    DEALLOCATE(d_t_lwr, d_t_lw0)
     1305    DEALLOCATE(d_t_swr, d_t_sw0)
     1306    DEALLOCATE(d_ql_lsc, d_qi_lsc)
     1307    DEALLOCATE(d_t_ajsb, d_q_ajsb)
     1308    DEALLOCATE(d_t_ajs, d_q_ajs)
     1309    !nrlmd<
     1310    DEALLOCATE(d_t_ajs_w, d_q_ajs_w)
     1311    DEALLOCATE(d_t_ajs_x, d_q_ajs_x)
     1312    !>nrlmd
     1313    DEALLOCATE(d_u_ajs, d_v_ajs)
     1314    DEALLOCATE(d_t_eva, d_q_eva)
     1315    ! SN 4D ISO
     1316    DEALLOCATE(d_qx_eva)
     1317    ! SN
     1318    DEALLOCATE(d_ql_eva, d_qi_eva)
     1319    DEALLOCATE(d_t_lscst, d_q_lscst)
     1320    DEALLOCATE(d_t_lscth, d_q_lscth)
     1321    DEALLOCATE(plul_st, plul_th)
     1322    DEALLOCATE(d_t_vdf, d_q_vdf, d_t_diss)
     1323    DEALLOCATE(d_qbs_vdf)
     1324    DEALLOCATE(d_t_bsss, d_q_bsss, d_qbs_bsss)
    13271325#ifdef ISO
    13281326      deallocate(xt_seri,xtl_seri,xts_seri,xtbs_seri)
     
    13471345#endif
    13481346
    1349       DEALLOCATE(d_u_vdf,d_v_vdf)
    1350       DEALLOCATE(d_t_oli,d_t_oro)
    1351       DEALLOCATE(d_u_oli,d_v_oli)
    1352       DEALLOCATE(d_u_oro,d_v_oro)
    1353       DEALLOCATE(d_t_oro_gw)
    1354       DEALLOCATE(d_u_oro_gw,d_v_oro_gw)
    1355       DEALLOCATE(d_t_lif,d_t_ec)
    1356       DEALLOCATE(d_u_lif,d_v_lif)
    1357       DEALLOCATE(d_ts, d_tr)
    1358       DEALLOCATE(topswad_aero,solswad_aero)
    1359       DEALLOCATE(topswai_aero,solswai_aero)
    1360       DEALLOCATE(topswad0_aero,solswad0_aero)
    1361       DEALLOCATE(toplwad_aero,sollwad_aero)
    1362       DEALLOCATE(toplwai_aero,sollwai_aero)
    1363       DEALLOCATE(toplwad0_aero,sollwad0_aero)
    1364       DEALLOCATE(topsw_aero,solsw_aero)
    1365       DEALLOCATE(topsw0_aero,solsw0_aero)
    1366       DEALLOCATE(topswcf_aero,solswcf_aero)
    1367       DEALLOCATE(stratomask)
    1368       DEALLOCATE(tausum_aero)
    1369       DEALLOCATE(drytausum_aero)
    1370       DEALLOCATE(tau3d_aero)
    1371       DEALLOCATE(dNovrN)
    1372       DEALLOCATE(zfice)
    1373       DEALLOCATE(od443aer)
    1374       DEALLOCATE(od550aer)
    1375       DEALLOCATE(od865aer)
    1376       DEALLOCATE(dryod550aer)
    1377       DEALLOCATE(abs550aer)
    1378       DEALLOCATE(ec550aer)
    1379       DEALLOCATE(od550lt1aer)
    1380       DEALLOCATE(sconcso4)
    1381       DEALLOCATE(sconcno3)
    1382       DEALLOCATE(sconcoa)
    1383       DEALLOCATE(sconcbc)
    1384       DEALLOCATE(sconcss)
    1385       DEALLOCATE(sconcdust)
    1386       DEALLOCATE(concso4)
    1387       DEALLOCATE(concno3)
    1388       DEALLOCATE(concoa)
    1389       DEALLOCATE(concbc)
    1390       DEALLOCATE(concss)
    1391       DEALLOCATE(concdust)
    1392       DEALLOCATE(loadso4)
    1393       DEALLOCATE(loadoa)
    1394       DEALLOCATE(loadbc)
    1395       DEALLOCATE(loadss)
    1396       DEALLOCATE(loaddust)
    1397       DEALLOCATE(loadno3)
    1398       DEALLOCATE(load_tmp1)
    1399       DEALLOCATE(load_tmp2)
    1400       DEALLOCATE(load_tmp3)
    1401       DEALLOCATE(load_tmp4)
    1402       DEALLOCATE(load_tmp5)
    1403       DEALLOCATE(load_tmp6)
    1404       DEALLOCATE(load_tmp7)
    1405       DEALLOCATE(load_tmp8)
    1406       DEALLOCATE(load_tmp9)
    1407       DEALLOCATE(load_tmp10)
    1408       DEALLOCATE(du_gwd_hines,dv_gwd_hines,d_t_hin)
    1409       DEALLOCATE(d_q_ch4)
    1410       DEALLOCATE(dv_gwd_rando,dv_gwd_front)
    1411       DEALLOCATE(east_gwstress,west_gwstress)
    1412 
    1413 !IM ajout variables CFMIP2/CMIP5
    1414       DEALLOCATE(topswad_aerop, solswad_aerop)
    1415       DEALLOCATE(topswai_aerop, solswai_aerop)
    1416       DEALLOCATE(topswad0_aerop, solswad0_aerop)
    1417       DEALLOCATE(topsw_aerop, topsw0_aerop)
    1418       DEALLOCATE(solsw_aerop, solsw0_aerop)
    1419       DEALLOCATE(topswcf_aerop, solswcf_aerop)
    1420 !CK LW diagnostics
    1421       DEALLOCATE(toplwad_aerop, sollwad_aerop)
    1422       DEALLOCATE(toplwai_aerop, sollwai_aerop)
    1423       DEALLOCATE(toplwad0_aerop, sollwad0_aerop)
    1424 
    1425 !AI Ajout pour Ecrad (3Deffect)
    1426       DEALLOCATE(topswad_aero_s2, solswad_aero_s2)
    1427       DEALLOCATE(topswai_aero_s2, solswai_aero_s2)
    1428       DEALLOCATE(topswad0_aero_s2, solswad0_aero_s2)
    1429       DEALLOCATE(topsw_aero_s2, topsw0_aero_s2)
    1430       DEALLOCATE(solsw_aero_s2, solsw0_aero_s2)
    1431       DEALLOCATE(topswcf_aero_s2, solswcf_aero_s2)
    1432 !CK LW diagnostics
    1433       DEALLOCATE(toplwad_aero_s2, sollwad_aero_s2)
    1434       DEALLOCATE(toplwai_aero_s2, sollwai_aero_s2)
    1435       DEALLOCATE(toplwad0_aero_s2, sollwad0_aero_s2)     
    1436 
    1437 ! FH Ajout de celles necessaires au phys_output_write_mod
    1438       DEALLOCATE(tal1, pal1, pab1, pab2)
    1439       DEALLOCATE(ptstar, pt0, slp)
    1440 !
    1441       DEALLOCATE(alp_wake)
    1442       DEALLOCATE(wake_h,wake_k)
    1443       DEALLOCATE(wake_omg)
    1444       DEALLOCATE(d_deltat_wk, d_deltaq_wk)
    1445       DEALLOCATE(d_s_wk, d_s_a_wk, d_dens_wk, d_dens_a_wk)
    1446       DEALLOCATE(d_deltat_wk_gw, d_deltaq_wk_gw)
    1447       DEALLOCATE(d_deltat_vdf, d_deltaq_vdf)
    1448 !!      DEALLOCATE( d_s_vdf, d_dens_vdf)
    1449       DEALLOCATE(d_deltat_the, d_deltaq_the)
    1450 !!      DEALLOCATE( d_s_the, d_dens_the)
    1451       DEALLOCATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
     1347    DEALLOCATE(d_u_vdf, d_v_vdf)
     1348    DEALLOCATE(d_t_oli, d_t_oro)
     1349    DEALLOCATE(d_u_oli, d_v_oli)
     1350    DEALLOCATE(d_u_oro, d_v_oro)
     1351    DEALLOCATE(d_t_oro_gw)
     1352    DEALLOCATE(d_u_oro_gw, d_v_oro_gw)
     1353    DEALLOCATE(d_t_lif, d_t_ec)
     1354    DEALLOCATE(d_u_lif, d_v_lif)
     1355    DEALLOCATE(d_ts, d_tr)
     1356    DEALLOCATE(topswad_aero, solswad_aero)
     1357    DEALLOCATE(topswai_aero, solswai_aero)
     1358    DEALLOCATE(topswad0_aero, solswad0_aero)
     1359    DEALLOCATE(toplwad_aero, sollwad_aero)
     1360    DEALLOCATE(toplwai_aero, sollwai_aero)
     1361    DEALLOCATE(toplwad0_aero, sollwad0_aero)
     1362    DEALLOCATE(topsw_aero, solsw_aero)
     1363    DEALLOCATE(topsw0_aero, solsw0_aero)
     1364    DEALLOCATE(topswcf_aero, solswcf_aero)
     1365    DEALLOCATE(stratomask)
     1366    DEALLOCATE(tausum_aero)
     1367    DEALLOCATE(drytausum_aero)
     1368    DEALLOCATE(tau3d_aero)
     1369    DEALLOCATE(dNovrN)
     1370    DEALLOCATE(zfice)
     1371    DEALLOCATE(od443aer)
     1372    DEALLOCATE(od550aer)
     1373    DEALLOCATE(od865aer)
     1374    DEALLOCATE(dryod550aer)
     1375    DEALLOCATE(abs550aer)
     1376    DEALLOCATE(ec550aer)
     1377    DEALLOCATE(od550lt1aer)
     1378    DEALLOCATE(sconcso4)
     1379    DEALLOCATE(sconcno3)
     1380    DEALLOCATE(sconcoa)
     1381    DEALLOCATE(sconcbc)
     1382    DEALLOCATE(sconcss)
     1383    DEALLOCATE(sconcdust)
     1384    DEALLOCATE(concso4)
     1385    DEALLOCATE(concno3)
     1386    DEALLOCATE(concoa)
     1387    DEALLOCATE(concbc)
     1388    DEALLOCATE(concss)
     1389    DEALLOCATE(concdust)
     1390    DEALLOCATE(loadso4)
     1391    DEALLOCATE(loadoa)
     1392    DEALLOCATE(loadbc)
     1393    DEALLOCATE(loadss)
     1394    DEALLOCATE(loaddust)
     1395    DEALLOCATE(loadno3)
     1396    DEALLOCATE(load_tmp1)
     1397    DEALLOCATE(load_tmp2)
     1398    DEALLOCATE(load_tmp3)
     1399    DEALLOCATE(load_tmp4)
     1400    DEALLOCATE(load_tmp5)
     1401    DEALLOCATE(load_tmp6)
     1402    DEALLOCATE(load_tmp7)
     1403    DEALLOCATE(load_tmp8)
     1404    DEALLOCATE(load_tmp9)
     1405    DEALLOCATE(load_tmp10)
     1406    DEALLOCATE(du_gwd_hines, dv_gwd_hines, d_t_hin)
     1407    DEALLOCATE(d_q_ch4)
     1408    DEALLOCATE(dv_gwd_rando, dv_gwd_front)
     1409    DEALLOCATE(east_gwstress, west_gwstress)
     1410
     1411    !IM ajout variables CFMIP2/CMIP5
     1412    DEALLOCATE(topswad_aerop, solswad_aerop)
     1413    DEALLOCATE(topswai_aerop, solswai_aerop)
     1414    DEALLOCATE(topswad0_aerop, solswad0_aerop)
     1415    DEALLOCATE(topsw_aerop, topsw0_aerop)
     1416    DEALLOCATE(solsw_aerop, solsw0_aerop)
     1417    DEALLOCATE(topswcf_aerop, solswcf_aerop)
     1418    !CK LW diagnostics
     1419    DEALLOCATE(toplwad_aerop, sollwad_aerop)
     1420    DEALLOCATE(toplwai_aerop, sollwai_aerop)
     1421    DEALLOCATE(toplwad0_aerop, sollwad0_aerop)
     1422
     1423    !AI Ajout pour Ecrad (3Deffect)
     1424    DEALLOCATE(topswad_aero_s2, solswad_aero_s2)
     1425    DEALLOCATE(topswai_aero_s2, solswai_aero_s2)
     1426    DEALLOCATE(topswad0_aero_s2, solswad0_aero_s2)
     1427    DEALLOCATE(topsw_aero_s2, topsw0_aero_s2)
     1428    DEALLOCATE(solsw_aero_s2, solsw0_aero_s2)
     1429    DEALLOCATE(topswcf_aero_s2, solswcf_aero_s2)
     1430    !CK LW diagnostics
     1431    DEALLOCATE(toplwad_aero_s2, sollwad_aero_s2)
     1432    DEALLOCATE(toplwai_aero_s2, sollwai_aero_s2)
     1433    DEALLOCATE(toplwad0_aero_s2, sollwad0_aero_s2)
     1434
     1435    ! FH Ajout de celles necessaires au phys_output_write_mod
     1436    DEALLOCATE(tal1, pal1, pab1, pab2)
     1437    DEALLOCATE(ptstar, pt0, slp)
     1438    !
     1439    DEALLOCATE(alp_wake)
     1440    DEALLOCATE(wake_h, wake_k)
     1441    DEALLOCATE(wake_omg)
     1442    DEALLOCATE(d_deltat_wk, d_deltaq_wk)
     1443    DEALLOCATE(d_s_wk, d_s_a_wk, d_dens_wk, d_dens_a_wk)
     1444    DEALLOCATE(d_deltat_wk_gw, d_deltaq_wk_gw)
     1445    DEALLOCATE(d_deltat_vdf, d_deltaq_vdf)
     1446    !!      DEALLOCATE( d_s_vdf, d_dens_vdf)
     1447    DEALLOCATE(d_deltat_the, d_deltaq_the)
     1448    !!      DEALLOCATE( d_s_the, d_dens_the)
     1449    DEALLOCATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
    14521450#ifdef ISO
    14531451      DEALLOCATE(d_deltaxt_wk)
     
    14561454      DEALLOCATE(d_deltaxt_vdf)
    14571455#endif
    1458 !
    1459       DEALLOCATE(bils)
    1460       DEALLOCATE(cdragm, cdragh, cldh, cldl)
    1461       DEALLOCATE(cldm, cldq, cldt, qsat2m)
    1462       DEALLOCATE(JrNt)
    1463       DEALLOCATE(dthmin, evap, snowerosion, fder, plcl, plfc)
    1464       DEALLOCATE(prw, prlw, prsw, prbsw, water_budget, zustar, zu10m, zv10m, rh2m, s_lcl)
    1465       DEALLOCATE(s_pblh, s_pblt, s_therm)
    1466 !
    1467 !nrlmd+jyg<
    1468       DEALLOCATE(s_pblh_x, s_pblh_w)
    1469       DEALLOCATE(s_lcl_x, s_lcl_w)
    1470 !>nrlmd+jyg
    1471 !
    1472       DEALLOCATE(slab_wfbils, tpot, tpote, ue)
    1473       DEALLOCATE(uq, ve, vq, zxffonte)
    1474       DEALLOCATE(uwat, vwat)
    1475       DEALLOCATE(zxfqcalving, zxfluxlat)
    1476       DEALLOCATE(zxrunofflic)
    1477       DEALLOCATE(zxustartlic, zxrhoslic, zxqsaltlic)
    1478       DEALLOCATE(zxtsol, snow_lsc, zxfqfonte, zxqsurf)
    1479       DEALLOCATE(rain_lsc)
    1480       DEALLOCATE(rain_num)
    1481       DEALLOCATE(qlth, qith, qsith, wiceth)
    1482 !
    1483       DEALLOCATE(sens_x, sens_w)
    1484       DEALLOCATE(zxfluxlat_x, zxfluxlat_w)
    1485       DEALLOCATE(delta_qsurf)
    1486 !jyg<
    1487 !!      DEALLOCATE(t_x, t_w)
    1488 !!      DEALLOCATE(q_x, q_w)
    1489 !>jyg
    1490       DEALLOCATE(d_t_vdf_x, d_t_vdf_w)
    1491       DEALLOCATE(d_q_vdf_x, d_q_vdf_w)
    1492       DEALLOCATE(pbl_tke_input)
    1493       DEALLOCATE(t_therm, q_therm, u_therm, v_therm)
    1494       DEALLOCATE(cdragh_x, cdragh_w)
    1495       DEALLOCATE(cdragm_x, cdragm_w)
    1496       DEALLOCATE(kh, kh_x, kh_w)
     1456    !
     1457    DEALLOCATE(bils)
     1458    DEALLOCATE(cdragm, cdragh, cldh, cldl)
     1459    DEALLOCATE(cldm, cldq, cldt, qsat2m)
     1460    DEALLOCATE(JrNt)
     1461    DEALLOCATE(dthmin, evap, snowerosion, fder, plcl, plfc)
     1462    DEALLOCATE(prw, prlw, prsw, prbsw, water_budget, zustar, zu10m, zv10m, rh2m, s_lcl)
     1463    DEALLOCATE(s_pblh, s_pblt, s_therm)
     1464    !
     1465    !nrlmd+jyg<
     1466    DEALLOCATE(s_pblh_x, s_pblh_w)
     1467    DEALLOCATE(s_lcl_x, s_lcl_w)
     1468    !>nrlmd+jyg
     1469    !
     1470    DEALLOCATE(slab_wfbils, tpot, tpote, ue)
     1471    DEALLOCATE(uq, ve, vq, zxffonte)
     1472    DEALLOCATE(uwat, vwat)
     1473    DEALLOCATE(zxfqcalving, zxfluxlat)
     1474    DEALLOCATE(zxrunofflic)
     1475    DEALLOCATE(zxustartlic, zxrhoslic, zxqsaltlic)
     1476    DEALLOCATE(zxtsol, snow_lsc, zxfqfonte, zxqsurf)
     1477    DEALLOCATE(rain_lsc)
     1478    DEALLOCATE(rain_num)
     1479    DEALLOCATE(qlth, qith, qsith, wiceth)
     1480    !
     1481    DEALLOCATE(sens_x, sens_w)
     1482    DEALLOCATE(zxfluxlat_x, zxfluxlat_w)
     1483    DEALLOCATE(delta_qsurf)
     1484    !jyg<
     1485    !!      DEALLOCATE(t_x, t_w)
     1486    !!      DEALLOCATE(q_x, q_w)
     1487    !>jyg
     1488    DEALLOCATE(d_t_vdf_x, d_t_vdf_w)
     1489    DEALLOCATE(d_q_vdf_x, d_q_vdf_w)
     1490    DEALLOCATE(pbl_tke_input)
     1491    DEALLOCATE(t_therm, q_therm, u_therm, v_therm)
     1492    DEALLOCATE(cdragh_x, cdragh_w)
     1493    DEALLOCATE(cdragm_x, cdragm_w)
     1494    DEALLOCATE(kh, kh_x, kh_w)
    14971495#ifdef ISO
    14981496      DEALLOCATE(xtevap,xtprw)
     
    15051503      DEALLOCATE(h1_diag,runoff_diag,xtrunoff_diag)
    15061504#endif
    1507 !
    1508       DEALLOCATE(ptconv)
    1509       DEALLOCATE(ratqsc)
    1510 !
    1511       DEALLOCATE(wbeff, convoccur, zmax_th)
    1512       DEALLOCATE(zq2m, zt2m, weak_inversion)
    1513       DEALLOCATE(zt2m_min_mon, zt2m_max_mon)
    1514       DEALLOCATE(t2m_min_mon, t2m_max_mon)
    1515       DEALLOCATE(sens, flwp, fiwp)
    1516       DEALLOCATE(alp_bl_conv,alp_bl_det)
    1517       DEALLOCATE(alp_bl_fluct_m,alp_bl_fluct_tke)
    1518       DEALLOCATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
    1519       DEALLOCATE(proba_notrig, random_notrig)
    1520 !FC
    1521       DEALLOCATE(zxfluxq,zxfluxt)
    1522 
    1523       DEALLOCATE(dnwd0)
    1524 !      DEALLOCATE(upwd, omega, coefh)
    1525       DEALLOCATE(omega)
    1526       DEALLOCATE(epmax_diag)
    1527 !      DEALLOCATE(coefm, lambda_th, cldemi)
    1528       DEALLOCATE(lambda_th, cldemi)
    1529       DEALLOCATE(cldfra, cldtau, fiwc)
    1530       DEALLOCATE(fl, re, flwc)
    1531       DEALLOCATE(ref_liq, ref_ice, theta)
    1532       DEALLOCATE(ref_liq_pi, ref_ice_pi)
    1533       DEALLOCATE(zphi, zx_rh, zx_rhl, zx_rhi)
    1534       DEALLOCATE(pmfd, pmfu)
    1535 
    1536       DEALLOCATE(t2m, fluxlat)
    1537       DEALLOCATE(fsollw, evap_pot)
    1538       DEALLOCATE(fsolsw, wfbils)
    1539       DEALLOCATE(wfevap)
    1540 
    1541       DEALLOCATE(pmflxr, pmflxs)
    1542       DEALLOCATE(wdtrainA, wdtrainS, wdtrainM)
    1543       DEALLOCATE(upwd, dnwd)
    1544       DEALLOCATE(ep)
    1545       DEALLOCATE(da, mp)
    1546       DEALLOCATE(phi)
    1547       DEALLOCATE(wght_cvfd)
    1548       DEALLOCATE(phi2)
    1549       DEALLOCATE(d1a, dam)
    1550       DEALLOCATE(ev)
    1551       DEALLOCATE(elij)
    1552       DEALLOCATE(qtaa)
    1553       DEALLOCATE(clw)
    1554       DEALLOCATE(epmlmMm, eplaMm)
    1555       DEALLOCATE(sij)
     1505    !
     1506    DEALLOCATE(ptconv)
     1507    DEALLOCATE(ratqsc)
     1508    !
     1509    DEALLOCATE(wbeff, convoccur, zmax_th)
     1510    DEALLOCATE(zq2m, zt2m, weak_inversion)
     1511    DEALLOCATE(zt2m_min_mon, zt2m_max_mon)
     1512    DEALLOCATE(t2m_min_mon, t2m_max_mon)
     1513    DEALLOCATE(sens, flwp, fiwp)
     1514    DEALLOCATE(alp_bl_conv, alp_bl_det)
     1515    DEALLOCATE(alp_bl_fluct_m, alp_bl_fluct_tke)
     1516    DEALLOCATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
     1517    DEALLOCATE(proba_notrig, random_notrig)
     1518    !FC
     1519    DEALLOCATE(zxfluxq, zxfluxt)
     1520
     1521    DEALLOCATE(dnwd0)
     1522    !      DEALLOCATE(upwd, omega, coefh)
     1523    DEALLOCATE(omega)
     1524    DEALLOCATE(epmax_diag)
     1525    !      DEALLOCATE(coefm, lambda_th, cldemi)
     1526    DEALLOCATE(lambda_th, cldemi)
     1527    DEALLOCATE(cldfra, cldtau, fiwc)
     1528    DEALLOCATE(fl, re, flwc)
     1529    DEALLOCATE(ref_liq, ref_ice, theta)
     1530    DEALLOCATE(ref_liq_pi, ref_ice_pi)
     1531    DEALLOCATE(zphi, zx_rh, zx_rhl, zx_rhi)
     1532    DEALLOCATE(pmfd, pmfu)
     1533
     1534    DEALLOCATE(t2m, fluxlat)
     1535    DEALLOCATE(fsollw, evap_pot)
     1536    DEALLOCATE(fsolsw, wfbils)
     1537    DEALLOCATE(wfevap)
     1538
     1539    DEALLOCATE(pmflxr, pmflxs)
     1540    DEALLOCATE(wdtrainA, wdtrainS, wdtrainM)
     1541    DEALLOCATE(upwd, dnwd)
     1542    DEALLOCATE(ep)
     1543    DEALLOCATE(da, mp)
     1544    DEALLOCATE(phi)
     1545    DEALLOCATE(wght_cvfd)
     1546    DEALLOCATE(phi2)
     1547    DEALLOCATE(d1a, dam)
     1548    DEALLOCATE(ev)
     1549    DEALLOCATE(elij)
     1550    DEALLOCATE(qtaa)
     1551    DEALLOCATE(clw)
     1552    DEALLOCATE(epmlmMm, eplaMm)
     1553    DEALLOCATE(sij)
    15561554#ifdef ISO
    15571555      DEALLOCATE(xtwdtrainA)
     
    15791577
    15801578
    1581       DEALLOCATE(prfl, psfl, bsfl, fraca, Vprecip)
    1582       DEALLOCATE(zw2)
    1583 
    1584       DEALLOCATE(fluxu, fluxv)
    1585       DEALLOCATE(fluxt)
    1586 
    1587       DEALLOCATE(uwriteSTD, vwriteSTD)
    1588       DEALLOCATE(wwriteSTD, phiwriteSTD)
    1589       DEALLOCATE(qwriteSTD, twriteSTD, rhwriteSTD)
    1590 
    1591 ! ug et d'autres encore:
    1592       DEALLOCATE(beta_prec)
    1593       DEALLOCATE(rneb)
    1594       DEALLOCATE(pfraclr,pfracld)
    1595       DEALLOCATE(cldfraliq)
    1596       DEALLOCATE(sigma2_icefracturb)
    1597       DEALLOCATE(mean_icefracturb)
    1598       DEALLOCATE (zxsnow,snowhgt,qsnow,to_ice,sissnow,runoff,albsol3_lic)
    1599       DEALLOCATE(distcltop)
    1600       DEALLOCATE(temp_cltop)
     1579    DEALLOCATE(prfl, psfl, bsfl, fraca, Vprecip)
     1580    DEALLOCATE(zw2)
     1581
     1582    DEALLOCATE(fluxu, fluxv)
     1583    DEALLOCATE(fluxt)
     1584
     1585    DEALLOCATE(uwriteSTD, vwriteSTD)
     1586    DEALLOCATE(wwriteSTD, phiwriteSTD)
     1587    DEALLOCATE(qwriteSTD, twriteSTD, rhwriteSTD)
     1588
     1589    ! ug et d'autres encore:
     1590    DEALLOCATE(beta_prec)
     1591    DEALLOCATE(rneb)
     1592    DEALLOCATE(pfraclr, pfracld)
     1593    DEALLOCATE(cldfraliq)
     1594    DEALLOCATE(sigma2_icefracturb)
     1595    DEALLOCATE(mean_icefracturb)
     1596    DEALLOCATE (zxsnow, snowhgt, qsnow, to_ice, sissnow, runoff, albsol3_lic)
     1597    DEALLOCATE(distcltop)
     1598    DEALLOCATE(temp_cltop)
    16011599#ifdef ISO
    16021600      DEALLOCATE (zxxtsnow,xtVprecip,xtVprecipi,pxtrfl,pxtsfl)
    16031601#endif
    16041602
    1605       DEALLOCATE (p_tropopause)
    1606       DEALLOCATE (z_tropopause)
    1607       DEALLOCATE (t_tropopause)
    1608       DEALLOCATE(zn2mout)
    1609 
    1610 ! Supersaturation
    1611       DEALLOCATE(rneb_seri)
    1612       DEALLOCATE(d_rneb_dyn)
    1613       DEALLOCATE(qclr, qcld, qss, qvc)
    1614       DEALLOCATE(rnebclr, rnebss, gamma_ss)
    1615       DEALLOCATE(N1_ss, N2_ss)
    1616       DEALLOCATE(drneb_sub, drneb_con, drneb_tur, drneb_avi)
    1617       DEALLOCATE(zqsatl, zqsats)
    1618       DEALLOCATE(Tcontr, qcontr, qcontr2, fcontrN, fcontrP)
    1619 
    1620 !--POPRECIP variables
    1621       DEALLOCATE(qraindiag, qsnowdiag)
    1622       DEALLOCATE(dqreva, dqssub)
    1623       DEALLOCATE(dqrauto, dqrcol, dqrmelt, dqrfreez)
    1624       DEALLOCATE(dqsauto, dqsagg, dqsrim, dqsmelt, dqsfreez)
    1625 
    1626 #ifdef CPP_StratAer
    1627 ! variables for strat. aerosol CK
     1603    DEALLOCATE (p_tropopause)
     1604    DEALLOCATE (z_tropopause)
     1605    DEALLOCATE (t_tropopause)
     1606    DEALLOCATE(zn2mout)
     1607
     1608    ! Supersaturation
     1609    DEALLOCATE(rneb_seri)
     1610    DEALLOCATE(d_rneb_dyn)
     1611    DEALLOCATE(qclr, qcld, qss, qvc)
     1612    DEALLOCATE(rnebclr, rnebss, gamma_ss)
     1613    DEALLOCATE(N1_ss, N2_ss)
     1614    DEALLOCATE(drneb_sub, drneb_con, drneb_tur, drneb_avi)
     1615    DEALLOCATE(zqsatl, zqsats)
     1616    DEALLOCATE(Tcontr, qcontr, qcontr2, fcontrN, fcontrP)
     1617
     1618    !--POPRECIP variables
     1619    DEALLOCATE(qraindiag, qsnowdiag)
     1620    DEALLOCATE(dqreva, dqssub)
     1621    DEALLOCATE(dqrauto, dqrcol, dqrmelt, dqrfreez)
     1622    DEALLOCATE(dqsauto, dqsagg, dqsrim, dqsmelt, dqsfreez)
     1623
     1624    IF (CPPKEY_STRATAER) THEN
     1625      ! variables for strat. aerosol CK
    16281626      DEALLOCATE (d_q_emiss)
    16291627      DEALLOCATE (R2SO4, R2SO4B)
     
    16701668      DEALLOCATE (budg_h2so4_to_part)
    16711669      DEALLOCATE (budg_sed_part)
    1672 #endif
    1673 
    1674 END SUBROUTINE phys_local_var_end
     1670    END IF
     1671
     1672  END SUBROUTINE phys_local_var_end
    16751673
    16761674END MODULE phys_local_var_mod
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_ctrlout_mod.F90

    r5056 r5098  
    14401440    'flx_co2_land_cor', 'correction of the CO2 flux from the land', 'kg CO2 m-2 s-1', (/ ('', i=1, 10) /))
    14411441
    1442 #ifdef CPP_StratAer
    14431442!--extinction coefficient
    14441443  TYPE(ctrl_out), SAVE :: o_ext_strat_550 = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
     
    15171516  TYPE(ctrl_out), SAVE :: o_surf_PM25_sulf = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
    15181517    'surf_PM25_sulf', 'Sulfate PM2.5 concentration at the surface', 'ug/m3', (/ ('', i=1, 10) /))
    1519 #endif
    15201518
    15211519!!!!!!!!!!!!!!!!!!!!!! 3D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_mod.F90

    r5082 r5098  
    4949    ! ug Pour les sorties XIOS
    5050    USE wxios
    51 #ifdef CPP_StratAer
    5251   USE infotrac_phy, ONLY: nbtr_bin
    53 #endif
    5452#ifdef ISO
    5553    USE isotopes_mod, ONLY: isoName,iso_HTO
     
    5856#endif
    5957#endif
     58    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
    6059
    6160    IMPLICIT NONE
     
    171170    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
    172171    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
    173 #ifdef CPP_StratAer
     172IF (CPPKEY_STRATAER) THEN
    174173    ALLOCATE(o_nd_mode(nbtr_bin),o_sulfmmr_mode(nbtr_bin))
    175 #endif
     174END IF
    176175#ifdef ISO
    177176    ALLOCATE(o_xtprecip(ntraciso))
     
    233232    clef_files(8) = ok_histNMC(2)
    234233    clef_files(9) = ok_histNMC(3)
    235 #ifdef CPP_StratAer
    236     clef_files(10)= .TRUE.
    237 #else
    238     clef_files(10)= .FALSE.
    239 #endif
     234    clef_files(10)= CPPKEY_STRATAER
    240235
    241236    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
     
    545540            tnam = 'cum'//TRIM(tracers(iq)%name); o_trac_cum(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
    546541           
    547 #ifdef CPP_StratAer
     542IF (CPPKEY_STRATAER) THEN
    548543            if(tracers(iq)%name(1:3)=='BIN') then
    549544               itrb = itrb + 1
     
    554549               tnam = TRIM(tracers(iq)%name)//'_sulfmmr_mode';o_sulfmmr_mode  (itrb) = ctrl_out(flag, tnam, lnam, "kg(H2SO4)/kg(air)", [('',i=1,nfiles)])
    555550            endif
    556 #endif
     551END IF
    557552         ENDDO
    558553
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phys_output_write_mod.F90

    r5088 r5098  
    244244#endif
    245245
    246 #ifdef CPP_StratAer
    247246    USE infotrac_phy, ONLY: nbtr_bin
    248247    USE phys_output_ctrlout_mod, ONLY:  &
     
    259258         o_vsed_aer, o_tau_strat_1020, o_ext_strat_1020, o_f_r_wet, &
    260259         o_SAD_sulfate, o_sulfmmr, o_nd_mode, o_sulfmmr_mode
    261 #endif
    262260
    263261    USE ice_sursat_mod, ONLY: flight_m, flight_h2o
     
    402400    USE phys_output_var_mod, ONLY: scdnc, cldncl, reffclwtop, lcc, reffclws, &
    403401         reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra
    404    
    405 #ifdef CPP_StratAer
     402
    406403    USE phys_local_var_mod, ONLY:  &
    407404         budg_3D_nucl, budg_3D_cond_evap, budg_3D_ocs_to_so2, budg_3D_so2_to_h2so4, &
     
    417414         vsed_aer, tau_strat_1020, f_r_wet, &
    418415         SAD_sulfate, sulfmmr, nd_mode, sulfmmr_mode
    419 #endif
     416    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
    420417
    421418    USE carbon_cycle_mod, ONLY: fco2_ff, fco2_bb, fco2_land, fco2_ocean
     
    526523    REAL, DIMENSION(klon,klev) :: coefh_stok
    527524   
    528 #ifdef CPP_StratAer
    529525    LOGICAL, PARAMETER :: debug_strataer=.FALSE.
    530526    CHARACTER(LEN=maxlen) :: unt
    531 #endif
    532527    REAL,DIMENSION(klon,klev) :: z, dz
    533528    REAL,DIMENSION(klon)      :: zrho, zt
     
    18081803! end add ThL
    18091804
    1810 #ifdef CPP_StratAer
     1805IF (CPPKEy_STRATAER) THEN
    18111806       IF (type_trac=='coag') THEN
    18121807          CALL histwrite_phy(o_R2SO4, R2SO4)
     
    18501845          ENDDO !--itr
    18511846       ENDIF
    1852 #endif
     1847END IF
    18531848       !NL
    18541849       IF (ok_volcan .AND. ok_ade) THEN
  • LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90

    r5091 r5098  
    9494    USE phys_output_var_mod, ONLY : cloud_cover_sw, cloud_cover_sw_s2
    9595
     96    USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
     97    USE time_phylmdz_mod,  ONLY: ndays
     98    USE infotrac_phy,      ONLY: nqCO2
     99
     100    USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
     101    USE vertical_layers_mod, ONLY: aps, bps, ap, bp
     102
     103
     104    USE lmdz_xios, ONLY: xios_update_calendar, xios_context_finalize, xios_get_field_attr, &
     105            xios_field_is_active, xios_context, xios_set_current_context
     106    USE wxios, ONLY: missing_val, using_xios
     107    USE paramLMDZ_phy_mod
    96108
    97109    !USE cmp_seri_mod
     
    110122#endif
    111123
    112 
    113     USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
    114     USE time_phylmdz_mod,  ONLY: ndays
    115     USE infotrac_phy,      ONLY: nqCO2
    116124#ifdef REPROBUS
    117125    USE chem_rep, ONLY: Init_chem_rep_xjour, d_q_rep, d_ql_rep, d_qi_rep, &
     
    120128    USE strataer_emiss_mod, ONLY: strataer_emiss_init
    121129#endif
    122     USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
    123     USE vertical_layers_mod, ONLY: aps, bps, ap, bp
    124 
    125130
    126131#ifdef CPP_RRTM
     
    129134#endif
    130135
    131 
    132 #ifdef CPP_StratAer
    133136    USE phys_local_var_mod, ONLY: d_q_emiss
    134137    USE strataer_local_var_mod
    135138    USE strataer_nuc_mod, ONLY: strataer_nuc_init
    136139    USE strataer_emiss_mod, ONLY: strataer_emiss_init
    137 #endif
    138 
    139     USE lmdz_xios, ONLY: xios_update_calendar, xios_context_finalize
    140     USE lmdz_xios, ONLY: xios_get_field_attr, xios_field_is_active, xios_context
    141     USE lmdz_xios, ONLY: xios_set_current_context
    142     USE wxios, ONLY: missing_val, using_xios
    143 
    144 #ifndef CPP_XIOS
    145     USE paramLMDZ_phy_mod
    146 #endif
     140    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
    147141!
    148142!
     
    363357       reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra
    364358       USE output_physiqex_mod, ONLY: output_physiqex
    365     USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
     359        USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    366360
    367361
     
    17641758       WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
    17651759
    1766 #ifndef CPP_XIOS
     1760      IF (.NOT. using_xios) THEN
    17671761       CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
    1768 #endif
     1762      END IF
    17691763
    17701764#endif
     
    18911885#endif
    18921886
    1893 #ifdef CPP_StratAer
     1887IF (CPPKEY_STRATAER) THEN
    18941888       CALL strataer_init
    18951889       CALL strataer_nuc_init
    18961890       CALL strataer_emiss_init
    1897 #endif
     1891END IF
    18981892
    18991893#ifdef CPP_Dust
     
    43464340          ELSE
    43474341#ifdef CPP_RRTM
    4348 #ifndef CPP_StratAer
     4342IF (.NOT. CPPKEY_STRATAER) THEN
    43494343          !--prescribed strat aerosols
    43504344          !--only in the case of non-interactive strat aerosols
     
    43574351             CALL abort_physic(modname,abort_message,1)
    43584352            ENDIF
    4359 #endif
     4353END IF
    43604354#else
    43614355             abort_message='You should compile with -rrtm if running ' &
     
    43694363!
    43704364#ifdef CPP_RRTM
    4371 #ifdef CPP_StratAer
     4365IF (CPPKEY_STRATAER) THEN
    43724366       !--compute stratospheric mask
    43734367       CALL stratosphere_mask(missing_val, pphis, t_seri, pplay, latitude_deg)
    43744368       !--interactive strat aerosols
    43754369       CALL calcaerosolstrato_rrtm(pplay,t_seri,paprs,debut)
    4376 #endif
     4370END IF
    43774371#endif
    43784372       !--fin STRAT AEROSOL
     
    49874981    IF (ok_qch4) THEN
    49884982!      d_q_ch4: H2O source from CH4 in MMR/s (mass mixing ratio/s or kg H2O/kg air/s)
    4989 #ifdef CPP_StratAer
     4983IF (CPPKEY_STRATAER) THEN
    49904984       CALL stratH2O_methox(debut,paprs,d_q_ch4)
    4991 #else
     4985ELSE
    49924986!      ECMWF routine METHOX
    49934987       CALL METHOX(1,klon,klon,klev,q_seri,d_q_ch4,pplay)
    4994 #endif
     4988END IF
    49954989       ! add humidity tendency due to methane
    49964990       d_q_ch4_dtime(:,:) = d_q_ch4(:,:)*phys_tstep
     
    50014995    !
    50024996    !
    5003 #ifdef CPP_StratAer
     4997IF (CPPKEY_STRATAER) THEN
    50044998    IF (ok_qemiss) THEN
    50054999       flh2o=1
     
    50445038       END SELECT ! emission scenario (flag_emit)
    50455039    ENDIF
    5046 #endif
     5040END IF
    50475041
    50485042!===============================================================
     
    54195413    ENDDO
    54205414
    5421 #ifdef CPP_StratAer
     5415IF (CPPKEY_STRATAER) THEN
    54225416    IF (ok_qemiss) THEN
    54235417       DO k = 1, klev
     
    54255419       ENDDO
    54265420    ENDIF
    5427 #endif
     5421END IF
    54285422    IF (ok_qch4) THEN
    54295423       DO k = 1, klev
     
    57265720#endif
    57275721
    5728 #ifndef CPP_XIOS
     5722    IF (.NOT. using_xios) THEN
    57295723      CALL write_paramLMDZ_phy(itap,nid_ctesGCM,ok_sync)
    5730 #endif
     5724    END IF
    57315725
    57325726#endif
  • LMDZ6/branches/Amaury_dev/libf/phylmd/phytrac_mod.F90

    r5091 r5098  
    11!$Id$
    22MODULE phytrac_mod
    3 !=================================================================================
    4 ! Interface between the LMDZ physical package and tracer computation.
    5 ! Chemistry modules (INCA, Reprobus or the more specific traclmdz routine)
    6 ! are called from phytrac.
    7 !
    8 !======================================================================
    9 ! Auteur(s) FH
    10 ! Objet: Moniteur general des tendances traceurs
    11 !
    12 ! iflag_vdf_trac : Options for activating transport by vertical diffusion :
    13 !     1. notmal
    14 !     0. emission is injected in the first layer only, without diffusion
    15 !    -1  no emission & no diffusion
    16 ! Modification 2013/07/22 : transformed into a module to pass tendencies to
    17 !     physics outputs. Additional keys for controling activation of sub processes.
    18 ! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
    19 ! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
    20 !=================================================================================
    21 
    22 !
    23 ! Tracer tendencies, for outputs
    24 !-------------------------------
    25   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_cl  ! Td couche limite/traceur
    26   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_dec                            !RomP
    27   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_cv  ! Td convection/traceur
    28 ! RomP >>>
    29   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_insc
    30   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_bcscav
    31   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_evapls
    32   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_ls
    33   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_trsp
    34   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_sscav
    35   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_sat
    36   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_uscav
    37   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qPr,qDi ! concentration tra dans pluie,air descente insaturee
    38   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qPa,qMel
    39   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qTrdi,dtrcvMA ! conc traceur descente air insaturee et td convective MA
    40 ! RomP <<<
    41   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_th  ! Td thermique
    42   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_lessi_impa ! Td du lessivage par impaction
    43   REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_lessi_nucl ! Td du lessivage par nucleation
    44   REAL,DIMENSION(:,:),ALLOCATABLE,SAVE  :: qPrls      !jyg: concentration tra dans pluie LS a la surf.
    45   REAL,DIMENSION(:,:),ALLOCATABLE,SAVE  :: d_tr_dry ! Td depot sec/traceur (1st layer),ALLOCATABLE,SAVE  jyg
    46   REAL,DIMENSION(:,:),ALLOCATABLE,SAVE  :: flux_tr_dry ! depot sec/traceur (surface),ALLOCATABLE,SAVE    jyg
    47 
    48 !$OMP THREADPRIVATE(qPa,qMel,qTrdi,dtrcvMA,d_tr_th,d_tr_lessi_impa,d_tr_lessi_nucl)
    49 !$OMP THREADPRIVATE(d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qPr,qDi)
    50 !$OMP THREADPRIVATE(d_tr_insc,d_tr_bcscav,d_tr_evapls,d_tr_ls,qPrls)
    51 !$OMP THREADPRIVATE(d_tr_cl,d_tr_dry,flux_tr_dry,d_tr_dec,d_tr_cv)
     3  !=================================================================================
     4  ! Interface between the LMDZ physical package and tracer computation.
     5  ! Chemistry modules (INCA, Reprobus or the more specific traclmdz routine)
     6  ! are called from phytrac.
     7  !
     8  !======================================================================
     9  ! Auteur(s) FH
     10  ! Objet: Moniteur general des tendances traceurs
     11  !
     12  ! iflag_vdf_trac : Options for activating transport by vertical diffusion :
     13  !     1. notmal
     14  !     0. emission is injected in the first layer only, without diffusion
     15  !    -1  no emission & no diffusion
     16  ! Modification 2013/07/22 : transformed into a module to pass tendencies to
     17  !     physics outputs. Additional keys for controling activation of sub processes.
     18  ! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
     19  ! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
     20  !=================================================================================
     21
     22  !
     23  ! Tracer tendencies, for outputs
     24  !-------------------------------
     25  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_cl  ! Td couche limite/traceur
     26  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_dec                            !RomP
     27  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_cv  ! Td convection/traceur
     28  ! RomP >>>
     29  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_insc
     30  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_bcscav
     31  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_evapls
     32  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_ls
     33  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_trsp
     34  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_sscav
     35  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_sat
     36  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_uscav
     37  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: qPr, qDi ! concentration tra dans pluie,air descente insaturee
     38  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: qPa, qMel
     39  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: qTrdi, dtrcvMA ! conc traceur descente air insaturee et td convective MA
     40  ! RomP <<<
     41  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_th  ! Td thermique
     42  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_lessi_impa ! Td du lessivage par impaction
     43  REAL, DIMENSION(:, :, :), ALLOCATABLE, SAVE :: d_tr_lessi_nucl ! Td du lessivage par nucleation
     44  REAL, DIMENSION(:, :), ALLOCATABLE, SAVE :: qPrls      !jyg: concentration tra dans pluie LS a la surf.
     45  REAL, DIMENSION(:, :), ALLOCATABLE, SAVE :: d_tr_dry ! Td depot sec/traceur (1st layer),ALLOCATABLE,SAVE  jyg
     46  REAL, DIMENSION(:, :), ALLOCATABLE, SAVE :: flux_tr_dry ! depot sec/traceur (surface),ALLOCATABLE,SAVE    jyg
     47
     48  !$OMP THREADPRIVATE(qPa,qMel,qTrdi,dtrcvMA,d_tr_th,d_tr_lessi_impa,d_tr_lessi_nucl)
     49  !$OMP THREADPRIVATE(d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qPr,qDi)
     50  !$OMP THREADPRIVATE(d_tr_insc,d_tr_bcscav,d_tr_evapls,d_tr_ls,qPrls)
     51  !$OMP THREADPRIVATE(d_tr_cl,d_tr_dry,flux_tr_dry,d_tr_dec,d_tr_cv)
    5252
    5353CONTAINS
     
    5656
    5757    USE dimphy
    58     USE infotrac_phy, ONLY: nbtr, type_trac
    59     USE tracco2i_mod, ONLY: tracco2i_init
    60    
     58    USE infotrac_phy, ONLY : nbtr, type_trac
     59    USE tracco2i_mod, ONLY : tracco2i_init
     60
    6161    IMPLICIT NONE
    6262
    63     ALLOCATE(d_tr_cl(klon,klev,nbtr),d_tr_dry(klon,nbtr))
    64     ALLOCATE(flux_tr_dry(klon,nbtr),d_tr_dec(klon,klev,nbtr),d_tr_cv(klon,klev,nbtr))
    65     ALLOCATE(d_tr_insc(klon,klev,nbtr),d_tr_bcscav(klon,klev,nbtr))
    66     ALLOCATE(d_tr_evapls(klon,klev,nbtr),d_tr_ls(klon,klev,nbtr))
    67     ALLOCATE(qPrls(klon,nbtr),d_tr_trsp(klon,klev,nbtr))
    68     ALLOCATE(d_tr_sscav(klon,klev,nbtr),d_tr_sat(klon,klev,nbtr))
    69     ALLOCATE(d_tr_uscav(klon,klev,nbtr),qPr(klon,klev,nbtr),qDi(klon,klev,nbtr))
    70     ALLOCATE(qPa(klon,klev,nbtr),qMel(klon,klev,nbtr))
    71     ALLOCATE(qTrdi(klon,klev,nbtr),dtrcvMA(klon,klev,nbtr))
    72     ALLOCATE(d_tr_th(klon,klev,nbtr))
    73     ALLOCATE(d_tr_lessi_impa(klon,klev,nbtr),d_tr_lessi_nucl(klon,klev,nbtr))
     63    ALLOCATE(d_tr_cl(klon, klev, nbtr), d_tr_dry(klon, nbtr))
     64    ALLOCATE(flux_tr_dry(klon, nbtr), d_tr_dec(klon, klev, nbtr), d_tr_cv(klon, klev, nbtr))
     65    ALLOCATE(d_tr_insc(klon, klev, nbtr), d_tr_bcscav(klon, klev, nbtr))
     66    ALLOCATE(d_tr_evapls(klon, klev, nbtr), d_tr_ls(klon, klev, nbtr))
     67    ALLOCATE(qPrls(klon, nbtr), d_tr_trsp(klon, klev, nbtr))
     68    ALLOCATE(d_tr_sscav(klon, klev, nbtr), d_tr_sat(klon, klev, nbtr))
     69    ALLOCATE(d_tr_uscav(klon, klev, nbtr), qPr(klon, klev, nbtr), qDi(klon, klev, nbtr))
     70    ALLOCATE(qPa(klon, klev, nbtr), qMel(klon, klev, nbtr))
     71    ALLOCATE(qTrdi(klon, klev, nbtr), dtrcvMA(klon, klev, nbtr))
     72    ALLOCATE(d_tr_th(klon, klev, nbtr))
     73    ALLOCATE(d_tr_lessi_impa(klon, klev, nbtr), d_tr_lessi_nucl(klon, klev, nbtr))
    7474
    7575    !===============================================================================
    7676    !    -- Do specific treatment according to chemestry model or local LMDZ tracers
    77     !     
     77    !
    7878    !===============================================================================
    7979    !   -- CO2 interactif --
    80     IF (ANY(type_trac == ['co2i','inco'])) CALL tracco2i_init()
    81 
    82        !   -- type_trac == 'co2i' ! PC
    83        !   -- CO2 interactif --
    84        !   -- source is updated with FF and BB emissions
    85        !   -- and net fluxes from ocean and orchidee
    86        !   -- sign convention : positive into the atmosphere
     80    IF (ANY(type_trac == ['co2i', 'inco'])) CALL tracco2i_init()
     81
     82    !   -- type_trac == 'co2i' ! PC
     83    !   -- CO2 interactif --
     84    !   -- source is updated with FF and BB emissions
     85    !   -- and net fluxes from ocean and orchidee
     86    !   -- sign convention : positive into the atmosphere
    8787
    8888  END SUBROUTINE phytrac_init
    8989
    90   SUBROUTINE phytrac(                                 &
    91        nstep,     julien,   gmtime,   debutphy,      &
    92        lafin,     pdtphys,  u, v,     t_seri,        &
    93        paprs,     pplay,    pmfu,     pmfd,          &
    94        pen_u,     pde_u,    pen_d,    pde_d,          &
    95        cdragh,    coefh,    fm_therm, entr_therm,    &
    96        yu1,       yv1,      ftsol,    pctsrf,        &
    97        ustar,     u10m,      v10m,                    &
    98        wstar,     ale_bl,      ale_wake,              &
    99        xlat,      xlon,                              &
    100        frac_impa,frac_nucl,beta_fisrt,beta_v1,        &
    101        presnivs,  pphis,    pphi,     albsol,        &
    102        sh,        ch, rh,   cldfra,   rneb,          &
    103        diafra,    cldliq,   itop_con, ibas_con,      &
    104        pmflxr,    pmflxs,   prfl,     psfl,          &
    105        da,        phi,      mp,       upwd,          &
    106        phi2,      d1a,      dam,      sij, wght_cvfd, &   ! RomP +RL
    107        wdtrainA,  wdtrainM, sigd,     clw, elij,      &   ! RomP
    108        evap,      ep,       epmlmMm,  eplaMm,        &   ! RomP
    109        dnwd,      aerosol_couple,     flxmass_w,      &
    110        tau_aero,  piz_aero,  cg_aero, ccm,            &
    111        rfname,                                        &
    112        d_tr_dyn,                                      &   ! RomP
    113        tr_seri, init_source)         
     90  SUBROUTINE phytrac(&
     91          nstep, julien, gmtime, debutphy, &
     92          lafin, pdtphys, u, v, t_seri, &
     93          paprs, pplay, pmfu, pmfd, &
     94          pen_u, pde_u, pen_d, pde_d, &
     95          cdragh, coefh, fm_therm, entr_therm, &
     96          yu1, yv1, ftsol, pctsrf, &
     97          ustar, u10m, v10m, &
     98          wstar, ale_bl, ale_wake, &
     99          xlat, xlon, &
     100          frac_impa, frac_nucl, beta_fisrt, beta_v1, &
     101          presnivs, pphis, pphi, albsol, &
     102          sh, ch, rh, cldfra, rneb, &
     103          diafra, cldliq, itop_con, ibas_con, &
     104          pmflxr, pmflxs, prfl, psfl, &
     105          da, phi, mp, upwd, &
     106          phi2, d1a, dam, sij, wght_cvfd, &   ! RomP +RL
     107          wdtrainA, wdtrainM, sigd, clw, elij, &   ! RomP
     108          evap, ep, epmlmMm, eplaMm, &   ! RomP
     109          dnwd, aerosol_couple, flxmass_w, &
     110          tau_aero, piz_aero, cg_aero, ccm, &
     111          rfname, &
     112          d_tr_dyn, &   ! RomP
     113          tr_seri, init_source)
    114114    !
    115115    !======================================================================
     
    123123    USE phys_cal_mod, only : hour
    124124    USE dimphy
    125     USE infotrac_phy, ONLY: nbtr, nqCO2, type_trac, conv_flg, pbl_flg
    126     USE strings_mod,  ONLY: int2str
     125    USE infotrac_phy, ONLY : nbtr, nqCO2, type_trac, conv_flg, pbl_flg
     126    USE strings_mod, ONLY : int2str
    127127    USE mod_grid_phy_lmdz
    128128    USE mod_phys_lmdz_para
     
    132132    USE tracreprobus_mod
    133133    USE indice_sol_mod
    134     USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
    135     USE print_control_mod, ONLY: lunout
     134    USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
     135    USE print_control_mod, ONLY : lunout
    136136    USE aero_mod, ONLY : naero_grp
    137137    USE lmdz_thermcell_dq, ONLY : thermcell_dq
     
    139139    USE tracco2i_mod
    140140
    141 #ifdef CPP_StratAer
    142141    USE traccoag_mod
    143     USE phys_local_var_mod, ONLY: mdw
    144     USE phys_local_var_mod, ONLY: budg_dep_dry_ocs,  budg_dep_wet_ocs
    145     USE phys_local_var_mod, ONLY: budg_dep_dry_so2,  budg_dep_wet_so2
    146     USE phys_local_var_mod, ONLY: budg_dep_dry_h2so4, budg_dep_wet_h2so4
    147     USE phys_local_var_mod, ONLY: budg_dep_dry_part, budg_dep_wet_part
    148     USE infotrac_phy, ONLY: nbtr_sulgas, id_OCS_strat, id_SO2_strat, id_H2SO4_strat
     142    USE phys_local_var_mod, ONLY : mdw
     143    USE phys_local_var_mod, ONLY : budg_dep_dry_ocs, budg_dep_wet_ocs
     144    USE phys_local_var_mod, ONLY : budg_dep_dry_so2, budg_dep_wet_so2
     145    USE phys_local_var_mod, ONLY : budg_dep_dry_h2so4, budg_dep_wet_h2so4
     146    USE phys_local_var_mod, ONLY : budg_dep_dry_part, budg_dep_wet_part
     147    USE infotrac_phy, ONLY : nbtr_sulgas, id_OCS_strat, id_SO2_strat, id_H2SO4_strat
    149148    USE strataer_nuc_mod, ONLY : tracstrataer_init
    150149    USE aerophys
    151 #endif
     150    USE lmdz_cppkeys_wrapper, ONLY : CPPKEY_STRATAER
     151    USE lmdz_yomcst
    152152
    153153    IMPLICIT NONE
    154154
    155     INCLUDE "YOMCST.h"
    156155    INCLUDE "clesphys.h"
    157156    !==========================================================================
     
    162161    !----------------
    163162    !Configuration grille,temps:
    164     INTEGER,INTENT(IN) :: nstep      ! Appel physique
    165     INTEGER,INTENT(IN) :: julien     ! Jour julien
    166     REAL,INTENT(IN)    :: gmtime     ! Heure courante
    167     REAL,INTENT(IN)    :: pdtphys    ! Pas d'integration pour la physique (seconde)
    168     LOGICAL,INTENT(IN) :: debutphy   ! le flag de l'initialisation de la physique
    169     LOGICAL,INTENT(IN) :: lafin      ! le flag de la fin de la physique
    170 
    171     REAL,DIMENSION(klon),INTENT(IN) :: xlat    ! latitudes pour chaque point
    172     REAL,DIMENSION(klon),INTENT(IN) :: xlon    ! longitudes pour chaque point
    173     !
    174     !Physique: 
     163    INTEGER, INTENT(IN) :: nstep      ! Appel physique
     164    INTEGER, INTENT(IN) :: julien     ! Jour julien
     165    REAL, INTENT(IN) :: gmtime     ! Heure courante
     166    REAL, INTENT(IN) :: pdtphys    ! Pas d'integration pour la physique (seconde)
     167    LOGICAL, INTENT(IN) :: debutphy   ! le flag de l'initialisation de la physique
     168    LOGICAL, INTENT(IN) :: lafin      ! le flag de la fin de la physique
     169
     170    REAL, DIMENSION(klon), INTENT(IN) :: xlat    ! latitudes pour chaque point
     171    REAL, DIMENSION(klon), INTENT(IN) :: xlon    ! longitudes pour chaque point
     172    !
     173    !Physique:
    175174    !--------
    176     REAL,DIMENSION(klon,klev),INTENT(IN)  :: t_seri  ! Temperature
    177     REAL,DIMENSION(klon,klev),INTENT(IN)   :: u       ! variable not used
    178     REAL,DIMENSION(klon,klev),INTENT(IN)   :: v       ! variable not used
    179     REAL,DIMENSION(klon,klev),INTENT(IN)  :: sh      ! humidite specifique
    180     REAL,DIMENSION(klon,klev),INTENT(IN)  :: rh      ! humidite relative
    181     REAL,DIMENSION(klon,klev),INTENT(IN)   :: ch      ! eau liquide (+ glace si le traceur existe)
    182     REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
    183     REAL,DIMENSION(klon,klev),INTENT(IN)  :: pplay   ! pression pour le mileu de chaque couche (en Pa)
    184     REAL,DIMENSION(klon,klev),INTENT(IN)  :: pphi    ! geopotentiel
    185     REAL,DIMENSION(klon),INTENT(IN)        :: pphis
    186     REAL,DIMENSION(klev),INTENT(IN)        :: presnivs
    187     REAL,DIMENSION(klon,klev),INTENT(IN)  :: cldliq  ! eau condensee totale
    188     REAL,DIMENSION(klon,klev),INTENT(IN)  :: cldfra  ! fraction nuageuse (tous les nuages)
    189     REAL,DIMENSION(klon,klev),INTENT(IN)  :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
    190     REAL,DIMENSION(klon,klev),INTENT(IN)  :: rneb    ! fraction nuageuse (grande echelle)
    191     !
    192     REAL                                   :: ql_incl ! contenu en eau liquide nuageuse dans le nuage ! ql_incl=oliq/rneb
    193     REAL,DIMENSION(klon,klev),INTENT(IN)  :: beta_fisrt ! taux de conversion de l'eau cond (de fisrtilp)
    194     REAL,DIMENSION(klon,klev),INTENT(out) :: beta_v1    ! -- (originale version)
    195 
    196     !
    197     INTEGER,DIMENSION(klon),INTENT(IN)    :: itop_con
    198     INTEGER,DIMENSION(klon),INTENT(IN)    :: ibas_con
    199     REAL,DIMENSION(klon),INTENT(IN)        :: albsol  ! albedo surface
     175    REAL, DIMENSION(klon, klev), INTENT(IN) :: t_seri  ! Temperature
     176    REAL, DIMENSION(klon, klev), INTENT(IN) :: u       ! variable not used
     177    REAL, DIMENSION(klon, klev), INTENT(IN) :: v       ! variable not used
     178    REAL, DIMENSION(klon, klev), INTENT(IN) :: sh      ! humidite specifique
     179    REAL, DIMENSION(klon, klev), INTENT(IN) :: rh      ! humidite relative
     180    REAL, DIMENSION(klon, klev), INTENT(IN) :: ch      ! eau liquide (+ glace si le traceur existe)
     181    REAL, DIMENSION(klon, klev + 1), INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
     182    REAL, DIMENSION(klon, klev), INTENT(IN) :: pplay   ! pression pour le mileu de chaque couche (en Pa)
     183    REAL, DIMENSION(klon, klev), INTENT(IN) :: pphi    ! geopotentiel
     184    REAL, DIMENSION(klon), INTENT(IN) :: pphis
     185    REAL, DIMENSION(klev), INTENT(IN) :: presnivs
     186    REAL, DIMENSION(klon, klev), INTENT(IN) :: cldliq  ! eau condensee totale
     187    REAL, DIMENSION(klon, klev), INTENT(IN) :: cldfra  ! fraction nuageuse (tous les nuages)
     188    REAL, DIMENSION(klon, klev), INTENT(IN) :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
     189    REAL, DIMENSION(klon, klev), INTENT(IN) :: rneb    ! fraction nuageuse (grande echelle)
     190    !
     191    REAL :: ql_incl ! contenu en eau liquide nuageuse dans le nuage ! ql_incl=oliq/rneb
     192    REAL, DIMENSION(klon, klev), INTENT(IN) :: beta_fisrt ! taux de conversion de l'eau cond (de fisrtilp)
     193    REAL, DIMENSION(klon, klev), INTENT(out) :: beta_v1    ! -- (originale version)
     194
     195    !
     196    INTEGER, DIMENSION(klon), INTENT(IN) :: itop_con
     197    INTEGER, DIMENSION(klon), INTENT(IN) :: ibas_con
     198    REAL, DIMENSION(klon), INTENT(IN) :: albsol  ! albedo surface
    200199    !
    201200    !Dynamique
    202201    !--------
    203     REAL,DIMENSION(klon,klev,nbtr),INTENT(IN)    :: d_tr_dyn
     202    REAL, DIMENSION(klon, klev, nbtr), INTENT(IN) :: d_tr_dyn
    204203    !
    205204    !Convection:
    206205    !----------
    207     REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfu  ! flux de masse dans le panache montant
    208     REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfd  ! flux de masse dans le panache descendant
    209     REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_u ! flux entraine dans le panache montant
    210     REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_u ! flux detraine dans le panache montant
    211     REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_d ! flux entraine dans le panache descendant
    212     REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_d ! flux detraine dans le panache descendant
    213 
    214     !...Tiedke     
    215     REAL,DIMENSION(klon,klev+1),INTENT(IN)  :: pmflxr, pmflxs ! Flux precipitant de pluie, neige aux interfaces [convection]
    216     REAL,DIMENSION(klon,klev+1),INTENT(IN)  :: prfl, psfl ! Flux precipitant de pluie, neige aux interfaces [large-scale]
    217 
    218     LOGICAL,INTENT(IN)                      :: aerosol_couple
    219     REAL,DIMENSION(klon,klev),INTENT(IN)    :: flxmass_w
    220     REAL,DIMENSION(klon,klev,naero_grp,2),INTENT(IN) :: tau_aero
    221     REAL,DIMENSION(klon,klev,naero_grp,2),INTENT(IN) :: piz_aero
    222     REAL,DIMENSION(klon,klev,naero_grp,2),INTENT(IN) :: cg_aero
    223     CHARACTER(len=4),DIMENSION(naero_grp),INTENT(IN) :: rfname
    224     REAL,DIMENSION(klon,klev,2),INTENT(IN)   :: ccm
     206    REAL, DIMENSION(klon, klev), INTENT(IN) :: pmfu  ! flux de masse dans le panache montant
     207    REAL, DIMENSION(klon, klev), INTENT(IN) :: pmfd  ! flux de masse dans le panache descendant
     208    REAL, DIMENSION(klon, klev), INTENT(IN) :: pen_u ! flux entraine dans le panache montant
     209    REAL, DIMENSION(klon, klev), INTENT(IN) :: pde_u ! flux detraine dans le panache montant
     210    REAL, DIMENSION(klon, klev), INTENT(IN) :: pen_d ! flux entraine dans le panache descendant
     211    REAL, DIMENSION(klon, klev), INTENT(IN) :: pde_d ! flux detraine dans le panache descendant
     212
     213    !...Tiedke
     214    REAL, DIMENSION(klon, klev + 1), INTENT(IN) :: pmflxr, pmflxs ! Flux precipitant de pluie, neige aux interfaces [convection]
     215    REAL, DIMENSION(klon, klev + 1), INTENT(IN) :: prfl, psfl ! Flux precipitant de pluie, neige aux interfaces [large-scale]
     216
     217    LOGICAL, INTENT(IN) :: aerosol_couple
     218    REAL, DIMENSION(klon, klev), INTENT(IN) :: flxmass_w
     219    REAL, DIMENSION(klon, klev, naero_grp, 2), INTENT(IN) :: tau_aero
     220    REAL, DIMENSION(klon, klev, naero_grp, 2), INTENT(IN) :: piz_aero
     221    REAL, DIMENSION(klon, klev, naero_grp, 2), INTENT(IN) :: cg_aero
     222    CHARACTER(len = 4), DIMENSION(naero_grp), INTENT(IN) :: rfname
     223    REAL, DIMENSION(klon, klev, 2), INTENT(IN) :: ccm
    225224    !... K.Emanuel
    226     REAL,DIMENSION(klon,klev),INTENT(IN)    :: da
    227     REAL,DIMENSION(klon,klev,klev),INTENT(IN):: phi
     225    REAL, DIMENSION(klon, klev), INTENT(IN) :: da
     226    REAL, DIMENSION(klon, klev, klev), INTENT(IN) :: phi
    228227    ! RomP >>>
    229     REAL,DIMENSION(klon,klev),INTENT(IN)      :: d1a,dam
    230     REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: phi2
    231     !
    232     REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainA
    233     REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainM
    234     REAL,DIMENSION(klon),INTENT(IN)          :: sigd
     228    REAL, DIMENSION(klon, klev), INTENT(IN) :: d1a, dam
     229    REAL, DIMENSION(klon, klev, klev), INTENT(IN) :: phi2
     230    !
     231    REAL, DIMENSION(klon, klev), INTENT(IN) :: wdtrainA
     232    REAL, DIMENSION(klon, klev), INTENT(IN) :: wdtrainM
     233    REAL, DIMENSION(klon), INTENT(IN) :: sigd
    235234    ! ---- RomP flux entraine, detraine et precipitant kerry Emanuel
    236     REAL,DIMENSION(klon,klev),INTENT(IN)      :: evap
    237     REAL,DIMENSION(klon,klev),INTENT(IN)      :: ep
    238     REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: sij
    239     REAL,DIMENSION(klon,klev),INTENT(IN)      :: wght_cvfd          !RL
    240     REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: elij
    241     REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: epmlmMm
    242     REAL,DIMENSION(klon,klev),INTENT(IN)      :: eplaMm
    243     REAL,DIMENSION(klon,klev),INTENT(IN)      :: clw
     235    REAL, DIMENSION(klon, klev), INTENT(IN) :: evap
     236    REAL, DIMENSION(klon, klev), INTENT(IN) :: ep
     237    REAL, DIMENSION(klon, klev, klev), INTENT(IN) :: sij
     238    REAL, DIMENSION(klon, klev), INTENT(IN) :: wght_cvfd          !RL
     239    REAL, DIMENSION(klon, klev, klev), INTENT(IN) :: elij
     240    REAL, DIMENSION(klon, klev, klev), INTENT(IN) :: epmlmMm
     241    REAL, DIMENSION(klon, klev), INTENT(IN) :: eplaMm
     242    REAL, DIMENSION(klon, klev), INTENT(IN) :: clw
    244243    ! RomP <<<
    245244    !
    246     REAL,DIMENSION(klon,klev),INTENT(IN)    :: mp
    247     REAL,DIMENSION(klon,klev),INTENT(IN)    :: upwd      ! saturated updraft mass flux
    248     REAL,DIMENSION(klon,klev),INTENT(IN)    :: dnwd      ! saturated downdraft mass flux
     245    REAL, DIMENSION(klon, klev), INTENT(IN) :: mp
     246    REAL, DIMENSION(klon, klev), INTENT(IN) :: upwd      ! saturated updraft mass flux
     247    REAL, DIMENSION(klon, klev), INTENT(IN) :: dnwd      ! saturated downdraft mass flux
    249248    !
    250249    !Thermiques:
    251250    !----------
    252     REAL,DIMENSION(klon,klev+1),INTENT(IN)  :: fm_therm
    253     REAL,DIMENSION(klon,klev),INTENT(INOUT)    :: entr_therm
     251    REAL, DIMENSION(klon, klev + 1), INTENT(IN) :: fm_therm
     252    REAL, DIMENSION(klon, klev), INTENT(INOUT) :: entr_therm
    254253    !
    255254    !Couche limite:
    256255    !--------------
    257256    !
    258     REAL,DIMENSION(:),INTENT(IN)  :: cdragh          ! (klon) coeff drag pour T et Q
    259     REAL,DIMENSION(:,:),INTENT(IN) :: coefh           ! (klon,klev) coeff melange CL (m**2/s)
    260     REAL,DIMENSION(:),INTENT(IN)   :: ustar,u10m,v10m ! (klon) u* & vent a 10m (m/s)
    261     REAL,DIMENSION(:),INTENT(IN)   :: wstar,ale_bl,ale_wake ! (klon) w* and Avail. Lifting Ener.
    262     REAL,DIMENSION(:),INTENT(IN)  :: yu1             ! (klon) vents au premier niveau
    263     REAL,DIMENSION(:),INTENT(IN)  :: yv1             ! (klon) vents au premier niveau
     257    REAL, DIMENSION(:), INTENT(IN) :: cdragh          ! (klon) coeff drag pour T et Q
     258    REAL, DIMENSION(:, :), INTENT(IN) :: coefh           ! (klon,klev) coeff melange CL (m**2/s)
     259    REAL, DIMENSION(:), INTENT(IN) :: ustar, u10m, v10m ! (klon) u* & vent a 10m (m/s)
     260    REAL, DIMENSION(:), INTENT(IN) :: wstar, ale_bl, ale_wake ! (klon) w* and Avail. Lifting Ener.
     261    REAL, DIMENSION(:), INTENT(IN) :: yu1             ! (klon) vents au premier niveau
     262    REAL, DIMENSION(:), INTENT(IN) :: yv1             ! (klon) vents au premier niveau
    264263    !
    265264    !Lessivage:
     
    270269    REAL, DIMENSION(:), ALLOCATABLE, SAVE :: coefcoli
    271270    LOGICAL, DIMENSION(:), ALLOCATABLE, SAVE :: flag_cvltr
    272 !$OMP THREADPRIVATE(ccntrAA,ccntrENV,coefcoli,flag_cvltr)
    273     REAL, DIMENSION(klon,klev) :: ccntrAA_3d
    274     REAL, DIMENSION(klon,klev) :: ccntrENV_3d
    275     REAL, DIMENSION(klon,klev) :: coefcoli_3d
     271    !$OMP THREADPRIVATE(ccntrAA,ccntrENV,coefcoli,flag_cvltr)
     272    REAL, DIMENSION(klon, klev) :: ccntrAA_3d
     273    REAL, DIMENSION(klon, klev) :: ccntrENV_3d
     274    REAL, DIMENSION(klon, klev) :: coefcoli_3d
    276275    !
    277276    ! pour le ON-LINE
    278277    !
    279     REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_impa ! fraction d'aerosols non impactes
    280     REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_nucl ! fraction d'aerosols non nuclees
     278    REAL, DIMENSION(klon, klev), INTENT(IN) :: frac_impa ! fraction d'aerosols non impactes
     279    REAL, DIMENSION(klon, klev), INTENT(IN) :: frac_nucl ! fraction d'aerosols non nuclees
    281280
    282281    ! Arguments necessaires pour les sources et puits de traceur:
    283     REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: ftsol  ! Temperature du sol (surf)(Kelvin)
    284     REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol (nature du sol)
    285 
    286 #ifdef CPP_StratAer
    287     REAL,DIMENSION(klon)           :: v_dep_dry !dry deposition velocity of stratospheric sulfate in m/s
    288 #endif
     282    REAL, DIMENSION(klon, nbsrf), INTENT(IN) :: ftsol  ! Temperature du sol (surf)(Kelvin)
     283    REAL, DIMENSION(klon, nbsrf), INTENT(IN) :: pctsrf ! Pourcentage de sol (nature du sol)
     284
     285    REAL, DIMENSION(klon) :: v_dep_dry !dry deposition velocity of stratospheric sulfate in m/s
    289286    ! Output argument
    290287    !----------------
    291     REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT) :: tr_seri ! Concentration Traceur [U/KgA]
    292     REAL,DIMENSION(klon,klev)                    :: sourceBE
    293     REAL,DIMENSION(klon,nbtr), INTENT(IN) :: init_source
     288    REAL, DIMENSION(klon, klev, nbtr), INTENT(INOUT) :: tr_seri ! Concentration Traceur [U/KgA]
     289    REAL, DIMENSION(klon, klev) :: sourceBE
     290    REAL, DIMENSION(klon, nbtr), INTENT(IN) :: init_source
    294291
    295292    !=======================================================================================
     
    303300    !--------------------------------------------
    304301    !
    305     REAL,DIMENSION(:,:),ALLOCATABLE,SAVE :: source  ! a voir lorsque le flux de surface est prescrit
    306 !$OMP THREADPRIVATE(source)
     302    REAL, DIMENSION(:, :), ALLOCATABLE, SAVE :: source  ! a voir lorsque le flux de surface est prescrit
     303    !$OMP THREADPRIVATE(source)
    307304
    308305    !
    309306    !Entrees/Sorties:
    310307    !---------------
    311     INTEGER                   :: iiq, ierr
    312     INTEGER                   :: nhori, nvert
    313     REAL                      :: zsto, zout, zjulian
    314     INTEGER,SAVE              :: nid_tra     ! pointe vers le fichier histrac.nc         
    315 !$OMP THREADPRIVATE(nid_tra)
    316     REAL,DIMENSION(klon)      :: zx_tmp_fi2d ! variable temporaire grille physique
    317     INTEGER                   :: itau_w      ! pas de temps ecriture = nstep + itau_phy
    318     LOGICAL,PARAMETER         :: ok_sync=.TRUE.
     308    INTEGER :: iiq, ierr
     309    INTEGER :: nhori, nvert
     310    REAL :: zsto, zout, zjulian
     311    INTEGER, SAVE :: nid_tra     ! pointe vers le fichier histrac.nc
     312    !$OMP THREADPRIVATE(nid_tra)
     313    REAL, DIMENSION(klon) :: zx_tmp_fi2d ! variable temporaire grille physique
     314    INTEGER :: itau_w      ! pas de temps ecriture = nstep + itau_phy
     315    LOGICAL, PARAMETER :: ok_sync = .TRUE.
    319316    !
    320317    ! Nature du traceur
    321318    !------------------
    322     LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: aerosol  ! aerosol(it) = true  => aerosol => lessivage
    323 !$OMP THREADPRIVATE(aerosol)                        ! aerosol(it) = false => gaz
    324     REAL,DIMENSION(klon,klev)            :: delp     ! epaisseur de couche (Pa)
     319    LOGICAL, DIMENSION(:), ALLOCATABLE, SAVE :: aerosol  ! aerosol(it) = true  => aerosol => lessivage
     320    !$OMP THREADPRIVATE(aerosol)                        ! aerosol(it) = false => gaz
     321    REAL, DIMENSION(klon, klev) :: delp     ! epaisseur de couche (Pa)
    325322    !
    326323    ! Tendances de traceurs (Td) et flux de traceurs:
    327324    !------------------------
    328     REAL,DIMENSION(klon,klev)      :: d_tr     ! Td dans l'atmosphere
    329     REAL,DIMENSION(klon,klev)      :: Mint
    330     REAL,DIMENSION(klon,klev,nbtr) :: zmfd1a
    331     REAL,DIMENSION(klon,klev,nbtr) :: zmfdam
    332     REAL,DIMENSION(klon,klev,nbtr) :: zmfphi2
     325    REAL, DIMENSION(klon, klev) :: d_tr     ! Td dans l'atmosphere
     326    REAL, DIMENSION(klon, klev) :: Mint
     327    REAL, DIMENSION(klon, klev, nbtr) :: zmfd1a
     328    REAL, DIMENSION(klon, klev, nbtr) :: zmfdam
     329    REAL, DIMENSION(klon, klev, nbtr) :: zmfphi2
    333330    ! Physique
    334     !---------- 
    335     REAL,DIMENSION(klon,klev,nbtr) :: flestottr ! flux de lessivage dans chaque couche
    336     REAL,DIMENSION(klon,klev)      :: zmasse    ! densite atmospherique Kg/m2
    337     REAL,DIMENSION(klon,klev)      :: ztra_th
     331    !----------
     332    REAL, DIMENSION(klon, klev, nbtr) :: flestottr ! flux de lessivage dans chaque couche
     333    REAL, DIMENSION(klon, klev) :: zmasse    ! densite atmospherique Kg/m2
     334    REAL, DIMENSION(klon, klev) :: ztra_th
    338335    !PhH
    339     REAL,DIMENSION(klon,klev)      :: zrho
    340     REAL,DIMENSION(klon,klev)      :: zdz
    341     REAL                           :: evaplsc,dx,beta ! variable pour lessivage Genthon
    342     REAL,DIMENSION(klon)          :: his_dh          ! ---
     336    REAL, DIMENSION(klon, klev) :: zrho
     337    REAL, DIMENSION(klon, klev) :: zdz
     338    REAL :: evaplsc, dx, beta ! variable pour lessivage Genthon
     339    REAL, DIMENSION(klon) :: his_dh          ! ---
    343340    ! in-cloud scav variables
    344     REAL           :: ql_incloud_ref     ! ref value of in-cloud condensed water content
     341    REAL :: ql_incloud_ref     ! ref value of in-cloud condensed water content
    345342
    346343    !Controles:
    347344    !---------
    348     INTEGER,SAVE :: iflag_vdf_trac,iflag_con_trac,iflag_the_trac
    349     INTEGER,SAVE  :: iflag_con_trac_omp, iflag_vdf_trac_omp,iflag_the_trac_omp
    350 !$OMP THREADPRIVATE(iflag_vdf_trac,iflag_con_trac,iflag_the_trac)
    351 
    352     LOGICAL,SAVE :: lessivage
    353 !$OMP THREADPRIVATE(lessivage)
     345    INTEGER, SAVE :: iflag_vdf_trac, iflag_con_trac, iflag_the_trac
     346    INTEGER, SAVE :: iflag_con_trac_omp, iflag_vdf_trac_omp, iflag_the_trac_omp
     347    !$OMP THREADPRIVATE(iflag_vdf_trac,iflag_con_trac,iflag_the_trac)
     348
     349    LOGICAL, SAVE :: lessivage
     350    !$OMP THREADPRIVATE(lessivage)
    354351
    355352    !RomP >>>
    356     INTEGER,SAVE  :: iflag_lscav_omp,iflag_lscav
    357     REAL, SAVE ::   ccntrAA_in,ccntrAA_omp
    358     REAL, SAVE ::   ccntrENV_in,ccntrENV_omp
    359     REAL, SAVE ::   coefcoli_in,coefcoli_omp
    360 
    361     LOGICAL,SAVE  :: convscav_omp,convscav
    362 !$OMP THREADPRIVATE(iflag_lscav)
    363 !$OMP THREADPRIVATE(ccntrAA_in,ccntrENV_in,coefcoli_in)
    364 !$OMP THREADPRIVATE(convscav)
     353    INTEGER, SAVE :: iflag_lscav_omp, iflag_lscav
     354    REAL, SAVE :: ccntrAA_in, ccntrAA_omp
     355    REAL, SAVE :: ccntrENV_in, ccntrENV_omp
     356    REAL, SAVE :: coefcoli_in, coefcoli_omp
     357
     358    LOGICAL, SAVE :: convscav_omp, convscav
     359    !$OMP THREADPRIVATE(iflag_lscav)
     360    !$OMP THREADPRIVATE(ccntrAA_in,ccntrENV_in,coefcoli_in)
     361    !$OMP THREADPRIVATE(convscav)
    365362    !RomP <<<
    366363    !######################################################################
     
    368365    !######################################################################
    369366
    370     DO k=1,klev
    371        DO i=1,klon
    372           sourceBE(i,k)=0.
    373           Mint(i,k)=0.
    374           zrho(i,k)=0.
    375           zdz(i,k)=0.
    376        ENDDO
     367    DO k = 1, klev
     368      DO i = 1, klon
     369        sourceBE(i, k) = 0.
     370        Mint(i, k) = 0.
     371        zrho(i, k) = 0.
     372        zdz(i, k) = 0.
     373      ENDDO
    377374    ENDDO
    378375
    379     DO it=1, nbtr
    380        DO k=1,klev
    381           DO i=1,klon
    382              d_tr_insc(i,k,it)=0.
    383              d_tr_bcscav(i,k,it)=0.
    384              d_tr_evapls(i,k,it)=0.
    385              d_tr_ls(i,k,it)=0.
    386              d_tr_cv(i,k,it)=0.
    387              d_tr_cl(i,k,it)=0.
    388              d_tr_trsp(i,k,it)=0.
    389              d_tr_sscav(i,k,it)=0.
    390              d_tr_sat(i,k,it)=0.
    391              d_tr_uscav(i,k,it)=0.
    392              d_tr_lessi_impa(i,k,it)=0.
    393              d_tr_lessi_nucl(i,k,it)=0.
    394              qDi(i,k,it)=0.
    395              qPr(i,k,it)=0.
    396              qPa(i,k,it)=0.
    397              qMel(i,k,it)=0.
    398              qTrdi(i,k,it)=0.
    399              dtrcvMA(i,k,it)=0.
    400              zmfd1a(i,k,it)=0.
    401              zmfdam(i,k,it)=0.
    402              zmfphi2(i,k,it)=0.
    403           ENDDO
    404        ENDDO
     376    DO it = 1, nbtr
     377      DO k = 1, klev
     378        DO i = 1, klon
     379          d_tr_insc(i, k, it) = 0.
     380          d_tr_bcscav(i, k, it) = 0.
     381          d_tr_evapls(i, k, it) = 0.
     382          d_tr_ls(i, k, it) = 0.
     383          d_tr_cv(i, k, it) = 0.
     384          d_tr_cl(i, k, it) = 0.
     385          d_tr_trsp(i, k, it) = 0.
     386          d_tr_sscav(i, k, it) = 0.
     387          d_tr_sat(i, k, it) = 0.
     388          d_tr_uscav(i, k, it) = 0.
     389          d_tr_lessi_impa(i, k, it) = 0.
     390          d_tr_lessi_nucl(i, k, it) = 0.
     391          qDi(i, k, it) = 0.
     392          qPr(i, k, it) = 0.
     393          qPa(i, k, it) = 0.
     394          qMel(i, k, it) = 0.
     395          qTrdi(i, k, it) = 0.
     396          dtrcvMA(i, k, it) = 0.
     397          zmfd1a(i, k, it) = 0.
     398          zmfdam(i, k, it) = 0.
     399          zmfphi2(i, k, it) = 0.
     400        ENDDO
     401      ENDDO
    405402    ENDDO
    406403
    407     DO it=1, nbtr
    408        DO i=1,klon
    409           d_tr_dry(i,it)=0.
    410           flux_tr_dry(i,it)=0.
    411        ENDDO
     404    DO it = 1, nbtr
     405      DO i = 1, klon
     406        d_tr_dry(i, it) = 0.
     407        flux_tr_dry(i, it) = 0.
     408      ENDDO
    412409    ENDDO
    413410
    414411    DO k = 1, klev
    415        DO i = 1, klon
    416           delp(i,k) = paprs(i,k)-paprs(i,k+1)
    417        ENDDO
     412      DO i = 1, klon
     413        delp(i, k) = paprs(i, k) - paprs(i, k + 1)
     414      ENDDO
    418415    ENDDO
    419416
    420417    IF (debutphy) THEN
    421        !!jyg
    422 !$OMP BARRIER
    423        ecrit_tra=86400. ! frequence de stokage en dur
    424        ! obsolete car remplace par des ecritures dans phys_output_write
    425        !RomP >>>
    426        !
    427        !Config Key  = convscav
    428        !Config Desc = Convective scavenging switch: 0=off, 1=on.
    429        !Config Def  = .FALSE.
    430        !Config Help =
    431        !
    432 !$OMP MASTER
    433        convscav_omp=.FALSE.
    434        call getin('convscav', convscav_omp)
    435        iflag_vdf_trac_omp=1
    436        call getin('iflag_vdf_trac', iflag_vdf_trac_omp)
    437        iflag_con_trac_omp=1
    438        call getin('iflag_con_trac', iflag_con_trac_omp)
    439        iflag_the_trac_omp=1
    440        call getin('iflag_the_trac', iflag_the_trac_omp)
    441 !$OMP END MASTER
    442 !$OMP BARRIER
    443        convscav=convscav_omp
    444        iflag_vdf_trac=iflag_vdf_trac_omp
    445        iflag_con_trac=iflag_con_trac_omp
    446        iflag_the_trac=iflag_the_trac_omp
    447        write(lunout,*) 'phytrac passage dans routine conv avec lessivage', convscav
    448        !
    449        !Config Key  = iflag_lscav
    450        !Config Desc = Large scale scavenging parametrization: 0=none, 1=old(Genthon92),
    451        !              2=1+PHeinrich, 3=Reddy_Boucher2004, 4=3+RPilon.
    452        !Config Def  = 1
    453        !Config Help =
    454        !
    455 !$OMP MASTER
    456        iflag_lscav_omp=1
    457        call getin('iflag_lscav', iflag_lscav_omp)
    458        ccntrAA_omp=1
    459        ccntrENV_omp=1.
    460        coefcoli_omp=0.001
    461        call getin('ccntrAA', ccntrAA_omp)
    462        call getin('ccntrENV', ccntrENV_omp)
    463        call getin('coefcoli', coefcoli_omp)
    464 !$OMP END MASTER
    465 !$OMP BARRIER
    466        iflag_lscav=iflag_lscav_omp
    467        ccntrAA_in=ccntrAA_omp
    468        ccntrENV_in=ccntrENV_omp
    469        coefcoli_in=coefcoli_omp
    470        !
    471        SELECT CASE(iflag_lscav)
    472        CASE(0)
    473           WRITE(lunout,*)  'Large scale scavenging: none'
    474        CASE(1)
    475           WRITE(lunout,*)  'Large scale scavenging: C. Genthon, Tellus(1992), 44B, 371-389'
    476        CASE(2)
    477           WRITE(lunout,*)  'Large scale scavenging: C. Genthon, modified P. Heinrich'
    478        CASE(3)
    479           WRITE(lunout,*)  'Large scale scavenging: M. Shekkar Reddy and O. Boucher, JGR(2004), 109, D14202'
    480        CASE(4)
    481           WRITE(lunout,*)  'Large scale scavenging: Reddy and Boucher, modified R. Pilon'
    482        END SELECT
    483        !RomP <<<
    484        WRITE(*,*) 'FIRST TIME IN PHYTRAC : pdtphys(sec) = ',pdtphys,'ecrit_tra (sec) = ',ecrit_tra
    485        ALLOCATE( source(klon,nbtr), stat=ierr)
    486        IF (ierr /= 0) CALL abort_physic('phytrac', 'pb in allocation 1',1)
    487 
    488        ALLOCATE( aerosol(nbtr), stat=ierr)
    489        IF (ierr /= 0) CALL abort_physic('phytrac', 'pb in allocation 2',1)
    490 
    491 
    492        ! Initialize module for specific tracers
    493        IF (type_trac == 'inca') THEN
    494           source(:,:)=init_source(:,:)
    495           CALL tracinca_init(aerosol,lessivage)
    496        ELSE IF (type_trac == 'repr') THEN
    497           source(:,:)=0.
    498        ELSE IF (type_trac == 'co2i') THEN
    499           source(:,:)=0.
    500           lessivage  = .FALSE.
    501           aerosol(:) = .FALSE.
    502           pbl_flg(:) = 1
    503           iflag_the_trac= 1
    504           iflag_vdf_trac= 1
    505           iflag_con_trac= 1
    506        ELSE IF (type_trac == 'inco') THEN
    507           source(:,1:nqCO2) = 0.                          ! from CO2i ModThL
    508           source(:,nqCO2+1:nbtr)=init_source(:,:)         ! from INCA ModThL
    509           aerosol(1:nqCO2) = .FALSE.                      ! from CO2i ModThL
    510           CALL tracinca_init(aerosol(nqCO2+1:nbtr),lessivage)     ! from INCA ModThL
    511           pbl_flg(1:nqCO2) = 1                            ! From CO2i ModThL
    512           iflag_the_trac = 1                              ! From CO2i
    513           iflag_vdf_trac = 1                              ! From CO2i
    514           iflag_con_trac = 1                              ! From CO2i
    515 #ifdef CPP_StratAer
    516        ELSE IF (type_trac == 'coag') THEN
    517           source(:,:)=0.
    518           CALL tracstrataer_init(aerosol,lessivage)       ! init aerosols and lessivage param
    519 #endif
    520        ELSE IF (type_trac == 'lmdz') THEN
    521           CALL traclmdz_init(pctsrf,xlat,xlon,ftsol,tr_seri,t_seri,pplay,sh,pdtphys,aerosol,lessivage)
    522        ENDIF
    523 
    524        !
    525        !--initialising coefficients for scavenging in the case of NP
    526        !
    527        ALLOCATE(flag_cvltr(nbtr))
    528        IF (iflag_con==3) THEN
    529           !
    530           ALLOCATE(ccntrAA(nbtr))
    531           ALLOCATE(ccntrENV(nbtr))
    532           ALLOCATE(coefcoli(nbtr))
    533           !
    534           DO it=1, nbtr
    535              IF (type_trac == 'repr') THEN
    536                  flag_cvltr(it)=.FALSE.
    537              ELSE IF (type_trac == 'inca') THEN
    538 !                IF ((it.EQ.id_Rn222) .OR. ((it.GE.id_SO2) .AND. (it.LE.id_NH3)) ) THEN
    539 !                   !--gas-phase species
    540 !                   flag_cvltr(it)=.FALSE.
    541 !
    542 !                ELSEIF ( (it.GE.id_CIDUSTM) .AND. (it.LE.id_AIN) ) THEN
    543 !                   !--insoluble aerosol species
    544 !                   flag_cvltr(it)=.TRUE.
    545 !                   ccntrAA(it)=0.7
    546 !                   ccntrENV(it)=0.7
    547 !                   coefcoli(it)=0.001
    548 !                ELSEIF ( (it.EQ.id_Pb210) .OR. ((it.GE.id_CSSSM) .AND. (it.LE.id_SSN))) THEN
    549 !                   !--soluble aerosol species
    550 !                   flag_cvltr(it)=.TRUE.
    551 !                   ccntrAA(it)=0.9
    552 !                   ccntrENV(it)=0.9
    553 !                   coefcoli(it)=0.001
    554 !                ELSE
    555 !                   WRITE(lunout,*) 'pb it=', it
    556 !                   CALL abort_physic('phytrac','pb it scavenging',1)
    557 !                ENDIF
    558                 !--test OB
    559                 !--for now we do not scavenge in cvltr
    560                 flag_cvltr(it)=.FALSE.
    561              ELSE IF (type_trac == 'co2i') THEN
    562                 !--co2 tracers are not scavenged
    563                 flag_cvltr(it)=.FALSE.
    564              ELSE IF (type_trac == 'inco') THEN     ! Add ThL
    565                 flag_cvltr(it)=.FALSE.
    566 #ifdef CPP_StratAer
    567              ELSE IF (type_trac == 'coag') THEN
    568                 IF (convscav.and.aerosol(it)) THEN
    569                    flag_cvltr(it)=.TRUE.
    570                    ccntrAA(it) =ccntrAA_in   
    571                    ccntrENV(it)=ccntrENV_in
    572                    coefcoli(it)=coefcoli_in
    573                 ELSE
    574                    flag_cvltr(it)=.FALSE.
    575                 ENDIF
    576 #endif
    577              ELSE IF (type_trac == 'lmdz') THEN
    578                 IF (convscav.and.aerosol(it)) THEN
    579                    flag_cvltr(it)=.TRUE.
    580                    ccntrAA(it) =ccntrAA_in    !--a modifier par JYG a lire depuis fichier
    581                    ccntrENV(it)=ccntrENV_in
    582                    coefcoli(it)=coefcoli_in
    583                 ELSE
    584                    flag_cvltr(it)=.FALSE.
    585                 ENDIF
    586              ENDIF
    587           ENDDO
    588           !
    589        ELSE ! iflag_con .ne. 3
    590           flag_cvltr(:) = .FALSE.
    591        ENDIF
    592        !
    593        ! print out all tracer flags
    594        !
    595        WRITE(lunout,*) 'print out all tracer flags'
    596        WRITE(lunout,*) 'type_trac      =', type_trac
    597        WRITE(lunout,*) 'config_inca    =', config_inca
    598        WRITE(lunout,*) 'iflag_con_trac =', iflag_con_trac
    599        WRITE(lunout,*) 'iflag_con      =', iflag_con
    600        WRITE(lunout,*) 'convscav       =', convscav
    601        WRITE(lunout,*) 'iflag_lscav    =', iflag_lscav
    602        WRITE(lunout,*) 'aerosol        =', aerosol
    603        WRITE(lunout,*) 'iflag_the_trac =', iflag_the_trac
    604        WRITE(lunout,*) 'iflag_thermals =', iflag_thermals
    605        WRITE(lunout,*) 'iflag_vdf_trac =', iflag_vdf_trac
    606        WRITE(lunout,*) 'pbl_flg        =', pbl_flg
    607        WRITE(lunout,*) 'lessivage      =', lessivage
    608        write(lunout,*)  'flag_cvltr    = ', flag_cvltr
    609 
    610        IF (lessivage .AND. ANY(type_trac == ['inca','inco'])) &
    611           CALL abort_physic('phytrac', 'lessivage=T config_inca=inca impossible',1)
    612        !
     418      !!jyg
     419      !$OMP BARRIER
     420      ecrit_tra = 86400. ! frequence de stokage en dur
     421      ! obsolete car remplace par des ecritures dans phys_output_write
     422      !RomP >>>
     423      !
     424      !Config Key  = convscav
     425      !Config Desc = Convective scavenging switch: 0=off, 1=on.
     426      !Config Def  = .FALSE.
     427      !Config Help =
     428      !
     429      !$OMP MASTER
     430      convscav_omp = .FALSE.
     431      call getin('convscav', convscav_omp)
     432      iflag_vdf_trac_omp = 1
     433      call getin('iflag_vdf_trac', iflag_vdf_trac_omp)
     434      iflag_con_trac_omp = 1
     435      call getin('iflag_con_trac', iflag_con_trac_omp)
     436      iflag_the_trac_omp = 1
     437      call getin('iflag_the_trac', iflag_the_trac_omp)
     438      !$OMP END MASTER
     439      !$OMP BARRIER
     440      convscav = convscav_omp
     441      iflag_vdf_trac = iflag_vdf_trac_omp
     442      iflag_con_trac = iflag_con_trac_omp
     443      iflag_the_trac = iflag_the_trac_omp
     444      write(lunout, *) 'phytrac passage dans routine conv avec lessivage', convscav
     445      !
     446      !Config Key  = iflag_lscav
     447      !Config Desc = Large scale scavenging parametrization: 0=none, 1=old(Genthon92),
     448      !              2=1+PHeinrich, 3=Reddy_Boucher2004, 4=3+RPilon.
     449      !Config Def  = 1
     450      !Config Help =
     451      !
     452      !$OMP MASTER
     453      iflag_lscav_omp = 1
     454      call getin('iflag_lscav', iflag_lscav_omp)
     455      ccntrAA_omp = 1
     456      ccntrENV_omp = 1.
     457      coefcoli_omp = 0.001
     458      call getin('ccntrAA', ccntrAA_omp)
     459      call getin('ccntrENV', ccntrENV_omp)
     460      call getin('coefcoli', coefcoli_omp)
     461      !$OMP END MASTER
     462      !$OMP BARRIER
     463      iflag_lscav = iflag_lscav_omp
     464      ccntrAA_in = ccntrAA_omp
     465      ccntrENV_in = ccntrENV_omp
     466      coefcoli_in = coefcoli_omp
     467      !
     468      SELECT CASE(iflag_lscav)
     469      CASE(0)
     470        WRITE(lunout, *)  'Large scale scavenging: none'
     471      CASE(1)
     472        WRITE(lunout, *)  'Large scale scavenging: C. Genthon, Tellus(1992), 44B, 371-389'
     473      CASE(2)
     474        WRITE(lunout, *)  'Large scale scavenging: C. Genthon, modified P. Heinrich'
     475      CASE(3)
     476        WRITE(lunout, *)  'Large scale scavenging: M. Shekkar Reddy and O. Boucher, JGR(2004), 109, D14202'
     477      CASE(4)
     478        WRITE(lunout, *)  'Large scale scavenging: Reddy and Boucher, modified R. Pilon'
     479      END SELECT
     480      !RomP <<<
     481      WRITE(*, *) 'FIRST TIME IN PHYTRAC : pdtphys(sec) = ', pdtphys, 'ecrit_tra (sec) = ', ecrit_tra
     482      ALLOCATE(source(klon, nbtr), stat = ierr)
     483      IF (ierr /= 0) CALL abort_physic('phytrac', 'pb in allocation 1', 1)
     484
     485      ALLOCATE(aerosol(nbtr), stat = ierr)
     486      IF (ierr /= 0) CALL abort_physic('phytrac', 'pb in allocation 2', 1)
     487
     488
     489      ! Initialize module for specific tracers
     490      IF (type_trac == 'inca') THEN
     491        source(:, :) = init_source(:, :)
     492        CALL tracinca_init(aerosol, lessivage)
     493      ELSE IF (type_trac == 'repr') THEN
     494        source(:, :) = 0.
     495      ELSE IF (type_trac == 'co2i') THEN
     496        source(:, :) = 0.
     497        lessivage = .FALSE.
     498        aerosol(:) = .FALSE.
     499        pbl_flg(:) = 1
     500        iflag_the_trac = 1
     501        iflag_vdf_trac = 1
     502        iflag_con_trac = 1
     503      ELSE IF (type_trac == 'inco') THEN
     504        source(:, 1:nqCO2) = 0.                          ! from CO2i ModThL
     505        source(:, nqCO2 + 1:nbtr) = init_source(:, :)         ! from INCA ModThL
     506        aerosol(1:nqCO2) = .FALSE.                      ! from CO2i ModThL
     507        CALL tracinca_init(aerosol(nqCO2 + 1:nbtr), lessivage)     ! from INCA ModThL
     508        pbl_flg(1:nqCO2) = 1                            ! From CO2i ModThL
     509        iflag_the_trac = 1                              ! From CO2i
     510        iflag_vdf_trac = 1                              ! From CO2i
     511        iflag_con_trac = 1                              ! From CO2i
     512      ELSE IF (type_trac == 'coag' .AND. CPPKEY_STRATAER) THEN
     513        source(:, :) = 0.
     514        CALL tracstrataer_init(aerosol, lessivage)       ! init aerosols and lessivage param
     515      ELSE IF (type_trac == 'lmdz') THEN
     516        CALL traclmdz_init(pctsrf, xlat, xlon, ftsol, tr_seri, t_seri, pplay, sh, pdtphys, aerosol, lessivage)
     517      ENDIF
     518
     519      !
     520      !--initialising coefficients for scavenging in the case of NP
     521      !
     522      ALLOCATE(flag_cvltr(nbtr))
     523      IF (iflag_con==3) THEN
     524        !
     525        ALLOCATE(ccntrAA(nbtr))
     526        ALLOCATE(ccntrENV(nbtr))
     527        ALLOCATE(coefcoli(nbtr))
     528        !
     529        DO it = 1, nbtr
     530          IF (type_trac == 'repr') THEN
     531            flag_cvltr(it) = .FALSE.
     532          ELSE IF (type_trac == 'inca') THEN
     533            !                IF ((it.EQ.id_Rn222) .OR. ((it.GE.id_SO2) .AND. (it.LE.id_NH3)) ) THEN
     534            !                   !--gas-phase species
     535            !                   flag_cvltr(it)=.FALSE.
     536            !
     537            !                ELSEIF ( (it.GE.id_CIDUSTM) .AND. (it.LE.id_AIN) ) THEN
     538            !                   !--insoluble aerosol species
     539            !                   flag_cvltr(it)=.TRUE.
     540            !                   ccntrAA(it)=0.7
     541            !                   ccntrENV(it)=0.7
     542            !                   coefcoli(it)=0.001
     543            !                ELSEIF ( (it.EQ.id_Pb210) .OR. ((it.GE.id_CSSSM) .AND. (it.LE.id_SSN))) THEN
     544            !                   !--soluble aerosol species
     545            !                   flag_cvltr(it)=.TRUE.
     546            !                   ccntrAA(it)=0.9
     547            !                   ccntrENV(it)=0.9
     548            !                   coefcoli(it)=0.001
     549            !                ELSE
     550            !                   WRITE(lunout,*) 'pb it=', it
     551            !                   CALL abort_physic('phytrac','pb it scavenging',1)
     552            !                ENDIF
     553            !--test OB
     554            !--for now we do not scavenge in cvltr
     555            flag_cvltr(it) = .FALSE.
     556          ELSE IF (type_trac == 'co2i') THEN
     557            !--co2 tracers are not scavenged
     558            flag_cvltr(it) = .FALSE.
     559          ELSE IF (type_trac == 'inco') THEN     ! Add ThL
     560            flag_cvltr(it) = .FALSE.
     561          ELSE IF (type_trac == 'coag' .AND. CPPKEY_STRATAER) THEN
     562            IF (convscav.and.aerosol(it)) THEN
     563              flag_cvltr(it) = .TRUE.
     564              ccntrAA(it) = ccntrAA_in
     565              ccntrENV(it) = ccntrENV_in
     566              coefcoli(it) = coefcoli_in
     567            ELSE
     568              flag_cvltr(it) = .FALSE.
     569            ENDIF
     570          ELSE IF (type_trac == 'lmdz') THEN
     571            IF (convscav.and.aerosol(it)) THEN
     572              flag_cvltr(it) = .TRUE.
     573              ccntrAA(it) = ccntrAA_in    !--a modifier par JYG a lire depuis fichier
     574              ccntrENV(it) = ccntrENV_in
     575              coefcoli(it) = coefcoli_in
     576            ELSE
     577              flag_cvltr(it) = .FALSE.
     578            ENDIF
     579          ENDIF
     580        ENDDO
     581        !
     582      ELSE ! iflag_con .ne. 3
     583        flag_cvltr(:) = .FALSE.
     584      ENDIF
     585      !
     586      ! print out all tracer flags
     587      !
     588      WRITE(lunout, *) 'print out all tracer flags'
     589      WRITE(lunout, *) 'type_trac      =', type_trac
     590      WRITE(lunout, *) 'config_inca    =', config_inca
     591      WRITE(lunout, *) 'iflag_con_trac =', iflag_con_trac
     592      WRITE(lunout, *) 'iflag_con      =', iflag_con
     593      WRITE(lunout, *) 'convscav       =', convscav
     594      WRITE(lunout, *) 'iflag_lscav    =', iflag_lscav
     595      WRITE(lunout, *) 'aerosol        =', aerosol
     596      WRITE(lunout, *) 'iflag_the_trac =', iflag_the_trac
     597      WRITE(lunout, *) 'iflag_thermals =', iflag_thermals
     598      WRITE(lunout, *) 'iflag_vdf_trac =', iflag_vdf_trac
     599      WRITE(lunout, *) 'pbl_flg        =', pbl_flg
     600      WRITE(lunout, *) 'lessivage      =', lessivage
     601      write(lunout, *)  'flag_cvltr    = ', flag_cvltr
     602
     603      IF (lessivage .AND. ANY(type_trac == ['inca', 'inco'])) &
     604              CALL abort_physic('phytrac', 'lessivage=T config_inca=inca impossible', 1)
     605      !
    613606    ENDIF ! of IF (debutphy)
    614607    !############################################ END INITIALIZATION #######
    615608
    616     DO k=1,klev
    617        DO i=1,klon
    618           zmasse(i,k)=(paprs(i,k)-paprs(i,k+1))/rg
    619        ENDDO
     609    DO k = 1, klev
     610      DO i = 1, klon
     611        zmasse(i, k) = (paprs(i, k) - paprs(i, k + 1)) / rg
     612      ENDDO
    620613    ENDDO
    621614    !
    622615    IF (id_be > 0) THEN
    623        DO k=1,klev
    624           DO i=1,klon
    625              sourceBE(i,k)=srcbe(i,k)       !RomP  -> pour sortie histrac
    626           ENDDO
    627        ENDDO
     616      DO k = 1, klev
     617        DO i = 1, klon
     618          sourceBE(i, k) = srcbe(i, k)       !RomP  -> pour sortie histrac
     619        ENDDO
     620      ENDDO
    628621    ENDIF
    629622
    630623    !===============================================================================
    631624    !    -- Do specific treatment according to chemestry model or local LMDZ tracers
    632     !     
     625    !
    633626    !===============================================================================
    634627    IF (type_trac == 'inca') THEN
    635        !    -- CHIMIE INCA  config_inca = aero or chem --
    636        ! Appel fait en fin de phytrac pour avoir les emissions modifiees par
    637        ! la couche limite et la convection avant le calcul de la chimie
     628      !    -- CHIMIE INCA  config_inca = aero or chem --
     629      ! Appel fait en fin de phytrac pour avoir les emissions modifiees par
     630      ! la couche limite et la convection avant le calcul de la chimie
    638631
    639632    ELSE IF (type_trac == 'repr') THEN
    640        !   -- CHIMIE REPROBUS --
    641        CALL tracreprobus(pdtphys, gmtime, debutphy, julien, &
    642             presnivs, xlat, xlon, pphis, pphi, &
    643             t_seri, pplay, paprs, sh , &
    644             tr_seri)
     633      !   -- CHIMIE REPROBUS --
     634      CALL tracreprobus(pdtphys, gmtime, debutphy, julien, &
     635              presnivs, xlat, xlon, pphis, pphi, &
     636              t_seri, pplay, paprs, sh, &
     637              tr_seri)
    645638
    646639    ELSE IF (type_trac == 'co2i') THEN
    647        !   -- CO2 interactif --
    648        !   -- source is updated with FF and BB emissions
    649        !   -- and net fluxes from ocean and orchidee
    650        !   -- sign convention : positive into the atmosphere
    651 
    652        CALL tracco2i(pdtphys, debutphy, &
    653             xlat, xlon, pphis, pphi, &
    654             t_seri, pplay, paprs, tr_seri, source)
     640      !   -- CO2 interactif --
     641      !   -- source is updated with FF and BB emissions
     642      !   -- and net fluxes from ocean and orchidee
     643      !   -- sign convention : positive into the atmosphere
     644
     645      CALL tracco2i(pdtphys, debutphy, &
     646              xlat, xlon, pphis, pphi, &
     647              t_seri, pplay, paprs, tr_seri, source)
    655648    ELSE IF (type_trac == 'inco') THEN      ! Add ThL
    656        CALL tracco2i(pdtphys, debutphy, &
    657             xlat, xlon, pphis, pphi, &
    658             t_seri, pplay, paprs, tr_seri, source)
    659 
    660 #ifdef CPP_StratAer
    661     ELSE IF (type_trac == 'coag') THEN
    662        !   --STRATOSPHERIC AER IN THE STRAT --
    663        CALL traccoag(pdtphys, gmtime, debutphy, julien, &
    664             presnivs, xlat, xlon, pphis, pphi, &
    665             t_seri, pplay, paprs, sh, rh , &
    666             tr_seri)
    667 #endif
     649      CALL tracco2i(pdtphys, debutphy, &
     650              xlat, xlon, pphis, pphi, &
     651              t_seri, pplay, paprs, tr_seri, source)
     652
     653    ELSE IF (type_trac == 'coag' .AND. CPPKEY_STRATAER) THEN
     654      !   --STRATOSPHERIC AER IN THE STRAT --
     655      CALL traccoag(pdtphys, gmtime, debutphy, julien, &
     656              presnivs, xlat, xlon, pphis, pphi, &
     657              t_seri, pplay, paprs, sh, rh, &
     658              tr_seri)
    668659    ELSE IF (type_trac == 'lmdz') THEN
    669        !    -- Traitement des traceurs avec traclmdz
    670        CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
    671             cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon,iflag_vdf_trac>=0,sh, &
    672             rh, pphi, ustar, wstar, ale_bl, ale_wake, u10m, v10m, &
    673             tr_seri, source, d_tr_cl,d_tr_dec, zmasse)               !RomP
     660      !    -- Traitement des traceurs avec traclmdz
     661      CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
     662              cdragh, coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon, iflag_vdf_trac>=0, sh, &
     663              rh, pphi, ustar, wstar, ale_bl, ale_wake, u10m, v10m, &
     664              tr_seri, source, d_tr_cl, d_tr_dec, zmasse)               !RomP
    674665    ENDIF
    675666    !======================================================================
     
    679670    IF (iflag_con_trac==1) THEN
    680671
    681        DO it=1, nbtr
    682           IF ( conv_flg(it) == 0 ) CYCLE
    683           IF (iflag_con<2) THEN
    684              !--pas de transport convectif
    685              d_tr_cv(:,:,it)=0.
    686 
    687           ELSE IF (iflag_con==2) THEN
    688              !--ancien transport convectif de Tiedtke
    689 
    690              CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
    691                   pplay, paprs, tr_seri(:,:,it), d_tr_cv(:,:,it))
    692           ELSE   
    693              !--nouveau transport convectif de Emanuel
    694 
    695              IF (flag_cvltr(it)) THEN
    696                 !--nouveau transport convectif de Emanuel avec lessivage convectif
    697                 !
    698                 !
    699                 ccntrAA_3d(:,:) =ccntrAA(it)
    700                 ccntrENV_3d(:,:)=ccntrENV(it)
    701                 coefcoli_3d(:,:)=coefcoli(it)
    702 
    703                 !--beware this interface is a bit weird because it is called for each tracer
    704                 !--with the full array tr_seri even if only item it is processed
    705 
    706                 CALL cvltr_scav(pdtphys, da, phi,phi2,d1a,dam, mp,ep,         &
    707                      sigd,sij,wght_cvfd,clw,elij,epmlmMm,eplaMm,              &     
    708                      pmflxr,pmflxs,evap,t_seri,wdtrainA,wdtrainM,             &   
    709                      paprs,it,tr_seri,upwd,dnwd,itop_con,ibas_con,            &
    710                      ccntrAA_3d,ccntrENV_3d,coefcoli_3d,                      &
    711                      d_tr_cv,d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qDi,qPr,&
    712                      qPa,qMel,qTrdi,dtrcvMA,Mint,                             &
    713                      zmfd1a,zmfphi2,zmfdam)
    714 
    715 
    716              ELSE  !---flag_cvltr(it).EQ.FALSE
    717                 !--nouveau transport convectif de Emanuel mais pas de lessivage convectif
    718 
    719                 !--beware this interface is a bit weird because it is called for each tracer
    720                 !--with the full array tr_seri even if only item it is processed
    721                 !
    722                 CALL cvltr_noscav(it,pdtphys, da, phi,mp,wght_cvfd,paprs,pplay, &  !jyg
    723                      tr_seri,upwd,dnwd,d_tr_cv)                                !jyg
    724 
    725              ENDIF
    726 
    727           ENDIF !--iflag
    728 
    729           !--on ajoute les tendances
    730 
    731           DO k = 1, klev
    732              DO i = 1, klon       
    733                 tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cv(i,k,it)
    734              ENDDO
     672      DO it = 1, nbtr
     673        IF (conv_flg(it) == 0) CYCLE
     674        IF (iflag_con<2) THEN
     675          !--pas de transport convectif
     676          d_tr_cv(:, :, it) = 0.
     677
     678        ELSE IF (iflag_con==2) THEN
     679          !--ancien transport convectif de Tiedtke
     680
     681          CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
     682                  pplay, paprs, tr_seri(:, :, it), d_tr_cv(:, :, it))
     683        ELSE
     684          !--nouveau transport convectif de Emanuel
     685
     686          IF (flag_cvltr(it)) THEN
     687            !--nouveau transport convectif de Emanuel avec lessivage convectif
     688            !
     689            !
     690            ccntrAA_3d(:, :) = ccntrAA(it)
     691            ccntrENV_3d(:, :) = ccntrENV(it)
     692            coefcoli_3d(:, :) = coefcoli(it)
     693
     694            !--beware this interface is a bit weird because it is called for each tracer
     695            !--with the full array tr_seri even if only item it is processed
     696
     697            CALL cvltr_scav(pdtphys, da, phi, phi2, d1a, dam, mp, ep, &
     698                    sigd, sij, wght_cvfd, clw, elij, epmlmMm, eplaMm, &
     699                    pmflxr, pmflxs, evap, t_seri, wdtrainA, wdtrainM, &
     700                    paprs, it, tr_seri, upwd, dnwd, itop_con, ibas_con, &
     701                    ccntrAA_3d, ccntrENV_3d, coefcoli_3d, &
     702                    d_tr_cv, d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav, qDi, qPr, &
     703                    qPa, qMel, qTrdi, dtrcvMA, Mint, &
     704                    zmfd1a, zmfphi2, zmfdam)
     705
     706          ELSE  !---flag_cvltr(it).EQ.FALSE
     707            !--nouveau transport convectif de Emanuel mais pas de lessivage convectif
     708
     709            !--beware this interface is a bit weird because it is called for each tracer
     710            !--with the full array tr_seri even if only item it is processed
     711            !
     712            CALL cvltr_noscav(it, pdtphys, da, phi, mp, wght_cvfd, paprs, pplay, &  !jyg
     713                    tr_seri, upwd, dnwd, d_tr_cv)                                !jyg
     714
     715          ENDIF
     716
     717        ENDIF !--iflag
     718
     719        !--on ajoute les tendances
     720
     721        DO k = 1, klev
     722          DO i = 1, klon
     723            tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cv(i, k, it)
    735724          ENDDO
    736 
    737           CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'convection it = '//TRIM(int2str(it)))
    738 
    739        ENDDO ! nbtr
    740 
    741 #ifdef CPP_StratAer
    742        IF (type_trac=='coag') THEN
    743          ! initialize wet deposition flux of sulfur
    744          budg_dep_wet_ocs(:)=0.0
    745          budg_dep_wet_so2(:)=0.0
    746          budg_dep_wet_h2so4(:)=0.0
    747          budg_dep_wet_part(:)=0.0
    748          ! compute wet deposition flux of sulfur (sum over gases and particles)
    749          ! and convert to kg(S)/m2/s
    750          DO i = 1, klon
    751          DO k = 1, klev
    752          DO it = 1, nbtr
    753          !do not include SO2 because most of it comes trom the troposphere
    754            IF (it==id_OCS_strat) THEN
    755              budg_dep_wet_ocs(i)=budg_dep_wet_ocs(i)+d_tr_cv(i,k,it)*(mSatom/mOCSmol) &
    756    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    757            ELSEIF (it==id_SO2_strat) THEN
    758              budg_dep_wet_so2(i)=budg_dep_wet_so2(i)+d_tr_cv(i,k,it)*(mSatom/mSO2mol) &
    759    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    760            ELSEIF (it==id_H2SO4_strat) THEN
    761              budg_dep_wet_h2so4(i)=budg_dep_wet_h2so4(i)+d_tr_cv(i,k,it)*(mSatom/mH2SO4mol) &
    762    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    763            ELSEIF (it.GT.nbtr_sulgas) THEN
    764              budg_dep_wet_part(i)=budg_dep_wet_part(i)+d_tr_cv(i,k,it)*(mSatom/mH2SO4mol)  &
    765    *dens_aer_dry*4./3.*RPI*(mdw(it-nbtr_sulgas)/2.)**3 &
    766    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    767            ENDIF
    768          ENDDO
    769          ENDDO
    770          ENDDO
    771        ENDIF
    772 #endif
     725        ENDDO
     726
     727        CALL minmaxqfi(tr_seri(:, :, it), 0., 1.e33, 'convection it = ' // TRIM(int2str(it)))
     728
     729      ENDDO ! nbtr
     730
     731      IF (CPPKEY_STRATAER) THEN
     732        IF (type_trac=='coag') THEN
     733          ! initialize wet deposition flux of sulfur
     734          budg_dep_wet_ocs(:) = 0.0
     735          budg_dep_wet_so2(:) = 0.0
     736          budg_dep_wet_h2so4(:) = 0.0
     737          budg_dep_wet_part(:) = 0.0
     738          ! compute wet deposition flux of sulfur (sum over gases and particles)
     739          ! and convert to kg(S)/m2/s
     740          DO i = 1, klon
     741            DO k = 1, klev
     742              DO it = 1, nbtr
     743                !do not include SO2 because most of it comes trom the troposphere
     744                IF (it==id_OCS_strat) THEN
     745                  budg_dep_wet_ocs(i) = budg_dep_wet_ocs(i) + d_tr_cv(i, k, it) * (mSatom / mOCSmol) &
     746                          * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     747                ELSEIF (it==id_SO2_strat) THEN
     748                  budg_dep_wet_so2(i) = budg_dep_wet_so2(i) + d_tr_cv(i, k, it) * (mSatom / mSO2mol) &
     749                          * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     750                ELSEIF (it==id_H2SO4_strat) THEN
     751                  budg_dep_wet_h2so4(i) = budg_dep_wet_h2so4(i) + d_tr_cv(i, k, it) * (mSatom / mH2SO4mol) &
     752                          * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     753                ELSEIF (it>nbtr_sulgas) THEN
     754                  budg_dep_wet_part(i) = budg_dep_wet_part(i) + d_tr_cv(i, k, it) * (mSatom / mH2SO4mol)  &
     755                          * dens_aer_dry * 4. / 3. * RPI * (mdw(it - nbtr_sulgas) / 2.)**3 &
     756                          * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     757                ENDIF
     758              ENDDO
     759            ENDDO
     760          ENDDO
     761        ENDIF
     762      END IF
    773763
    774764    ENDIF ! convection
     
    778768    !======================================================================
    779769
    780     DO it=1,nbtr
    781        DO k=1,klev
    782           DO i=1,klon
    783              d_tr_th(i,k,it)=0.
    784              tr_seri(i,k,it)=MAX(tr_seri(i,k,it),0.)
    785 ! the next safeguard causes some problem for stratospheric aerosol tracers (particle number)
    786 ! and there is little justification for it so it is commented out (4 December 2017) by OB
    787 ! if reinstated please keep the ifndef CPP_StratAer
    788 !#ifndef CPP_StratAer
    789 !             tr_seri(i,k,it)=MIN(tr_seri(i,k,it),1.e10)
    790 !#endif
     770    DO it = 1, nbtr
     771      DO k = 1, klev
     772        DO i = 1, klon
     773          d_tr_th(i, k, it) = 0.
     774          tr_seri(i, k, it) = MAX(tr_seri(i, k, it), 0.)
     775          ! the next safeguard causes some problem for stratospheric aerosol tracers (particle number)
     776          ! and there is little justification for it so it is commented out (4 December 2017) by OB
     777          ! if reinstated please keep the ifndef CPP_StratAer
     778          !#ifndef CPP_StratAer
     779          !             tr_seri(i,k,it)=MIN(tr_seri(i,k,it),1.e10)
     780          !#endif
     781        ENDDO
     782      ENDDO
     783    ENDDO
     784
     785    IF (iflag_thermals>0.AND.iflag_the_trac>0) THEN
     786
     787      DO it = 1, nbtr
     788
     789        CALL thermcell_dq(klon, klev, 1, pdtphys, fm_therm, entr_therm, &
     790                zmasse, tr_seri(1:klon, 1:klev, it), &
     791                d_tr_th(1:klon, 1:klev, it), ztra_th, 0)
     792
     793        DO k = 1, klev
     794          DO i = 1, klon
     795            d_tr_th(i, k, it) = pdtphys * d_tr_th(i, k, it)
     796            tr_seri(i, k, it) = MAX(tr_seri(i, k, it) + d_tr_th(i, k, it), 0.)
    791797          ENDDO
    792        ENDDO
    793     ENDDO
    794 
    795     IF (iflag_thermals>0.AND.iflag_the_trac>0) THEN
    796 
    797        DO it=1, nbtr
    798 
    799           CALL thermcell_dq(klon,klev,1,pdtphys,fm_therm,entr_therm, &
    800                zmasse,tr_seri(1:klon,1:klev,it),        &
    801                d_tr_th(1:klon,1:klev,it),ztra_th,0 )
    802 
    803           DO k=1,klev
    804              DO i=1,klon
    805                 d_tr_th(i,k,it)=pdtphys*d_tr_th(i,k,it)
    806                 tr_seri(i,k,it)=MAX(tr_seri(i,k,it)+d_tr_th(i,k,it),0.)
    807              ENDDO
    808           ENDDO
    809 
    810        ENDDO ! it
     798        ENDDO
     799
     800      ENDDO ! it
    811801
    812802    ENDIF ! Thermiques
     
    818808    IF (iflag_vdf_trac==1) THEN
    819809
    820        !  Injection during BL mixing
    821        !
    822 #ifdef CPP_StratAer
    823        IF (type_trac=='coag') THEN
    824 
    825          ! initialize dry deposition flux of sulfur
    826          budg_dep_dry_ocs(:)=0.0
    827          budg_dep_dry_so2(:)=0.0
    828          budg_dep_dry_h2so4(:)=0.0
    829          budg_dep_dry_part(:)=0.0
    830 
    831          ! compute dry deposition velocity as function of surface type (numbers
    832          ! from IPSL note 23, 2002)
    833          v_dep_dry(:) =  pctsrf(:,is_ter) * 2.5e-3 &
    834    + pctsrf(:,is_oce) * 0.5e-3 &
    835    + pctsrf(:,is_lic) * 2.5e-3 &
    836    + pctsrf(:,is_sic) * 2.5e-3
    837 
    838          ! compute surface dry deposition flux
    839          zrho(:,1)=pplay(:,1)/t_seri(:,1)/RD
    840 
    841          DO it=1, nbtr
    842           source(:,it) = - v_dep_dry(:) * tr_seri(:,1,it) * zrho(:,1)
    843          ENDDO
    844 
    845        ENDIF
    846 #endif
    847 
    848        DO it=1, nbtr
     810      !  Injection during BL mixing
     811      !
     812      IF (CPPKEY_STRATAER) THEN
     813        IF (type_trac=='coag') THEN
     814
     815          ! initialize dry deposition flux of sulfur
     816          budg_dep_dry_ocs(:) = 0.0
     817          budg_dep_dry_so2(:) = 0.0
     818          budg_dep_dry_h2so4(:) = 0.0
     819          budg_dep_dry_part(:) = 0.0
     820
     821          ! compute dry deposition velocity as function of surface type (numbers
     822          ! from IPSL note 23, 2002)
     823          v_dep_dry(:) = pctsrf(:, is_ter) * 2.5e-3 &
     824                  + pctsrf(:, is_oce) * 0.5e-3 &
     825                  + pctsrf(:, is_lic) * 2.5e-3 &
     826                  + pctsrf(:, is_sic) * 2.5e-3
     827
     828          ! compute surface dry deposition flux
     829          zrho(:, 1) = pplay(:, 1) / t_seri(:, 1) / RD
     830
     831          DO it = 1, nbtr
     832            source(:, it) = - v_dep_dry(:) * tr_seri(:, 1, it) * zrho(:, 1)
     833          ENDDO
     834
     835        ENDIF
     836      END IF
     837
     838      DO it = 1, nbtr
     839        !
     840        IF (pbl_flg(it) /= 0) THEN
    849841          !
    850           IF (pbl_flg(it) /= 0) THEN
    851              !
    852              CALL cltrac(pdtphys, coefh,t_seri,       &
    853                   tr_seri(:,:,it), source(:,it),      &
    854                   paprs, pplay, delp,                 &
    855                   d_tr_cl(:,:,it),d_tr_dry(:,it),flux_tr_dry(:,it))
    856              !
    857              tr_seri(:,:,it)=tr_seri(:,:,it)+d_tr_cl(:,:,it)
    858              !
    859 #ifdef CPP_StratAer
    860              IF (type_trac=='coag') THEN
    861                ! compute dry deposition flux of sulfur (sum over gases and particles)
    862                IF (it==id_OCS_strat) THEN
    863                  budg_dep_dry_ocs(:)=budg_dep_dry_ocs(:)-source(:,it)*(mSatom/mOCSmol)
    864                ELSEIF (it==id_SO2_strat) THEN
    865                  budg_dep_dry_so2(:)=budg_dep_dry_so2(:)-source(:,it)*(mSatom/mSO2mol)
    866                ELSEIF (it==id_H2SO4_strat) THEN
    867                  budg_dep_dry_h2so4(:)=budg_dep_dry_h2so4(:)-source(:,it)*(mSatom/mH2SO4mol)
    868                ELSEIF (it.GT.nbtr_sulgas) THEN
    869                  budg_dep_dry_part(:)=budg_dep_dry_part(:)-source(:,it)*(mSatom/mH2SO4mol)*dens_aer_dry &
    870    *4./3.*RPI*(mdw(it-nbtr_sulgas)/2.)**3
    871                ENDIF
    872              ENDIF
    873 #endif
    874              !
    875           ENDIF
     842          CALL cltrac(pdtphys, coefh, t_seri, &
     843                  tr_seri(:, :, it), source(:, it), &
     844                  paprs, pplay, delp, &
     845                  d_tr_cl(:, :, it), d_tr_dry(:, it), flux_tr_dry(:, it))
    876846          !
    877        ENDDO
    878        !
     847          tr_seri(:, :, it) = tr_seri(:, :, it) + d_tr_cl(:, :, it)
     848          !
     849          IF (CPPKEY_STRATAER) THEN
     850            IF (type_trac=='coag') THEN
     851              ! compute dry deposition flux of sulfur (sum over gases and particles)
     852              IF (it==id_OCS_strat) THEN
     853                budg_dep_dry_ocs(:) = budg_dep_dry_ocs(:) - source(:, it) * (mSatom / mOCSmol)
     854              ELSEIF (it==id_SO2_strat) THEN
     855                budg_dep_dry_so2(:) = budg_dep_dry_so2(:) - source(:, it) * (mSatom / mSO2mol)
     856              ELSEIF (it==id_H2SO4_strat) THEN
     857                budg_dep_dry_h2so4(:) = budg_dep_dry_h2so4(:) - source(:, it) * (mSatom / mH2SO4mol)
     858              ELSEIF (it>nbtr_sulgas) THEN
     859                budg_dep_dry_part(:) = budg_dep_dry_part(:) - source(:, it) * (mSatom / mH2SO4mol) * dens_aer_dry &
     860                        * 4. / 3. * RPI * (mdw(it - nbtr_sulgas) / 2.)**3
     861              ENDIF
     862            ENDIF
     863          END IF
     864          !
     865        ENDIF
     866        !
     867      ENDDO
     868      !
    879869    ELSE IF (iflag_vdf_trac==0) THEN
    880        !
    881        !   Injection of source in the first model layer
    882        !
    883        DO it=1,nbtr
    884           d_tr_cl(:,1,it)=source(:,it)*RG/delp(:,1)*pdtphys
    885           tr_seri(:,1,it)=tr_seri(:,1,it)+d_tr_cl(:,1,it)
    886        ENDDO
    887        d_tr_cl(:,2:klev,1:nbtr)=0.
    888        !
     870      !
     871      !   Injection of source in the first model layer
     872      !
     873      DO it = 1, nbtr
     874        d_tr_cl(:, 1, it) = source(:, it) * RG / delp(:, 1) * pdtphys
     875        tr_seri(:, 1, it) = tr_seri(:, 1, it) + d_tr_cl(:, 1, it)
     876      ENDDO
     877      d_tr_cl(:, 2:klev, 1:nbtr) = 0.
     878      !
    889879    ELSE IF (iflag_vdf_trac==-1) THEN
    890        !
    891        ! Nothing happens
    892        d_tr_cl=0.
    893        !
     880      !
     881      ! Nothing happens
     882      d_tr_cl = 0.
     883      !
    894884    ELSE
    895        !
    896        CALL abort_physic('iflag_vdf_trac', 'cas non prevu',1)
    897        !
     885      !
     886      CALL abort_physic('iflag_vdf_trac', 'cas non prevu', 1)
     887      !
    898888    ENDIF ! couche limite
    899889
     
    905895    IF (lessivage) THEN
    906896
    907        ql_incloud_ref = 10.e-4
    908        ql_incloud_ref =  5.e-4
    909 
    910 
    911        ! calcul du contenu en eau liquide au sein du nuage
    912        ql_incl = ql_incloud_ref
    913        ! choix du lessivage
    914        !
    915        IF (iflag_lscav == 3 .OR. iflag_lscav == 4) THEN
    916           ! ********  Olivier Boucher version (3) possibly with modified ql_incl (4)
    917           !
    918           DO it = 1, nbtr
    919 
    920              IF (aerosol(it)) THEN
    921              !  incloud scavenging and removal by large scale rain ! orig : ql_incl was replaced by 0.5e-3 kg/kg
    922              ! the value 0.5e-3 kg/kg is from Giorgi and Chameides (1986), JGR
    923              ! Liu (2001) proposed to use 1.5e-3 kg/kg
    924 
    925              CALL lsc_scav(pdtphys,it,iflag_lscav,aerosol,ql_incl,prfl,psfl,rneb,beta_fisrt,  &
    926                            beta_v1,pplay,paprs,t_seri,tr_seri,d_tr_insc,d_tr_bcscav,d_tr_evapls,qPrls)
    927 
    928              !large scale scavenging tendency
    929              DO k = 1, klev
    930                 DO i = 1, klon
    931                    d_tr_ls(i,k,it)=d_tr_insc(i,k,it)+d_tr_bcscav(i,k,it)+d_tr_evapls(i,k,it)
    932                    tr_seri(i,k,it)=tr_seri(i,k,it)+d_tr_ls(i,k,it)
     897      ql_incloud_ref = 10.e-4
     898      ql_incloud_ref = 5.e-4
     899
     900
     901      ! calcul du contenu en eau liquide au sein du nuage
     902      ql_incl = ql_incloud_ref
     903      ! choix du lessivage
     904      !
     905      IF (iflag_lscav == 3 .OR. iflag_lscav == 4) THEN
     906        ! ********  Olivier Boucher version (3) possibly with modified ql_incl (4)
     907        !
     908        DO it = 1, nbtr
     909
     910          IF (aerosol(it)) THEN
     911            !  incloud scavenging and removal by large scale rain ! orig : ql_incl was replaced by 0.5e-3 kg/kg
     912            ! the value 0.5e-3 kg/kg is from Giorgi and Chameides (1986), JGR
     913            ! Liu (2001) proposed to use 1.5e-3 kg/kg
     914
     915            CALL lsc_scav(pdtphys, it, iflag_lscav, aerosol, ql_incl, prfl, psfl, rneb, beta_fisrt, &
     916                    beta_v1, pplay, paprs, t_seri, tr_seri, d_tr_insc, d_tr_bcscav, d_tr_evapls, qPrls)
     917
     918            !large scale scavenging tendency
     919            DO k = 1, klev
     920              DO i = 1, klon
     921                d_tr_ls(i, k, it) = d_tr_insc(i, k, it) + d_tr_bcscav(i, k, it) + d_tr_evapls(i, k, it)
     922                tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_ls(i, k, it)
     923              ENDDO
     924            ENDDO
     925            CALL minmaxqfi(tr_seri(:, :, it), 0., 1.e33, 'lsc scav it = ' // TRIM(int2str(it)))
     926          ENDIF
     927
     928        ENDDO  !tr
     929
     930        IF (CPPKEY_STRATAER) THEN
     931          IF (type_trac=='coag') THEN
     932            ! compute wet deposition flux of sulfur (sum over gases and
     933            ! particles) and convert to kg(S)/m2/s
     934            ! adding contribution of d_tr_ls to d_tr_cv (above)
     935            DO i = 1, klon
     936              DO k = 1, klev
     937                DO it = 1, nbtr
     938                  IF (it==id_OCS_strat) THEN
     939                    budg_dep_wet_ocs(i) = budg_dep_wet_ocs(i) + d_tr_ls(i, k, it) * (mSatom / mOCSmol) &
     940                            * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     941                  ELSEIF (it==id_SO2_strat) THEN
     942                    budg_dep_wet_so2(i) = budg_dep_wet_so2(i) + d_tr_ls(i, k, it) * (mSatom / mSO2mol) &
     943                            * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     944                  ELSEIF (it==id_H2SO4_strat) THEN
     945                    budg_dep_wet_h2so4(i) = budg_dep_wet_h2so4(i) + d_tr_ls(i, k, it) * (mSatom / mH2SO4mol) &
     946                            * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     947                  ELSEIF (it>nbtr_sulgas) THEN
     948                    budg_dep_wet_part(i) = budg_dep_wet_part(i) + d_tr_ls(i, k, it) * (mSatom / mH2SO4mol)  &
     949                            * dens_aer_dry * 4. / 3. * RPI * (mdw(it - nbtr_sulgas) / 2.)**3 &
     950                            * (paprs(i, k) - paprs(i, k + 1)) / RG / pdtphys
     951                  ENDIF
    933952                ENDDO
    934              ENDDO
    935              CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'lsc scav it = '//TRIM(int2str(it)))
    936              ENDIF
    937 
    938           ENDDO  !tr
    939 
    940 #ifdef CPP_StratAer
    941          IF (type_trac=='coag') THEN
    942            ! compute wet deposition flux of sulfur (sum over gases and
    943            ! particles) and convert to kg(S)/m2/s
    944            ! adding contribution of d_tr_ls to d_tr_cv (above)
    945            DO i = 1, klon
    946            DO k = 1, klev
    947            DO it = 1, nbtr
    948              IF (it==id_OCS_strat) THEN
    949                budg_dep_wet_ocs(i)=budg_dep_wet_ocs(i)+d_tr_ls(i,k,it)*(mSatom/mOCSmol) &
    950    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    951              ELSEIF (it==id_SO2_strat) THEN
    952                budg_dep_wet_so2(i)=budg_dep_wet_so2(i)+d_tr_ls(i,k,it)*(mSatom/mSO2mol) &
    953    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    954              ELSEIF (it==id_H2SO4_strat) THEN
    955                budg_dep_wet_h2so4(i)=budg_dep_wet_h2so4(i)+d_tr_ls(i,k,it)*(mSatom/mH2SO4mol) &
    956    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    957              ELSEIF (it.GT.nbtr_sulgas) THEN
    958                budg_dep_wet_part(i)=budg_dep_wet_part(i)+d_tr_ls(i,k,it)*(mSatom/mH2SO4mol)  &
    959    *dens_aer_dry*4./3.*RPI*(mdw(it-nbtr_sulgas)/2.)**3 &
    960    *(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
    961              ENDIF
    962            ENDDO
    963            ENDDO
    964            ENDDO
    965          ENDIF
    966 #endif
    967 
    968        ELSE IF (iflag_lscav == 2) THEN ! frac_impa, frac_nucl
    969           ! *********   modified  old version
    970 
    971           d_tr_lessi_nucl(:,:,:) = 0.
    972           d_tr_lessi_impa(:,:,:) = 0.
    973           flestottr(:,:,:) = 0.
    974           ! Tendance des aerosols nuclees et impactes
    975           DO it = 1, nbtr
    976              IF (aerosol(it)) THEN
    977                 his_dh(:)=0.
    978                 DO k = 1, klev
    979                    DO i = 1, klon
    980                       !PhH
    981                       zrho(i,k)=pplay(i,k)/t_seri(i,k)/RD
    982                       zdz(i,k)=(paprs(i,k)-paprs(i,k+1))/zrho(i,k)/RG
    983                       !
    984                    ENDDO
    985                 ENDDO
    986 
    987                 DO k=klev-1, 1, -1
    988                    DO i=1, klon
    989                       !             d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.)
    990                       dx=d_tr_ls(i,k,it)
    991                       his_dh(i)=his_dh(i)-dx*zrho(i,k)*zdz(i,k)/pdtphys !  kg/m2/s
    992                       evaplsc = prfl(i,k) - prfl(i,k+1) + psfl(i,k) - psfl(i,k+1)
    993                       ! Evaporation Partielle -> Liberation Partielle 0.5*evap
    994                       IF ( evaplsc <0..and.abs(prfl(i,k+1)+psfl(i,k+1))>1.e-10) THEN
    995                          evaplsc = (-evaplsc)/(prfl(i,k+1)+psfl(i,k+1))
    996                          ! evaplsc est donc positif, his_dh(i) est positif
    997                          !-------------- 
    998                          d_tr_evapls(i,k,it)=0.5*evaplsc*(d_tr_lessi_nucl(i,k+1,it) &
    999                               +d_tr_lessi_impa(i,k+1,it))
    1000                          !-------------   d_tr_evapls(i,k,it)=-0.5*evaplsc*(d_tr_lsc(i,k+1,it))
    1001                          beta=0.5*evaplsc
    1002                          if ((prfl(i,k)+psfl(i,k))<1.e-10) THEN
    1003                             beta=1.0*evaplsc
    1004                          endif
    1005                          dx=beta*his_dh(i)/zrho(i,k)/zdz(i,k)*pdtphys
    1006                          his_dh(i)=(1.-beta)*his_dh(i)   ! tracer from
    1007                          d_tr_evapls(i,k,it)=dx
    1008                       ENDIF
    1009                       d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.) &
    1010                            +d_tr_evapls(i,k,it)
    1011 
    1012                       !--------------
    1013                       d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
    1014                            ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
    1015                       d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
    1016                            ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
    1017                       !
    1018                       ! Flux lessivage total
    1019                       flestottr(i,k,it) = flestottr(i,k,it) -   &
    1020                            ( d_tr_lessi_nucl(i,k,it)   +        &
    1021                            d_tr_lessi_impa(i,k,it) ) *          &
    1022                            ( paprs(i,k)-paprs(i,k+1) ) /        &
    1023                            (RG * pdtphys)
    1024                       !! Mise a jour des traceurs due a l'impaction,nucleation
    1025                       !                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
    1026                       !!  calcul de la tendance liee au lessivage stratiforme
    1027                       !                 d_tr_ls(i,k,it)=tr_seri(i,k,it)*&
    1028                       !                                (1.-1./(frac_impa(i,k)*frac_nucl(i,k)))
    1029                       !--------------
    1030                    ENDDO
    1031                 ENDDO
    1032              ENDIF
    1033           ENDDO
    1034           ! *********   end modified old version
    1035 
    1036        ELSE IF (iflag_lscav == 1) THEN ! frac_impa, frac_nucl
    1037           ! *********    old version
    1038 
    1039           d_tr_lessi_nucl(:,:,:) = 0.
    1040           d_tr_lessi_impa(:,:,:) = 0.
    1041           flestottr(:,:,:) = 0.
    1042           !=========================
    1043           ! LESSIVAGE LARGE SCALE :
    1044           !=========================
    1045 
    1046           ! Tendance des aerosols nuclees et impactes
    1047           ! -----------------------------------------
    1048           DO it = 1, nbtr
    1049              IF (aerosol(it)) THEN
    1050                 DO k = 1, klev
    1051                    DO i = 1, klon
    1052                       d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
    1053                            ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
    1054                       d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
    1055                            ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
    1056 
    1057                       !
    1058                       ! Flux lessivage total
    1059                       ! ------------------------------------------------------------
    1060                       flestottr(i,k,it) = flestottr(i,k,it) -   &
    1061                            ( d_tr_lessi_nucl(i,k,it)   +        &
    1062                            d_tr_lessi_impa(i,k,it) ) *          &
    1063                            ( paprs(i,k)-paprs(i,k+1) ) /        &
    1064                            (RG * pdtphys)
    1065                       !
    1066                       ! Mise a jour des traceurs due a l'impaction,nucleation
    1067                       ! ----------------------------------------------------------------------
    1068                       tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
    1069                    ENDDO
    1070                 ENDDO
    1071              ENDIF
    1072           ENDDO
    1073 
    1074           ! *********   end old version
    1075        ENDIF  !  iflag_lscav  .EQ. 1, 2, 3 or 4
    1076        !
     953              ENDDO
     954            ENDDO
     955          ENDIF
     956        END IF
     957
     958      ELSE IF (iflag_lscav == 2) THEN ! frac_impa, frac_nucl
     959        ! *********   modified  old version
     960
     961        d_tr_lessi_nucl(:, :, :) = 0.
     962        d_tr_lessi_impa(:, :, :) = 0.
     963        flestottr(:, :, :) = 0.
     964        ! Tendance des aerosols nuclees et impactes
     965        DO it = 1, nbtr
     966          IF (aerosol(it)) THEN
     967            his_dh(:) = 0.
     968            DO k = 1, klev
     969              DO i = 1, klon
     970                !PhH
     971                zrho(i, k) = pplay(i, k) / t_seri(i, k) / RD
     972                zdz(i, k) = (paprs(i, k) - paprs(i, k + 1)) / zrho(i, k) / RG
     973                !
     974              ENDDO
     975            ENDDO
     976
     977            DO k = klev - 1, 1, -1
     978              DO i = 1, klon
     979                !             d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.)
     980                dx = d_tr_ls(i, k, it)
     981                his_dh(i) = his_dh(i) - dx * zrho(i, k) * zdz(i, k) / pdtphys !  kg/m2/s
     982                evaplsc = prfl(i, k) - prfl(i, k + 1) + psfl(i, k) - psfl(i, k + 1)
     983                ! Evaporation Partielle -> Liberation Partielle 0.5*evap
     984                IF (evaplsc <0..and.abs(prfl(i, k + 1) + psfl(i, k + 1))>1.e-10) THEN
     985                  evaplsc = (-evaplsc) / (prfl(i, k + 1) + psfl(i, k + 1))
     986                  ! evaplsc est donc positif, his_dh(i) est positif
     987                  !--------------
     988                  d_tr_evapls(i, k, it) = 0.5 * evaplsc * (d_tr_lessi_nucl(i, k + 1, it) &
     989                          + d_tr_lessi_impa(i, k + 1, it))
     990                  !-------------   d_tr_evapls(i,k,it)=-0.5*evaplsc*(d_tr_lsc(i,k+1,it))
     991                  beta = 0.5 * evaplsc
     992                  if ((prfl(i, k) + psfl(i, k))<1.e-10) THEN
     993                    beta = 1.0 * evaplsc
     994                  endif
     995                  dx = beta * his_dh(i) / zrho(i, k) / zdz(i, k) * pdtphys
     996                  his_dh(i) = (1. - beta) * his_dh(i)   ! tracer from
     997                  d_tr_evapls(i, k, it) = dx
     998                ENDIF
     999                d_tr_ls(i, k, it) = tr_seri(i, k, it) * (frac_impa(i, k) * frac_nucl(i, k) - 1.) &
     1000                        + d_tr_evapls(i, k, it)
     1001
     1002                !--------------
     1003                d_tr_lessi_nucl(i, k, it) = d_tr_lessi_nucl(i, k, it) + &
     1004                        (1 - frac_nucl(i, k)) * tr_seri(i, k, it)
     1005                d_tr_lessi_impa(i, k, it) = d_tr_lessi_impa(i, k, it) + &
     1006                        (1 - frac_impa(i, k)) * tr_seri(i, k, it)
     1007                !
     1008                ! Flux lessivage total
     1009                flestottr(i, k, it) = flestottr(i, k, it) - &
     1010                        (d_tr_lessi_nucl(i, k, it) + &
     1011                                d_tr_lessi_impa(i, k, it)) * &
     1012                                (paprs(i, k) - paprs(i, k + 1)) / &
     1013                                (RG * pdtphys)
     1014                !! Mise a jour des traceurs due a l'impaction,nucleation
     1015                !                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
     1016                !!  calcul de la tendance liee au lessivage stratiforme
     1017                !                 d_tr_ls(i,k,it)=tr_seri(i,k,it)*&
     1018                !                                (1.-1./(frac_impa(i,k)*frac_nucl(i,k)))
     1019                !--------------
     1020              ENDDO
     1021            ENDDO
     1022          ENDIF
     1023        ENDDO
     1024        ! *********   end modified old version
     1025
     1026      ELSE IF (iflag_lscav == 1) THEN ! frac_impa, frac_nucl
     1027        ! *********    old version
     1028
     1029        d_tr_lessi_nucl(:, :, :) = 0.
     1030        d_tr_lessi_impa(:, :, :) = 0.
     1031        flestottr(:, :, :) = 0.
     1032        !=========================
     1033        ! LESSIVAGE LARGE SCALE :
     1034        !=========================
     1035
     1036        ! Tendance des aerosols nuclees et impactes
     1037        ! -----------------------------------------
     1038        DO it = 1, nbtr
     1039          IF (aerosol(it)) THEN
     1040            DO k = 1, klev
     1041              DO i = 1, klon
     1042                d_tr_lessi_nucl(i, k, it) = d_tr_lessi_nucl(i, k, it) + &
     1043                        (1 - frac_nucl(i, k)) * tr_seri(i, k, it)
     1044                d_tr_lessi_impa(i, k, it) = d_tr_lessi_impa(i, k, it) + &
     1045                        (1 - frac_impa(i, k)) * tr_seri(i, k, it)
     1046
     1047                !
     1048                ! Flux lessivage total
     1049                ! ------------------------------------------------------------
     1050                flestottr(i, k, it) = flestottr(i, k, it) - &
     1051                        (d_tr_lessi_nucl(i, k, it) + &
     1052                                d_tr_lessi_impa(i, k, it)) * &
     1053                                (paprs(i, k) - paprs(i, k + 1)) / &
     1054                                (RG * pdtphys)
     1055                !
     1056                ! Mise a jour des traceurs due a l'impaction,nucleation
     1057                ! ----------------------------------------------------------------------
     1058                tr_seri(i, k, it) = tr_seri(i, k, it) * frac_impa(i, k) * frac_nucl(i, k)
     1059              ENDDO
     1060            ENDDO
     1061          ENDIF
     1062        ENDDO
     1063
     1064        ! *********   end old version
     1065      ENDIF  !  iflag_lscav  .EQ. 1, 2, 3 or 4
     1066      !
    10771067    ENDIF !  lessivage
    10781068
    10791069
    10801070    !    -- CHIMIE INCA  config_inca = aero or chem --
    1081     IF (ANY(type_trac == ['inca','inco'])) THEN  ! ModThL
    1082 
    1083        CALL tracinca(&
    1084             nstep,    julien,   gmtime,         lafin,    &
    1085             pdtphys,  t_seri,   paprs,          pplay,    &
    1086             pmfu,     upwd,     ftsol,  pctsrf, pphis,    &
    1087             pphi,     albsol,   sh,    ch,     rh,        &
    1088             cldfra,   rneb,     diafra,         cldliq,    &
    1089             itop_con, ibas_con, pmflxr,         pmflxs,    &
    1090             prfl,     psfl,    aerosol_couple, flxmass_w, &
    1091             tau_aero, piz_aero, cg_aero,        ccm,      &
    1092             rfname,                                        &
    1093             tr_seri(:,:,1+nqCO2:nbtr),  source(:,1+nqCO2:nbtr))  ! ModThL 
     1071    IF (ANY(type_trac == ['inca', 'inco'])) THEN  ! ModThL
     1072
     1073      CALL tracinca(&
     1074              nstep, julien, gmtime, lafin, &
     1075              pdtphys, t_seri, paprs, pplay, &
     1076              pmfu, upwd, ftsol, pctsrf, pphis, &
     1077              pphi, albsol, sh, ch, rh, &
     1078              cldfra, rneb, diafra, cldliq, &
     1079              itop_con, ibas_con, pmflxr, pmflxs, &
     1080              prfl, psfl, aerosol_couple, flxmass_w, &
     1081              tau_aero, piz_aero, cg_aero, ccm, &
     1082              rfname, &
     1083              tr_seri(:, :, 1 + nqCO2:nbtr), source(:, 1 + nqCO2:nbtr))  ! ModThL
    10941084    ENDIF
    10951085
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/isotopes_mod.F90

    r4982 r5098  
    144144!$OMP THREADPRIVATE(ok_prod_nucl_tritium)
    145145   INTEGER, PARAMETER :: nessai = 486
    146    INTEGER, DIMENSION(nessai), SAVE :: &
     146   INTEGER, DIMENSION(nessai) :: &
    147147                    day_nucl, month_nucl, year_nucl
    148148!$OMP THREADPRIVATE(day_nucl, month_nucl, year_nucl)
    149    REAL,    DIMENSION(nessai), SAVE :: &
     149   REAL,    DIMENSION(nessai) :: &
    150150                    lat_nucl, lon_nucl, zmin_nucl, zmax_nucl, HTO_nucl
    151151!$OMP THREADPRIVATE(lat_nucl, lon_nucl, zmin_nucl, zmax_nucl, HTO_nucl)
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/isotopes_routines_mod.F90

    r5087 r5098  
    1717&       bidouille_anti_divergence, &
    1818&       iso_eau,iso_HDO,iso_O18
     19USE lmdz_yomcst
     20
    1921#ifdef ISOVERIF
    2022!USE isotopes_verif_mod, ONLY: errmax,errmaxrel
     
    2830#endif
    2931implicit none
    30 
    31 #include "YOMCST.h"       
    3232
    3333! inputs
     
    1296212962&       bidouille_anti_divergence, ridicule,ridicule_snow, &
    1296312963&       tcorr,toce,alpha_liq_sol
    12964     USE indice_sol_mod   
     12964    USE indice_sol_mod
     12965    USE lmdz_yomcst
    1296512966#ifdef ISOVERIF
    1296612967!    USE isotopes_verif_mod, ONLY: errmax,errmaxrel,errmax_sol,deltalim_snow
     
    1297812979#include "YOETHF.h"
    1297912980#include "FCTTRE.h"   
    12980 #include "YOMCST.h"
    1298112981!#include "dimensions.h"
    1298212982!#include "paramet.h"
     
    1353413534&       rh_cste_surf_cond,Rdefault,T_cste_surf_cond,iso_O17,iso_O18, &
    1353513535&       ridicule_evap,tnat
     13536    USE lmdz_yomcst
    1353613537#ifdef ISOVERIF
    1353713538!    USE isotopes_verif_mod, ONLY: deltaDfaible, faible_evap,errmax,errmaxrel
     
    1354613547#include "YOETHF.h"         
    1354713548#include "FCTTRE.h"   
    13548 #include "YOMCST.h"
    13549        
     13549
    1355013550        ! inputs
    1355113551        integer, intent(in) :: klon,knon ! dimensions
     
    1444714447&       ridicule_evap
    1444814448USE fonte_neige_mod, ONLY: gestion_neige_besoin_varglob_fonte_neige
     14449USE lmdz_yomcst
    1444914450#ifdef ISOVERIF
    1445014451!USE isotopes_verif_mod, ONLY: errmax,errmaxrel,errmax_sol,deltalim_snow, &
     
    1446014461
    1446114462#include "YOETHF.h"
    14462 #include "FCTTRE.h"   
    14463 #include "YOMCST.h"
    14464 !#include "dimensions.h"
    14465 !#include "paramet.h"
     14463#include "FCTTRE.h"
    1446614464       
    1446714465        ! inputs
     
    1663416632        USE geometry_mod, only: latitude_deg,longitude_deg, & ! en degré, remplace rlat et rlon
    1663516633                   latitude,longitude ! en radian, remplace rlatd et rlond
     16634        USE lmdz_yomcst
    1663616635#ifdef ISOVERIF
    1663716636        USE isotopes_verif_mod
    1663816637#endif
    1663916638      implicit none
    16640 
    16641 #include "YOMCST.h"
    1664216639
    1664316640! input
     
    1823218229        USE dimphy, only: klon,klev
    1823318230        use geometry_mod, only: latitude_deg,longitude_deg
     18231        USE lmdz_yomcst
    1823418232#ifdef ISOVERIF
    1823518233        USE isotopes_verif_mod
     
    1823718235      implicit none
    1823818236
    18239 #include "YOMCST.h"
    1824018237#include "dimensions.h"
    1824118238! pour avoir iim et jjm
     
    1837518372        use geometry_mod, only: cell_area
    1837618373        use dimphy, only: klon,klev
     18374        USE lmdz_yomcst
    1837718375#ifdef ISOVERIF
    1837818376        USE isotopes_verif_mod
    1837918377#endif
    1838018378      implicit none
    18381 
    18382 #include "YOMCST.h"
    1838318379
    1838418380!     Arguments
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/phys_local_var_mod.F90

    r5066 r5098  
    22! $Id: phys_local_var_mod.F90 3888 2021-05-05 10:50:37Z jyg $
    33!
    4       MODULE phys_local_var_mod
    5 ! Variables locales pour effectuer les appels en serie
    6 !======================================================================
    7 !
    8 !
    9 !======================================================================
    10 ! Declaration des variables
    11 
    12       REAL, SAVE, ALLOCATABLE :: t_seri(:,:), q_seri(:,:)
    13       !$OMP THREADPRIVATE(t_seri, q_seri)
    14       REAL, SAVE, ALLOCATABLE :: ql_seri(:,:),qs_seri(:,:)
    15       !$OMP THREADPRIVATE(ql_seri,qs_seri)
    16       REAL, SAVE, ALLOCATABLE :: qx_seri(:,:,:)
    17       !$OMP THREADPRIVATE(qx_seri)
    18       REAL, SAVE, ALLOCATABLE :: qbs_seri(:,:)
    19       !$OMP THREADPRIVATE(qbs_seri)
    20       REAL, SAVE, ALLOCATABLE :: u_seri(:,:), v_seri(:,:)
    21       !$OMP THREADPRIVATE(u_seri, v_seri)
    22       REAL, SAVE, ALLOCATABLE :: rneb_seri(:,:)
    23       !$OMP THREADPRIVATE(rneb_seri)
    24       REAL, SAVE, ALLOCATABLE :: d_rneb_dyn(:,:)
    25       !$OMP THREADPRIVATE(d_rneb_dyn)
    26       REAL, SAVE, ALLOCATABLE :: l_mixmin(:,:,:),l_mix(:,:,:),wprime(:,:,:)
    27       !$OMP THREADPRIVATE(l_mixmin, l_mix, wprime)
    28       REAL, SAVE, ALLOCATABLE :: pbl_eps(:,:,:)
    29       !$OMP THREADPRIVATE(pbl_eps)
    30       REAL, SAVE, ALLOCATABLE :: tke_shear(:,:,:), tke_buoy(:,:,:), tke_trans(:,:,:)
    31       !$OMP THREADPRIVATE(tke_shear,tke_buoy,tke_trans)
    32       REAL, SAVE, ALLOCATABLE :: tr_seri(:,:,:)
    33       !$OMP THREADPRIVATE(tr_seri)
    34       REAL, SAVE, ALLOCATABLE :: rhcl(:,:)
    35       !$OMP THREADPRIVATE(rhcl)
    36       REAL, SAVE, ALLOCATABLE :: d_t_dyn(:,:), d_q_dyn(:,:)
    37       !$OMP THREADPRIVATE(d_t_dyn, d_q_dyn)
    38       REAL, SAVE, ALLOCATABLE :: d_ql_dyn(:,:), d_qs_dyn(:,:), d_qbs_dyn(:,:)
    39       !$OMP THREADPRIVATE(d_ql_dyn, d_qs_dyn, d_qbs_dyn)
    40       REAL, SAVE, ALLOCATABLE :: d_q_dyn2d(:), d_ql_dyn2d(:), d_qs_dyn2d(:), d_qbs_dyn2d(:)
    41       !$OMP THREADPRIVATE(d_q_dyn2d, d_ql_dyn2d, d_qs_dyn2d, d_qbs_dyn2d)
    42       REAL, SAVE, ALLOCATABLE :: d_u_dyn(:,:), d_v_dyn(:,:)
    43       !$OMP THREADPRIVATE(d_u_dyn, d_v_dyn)
    44       REAL, SAVE, ALLOCATABLE :: d_tr_dyn(:,:,:)
    45       !$OMP THREADPRIVATE(d_tr_dyn)
    46       REAL, SAVE, ALLOCATABLE :: d_t_con(:,:),d_q_con(:,:),d_q_con_zmasse(:,:)
    47       !$OMP THREADPRIVATE(d_t_con,d_q_con,d_q_con_zmasse)
    48       REAL, SAVE, ALLOCATABLE :: d_u_con(:,:),d_v_con(:,:)
    49       !$OMP THREADPRIVATE(d_u_con,d_v_con)
    50       REAL, SAVE, ALLOCATABLE :: d_t_wake(:,:),d_q_wake(:,:)
    51       !$OMP THREADPRIVATE( d_t_wake,d_q_wake)
    52       REAL, SAVE, ALLOCATABLE :: d_t_lsc(:,:),d_q_lsc(:,:),d_ql_lsc(:,:),d_qi_lsc(:,:)
    53       !$OMP THREADPRIVATE(d_t_lsc,d_q_lsc,d_ql_lsc,d_qi_lsc)
    54       REAL, SAVE, ALLOCATABLE :: d_t_lwr(:,:),d_t_lw0(:,:),d_t_swr(:,:),d_t_sw0(:,:)
    55       !$OMP THREADPRIVATE(d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0)
    56       REAL, SAVE, ALLOCATABLE :: d_t_ajsb(:,:), d_q_ajsb(:,:)
    57       !$OMP THREADPRIVATE(d_t_ajsb, d_q_ajsb)
    58       REAL, SAVE, ALLOCATABLE :: d_t_ajs(:,:), d_q_ajs(:,:)
    59       !$OMP THREADPRIVATE(d_t_ajs, d_q_ajs)
    60       REAL, SAVE, ALLOCATABLE :: d_u_ajs(:,:), d_v_ajs(:,:)
    61       !$OMP THREADPRIVATE(d_u_ajs, d_v_ajs)
    62 !nrlmd<
    63       REAL, SAVE, ALLOCATABLE :: d_t_ajs_w(:,:), d_q_ajs_w(:,:)
    64       !$OMP THREADPRIVATE(d_t_ajs_w, d_q_ajs_w)
    65       REAL, SAVE, ALLOCATABLE :: d_t_ajs_x(:,:), d_q_ajs_x(:,:)
    66       !$OMP THREADPRIVATE(d_t_ajs_x, d_q_ajs_x)
    67 !>nrlmd
    68       REAL, SAVE, ALLOCATABLE :: d_t_eva(:,:),d_q_eva(:,:),d_ql_eva(:,:),d_qi_eva(:,:)
    69       !$OMP THREADPRIVATE(d_t_eva,d_q_eva,d_ql_eva,d_qi_eva)
    70       REAL, SAVE, ALLOCATABLE :: d_qx_eva(:,:,:)
    71       !$OMP THREADPRIVATE(d_qx_eva)
    72       REAL, SAVE, ALLOCATABLE :: d_t_lscst(:,:),d_q_lscst(:,:)
    73       !$OMP THREADPRIVATE(d_t_lscst,d_q_lscst)
    74       REAL, SAVE, ALLOCATABLE :: d_t_lscth(:,:),d_q_lscth(:,:)
    75       !$OMP THREADPRIVATE(d_t_lscth,d_q_lscth)
    76       REAL, SAVE, ALLOCATABLE :: plul_th(:),plul_st(:)
    77       !$OMP THREADPRIVATE(plul_th,plul_st)
    78 !tendances dues a oro et lif
    79       REAL, SAVE, ALLOCATABLE :: d_t_oli(:,:)
    80       !$OMP THREADPRIVATE(d_t_oli)
    81       REAL, SAVE, ALLOCATABLE :: d_u_oli(:,:), d_v_oli(:,:)
    82       !$OMP THREADPRIVATE(d_u_oli, d_v_oli)
    83       REAL, SAVE, ALLOCATABLE :: d_t_vdf(:,:), d_q_vdf(:,:), d_qbs_vdf(:,:), d_t_diss(:,:)
    84       !$OMP THREADPRIVATE( d_t_vdf, d_q_vdf, d_qbs_vdf, d_t_diss)
    85       REAL, SAVE, ALLOCATABLE :: d_u_vdf(:,:), d_v_vdf(:,:)
    86       !$OMP THREADPRIVATE(d_u_vdf, d_v_vdf)
    87 !nrlmd+jyg<
    88       REAL, SAVE, ALLOCATABLE :: d_t_vdf_w(:,:), d_q_vdf_w(:,:)
    89       !$OMP THREADPRIVATE( d_t_vdf_w, d_q_vdf_w)
    90       REAL, SAVE, ALLOCATABLE :: d_t_vdf_x(:,:), d_q_vdf_x(:,:)
    91       !$OMP THREADPRIVATE( d_t_vdf_x, d_q_vdf_x)
    92       REAL, SAVE, ALLOCATABLE :: d_t_bsss(:,:), d_q_bsss(:,:), d_qbs_bsss(:,:)
    93       !$OMP THREADPRIVATE( d_t_bsss,d_q_bsss, d_qbs_bsss)
    94 !>nrlmd+jyg
    95       REAL, SAVE, ALLOCATABLE :: d_t_oro(:,:)
    96       !$OMP THREADPRIVATE(d_t_oro)
    97       REAL, SAVE, ALLOCATABLE :: d_u_oro(:,:), d_v_oro(:,:)
    98       !$OMP THREADPRIVATE(d_u_oro, d_v_oro)
    99       REAL, SAVE, ALLOCATABLE :: d_t_oro_gw(:,:)
    100       !$OMP THREADPRIVATE(d_t_oro_gw)
    101       REAL, SAVE, ALLOCATABLE :: d_u_oro_gw(:,:), d_v_oro_gw(:,:)
    102       !$OMP THREADPRIVATE(d_u_oro_gw, d_v_oro_gw)
    103       REAL, SAVE, ALLOCATABLE :: d_t_lif(:,:)
    104       !$OMP THREADPRIVATE(d_t_lif)
    105       REAL, SAVE, ALLOCATABLE :: d_u_lif(:,:), d_v_lif(:,:)
    106       !$OMP THREADPRIVATE(d_u_lif, d_v_lif)
    107 ! Tendances Ondes de G non oro (runs strato).
    108       REAL, SAVE, ALLOCATABLE :: du_gwd_hines(:,:)
    109       !$OMP THREADPRIVATE(du_gwd_hines)
    110       REAL, SAVE, ALLOCATABLE :: dv_gwd_hines(:,:)
    111       !$OMP THREADPRIVATE(dv_gwd_hines)
    112       REAL, SAVE, ALLOCATABLE :: dv_gwd_rando(:,:)
    113       !$OMP THREADPRIVATE(dv_gwd_rando)
    114       REAL, SAVE, ALLOCATABLE :: dv_gwd_front(:,:)
    115       !$OMP THREADPRIVATE(dv_gwd_front)
    116       REAL, SAVE, ALLOCATABLE :: east_gwstress(:,:)
    117       !$OMP THREADPRIVATE(east_gwstress)
    118       REAL, SAVE, ALLOCATABLE :: west_gwstress(:,:)
    119       !$OMP THREADPRIVATE(west_gwstress)
    120       REAL, SAVE, ALLOCATABLE :: d_t_hin(:,:)
    121       !$OMP THREADPRIVATE(d_t_hin)
    122 ! tendance due a l'oxydation du methane
    123       REAL, SAVE, ALLOCATABLE :: d_q_ch4(:,:)
    124       !$OMP THREADPRIVATE(d_q_ch4)
     4MODULE phys_local_var_mod
     5  USE lmdz_cppkeys_wrapper, ONLY : CPPKEY_STRATAER
     6  ! Variables locales pour effectuer les appels en serie
     7  !======================================================================
     8  !
     9  !
     10  !======================================================================
     11  ! Declaration des variables
     12
     13  REAL, SAVE, ALLOCATABLE :: t_seri(:, :), q_seri(:, :)
     14  !$OMP THREADPRIVATE(t_seri, q_seri)
     15  REAL, SAVE, ALLOCATABLE :: ql_serf_r_wetbi(:, :), qs_seri(:, :)
     16  !$OMP THREADPRIVATE(ql_seri,qs_seri)
     17  REAL, SAVE, ALLOCATABLE :: qx_seri(:, :, :)
     18  !$OMP THREADPRIVATE(qx_seri)
     19  REAL, SAVE, ALLOCATABLE :: qbs_seri(:, :)
     20  !$OMP THREADPRIVATE(qbs_seri)
     21  REAL, SAVE, ALLOCATABLE :: u_seri(:, :), v_seri(:, :)
     22  !$OMP THREADPRIVATE(u_seri, v_seri)
     23  REAL, SAVE, ALLOCATABLE :: rneb_seri(:, :)
     24  !$OMP THREADPRIVATE(rneb_seri)
     25  REAL, SAVE, ALLOCATABLE :: d_rneb_dyn(:, :)
     26  !$OMP THREADPRIVATE(d_rneb_dyn)
     27  REAL, SAVE, ALLOCATABLE :: l_mixmin(:, :, :), l_mix(:, :, :), wprime(:, :, :)
     28  !$OMP THREADPRIVATE(l_mixmin, l_mix, wprime)
     29  REAL, SAVE, ALLOCATABLE :: pbl_eps(:, :, :)
     30  !$OMP THREADPRIVATE(pbl_eps)
     31  REAL, SAVE, ALLOCATABLE :: tke_shear(:, :, :), tke_buoy(:, :, :), tke_trans(:, :, :)
     32  !$OMP THREADPRIVATE(tke_shear,tke_buoy,tke_trans)
     33  REAL, SAVE, ALLOCATABLE :: tr_seri(:, :, :)
     34  !$OMP THREADPRIVATE(tr_seri)
     35  REAL, SAVE, ALLOCATABLE :: rhcl(:, :)
     36  !$OMP THREADPRIVATE(rhcl)
     37  REAL, SAVE, ALLOCATABLE :: d_t_dyn(:, :), d_q_dyn(:, :)
     38  !$OMP THREADPRIVATE(d_t_dyn, d_q_dyn)
     39  REAL, SAVE, ALLOCATABLE :: d_ql_dyn(:, :), d_qs_dyn(:, :), d_qbs_dyn(:, :)
     40  !$OMP THREADPRIVATE(d_ql_dyn, d_qs_dyn, d_qbs_dyn)
     41  REAL, SAVE, ALLOCATABLE :: d_q_dyn2d(:), d_ql_dyn2d(:), d_qs_dyn2d(:), d_qbs_dyn2d(:)
     42  !$OMP THREADPRIVATE(d_q_dyn2d, d_ql_dyn2d, d_qs_dyn2d, d_qbs_dyn2d)
     43  REAL, SAVE, ALLOCATABLE :: d_u_dyn(:, :), d_v_dyn(:, :)
     44  !$OMP THREADPRIVATE(d_u_dyn, d_v_dyn)
     45  REAL, SAVE, ALLOCATABLE :: d_tr_dyn(:, :, :)
     46  !$OMP THREADPRIVATE(d_tr_dyn)
     47  REAL, SAVE, ALLOCATABLE :: d_t_con(:, :), d_q_con(:, :), d_q_con_zmasse(:, :)
     48  !$OMP THREADPRIVATE(d_t_con,d_q_con,d_q_con_zmasse)
     49  REAL, SAVE, ALLOCATABLE :: d_u_con(:, :), d_v_con(:, :)
     50  !$OMP THREADPRIVATE(d_u_con,d_v_con)
     51  REAL, SAVE, ALLOCATABLE :: d_t_wake(:, :), d_q_wake(:, :)
     52  !$OMP THREADPRIVATE( d_t_wake,d_q_wake)
     53  REAL, SAVE, ALLOCATABLE :: d_t_lsc(:, :), d_q_lsc(:, :), d_ql_lsc(:, :), d_qi_lsc(:, :)
     54  !$OMP THREADPRIVATE(d_t_lsc,d_q_lsc,d_ql_lsc,d_qi_lsc)
     55  REAL, SAVE, ALLOCATABLE :: d_t_lwr(:, :), d_t_lw0(:, :), d_t_swr(:, :), d_t_sw0(:, :)
     56  !$OMP THREADPRIVATE(d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0)
     57  REAL, SAVE, ALLOCATABLE :: d_t_ajsb(:, :), d_q_ajsb(:, :)
     58  !$OMP THREADPRIVATE(d_t_ajsb, d_q_ajsb)
     59  REAL, SAVE, ALLOCATABLE :: d_t_ajs(:, :), d_q_ajs(:, :)
     60  !$OMP THREADPRIVATE(d_t_ajs, d_q_ajs)
     61  REAL, SAVE, ALLOCATABLE :: d_u_ajs(:, :), d_v_ajs(:, :)
     62  !$OMP THREADPRIVATE(d_u_ajs, d_v_ajs)
     63  !nrlmd<
     64  REAL, SAVE, ALLOCATABLE :: d_t_ajs_w(:, :), d_q_ajs_w(:, :)
     65  !$OMP THREADPRIVATE(d_t_ajs_w, d_q_ajs_w)
     66  REAL, SAVE, ALLOCATABLE :: d_t_ajs_x(:, :), d_q_ajs_x(:, :)
     67  !$OMP THREADPRIVATE(d_t_ajs_x, d_q_ajs_x)
     68  !>nrlmd
     69  REAL, SAVE, ALLOCATABLE :: d_t_eva(:, :), d_q_eva(:, :), d_ql_eva(:, :), d_qi_eva(:, :)
     70  !$OMP THREADPRIVATE(d_t_eva,d_q_eva,d_ql_eva,d_qi_eva)
     71  REAL, SAVE, ALLOCATABLE :: d_qx_eva(:, :, :)
     72  !$OMP THREADPRIVATE(d_qx_eva)
     73  REAL, SAVE, ALLOCATABLE :: d_t_lscst(:, :), d_q_lscst(:, :)
     74  !$OMP THREADPRIVATE(d_t_lscst,d_q_lscst)
     75  REAL, SAVE, ALLOCATABLE :: d_t_lscth(:, :), d_q_lscth(:, :)
     76  !$OMP THREADPRIVATE(d_t_lscth,d_q_lscth)
     77  REAL, SAVE, ALLOCATABLE :: plul_th(:), plul_st(:)
     78  !$OMP THREADPRIVATE(plul_th,plul_st)
     79  !tendances dues a oro et lif
     80  REAL, SAVE, ALLOCATABLE :: d_t_oli(:, :)
     81  !$OMP THREADPRIVATE(d_t_oli)
     82  REAL, SAVE, ALLOCATABLE :: d_u_oli(:, :), d_v_oli(:, :)
     83  !$OMP THREADPRIVATE(d_u_oli, d_v_oli)
     84  REAL, SAVE, ALLOCATABLE :: d_t_vdf(:, :), d_q_vdf(:, :), d_qbs_vdf(:, :), d_t_diss(:, :)
     85  !$OMP THREADPRIVATE( d_t_vdf, d_q_vdf, d_qbs_vdf, d_t_diss)
     86  REAL, SAVE, ALLOCATABLE :: d_u_vdf(:, :), d_v_vdf(:, :)
     87  !$OMP THREADPRIVATE(d_u_vdf, d_v_vdf)
     88  !nrlmd+jyg<
     89  REAL, SAVE, ALLOCATABLE :: d_t_vdf_w(:, :), d_q_vdf_w(:, :)
     90  !$OMP THREADPRIVATE( d_t_vdf_w, d_q_vdf_w)
     91  REAL, SAVE, ALLOCATABLE :: d_t_vdf_x(:, :), d_q_vdf_x(:, :)
     92  !$OMP THREADPRIVATE( d_t_vdf_x, d_q_vdf_x)
     93  REAL, SAVE, ALLOCATABLE :: d_t_bsss(:, :), d_q_bsss(:, :), d_qbs_bsss(:, :)
     94  !$OMP THREADPRIVATE( d_t_bsss,d_q_bsss, d_qbs_bsss)
     95  !>nrlmd+jyg
     96  REAL, SAVE, ALLOCATABLE :: d_t_oro(:, :)
     97  !$OMP THREADPRIVATE(d_t_oro)
     98  REAL, SAVE, ALLOCATABLE :: d_u_oro(:, :), d_v_oro(:, :)
     99  !$OMP THREADPRIVATE(d_u_oro, d_v_oro)
     100  REAL, SAVE, ALLOCATABLE :: d_t_oro_gw(:, :)
     101  !$OMP THREADPRIVATE(d_t_oro_gw)
     102  REAL, SAVE, ALLOCATABLE :: d_u_oro_gw(:, :), d_v_oro_gw(:, :)
     103  !$OMP THREADPRIVATE(d_u_oro_gw, d_v_oro_gw)
     104  REAL, SAVE, ALLOCATABLE :: d_t_lif(:, :)
     105  !$OMP THREADPRIVATE(d_t_lif)
     106  REAL, SAVE, ALLOCATABLE :: d_u_lif(:, :), d_v_lif(:, :)
     107  !$OMP THREADPRIVATE(d_u_lif, d_v_lif)
     108  ! Tendances Ondes de G non oro (runs strato).
     109  REAL, SAVE, ALLOCATABLE :: du_gwd_hines(:, :)
     110  !$OMP THREADPRIVATE(du_gwd_hines)
     111  REAL, SAVE, ALLOCATABLE :: dv_gwd_hines(:, :)
     112  !$OMP THREADPRIVATE(dv_gwd_hines)
     113  REAL, SAVE, ALLOCATABLE :: dv_gwd_rando(:, :)
     114  !$OMP THREADPRIVATE(dv_gwd_rando)
     115  REAL, SAVE, ALLOCATABLE :: dv_gwd_front(:, :)
     116  !$OMP THREADPRIVATE(dv_gwd_front)
     117  REAL, SAVE, ALLOCATABLE :: east_gwstress(:, :)
     118  !$OMP THREADPRIVATE(east_gwstress)
     119  REAL, SAVE, ALLOCATABLE :: west_gwstress(:, :)
     120  !$OMP THREADPRIVATE(west_gwstress)
     121  REAL, SAVE, ALLOCATABLE :: d_t_hin(:, :)
     122  !$OMP THREADPRIVATE(d_t_hin)
     123  ! tendance due a l'oxydation du methane
     124  REAL, SAVE, ALLOCATABLE :: d_q_ch4(:, :)
     125  !$OMP THREADPRIVATE(d_q_ch4)
    125126#ifdef ISO
    126127      REAL, SAVE, ALLOCATABLE :: xt_seri(:,:,:)
     
    168169#endif
    169170
    170 ! tendance du a la conersion Ec -> E thermique
    171       REAL, SAVE, ALLOCATABLE :: d_t_ec(:,:)
    172       !$OMP THREADPRIVATE(d_t_ec)
    173       REAL, SAVE, ALLOCATABLE :: d_ts(:,:), d_tr(:,:,:)
    174       !$OMP THREADPRIVATE(d_ts, d_tr)
    175 
    176 ! aerosols
    177       REAL, SAVE, ALLOCATABLE :: m_allaer (:,:,:)
    178       !$OMP THREADPRIVATE(m_allaer)
    179 ! diagnostique pour le rayonnement
    180       REAL, SAVE, ALLOCATABLE :: topswad_aero(:), solswad_aero(:)      ! diag
    181       !$OMP THREADPRIVATE(topswad_aero,solswad_aero)
    182       REAL, SAVE, ALLOCATABLE :: topswai_aero(:), solswai_aero(:)      ! diag
    183       !$OMP THREADPRIVATE(topswai_aero,solswai_aero)
    184       REAL, SAVE, ALLOCATABLE :: topswad0_aero(:), solswad0_aero(:)     ! diag
    185       !$OMP THREADPRIVATE(topswad0_aero,solswad0_aero)
    186       REAL, SAVE, ALLOCATABLE :: topsw_aero(:,:),  solsw_aero(:,:)      ! diag
    187       !$OMP THREADPRIVATE(topsw_aero,solsw_aero)
    188       REAL, SAVE, ALLOCATABLE :: topsw0_aero(:,:), solsw0_aero(:,:)     ! diag
    189       !$OMP THREADPRIVATE(topsw0_aero,solsw0_aero)
    190       REAL, SAVE, ALLOCATABLE :: topswcf_aero(:,:),  solswcf_aero(:,:)  ! diag
    191       !$OMP THREADPRIVATE(topswcf_aero,solswcf_aero)
    192 ! LW radiation diagnostics CK
    193       REAL, SAVE, ALLOCATABLE :: toplwad_aero(:), sollwad_aero(:)      ! diag
    194       !$OMP THREADPRIVATE(toplwad_aero,sollwad_aero)
    195       REAL, SAVE, ALLOCATABLE :: toplwai_aero(:), sollwai_aero(:)      ! diag
    196       !$OMP THREADPRIVATE(toplwai_aero,sollwai_aero)
    197       REAL, SAVE, ALLOCATABLE :: toplwad0_aero(:), sollwad0_aero(:)     ! diag
    198       !$OMP THREADPRIVATE(toplwad0_aero,sollwad0_aero)
    199 ! Special RRTM
    200       REAL, SAVE, ALLOCATABLE :: ZLWFT0_i(:,:),  ZSWFT0_i(:,:)      ! diag
    201       !$OMP THREADPRIVATE(ZLWFT0_i,ZSWFT0_i)
    202       REAL, SAVE, ALLOCATABLE :: ZFLDN0(:,:),  ZFLUP0(:,:)      ! diag
    203       !$OMP THREADPRIVATE(ZFLDN0,ZFLUP0)
    204       REAL, SAVE, ALLOCATABLE :: ZFSDN0(:,:),  ZFSUP0(:,:)      ! diag
    205       !$OMP THREADPRIVATE(ZFSDN0,ZFSUP0)
    206 !
    207       REAL, SAVE, ALLOCATABLE :: stratomask(:,:)
    208       !$OMP THREADPRIVATE(stratomask)
    209       REAL, SAVE, ALLOCATABLE :: tausum_aero(:,:,:)
    210       !$OMP THREADPRIVATE(tausum_aero)
    211       REAL, SAVE, ALLOCATABLE :: drytausum_aero(:,:)
    212       !$OMP THREADPRIVATE(drytausum_aero)
    213       REAL, SAVE, ALLOCATABLE :: tau3d_aero(:,:,:,:)
    214       !$OMP THREADPRIVATE(tau3d_aero)
    215       REAL, SAVE, ALLOCATABLE :: dNovrN(:)
    216       !$OMP THREADPRIVATE(dNovrN)
    217       REAL, SAVE, ALLOCATABLE :: zfice(:,:)
    218       !$OMP THREADPRIVATE(zfice)
    219       REAL, SAVE, ALLOCATABLE :: od443aer(:)
    220       !$OMP THREADPRIVATE(od443aer)
    221       REAL, SAVE, ALLOCATABLE :: od550aer(:)
    222       !$OMP THREADPRIVATE(od550aer)
    223       REAL, SAVE, ALLOCATABLE :: dryod550aer(:)
    224       !$OMP THREADPRIVATE(dryod550aer)
    225       REAL, SAVE, ALLOCATABLE :: abs550aer(:)
    226       !$OMP THREADPRIVATE(abs550aer)
    227       REAL, SAVE, ALLOCATABLE :: od865aer(:)
    228       !$OMP THREADPRIVATE(od865aer)
    229       REAL, SAVE, ALLOCATABLE :: ec550aer(:,:)
    230       !$OMP THREADPRIVATE(ec550aer)
    231       REAL, SAVE, ALLOCATABLE :: od550lt1aer(:)
    232       !$OMP THREADPRIVATE(od550lt1aer)
    233       REAL, SAVE, ALLOCATABLE :: sconcso4(:)
    234       !$OMP THREADPRIVATE(sconcso4)
    235       REAL, SAVE, ALLOCATABLE :: sconcno3(:)
    236       !$OMP THREADPRIVATE(sconcno3)
    237       REAL, SAVE, ALLOCATABLE :: sconcoa(:)
    238       !$OMP THREADPRIVATE(sconcoa)
    239       REAL, SAVE, ALLOCATABLE :: sconcbc(:)
    240       !$OMP THREADPRIVATE(sconcbc)
    241       REAL, SAVE, ALLOCATABLE :: sconcss(:)
    242       !$OMP THREADPRIVATE(sconcss)
    243       REAL, SAVE, ALLOCATABLE :: sconcdust(:)
    244       !$OMP THREADPRIVATE(sconcdust)
    245       REAL, SAVE, ALLOCATABLE :: concso4(:,:)
    246       !$OMP THREADPRIVATE(concso4)
    247       REAL, SAVE, ALLOCATABLE :: concno3(:,:)
    248       !$OMP THREADPRIVATE(concno3)
    249       REAL, SAVE, ALLOCATABLE :: concoa(:,:)
    250       !$OMP THREADPRIVATE(concoa)
    251       REAL, SAVE, ALLOCATABLE :: concbc(:,:)
    252       !$OMP THREADPRIVATE(concbc)
    253       REAL, SAVE, ALLOCATABLE :: concss(:,:)
    254       !$OMP THREADPRIVATE(concss)
    255       REAL, SAVE, ALLOCATABLE :: concdust(:,:)
    256       !$OMP THREADPRIVATE(concdust)
    257       REAL, SAVE, ALLOCATABLE :: loadso4(:)
    258       !$OMP THREADPRIVATE(loadso4)
    259       REAL, SAVE, ALLOCATABLE :: loadoa(:)
    260       !$OMP THREADPRIVATE(loadoa)
    261       REAL, SAVE, ALLOCATABLE :: loadbc(:)
    262       !$OMP THREADPRIVATE(loadbc)
    263       REAL, SAVE, ALLOCATABLE :: loadss(:)
    264       !$OMP THREADPRIVATE(loadss)
    265       REAL, SAVE, ALLOCATABLE :: loaddust(:)
    266       !$OMP THREADPRIVATE(loaddust)
    267       REAL, SAVE, ALLOCATABLE :: loadno3(:)
    268       !$OMP THREADPRIVATE(loadno3)
    269       REAL, SAVE, ALLOCATABLE :: load_tmp1(:), load_tmp2(:)
    270       !$OMP THREADPRIVATE(load_tmp1, load_tmp2)
    271       REAL, SAVE, ALLOCATABLE :: load_tmp3(:), load_tmp4(:)
    272       !$OMP THREADPRIVATE(load_tmp3, load_tmp4)
    273       REAL, SAVE, ALLOCATABLE :: load_tmp5(:), load_tmp6(:)
    274       !$OMP THREADPRIVATE(load_tmp5, load_tmp6)
    275       REAL, SAVE, ALLOCATABLE :: load_tmp7(:), load_tmp8(:)
    276       !$OMP THREADPRIVATE(load_tmp7, load_tmp8)
    277       REAL, SAVE, ALLOCATABLE :: load_tmp9(:), load_tmp10(:)
    278       !$OMP THREADPRIVATE(load_tmp9, load_tmp10)
    279 
    280 !IM ajout variables CFMIP2/CMIP5
    281       REAL,ALLOCATABLE,SAVE :: topswad_aerop(:), solswad_aerop(:)
    282 !$OMP THREADPRIVATE(topswad_aerop, solswad_aerop)
    283       REAL,ALLOCATABLE,SAVE :: topswai_aerop(:), solswai_aerop(:)
    284 !$OMP THREADPRIVATE(topswai_aerop, solswai_aerop)
    285       REAL,ALLOCATABLE,SAVE :: topswad0_aerop(:), solswad0_aerop(:)
    286 !$OMP THREADPRIVATE(topswad0_aerop, solswad0_aerop)
    287       REAL,ALLOCATABLE,SAVE :: topsw_aerop(:,:), topsw0_aerop(:,:) 
    288 !$OMP THREADPRIVATE(topsw_aerop, topsw0_aerop)
    289       REAL,ALLOCATABLE,SAVE :: solsw_aerop(:,:), solsw0_aerop(:,:)
    290 !$OMP THREADPRIVATE(solsw_aerop, solsw0_aerop)
    291       REAL,ALLOCATABLE,SAVE :: topswcf_aerop(:,:), solswcf_aerop(:,:)
    292 !$OMP THREADPRIVATE(topswcf_aerop, solswcf_aerop)
    293 
    294 ! additional LW variables CK
    295       REAL,ALLOCATABLE,SAVE :: toplwad_aerop(:), sollwad_aerop(:)
    296 !$OMP THREADPRIVATE(toplwad_aerop, sollwad_aerop)
    297       REAL,ALLOCATABLE,SAVE :: toplwai_aerop(:), sollwai_aerop(:)
    298 !$OMP THREADPRIVATE(toplwai_aerop, sollwai_aerop)
    299       REAL,ALLOCATABLE,SAVE :: toplwad0_aerop(:), sollwad0_aerop(:)
    300 !$OMP THREADPRIVATE(toplwad0_aerop, sollwad0_aerop)
    301 
    302 !AI 08 2023 ajout pour Ecrad
    303       REAL,ALLOCATABLE,SAVE :: topswad_aero_s2(:), solswad_aero_s2(:)
    304 !$OMP THREADPRIVATE(topswad_aero_s2, solswad_aero_s2)
    305       REAL,ALLOCATABLE,SAVE :: topswai_aero_s2(:), solswai_aero_s2(:)
    306 !$OMP THREADPRIVATE(topswai_aero_s2, solswai_aero_s2)
    307       REAL,ALLOCATABLE,SAVE :: topswad0_aero_s2(:), solswad0_aero_s2(:)
    308 !$OMP THREADPRIVATE(topswad0_aero_s2, solswad0_aero_s2)
    309       REAL,ALLOCATABLE,SAVE :: topsw_aero_s2(:,:), topsw0_aero_s2(:,:)
    310 !$OMP THREADPRIVATE(topsw_aero_s2, topsw0_aero_s2)
    311       REAL,ALLOCATABLE,SAVE :: solsw_aero_s2(:,:), solsw0_aero_s2(:,:)
    312 !$OMP THREADPRIVATE(solsw_aero_s2, solsw0_aero_s2)
    313       REAL,ALLOCATABLE,SAVE :: topswcf_aero_s2(:,:), solswcf_aero_s2(:,:)
    314 !$OMP THREADPRIVATE(topswcf_aero_s2, solswcf_aero_s2)
    315 ! additional LW variables CK
    316       REAL,ALLOCATABLE,SAVE :: toplwad_aero_s2(:), sollwad_aero_s2(:)
    317 !$OMP THREADPRIVATE(toplwad_aero_s2, sollwad_aero_s2)
    318       REAL,ALLOCATABLE,SAVE :: toplwai_aero_s2(:), sollwai_aero_s2(:)
    319 !$OMP THREADPRIVATE(toplwai_aero_s2, sollwai_aero_s2)
    320       REAL,ALLOCATABLE,SAVE :: toplwad0_aero_s2(:), sollwad0_aero_s2(:)
    321 !$OMP THREADPRIVATE(toplwad0_aero_s2, sollwad0_aero_s2)
    322 
    323 !Ajout de celles n??cessaires au phys_output_write_mod
    324       REAL, SAVE, ALLOCATABLE :: tal1(:), pal1(:), pab1(:), pab2(:)
    325 !$OMP THREADPRIVATE(tal1, pal1, pab1, pab2)
    326       REAL, SAVE, ALLOCATABLE :: ptstar(:), pt0(:), slp(:)
    327 !$OMP THREADPRIVATE(ptstar, pt0, slp)
    328       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: sens, flwp, fiwp
    329 !$OMP THREADPRIVATE(sens, flwp, fiwp)
    330 !!
    331 !FC
    332       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zxfluxt, zxfluxq
    333 !$OMP THREADPRIVATE(zxfluxt, zxfluxq)
    334 !FC
    335 !!         Wake variables
    336       REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: alp_wake
    337 !$OMP THREADPRIVATE(alp_wake)           
    338 !!jyg!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: wake_h,wake_k
    339       REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: wake_h
    340       INTEGER,ALLOCATABLE,SAVE,DIMENSION(:)        :: wake_k
    341 !$OMP THREADPRIVATE(wake_h,wake_k)                       
    342     REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)            :: wake_omg
    343 !$OMP THREADPRIVATE(wake_omg)                     
    344     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_wk, d_deltaq_wk
    345 !$OMP THREADPRIVATE(d_deltat_wk, d_deltaq_wk)
    346       REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: d_s_wk, d_dens_a_wk, d_dens_wk
    347 !$OMP THREADPRIVATE(d_s_wk, d_dens_a_wk, d_dens_wk)
    348     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_wk_gw, d_deltaq_wk_gw
    349 !$OMP THREADPRIVATE(d_deltat_wk_gw, d_deltaq_wk_gw)
    350     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_vdf, d_deltaq_vdf
    351 !$OMP THREADPRIVATE(d_deltat_vdf, d_deltaq_vdf)
    352 !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_vdf, d_dens_vdf
    353 !!!$OMP THREADPRIVATE(d_s_vdf, d_dens_vdf)
    354     REAL, SAVE, ALLOCATABLE,DIMENSION(:,:)          :: d_deltat_the, d_deltaq_the
    355 !$OMP THREADPRIVATE(d_deltat_the, d_deltaq_the)
    356 !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_the, d_dens_the
    357 !!!$OMP THREADPRIVATE(d_s_the, d_dens_the)
    358       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)          :: d_deltat_ajs_cv, d_deltaq_ajs_cv
    359 !$OMP THREADPRIVATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)                       
     171  ! tendance du a la conersion Ec -> E thermique
     172  REAL, SAVE, ALLOCATABLE :: d_t_ec(:, :)
     173  !$OMP THREADPRIVATE(d_t_ec)
     174  REAL, SAVE, ALLOCATABLE :: d_ts(:, :), d_tr(:, :, :)
     175  !$OMP THREADPRIVATE(d_ts, d_tr)
     176
     177  ! aerosols
     178  REAL, SAVE, ALLOCATABLE :: m_allaer (:, :, :)
     179  !$OMP THREADPRIVATE(m_allaer)
     180  ! diagnostique pour le rayonnement
     181  REAL, SAVE, ALLOCATABLE :: topswad_aero(:), solswad_aero(:)      ! diag
     182  !$OMP THREADPRIVATE(topswad_aero,solswad_aero)
     183  REAL, SAVE, ALLOCATABLE :: topswai_aero(:), solswai_aero(:)      ! diag
     184  !$OMP THREADPRIVATE(topswai_aero,solswai_aero)
     185  REAL, SAVE, ALLOCATABLE :: topswad0_aero(:), solswad0_aero(:)     ! diag
     186  !$OMP THREADPRIVATE(topswad0_aero,solswad0_aero)
     187  REAL, SAVE, ALLOCATABLE :: topsw_aero(:, :), solsw_aero(:, :)      ! diag
     188  !$OMP THREADPRIVATE(topsw_aero,solsw_aero)
     189  REAL, SAVE, ALLOCATABLE :: topsw0_aero(:, :), solsw0_aero(:, :)     ! diag
     190  !$OMP THREADPRIVATE(topsw0_aero,solsw0_aero)
     191  REAL, SAVE, ALLOCATABLE :: topswcf_aero(:, :), solswcf_aero(:, :)  ! diag
     192  !$OMP THREADPRIVATE(topswcf_aero,solswcf_aero)
     193  ! LW radiation diagnostics CK
     194  REAL, SAVE, ALLOCATABLE :: toplwad_aero(:), sollwad_aero(:)      ! diag
     195  !$OMP THREADPRIVATE(toplwad_aero,sollwad_aero)
     196  REAL, SAVE, ALLOCATABLE :: toplwai_aero(:), sollwai_aero(:)      ! diag
     197  !$OMP THREADPRIVATE(toplwai_aero,sollwai_aero)
     198  REAL, SAVE, ALLOCATABLE :: toplwad0_aero(:), sollwad0_aero(:)     ! diag
     199  !$OMP THREADPRIVATE(toplwad0_aero,sollwad0_aero)
     200  ! Special RRTM
     201  REAL, SAVE, ALLOCATABLE :: ZLWFT0_i(:, :), ZSWFT0_i(:, :)      ! diag
     202  !$OMP THREADPRIVATE(ZLWFT0_i,ZSWFT0_i)
     203  REAL, SAVE, ALLOCATABLE :: ZFLDN0(:, :), ZFLUP0(:, :)      ! diag
     204  !$OMP THREADPRIVATE(ZFLDN0,ZFLUP0)
     205  REAL, SAVE, ALLOCATABLE :: ZFSDN0(:, :), ZFSUP0(:, :)      ! diag
     206  !$OMP THREADPRIVATE(ZFSDN0,ZFSUP0)
     207  !
     208  REAL, SAVE, ALLOCATABLE :: stratomask(:, :)
     209  !$OMP THREADPRIVATE(stratomask)
     210  REAL, SAVE, ALLOCATABLE :: tausum_aero(:, :, :)
     211  !$OMP THREADPRIVATE(tausum_aero)
     212  REAL, SAVE, ALLOCATABLE :: drytausum_aero(:, :)
     213  !$OMP THREADPRIVATE(drytausum_aero)
     214  REAL, SAVE, ALLOCATABLE :: tau3d_aero(:, :, :, :)
     215  !$OMP THREADPRIVATE(tau3d_aero)
     216  REAL, SAVE, ALLOCATABLE :: dNovrN(:)
     217  !$OMP THREADPRIVATE(dNovrN)
     218  REAL, SAVE, ALLOCATABLE :: zfice(:, :)
     219  !$OMP THREADPRIVATE(zfice)
     220  REAL, SAVE, ALLOCATABLE :: od443aer(:)
     221  !$OMP THREADPRIVATE(od443aer)
     222  REAL, SAVE, ALLOCATABLE :: od550aer(:)
     223  !$OMP THREADPRIVATE(od550aer)
     224  REAL, SAVE, ALLOCATABLE :: dryod550aer(:)
     225  !$OMP THREADPRIVATE(dryod550aer)
     226  REAL, SAVE, ALLOCATABLE :: abs550aer(:)
     227  !$OMP THREADPRIVATE(abs550aer)
     228  REAL, SAVE, ALLOCATABLE :: od865aer(:)
     229  !$OMP THREADPRIVATE(od865aer)
     230  REAL, SAVE, ALLOCATABLE :: ec550aer(:, :)
     231  !$OMP THREADPRIVATE(ec550aer)
     232  REAL, SAVE, ALLOCATABLE :: od550lt1aer(:)
     233  !$OMP THREADPRIVATE(od550lt1aer)
     234  REAL, SAVE, ALLOCATABLE :: sconcso4(:)
     235  !$OMP THREADPRIVATE(sconcso4)
     236  REAL, SAVE, ALLOCATABLE :: sconcno3(:)
     237  !$OMP THREADPRIVATE(sconcno3)
     238  REAL, SAVE, ALLOCATABLE :: sconcoa(:)
     239  !$OMP THREADPRIVATE(sconcoa)
     240  REAL, SAVE, ALLOCATABLE :: sconcbc(:)
     241  !$OMP THREADPRIVATE(sconcbc)
     242  REAL, SAVE, ALLOCATABLE :: sconcss(:)
     243  !$OMP THREADPRIVATE(sconcss)
     244  REAL, SAVE, ALLOCATABLE :: sconcdust(:)
     245  !$OMP THREADPRIVATE(sconcdust)
     246  REAL, SAVE, ALLOCATABLE :: concso4(:, :)
     247  !$OMP THREADPRIVATE(concso4)
     248  REAL, SAVE, ALLOCATABLE :: concno3(:, :)
     249  !$OMP THREADPRIVATE(concno3)
     250  REAL, SAVE, ALLOCATABLE :: concoa(:, :)
     251  !$OMP THREADPRIVATE(concoa)
     252  REAL, SAVE, ALLOCATABLE :: concbc(:, :)
     253  !$OMP THREADPRIVATE(concbc)
     254  REAL, SAVE, ALLOCATABLE :: concss(:, :)
     255  !$OMP THREADPRIVATE(concss)
     256  REAL, SAVE, ALLOCATABLE :: concdust(:, :)
     257  !$OMP THREADPRIVATE(concdust)
     258  REAL, SAVE, ALLOCATABLE :: loadso4(:)
     259  !$OMP THREADPRIVATE(loadso4)
     260  REAL, SAVE, ALLOCATABLE :: loadoa(:)
     261  !$OMP THREADPRIVATE(loadoa)
     262  REAL, SAVE, ALLOCATABLE :: loadbc(:)
     263  !$OMP THREADPRIVATE(loadbc)
     264  REAL, SAVE, ALLOCATABLE :: loadss(:)
     265  !$OMP THREADPRIVATE(loadss)
     266  REAL, SAVE, ALLOCATABLE :: loaddust(:)
     267  !$OMP THREADPRIVATE(loaddust)
     268  REAL, SAVE, ALLOCATABLE :: loadno3(:)
     269  !$OMP THREADPRIVATE(loadno3)
     270  REAL, SAVE, ALLOCATABLE :: load_tmp1(:), load_tmp2(:)
     271  !$OMP THREADPRIVATE(load_tmp1, load_tmp2)
     272  REAL, SAVE, ALLOCATABLE :: load_tmp3(:), load_tmp4(:)
     273  !$OMP THREADPRIVATE(load_tmp3, load_tmp4)
     274  REAL, SAVE, ALLOCATABLE :: load_tmp5(:), load_tmp6(:)
     275  !$OMP THREADPRIVATE(load_tmp5, load_tmp6)
     276  REAL, SAVE, ALLOCATABLE :: load_tmp7(:), load_tmp8(:)
     277  !$OMP THREADPRIVATE(load_tmp7, load_tmp8)
     278  REAL, SAVE, ALLOCATABLE :: load_tmp9(:), load_tmp10(:)
     279  !$OMP THREADPRIVATE(load_tmp9, load_tmp10)
     280
     281  !IM ajout variables CFMIP2/CMIP5
     282  REAL, ALLOCATABLE, SAVE :: topswad_aerop(:), solswad_aerop(:)
     283  !$OMP THREADPRIVATE(topswad_aerop, solswad_aerop)
     284  REAL, ALLOCATABLE, SAVE :: topswai_aerop(:), solswai_aerop(:)
     285  !$OMP THREADPRIVATE(topswai_aerop, solswai_aerop)
     286  REAL, ALLOCATABLE, SAVE :: topswad0_aerop(:), solswad0_aerop(:)
     287  !$OMP THREADPRIVATE(topswad0_aerop, solswad0_aerop)
     288  REAL, ALLOCATABLE, SAVE :: topsw_aerop(:, :), topsw0_aerop(:, :)
     289  !$OMP THREADPRIVATE(topsw_aerop, topsw0_aerop)
     290  REAL, ALLOCATABLE, SAVE :: solsw_aerop(:, :), solsw0_aerop(:, :)
     291  !$OMP THREADPRIVATE(solsw_aerop, solsw0_aerop)
     292  REAL, ALLOCATABLE, SAVE :: topswcf_aerop(:, :), solswcf_aerop(:, :)
     293  !$OMP THREADPRIVATE(topswcf_aerop, solswcf_aerop)
     294
     295  ! additional LW variables CK
     296  REAL, ALLOCATABLE, SAVE :: toplwad_aerop(:), sollwad_aerop(:)
     297  !$OMP THREADPRIVATE(toplwad_aerop, sollwad_aerop)
     298  REAL, ALLOCATABLE, SAVE :: toplwai_aerop(:), sollwai_aerop(:)
     299  !$OMP THREADPRIVATE(toplwai_aerop, sollwai_aerop)
     300  REAL, ALLOCATABLE, SAVE :: toplwad0_aerop(:), sollwad0_aerop(:)
     301  !$OMP THREADPRIVATE(toplwad0_aerop, sollwad0_aerop)
     302
     303  !AI 08 2023 ajout pour Ecrad
     304  REAL, ALLOCATABLE, SAVE :: topswad_aero_s2(:), solswad_aero_s2(:)
     305  !$OMP THREADPRIVATE(topswad_aero_s2, solswad_aero_s2)
     306  REAL, ALLOCATABLE, SAVE :: topswai_aero_s2(:), solswai_aero_s2(:)
     307  !$OMP THREADPRIVATE(topswai_aero_s2, solswai_aero_s2)
     308  REAL, ALLOCATABLE, SAVE :: topswad0_aero_s2(:), solswad0_aero_s2(:)
     309  !$OMP THREADPRIVATE(topswad0_aero_s2, solswad0_aero_s2)
     310  REAL, ALLOCATABLE, SAVE :: topsw_aero_s2(:, :), topsw0_aero_s2(:, :)
     311  !$OMP THREADPRIVATE(topsw_aero_s2, topsw0_aero_s2)
     312  REAL, ALLOCATABLE, SAVE :: solsw_aero_s2(:, :), solsw0_aero_s2(:, :)
     313  !$OMP THREADPRIVATE(solsw_aero_s2, solsw0_aero_s2)
     314  REAL, ALLOCATABLE, SAVE :: topswcf_aero_s2(:, :), solswcf_aero_s2(:, :)
     315  !$OMP THREADPRIVATE(topswcf_aero_s2, solswcf_aero_s2)
     316  ! additional LW variables CK
     317  REAL, ALLOCATABLE, SAVE :: toplwad_aero_s2(:), sollwad_aero_s2(:)
     318  !$OMP THREADPRIVATE(toplwad_aero_s2, sollwad_aero_s2)
     319  REAL, ALLOCATABLE, SAVE :: toplwai_aero_s2(:), sollwai_aero_s2(:)
     320  !$OMP THREADPRIVATE(toplwai_aero_s2, sollwai_aero_s2)
     321  REAL, ALLOCATABLE, SAVE :: toplwad0_aero_s2(:), sollwad0_aero_s2(:)
     322  !$OMP THREADPRIVATE(toplwad0_aero_s2, sollwad0_aero_s2)
     323
     324  !Ajout de celles n??cessaires au phys_output_write_mod
     325  REAL, SAVE, ALLOCATABLE :: tal1(:), pal1(:), pab1(:), pab2(:)
     326  !$OMP THREADPRIVATE(tal1, pal1, pab1, pab2)
     327  REAL, SAVE, ALLOCATABLE :: ptstar(:), pt0(:), slp(:)
     328  !$OMP THREADPRIVATE(ptstar, pt0, slp)
     329  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sens, flwp, fiwp
     330  !$OMP THREADPRIVATE(sens, flwp, fiwp)
     331  !!
     332  !FC
     333  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: zxfluxt, zxfluxq
     334  !$OMP THREADPRIVATE(zxfluxt, zxfluxq)
     335  !FC
     336  !!         Wake variables
     337  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_wake
     338  !$OMP THREADPRIVATE(alp_wake)
     339  !!jyg!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)            :: wake_h,wake_k
     340  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: wake_h
     341  INTEGER, ALLOCATABLE, SAVE, DIMENSION(:) :: wake_k
     342  !$OMP THREADPRIVATE(wake_h,wake_k)
     343  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wake_omg
     344  !$OMP THREADPRIVATE(wake_omg)
     345  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_wk, d_deltaq_wk
     346  !$OMP THREADPRIVATE(d_deltat_wk, d_deltaq_wk)
     347  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: d_s_wk, d_dens_a_wk, d_dens_wk
     348  !$OMP THREADPRIVATE(d_s_wk, d_dens_a_wk, d_dens_wk)
     349  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_wk_gw, d_deltaq_wk_gw
     350  !$OMP THREADPRIVATE(d_deltat_wk_gw, d_deltaq_wk_gw)
     351  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_vdf, d_deltaq_vdf
     352  !$OMP THREADPRIVATE(d_deltat_vdf, d_deltaq_vdf)
     353  !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_vdf, d_dens_vdf
     354  !!!$OMP THREADPRIVATE(d_s_vdf, d_dens_vdf)
     355  REAL, SAVE, ALLOCATABLE, DIMENSION(:, :) :: d_deltat_the, d_deltaq_the
     356  !$OMP THREADPRIVATE(d_deltat_the, d_deltaq_the)
     357  !!!      REAL,ALLOCATABLE,SAVE,DIMENSION(:)          :: d_s_the, d_dens_the
     358  !!!$OMP THREADPRIVATE(d_s_the, d_dens_the)
     359  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: d_deltat_ajs_cv, d_deltaq_ajs_cv
     360  !$OMP THREADPRIVATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
    360361#ifdef ISO
    361362    REAL, SAVE, ALLOCATABLE,DIMENSION(:,:,:)          :: d_deltaxt_wk
     
    370371!$OMP THREADPRIVATE(d_deltaxt_ajs_cv)
    371372#endif                       
    372 !!         End of Wake variables
    373 !!
    374       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: bils
    375 !$OMP THREADPRIVATE(bils)
    376       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragm, cdragh
    377 !$OMP THREADPRIVATE(cdragm, cdragh)
    378       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cldh, cldl, cldm, cldq, cldt, qsat2m
    379 !$OMP THREADPRIVATE(cldh, cldl, cldm, cldq, cldt, qsat2m)
    380 !AS: cldhjn, cldljn, cldmjn,cldtjn pas utilisés en tant que variables, juste noms de diagnostics
    381       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: JrNt
    382 !$OMP THREADPRIVATE(JrNt)
    383       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget
    384 !$OMP THREADPRIVATE(dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget)
    385       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zustar, zu10m, zv10m, rh2m
    386 !$OMP THREADPRIVATE(zustar, zu10m, zv10m, rh2m)
    387       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_lcl, s_pblh, s_pblt, s_therm
    388 !$OMP THREADPRIVATE(s_lcl, s_pblh, s_pblt, s_therm)
    389 !
    390 !nrlmd+jyg<
    391       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_pblh_x, s_pblh_w
    392 !$OMP THREADPRIVATE(s_pblh_x, s_pblh_w)
    393       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_lcl_x, s_lcl_w
    394 !$OMP THREADPRIVATE(s_lcl_x, s_lcl_w)
    395 !>nrlmd+jyg
    396 !
    397       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: slab_wfbils
    398 !$OMP THREADPRIVATE(slab_wfbils)
    399       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte
    400 !$OMP THREADPRIVATE(tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte)
    401       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxustartlic, zxrhoslic, zxqsaltlic
    402 !$OMP THREADPRIVATE(zxustartlic, zxrhoslic, zxqsaltlic)
    403       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfqcalving
    404 !$OMP THREADPRIVATE(zxfqcalving)
    405       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfluxlat, zxtsol, snow_lsc, zxfqfonte
    406 !$OMP THREADPRIVATE(zxfluxlat, zxtsol, snow_lsc, zxfqfonte)
    407       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxrunofflic
    408 !$OMP THREADPRIVATE(zxrunofflic)
    409       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxqsurf, rain_lsc, rain_num
    410 !$OMP THREADPRIVATE(zxqsurf, rain_lsc, rain_num)
     373  !!         End of Wake variables
     374  !!
     375  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: bils
     376  !$OMP THREADPRIVATE(bils)
     377  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cdragm, cdragh
     378  !$OMP THREADPRIVATE(cdragm, cdragh)
     379  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cldh, cldl, cldm, cldq, cldt, qsat2m
     380  !$OMP THREADPRIVATE(cldh, cldl, cldm, cldq, cldt, qsat2m)
     381  !AS: cldhjn, cldljn, cldmjn,cldtjn pas utilisés en tant que variables, juste noms de diagnostics
     382  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: JrNt
     383  !$OMP THREADPRIVATE(JrNt)
     384  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget
     385  !$OMP THREADPRIVATE(dthmin, evap, snowerosion, fder, plcl, plfc, prw, prlw, prsw, prbsw, water_budget)
     386  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zustar, zu10m, zv10m, rh2m
     387  !$OMP THREADPRIVATE(zustar, zu10m, zv10m, rh2m)
     388  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: s_lcl, s_pblh, s_pblt, s_therm
     389  !$OMP THREADPRIVATE(s_lcl, s_pblh, s_pblt, s_therm)
     390  !
     391  !nrlmd+jyg<
     392  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: s_pblh_x, s_pblh_w
     393  !$OMP THREADPRIVATE(s_pblh_x, s_pblh_w)
     394  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: s_lcl_x, s_lcl_w
     395  !$OMP THREADPRIVATE(s_lcl_x, s_lcl_w)
     396  !>nrlmd+jyg
     397  !
     398  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: slab_wfbils
     399  !$OMP THREADPRIVATE(slab_wfbils)
     400  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte
     401  !$OMP THREADPRIVATE(tpot, tpote, ue, uq, uwat, ve, vq, vwat, zxffonte)
     402  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxustartlic, zxrhoslic, zxqsaltlic
     403  !$OMP THREADPRIVATE(zxustartlic, zxrhoslic, zxqsaltlic)
     404  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfqcalving
     405  !$OMP THREADPRIVATE(zxfqcalving)
     406  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfluxlat, zxtsol, snow_lsc, zxfqfonte
     407  !$OMP THREADPRIVATE(zxfluxlat, zxtsol, snow_lsc, zxfqfonte)
     408  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxrunofflic
     409  !$OMP THREADPRIVATE(zxrunofflic)
     410  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxqsurf, rain_lsc, rain_num
     411  !$OMP THREADPRIVATE(zxqsurf, rain_lsc, rain_num)
    411412#ifdef ISO
    412413      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: xtevap,xtprw
     
    424425!$OMP THREADPRIVATE(xtrain_lsc)
    425426#endif
    426 !
    427 !jyg+nrlmd<
    428 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    429 !                                                                          c
    430 !       Declarations liees a la couche limite differentiee w-x             c
    431 !                                                                          c
    432 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    433       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: sens_x, sens_w
    434 !$OMP THREADPRIVATE(sens_x, sens_w)
    435       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfluxlat_x, zxfluxlat_w
    436 !$OMP THREADPRIVATE(zxfluxlat_x, zxfluxlat_w)
    437       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: delta_qsurf
    438 !$OMP THREADPRIVATE(delta_qsurf)
    439 !jyg<
    440 !!! Entrees supplementaires couche-limite
    441 !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: t_x, t_w
    442 !!!$OMP THREADPRIVATE(t_x, t_w)
    443 !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: q_x, q_w
    444 !!!$OMP THREADPRIVATE(q_x, q_w)
    445 !>jyg
    446 !!! Sorties ferret
    447       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dtvdf_x, dtvdf_w
    448 !$OMP THREADPRIVATE(dtvdf_x, dtvdf_w)
    449       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dqvdf_x, dqvdf_w
    450 !$OMP THREADPRIVATE(dqvdf_x, dqvdf_w)
    451 ! Variables supplementaires dans physiq.F relative au splitting de la surface
    452       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: pbl_tke_input
    453 !$OMP THREADPRIVATE(pbl_tke_input)
    454 ! Entree supplementaire Thermiques :
    455       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: t_therm, q_therm, u_therm, v_therm
    456 !$OMP THREADPRIVATE(t_therm, q_therm, u_therm, v_therm)
    457       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragh_x, cdragh_w
    458 !$OMP THREADPRIVATE(cdragh_x, cdragh_w)
    459       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragm_x, cdragm_w
    460 !$OMP THREADPRIVATE(cdragm_x, cdragm_w)
    461       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: kh, kh_x, kh_w
    462 !$OMP THREADPRIVATE(kh, kh_x, kh_w)
     427  !
     428  !jyg+nrlmd<
     429  !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     430  !                                                                          c
     431  !       Declarations liees a la couche limite differentiee w-x             c
     432  !                                                                          c
     433  !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     434  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sens_x, sens_w
     435  !$OMP THREADPRIVATE(sens_x, sens_w)
     436  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxfluxlat_x, zxfluxlat_w
     437  !$OMP THREADPRIVATE(zxfluxlat_x, zxfluxlat_w)
     438  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: delta_qsurf
     439  !$OMP THREADPRIVATE(delta_qsurf)
     440  !jyg<
     441  !!! Entrees supplementaires couche-limite
     442  !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: t_x, t_w
     443  !!!$OMP THREADPRIVATE(t_x, t_w)
     444  !!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: q_x, q_w
     445  !!!$OMP THREADPRIVATE(q_x, q_w)
     446  !>jyg
     447  !!! Sorties ferret
     448  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dtvdf_x, dtvdf_w
     449  !$OMP THREADPRIVATE(dtvdf_x, dtvdf_w)
     450  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dqvdf_x, dqvdf_w
     451  !$OMP THREADPRIVATE(dqvdf_x, dqvdf_w)
     452  ! Variables supplementaires dans physiq.F relative au splitting de la surface
     453  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: pbl_tke_input
     454  !$OMP THREADPRIVATE(pbl_tke_input)
     455  ! Entree supplementaire Thermiques :
     456  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: t_therm, q_therm, u_therm, v_therm
     457  !$OMP THREADPRIVATE(t_therm, q_therm, u_therm, v_therm)
     458  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cdragh_x, cdragh_w
     459  !$OMP THREADPRIVATE(cdragh_x, cdragh_w)
     460  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: cdragm_x, cdragm_w
     461  !$OMP THREADPRIVATE(cdragm_x, cdragm_w)
     462  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: kh, kh_x, kh_w
     463  !$OMP THREADPRIVATE(kh, kh_x, kh_w)
    463464#ifdef ISO
    464465      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: dxtvdf_x, dxtvdf_w
     
    467468!$OMP THREADPRIVATE(xt_therm)
    468469#endif
    469 !!!
    470 !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
    471       LOGICAL, SAVE, ALLOCATABLE :: ptconv(:,:)
    472       !$OMP THREADPRIVATE(ptconv)
    473       REAL, SAVE, ALLOCATABLE :: ratqsc(:,:)
    474       !$OMP THREADPRIVATE(ratqsc)
    475 !>jyg+nrlmd
     470  !!!
     471  !!!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
     472  LOGICAL, SAVE, ALLOCATABLE :: ptconv(:, :)
     473  !$OMP THREADPRIVATE(ptconv)
     474  REAL, SAVE, ALLOCATABLE :: ratqsc(:, :)
     475  !$OMP THREADPRIVATE(ratqsc)
     476  !>jyg+nrlmd
    476477  !
    477       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: wbeff, convoccur, zmax_th, zq2m, zt2m
    478 !$OMP THREADPRIVATE(wbeff, convoccur, zmax_th, zq2m, zt2m)
    479       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zt2m_min_mon, zt2m_max_mon
    480 !$OMP THREADPRIVATE(zt2m_min_mon, zt2m_max_mon)
    481       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: t2m_min_mon, t2m_max_mon
    482 !$OMP THREADPRIVATE(t2m_min_mon, t2m_max_mon)
    483       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: weak_inversion
    484 !$OMP THREADPRIVATE(weak_inversion)
    485       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_conv,alp_bl_det
    486 !$OMP THREADPRIVATE(alp_bl_conv,alp_bl_det)
    487       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_fluct_m,alp_bl_fluct_tke
    488 !$OMP THREADPRIVATE(alp_bl_fluct_m,alp_bl_fluct_tke)
    489       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_stat, n2, s2, strig, zcong, zlcl_th
    490 !$OMP THREADPRIVATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
    491       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: proba_notrig, random_notrig
    492 !$OMP THREADPRIVATE(proba_notrig, random_notrig)
    493       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: fsolsw, wfbils
    494 !$OMP THREADPRIVATE(fsolsw, wfbils)
    495       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wfevap
    496 !$OMP THREADPRIVATE(wfevap)
    497       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: t2m, fluxlat, fsollw,evap_pot
    498 !$OMP THREADPRIVATE(t2m, fluxlat, fsollw,evap_pot)
    499       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dnwd0, omega
    500 !$OMP THREADPRIVATE(dnwd0, omega)
    501       REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: epmax_diag ! epmax_cape
    502 !$OMP THREADPRIVATE(epmax_diag)
    503 !
    504 !  Deep convective variables used in phytrac
    505       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ep ! epmax_cape
    506 !$OMP THREADPRIVATE(ep)
    507       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dnwd, upwd
    508 !$OMP THREADPRIVATE(dnwd, upwd)
    509       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: pmflxr, pmflxs
    510 !$OMP THREADPRIVATE(pmflxr, pmflxs)
    511       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wdtrainA, wdtrainS, wdtrainM
    512 !$OMP THREADPRIVATE(wdtrainA, wdtrainS, wdtrainM)
    513       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: da, mp
    514 !$OMP THREADPRIVATE(da, mp)
    515       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wght_cvfd
    516 !$OMP THREADPRIVATE(wght_cvfd)
    517       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:):: phi, phi2, elij, epmlmMm
    518 !$OMP THREADPRIVATE(phi, phi2, elij, epmlmMm)
    519       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: d1a, dam
    520 !$OMP THREADPRIVATE(d1a, dam)
    521       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ev
    522 !$OMP THREADPRIVATE(ev)
    523       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: qtaa
    524 !$OMP THREADPRIVATE(qtaa)
    525       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: clw
    526 !$OMP THREADPRIVATE(clw)
    527       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: eplaMm
    528 !$OMP THREADPRIVATE(eplaMm)
    529       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:):: sij
    530 !$OMP THREADPRIVATE(sij)
     478  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: wbeff, convoccur, zmax_th, zq2m, zt2m
     479  !$OMP THREADPRIVATE(wbeff, convoccur, zmax_th, zq2m, zt2m)
     480  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zt2m_min_mon, zt2m_max_mon
     481  !$OMP THREADPRIVATE(zt2m_min_mon, zt2m_max_mon)
     482  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: t2m_min_mon, t2m_max_mon
     483  !$OMP THREADPRIVATE(t2m_min_mon, t2m_max_mon)
     484  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: weak_inversion
     485  !$OMP THREADPRIVATE(weak_inversion)
     486  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_bl_conv, alp_bl_det
     487  !$OMP THREADPRIVATE(alp_bl_conv,alp_bl_det)
     488  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_bl_fluct_m, alp_bl_fluct_tke
     489  !$OMP THREADPRIVATE(alp_bl_fluct_m,alp_bl_fluct_tke)
     490  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: alp_bl_stat, n2, s2, strig, zcong, zlcl_th
     491  !$OMP THREADPRIVATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
     492  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: proba_notrig, random_notrig
     493  !$OMP THREADPRIVATE(proba_notrig, random_notrig)
     494  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: fsolsw, wfbils
     495  !$OMP THREADPRIVATE(fsolsw, wfbils)
     496  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wfevap
     497  !$OMP THREADPRIVATE(wfevap)
     498  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: t2m, fluxlat, fsollw, evap_pot
     499  !$OMP THREADPRIVATE(t2m, fluxlat, fsollw,evap_pot)
     500  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dnwd0, omega
     501  !$OMP THREADPRIVATE(dnwd0, omega)
     502  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: epmax_diag ! epmax_cape
     503  !$OMP THREADPRIVATE(epmax_diag)
     504  !
     505  !  Deep convective variables used in phytrac
     506  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ep ! epmax_cape
     507  !$OMP THREADPRIVATE(ep)
     508  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: dnwd, upwd
     509  !$OMP THREADPRIVATE(dnwd, upwd)
     510  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: pmflxr, pmflxs
     511  !$OMP THREADPRIVATE(pmflxr, pmflxs)
     512  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wdtrainA, wdtrainS, wdtrainM
     513  !$OMP THREADPRIVATE(wdtrainA, wdtrainS, wdtrainM)
     514  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: da, mp
     515  !$OMP THREADPRIVATE(da, mp)
     516  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: wght_cvfd
     517  !$OMP THREADPRIVATE(wght_cvfd)
     518  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: phi, phi2, elij, epmlmMm
     519  !$OMP THREADPRIVATE(phi, phi2, elij, epmlmMm)
     520  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: d1a, dam
     521  !$OMP THREADPRIVATE(d1a, dam)
     522  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ev
     523  !$OMP THREADPRIVATE(ev)
     524  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: qtaa
     525  !$OMP THREADPRIVATE(qtaa)
     526  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: clw
     527  !$OMP THREADPRIVATE(clw)
     528  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: eplaMm
     529  !$OMP THREADPRIVATE(eplaMm)
     530  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: sij
     531  !$OMP THREADPRIVATE(sij)
    531532#ifdef ISO
    532533      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:)  :: xtwdtrainA
     
    575576#endif
    576577#endif
    577 !
    578 !      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: coefh, coefm, lambda_th
    579       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: lambda_th
    580 !$OMP THREADPRIVATE(lambda_th)
    581       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: cldemi, cldfra, cldtau, fiwc, fl, re, flwc
    582 !$OMP THREADPRIVATE(cldemi, cldfra, cldtau, fiwc, fl, re, flwc)
    583       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: qlth, qith, qsith, wiceth
    584 !$OMP THREADPRIVATE(qlth, qith, qsith, wiceth)
    585       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ref_liq, ref_ice, theta, zphi
    586 !$OMP THREADPRIVATE(ref_liq, ref_ice, theta, zphi)
    587       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ref_liq_pi, ref_ice_pi
    588 !$OMP THREADPRIVATE(ref_liq_pi, ref_ice_pi)
    589       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zx_rh, zx_rhl, zx_rhi
    590 !$OMP THREADPRIVATE(zx_rh, zx_rhl, zx_rhi)
    591       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: prfl, psfl, fraca, bsfl
    592 !$OMP THREADPRIVATE(prfl, psfl, fraca, bsfl)
    593       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: Vprecip, zw2
    594 !$OMP THREADPRIVATE(Vprecip, zw2)
    595       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: pmfd, pmfu
    596 !$OMP THREADPRIVATE(pmfd, pmfu)
    597       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: fluxt, fluxu, fluxv
    598 !$OMP THREADPRIVATE(fluxt, fluxu, fluxv)
    599       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: uwriteSTD, vwriteSTD, wwriteSTD
    600 !$OMP THREADPRIVATE(uwriteSTD, vwriteSTD, wwriteSTD)
    601       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD
    602 !$OMP THREADPRIVATE(phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD)
    603 
    604 
    605 ! ug et d'autres encore:
    606       REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: beta_prec
    607 !$OMP THREADPRIVATE(beta_prec)
    608       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: rneb,rnebjn,rneblsvol
    609 !$OMP THREADPRIVATE(rneb,rnebjn,rneblsvol)
    610       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: pfraclr,pfracld
    611 !$OMP THREADPRIVATE(pfraclr,pfracld)
    612       REAL, SAVE, ALLOCATABLE :: cldfraliq(:,:)
    613 !$OMP THREADPRIVATE(cldfraliq)
    614       REAL, SAVE, ALLOCATABLE ::mean_icefracturb(:,:)
    615 !$OMP THREADPRIVATE(mean_icefracturb)
    616       REAL, SAVE, ALLOCATABLE :: sigma2_icefracturb(:,:)
    617 !$OMP THREADPRIVATE(sigma2_icefracturb)
    618 
    619 ! variables de sorties MM
    620       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxsnow,snowhgt,qsnow,to_ice
    621       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sissnow,runoff,albsol3_lic
    622 !$OMP THREADPRIVATE(zxsnow,snowhgt,qsnow,to_ice)
    623 !$OMP THREADPRIVATE(sissnow,runoff,albsol3_lic)
     578  !
     579  !      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: coefh, coefm, lambda_th
     580  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: lambda_th
     581  !$OMP THREADPRIVATE(lambda_th)
     582  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: cldemi, cldfra, cldtau, fiwc, fl, re, flwc
     583  !$OMP THREADPRIVATE(cldemi, cldfra, cldtau, fiwc, fl, re, flwc)
     584  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: qlth, qith, qsith, wiceth
     585  !$OMP THREADPRIVATE(qlth, qith, qsith, wiceth)
     586  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ref_liq, ref_ice, theta, zphi
     587  !$OMP THREADPRIVATE(ref_liq, ref_ice, theta, zphi)
     588  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: ref_liq_pi, ref_ice_pi
     589  !$OMP THREADPRIVATE(ref_liq_pi, ref_ice_pi)
     590  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: zx_rh, zx_rhl, zx_rhi
     591  !$OMP THREADPRIVATE(zx_rh, zx_rhl, zx_rhi)
     592  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: prfl, psfl, fraca, bsfl
     593  !$OMP THREADPRIVATE(prfl, psfl, fraca, bsfl)
     594  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: Vprecip, zw2
     595  !$OMP THREADPRIVATE(Vprecip, zw2)
     596  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: pmfd, pmfu
     597  !$OMP THREADPRIVATE(pmfd, pmfu)
     598  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: fluxt, fluxu, fluxv
     599  !$OMP THREADPRIVATE(fluxt, fluxu, fluxv)
     600  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: uwriteSTD, vwriteSTD, wwriteSTD
     601  !$OMP THREADPRIVATE(uwriteSTD, vwriteSTD, wwriteSTD)
     602  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD
     603  !$OMP THREADPRIVATE(phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD)
     604
     605
     606  ! ug et d'autres encore:
     607  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: beta_prec
     608  !$OMP THREADPRIVATE(beta_prec)
     609  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: rneb, rnebjn, rneblsvol
     610  !$OMP THREADPRIVATE(rneb,rnebjn,rneblsvol)
     611  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: pfraclr, pfracld
     612  !$OMP THREADPRIVATE(pfraclr,pfracld)
     613  REAL, SAVE, ALLOCATABLE :: cldfraliq(:, :)
     614  !$OMP THREADPRIVATE(cldfraliq)
     615  REAL, SAVE, ALLOCATABLE :: mean_icefracturb(:, :)
     616  !$OMP THREADPRIVATE(mean_icefracturb)
     617  REAL, SAVE, ALLOCATABLE :: sigma2_icefracturb(:, :)
     618  !$OMP THREADPRIVATE(sigma2_icefracturb)
     619
     620  ! variables de sorties MM
     621  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: zxsnow, snowhgt, qsnow, to_ice
     622  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: sissnow, runoff, albsol3_lic
     623  !$OMP THREADPRIVATE(zxsnow,snowhgt,qsnow,to_ice)
     624  !$OMP THREADPRIVATE(sissnow,runoff,albsol3_lic)
    624625#ifdef ISO
    625626      REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: zxxtsnow
     
    631632#endif
    632633
    633       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause, z_tropopause, t_tropopause
    634 !$OMP THREADPRIVATE(p_tropopause, z_tropopause, t_tropopause)
    635 
    636       INTEGER,ALLOCATABLE,SAVE,DIMENSION(:,:) :: zn2mout
    637 !$OMP THREADPRIVATE(zn2mout)
    638 
    639       REAL, SAVE, ALLOCATABLE :: qclr(:,:)
    640       !$OMP THREADPRIVATE(qclr)
    641       REAL, SAVE, ALLOCATABLE :: qcld(:,:)
    642       !$OMP THREADPRIVATE(qcld)
    643       REAL, SAVE, ALLOCATABLE :: qss(:,:)
    644       !$OMP THREADPRIVATE(qss)
    645       REAL, SAVE, ALLOCATABLE :: qvc(:,:)
    646       !$OMP THREADPRIVATE(qvc)
    647       REAL, SAVE, ALLOCATABLE :: rnebclr(:,:)
    648       !$OMP THREADPRIVATE(rnebclr)
    649       REAL, SAVE, ALLOCATABLE :: rnebss(:,:)
    650       !$OMP THREADPRIVATE(rnebss)
    651       REAL, SAVE, ALLOCATABLE :: gamma_ss(:,:)
    652       !$OMP THREADPRIVATE(gamma_ss)
    653       REAL, SAVE, ALLOCATABLE :: N1_ss(:,:)
    654       !$OMP THREADPRIVATE(N1_ss)
    655       REAL, SAVE, ALLOCATABLE :: N2_ss(:,:)
    656       !$OMP THREADPRIVATE(N2_ss)
    657       REAL, SAVE, ALLOCATABLE :: drneb_sub(:,:)
    658       !$OMP THREADPRIVATE(drneb_sub)
    659       REAL, SAVE, ALLOCATABLE :: drneb_con(:,:)
    660       !$OMP THREADPRIVATE(drneb_con)
    661       REAL, SAVE, ALLOCATABLE :: drneb_tur(:,:)
    662       !$OMP THREADPRIVATE(drneb_tur)
    663       REAL, SAVE, ALLOCATABLE :: drneb_avi(:,:)
    664       !$OMP THREADPRIVATE(drneb_avi)
    665       REAL, SAVE, ALLOCATABLE :: zqsatl(:,:)
    666       !$OMP THREADPRIVATE(zqsatl)
    667       REAL, SAVE, ALLOCATABLE :: zqsats(:,:)
    668       !$OMP THREADPRIVATE(zqsats)
    669       REAL, SAVE, ALLOCATABLE :: Tcontr(:,:)
    670       !$OMP THREADPRIVATE(Tcontr)
    671       REAL, SAVE, ALLOCATABLE :: qcontr(:,:)
    672       !$OMP THREADPRIVATE(qcontr)
    673       REAL, SAVE, ALLOCATABLE :: qcontr2(:,:)
    674       !$OMP THREADPRIVATE(qcontr2)
    675       REAL, SAVE, ALLOCATABLE :: fcontrN(:,:)
    676       !$OMP THREADPRIVATE(fcontrN)
    677       REAL, SAVE, ALLOCATABLE :: fcontrP(:,:)
    678       !$OMP THREADPRIVATE(fcontrP)
    679       REAL, SAVE, ALLOCATABLE :: distcltop(:,:)
    680       !$OMP THREADPRIVATE(distcltop)
    681       REAL, SAVE, ALLOCATABLE :: temp_cltop(:,:)
    682       !$OMP THREADPRIVATE(temp_cltop)
    683 
    684 
    685 !--POPRECIP variables
    686       REAL, SAVE, ALLOCATABLE :: qraindiag(:,:)
    687       !$OMP THREADPRIVATE(qraindiag)
    688       REAL, SAVE, ALLOCATABLE :: qsnowdiag(:,:)
    689       !$OMP THREADPRIVATE(qsnowdiag)
    690       REAL, SAVE, ALLOCATABLE :: dqreva(:,:)
    691       !$OMP THREADPRIVATE(dqreva)
    692       REAL, SAVE, ALLOCATABLE :: dqrauto(:,:)
    693       !$OMP THREADPRIVATE(dqrauto)
    694       REAL, SAVE, ALLOCATABLE :: dqrcol(:,:)
    695       !$OMP THREADPRIVATE(dqrcol)
    696       REAL, SAVE, ALLOCATABLE :: dqrmelt(:,:)
    697       !$OMP THREADPRIVATE(dqrmelt)
    698        REAL, SAVE, ALLOCATABLE :: dqrfreez(:,:)
    699       !$OMP THREADPRIVATE(dqrfreez)
    700       REAL, SAVE, ALLOCATABLE :: dqssub(:,:)
    701       !$OMP THREADPRIVATE(dqssub)
    702       REAL, SAVE, ALLOCATABLE :: dqsauto(:,:)
    703       !$OMP THREADPRIVATE(dqsauto)
    704       REAL, SAVE, ALLOCATABLE :: dqsagg(:,:)
    705       !$OMP THREADPRIVATE(dqsagg)
    706       REAL, SAVE, ALLOCATABLE :: dqsrim(:,:)
    707       !$OMP THREADPRIVATE(dqsrim)
    708       REAL, SAVE, ALLOCATABLE :: dqsmelt(:,:)
    709       !$OMP THREADPRIVATE(dqsmelt)
    710       REAL, SAVE, ALLOCATABLE :: dqsfreez(:,:)
    711       !$OMP THREADPRIVATE(dqsfreez)
    712 
    713 
    714      
    715 
    716 
    717 #ifdef CPP_StratAer
    718 !
    719 ! variables for stratospheric aerosol
    720       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: d_q_emiss
    721 !$OMP THREADPRIVATE(d_q_emiss)
    722       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: R2SO4
    723 !$OMP THREADPRIVATE(R2SO4)
    724       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: DENSO4
    725 !$OMP THREADPRIVATE(DENSO4)
    726       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: f_r_wet
    727 !$OMP THREADPRIVATE(f_r_wet)
    728       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: decfluxaer
    729 !$OMP THREADPRIVATE(decfluxaer)
    730       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: mdw
    731 !$OMP THREADPRIVATE(mdw)
    732       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: OCS_lifetime
    733 !$OMP THREADPRIVATE(OCS_lifetime)
    734       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: SO2_lifetime
    735 !$OMP THREADPRIVATE(SO2_lifetime)
    736       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: H2SO4_lifetime
    737 !$OMP THREADPRIVATE(H2SO4_lifetime)
    738       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: O3_clim
    739 !$OMP THREADPRIVATE(O3_clim)
    740       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: alpha_bin
    741 !$OMP THREADPRIVATE(alpha_bin)
    742       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: piz_bin
    743 !$OMP THREADPRIVATE(piz_bin)
    744       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: cg_bin
    745 !$OMP THREADPRIVATE(cg_bin)
    746       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tau_strat_550
    747 !$OMP THREADPRIVATE(tau_strat_550)
    748       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tau_strat_1020
    749 !$OMP THREADPRIVATE(tau_strat_1020)
    750       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: tausum_strat
    751 !$OMP THREADPRIVATE(tausum_strat)
    752       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: surf_PM25_sulf
    753 !$OMP THREADPRIVATE(surf_PM25_sulf)
    754       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: vsed_aer
    755 !$OMP THREADPRIVATE(vsed_aer)
    756 !
    757 !---3D budget variables
    758       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_nucl
    759 !$OMP THREADPRIVATE(budg_3D_nucl)
    760       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_cond_evap
    761 !$OMP THREADPRIVATE(budg_3D_cond_evap)
    762       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_ocs_to_so2
    763 !$OMP THREADPRIVATE(budg_3D_ocs_to_so2)
    764       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_so2_to_h2so4
    765 !$OMP THREADPRIVATE(budg_3D_so2_to_h2so4)
    766       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_backgr_ocs
    767 !$OMP THREADPRIVATE(budg_3D_backgr_ocs)
    768       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: budg_3D_backgr_so2
    769 !$OMP THREADPRIVATE(budg_3D_backgr_so2)
    770 !
    771 !---2D budget variables
    772       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_ocs
    773       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_so2
    774       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_h2so4
    775       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_part
    776 !$OMP THREADPRIVATE(budg_dep_dry_ocs,budg_dep_dry_so2,budg_dep_dry_h2so4,budg_dep_dry_part)
    777       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_ocs
    778       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_so2
    779       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_h2so4
    780       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_part
    781 !$OMP THREADPRIVATE(budg_dep_wet_ocs,budg_dep_wet_so2,budg_dep_wet_h2so4,budg_dep_wet_part)
    782       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_ocs
    783       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_so2
    784       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_h2so4
    785       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_part
    786 !$OMP THREADPRIVATE(budg_emi_ocs,budg_emi_so2,budg_emi_h2so4,budg_emi_part)
    787       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_ocs_to_so2
    788       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_so2_to_h2so4
    789       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_h2so4_to_part
    790 !$OMP THREADPRIVATE(budg_ocs_to_so2,budg_so2_to_h2so4,budg_h2so4_to_part)
    791       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_sed_part
    792 !$OMP THREADPRIVATE(budg_sed_part)
    793 #endif
     634  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause, z_tropopause, t_tropopause
     635  !$OMP THREADPRIVATE(p_tropopause, z_tropopause, t_tropopause)
     636
     637  INTEGER, ALLOCATABLE, SAVE, DIMENSION(:, :) :: zn2mout
     638  !$OMP THREADPRIVATE(zn2mout)
     639
     640  REAL, SAVE, ALLOCATABLE :: qclr(:, :)
     641  !$OMP THREADPRIVATE(qclr)
     642  REAL, SAVE, ALLOCATABLE :: qcld(:, :)
     643  !$OMP THREADPRIVATE(qcld)
     644  REAL, SAVE, ALLOCATABLE :: qss(:, :)
     645  !$OMP THREADPRIVATE(qss)
     646  REAL, SAVE, ALLOCATABLE :: qvc(:, :)
     647  !$OMP THREADPRIVATE(qvc)
     648  REAL, SAVE, ALLOCATABLE :: rnebclr(:, :)
     649  !$OMP THREADPRIVATE(rnebclr)
     650  REAL, SAVE, ALLOCATABLE :: rnebss(:, :)
     651  !$OMP THREADPRIVATE(rnebss)
     652  REAL, SAVE, ALLOCATABLE :: gamma_ss(:, :)
     653  !$OMP THREADPRIVATE(gamma_ss)
     654  REAL, SAVE, ALLOCATABLE :: N1_ss(:, :)
     655  !$OMP THREADPRIVATE(N1_ss)
     656  REAL, SAVE, ALLOCATABLE :: N2_ss(:, :)
     657  !$OMP THREADPRIVATE(N2_ss)
     658  REAL, SAVE, ALLOCATABLE :: drneb_sub(:, :)
     659  !$OMP THREADPRIVATE(drneb_sub)
     660  REAL, SAVE, ALLOCATABLE :: drneb_con(:, :)
     661  !$OMP THREADPRIVATE(drneb_con)
     662  REAL, SAVE, ALLOCATABLE :: drneb_tur(:, :)
     663  !$OMP THREADPRIVATE(drneb_tur)
     664  REAL, SAVE, ALLOCATABLE :: drneb_avi(:, :)
     665  !$OMP THREADPRIVATE(drneb_avi)
     666  REAL, SAVE, ALLOCATABLE :: zqsatl(:, :)
     667  !$OMP THREADPRIVATE(zqsatl)
     668  REAL, SAVE, ALLOCATABLE :: zqsats(:, :)
     669  !$OMP THREADPRIVATE(zqsats)
     670  REAL, SAVE, ALLOCATABLE :: Tcontr(:, :)
     671  !$OMP THREADPRIVATE(Tcontr)
     672  REAL, SAVE, ALLOCATABLE :: qcontr(:, :)
     673  !$OMP THREADPRIVATE(qcontr)
     674  REAL, SAVE, ALLOCATABLE :: qcontr2(:, :)
     675  !$OMP THREADPRIVATE(qcontr2)
     676  REAL, SAVE, ALLOCATABLE :: fcontrN(:, :)
     677  !$OMP THREADPRIVATE(fcontrN)
     678  REAL, SAVE, ALLOCATABLE :: fcontrP(:, :)
     679  !$OMP THREADPRIVATE(fcontrP)
     680  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :, :) :: DENSO4B
     681  !$OMP THREADPRIVATE(DENSO4B)
     682  REAL, SAVE, ALLOCATABLE :: distcltop(:, :)
     683  !$OMP THREADPRIVATE(distcltop)
     684  REAL, SAVE, ALLOCATABLE :: temp_cltop(:, :)
     685  !$OMP THREADPRIVATE(temp_cltop)
     686
     687
     688  !--POPRECIP variables
     689  REAL, SAVE, ALLOCATABLE :: qraindiag(:, :)
     690  !$OMP THREADPRIVATE(qraindiag)
     691  REAL, SAVE, ALLOCATABLE :: qsnowdiag(:, :)
     692  !$OMP THREADPRIVATE(qsnowdiag)
     693  REAL, SAVE, ALLOCATABLE :: dqreva(:, :)
     694  !$OMP THREADPRIVATE(dqreva)
     695  REAL, SAVE, ALLOCATABLE :: dqrauto(:, :)
     696  !$OMP THREADPRIVATE(dqrauto)
     697  REAL, SAVE, ALLOCATABLE :: dqrcol(:, :)
     698  !$OMP THREADPRIVATE(dqrcol)
     699  REAL, SAVE, ALLOCATABLE :: dqrmelt(:, :)
     700  !$OMP THREADPRIVATE(dqrmelt)
     701  REAL, SAVE, ALLOCATABLE :: dqrfreez(:, :)
     702  !$OMP THREADPRIVATE(dqrfreez)
     703  REAL, SAVE, ALLOCATABLE :: dqssub(:, :)
     704  !$OMP THREADPRIVATE(dqssub)
     705  REAL, SAVE, ALLOCATABLE :: dqsauto(:, :)
     706  !$OMP THREADPRIVATE(dqsauto)
     707  REAL, SAVE, ALLOCATABLE :: dqsagg(:, :)
     708  !$OMP THREADPRIVATE(dqsagg)
     709  REAL, SAVE, ALLOCATABLE :: dqsrim(:, :)
     710  !$OMP THREADPRIVATE(dqsrim)
     711  REAL, SAVE, ALLOCATABLE :: dqsmelt(:, :)
     712  !$OMP THREADPRIVATE(dqsmelt)
     713  REAL, SAVE, ALLOCATABLE :: dqsfreez(:, :)
     714  !$OMP THREADPRIVATE(dqsfreez)
     715
     716
     717
     718
     719
     720  !
     721  ! variables for stratospheric aerosol
     722  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: d_q_emiss
     723  !$OMP THREADPRIVATE(d_q_emiss)
     724  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: R2SO4
     725  !$OMP THREADPRIVATE(R2SO4)
     726  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: DENSO4
     727  !$OMP THREADPRIVATE(DENSO4)
     728  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: f_r_wet
     729  !$OMP THREADPRIVATE(f_r_wet)
     730  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: decfluxaer
     731  !$OMP THREADPRIVATE(decfluxaer)
     732  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: mdw
     733  !$OMP THREADPRIVATE(mdw)
     734  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: OCS_lifetime
     735  !$OMP THREADPRIVATE(OCS_lifetime)
     736  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: SO2_lifetime
     737  !$OMP THREADPRIVATE(SO2_lifetime)
     738  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: H2SO4_lifetime
     739  !$OMP THREADPRIVATE(H2SO4_lifetime)
     740  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: O3_clim
     741  !$OMP THREADPRIVATE(O3_clim)
     742  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: alpha_bin
     743  !$OMP THREADPRIVATE(alpha_bin)
     744  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: piz_bin
     745  !$OMP THREADPRIVATE(piz_bin)
     746  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: cg_bin
     747  !$OMP THREADPRIVATE(cg_bin)
     748  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: tau_strat_550
     749  !$OMP THREADPRIVATE(tau_strat_550)
     750  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: tau_strat_1020
     751  !$OMP THREADPRIVATE(tau_strat_1020)
     752  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: tausum_strat
     753  !$OMP THREADPRIVATE(tausum_strat)
     754  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: surf_PM25_sulf
     755  !$OMP THREADPRIVATE(surf_PM25_sulf)
     756  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: vsed_aer
     757  !$OMP THREADPRIVATE(vsed_aer)
     758  !
     759  !---3D budget variables
     760  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_nucl
     761  !$OMP THREADPRIVATE(budg_3D_nucl)
     762  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_cond_evap
     763  !$OMP THREADPRIVATE(budg_3D_cond_evap)
     764  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_ocs_to_so2
     765  !$OMP THREADPRIVATE(budg_3D_ocs_to_so2)
     766  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_so2_to_h2so4
     767  !$OMP THREADPRIVATE(budg_3D_so2_to_h2so4)
     768  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_backgr_ocs
     769  !$OMP THREADPRIVATE(budg_3D_backgr_ocs)
     770  REAL, ALLOCATABLE, SAVE, DIMENSION(:, :) :: budg_3D_backgr_so2
     771  !$OMP THREADPRIVATE(budg_3D_backgr_so2)
     772  !
     773  !---2D budget variables
     774  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_ocs
     775  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_so2
     776  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_h2so4
     777  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_dry_part
     778  !$OMP THREADPRIVATE(budg_dep_dry_ocs,budg_dep_dry_so2,budg_dep_dry_h2so4,budg_dep_dry_part)
     779  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_ocs
     780  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_so2
     781  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_h2so4
     782  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_dep_wet_part
     783  !$OMP THREADPRIVATE(budg_dep_wet_ocs,budg_dep_wet_so2,budg_dep_wet_h2so4,budg_dep_wet_part)
     784  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_ocs
     785  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_so2
     786  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_h2so4
     787  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_emi_part
     788  !$OMP THREADPRIVATE(budg_emi_ocs,budg_emi_so2,budg_emi_h2so4,budg_emi_part)
     789  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_ocs_to_so2
     790  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_so2_to_h2so4
     791  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_h2so4_to_part
     792  !$OMP THREADPRIVATE(budg_ocs_to_so2,budg_so2_to_h2so4,budg_h2so4_to_part)
     793  REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: budg_sed_part
     794  !$OMP THREADPRIVATE(budg_sed_part)
    794795#ifdef REPROBUS
    795796      REAL,SAVE,ALLOCATABLE    :: d_q_emiss(:,:)
     
    799800CONTAINS
    800801
    801 !======================================================================
    802 SUBROUTINE phys_local_var_init
    803 USE dimphy
    804 USE infotrac_phy, ONLY : nbtr,nqtot
     802  !======================================================================
     803  SUBROUTINE phys_local_var_init
     804    USE dimphy
     805    USE infotrac_phy, ONLY : nbtr, nqtot
    805806#ifdef ISO
    806807USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
    807808#endif
    808 USE aero_mod
    809 USE indice_sol_mod
    810 USE phys_output_var_mod
    811 USE phys_state_var_mod
    812 
    813 IMPLICIT NONE
    814       ALLOCATE(t_seri(klon,klev),q_seri(klon,klev),ql_seri(klon,klev),qs_seri(klon,klev), qbs_seri(klon,klev))
    815       ALLOCATE(qx_seri(klon,klev,nqtot))
    816       ALLOCATE(u_seri(klon,klev),v_seri(klon,klev))
    817       ALLOCATE(l_mixmin(klon,klev+1,nbsrf),l_mix(klon,klev+1,nbsrf),wprime(klon,klev+1,nbsrf))
    818       ALLOCATE(pbl_eps(klon,klev+1,nbsrf+1))
    819       ALLOCATE(tke_shear(klon,klev+1,nbsrf), tke_buoy(klon,klev+1,nbsrf), tke_trans(klon,klev+1,nbsrf))
    820       pbl_eps(:,:,:)=0.
    821       tke_shear(:,:,:)=0.; tke_buoy(:,:,:)=0.; tke_trans(:,:,:)=0.
    822       l_mix(:,:,:)=0.;l_mixmin(:,:,:)=0.;wprime(:,:,:)=0. ! doit etre initialse car pas toujours remplis
    823       ALLOCATE(rhcl(klon,klev))
    824       ALLOCATE(tr_seri(klon,klev,nbtr))
    825       ALLOCATE(d_t_dyn(klon,klev),d_q_dyn(klon,klev))
    826       ALLOCATE(d_ql_dyn(klon,klev),d_qs_dyn(klon,klev), d_qbs_dyn(klon,klev))
    827       ALLOCATE(d_q_dyn2d(klon),d_ql_dyn2d(klon),d_qs_dyn2d(klon), d_qbs_dyn2d(klon))
    828       ALLOCATE(d_u_dyn(klon,klev),d_v_dyn(klon,klev))
    829       ALLOCATE(d_tr_dyn(klon,klev,nbtr))                   !RomP
    830       ALLOCATE(d_t_con(klon,klev),d_q_con(klon,klev),d_q_con_zmasse(klon,klev))
    831       ALLOCATE(d_u_con(klon,klev),d_v_con(klon,klev))
    832       ALLOCATE(d_t_wake(klon,klev),d_q_wake(klon,klev))
    833       ALLOCATE(d_t_lsc(klon,klev),d_q_lsc(klon,klev))
    834       ALLOCATE(d_t_lwr(klon,klev),d_t_lw0(klon,klev))
    835       ALLOCATE(d_t_swr(klon,klev),d_t_sw0(klon,klev))
    836       ALLOCATE(d_ql_lsc(klon,klev),d_qi_lsc(klon,klev))
    837       ALLOCATE(d_t_ajsb(klon,klev),d_q_ajsb(klon,klev))
    838       ALLOCATE(d_t_ajs(klon,klev),d_q_ajs(klon,klev))
    839 !nrlmd<
    840       ALLOCATE(d_t_ajs_w(klon,klev),d_q_ajs_w(klon,klev))
    841       ALLOCATE(d_t_ajs_x(klon,klev),d_q_ajs_x(klon,klev))
    842 !>nrlmd
    843       ALLOCATE(d_u_ajs(klon,klev),d_v_ajs(klon,klev))
    844       ALLOCATE(d_t_eva(klon,klev),d_q_eva(klon,klev))
    845       ALLOCATE(d_qx_eva(klon,klev,nqtot))
    846       ALLOCATE(d_ql_eva(klon,klev),d_qi_eva(klon,klev))
    847       ALLOCATE(d_t_lscst(klon,klev),d_q_lscst(klon,klev))
    848       ALLOCATE(d_t_lscth(klon,klev),d_q_lscth(klon,klev))
    849       ALLOCATE(plul_st(klon),plul_th(klon))
    850       ALLOCATE(d_t_vdf(klon,klev),d_q_vdf(klon,klev),d_t_diss(klon,klev))
    851       ALLOCATE (d_qbs_vdf(klon,klev))
    852       ALLOCATE(d_t_bsss(klon,klev),d_q_bsss(klon,klev),d_qbs_bsss(klon,klev))
    853       ALLOCATE(d_t_vdf_w(klon,klev),d_q_vdf_w(klon,klev))
    854       ALLOCATE(d_t_vdf_x(klon,klev),d_q_vdf_x(klon,klev))
     809    USE aero_mod
     810    USE indice_sol_mod
     811    USE phys_output_var_mod
     812    USE phys_state_var_mod
     813
     814    IMPLICIT NONE
     815    ALLOCATE(t_seri(klon, klev), q_seri(klon, klev), ql_seri(klon, klev), qs_seri(klon, klev), qbs_seri(klon, klev))
     816    ALLOCATE(qx_seri(klon, klev, nqtot))
     817    ALLOCATE(u_seri(klon, klev), v_seri(klon, klev))
     818    ALLOCATE(l_mixmin(klon, klev + 1, nbsrf), l_mix(klon, klev + 1, nbsrf), wprime(klon, klev + 1, nbsrf))
     819    ALLOCATE(pbl_eps(klon, klev + 1, nbsrf + 1))
     820    ALLOCATE(tke_shear(klon, klev + 1, nbsrf), tke_buoy(klon, klev + 1, nbsrf), tke_trans(klon, klev + 1, nbsrf))
     821    pbl_eps(:, :, :) = 0.
     822    tke_shear(:, :, :) = 0.; tke_buoy(:, :, :) = 0.; tke_trans(:, :, :) = 0.
     823    l_mix(:, :, :) = 0.;l_mixmin(:, :, :) = 0.;wprime(:, :, :) = 0. ! doit etre initialse car pas toujours remplis
     824    ALLOCATE(rhcl(klon, klev))
     825    ALLOCATE(tr_seri(klon, klev, nbtr))
     826    ALLOCATE(d_t_dyn(klon, klev), d_q_dyn(klon, klev))
     827    ALLOCATE(d_ql_dyn(klon, klev), d_qs_dyn(klon, klev), d_qbs_dyn(klon, klev))
     828    ALLOCATE(d_q_dyn2d(klon), d_ql_dyn2d(klon), d_qs_dyn2d(klon), d_qbs_dyn2d(klon))
     829    ALLOCATE(d_u_dyn(klon, klev), d_v_dyn(klon, klev))
     830    ALLOCATE(d_tr_dyn(klon, klev, nbtr))                   !RomP
     831    ALLOCATE(d_t_con(klon, klev), d_q_con(klon, klev), d_q_con_zmasse(klon, klev))
     832    ALLOCATE(d_u_con(klon, klev), d_v_con(klon, klev))
     833    ALLOCATE(d_t_wake(klon, klev), d_q_wake(klon, klev))
     834    ALLOCATE(d_t_lsc(klon, klev), d_q_lsc(klon, klev))
     835    ALLOCATE(d_t_lwr(klon, klev), d_t_lw0(klon, klev))
     836    ALLOCATE(d_t_swr(klon, klev), d_t_sw0(klon, klev))
     837    ALLOCATE(d_ql_lsc(klon, klev), d_qi_lsc(klon, klev))
     838    ALLOCATE(d_t_ajsb(klon, klev), d_q_ajsb(klon, klev))
     839    ALLOCATE(d_t_ajs(klon, klev), d_q_ajs(klon, klev))
     840    !nrlmd<
     841    ALLOCATE(d_t_ajs_w(klon, klev), d_q_ajs_w(klon, klev))
     842    ALLOCATE(d_t_ajs_x(klon, klev), d_q_ajs_x(klon, klev))
     843    !>nrlmd
     844    ALLOCATE(d_u_ajs(klon, klev), d_v_ajs(klon, klev))
     845    ALLOCATE(d_t_eva(klon, klev), d_q_eva(klon, klev))
     846    ALLOCATE(d_qx_eva(klon, klev, nqtot))
     847    ALLOCATE(d_ql_eva(klon, klev), d_qi_eva(klon, klev))
     848    ALLOCATE(d_t_lscst(klon, klev), d_q_lscst(klon, klev))
     849    ALLOCATE(d_t_lscth(klon, klev), d_q_lscth(klon, klev))
     850    ALLOCATE(plul_st(klon), plul_th(klon))
     851    ALLOCATE(d_t_vdf(klon, klev), d_q_vdf(klon, klev), d_t_diss(klon, klev))
     852    ALLOCATE (d_qbs_vdf(klon, klev))
     853    ALLOCATE(d_t_bsss(klon, klev), d_q_bsss(klon, klev), d_qbs_bsss(klon, klev))
     854    ALLOCATE(d_t_vdf_w(klon, klev), d_q_vdf_w(klon, klev))
     855    ALLOCATE(d_t_vdf_x(klon, klev), d_q_vdf_x(klon, klev))
    855856#ifdef ISO
    856857      allocate(xt_seri(ntraciso,klon,klev))
     
    883884#endif
    884885
    885       ALLOCATE(d_u_vdf(klon,klev),d_v_vdf(klon,klev))
    886       ALLOCATE(d_t_oli(klon,klev),d_t_oro(klon,klev))
    887       ALLOCATE(d_u_oli(klon,klev),d_v_oli(klon,klev))
    888       ALLOCATE(d_u_oro(klon,klev),d_v_oro(klon,klev))
    889       ALLOCATE(d_u_oro_gw(klon,klev),d_v_oro_gw(klon,klev))
    890       ALLOCATE(d_t_oro_gw(klon,klev))
    891       ALLOCATE(d_t_lif(klon,klev),d_t_ec(klon,klev))
    892       ALLOCATE(d_u_lif(klon,klev),d_v_lif(klon,klev))
    893       ALLOCATE(d_ts(klon,nbsrf), d_tr(klon,klev,nbtr))
    894 
    895 ! aerosols
    896       ALLOCATE(m_allaer(klon,klev,naero_tot))
    897 ! Special RRTM
    898       ALLOCATE(ZLWFT0_i(klon,klev+1),ZSWFT0_i(klon,klev+1),ZFLDN0(klon,klev+1))
    899       ZFLDN0= 0.
    900       ALLOCATE(ZFLUP0(klon,klev+1),ZFSDN0(klon,klev+1),ZFSUP0(klon,klev+1))
    901 !
    902       ALLOCATE(topswad_aero(klon), solswad_aero(klon))
    903       ALLOCATE(topswai_aero(klon), solswai_aero(klon))
    904       ALLOCATE(topswad0_aero(klon), solswad0_aero(klon))
    905       ALLOCATE(toplwad_aero(klon), sollwad_aero(klon))
    906       ALLOCATE(toplwai_aero(klon), sollwai_aero(klon))
    907       ALLOCATE(toplwad0_aero(klon), sollwad0_aero(klon))
    908       ALLOCATE(topsw_aero(klon,naero_grp), solsw_aero(klon,naero_grp))
    909       ALLOCATE(topsw0_aero(klon,naero_grp), solsw0_aero(klon,naero_grp))
    910       ALLOCATE(topswcf_aero(klon,3), solswcf_aero(klon,3))
    911       ALLOCATE(du_gwd_hines(klon,klev),dv_gwd_hines(klon,klev))
    912       ALLOCATE(dv_gwd_rando(klon,klev),dv_gwd_front(klon,klev))
    913       ALLOCATE(east_gwstress(klon,klev),west_gwstress(klon,klev))
    914       east_gwstress(:,:)=0 !ym missing init
    915       west_gwstress(:,:)=0 !ym missing init
    916       ALLOCATE(d_t_hin(klon,klev))
    917       ALLOCATE(d_q_ch4(klon,klev))
    918       ALLOCATE(stratomask(klon,klev))
    919       ALLOCATE(tausum_aero(klon,nwave,naero_tot))
    920       ALLOCATE(drytausum_aero(klon,naero_tot))
    921       ALLOCATE(tau3d_aero(klon,klev,nwave,naero_tot))
    922       ALLOCATE(dNovrN(klon))
    923       ALLOCATE(zfice(klon, klev))
    924       ALLOCATE(od443aer(klon))
    925       ALLOCATE(od550aer(klon))
    926       ALLOCATE(od865aer(klon))
    927       ALLOCATE(dryod550aer(klon))
    928       dryod550aer(:) = 0.
    929       ALLOCATE(abs550aer(klon))
    930       abs550aer(:) = 0.
    931       ALLOCATE(ec550aer(klon,klev))
    932       ALLOCATE(od550lt1aer(klon))
    933       ALLOCATE(sconcso4(klon))
    934       ALLOCATE(sconcno3(klon))
    935       ALLOCATE(sconcoa(klon))
    936       ALLOCATE(sconcbc(klon))
    937       ALLOCATE(sconcss(klon))
    938       ALLOCATE(sconcdust(klon))
    939       ALLOCATE(concso4(klon,klev))
    940       ALLOCATE(concno3(klon,klev))
    941       ALLOCATE(concoa(klon,klev))
    942       ALLOCATE(concbc(klon,klev))
    943       ALLOCATE(concss(klon,klev))
    944       ALLOCATE(concdust(klon,klev))
    945       ALLOCATE(loadso4(klon))
    946       ALLOCATE(loadoa(klon))
    947       ALLOCATE(loadbc(klon))
    948       ALLOCATE(loadss(klon))
    949       ALLOCATE(loaddust(klon))
    950       ALLOCATE(loadno3(klon))
    951       ALLOCATE(load_tmp1(klon))
    952       ALLOCATE(load_tmp2(klon))
    953       ALLOCATE(load_tmp3(klon))
    954       ALLOCATE(load_tmp4(klon))
    955       ALLOCATE(load_tmp5(klon))
    956       ALLOCATE(load_tmp6(klon))
    957       ALLOCATE(load_tmp7(klon))
    958       ALLOCATE(load_tmp8(klon))
    959       ALLOCATE(load_tmp9(klon))
    960       ALLOCATE(load_tmp10(klon))
    961 
    962 !IM ajout variables CFMIP2/CMIP5
    963       ALLOCATE(topswad_aerop(klon), solswad_aerop(klon))
    964       ALLOCATE(topswai_aerop(klon), solswai_aerop(klon))
    965       ALLOCATE(topswad0_aerop(klon), solswad0_aerop(klon))
    966       ALLOCATE(topsw_aerop(klon,naero_grp), topsw0_aerop(klon,naero_grp))
    967       ALLOCATE(solsw_aerop(klon,naero_grp), solsw0_aerop(klon,naero_grp))
    968       ALLOCATE(topswcf_aerop(klon,naero_grp), solswcf_aerop(klon,naero_grp))
    969 
    970 ! additional LW variables CK
    971       ALLOCATE(toplwad_aerop(klon), sollwad_aerop(klon))
    972       ALLOCATE(toplwai_aerop(klon), sollwai_aerop(klon))
    973       ALLOCATE(toplwad0_aerop(klon), sollwad0_aerop(klon))
    974 
    975 !AI Ajout Ecrad (3Deffect)
    976       ALLOCATE(topswad_aero_s2(klon), solswad_aero_s2(klon))
    977       ALLOCATE(topswai_aero_s2(klon), solswai_aero_s2(klon))
    978       ALLOCATE(topswad0_aero_s2(klon), solswad0_aero_s2(klon))
    979       ALLOCATE(topsw_aero_s2(klon,naero_grp), topsw0_aero_s2(klon,naero_grp))
    980       ALLOCATE(solsw_aero_s2(klon,naero_grp), solsw0_aero_s2(klon,naero_grp))
    981       ALLOCATE(topswcf_aero_s2(klon,naero_grp), solswcf_aero_s2(klon,naero_grp))
    982 ! additional LW variables CK
    983       ALLOCATE(toplwad_aero_s2(klon), sollwad_aero_s2(klon))
    984       ALLOCATE(toplwai_aero_s2(klon), sollwai_aero_s2(klon))
    985       ALLOCATE(toplwad0_aero_s2(klon), sollwad0_aero_s2(klon))
    986 
    987 ! FH Ajout de celles necessaires au phys_output_write_mod
    988 
    989       ALLOCATE(tal1(klon), pal1(klon), pab1(klon), pab2(klon))
    990       ALLOCATE(ptstar(klon),pt0(klon),slp(klon))
    991 !!
    992 !!          Wake variables
    993       ALLOCATE(alp_wake(klon))
    994       ALLOCATE(wake_h(klon),wake_k(klon))
    995       ALLOCATE(wake_omg(klon, klev))
    996       ALLOCATE(d_deltat_wk(klon, klev), d_deltaq_wk(klon, klev))
    997       ALLOCATE(d_s_wk(klon), d_dens_a_wk(klon), d_dens_wk(klon))
    998       ALLOCATE(d_deltat_wk_gw(klon, klev), d_deltaq_wk_gw(klon, klev))
    999       ALLOCATE(d_deltat_vdf(klon, klev), d_deltaq_vdf(klon, klev))
    1000 !!      ALLOCATE( d_s_vdf(klon), d_dens_vdf(klon))
    1001       ALLOCATE(d_deltat_the(klon, klev), d_deltaq_the(klon, klev))
    1002 !!      ALLOCATE( d_s_the(klon), d_dens_the(klon))
    1003       ALLOCATE(d_deltat_ajs_cv(klon, klev), d_deltaq_ajs_cv(klon, klev))
     886    ALLOCATE(d_u_vdf(klon, klev), d_v_vdf(klon, klev))
     887    ALLOCATE(d_t_oli(klon, klev), d_t_oro(klon, klev))
     888    ALLOCATE(d_u_oli(klon, klev), d_v_oli(klon, klev))
     889    ALLOCATE(d_u_oro(klon, klev), d_v_oro(klon, klev))
     890    ALLOCATE(d_u_oro_gw(klon, klev), d_v_oro_gw(klon, klev))
     891    ALLOCATE(d_t_oro_gw(klon, klev))
     892    ALLOCATE(d_t_lif(klon, klev), d_t_ec(klon, klev))
     893    ALLOCATE(d_u_lif(klon, klev), d_v_lif(klon, klev))
     894    ALLOCATE(d_ts(klon, nbsrf), d_tr(klon, klev, nbtr))
     895
     896    ! aerosols
     897    ALLOCATE(m_allaer(klon, klev, naero_tot))
     898    ! Special RRTM
     899    ALLOCATE(ZLWFT0_i(klon, klev + 1), ZSWFT0_i(klon, klev + 1), ZFLDN0(klon, klev + 1))
     900    ZFLDN0 = 0.
     901    ALLOCATE(ZFLUP0(klon, klev + 1), ZFSDN0(klon, klev + 1), ZFSUP0(klon, klev + 1))
     902    !
     903    ALLOCATE(topswad_aero(klon), solswad_aero(klon))
     904    ALLOCATE(topswai_aero(klon), solswai_aero(klon))
     905    ALLOCATE(topswad0_aero(klon), solswad0_aero(klon))
     906    ALLOCATE(toplwad_aero(klon), sollwad_aero(klon))
     907    ALLOCATE(toplwai_aero(klon), sollwai_aero(klon))
     908    ALLOCATE(toplwad0_aero(klon), sollwad0_aero(klon))
     909    ALLOCATE(topsw_aero(klon, naero_grp), solsw_aero(klon, naero_grp))
     910    ALLOCATE(topsw0_aero(klon, naero_grp), solsw0_aero(klon, naero_grp))
     911    ALLOCATE(topswcf_aero(klon, 3), solswcf_aero(klon, 3))
     912    ALLOCATE(du_gwd_hines(klon, klev), dv_gwd_hines(klon, klev))
     913    ALLOCATE(dv_gwd_rando(klon, klev), dv_gwd_front(klon, klev))
     914    ALLOCATE(east_gwstress(klon, klev), west_gwstress(klon, klev))
     915    east_gwstress(:, :) = 0 !ym missing init
     916    west_gwstress(:, :) = 0 !ym missing init
     917    ALLOCATE(d_t_hin(klon, klev))
     918    ALLOCATE(d_q_ch4(klon, klev))
     919    ALLOCATE(stratomask(klon, klev))
     920    ALLOCATE(tausum_aero(klon, nwave, naero_tot))
     921    ALLOCATE(drytausum_aero(klon, naero_tot))
     922    ALLOCATE(tau3d_aero(klon, klev, nwave, naero_tot))
     923    ALLOCATE(dNovrN(klon))
     924    ALLOCATE(zfice(klon, klev))
     925    ALLOCATE(od443aer(klon))
     926    ALLOCATE(od550aer(klon))
     927    ALLOCATE(od865aer(klon))
     928    ALLOCATE(dryod550aer(klon))
     929    dryod550aer(:) = 0.
     930    ALLOCATE(abs550aer(klon))
     931    abs550aer(:) = 0.
     932    ALLOCATE(ec550aer(klon, klev))
     933    ALLOCATE(od550lt1aer(klon))
     934    ALLOCATE(sconcso4(klon))
     935    ALLOCATE(sconcno3(klon))
     936    ALLOCATE(sconcoa(klon))
     937    ALLOCATE(sconcbc(klon))
     938    ALLOCATE(sconcss(klon))
     939    ALLOCATE(sconcdust(klon))
     940    ALLOCATE(concso4(klon, klev))
     941    ALLOCATE(concno3(klon, klev))
     942    ALLOCATE(concoa(klon, klev))
     943    ALLOCATE(concbc(klon, klev))
     944    ALLOCATE(concss(klon, klev))
     945    ALLOCATE(concdust(klon, klev))
     946    ALLOCATE(loadso4(klon))
     947    ALLOCATE(loadoa(klon))
     948    ALLOCATE(loadbc(klon))
     949    ALLOCATE(loadss(klon))
     950    ALLOCATE(loaddust(klon))
     951    ALLOCATE(loadno3(klon))
     952    ALLOCATE(load_tmp1(klon))
     953    ALLOCATE(load_tmp2(klon))
     954    ALLOCATE(load_tmp3(klon))
     955    ALLOCATE(load_tmp4(klon))
     956    ALLOCATE(load_tmp5(klon))
     957    ALLOCATE(load_tmp6(klon))
     958    ALLOCATE(load_tmp7(klon))
     959    ALLOCATE(load_tmp8(klon))
     960    ALLOCATE(load_tmp9(klon))
     961    ALLOCATE(load_tmp10(klon))
     962
     963    !IM ajout variables CFMIP2/CMIP5
     964    ALLOCATE(topswad_aerop(klon), solswad_aerop(klon))
     965    ALLOCATE(topswai_aerop(klon), solswai_aerop(klon))
     966    ALLOCATE(topswad0_aerop(klon), solswad0_aerop(klon))
     967    ALLOCATE(topsw_aerop(klon, naero_grp), topsw0_aerop(klon, naero_grp))
     968    ALLOCATE(solsw_aerop(klon, naero_grp), solsw0_aerop(klon, naero_grp))
     969    ALLOCATE(topswcf_aerop(klon, naero_grp), solswcf_aerop(klon, naero_grp))
     970
     971    ! additional LW variables CK
     972    ALLOCATE(toplwad_aerop(klon), sollwad_aerop(klon))
     973    ALLOCATE(toplwai_aerop(klon), sollwai_aerop(klon))
     974    ALLOCATE(toplwad0_aerop(klon), sollwad0_aerop(klon))
     975
     976    !AI Ajout Ecrad (3Deffect)
     977    ALLOCATE(topswad_aero_s2(klon), solswad_aero_s2(klon))
     978    ALLOCATE(topswai_aero_s2(klon), solswai_aero_s2(klon))
     979    ALLOCATE(topswad0_aero_s2(klon), solswad0_aero_s2(klon))
     980    ALLOCATE(topsw_aero_s2(klon, naero_grp), topsw0_aero_s2(klon, naero_grp))
     981    ALLOCATE(solsw_aero_s2(klon, naero_grp), solsw0_aero_s2(klon, naero_grp))
     982    ALLOCATE(topswcf_aero_s2(klon, naero_grp), solswcf_aero_s2(klon, naero_grp))
     983    ! additional LW variables CK
     984    ALLOCATE(toplwad_aero_s2(klon), sollwad_aero_s2(klon))
     985    ALLOCATE(toplwai_aero_s2(klon), sollwai_aero_s2(klon))
     986    ALLOCATE(toplwad0_aero_s2(klon), sollwad0_aero_s2(klon))
     987
     988    ! FH Ajout de celles necessaires au phys_output_write_mod
     989
     990    ALLOCATE(tal1(klon), pal1(klon), pab1(klon), pab2(klon))
     991    ALLOCATE(ptstar(klon), pt0(klon), slp(klon))
     992    !!
     993    !!          Wake variables
     994    ALLOCATE(alp_wake(klon))
     995    ALLOCATE(wake_h(klon), wake_k(klon))
     996    ALLOCATE(wake_omg(klon, klev))
     997    ALLOCATE(d_deltat_wk(klon, klev), d_deltaq_wk(klon, klev))
     998    ALLOCATE(d_s_wk(klon), d_dens_a_wk(klon), d_dens_wk(klon))
     999    ALLOCATE(d_deltat_wk_gw(klon, klev), d_deltaq_wk_gw(klon, klev))
     1000    ALLOCATE(d_deltat_vdf(klon, klev), d_deltaq_vdf(klon, klev))
     1001    !!      ALLOCATE( d_s_vdf(klon), d_dens_vdf(klon))
     1002    ALLOCATE(d_deltat_the(klon, klev), d_deltaq_the(klon, klev))
     1003    !!      ALLOCATE( d_s_the(klon), d_dens_the(klon))
     1004    ALLOCATE(d_deltat_ajs_cv(klon, klev), d_deltaq_ajs_cv(klon, klev))
    10041005#ifdef ISO
    10051006      ALLOCATE(d_deltaxt_wk(ntraciso,klon, klev))
     
    10091010      ALLOCATE(d_deltaxt_ajs_cv(ntraciso,klon, klev))
    10101011#endif
    1011 !!         End of wake variables
    1012 !!
    1013       ALLOCATE(bils(klon))
    1014       ALLOCATE(cdragm(klon), cdragh(klon), cldh(klon), cldl(klon))
    1015       ALLOCATE(cldm(klon), cldq(klon), cldt(klon), qsat2m(klon))
    1016       ALLOCATE(JrNt(klon))
    1017       ALLOCATE(dthmin(klon), evap(klon), snowerosion(klon), fder(klon), plcl(klon), plfc(klon))
    1018       ALLOCATE(prw(klon), prlw(klon), prsw(klon), prbsw(klon), water_budget(klon), zustar(klon), zu10m(klon), zv10m(klon), rh2m(klon))
    1019       ALLOCATE(s_lcl(klon))
    1020       ALLOCATE(s_pblh(klon), s_pblt(klon), s_therm(klon))
    1021 !
    1022 !nrlmd+jyg<
    1023       ALLOCATE(s_pblh_x(klon), s_pblh_w(klon))
    1024       ALLOCATE(s_lcl_x(klon), s_lcl_w(klon))
    1025 !>nrlmd+jyg
    1026 !
    1027       ALLOCATE(slab_wfbils(klon), tpot(klon), tpote(klon), ue(klon))
    1028       ALLOCATE(uq(klon), ve(klon), vq(klon), zxffonte(klon))
    1029       ALLOCATE(uwat(klon), vwat(klon))
    1030       ALLOCATE(zxfqcalving(klon), zxfluxlat(klon))
    1031       ALLOCATE(zxtsol(klon), snow_lsc(klon), zxfqfonte(klon), zxqsurf(klon))
    1032       ALLOCATE(zxrunofflic(klon))
    1033       ALLOCATE(zxustartlic(klon), zxrhoslic(klon), zxqsaltlic(klon))
    1034       zxustartlic(:)=0. ; zxrhoslic(:)=0. ; zxqsaltlic(:)=0.
    1035       ALLOCATE(rain_lsc(klon))
    1036       ALLOCATE(rain_num(klon))
    1037       ALLOCATE(qlth(klon,klev), qith(klon,klev), qsith(klon,klev), wiceth(klon,klev))
    1038       !
     1012    !!         End of wake variables
     1013    !!
     1014    ALLOCATE(bils(klon))
     1015    ALLOCATE(cdragm(klon), cdragh(klon), cldh(klon), cldl(klon))
     1016    ALLOCATE(cldm(klon), cldq(klon), cldt(klon), qsat2m(klon))
     1017    ALLOCATE(JrNt(klon))
     1018    ALLOCATE(dthmin(klon), evap(klon), snowerosion(klon), fder(klon), plcl(klon), plfc(klon))
     1019    ALLOCATE(prw(klon), prlw(klon), prsw(klon), prbsw(klon), water_budget(klon), zustar(klon), zu10m(klon), zv10m(klon), rh2m(klon))
     1020    ALLOCATE(s_lcl(klon))
     1021    ALLOCATE(s_pblh(klon), s_pblt(klon), s_therm(klon))
     1022    !
     1023    !nrlmd+jyg<
     1024    ALLOCATE(s_pblh_x(klon), s_pblh_w(klon))
     1025    ALLOCATE(s_lcl_x(klon), s_lcl_w(klon))
     1026    !>nrlmd+jyg
     1027    !
     1028    ALLOCATE(slab_wfbils(klon), tpot(klon), tpote(klon), ue(klon))
     1029    ALLOCATE(uq(klon), ve(klon), vq(klon), zxffonte(klon))
     1030    ALLOCATE(uwat(klon), vwat(klon))
     1031    ALLOCATE(zxfqcalving(klon), zxfluxlat(klon))
     1032    ALLOCATE(zxtsol(klon), snow_lsc(klon), zxfqfonte(klon), zxqsurf(klon))
     1033    ALLOCATE(zxrunofflic(klon))
     1034    ALLOCATE(zxustartlic(klon), zxrhoslic(klon), zxqsaltlic(klon))
     1035    zxustartlic(:) = 0. ; zxrhoslic(:) = 0. ; zxqsaltlic(:) = 0.
     1036    ALLOCATE(rain_lsc(klon))
     1037    ALLOCATE(rain_num(klon))
     1038    ALLOCATE(qlth(klon, klev), qith(klon, klev), qsith(klon, klev), wiceth(klon, klev))
     1039    !
    10391040#ifdef ISO
    10401041      ALLOCATE(xtevap(ntraciso,klon))
     
    10491050      runoff_diag(:)=0. ; xtrunoff_diag(:,:)=0. ! because variables are only given values on knon grid points
    10501051#endif
    1051 !
    1052       ALLOCATE(sens_x(klon), sens_w(klon))
    1053       ALLOCATE(zxfluxlat_x(klon), zxfluxlat_w(klon))
    1054       ALLOCATE(delta_qsurf(klon))
    1055 !jyg<
    1056 !!      ALLOCATE(t_x(klon,klev), t_w(klon,klev))
    1057 !!      ALLOCATE(q_x(klon,klev), q_w(klon,klev))
    1058 !>jyg
    1059       ALLOCATE(dtvdf_x(klon,klev), dtvdf_w(klon,klev))
    1060       dtvdf_x = 0 ; dtvdf_w=0 ;   !ym missing init
    1061       ALLOCATE(dqvdf_x(klon,klev), dqvdf_w(klon,klev))
    1062       dqvdf_x = 0 ; dqvdf_w=0 ;   !ym missing init
    1063       ALLOCATE(pbl_tke_input(klon,klev+1,nbsrf))
    1064       ALLOCATE(t_therm(klon,klev), q_therm(klon,klev),u_therm(klon,klev), v_therm(klon,klev))
    1065       ALLOCATE(cdragh_x(klon), cdragh_w(klon))
    1066       ALLOCATE(cdragm_x(klon), cdragm_w(klon))
    1067       ALLOCATE(kh(klon), kh_x(klon), kh_w(klon))
     1052    !
     1053    ALLOCATE(sens_x(klon), sens_w(klon))
     1054    ALLOCATE(zxfluxlat_x(klon), zxfluxlat_w(klon))
     1055    ALLOCATE(delta_qsurf(klon))
     1056    !jyg<
     1057    !!      ALLOCATE(t_x(klon,klev), t_w(klon,klev))
     1058    !!      ALLOCATE(q_x(klon,klev), q_w(klon,klev))
     1059    !>jyg
     1060    ALLOCATE(dtvdf_x(klon, klev), dtvdf_w(klon, klev))
     1061    dtvdf_x = 0 ; dtvdf_w = 0 ;
     1062    !ym missing init
     1063    ALLOCATE(dqvdf_x(klon, klev), dqvdf_w(klon, klev))
     1064    dqvdf_x = 0 ; dqvdf_w = 0 ;
     1065    !ym missing init
     1066    ALLOCATE(pbl_tke_input(klon, klev + 1, nbsrf))
     1067    ALLOCATE(t_therm(klon, klev), q_therm(klon, klev), u_therm(klon, klev), v_therm(klon, klev))
     1068    ALLOCATE(cdragh_x(klon), cdragh_w(klon))
     1069    ALLOCATE(cdragm_x(klon), cdragm_w(klon))
     1070    ALLOCATE(kh(klon), kh_x(klon), kh_w(klon))
    10681071#ifdef ISO
    10691072      ALLOCATE(dxtvdf_x(ntraciso,klon,klev), dxtvdf_w(ntraciso,klon,klev))
    10701073      ALLOCATE(xt_therm(ntraciso,klon,klev))
    10711074#endif
    1072 !
    1073       ALLOCATE(ptconv(klon,klev))
    1074       ALLOCATE(ratqsc(klon,klev))
    1075 !
    1076       ALLOCATE(wbeff(klon), convoccur(klon), zmax_th(klon))
    1077       ALLOCATE(zq2m(klon), zt2m(klon), weak_inversion(klon))
    1078       ALLOCATE(zt2m_min_mon(klon), zt2m_max_mon(klon))
    1079       ALLOCATE(t2m_min_mon(klon), t2m_max_mon(klon))
    1080       ALLOCATE(sens(klon), flwp(klon), fiwp(klon))
    1081       ALLOCATE(alp_bl_conv(klon), alp_bl_det(klon))
    1082       alp_bl_conv(:)=0 ;  alp_bl_det(:)=0
    1083       ALLOCATE(alp_bl_fluct_m(klon), alp_bl_fluct_tke(klon))
    1084       alp_bl_fluct_m(:)=0 ; alp_bl_fluct_tke(:)= 0.
    1085       ALLOCATE(alp_bl_stat(klon), n2(klon), s2(klon), strig(klon), zcong(klon), zlcl_th(klon))
    1086       alp_bl_stat(:)=0
    1087       ALLOCATE(proba_notrig(klon), random_notrig(klon))
    1088 
    1089       ALLOCATE(dnwd0(klon, klev))
    1090 !      ALLOCATE(upwd(klon, klev), omega(klon, klev), coefh(klon, klev))
    1091       ALLOCATE(omega(klon, klev))
    1092       ALLOCATE(epmax_diag(klon)) ! epmax_cape
    1093 !      ALLOCATE(coefm(klon, klev), lambda_th(klon, klev), cldemi(klon, klev))
    1094       ALLOCATE(lambda_th(klon, klev), cldemi(klon, klev))
    1095       ALLOCATE(cldfra(klon, klev), cldtau(klon, klev), fiwc(klon, klev))
    1096       ALLOCATE(fl(klon, klev), re(klon, klev), flwc(klon, klev))
    1097       ALLOCATE(ref_liq(klon, klev), ref_ice(klon, klev), theta(klon, klev))
    1098       ALLOCATE(ref_liq_pi(klon, klev), ref_ice_pi(klon, klev))
    1099       ALLOCATE(zphi(klon, klev), zx_rh(klon, klev), zx_rhl(klon,klev), zx_rhi(klon,klev))
    1100       zx_rhl(:,:)=0.; zx_rhi(:,:)=0. ! because not always defined
    1101       ALLOCATE(pmfd(klon, klev), pmfu(klon, klev))
    1102 
    1103       ALLOCATE(t2m(klon, nbsrf), fluxlat(klon, nbsrf))
    1104       ALLOCATE(fsollw(klon, nbsrf))
    1105       ALLOCATE(fsolsw(klon, nbsrf), wfbils(klon, nbsrf))
    1106       ALLOCATE(wfevap(klon, nbsrf))
    1107       ALLOCATE(evap_pot(klon, nbsrf))
    1108 ! FC
    1109       ALLOCATE(zxfluxq(klon,klev),zxfluxt(klon,klev))
    1110 !
    1111 !
    1112 !  Deep convective variables used in phytrac
    1113       ALLOCATE(pmflxr(klon, klev+1), pmflxs(klon, klev+1))
    1114       ALLOCATE(wdtrainA(klon,klev),wdtrainS(klon,klev),wdtrainM(klon,klev))
    1115       ALLOCATE(dnwd(klon, klev), upwd(klon, klev))
    1116       ALLOCATE(ep(klon,klev))                          ! epmax_cape
    1117       ALLOCATE(da(klon,klev), mp(klon,klev))
    1118       ALLOCATE(phi(klon,klev,klev))
    1119       ALLOCATE(wght_cvfd(klon,klev))
    1120       ALLOCATE(phi2(klon,klev,klev))
    1121       ALLOCATE(d1a(klon,klev), dam(klon,klev))
    1122       ALLOCATE(ev(klon,klev))
    1123       ALLOCATE(elij(klon,klev,klev))
    1124       ALLOCATE(qtaa(klon,klev))
    1125       ALLOCATE(clw(klon,klev))
    1126       ALLOCATE(epmlmMm(klon,klev,klev), eplaMm(klon,klev))
    1127       ALLOCATE(sij(klon,klev,klev))
     1075    !
     1076    ALLOCATE(ptconv(klon, klev))
     1077    ALLOCATE(ratqsc(klon, klev))
     1078    !
     1079    ALLOCATE(wbeff(klon), convoccur(klon), zmax_th(klon))
     1080    ALLOCATE(zq2m(klon), zt2m(klon), weak_inversion(klon))
     1081    ALLOCATE(zt2m_min_mon(klon), zt2m_max_mon(klon))
     1082    ALLOCATE(t2m_min_mon(klon), t2m_max_mon(klon))
     1083    ALLOCATE(sens(klon), flwp(klon), fiwp(klon))
     1084    ALLOCATE(alp_bl_conv(klon), alp_bl_det(klon))
     1085    alp_bl_conv(:) = 0 ;  alp_bl_det(:) = 0
     1086    ALLOCATE(alp_bl_fluct_m(klon), alp_bl_fluct_tke(klon))
     1087    alp_bl_fluct_m(:) = 0 ; alp_bl_fluct_tke(:) = 0.
     1088    ALLOCATE(alp_bl_stat(klon), n2(klon), s2(klon), strig(klon), zcong(klon), zlcl_th(klon))
     1089    alp_bl_stat(:) = 0
     1090    ALLOCATE(proba_notrig(klon), random_notrig(klon))
     1091
     1092    ALLOCATE(dnwd0(klon, klev))
     1093    !      ALLOCATE(upwd(klon, klev), omega(klon, klev), coefh(klon, klev))
     1094    ALLOCATE(omega(klon, klev))
     1095    ALLOCATE(epmax_diag(klon)) ! epmax_cape
     1096    !      ALLOCATE(coefm(klon, klev), lambda_th(klon, klev), cldemi(klon, klev))
     1097    ALLOCATE(lambda_th(klon, klev), cldemi(klon, klev))
     1098    ALLOCATE(cldfra(klon, klev), cldtau(klon, klev), fiwc(klon, klev))
     1099    ALLOCATE(fl(klon, klev), re(klon, klev), flwc(klon, klev))
     1100    ALLOCATE(ref_liq(klon, klev), ref_ice(klon, klev), theta(klon, klev))
     1101    ALLOCATE(ref_liq_pi(klon, klev), ref_ice_pi(klon, klev))
     1102    ALLOCATE(zphi(klon, klev), zx_rh(klon, klev), zx_rhl(klon, klev), zx_rhi(klon, klev))
     1103    zx_rhl(:, :) = 0.; zx_rhi(:, :) = 0. ! because not always defined
     1104    ALLOCATE(pmfd(klon, klev), pmfu(klon, klev))
     1105
     1106    ALLOCATE(t2m(klon, nbsrf), fluxlat(klon, nbsrf))
     1107    ALLOCATE(fsollw(klon, nbsrf))
     1108    ALLOCATE(fsolsw(klon, nbsrf), wfbils(klon, nbsrf))
     1109    ALLOCATE(wfevap(klon, nbsrf))
     1110    ALLOCATE(evap_pot(klon, nbsrf))
     1111    ! FC
     1112    ALLOCATE(zxfluxq(klon, klev), zxfluxt(klon, klev))
     1113    !
     1114    !
     1115    !  Deep convective variables used in phytrac
     1116    ALLOCATE(pmflxr(klon, klev + 1), pmflxs(klon, klev + 1))
     1117    ALLOCATE(wdtrainA(klon, klev), wdtrainS(klon, klev), wdtrainM(klon, klev))
     1118    ALLOCATE(dnwd(klon, klev), upwd(klon, klev))
     1119    ALLOCATE(ep(klon, klev))                          ! epmax_cape
     1120    ALLOCATE(da(klon, klev), mp(klon, klev))
     1121    ALLOCATE(phi(klon, klev, klev))
     1122    ALLOCATE(wght_cvfd(klon, klev))
     1123    ALLOCATE(phi2(klon, klev, klev))
     1124    ALLOCATE(d1a(klon, klev), dam(klon, klev))
     1125    ALLOCATE(ev(klon, klev))
     1126    ALLOCATE(elij(klon, klev, klev))
     1127    ALLOCATE(qtaa(klon, klev))
     1128    ALLOCATE(clw(klon, klev))
     1129    ALLOCATE(epmlmMm(klon, klev, klev), eplaMm(klon, klev))
     1130    ALLOCATE(sij(klon, klev, klev))
    11281131#ifdef ISO
    11291132      ALLOCATE(xtwdtrainA(ntraciso,klon,klev))
     
    11501153#endif
    11511154
    1152       ALLOCATE(prfl(klon, klev+1))
    1153       ALLOCATE(psfl(klon, klev+1), fraca(klon, klev+1), Vprecip(klon, klev+1))
    1154       ALLOCATE(bsfl(klon,klev+1))
    1155       ALLOCATE(zw2(klon, klev+1))
    1156 
    1157       ALLOCATE(fluxu(klon, klev, nbsrf), fluxv(klon, klev, nbsrf))
    1158       ALLOCATE(fluxt(klon, klev, nbsrf))
    1159 
    1160       ALLOCATE(uwriteSTD(klon,nlevSTD,nfiles), vwriteSTD(klon,nlevSTD,nfiles))
    1161       ALLOCATE(wwriteSTD(klon,nlevSTD,nfiles), phiwriteSTD(klon,nlevSTD,nfiles))
    1162       ALLOCATE(qwriteSTD(klon,nlevSTD,nfiles), twriteSTD(klon,nlevSTD,nfiles))
    1163       ALLOCATE(rhwriteSTD(klon,nlevSTD,nfiles))
    1164 
    1165 ! ug et d'autres encore:
    1166       ALLOCATE(beta_prec(klon,klev))
    1167       ALLOCATE(rneb(klon,klev),rnebjn(klon,klev),rneblsvol(klon,klev))
    1168       ALLOCATE(pfraclr(klon,klev),pfracld(klon,klev))
    1169       pfraclr(:,:)=0. ; pfracld(:,:)=0. ! because not always defined
    1170       ALLOCATE(cldfraliq(klon,klev))
    1171       ALLOCATE(sigma2_icefracturb(klon,klev))
    1172       ALLOCATE(mean_icefracturb(klon,klev))
    1173       ALLOCATE(distcltop(klon,klev))
    1174       ALLOCATE(temp_cltop(klon,klev))
    1175 
    1176       ALLOCATE (zxsnow(klon),snowhgt(klon),qsnow(klon),to_ice(klon))
    1177       ALLOCATE (sissnow(klon),runoff(klon),albsol3_lic(klon))
     1155    ALLOCATE(prfl(klon, klev + 1))
     1156    ALLOCATE(psfl(klon, klev + 1), fraca(klon, klev + 1), Vprecip(klon, klev + 1))
     1157    ALLOCATE(bsfl(klon, klev + 1))
     1158    ALLOCATE(zw2(klon, klev + 1))
     1159
     1160    ALLOCATE(fluxu(klon, klev, nbsrf), fluxv(klon, klev, nbsrf))
     1161    ALLOCATE(fluxt(klon, klev, nbsrf))
     1162
     1163    ALLOCATE(uwriteSTD(klon, nlevSTD, nfiles), vwriteSTD(klon, nlevSTD, nfiles))
     1164    ALLOCATE(wwriteSTD(klon, nlevSTD, nfiles), phiwriteSTD(klon, nlevSTD, nfiles))
     1165    ALLOCATE(qwriteSTD(klon, nlevSTD, nfiles), twriteSTD(klon, nlevSTD, nfiles))
     1166    ALLOCATE(rhwriteSTD(klon, nlevSTD, nfiles))
     1167
     1168    ! ug et d'autres encore:
     1169    ALLOCATE(beta_prec(klon, klev))
     1170    ALLOCATE(rneb(klon, klev), rnebjn(klon, klev), rneblsvol(klon, klev))
     1171    ALLOCATE(pfraclr(klon, klev), pfracld(klon, klev))
     1172    pfraclr(:, :) = 0. ; pfracld(:, :) = 0. ! because not always defined
     1173    ALLOCATE(cldfraliq(klon, klev))
     1174    ALLOCATE(sigma2_icefracturb(klon, klev))
     1175    ALLOCATE(mean_icefracturb(klon, klev))
     1176    ALLOCATE(distcltop(klon, klev))
     1177    ALLOCATE(temp_cltop(klon, klev))
     1178
     1179    ALLOCATE (zxsnow(klon), snowhgt(klon), qsnow(klon), to_ice(klon))
     1180    ALLOCATE (sissnow(klon), runoff(klon), albsol3_lic(klon))
    11781181#ifdef ISO
    11791182      ALLOCATE (zxxtsnow(niso,klon))
     
    11821185#endif
    11831186
    1184       ALLOCATE (p_tropopause(klon))
    1185       ALLOCATE (z_tropopause(klon))
    1186       ALLOCATE (t_tropopause(klon))
    1187 
    1188       ALLOCATE(zn2mout(klon,6))
    1189 
    1190 ! Supersaturation
    1191       ALLOCATE(rneb_seri(klon,klev))
    1192       ALLOCATE(d_rneb_dyn(klon,klev))
    1193       ALLOCATE(qclr(klon,klev), qcld(klon,klev), qss(klon,klev), qvc(klon,klev))
    1194       ALLOCATE(rnebclr(klon,klev), rnebss(klon,klev), gamma_ss(klon,klev))
    1195       ALLOCATE(N1_ss(klon,klev), N2_ss(klon,klev))
    1196       ALLOCATE(drneb_sub(klon,klev), drneb_con(klon,klev), drneb_tur(klon,klev), drneb_avi(klon,klev))
    1197       ALLOCATE(zqsatl(klon,klev), zqsats(klon,klev))
    1198       ALLOCATE(Tcontr(klon,klev), qcontr(klon,klev), qcontr2(klon,klev), fcontrN(klon,klev), fcontrP(klon,klev))
    1199 
    1200 !--POPRECIP variables
    1201       ALLOCATE(qraindiag(klon,klev), qsnowdiag(klon,klev))
    1202       ALLOCATE(dqreva(klon,klev), dqssub(klon,klev))
    1203       ALLOCATE(dqrauto(klon,klev), dqrcol(klon,klev), dqrmelt(klon,klev), dqrfreez(klon,klev))
    1204       ALLOCATE(dqsauto(klon,klev), dqsagg(klon,klev), dqsrim(klon,klev), dqsmelt(klon,klev), dqsfreez(klon,klev))
    1205 
    1206 #ifdef CPP_StratAer
    1207       ALLOCATE (d_q_emiss(klon,klev))
    1208       ALLOCATE (R2SO4(klon,klev))
    1209       ALLOCATE (DENSO4(klon,klev))
    1210       ALLOCATE (f_r_wet(klon,klev))
    1211       ALLOCATE (decfluxaer(klon,nbtr))
     1187    ALLOCATE (p_tropopause(klon))
     1188    ALLOCATE (z_tropopause(klon))
     1189    ALLOCATE (t_tropopause(klon))
     1190
     1191    ALLOCATE(zn2mout(klon, 6))
     1192
     1193    ! Supersaturation
     1194    ALLOCATE(rneb_seri(klon, klev))
     1195    ALLOCATE(d_rneb_dyn(klon, klev))
     1196    ALLOCATE(qclr(klon, klev), qcld(klon, klev), qss(klon, klev), qvc(klon, klev))
     1197    ALLOCATE(rnebclr(klon, klev), rnebss(klon, klev), gamma_ss(klon, klev))
     1198    ALLOCATE(N1_ss(klon, klev), N2_ss(klon, klev))
     1199    ALLOCATE(drneb_sub(klon, klev), drneb_con(klon, klev), drneb_tur(klon, klev), drneb_avi(klon, klev))
     1200    ALLOCATE(zqsatl(klon, klev), zqsats(klon, klev))
     1201    ALLOCATE(Tcontr(klon, klev), qcontr(klon, klev), qcontr2(klon, klev), fcontrN(klon, klev), fcontrP(klon, klev))
     1202
     1203    !--POPRECIP variables
     1204    ALLOCATE(qraindiag(klon, klev), qsnowdiag(klon, klev))
     1205    ALLOCATE(dqreva(klon, klev), dqssub(klon, klev))
     1206    ALLOCATE(dqrauto(klon, klev), dqrcol(klon, klev), dqrmelt(klon, klev), dqrfreez(klon, klev))
     1207    ALLOCATE(dqsauto(klon, klev), dqsagg(klon, klev), dqsrim(klon, klev), dqsmelt(klon, klev), dqsfreez(klon, klev))
     1208
     1209    IF (CPPKEY_STRATAER) THEN
     1210      ALLOCATE (d_q_emiss(klon, klev))
     1211      ALLOCATE (R2SO4(klon, klev))
     1212      ALLOCATE (DENSO4(klon, klev))
     1213      ALLOCATE (f_r_wet(klon, klev))
     1214      ALLOCATE (decfluxaer(klon, nbtr))
    12121215      ALLOCATE (mdw(nbtr))
    1213       ALLOCATE (budg_3D_nucl(klon,klev))
    1214       ALLOCATE (budg_3D_cond_evap(klon,klev))
    1215       ALLOCATE (budg_3D_ocs_to_so2(klon,klev))
    1216       ALLOCATE (budg_3D_so2_to_h2so4(klon,klev))
    1217       ALLOCATE (budg_3D_backgr_ocs(klon,klev))
    1218       ALLOCATE (budg_3D_backgr_so2(klon,klev))
    1219       ALLOCATE (OCS_lifetime(klon,klev))
    1220       ALLOCATE (SO2_lifetime(klon,klev))
    1221       ALLOCATE (H2SO4_lifetime(klon,klev))
    1222       ALLOCATE (O3_clim(klon,klev))
    1223       ALLOCATE (alpha_bin(nbands_sw_rrtm+nbands_lw_rrtm+nwave,nbtr))
    1224       ALLOCATE (piz_bin(nbands_sw_rrtm+nbands_lw_rrtm+nwave,nbtr))
    1225       ALLOCATE (cg_bin(nbands_sw_rrtm+nbands_lw_rrtm+nwave,nbtr))
    1226       ALLOCATE (tau_strat_550(klon,klev))
    1227       ALLOCATE (tau_strat_1020(klon,klev))
    1228       ALLOCATE (tausum_strat(klon,3))
     1216      ALLOCATE (budg_3D_nucl(klon, klev))
     1217      ALLOCATE (budg_3D_cond_evap(klon, klev))
     1218      ALLOCATE (budg_3D_ocs_to_so2(klon, klev))
     1219      ALLOCATE (budg_3D_so2_to_h2so4(klon, klev))
     1220      ALLOCATE (budg_3D_backgr_ocs(klon, klev))
     1221      ALLOCATE (budg_3D_backgr_so2(klon, klev))
     1222      ALLOCATE (OCS_lifetime(klon, klev))
     1223      ALLOCATE (SO2_lifetime(klon, klev))
     1224      ALLOCATE (H2SO4_lifetime(klon, klev))
     1225      ALLOCATE (O3_clim(klon, klev))
     1226      ALLOCATE (alpha_bin(nbands_sw_rrtm + nbands_lw_rrtm + nwave, nbtr))
     1227      ALLOCATE (piz_bin(nbands_sw_rrtm + nbands_lw_rrtm + nwave, nbtr))
     1228      ALLOCATE (cg_bin(nbands_sw_rrtm + nbands_lw_rrtm + nwave, nbtr))
     1229      ALLOCATE (tau_strat_550(klon, klev))
     1230      ALLOCATE (tau_strat_1020(klon, klev))
     1231      ALLOCATE (tausum_strat(klon, 3))
    12291232      ALLOCATE (budg_dep_dry_ocs(klon))
    12301233      ALLOCATE (budg_dep_wet_ocs(klon))
     
    12441247      ALLOCATE (budg_sed_part(klon))
    12451248      ALLOCATE (surf_PM25_sulf(klon))
    1246       ALLOCATE (vsed_aer(klon,klev))
    1247 #endif
    1248 
    1249 END SUBROUTINE phys_local_var_init
    1250 
    1251 !======================================================================
    1252 SUBROUTINE phys_local_var_end
    1253 USE dimphy
    1254 USE indice_sol_mod
    1255 IMPLICIT NONE
    1256       DEALLOCATE(t_seri,q_seri,ql_seri,qs_seri, qbs_seri,qx_seri)
    1257       DEALLOCATE(u_seri,v_seri)
    1258       DEALLOCATE(l_mixmin,l_mix,wprime)
    1259       DEALLOCATE(tke_shear,tke_buoy,tke_trans)
    1260       DEALLOCATE(pbl_eps)
    1261       DEALLOCATE(rhcl)
    1262       DEALLOCATE(tr_seri)
    1263       DEALLOCATE(d_t_dyn,d_q_dyn)
    1264       DEALLOCATE(d_ql_dyn,d_qs_dyn, d_qbs_dyn)
    1265       DEALLOCATE(d_q_dyn2d,d_ql_dyn2d,d_qs_dyn2d, d_qbs_dyn2d)
    1266       DEALLOCATE(d_u_dyn,d_v_dyn)
    1267       DEALLOCATE(d_tr_dyn)                      !RomP
    1268       DEALLOCATE(d_t_con,d_q_con,d_q_con_zmasse)
    1269       DEALLOCATE(d_u_con,d_v_con)
    1270       DEALLOCATE(d_t_wake,d_q_wake)
    1271       DEALLOCATE(d_t_lsc,d_q_lsc)
    1272       DEALLOCATE(d_t_lwr,d_t_lw0)
    1273       DEALLOCATE(d_t_swr,d_t_sw0)
    1274       DEALLOCATE(d_ql_lsc,d_qi_lsc)
    1275       DEALLOCATE(d_t_ajsb,d_q_ajsb)
    1276       DEALLOCATE(d_t_ajs,d_q_ajs)
    1277 !nrlmd<
    1278       DEALLOCATE(d_t_ajs_w,d_q_ajs_w)
    1279       DEALLOCATE(d_t_ajs_x,d_q_ajs_x)
    1280 !>nrlmd
    1281       DEALLOCATE(d_u_ajs,d_v_ajs)
    1282       DEALLOCATE(d_t_eva,d_q_eva)
    1283       DEALLOCATE(d_qx_eva)
    1284       DEALLOCATE(d_ql_eva,d_qi_eva)
    1285       DEALLOCATE(d_t_lscst,d_q_lscst)
    1286       DEALLOCATE(d_t_lscth,d_q_lscth)
    1287       DEALLOCATE(plul_st,plul_th)
    1288       DEALLOCATE(d_t_vdf,d_q_vdf,d_t_diss)
    1289       DEALLOCATE(d_qbs_vdf)
    1290       DEALLOCATE(d_t_bsss,d_q_bsss,d_qbs_bsss)
     1249      ALLOCATE (vsed_aer(klon, klev))
     1250    END IF
     1251
     1252  END SUBROUTINE phys_local_var_init
     1253
     1254  !======================================================================
     1255  SUBROUTINE phys_local_var_end
     1256    USE dimphy
     1257    USE indice_sol_mod
     1258    IMPLICIT NONE
     1259    DEALLOCATE(t_seri, q_seri, ql_seri, qs_seri, qbs_seri, qx_seri)
     1260    DEALLOCATE(u_seri, v_seri)
     1261    DEALLOCATE(l_mixmin, l_mix, wprime)
     1262    DEALLOCATE(tke_shear, tke_buoy, tke_trans)
     1263    DEALLOCATE(pbl_eps)
     1264    DEALLOCATE(rhcl)
     1265    DEALLOCATE(tr_seri)
     1266    DEALLOCATE(d_t_dyn, d_q_dyn)
     1267    DEALLOCATE(d_ql_dyn, d_qs_dyn, d_qbs_dyn)
     1268    DEALLOCATE(d_q_dyn2d, d_ql_dyn2d, d_qs_dyn2d, d_qbs_dyn2d)
     1269    DEALLOCATE(d_u_dyn, d_v_dyn)
     1270    DEALLOCATE(d_tr_dyn)                      !RomP
     1271    DEALLOCATE(d_t_con, d_q_con, d_q_con_zmasse)
     1272    DEALLOCATE(d_u_con, d_v_con)
     1273    DEALLOCATE(d_t_wake, d_q_wake)
     1274    DEALLOCATE(d_t_lsc, d_q_lsc)
     1275    DEALLOCATE(d_t_lwr, d_t_lw0)
     1276    DEALLOCATE(d_t_swr, d_t_sw0)
     1277    DEALLOCATE(d_ql_lsc, d_qi_lsc)
     1278    DEALLOCATE(d_t_ajsb, d_q_ajsb)
     1279    DEALLOCATE(d_t_ajs, d_q_ajs)
     1280    !nrlmd<
     1281    DEALLOCATE(d_t_ajs_w, d_q_ajs_w)
     1282    DEALLOCATE(d_t_ajs_x, d_q_ajs_x)
     1283    !>nrlmd
     1284    DEALLOCATE(d_u_ajs, d_v_ajs)
     1285    DEALLOCATE(d_t_eva, d_q_eva)
     1286    DEALLOCATE(d_qx_eva)
     1287    DEALLOCATE(d_ql_eva, d_qi_eva)
     1288    DEALLOCATE(d_t_lscst, d_q_lscst)
     1289    DEALLOCATE(d_t_lscth, d_q_lscth)
     1290    DEALLOCATE(plul_st, plul_th)
     1291    DEALLOCATE(d_t_vdf, d_q_vdf, d_t_diss)
     1292    DEALLOCATE(d_qbs_vdf)
     1293    DEALLOCATE(d_t_bsss, d_q_bsss, d_qbs_bsss)
    12911294#ifdef ISO
    12921295      deallocate(xt_seri,xtl_seri,xts_seri,xtbs_seri)
     
    13111314#endif
    13121315
    1313       DEALLOCATE(d_u_vdf,d_v_vdf)
    1314       DEALLOCATE(d_t_oli,d_t_oro)
    1315       DEALLOCATE(d_u_oli,d_v_oli)
    1316       DEALLOCATE(d_u_oro,d_v_oro)
    1317       DEALLOCATE(d_t_oro_gw)
    1318       DEALLOCATE(d_u_oro_gw,d_v_oro_gw)
    1319       DEALLOCATE(d_t_lif,d_t_ec)
    1320       DEALLOCATE(d_u_lif,d_v_lif)
    1321       DEALLOCATE(d_ts, d_tr)
    1322       DEALLOCATE(topswad_aero,solswad_aero)
    1323       DEALLOCATE(topswai_aero,solswai_aero)
    1324       DEALLOCATE(topswad0_aero,solswad0_aero)
    1325       DEALLOCATE(toplwad_aero,sollwad_aero)
    1326       DEALLOCATE(toplwai_aero,sollwai_aero)
    1327       DEALLOCATE(toplwad0_aero,sollwad0_aero)
    1328       DEALLOCATE(topsw_aero,solsw_aero)
    1329       DEALLOCATE(topsw0_aero,solsw0_aero)
    1330       DEALLOCATE(topswcf_aero,solswcf_aero)
    1331       DEALLOCATE(stratomask)
    1332       DEALLOCATE(tausum_aero)
    1333       DEALLOCATE(drytausum_aero)
    1334       DEALLOCATE(tau3d_aero)
    1335       DEALLOCATE(dNovrN)
    1336       DEALLOCATE(zfice)
    1337       DEALLOCATE(od443aer)
    1338       DEALLOCATE(od550aer)
    1339       DEALLOCATE(od865aer)
    1340       DEALLOCATE(dryod550aer)
    1341       DEALLOCATE(abs550aer)
    1342       DEALLOCATE(ec550aer)
    1343       DEALLOCATE(od550lt1aer)
    1344       DEALLOCATE(sconcso4)
    1345       DEALLOCATE(sconcno3)
    1346       DEALLOCATE(sconcoa)
    1347       DEALLOCATE(sconcbc)
    1348       DEALLOCATE(sconcss)
    1349       DEALLOCATE(sconcdust)
    1350       DEALLOCATE(concso4)
    1351       DEALLOCATE(concno3)
    1352       DEALLOCATE(concoa)
    1353       DEALLOCATE(concbc)
    1354       DEALLOCATE(concss)
    1355       DEALLOCATE(concdust)
    1356       DEALLOCATE(loadso4)
    1357       DEALLOCATE(loadoa)
    1358       DEALLOCATE(loadbc)
    1359       DEALLOCATE(loadss)
    1360       DEALLOCATE(loaddust)
    1361       DEALLOCATE(loadno3)
    1362       DEALLOCATE(load_tmp1)
    1363       DEALLOCATE(load_tmp2)
    1364       DEALLOCATE(load_tmp3)
    1365       DEALLOCATE(load_tmp4)
    1366       DEALLOCATE(load_tmp5)
    1367       DEALLOCATE(load_tmp6)
    1368       DEALLOCATE(load_tmp7)
    1369       DEALLOCATE(load_tmp8)
    1370       DEALLOCATE(load_tmp9)
    1371       DEALLOCATE(load_tmp10)
    1372       DEALLOCATE(du_gwd_hines,dv_gwd_hines,d_t_hin)
    1373       DEALLOCATE(d_q_ch4)
    1374       DEALLOCATE(dv_gwd_rando,dv_gwd_front)
    1375       DEALLOCATE(east_gwstress,west_gwstress)
    1376 
    1377 !IM ajout variables CFMIP2/CMIP5
    1378       DEALLOCATE(topswad_aerop, solswad_aerop)
    1379       DEALLOCATE(topswai_aerop, solswai_aerop)
    1380       DEALLOCATE(topswad0_aerop, solswad0_aerop)
    1381       DEALLOCATE(topsw_aerop, topsw0_aerop)
    1382       DEALLOCATE(solsw_aerop, solsw0_aerop)
    1383       DEALLOCATE(topswcf_aerop, solswcf_aerop)
    1384 !AI Aerosols
    1385       DEALLOCATE(m_allaer)
    1386 !CK LW diagnostics
    1387       DEALLOCATE(toplwad_aerop, sollwad_aerop)
    1388       DEALLOCATE(toplwai_aerop, sollwai_aerop)
    1389       DEALLOCATE(toplwad0_aerop, sollwad0_aerop)
    1390 
    1391 !AI Ajout pour Ecrad (3Deffect)
    1392       DEALLOCATE(topswad_aero_s2, solswad_aero_s2)
    1393       DEALLOCATE(topswai_aero_s2, solswai_aero_s2)
    1394       DEALLOCATE(topswad0_aero_s2, solswad0_aero_s2)
    1395       DEALLOCATE(topsw_aero_s2, topsw0_aero_s2)
    1396       DEALLOCATE(solsw_aero_s2, solsw0_aero_s2)
    1397       DEALLOCATE(topswcf_aero_s2, solswcf_aero_s2)
    1398 !CK LW diagnostics
    1399       DEALLOCATE(toplwad_aero_s2, sollwad_aero_s2)
    1400       DEALLOCATE(toplwai_aero_s2, sollwai_aero_s2)
    1401       DEALLOCATE(toplwad0_aero_s2, sollwad0_aero_s2)     
    1402 
    1403 ! FH Ajout de celles necessaires au phys_output_write_mod
    1404       DEALLOCATE(tal1, pal1, pab1, pab2)
    1405       DEALLOCATE(ptstar, pt0, slp)
    1406 !
    1407       DEALLOCATE(alp_wake)
    1408       DEALLOCATE(wake_h,wake_k)
    1409       DEALLOCATE(wake_omg)
    1410       DEALLOCATE(d_deltat_wk, d_deltaq_wk)
    1411       DEALLOCATE(d_s_wk, d_dens_a_wk, d_dens_wk)
    1412       DEALLOCATE(d_deltat_wk_gw, d_deltaq_wk_gw)
    1413       DEALLOCATE(d_deltat_vdf, d_deltaq_vdf)
    1414 !!      DEALLOCATE( d_s_vdf, d_dens_vdf)
    1415       DEALLOCATE(d_deltat_the, d_deltaq_the)
    1416 !!      DEALLOCATE( d_s_the, d_dens_the)
    1417       DEALLOCATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
     1316    DEALLOCATE(d_u_vdf, d_v_vdf)
     1317    DEALLOCATE(d_t_oli, d_t_oro)
     1318    DEALLOCATE(d_u_oli, d_v_oli)
     1319    DEALLOCATE(d_u_oro, d_v_oro)
     1320    DEALLOCATE(d_t_oro_gw)
     1321    DEALLOCATE(d_u_oro_gw, d_v_oro_gw)
     1322    DEALLOCATE(d_t_lif, d_t_ec)
     1323    DEALLOCATE(d_u_lif, d_v_lif)
     1324    DEALLOCATE(d_ts, d_tr)
     1325    DEALLOCATE(topswad_aero, solswad_aero)
     1326    DEALLOCATE(topswai_aero, solswai_aero)
     1327    DEALLOCATE(topswad0_aero, solswad0_aero)
     1328    DEALLOCATE(toplwad_aero, sollwad_aero)
     1329    DEALLOCATE(toplwai_aero, sollwai_aero)
     1330    DEALLOCATE(toplwad0_aero, sollwad0_aero)
     1331    DEALLOCATE(topsw_aero, solsw_aero)
     1332    DEALLOCATE(topsw0_aero, solsw0_aero)
     1333    DEALLOCATE(topswcf_aero, solswcf_aero)
     1334    DEALLOCATE(stratomask)
     1335    DEALLOCATE(tausum_aero)
     1336    DEALLOCATE(drytausum_aero)
     1337    DEALLOCATE(tau3d_aero)
     1338    DEALLOCATE(dNovrN)
     1339    DEALLOCATE(zfice)
     1340    DEALLOCATE(od443aer)
     1341    DEALLOCATE(od550aer)
     1342    DEALLOCATE(od865aer)
     1343    DEALLOCATE(dryod550aer)
     1344    DEALLOCATE(abs550aer)
     1345    DEALLOCATE(ec550aer)
     1346    DEALLOCATE(od550lt1aer)
     1347    DEALLOCATE(sconcso4)
     1348    DEALLOCATE(sconcno3)
     1349    DEALLOCATE(sconcoa)
     1350    DEALLOCATE(sconcbc)
     1351    DEALLOCATE(sconcss)
     1352    DEALLOCATE(sconcdust)
     1353    DEALLOCATE(concso4)
     1354    DEALLOCATE(concno3)
     1355    DEALLOCATE(concoa)
     1356    DEALLOCATE(concbc)
     1357    DEALLOCATE(concss)
     1358    DEALLOCATE(concdust)
     1359    DEALLOCATE(loadso4)
     1360    DEALLOCATE(loadoa)
     1361    DEALLOCATE(loadbc)
     1362    DEALLOCATE(loadss)
     1363    DEALLOCATE(loaddust)
     1364    DEALLOCATE(loadno3)
     1365    DEALLOCATE(load_tmp1)
     1366    DEALLOCATE(load_tmp2)
     1367    DEALLOCATE(load_tmp3)
     1368    DEALLOCATE(load_tmp4)
     1369    DEALLOCATE(load_tmp5)
     1370    DEALLOCATE(load_tmp6)
     1371    DEALLOCATE(load_tmp7)
     1372    DEALLOCATE(load_tmp8)
     1373    DEALLOCATE(load_tmp9)
     1374    DEALLOCATE(load_tmp10)
     1375    DEALLOCATE(du_gwd_hines, dv_gwd_hines, d_t_hin)
     1376    DEALLOCATE(d_q_ch4)
     1377    DEALLOCATE(dv_gwd_rando, dv_gwd_front)
     1378    DEALLOCATE(east_gwstress, west_gwstress)
     1379
     1380    !IM ajout variables CFMIP2/CMIP5
     1381    DEALLOCATE(topswad_aerop, solswad_aerop)
     1382    DEALLOCATE(topswai_aerop, solswai_aerop)
     1383    DEALLOCATE(topswad0_aerop, solswad0_aerop)
     1384    DEALLOCATE(topsw_aerop, topsw0_aerop)
     1385    DEALLOCATE(solsw_aerop, solsw0_aerop)
     1386    DEALLOCATE(topswcf_aerop, solswcf_aerop)
     1387    !AI Aerosols
     1388    DEALLOCATE(m_allaer)
     1389    !CK LW diagnostics
     1390    DEALLOCATE(toplwad_aerop, sollwad_aerop)
     1391    DEALLOCATE(toplwai_aerop, sollwai_aerop)
     1392    DEALLOCATE(toplwad0_aerop, sollwad0_aerop)
     1393
     1394    !AI Ajout pour Ecrad (3Deffect)
     1395    DEALLOCATE(topswad_aero_s2, solswad_aero_s2)
     1396    DEALLOCATE(topswai_aero_s2, solswai_aero_s2)
     1397    DEALLOCATE(topswad0_aero_s2, solswad0_aero_s2)
     1398    DEALLOCATE(topsw_aero_s2, topsw0_aero_s2)
     1399    DEALLOCATE(solsw_aero_s2, solsw0_aero_s2)
     1400    DEALLOCATE(topswcf_aero_s2, solswcf_aero_s2)
     1401    !CK LW diagnostics
     1402    DEALLOCATE(toplwad_aero_s2, sollwad_aero_s2)
     1403    DEALLOCATE(toplwai_aero_s2, sollwai_aero_s2)
     1404    DEALLOCATE(toplwad0_aero_s2, sollwad0_aero_s2)
     1405
     1406    ! FH Ajout de celles necessaires au phys_output_write_mod
     1407    DEALLOCATE(tal1, pal1, pab1, pab2)
     1408    DEALLOCATE(ptstar, pt0, slp)
     1409    !
     1410    DEALLOCATE(alp_wake)
     1411    DEALLOCATE(wake_h, wake_k)
     1412    DEALLOCATE(wake_omg)
     1413    DEALLOCATE(d_deltat_wk, d_deltaq_wk)
     1414    DEALLOCATE(d_s_wk, d_dens_a_wk, d_dens_wk)
     1415    DEALLOCATE(d_deltat_wk_gw, d_deltaq_wk_gw)
     1416    DEALLOCATE(d_deltat_vdf, d_deltaq_vdf)
     1417    !!      DEALLOCATE( d_s_vdf, d_dens_vdf)
     1418    DEALLOCATE(d_deltat_the, d_deltaq_the)
     1419    !!      DEALLOCATE( d_s_the, d_dens_the)
     1420    DEALLOCATE(d_deltat_ajs_cv, d_deltaq_ajs_cv)
    14181421#ifdef ISO
    14191422      DEALLOCATE(d_deltaxt_wk)
     
    14221425      DEALLOCATE(d_deltaxt_vdf)
    14231426#endif
    1424 !
    1425       DEALLOCATE(bils)
    1426       DEALLOCATE(cdragm, cdragh, cldh, cldl)
    1427       DEALLOCATE(cldm, cldq, cldt, qsat2m)
    1428       DEALLOCATE(JrNt)
    1429       DEALLOCATE(dthmin, evap, snowerosion, fder, plcl, plfc)
    1430       DEALLOCATE(prw, prlw, prsw, prbsw, water_budget, zustar, zu10m, zv10m, rh2m, s_lcl)
    1431       DEALLOCATE(s_pblh, s_pblt, s_therm)
    1432 !
    1433 !nrlmd+jyg<
    1434       DEALLOCATE(s_pblh_x, s_pblh_w)
    1435       DEALLOCATE(s_lcl_x, s_lcl_w)
    1436 !>nrlmd+jyg
    1437 !
    1438       DEALLOCATE(slab_wfbils, tpot, tpote, ue)
    1439       DEALLOCATE(uq, ve, vq, zxffonte)
    1440       DEALLOCATE(uwat, vwat)
    1441       DEALLOCATE(zxfqcalving, zxfluxlat)
    1442       DEALLOCATE(zxrunofflic)
    1443       DEALLOCATE(zxustartlic, zxrhoslic, zxqsaltlic)
    1444       DEALLOCATE(zxtsol, snow_lsc, zxfqfonte, zxqsurf)
    1445       DEALLOCATE(rain_lsc)
    1446       DEALLOCATE(rain_num)
    1447       DEALLOCATE(qlth, qith, qsith, wiceth)
    1448 !
    1449       DEALLOCATE(sens_x, sens_w)
    1450       DEALLOCATE(zxfluxlat_x, zxfluxlat_w)
    1451       DEALLOCATE(delta_qsurf)
    1452 !jyg<
    1453 !!      DEALLOCATE(t_x, t_w)
    1454 !!      DEALLOCATE(q_x, q_w)
    1455 !>jyg
    1456       DEALLOCATE(d_t_vdf_x, d_t_vdf_w)
    1457       DEALLOCATE(d_q_vdf_x, d_q_vdf_w)
    1458       DEALLOCATE(pbl_tke_input)
    1459       DEALLOCATE(t_therm, q_therm, u_therm, v_therm)
    1460       DEALLOCATE(cdragh_x, cdragh_w)
    1461       DEALLOCATE(cdragm_x, cdragm_w)
    1462       DEALLOCATE(kh, kh_x, kh_w)
     1427    !
     1428    DEALLOCATE(bils)
     1429    DEALLOCATE(cdragm, cdragh, cldh, cldl)
     1430    DEALLOCATE(cldm, cldq, cldt, qsat2m)
     1431    DEALLOCATE(JrNt)
     1432    DEALLOCATE(dthmin, evap, snowerosion, fder, plcl, plfc)
     1433    DEALLOCATE(prw, prlw, prsw, prbsw, water_budget, zustar, zu10m, zv10m, rh2m, s_lcl)
     1434    DEALLOCATE(s_pblh, s_pblt, s_therm)
     1435    !
     1436    !nrlmd+jyg<
     1437    DEALLOCATE(s_pblh_x, s_pblh_w)
     1438    DEALLOCATE(s_lcl_x, s_lcl_w)
     1439    !>nrlmd+jyg
     1440    !
     1441    DEALLOCATE(slab_wfbils, tpot, tpote, ue)
     1442    DEALLOCATE(uq, ve, vq, zxffonte)
     1443    DEALLOCATE(uwat, vwat)
     1444    DEALLOCATE(zxfqcalving, zxfluxlat)
     1445    DEALLOCATE(zxrunofflic)
     1446    DEALLOCATE(zxustartlic, zxrhoslic, zxqsaltlic)
     1447    DEALLOCATE(zxtsol, snow_lsc, zxfqfonte, zxqsurf)
     1448    DEALLOCATE(rain_lsc)
     1449    DEALLOCATE(rain_num)
     1450    DEALLOCATE(qlth, qith, qsith, wiceth)
     1451    !
     1452    DEALLOCATE(sens_x, sens_w)
     1453    DEALLOCATE(zxfluxlat_x, zxfluxlat_w)
     1454    DEALLOCATE(delta_qsurf)
     1455    !jyg<
     1456    !!      DEALLOCATE(t_x, t_w)
     1457    !!      DEALLOCATE(q_x, q_w)
     1458    !>jyg
     1459    DEALLOCATE(d_t_vdf_x, d_t_vdf_w)
     1460    DEALLOCATE(d_q_vdf_x, d_q_vdf_w)
     1461    DEALLOCATE(pbl_tke_input)
     1462    DEALLOCATE(t_therm, q_therm, u_therm, v_therm)
     1463    DEALLOCATE(cdragh_x, cdragh_w)
     1464    DEALLOCATE(cdragm_x, cdragm_w)
     1465    DEALLOCATE(kh, kh_x, kh_w)
    14631466#ifdef ISO
    14641467      DEALLOCATE(xtevap,xtprw)
     
    14711474      DEALLOCATE(h1_diag,runoff_diag,xtrunoff_diag)
    14721475#endif
    1473 !
    1474       DEALLOCATE(ptconv)
    1475       DEALLOCATE(ratqsc)
    1476 !
    1477       DEALLOCATE(wbeff, convoccur, zmax_th)
    1478       DEALLOCATE(zq2m, zt2m, weak_inversion)
    1479       DEALLOCATE(zt2m_min_mon, zt2m_max_mon)
    1480       DEALLOCATE(t2m_min_mon, t2m_max_mon)
    1481       DEALLOCATE(sens, flwp, fiwp)
    1482       DEALLOCATE(alp_bl_conv,alp_bl_det)
    1483       DEALLOCATE(alp_bl_fluct_m,alp_bl_fluct_tke)
    1484       DEALLOCATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
    1485       DEALLOCATE(proba_notrig, random_notrig)
    1486 !FC
    1487       DEALLOCATE(zxfluxq,zxfluxt)
    1488 
    1489       DEALLOCATE(dnwd0)
    1490 !      DEALLOCATE(upwd, omega, coefh)
    1491       DEALLOCATE(omega)
    1492       DEALLOCATE(epmax_diag)
    1493 !      DEALLOCATE(coefm, lambda_th, cldemi)
    1494       DEALLOCATE(lambda_th, cldemi)
    1495       DEALLOCATE(cldfra, cldtau, fiwc)
    1496       DEALLOCATE(fl, re, flwc)
    1497       DEALLOCATE(ref_liq, ref_ice, theta)
    1498       DEALLOCATE(ref_liq_pi, ref_ice_pi)
    1499       DEALLOCATE(zphi, zx_rh, zx_rhl, zx_rhi)
    1500       DEALLOCATE(pmfd, pmfu)
    1501 
    1502       DEALLOCATE(t2m, fluxlat)
    1503       DEALLOCATE(fsollw, evap_pot)
    1504       DEALLOCATE(fsolsw, wfbils)
    1505       DEALLOCATE(wfevap)
    1506 
    1507       DEALLOCATE(pmflxr, pmflxs)
    1508       DEALLOCATE(wdtrainA, wdtrainS, wdtrainM)
    1509       DEALLOCATE(upwd, dnwd)
    1510       DEALLOCATE(ep)
    1511       DEALLOCATE(da, mp)
    1512       DEALLOCATE(phi)
    1513       DEALLOCATE(wght_cvfd)
    1514       DEALLOCATE(phi2)
    1515       DEALLOCATE(d1a, dam)
    1516       DEALLOCATE(ev)
    1517       DEALLOCATE(elij)
    1518       DEALLOCATE(qtaa)
    1519       DEALLOCATE(clw)
    1520       DEALLOCATE(epmlmMm, eplaMm)
    1521       DEALLOCATE(sij)
     1476    !
     1477    DEALLOCATE(ptconv)
     1478    DEALLOCATE(ratqsc)
     1479    !
     1480    DEALLOCATE(wbeff, convoccur, zmax_th)
     1481    DEALLOCATE(zq2m, zt2m, weak_inversion)
     1482    DEALLOCATE(zt2m_min_mon, zt2m_max_mon)
     1483    DEALLOCATE(t2m_min_mon, t2m_max_mon)
     1484    DEALLOCATE(sens, flwp, fiwp)
     1485    DEALLOCATE(alp_bl_conv, alp_bl_det)
     1486    DEALLOCATE(alp_bl_fluct_m, alp_bl_fluct_tke)
     1487    DEALLOCATE(alp_bl_stat, n2, s2, strig, zcong, zlcl_th)
     1488    DEALLOCATE(proba_notrig, random_notrig)
     1489    !FC
     1490    DEALLOCATE(zxfluxq, zxfluxt)
     1491
     1492    DEALLOCATE(dnwd0)
     1493    !      DEALLOCATE(upwd, omega, coefh)
     1494    DEALLOCATE(omega)
     1495    DEALLOCATE(epmax_diag)
     1496    !      DEALLOCATE(coefm, lambda_th, cldemi)
     1497    DEALLOCATE(lambda_th, cldemi)
     1498    DEALLOCATE(cldfra, cldtau, fiwc)
     1499    DEALLOCATE(fl, re, flwc)
     1500    DEALLOCATE(ref_liq, ref_ice, theta)
     1501    DEALLOCATE(ref_liq_pi, ref_ice_pi)
     1502    DEALLOCATE(zphi, zx_rh, zx_rhl, zx_rhi)
     1503    DEALLOCATE(pmfd, pmfu)
     1504
     1505    DEALLOCATE(t2m, fluxlat)
     1506    DEALLOCATE(fsollw, evap_pot)
     1507    DEALLOCATE(fsolsw, wfbils)
     1508    DEALLOCATE(wfevap)
     1509
     1510    DEALLOCATE(pmflxr, pmflxs)
     1511    DEALLOCATE(wdtrainA, wdtrainS, wdtrainM)
     1512    DEALLOCATE(upwd, dnwd)
     1513    DEALLOCATE(ep)
     1514    DEALLOCATE(da, mp)
     1515    DEALLOCATE(phi)
     1516    DEALLOCATE(wght_cvfd)
     1517    DEALLOCATE(phi2)
     1518    DEALLOCATE(d1a, dam)
     1519    DEALLOCATE(ev)
     1520    DEALLOCATE(elij)
     1521    DEALLOCATE(qtaa)
     1522    DEALLOCATE(clw)
     1523    DEALLOCATE(epmlmMm, eplaMm)
     1524    DEALLOCATE(sij)
    15221525#ifdef ISO
    15231526      DEALLOCATE(xtwdtrainA)
     
    15451548
    15461549
    1547       DEALLOCATE(prfl, psfl, bsfl, fraca, Vprecip)
    1548       DEALLOCATE(zw2)
    1549 
    1550       DEALLOCATE(fluxu, fluxv)
    1551       DEALLOCATE(fluxt)
    1552 
    1553       DEALLOCATE(uwriteSTD, vwriteSTD)
    1554       DEALLOCATE(wwriteSTD, phiwriteSTD)
    1555       DEALLOCATE(qwriteSTD, twriteSTD, rhwriteSTD)
    1556 
    1557 ! ug et d'autres encore:
    1558       DEALLOCATE(beta_prec)
    1559       DEALLOCATE(rneb)
    1560       DEALLOCATE(pfraclr,pfracld)
    1561       DEALLOCATE(cldfraliq)
    1562       DEALLOCATE(sigma2_icefracturb)
    1563       DEALLOCATE(mean_icefracturb)
    1564       DEALLOCATE (zxsnow,snowhgt,qsnow,to_ice,sissnow,runoff,albsol3_lic)
    1565       DEALLOCATE(distcltop)
    1566       DEALLOCATE(temp_cltop)
     1550    DEALLOCATE(prfl, psfl, bsfl, fraca, Vprecip)
     1551    DEALLOCATE(zw2)
     1552
     1553    DEALLOCATE(fluxu, fluxv)
     1554    DEALLOCATE(fluxt)
     1555
     1556    DEALLOCATE(uwriteSTD, vwriteSTD)
     1557    DEALLOCATE(wwriteSTD, phiwriteSTD)
     1558    DEALLOCATE(qwriteSTD, twriteSTD, rhwriteSTD)
     1559
     1560    ! ug et d'autres encore:
     1561    DEALLOCATE(beta_prec)
     1562    DEALLOCATE(rneb)
     1563    DEALLOCATE(pfraclr, pfracld)
     1564    DEALLOCATE(cldfraliq)
     1565    DEALLOCATE(sigma2_icefracturb)
     1566    DEALLOCATE(mean_icefracturb)
     1567    DEALLOCATE (zxsnow, snowhgt, qsnow, to_ice, sissnow, runoff, albsol3_lic)
     1568    DEALLOCATE(distcltop)
     1569    DEALLOCATE(temp_cltop)
    15671570#ifdef ISO
    15681571      DEALLOCATE (zxxtsnow,xtVprecip,xtVprecipi,pxtrfl,pxtsfl)
    15691572#endif
    15701573
    1571       DEALLOCATE (p_tropopause)
    1572       DEALLOCATE (z_tropopause)
    1573       DEALLOCATE (t_tropopause)
    1574       DEALLOCATE(zn2mout)
    1575 
    1576 ! Supersaturation
    1577       DEALLOCATE(rneb_seri)
    1578       DEALLOCATE(d_rneb_dyn)
    1579       DEALLOCATE(qclr, qcld, qss, qvc)
    1580       DEALLOCATE(rnebclr, rnebss, gamma_ss)
    1581       DEALLOCATE(N1_ss, N2_ss)
    1582       DEALLOCATE(drneb_sub, drneb_con, drneb_tur, drneb_avi)
    1583       DEALLOCATE(zqsatl, zqsats)
    1584       DEALLOCATE(Tcontr, qcontr, qcontr2, fcontrN, fcontrP)
    1585 
    1586 !--POPRECIP variables
    1587       DEALLOCATE(qraindiag, qsnowdiag)
    1588       DEALLOCATE(dqreva, dqssub)
    1589       DEALLOCATE(dqrauto, dqrcol, dqrmelt, dqrfreez)
    1590       DEALLOCATE(dqsauto, dqsagg, dqsrim, dqsmelt, dqsfreez)
    1591 
    1592 #ifdef CPP_StratAer
    1593 ! variables for strat. aerosol CK
     1574    DEALLOCATE (p_tropopause)
     1575    DEALLOCATE (z_tropopause)
     1576    DEALLOCATE (t_tropopause)
     1577    DEALLOCATE(zn2mout)
     1578
     1579    ! Supersaturation
     1580    DEALLOCATE(rneb_seri)
     1581    DEALLOCATE(d_rneb_dyn)
     1582    DEALLOCATE(qclr, qcld, qss, qvc)
     1583    DEALLOCATE(rnebclr, rnebss, gamma_ss)
     1584    DEALLOCATE(N1_ss, N2_ss)
     1585    DEALLOCATE(drneb_sub, drneb_con, drneb_tur, drneb_avi)
     1586    DEALLOCATE(zqsatl, zqsats)
     1587    DEALLOCATE(Tcontr, qcontr, qcontr2, fcontrN, fcontrP)
     1588
     1589    !--POPRECIP variables
     1590    DEALLOCATE(qraindiag, qsnowdiag)
     1591    DEALLOCATE(dqreva, dqssub)
     1592    DEALLOCATE(dqrauto, dqrcol, dqrmelt, dqrfreez)
     1593    DEALLOCATE(dqsauto, dqsagg, dqsrim, dqsmelt, dqsfreez)
     1594
     1595    IF (CPPKEY_STRATAER) THEN
     1596      ! variables for strat. aerosol CK
    15941597      DEALLOCATE (d_q_emiss)
    15951598      DEALLOCATE (R2SO4)
     
    16321635      DEALLOCATE (budg_h2so4_to_part)
    16331636      DEALLOCATE (budg_sed_part)
    1634 #endif
    1635 
    1636 END SUBROUTINE phys_local_var_end
     1637    END IF
     1638
     1639  END SUBROUTINE phys_local_var_end
    16371640
    16381641END MODULE phys_local_var_mod
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/phys_output_ctrlout_mod.F90

    r5039 r5098  
    14401440    'flx_co2_land_cor', 'correction of the CO2 flux from the land', 'kg CO2 m-2 s-1', (/ ('', i=1, 10) /))
    14411441
    1442 #ifdef CPP_StratAer
    14431442!--extinction coefficient
    14441443  TYPE(ctrl_out), SAVE :: o_ext_strat_550 = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
     
    15111510  TYPE(ctrl_out), SAVE :: o_surf_PM25_sulf = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
    15121511    'surf_PM25_sulf', 'Sulfate PM2.5 concentration at the surface', 'ug/m3', (/ ('', i=1, 10) /))
    1513 #endif
    15141512
    15151513!!!!!!!!!!!!!!!!!!!!!! 3D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/phys_output_mod.F90

    r5082 r5098  
    77  USE phys_output_write_mod, ONLY : phys_output_write
    88  REAL, DIMENSION(nfiles),SAVE :: ecrit_files
     9  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
    910
    1011! Abderrahmane 12 2007
     
    228229    clef_files(8) = ok_histNMC(2)
    229230    clef_files(9) = ok_histNMC(3)
    230 #ifdef CPP_StratAer
    231     clef_files(10)= .TRUE.
    232 #else
    233     clef_files(10)= .FALSE.
    234 #endif
     231    clef_files(10)= CPPKEY_StratAer
    235232
    236233    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
  • LMDZ6/branches/Amaury_dev/libf/phylmdiso/physiq_mod.F90

    r5091 r5098  
    9595    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
    9696
     97    USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
     98    USE time_phylmdz_mod,  ONLY: ndays
     99    USE infotrac_phy,      ONLY: nqCO2
     100
     101    USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
     102    USE vertical_layers_mod, ONLY: aps, bps, ap, bp
     103
     104    USE lmdz_xios, ONLY: xios_update_calendar, xios_context_finalize, xios_get_field_attr, &
     105            xios_field_is_active, xios_context, xios_set_current_context
     106    USE wxios, ONLY: missing_val, using_xios
     107    USE paramLMDZ_phy_mod
     108
    97109
    98110    !USE cmp_seri_mod
     
    111123#endif
    112124
    113 
    114     USE geometry_mod,      ONLY: longitude, latitude, boundslon, boundslat, ind_cell_glo
    115     USE time_phylmdz_mod,  ONLY: ndays
    116     USE infotrac_phy,      ONLY: nqCO2
    117125#ifdef REPROBUS
    118126    USE chem_rep, ONLY: Init_chem_rep_xjour, d_q_rep, d_ql_rep, d_qi_rep, &
     
    121129    USE strataer_emiss_mod, ONLY: strataer_emiss_init
    122130#endif
    123     USE time_phylmdz_mod,    ONLY: annee_ref, day_ini, day_ref, start_time
    124     USE vertical_layers_mod, ONLY: aps, bps, ap, bp
    125 
    126131
    127132#ifdef CPP_RRTM
     
    131136
    132137
    133 #ifdef CPP_StratAer
    134138    USE phys_local_var_mod, ONLY: d_q_emiss
    135139    USE strataer_local_var_mod
    136140    USE strataer_nuc_mod, ONLY: strataer_nuc_init
    137141    USE strataer_emiss_mod, ONLY: strataer_emiss_init
    138 #endif
    139 
    140     USE lmdz_xios, ONLY: xios_update_calendar, xios_context_finalize
    141     USE lmdz_xios, ONLY: xios_get_field_attr, xios_field_is_active, xios_context
    142     USE lmdz_xios, ONLY: xios_set_current_context
    143     USE wxios, ONLY: missing_val, using_xios
    144 
    145 #ifndef CPP_XIOS
    146     USE paramLMDZ_phy_mod
    147 #endif
    148 
    149142
    150143#ifdef ISO
     
    15101503#endif
    15111504
    1512 #ifdef CPP_StratAer
     1505IF (CPPKEY_STRATAER) THEN
    15131506       CALL strataer_init
    15141507       CALL strataer_nuc_init
    15151508       CALL strataer_emiss_init
    1516 #endif
     1509END IF
    15171510
    15181511       print*, '================================================='
     
    19281921       WRITE(lunout,*)'OK freq_outNMC(3)=',freq_outNMC(3)
    19291922
    1930 #ifndef CPP_XIOS
     1923    IF (.NOT. using_xios) THEN
    19311924       CALL ini_paramLMDZ_phy(phys_tstep,nid_ctesGCM)
    1932 #endif
     1925END IF
    19331926
    19341927#endif
     
    58005793          ELSE
    58015794#ifdef CPP_RRTM
    5802 #ifndef CPP_StratAer
     5795IF (.NOT. CPPKEY_STRATAER) THEN
    58035796          !--prescribed strat aerosols
    58045797          !--only in the case of non-interactive strat aerosols
     
    58115804             CALL abort_physic(modname,abort_message,1)
    58125805            ENDIF
    5813 #endif
     5806END IF
    58145807#else
    58155808             abort_message='You should compile with -rrtm if running ' &
     
    58235816!
    58245817#ifdef CPP_RRTM
    5825 #ifdef CPP_StratAer
     5818IF (CPPKEY_STRATER) THEN
    58265819       !--compute stratospheric mask
    58275820       CALL stratosphere_mask(missing_val, pphis, t_seri, pplay, latitude_deg)
    58285821       !--interactive strat aerosols
    58295822       CALL calcaerosolstrato_rrtm(pplay,t_seri,paprs,debut)
    5830 #endif
     5823END IF
    58315824#endif
    58325825       !--fin STRAT AEROSOL
     
    64706463    IF (ok_qch4) THEN
    64716464!      d_q_ch4: H2O source from CH4 in MMR/s (mass mixing ratio/s or kg H2O/kg air/s)
    6472 #ifdef CPP_StratAer
     6465IF (CPPKEY_STRATER) THEN
    64736466       CALL stratH2O_methox(debut,paprs,d_q_ch4)
    6474 #else
     6467ELSE
    64756468!      ECMWF routine METHOX
    64766469       CALL METHOX(1,klon,klon,klev,q_seri,d_q_ch4,pplay)
    6477 #endif
     6470END IF
    64786471       ! add humidity tendency due to methane
    64796472       d_q_ch4_dtime(:,:) = d_q_ch4(:,:)*phys_tstep
     
    64946487    !
    64956488    !
    6496 #ifdef CPP_StratAer
     6489IF (CPPKEY_STRATER) THEN
    64976490    IF (ok_qemiss) THEN
    64986491       flh2o=1
     
    65376530       END SELECT ! emission scenario (flag_emit)
    65386531    ENDIF
    6539 #endif
     6532END IF
    65406533
    65416534!===============================================================
     
    69976990    ENDDO
    69986991
    6999 #ifdef CPP_StratAer
     6992IF (CPPKEY_STRATER) THEN
    70006993    IF (ok_qemiss) THEN
    70016994       DO k = 1, klev
     
    70036996       ENDDO
    70046997    ENDIF
    7005 #endif
     6998END IF
    70066999    IF (ok_qch4) THEN
    70077000       DO k = 1, klev
     
    73347327#endif
    73357328
    7336 #ifndef CPP_XIOS
     7329    IF (.NOT. using_xios) THEN
    73377330      CALL write_paramLMDZ_phy(itap,nid_ctesGCM,ok_sync)
    7338 #endif
     7331END IF
    73397332
    73407333#endif
  • LMDZ6/branches/Amaury_dev/makelmdz_fcm

    r5093 r5098  
    441441  fi
    442442
     443  STRATAER_PATH="$LIBFGCM/phy${physique}/StratAer"
    443444  if [[ $strataer = "true" ]]; then
    444445     CPP_KEY="$CPP_KEY CPP_StratAer"
    445      STRATAER_PATH="$LIBFGCM/phy${physique}/StratAer"
    446446  fi
    447447
Note: See TracChangeset for help on using the changeset viewer.