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

Last change on this file since 3046 was 2895, checked in by llange, 2 years ago

PEM
Soil temperature initialisation has been updated
Conf_PEM improved by adding some options to the users (thermal regolith depend on the pressure, depth of the subsurface layers, etc.)
Minor edits then (+ svn update with RV had some issues, so there are some "artefact changes" ...)
LL

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