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

Diff of /trunk/phylmd/phytrac.f

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

trunk/phylmd/phytrac.f revision 118 by guez, Thu Dec 18 17:30:24 2014 UTC trunk/Sources/phylmd/phytrac.f revision 201 by guez, Mon Jun 6 17:42:15 2016 UTC
# Line 7  module phytrac_m Line 7  module phytrac_m
7    
8  contains  contains
9    
10    SUBROUTINE phytrac(itap, lmt_pas, julien, gmtime, firstcal, lafin, pdtphys, &    SUBROUTINE phytrac(lmt_pas, julien, gmtime, firstcal, lafin, pdtphys, &
11         t_seri, paprs, pplay, pmfu, pmfd, pde_u, pen_d, coefh, fm_therm, &         t_seri, paprs, pplay, pmfu, pmfd, pde_u, pen_d, coefh, fm_therm, &
12         entr_therm, yu1, yv1, ftsol, pctsrf, frac_impa, frac_nucl, pphis, da, &         entr_therm, yu1, yv1, ftsol, pctsrf, frac_impa, frac_nucl, da, phi, &
13         phi, mp, upwd, dnwd, tr_seri, zmasse)         mp, upwd, dnwd, tr_seri, zmasse, ncid_startphy)
14    
15      ! From phylmd/phytrac.F, version 1.15 2006/02/21 08:08:30 (SVN revision 679)      ! From phylmd/phytrac.F, version 1.15 2006/02/21 08:08:30 (SVN
16        ! revision 679) and phylmd/write_histrac.h, version 1.9 2006/02/21
17        ! 08:08:30
18    
19      ! Authors: Fr\'ed\'eric Hourdin, Abderrahmane Idelkadi, Marie-Alice      ! Authors: Fr\'ed\'eric Hourdin, Abderrahmane Idelkadi, Marie-Alice
20      ! Foujols, Olivia      ! Foujols, Olivia
# Line 28  contains Line 30  contains
30    
31      use abort_gcm_m, only: abort_gcm      use abort_gcm_m, only: abort_gcm
32      use clesphys, only: ecrit_tra      use clesphys, only: ecrit_tra
33      use clesphys2, only: iflag_con      use clesphys2, only: conv_emanuel
34        use cltrac_m, only: cltrac
35      use cltracrn_m, only: cltracrn      use cltracrn_m, only: cltracrn
36      use ctherm, only: iflag_thermals      use ctherm, only: iflag_thermals
37        use cvltr_m, only: cvltr
38      use dimens_m, only: llm, nqmx      use dimens_m, only: llm, nqmx
39      use dimphy, only: klon      use dimphy, only: klon
40        use histwrite_phy_m, only: histwrite_phy
41      use indicesol, only: nbsrf      use indicesol, only: nbsrf
42      use ini_histrac_m, only: ini_histrac      use iniadvtrac_m, only: tname
43      use initrrnpb_m, only: initrrnpb      use initrrnpb_m, only: initrrnpb
44      use minmaxqfi_m, only: minmaxqfi      use minmaxqfi_m, only: minmaxqfi
45        use netcdf, only: NF90_FILL_float
46        use netcdf95, only: nf95_inq_varid, nf95_get_var, nf95_put_var
47      use nflxtr_m, only: nflxtr      use nflxtr_m, only: nflxtr
48      use nr_util, only: assert      use nr_util, only: assert
49      use o3_chem_m, only: o3_chem      use o3_chem_m, only: o3_chem
50      use phyetat0_m, only: rlat      use phyetat0_m, only: rlat
51        use phyredem0_m, only: ncid_restartphy
52      use press_coefoz_m, only: press_coefoz      use press_coefoz_m, only: press_coefoz
53      use radiornpb_m, only: radiornpb      use radiornpb_m, only: radiornpb
54      use regr_pr_comb_coefoz_m, only: regr_pr_comb_coefoz      use regr_pr_comb_coefoz_m, only: regr_pr_comb_coefoz
55      use SUPHEC_M, only: rg      use SUPHEC_M, only: rg
56        use time_phylmdz, only: itap
57    
     integer, intent(in):: itap ! number of calls to "physiq"  
58      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
59      integer, intent(in):: julien !jour julien, 1 <= julien <= 360      integer, intent(in):: julien !jour julien, 1 <= julien <= 360
60      real, intent(in):: gmtime ! heure de la journ\'ee en fraction de jour      real, intent(in):: gmtime ! heure de la journ\'ee en fraction de jour
# Line 87  contains Line 95  contains
95      REAL frac_impa(klon, llm) ! fraction d'aerosols impactes      REAL frac_impa(klon, llm) ! fraction d'aerosols impactes
96      REAL frac_nucl(klon, llm) ! fraction d'aerosols nuclees      REAL frac_nucl(klon, llm) ! fraction d'aerosols nuclees
97    
     real, intent(in):: pphis(klon)  
   
