430,433c430,435
< !          CALL WRITEDIAGFI(ngridmx,'tauTES','tauabs IR refwvl',
< !     &      ' ',2,taucloudtes)
< !          CALL wstats(ngridmx,'tauTES','tauabs IR refwvl',
< !     &      ' ',2,taucloudtes)
---
>           CALL WRITEDIAGFI(ngridmx,'tauTES','tauabs IR refwvl',
>      &      ' ',2,taucloudtes)
>           IF (callstats) THEN
>             CALL wstats(ngridmx,'tauTES','tauabs IR refwvl',
>      &        ' ',2,taucloudtes)
>           ENDIF
1,2c1
<       SUBROUTINE dustlift(ngrid,nlay,nq,rho,
<      $                  pcdh_true,pcdh,co2ice,
---
>       SUBROUTINE dustlift(ngrid,nlay,nq,rho,pcdh_true,pcdh,co2ice,
45,66c44
< c      DATA stress_seuil/0.0225/   ! stress seuil soulevement (N.m2)
< !****WRF
< !****WRF: additional ASCII file to define dust opacity
<           REAL alpha
<           INTEGER ierr
<           OPEN(99,file='stress.def',status='old',form='formatted'
<      .     ,iostat=ierr)
<           IF(ierr.NE.0) THEN
<              stress_seuil = 0.0225
<              alpha = 1.
<              write(*,*) 'No file stress.def - set ', stress_seuil, alpha
<              !stop
<           ELSE
<              READ(99,*) stress_seuil
<              READ(99,*) alpha
<              write(*,*) 'definir seuil stress : ', stress_seuil, alpha
<              CLOSE(99)
<           ENDIF
<           alpha_lift(1) = alpha
< !****WRF
< !****WRF
< 
---
>       DATA stress_seuil/0.0225/   ! stress seuil soulevement (N.m2)
46c46,47
< #include "chimiedata.h"  
---
> #include "chimiedata.h"
> 
221d221
<             mmol(iq)=100.
367,370c367,370
<         if( (nqmx.lt.2).or.(water.and.(nqmx.lt.3)) ) then
<           write(*,*)'initracer: nqmx is too low : nqmx=', nqmx
<           write(*,*)'water= ',water,' doubleq= ',doubleq   
<         end if
---
> !        if( (nqmx.lt.2).or.(water.and.(nqmx.lt.3)) ) then
> !          write(*,*)'initracer: nqmx is too low : nqmx=', nqmx
> !          write(*,*)'water= ',water,' doubleq= ',doubleq   
> !        end if
404,411c404
<       else
< 
<        if (dustbin.gt.1) then
<         print*,'ATTENTION:',
<      $   ' properties of dust need input in initracer !!!'
<         stop
< 
<        else if (dustbin.eq.1) then
---
>       endif ! of if (doubleq)
412a406,408
>       if (dustbin.gt.0) then
>         if (dustbin.eq.1) then
> c
415,419c411,415
<         radius(igcm_dustbin(1))=3.e-6
<         Qext(igcm_dustbin(1))=3.04
<         alpha_lift(igcm_dustbin(1))=0.0e-6
<         alpha_devil(igcm_dustbin(1))=7.65e-9
<         qextrhor(igcm_dustbin(1))=(3./4.)*Qext(igcm_dustbin(1))
---
>           radius(igcm_dustbin(1))=3.e-6
>           Qext(igcm_dustbin(1))=3.04
>           alpha_lift(igcm_dustbin(1))=0.0e-6
>           alpha_devil(igcm_dustbin(1))=7.65e-9
>           qextrhor(igcm_dustbin(1))=(3./4.)*Qext(igcm_dustbin(1))
421,424c417,423
<         rho_q(igcm_dustbin(1))=rho_dust
< 
<        endif
<       end if    ! (doubleq)
---
>           rho_q(igcm_dustbin(1))=rho_dust
>         else
>           write(*,*) "initracer: properties of dust need to be set",
>      &              " in initracer !!!"
>           stop
>         endif ! of if (dustbin.eq.1)
>       endif ! of if (dustbin.gt.0)
438,439c437,438
<             qextrhor(iq)= 0.
<          endif
---
> 	    qextrhor(iq)= 0.
>           endif
450c449
<          qextrhor(igcm_h2o_vap)= 0.
---
> 	 qextrhor(igcm_h2o_vap)= 0.
513a513,649
> !
> !     some extra sanity checks for tracers: 
> !     ------------------------------------
> 
>        if (doubleq) then 
>        ! verify that we indeed have dust_mass and dust_number tracers 
>          if (igcm_dust_mass.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use doubleq option without ",
>      &                "a dust_mass tracer !"
>            stop
>          endif
>          if (igcm_dust_number.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use doubleq option without ",
>      &                "a dust_number tracer !"
>            stop
>          endif
>        endif
> 
>        if (dustbin.gt.0) then
>        ! verify that we indeed have 'dustbin' dust tracers
>          count=0
>          do iq=1,dustbin
>            if (igcm_dustbin(iq).ne.0) then
>              count=count+1
>            endif
>          enddo
>          if (count.ne.dustbin) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  dusbin is set to ",dustbin,
>      &                " but we only have the following dust tracers:"
>            do iq=1,count
>              write(*,*)"   ",trim(noms(igcm_dustbin(iq)))
>            enddo
>            stop
>          endif
>        endif
> 
>        if (water) then
>        ! verify that we indeed have h2o_vap and h2o_ice tracers
>          if (igcm_h2o_vap.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use water option without ",
>      &                "an h2o_vap tracer !"
>            stop
>          endif
>          if (igcm_h2o_ice.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use water option without ",
>      &                "an h2o_ice tracer !"
>            stop
>          endif
>        endif
> 
>        if (photochem .or. callthermos) then
>        ! verify that we indeed have the chemistry tracers
>          if (igcm_co2.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a co2 tracer !"
>          stop
>          endif
>          if (igcm_co.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a co tracer !"
>          stop
>          endif
>          if (igcm_o.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a o tracer !"
>          stop
>          endif
>          if (igcm_o1d.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a o1d tracer !"
>          stop
>          endif
>          if (igcm_o2.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "an o2 tracer !"
>          stop
>          endif
>          if (igcm_o3.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "an o3 tracer !"
>          stop
>          endif
>          if (igcm_h.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a h tracer !"
>          stop
>          endif
>          if (igcm_h2.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a h2 tracer !"
>          stop
>          endif
>          if (igcm_oh.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "an oh tracer !"
>          stop
>          endif
>          if (igcm_ho2.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a ho2 tracer !"
>          stop
>          endif
>          if (igcm_h2o2.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a h2o2 tracer !"
>          stop
>          endif
>          if (igcm_n2.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "a n2 tracer !"
>          stop
>          endif
>          if (igcm_ar.eq.0) then
>            write(*,*) "initracer: error !!"
>            write(*,*) "  cannot use chemistry option without ",
>      &                "an ar tracer !"
>          stop
>          endif
>        endif ! of if (photochem .or. callthermos)
> 
58,61c58,61
<       tab_cntrl(1)  = FLOAT(iim)
<       tab_cntrl(2)  = FLOAT(jjm)
<       tab_cntrl(3)  = FLOAT(llm)
<       tab_cntrl(4)  = FLOAT(idayref)
---
>       tab_cntrl(1)  = real(iim)
>       tab_cntrl(2)  = real(jjm)
>       tab_cntrl(3)  = real(llm)
>       tab_cntrl(4)  = real(idayref)
426c426
< 
---
>       
591a592,595
>   
> c           Tendencies on T, U, V, Q 
> c           """"""""""""""""""""""""
>             DO l=1,nlayer
593,619c597,615
< CCCC
< CCCC *** WRF comments
< CCCC
< c 
< cc           Tendencies on T, U, V, Q 
< cc           """"""""""""""""""""""""
< c            DO l=1,nlayer
< c 
< cc             Tendencies on T
< c                zdtsig(ig,l) = (1/masse(l)) *
< c     &        ( zmflux(l)*(ztm(l) - ztc(l)) 
< c     &        - zmflux(l+1)*(ztm(l+1) - ztc(l))
< c     &        + zcondicea(ig,l)*(ztcond(ig,l)-ztc(l))  )
< c                pdtc(ig,l) =  pdtc(ig,l) + zdtsig(ig,l)
< c
< cc             Tendencies on U
< c                pduc(ig,l)   = (1/masse(l)) *
< c     &        ( zmflux(l)*(zum(l) - zu(l))
< c     &        - zmflux(l+1)*(zum(l+1) - zu(l)) )
< c
< c
< cc             Tendencies on V
< c                pdvc(ig,l)   = (1/masse(l)) *
< c     &        ( zmflux(l)*(zvm(l) - zv(l))
< c     &        - zmflux(l+1)*(zvm(l+1) - zv(l)) )
< c
< c            END DO
---
> c             Tendencies on T
>                 zdtsig(ig,l) = (1/masse(l)) *
>      &        ( zmflux(l)*(ztm(l) - ztc(l)) 
>      &        - zmflux(l+1)*(ztm(l+1) - ztc(l))
>      &        + zcondicea(ig,l)*(ztcond(ig,l)-ztc(l))  )
>                 pdtc(ig,l) =  pdtc(ig,l) + zdtsig(ig,l)
> 
> c             Tendencies on U
>                 pduc(ig,l)   = (1/masse(l)) *
>      &        ( zmflux(l)*(zum(l) - zu(l))
>      &        - zmflux(l+1)*(zum(l+1) - zu(l)) )
> 
> 
> c             Tendencies on V
>                 pdvc(ig,l)   = (1/masse(l)) *
>      &        ( zmflux(l)*(zvm(l) - zv(l))
>      &        - zmflux(l+1)*(zvm(l+1) - zv(l)) )
> 
>             END DO
229,231c229,231
<       write(*,5) '(1)      = ngridmx?',tab_cntrl(tab0+1),float(ngridmx)
<       write(*,5) '(2)            lmax',tab_cntrl(tab0+2),float(lmax)
<       write(*,5) '(3)         day_ini',tab_cntrl(tab0+3),float(day_ini)
---
>       write(*,5) '(1)      = ngridmx?',tab_cntrl(tab0+1),real(ngridmx)
>       write(*,5) '(2)            lmax',tab_cntrl(tab0+2),real(lmax)
>       write(*,5) '(3)         day_ini',tab_cntrl(tab0+3),real(day_ini)
478,480c478,480
<       write(*,5) '(1)      = ngridmx?',tab_cntrl(tab0+1),float(ngridmx)
<       write(*,5) '(2)            lmax',tab_cntrl(tab0+2),float(lmax)
<       write(*,5) '(3)         day_ini',tab_cntrl(tab0+3),float(day_ini)
---
>       write(*,5) '(1)      = ngridmx?',tab_cntrl(tab0+1),real(ngridmx)
>       write(*,5) '(2)            lmax',tab_cntrl(tab0+2),real(lmax)
>       write(*,5) '(3)         day_ini',tab_cntrl(tab0+3),real(day_ini)
8c8,9
< !  Dans la version 2000, la periode d'ecriture est celle de 
---
> !  (ou encore 1d, dans le cas de testphys1d, pour sortir une colonne)
> !  La periode d'ecriture est donnee par 
33,34c34,35
< !      px : variable a sortir (real 0, 2, ou 3d)
< !      dim : dimension de px : 0, 2, ou 3 dimensions
---
> !      px : variable a sortir (real 0, 1, 2, ou 3d)
> !      dim : dimension de px : 0, 1, 2, ou 3 dimensions
61a63
>       real dx1(llm)           ! to store a 1D (column) data set
101,107d102
< ! The following test is here to enforce that writediagfi is not used with the
< ! 1D version of the GCM
<       if (ngrid.eq.1) return
<       
< c     nom=trim((nom))
< c     unite=trim((unite))
< c     titre=trim((titre))
154a150,157
>       if (ngridmx.eq.1) then
>         ! in testphys1d, for the 1d version of the GCM, iphysiq and irythme
>         ! are undefined; so set them to 1
>         iphysiq=1 
>         irythme=1
>         ! NB: 
>       endif
> 
171d173
< !       (like the 'histoire' outputs)
318a321,363
> !Case of a 1D variable (ie: a column)
> !---------------------------------------------------
> 
>        else if (dim.eq.1) then
> !         Passage variable physique -->  physique dynamique
> !         recast (copy) variable from physics grid to dynamics grid
>           do l=1,llm
>             dx1(l)=px(1,l)
>           enddo
>           
>           ierr= NF_INQ_VARID(nid,nom,varid)
>            if (ierr /= NF_NOERR) then
> ! corresponding dimensions
>               ierr= NF_INQ_DIMID(nid,"altitude",id(1))
>               ierr= NF_INQ_DIMID(nid,"Time",id(2))
> 
> ! Create the variable if it doesn't exist yet
> 
>               write (*,*) "=========================="
>               write (*,*) "DIAGFI: creating variable ",nom
> 
>               call def_var(nid,nom,titre,unite,2,id,varid,ierr)
>               
>            endif
>            
>            corner(1)=1
>            corner(2)=ntime
>            
>            edges(1)=llm
>            edges(2)=1
> #ifdef NC_DOUBLE
>            ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx1)
> #else
>            ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx1)
> #endif
> 
>            if (ierr.ne.NF_NOERR) then
>               write(*,*) "***** PUT_VAR problem in writediagfi"
>               write(*,*) "***** with ",nom
>               write(*,*) 'ierr=', ierr
> c             call abort
>            endif 
> 
