/[lmdze]/trunk/Sources/phylmd/phytrac.f
ViewVC logotype

Diff of /trunk/Sources/phylmd/phytrac.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 17 by guez, Tue Aug 5 13:31:32 2008 UTC revision 72 by guez, Tue Jul 23 13:00:07 2013 UTC
# Line 1  Line 1 
1  module phytrac_m  module phytrac_m
2    
   ! This module is clean: no C preprocessor directive, no include line.  
   
3    IMPLICIT none    IMPLICIT none
4    
5    private    private
# Line 10  module phytrac_m Line 8  module phytrac_m
8  contains  contains
9    
10    SUBROUTINE phytrac(rnpb, itap, lmt_pas, julien, gmtime, firstcal, lafin, &    SUBROUTINE phytrac(rnpb, itap, lmt_pas, julien, gmtime, firstcal, lafin, &
11         nqmax, pdtphys, u, v, t_seri, paprs, pplay, pmfu, pmfd, pen_u, &         nq_phys, pdtphys, u, t_seri, paprs, pplay, pmfu, pmfd, pen_u, pde_u, &
12         pde_u, pen_d, pde_d, coefh, fm_therm, entr_therm, yu1, yv1, ftsol, &         pen_d, pde_d, coefh, fm_therm, entr_therm, yu1, yv1, ftsol, pctsrf, &
13         pctsrf, frac_impa, frac_nucl, presnivs, pphis, &         frac_impa, frac_nucl, pphis, albsol, rh, cldfra, rneb, diafra, cldliq, &
14         pphi, albsol, rh, cldfra, rneb, diafra, cldliq, itop_con, &         pmflxr, pmflxs, prfl, psfl, da, phi, mp, upwd, dnwd, tr_seri, zmasse)
        ibas_con, pmflxr, pmflxs, prfl, psfl, da, phi, mp, upwd, dnwd, &  
        tr_seri, zmasse)  
15    
16      ! From phylmd/phytrac.F, version 1.15 2006/02/21 08:08:30      ! From phylmd/phytrac.F, version 1.15 2006/02/21 08:08:30 (SVN revision 679)
17    
18      ! Authors : Frédéric Hourdin, Abderrahmane Idelkadi, Marie-Alice      ! Authors: Frédéric Hourdin, Abderrahmane Idelkadi, Marie-Alice
19      ! Foujols, Olivia      ! Foujols, Olivia
20      ! Objet : moniteur général des tendances des traceurs      ! Objet : moniteur général des tendances des traceurs
21    
22      ! Remarques :      ! L'appel de "phytrac" se fait avec "nqmx-2" donc nous avons bien
     ! 1/ L'appel de "phytrac" se fait avec "nq-2" donc nous avons bien  
23      ! les vrais traceurs (en nombre "nbtr", sans la vapeur d'eau ni l'eau      ! les vrais traceurs (en nombre "nbtr", sans la vapeur d'eau ni l'eau
24      ! liquide) dans "phytrac".      ! liquide) dans "phytrac".
25      ! 2/ Le choix du radon et du plomb se fait juste avec un "data"  
26      ! (peu propre).      ! Modifications pour les traceurs :
27      ! Pourrait-on avoir une variable qui indiquerait le type de traceur ?      ! - uniformisation des parametrisations dans phytrac
28        ! - stockage des moyennes des champs nécessaires en mode traceur off-line
29    
30      use dimens_m, only: llm      use dimens_m, only: llm
31      use indicesol, only: nbsrf      use indicesol, only: nbsrf
# Line 37  contains Line 33  contains
33      use clesphys, only: ecrit_tra      use clesphys, only: ecrit_tra
34      use clesphys2, only: iflag_con      use clesphys2, only: iflag_con
35      use abort_gcm_m, only: abort_gcm      use abort_gcm_m, only: abort_gcm
36      use YOMCST, only: rg      use SUPHEC_M, only: rg
37      use ctherm, only: iflag_thermals      use ctherm, only: iflag_thermals
38      use regr_pr_comb_coefoz_m, only: regr_pr_comb_coefoz      use regr_pr_comb_coefoz_m, only: regr_pr_comb_coefoz
39      use phyetat0_m, only: rlat      use phyetat0_m, only: rlat
40      use o3_chem_m, only: o3_chem      use o3_chem_m, only: o3_chem
41      use ini_hist, only: ini_histrac      use ini_histrac_m, only: ini_histrac
42      use radiornpb_m, only: radiornpb      use radiornpb_m, only: radiornpb
43      use minmaxqfi_m, only: minmaxqfi      use minmaxqfi_m, only: minmaxqfi
44      use numer_rec, only: assert      use nr_util, only: assert
45      use press_coefoz_m, only: press_coefoz      use press_coefoz_m, only: press_coefoz
46    
     ! Arguments:  
   
     !   EN ENTREE:  
   
     !   divers:  
   