98      ! Kerry Emanuel      ! Kerry Emanuel
99      real, intent(in):: da(klon, llm), phi(klon, llm, llm), mp(klon, llm)      real, intent(in):: da(klon, llm), phi(klon, llm, llm), mp(klon, llm)
100      REAL, intent(in):: upwd(klon, llm) ! saturated updraft mass flux      REAL, intent(in):: upwd(klon, llm) ! saturated updraft mass flux
# Line 100  contains Line 106  contains
106      real, intent(in):: zmasse(:, :) ! (klon, llm)      real, intent(in):: zmasse(:, :) ! (klon, llm)
107      ! (column-density of mass of air in a cell, in kg m-2)      ! (column-density of mass of air in a cell, in kg m-2)
108    
109      ! Variables local to the procedure:      integer, intent(in):: ncid_startphy
110    
111        ! Local:
112    
113      integer nsplit      integer nsplit
114    
# Line 114  contains Line 122  contains
122      !      !
123      ! Pour la source de radon et son reservoir de sol      ! Pour la source de radon et son reservoir de sol
124    
125      REAL, save:: trs(klon, nqmx - 2) ! Concentration de radon dans le sol      REAL, save:: trs(klon, nqmx - 2) ! Concentration de traceur dans le sol
126    
127      REAL masktr(klon, nqmx - 2) ! Masque reservoir de sol traceur      REAL masktr(klon, nqmx - 2) ! Masque reservoir de sol traceur
128      ! Masque de l'echange avec la surface      ! Masque de l'echange avec la surface
# Line 132  contains Line 140  contains
140      SAVE scavtr      SAVE scavtr
141    
142      CHARACTER itn      CHARACTER itn
     INTEGER, save:: nid_tra  
143    
144      ! nature du traceur      ! nature du traceur
145    
# Line 153  contains Line 160  contains
160    
161      REAL d_tr(klon, llm), d_trs(klon) ! tendances de traceurs      REAL d_tr(klon, llm), d_trs(klon) ! tendances de traceurs
162      REAL d_tr_cl(klon, llm, nqmx - 2) ! tendance de traceurs couche limite      REAL d_tr_cl(klon, llm, nqmx - 2) ! tendance de traceurs couche limite
163      REAL d_tr_cv(klon, llm, nqmx - 2) ! tendance de traceurs conv pour chq traceur  
164        REAL d_tr_cv(klon, llm, nqmx - 2)
165        ! tendance de traceurs conv pour chq traceur
166    
167      REAL d_tr_th(klon, llm, nqmx - 2) ! la tendance des thermiques      REAL d_tr_th(klon, llm, nqmx - 2) ! la tendance des thermiques
168      REAL d_tr_dec(klon, llm, 2) ! la tendance de la decroissance      REAL d_tr_dec(klon, llm, 2) ! la tendance de la decroissance
169      ! ! radioactive du rn - > pb      ! ! radioactive du rn - > pb
# Line 165  contains Line 175  contains
175      ! ! dans chaque couche      ! ! dans chaque couche
176    
177      real ztra_th(klon, llm)      real ztra_th(klon, llm)
178      integer isplit      integer isplit, varid
179    
180      ! Controls:      ! Controls:
181      logical:: couchelimite = .true.      logical:: couchelimite = .true.
# Line 183  contains Line 193  contains
193         PRINT *, 'Frequency of tracer output: ecrit_tra = ', ecrit_tra         PRINT *, 'Frequency of tracer output: ecrit_tra = ', ecrit_tra
194         inirnpb = .true.         inirnpb = .true.
195    
        ! Initialisation des sorties :  
        call ini_histrac(nid_tra, pdtphys, nqmx - 2, lessivage)  
   
196         ! Initialisation de certaines variables pour le radon et le plomb         ! Initialisation de certaines variables pour le radon et le plomb
197         ! Initialisation du traceur dans le sol (couche limite radonique)         ! Initialisation du traceur dans le sol (couche limite radonique)
198         trs(:, :) = 0.         trs(:, 2:) = 0.
199    
200         open (unit=99, file='starttrac', status='old', err=999, &         call nf95_inq_varid(ncid_startphy, "trs", varid)
201              form='formatted')         call nf95_get_var(ncid_startphy, varid, trs(:, 1))
202         read(unit=99, fmt=*) (trs(i, 1), i=1, klon)         if (any(trs(:, 1) == NF90_FILL_float)) call abort_gcm("phytrac", &
203  999    continue              "some missing values in trs(:, 1)")
        close(unit=99)  
