source: trunk/LMDZ.COMMON/libf/evolution/soil_pem_ini_mod.F90 @ 3093

Last change on this file since 3093 was 3076, checked in by jbclement, 14 months ago

PEM:
Big cleaning/improvements of the PEM:

  • Conversion of "abort_pem.F" and "soil_settings_PEM.F" into Fortran 90;
  • Transformation of every PEM subroutines into module;
  • Rewriting of many subroutines with modern Fortran syntax;
  • Correction of a bug in "pem.F90" when calling 'recomp_tend_co2_slope'. The arguments were given in disorder and emissivity was missing;
  • Update of "launch_pem.sh" in deftank.

JBC

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