source: trunk/LMDZ.COMMON/libf/evolution/soil_pem.F90 @ 2863

Last change on this file since 2863 was 2855, checked in by llange, 3 years ago

PEM
Documentation of the main subroutines, and variables.
Unused programs have been removed.
LL

File size: 4.3 KB
Line 
1      subroutine soil_pem_routine(ngrid,nsoil,firstcall, &
2               therm_i,                          &
3               timestep,tsurf,tsoil,alph_PEM,beta_PEM)
4
5
6      use comsoil_h_PEM, only: layer_PEM, mlayer_PEM,  &
7                          mthermdiff_PEM, thermdiff_PEM, coefq_PEM, &
8                          coefd_PEM, mu_PEM,fluxgeo
9      use comsoil_h,only: volcapa
10      implicit none
11
12!-----------------------------------------------------------------------
13!  Author: LL
14!  Purpose: Compute soil temperature using an implict 1st order scheme
15
16!  Note: depths of layers and mid-layers, soil thermal inertia and
17!        heat capacity are commons in comsoil_PEM.h
18!        A convergence loop is added until equilibrium
19!-----------------------------------------------------------------------
20
21#include "dimensions.h"
22
23!-----------------------------------------------------------------------
24!  arguments
25!  ---------
26!  inputs:
27      integer,intent(in) :: ngrid       ! number of (horizontal) grid-points
28      integer,intent(in) :: nsoil       ! number of soil layers 
29      logical,intent(in) :: firstcall    ! identifier for initialization call
30      real,intent(in) :: therm_i(ngrid,nsoil) ! thermal inertia [SI]
31      real,intent(in) :: timestep       ! time step [s]
32      real,intent(in) :: tsurf(ngrid)   ! surface temperature [K]
33 
34! outputs:
35      real,intent(inout) :: tsoil(ngrid,nsoil) ! soil (mid-layer) temperature [K]
36      real,intent(inout) :: alph_PEM(ngrid,nsoil-1) ! intermediate for computations [1]
37      real,intent(inout) :: beta_PEM(ngrid,nsoil-1) ! intermediate for computations [K]
38     
39! local variables:
40      integer ig,ik   
41
42! 0. Initialisations and preprocessing step
43 if (firstcall) then
44   
45! 0.1 Build mthermdiff_PEM(:), the mid-layer thermal diffusivities
46      do ig=1,ngrid
47        do ik=0,nsoil-1
48          mthermdiff_PEM(ig,ik)=therm_i(ig,ik+1)*therm_i(ig,ik+1)/volcapa   
49        enddo
50      enddo
51
52! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities
53      do ig=1,ngrid
54        do ik=1,nsoil-1
55      thermdiff_PEM(ig,ik)=((layer_PEM(ik)-mlayer_PEM(ik-1))*mthermdiff_PEM(ig,ik) &
56                     +(mlayer_PEM(ik)-layer_PEM(ik))*mthermdiff_PEM(ig,ik-1))  &
57                         /(mlayer_PEM(ik)-mlayer_PEM(ik-1))
58        enddo
59      enddo
60
61! 0.3 Build coefficients mu_PEM, q_{k+1/2}, d_k, alph_PEMa_k and capcal
62      ! mu_PEM
63      mu_PEM=mlayer_PEM(0)/(mlayer_PEM(1)-mlayer_PEM(0))
64
65      ! q_{1/2}
66      coefq_PEM(0)=volcapa*layer_PEM(1)/timestep
67        ! q_{k+1/2}
68        do ik=1,nsoil-1
69          coefq_PEM(ik)=volcapa*(layer_PEM(ik+1)-layer_PEM(ik))                  &
70                      /timestep
71        enddo
72
73      do ig=1,ngrid
74        ! d_k
75        do ik=1,nsoil-1
76          coefd_PEM(ig,ik)=thermdiff_PEM(ig,ik)/(mlayer_PEM(ik)-mlayer_PEM(ik-1))
77        enddo
78       
79        ! alph_PEM_{N-1}
80        alph_PEM(ig,nsoil-1)=coefd_PEM(ig,nsoil-1)/                      &
81                       (coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1))
82        ! alph_PEM_k
83        do ik=nsoil-2,1,-1
84          alph_PEM(ig,ik)=coefd_PEM(ig,ik)/(coefq_PEM(ik)+coefd_PEM(ig,ik+1)*    &
85                                   (1.-alph_PEM(ig,ik+1))+coefd_PEM(ig,ik))
86        enddo
87
88      enddo ! of do ig=1,ngrid
89
90endif ! of if (firstcall)
91
92      IF (.not.firstcall) THEN
93!  2. Compute soil temperatures
94! First layer:
95        do ig=1,ngrid
96          tsoil(ig,1)=(tsurf(ig)+mu_PEM*beta_PEM(ig,1)* & 
97                                  thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))/ &
98                   (1.+mu_PEM*(1.0-alph_PEM(ig,1))*&
99                    thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))
100
101! Other layers:
102          do ik=1,nsoil-1
103            tsoil(ig,ik+1)=alph_PEM(ig,ik)*tsoil(ig,ik)+beta_PEM(ig,ik)
104          enddo
105        enddo
106      ENDIF
107
108!  2. Compute beta_PEM coefficients (preprocessing for next time step)
109! Bottom layer, beta_PEM_{N-1}
110      do ig=1,ngrid
111        beta_PEM(ig,nsoil-1)=coefq_PEM(nsoil-1)*tsoil(ig,nsoil)          &
112                        /(coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) &
113                 +  fluxgeo/(coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1))
114      enddo
115! Other layers
116      do ik=nsoil-2,1,-1
117        do ig=1,ngrid
118          beta_PEM(ig,ik)=(coefq_PEM(ik)*tsoil(ig,ik+1)+                 &
119                      coefd_PEM(ig,ik+1)*beta_PEM(ig,ik+1))/             &
120                      (coefq_PEM(ik)+coefd_PEM(ig,ik+1)*(1.0-alph_PEM(ig,ik+1)) &
121                       +coefd_PEM(ig,ik))
122        enddo
123      enddo
124
125      end
126
Note: See TracBrowser for help on using the repository browser.