204    
205         ! Initialisation de la fraction d'aerosols lessivee         ! Initialisation de la fraction d'aerosols lessivee
206    
# Line 228  contains Line 234  contains
234      if (convection) then      if (convection) then
235         ! Calcul de l'effet de la convection         ! Calcul de l'effet de la convection
236         DO it=1, nqmx - 2         DO it=1, nqmx - 2
237            if (iflag_con == 2) then            if (conv_emanuel) then
238               ! Tiedke               call cvltr(pdtphys, da, phi, mp, paprs, tr_seri(:, :, it), upwd, &
239                      dnwd, d_tr_cv(:, :, it))
240              else
241               CALL nflxtr(pdtphys, pmfu, pmfd, pde_u, pen_d, paprs, &               CALL nflxtr(pdtphys, pmfu, pmfd, pde_u, pen_d, paprs, &
242                    tr_seri(:, :, it), d_tr_cv(:, :, it))                    tr_seri(:, :, it), d_tr_cv(:, :, it))
           else if (iflag_con == 3) then  
              ! Emanuel  
              call cvltr(pdtphys, da, phi, mp, paprs, tr_seri(1, 1, it), upwd, &  
                   dnwd, d_tr_cv(1, 1, it))  
243            endif            endif
244    
245            DO k = 1, llm            DO k = 1, llm
# Line 294  contains Line 298  contains
298         DO it=1, nqmx - 2         DO it=1, nqmx - 2
299            if (clsol(it)) then            if (clsol(it)) then
300               ! couche limite avec quantite dans le sol calculee               ! couche limite avec quantite dans le sol calculee
301               CALL cltracrn(it, pdtphys, yu1, yv1, &               CALL cltracrn(it, pdtphys, yu1, yv1, coefh, t_seri, ftsol, &
302                    coefh, t_seri, ftsol, pctsrf, &                    pctsrf, tr_seri(:, :, it), trs(:, it), paprs, pplay, delp, &
303                    tr_seri(:, :, it), trs(1, it), &                    masktr(1, it), fshtr(1, it), hsoltr(it), tautr(it), &
304                    paprs, pplay, delp, &                    vdeptr(it), rlat, d_tr_cl(1, 1, it), d_trs)
                   masktr(1, it), fshtr(1, it), hsoltr(it), &  
                   tautr(it), vdeptr(it), &  
                   rlat, &  
                   d_tr_cl(1, 1, it), d_trs)  
305               DO k = 1, llm               DO k = 1, llm
306                  DO i = 1, klon                  DO i = 1, klon
307                     tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cl(i, k, it)                     tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cl(i, k, it)
308                  ENDDO                  ENDDO
309               ENDDO               ENDDO
310    
311               ! Traceur ds sol               trs(:, it) = trs(:, it) + d_trs
312              else
313               DO i = 1, klon               ! couche limite avec flux prescrit
                 trs(i, it) = trs(i, it) + d_trs(i)  
              END DO  
           else ! couche limite avec flux prescrit  
314               !MAF provisoire source / traceur a creer               !MAF provisoire source / traceur a creer
315               DO i=1, klon               DO i=1, klon
316                  source(i) = 0.0 ! pas de source, pour l'instant                  source(i) = 0. ! pas de source, pour l'instant
317               ENDDO               ENDDO
318    
319               CALL cltrac(pdtphys, coefh, t_seri, &               CALL cltrac(pdtphys, coefh, t_seri, tr_seri(:, :, it), source, &
320                    tr_seri(1, 1, it), source, &                    paprs, pplay, delp, d_tr_cl(1, 1, it))
                   paprs, pplay, delp, &  
                   d_tr_cl(1, 1, it))  