47      logical, intent(in):: rnpb      logical, intent(in):: rnpb
48    
49      integer, intent(in):: nqmax      integer, intent(in):: nq_phys
50      ! (nombre de traceurs auxquels on applique la physique)      ! (nombre de traceurs auxquels on applique la physique)
51    
52      integer, intent(in):: itap  ! number of calls to "physiq"      integer, intent(in):: itap  ! number of calls to "physiq"
53      integer, intent(in):: lmt_pas ! number of time steps of "physics" per day      integer, intent(in):: lmt_pas ! number of time steps of "physics" per day
54      integer, intent(in):: julien !jour julien, 1 <= julien <= 360      integer, intent(in):: julien !jour julien, 1 <= julien <= 360
     integer itop_con(klon)  
     integer ibas_con(klon)  
55      real, intent(in):: gmtime ! heure de la journée en fraction de jour      real, intent(in):: gmtime ! heure de la journée en fraction de jour
56      real, intent(in):: pdtphys  ! pas d'integration pour la physique (s)      real, intent(in):: pdtphys  ! pas d'integration pour la physique (s)
57      real, intent(in):: t_seri(klon, llm) ! temperature, in K      real, intent(in):: t_seri(klon, llm) ! temperature, in K
58    
59      real, intent(inout):: tr_seri(klon, llm, nbtr)      real, intent(inout):: tr_seri(:, :, :) ! (klon, llm, nbtr)
60      ! (mass fractions of tracers, excluding water, at mid-layers)      ! (mass fractions of tracers, excluding water, at mid-layers)
61    
62      real u(klon, llm)      real, intent(in):: u(klon, llm)
     real v(klon, llm)  
63      real rh(klon, llm)     ! humidite relative      real rh(klon, llm)     ! humidite relative
64      real cldliq(klon, llm) ! eau liquide nuageuse      real cldliq(klon, llm) ! eau liquide nuageuse
65      real cldfra(klon, llm) ! fraction nuageuse (tous les nuages)      real cldfra(klon, llm) ! fraction nuageuse (tous les nuages)
# Line 89  contains Line 76  contains
76      real, intent(in):: pplay(klon, llm)      real, intent(in):: pplay(klon, llm)
77      ! (pression pour le mileu de chaque couche, en Pa)      ! (pression pour le mileu de chaque couche, en Pa)
78    
79      real pphi(klon, llm) ! geopotentiel      real, intent(in):: pphis(klon)
     real pphis(klon)  
     REAL, intent(in):: presnivs(llm)  