321               DO k = 1, llm               DO k = 1, llm
322                  DO i = 1, klon                  DO i = 1, klon
323                     tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cl(i, k, it)                     tr_seri(i, k, it) = tr_seri(i, k, it) + d_tr_cl(i, k, it)
# Line 349  contains Line 344  contains
344         ! Ozone as a tracer:         ! Ozone as a tracer:
345         if (mod(itap - 1, lmt_pas) == 0) then         if (mod(itap - 1, lmt_pas) == 0) then
346            ! Once per day, update the coefficients for ozone chemistry:            ! Once per day, update the coefficients for ozone chemistry:
347            call regr_pr_comb_coefoz(julien)            call regr_pr_comb_coefoz(julien, paprs, pplay)
348         end if         end if
349         call o3_chem(julien, gmtime, t_seri, zmasse, pdtphys, tr_seri(:, :, 3))         call o3_chem(julien, gmtime, t_seri, zmasse, pdtphys, tr_seri(:, :, 3))
350      end if      end if
# Line 404  contains Line 399  contains
399      ENDIF      ENDIF
400    
401      ! Ecriture des sorties      ! Ecriture des sorties
402      call write_histrac(lessivage, itap, nid_tra)      CALL histwrite_phy("zmasse", zmasse)
403        DO it=1, nqmx - 2
404           CALL histwrite_phy(tname(it+2), tr_seri(:, :, it))
405           if (lessivage) THEN
406              CALL histwrite_phy("fl"//tname(it+2), flestottr(:, :, it))
407           endif
408           CALL histwrite_phy("d_tr_th_"//tname(it+2), d_tr_th(:, :, it))
409           CALL histwrite_phy("d_tr_cv_"//tname(it+2), d_tr_cv(:, :, it))
410           CALL histwrite_phy("d_tr_cl_"//tname(it+2), d_tr_cl(:, :, it))
411        ENDDO
412    
413      if (lafin) then      if (lafin) then
414         print *, "C'est la fin de la physique."         call nf95_inq_varid(ncid_restartphy, "trs", varid)
415         open(unit=99, file='restarttrac', form='formatted')         call nf95_put_var(ncid_restartphy, varid, trs(:, 1))
        do i=1, klon  
           write(unit=99, fmt=*) trs(i, 1)  
        enddo  
        PRINT *, 'Ecriture du fichier restarttrac'  
        close(unit=99)  
416      endif      endif
417    
   contains  
   
     subroutine write_histrac(lessivage, itap, nid_tra)  
   
       ! From phylmd/write_histrac.h, version 1.9 2006/02/21 08:08:30  
   
       use dimens_m, only: iim, jjm, llm  
       use histsync_m, only: histsync  
       use histwrite_m, only: histwrite  
       use temps, only: itau_phy  
       use iniadvtrac_m, only: tnom  
       use comgeomphy, only: airephy  
       use dimphy, only: klon  
       use grid_change, only: gr_phy_write_2d  
       use gr_phy_write_3d_m, only: gr_phy_write_3d  
   
       logical, intent(in):: lessivage  
       integer, intent(in):: itap ! number of calls to "physiq"  
       integer, intent(in):: nid_tra  
   
       ! Variables local to the procedure:  
       integer it  
       integer itau_w ! pas de temps ecriture  
       logical, parameter:: ok_sync = .true.  
   
       !-----------------------------------------------------  
   
       itau_w = itau_phy + itap  
   
       CALL histwrite(nid_tra, "phis", itau_w, gr_phy_write_2d(pphis))  
       CALL histwrite(nid_tra, "aire", itau_w, gr_phy_write_2d(airephy))  
       CALL histwrite(nid_tra, "zmasse", itau_w, gr_phy_write_3d(zmasse))  
   
       DO it=1, nqmx - 2  
          CALL histwrite(nid_tra, tnom(it+2), itau_w, &  
               gr_phy_write_3d(tr_seri(:, :, it)))  
          if (lessivage) THEN  
             CALL histwrite(nid_tra, "fl"//tnom(it+2), itau_w, &  
                  gr_phy_write_3d(flestottr(:, :, it)))  
          endif  
          CALL histwrite(nid_tra, "d_tr_th_"//tnom(it+2), itau_w, &  
               gr_phy_write_3d(d_tr_th(:, :, it)))  
          CALL histwrite(nid_tra, "d_tr_cv_"//tnom(it+2), itau_w, &  
               gr_phy_write_3d(d_tr_cv(:, :, it)))  
          CALL histwrite(nid_tra, "d_tr_cl_"//tnom(it+2), itau_w, &  
               gr_phy_write_3d(d_tr_cl(:, :, it)))  
       ENDDO  
   
       CALL histwrite(nid_tra, "pplay", itau_w, gr_phy_write_3d(pplay))  
       CALL histwrite(nid_tra, "T", itau_w, gr_phy_write_3d(t_seri))  
   
       if (ok_sync) then  
          call histsync(nid_tra)  
       endif  
   
     end subroutine write_histrac  
   
418    END SUBROUTINE phytrac    END SUBROUTINE phytrac
419    
420  end module phytrac_m  end module phytrac_m

Legend:
Removed from v.118  
changed lines
  Added in v.201

  ViewVC Help
Powered by ViewVC 1.1.21