80      logical, intent(in):: firstcal ! first call to "calfis"      logical, intent(in):: firstcal ! first call to "calfis"
81      logical, intent(in):: lafin ! fin de la physique      logical, intent(in):: lafin ! fin de la physique
82    
# Line 99  contains Line 84  contains
84      REAL prfl(klon, llm+1),   psfl(klon, llm+1)     !--lessivage large-scale      REAL prfl(klon, llm+1),   psfl(klon, llm+1)     !--lessivage large-scale
85    
86      !   convection:      !   convection:
87      REAL pmfu(klon, llm)  ! flux de masse dans le panache montant  
88      REAL pmfd(klon, llm)  ! flux de masse dans le panache descendant      REAL, intent(in):: pmfu(klon, llm) ! flux de masse dans le panache montant
89    
90        REAL, intent(in):: pmfd(klon, llm)
91        ! flux de masse dans le panache descendant
92    
93      REAL pen_u(klon, llm) ! flux entraine dans le panache montant      REAL pen_u(klon, llm) ! flux entraine dans le panache montant
94    
95      !   thermiques:      !   thermiques:
# Line 110  contains Line 99  contains
99      REAL pde_u(klon, llm) ! flux detraine dans le panache montant      REAL pde_u(klon, llm) ! flux detraine dans le panache montant
100      REAL pen_d(klon, llm) ! flux entraine dans le panache descendant      REAL pen_d(klon, llm) ! flux entraine dans le panache descendant
101      REAL pde_d(klon, llm) ! flux detraine dans le panache descendant      REAL pde_d(klon, llm) ! flux detraine dans le panache descendant
102      ! KE      ! Kerry Emanuel
103      real da(klon, llm), phi(klon, llm, llm), mp(klon, llm)      real da(klon, llm), phi(klon, llm, llm), mp(klon, llm)
104      REAL upwd(klon, llm)      ! saturated updraft mass flux      REAL, intent(in):: upwd(klon, llm) ! saturated updraft mass flux
105      REAL dnwd(klon, llm)      ! saturated downdraft mass flux      REAL, intent(in):: dnwd(klon, llm) ! saturated downdraft mass flux
106    
107      !   Couche limite:      !   Couche limite:
108    
# Line 211  contains Line 200  contains
200    
201      !--------------------------------------      !--------------------------------------
202    
203      call assert(shape(zmasse) == (/klon, llm/), "phytrac")      call assert(shape(zmasse) == (/klon, llm/), "phytrac zmasse")
204        call assert(shape(tr_seri) == (/klon, llm, nbtr/), "phytrac tr_seri")
205    
206      if (firstcal) then      if (firstcal) then
207         print *, 'phytrac: pdtphys = ', pdtphys         print *, 'phytrac: pdtphys = ', pdtphys
208         PRINT *, 'Fréquence de sortie des traceurs : ecrit_tra = ', ecrit_tra         PRINT *, 'Fréquence de sortie des traceurs : ecrit_tra = ', ecrit_tra
209         if (nbtr < nqmax) call abort_gcm('phytrac', 'See above', 1)         if (nbtr < nq_phys) call abort_gcm('phytrac', 'nbtr < nq_phys', 1)
210         inirnpb=rnpb         inirnpb=rnpb
211    
212         ! Initialisation des sorties :         ! Initialisation des sorties :
213         call ini_histrac(nid_tra, pdtphys, presnivs, nqmax, lessivage)         call ini_histrac(nid_tra, pdtphys, nq_phys, lessivage)
214    
215         ! Initialisation de certaines variables pour le radon et le plomb         ! Initialisation de certaines variables pour le radon et le plomb
216         ! Initialisation du traceur dans le sol (couche limite radonique)         ! Initialisation du traceur dans le sol (couche limite radonique)
# Line 239  contains Line 229  contains
229    
230         ! Initialisation de la nature des traceurs         ! Initialisation de la nature des traceurs
231    
232         DO it = 1, nqmax         DO it = 1, nq_phys
233            aerosol(it) = .FALSE.  ! Tous les traceurs sont des gaz par defaut            aerosol(it) = .FALSE.  ! Tous les traceurs sont des gaz par defaut
234            radio(it) = .FALSE. ! par défaut pas de passage par "radiornpb"            radio(it) = .FALSE. ! par défaut pas de passage par "radiornpb"
235            clsol(it) = .FALSE.  ! Par defaut couche limite avec flux prescrit            clsol(it) = .FALSE.  ! Par defaut couche limite avec flux prescrit
236         ENDDO         ENDDO
237    
238         if (nqmax >= 3) then         if (nq_phys >= 3) then
239            call press_coefoz ! read input pressure levels for ozone coefficients            call press_coefoz ! read input pressure levels for ozone coefficients
240         end if         end if
241      ENDIF      ENDIF
242    
     ! Initialisation du traceur dans le sol (couche limite radonique)  
243      if (inirnpb) THEN      if (inirnpb) THEN
244           ! Initialisation du traceur dans le sol (couche limite radonique)
245         radio(1)= .true.         radio(1)= .true.
246         radio(2)= .true.         radio(2)= .true.
247         clsol(1)= .true.         clsol(1)= .true.
248         clsol(2)= .true.         clsol(2)= .true.
249         aerosol(2) = .TRUE. ! le Pb est un aerosol         aerosol(2) = .TRUE. ! le Pb est un aerosol
   
250         call initrrnpb(ftsol, pctsrf, masktr, fshtr, hsoltr, tautr, vdeptr, &         call initrrnpb(ftsol, pctsrf, masktr, fshtr, hsoltr, tautr, vdeptr, &
251              scavtr)              scavtr)
252         inirnpb=.false.         inirnpb=.false.
253      endif      endif
254    
     ! Calcul de l'effet de la convection  
   
255      if (convection) then      if (convection) then
256         DO it=1, nqmax         ! Calcul de l'effet de la convection
257            if (iflag_con.eq.2) then         DO it=1, nq_phys
258               ! tiedke            if (iflag_con == 2) then
259                 ! Tiedke
260               CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &               CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
261                    paprs, tr_seri(1, 1, it), d_tr_cv(1, 1, it))                    paprs, tr_seri(1, 1, it), d_tr_cv(1, 1, it))
262            else if (iflag_con.eq.3) then            else if (iflag_con == 3) then
263               ! KE               ! Emanuel
264               call cvltr(pdtphys, da, phi, mp, paprs, &               call cvltr(pdtphys, da, phi, mp, paprs, tr_seri(1, 1, it), upwd, &
265                    tr_seri(1, 1, it), upwd, dnwd, d_tr_cv(1, 1, it))                    dnwd, d_tr_cv(1, 1, it))
266            endif            endif
267    
268            DO k = 1, llm            DO k = 1, llm
# Line 291  contains Line 278  contains
278    
279      ! Calcul de l'effet des thermiques      ! Calcul de l'effet des thermiques
280    
281      do it=1, nqmax      do it=1, nq_phys
282         do k=1, llm         do k=1, llm
283            do i=1, klon            do i=1, klon
284               d_tr_th(i, k, it)=0.               d_tr_th(i, k, it)=0.
# Line 303  contains Line 290  contains
290    
291      if (iflag_thermals > 0) then      if (iflag_thermals > 0) then
292         nsplit=10         nsplit=10
293         DO it=1, nqmax         DO it=1, nq_phys
294            do isplit=1, nsplit            do isplit=1, nsplit
295               ! Thermiques               ! Thermiques
296               call dqthermcell(klon, llm, pdtphys/nsplit &               call dqthermcell(klon, llm, pdtphys/nsplit &
# Line 332  contains Line 319  contains
319         ENDDO         ENDDO
320    
321         ! MAF modif pour tenir compte du cas rnpb + traceur         ! MAF modif pour tenir compte du cas rnpb + traceur
322         DO it=1, nqmax         DO it=1, nq_phys
323            if (clsol(it)) then            if (clsol(it)) then
324               ! couche limite avec quantite dans le sol calculee               ! couche limite avec quantite dans le sol calculee
325               CALL cltracrn(it, pdtphys, yu1, yv1, &               CALL cltracrn(it, pdtphys, yu1, yv1, &
# Line 380  contains Line 367  contains
367      ! si radio=true mais pour l'instant radiornpb propre au cas rnpb      ! si radio=true mais pour l'instant radiornpb propre au cas rnpb
368      if (rnpb) then      if (rnpb) then
369         d_tr_dec(:, :, :) = radiornpb(tr_seri, pdtphys, tautr)         d_tr_dec(:, :, :) = radiornpb(tr_seri, pdtphys, tautr)
370         DO it=1, nqmax         DO it=1, nq_phys
371            if (radio(it)) then            if (radio(it)) then
372               tr_seri(:, :, it) = tr_seri(:, :, it) + d_tr_dec(:, :, it)               tr_seri(:, :, it) = tr_seri(:, :, it) + d_tr_dec(:, :, it)
373               WRITE(unit=itn, fmt='(i1)') it               WRITE(unit=itn, fmt='(i1)') it
# Line 389  contains Line 376  contains
376         ENDDO         ENDDO
377      endif ! rnpb decroissance  radioactive      endif ! rnpb decroissance  radioactive
378    
379      if (nqmax >= 3) then      if (nq_phys >= 3) then
380         ! Ozone as a tracer:         ! Ozone as a tracer:
381         if (mod(itap - 1, lmt_pas) == 0) then         if (mod(itap - 1, lmt_pas) == 0) then
382            ! Once per day, update the coefficients for ozone chemistry:            ! Once per day, update the coefficients for ozone chemistry:
# Line 407  contains Line 394  contains
394    
395         ! tendance des aerosols nuclees et impactes         ! tendance des aerosols nuclees et impactes
396    
397         DO it = 1, nqmax         DO it = 1, nq_phys
398            IF (aerosol(it)) THEN            IF (aerosol(it)) THEN
399               DO k = 1, llm               DO k = 1, llm
400                  DO i = 1, klon                  DO i = 1, klon
# Line 423  contains Line 410  contains
410         ! Mises a jour des traceurs + calcul des flux de lessivage         ! Mises a jour des traceurs + calcul des flux de lessivage
411         ! Mise a jour due a l'impaction et a la nucleation         ! Mise a jour due a l'impaction et a la nucleation
412    
413         DO it = 1, nqmax         DO it = 1, nq_phys
414            IF (aerosol(it)) THEN            IF (aerosol(it)) THEN
415               DO k = 1, llm               DO k = 1, llm
416                  DO i = 1, klon                  DO i = 1, klon
# Line 436  contains Line 423  contains
423    
424         ! Flux lessivage total         ! Flux lessivage total
425    
426         DO it = 1, nqmax         DO it = 1, nq_phys
427            DO k = 1, llm            DO k = 1, llm
428               DO i = 1, klon               DO i = 1, klon
429                  flestottr(i, k, it) = flestottr(i, k, it) - &                  flestottr(i, k, it) = flestottr(i, k, it) - &
# Line 450  contains Line 437  contains
437      ENDIF      ENDIF
438    
439      !   Ecriture des sorties      !   Ecriture des sorties
440      call write_histrac(lessivage, nqmax, itap, nid_tra)      call write_histrac(lessivage, nq_phys, itap, nid_tra)
441    
442      if (lafin) then      if (lafin) then
443         print *, "C'est la fin de la physique."         print *, "C'est la fin de la physique."
# Line 464  contains Line 451  contains
451    
452    contains    contains
453    
454      subroutine write_histrac(lessivage, nqmax, itap, nid_tra)      subroutine write_histrac(lessivage, nq_phys, itap, nid_tra)
455    
456        ! From phylmd/write_histrac.h, version 1.9 2006/02/21 08:08:30        ! From phylmd/write_histrac.h, version 1.9 2006/02/21 08:08:30
457    
458        use dimens_m, only: iim, jjm, llm        use dimens_m, only: iim, jjm, llm
459        use ioipsl, only: histwrite, histsync        use histsync_m, only: histsync
460          use histwrite_m, only: histwrite
461        use temps, only: itau_phy        use temps, only: itau_phy
462        use advtrac_m, only: tnom        use iniadvtrac_m, only: tnom
463        use comgeomphy, only: airephy        use comgeomphy, only: airephy
464        use dimphy, only: klon        use dimphy, only: klon
465          use grid_change, only: gr_phy_write_2d
466          use gr_phy_write_3d_m, only: gr_phy_write_3d
467    
468        logical, intent(in):: lessivage        logical, intent(in):: lessivage
469    
470        integer, intent(in):: nqmax        integer, intent(in):: nq_phys
471        ! (nombre de traceurs auxquels on applique la physique)        ! (nombre de traceurs auxquels on applique la physique)
472    
473        integer, intent(in):: itap  ! number of calls to "physiq"        integer, intent(in):: itap  ! number of calls to "physiq"
# Line 486  contains Line 476  contains
476        ! Variables local to the procedure:        ! Variables local to the procedure:
477        integer it        integer it
478        integer itau_w   ! pas de temps ecriture        integer itau_w   ! pas de temps ecriture
       REAL zx_tmp_2d(iim, jjm+1), zx_tmp_3d(iim, jjm+1, llm)  
479        logical, parameter:: ok_sync = .true.        logical, parameter:: ok_sync = .true.
480    
481        !-----------------------------------------------------        !-----------------------------------------------------
482    
483        itau_w = itau_phy + itap        itau_w = itau_phy + itap
484    
485        CALL gr_fi_ecrit(1, klon, iim, jjm+1, pphis, zx_tmp_2d)        CALL histwrite(nid_tra, "phis", itau_w, gr_phy_write_2d(pphis))
486        CALL histwrite(nid_tra, "phis", itau_w, zx_tmp_2d)        CALL histwrite(nid_tra, "aire", itau_w, gr_phy_write_2d(airephy))
487          CALL histwrite(nid_tra, "zmasse", itau_w, gr_phy_write_3d(zmasse))
488        CALL gr_fi_ecrit(1, klon, iim, jjm+1, airephy, zx_tmp_2d)        
489        CALL histwrite(nid_tra, "aire", itau_w, zx_tmp_2d)        DO it=1, nq_phys
490             CALL histwrite(nid_tra, tnom(it+2), itau_w, &
491        CALL gr_fi_ecrit(llm, klon, iim, jjm+1, zmasse, zx_tmp_3d)                      gr_phy_write_3d(tr_seri(:, :, it)))
       CALL histwrite(nid_tra, "zmasse", itau_w, zx_tmp_3d)  
   
       DO it=1, nqmax  
          CALL gr_fi_ecrit(llm, klon, iim, jjm+1, tr_seri(1, 1, it), zx_tmp_3d)  
          CALL histwrite(nid_tra, tnom(it+2), itau_w, zx_tmp_3d)  
492           if (lessivage) THEN           if (lessivage) THEN
493              CALL gr_fi_ecrit(llm, klon, iim, jjm+1, flestottr(1, 1, it), &              CALL histwrite(nid_tra, "fl"//tnom(it+2), itau_w, &
494                   zx_tmp_3d)                   gr_phy_write_3d(flestottr(:, :, it)))
             CALL histwrite(nid_tra, "fl"//tnom(it+2), itau_w, zx_tmp_3d)  
495           endif           endif
496             CALL histwrite(nid_tra, "d_tr_th_"//tnom(it+2), itau_w, &
497           CALL gr_fi_ecrit(llm, klon, iim, jjm+1, d_tr_th(1, 1, it), zx_tmp_3d)                gr_phy_write_3d(d_tr_th(:, :, it)))
498           CALL histwrite(nid_tra, "d_tr_th_"//tnom(it+2), itau_w, zx_tmp_3d)           CALL histwrite(nid_tra, "d_tr_cv_"//tnom(it+2), itau_w, &
499           CALL gr_fi_ecrit(llm, klon, iim, jjm+1, d_tr_cv(1, 1, it), zx_tmp_3d)                gr_phy_write_3d(d_tr_cv(:, :, it)))
500           CALL histwrite(nid_tra, "d_tr_cv_"//tnom(it+2), itau_w, zx_tmp_3d)           CALL histwrite(nid_tra, "d_tr_cl_"//tnom(it+2), itau_w, &
501           CALL gr_fi_ecrit(llm, klon, iim, jjm+1, d_tr_cl(1, 1, it), zx_tmp_3d)                gr_phy_write_3d(d_tr_cl(:, :, it)))
          CALL histwrite(nid_tra, "d_tr_cl_"//tnom(it+2), itau_w, zx_tmp_3d)  
502        ENDDO        ENDDO
503    
504        CALL gr_fi_ecrit(llm, klon, iim, jjm+1, pplay, zx_tmp_3d)        CALL histwrite(nid_tra, "pplay", itau_w, gr_phy_write_3d(pplay))
505        CALL histwrite(nid_tra, "pplay", itau_w, zx_tmp_3d)        CALL histwrite(nid_tra, "T", itau_w, gr_phy_write_3d(t_seri))
   
       CALL gr_fi_ecrit(llm, klon, iim, jjm+1, t_seri, zx_tmp_3d)  
       CALL histwrite(nid_tra, "t", itau_w, zx_tmp_3d)  
506    
507        if (ok_sync) then        if (ok_sync) then
508           call histsync(nid_tra)           call histsync(nid_tra)

Legend:
Removed from v.17  
changed lines
  Added in v.72

  ViewVC Help
Powered by ViewVC 1.1.21