source: trunk/LMDZ.MARS/libf/phymars/soil.F @ 171

Last change on this file since 171 was 38, checked in by emillour, 14 years ago

Ajout du modè Martien (mon LMDZ.MARS.BETA, du 28/01/2011) dans le rértoire mars, pour pouvoir suivre plus facilement les modifs.
EM

File size: 5.4 KB
Line 
1      subroutine soil(ngrid,nsoil,firstcall,
2     &          therm_i,
3     &          timestep,tsurf,tsoil,
4     &          capcal,fluxgrd)
5      implicit none
6
7!-----------------------------------------------------------------------
8!  Author: Ehouarn Millour
9!
10!  Purpose: Compute soil temperature using an implict 1st order scheme
11
12!  Note: depths of layers and mid-layers, soil thermal inertia and
13!        heat capacity are commons in comsoil.h
14!-----------------------------------------------------------------------
15
16#include "dimensions.h"
17#include "dimphys.h"
18
19#include"comsoil.h"
20
21c-----------------------------------------------------------------------
22!  arguments
23!  ---------
24!  inputs:
25      integer ngrid     ! number of (horizontal) grid-points
26      integer nsoil     ! number of soil layers
27      logical firstcall ! identifier for initialization call
28      real therm_i(ngrid,nsoil) ! thermal inertia
29      real timestep         ! time step
30      real tsurf(ngrid)   ! surface temperature
31! outputs:
32      real tsoil(ngrid,nsoil) ! soil (mid-layer) temperature
33      real capcal(ngrid) ! surface specific heat
34      real fluxgrd(ngrid) ! surface diffusive heat flux
35
36! local saved variables:
37!      real,save :: layer(ngridmx,nsoilmx)      ! layer depth
38      real,save :: mthermdiff(ngridmx,0:nsoilmx-1) ! mid-layer thermal diffusivity
39      real,save :: thermdiff(ngridmx,nsoilmx-1) ! inter-layer thermal diffusivity
40      real,save :: coefq(0:nsoilmx-1)           ! q_{k+1/2} coefficients
41      real,save :: coefd(ngridmx,nsoilmx-1)     ! d_k coefficients
42      real,save :: alph(ngridmx,nsoilmx-1)      ! alpha_k coefficients
43      real,save :: beta(ngridmx,nsoilmx-1)      ! beta_k coefficients
44      real,save :: mu
45     
46! local variables:
47      integer ig,ik
48
49! 0. Initialisations and preprocessing step
50      if (firstcall) then
51      ! note: firstcall is set to .true. or .false. by the caller
52      !       and not changed by soil.F
53! 0.1 Build mthermdiff(:), the mid-layer thermal diffusivities
54      do ig=1,ngrid
55        do ik=0,nsoil-1
56          mthermdiff(ig,ik)=therm_i(ig,ik+1)*therm_i(ig,ik+1)/volcapa
57!         write(*,*),'soil: ik: ',ik,' mthermdiff:',mthermdiff(ig,ik)
58        enddo
59      enddo
60
61! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities
62      do ig=1,ngrid
63        do ik=1,nsoil-1
64      thermdiff(ig,ik)=((layer(ik)-mlayer(ik-1))*mthermdiff(ig,ik)
65     &                +(mlayer(ik)-layer(ik))*mthermdiff(ig,ik-1))
66     &                    /(mlayer(ik)-mlayer(ik-1))
67!       write(*,*),'soil: ik: ',ik,' thermdiff:',thermdiff(ig,ik)
68        enddo
69      enddo
70
71! 0.3 Build coefficients mu, q_{k+1/2}, d_k, alpha_k and capcal
72      ! mu
73      mu=mlayer(0)/(mlayer(1)-mlayer(0))
74
75      ! q_{1/2}
76      coefq(0)=volcapa*layer(1)/timestep
77        ! q_{k+1/2}
78        do ik=1,nsoil-1
79          coefq(ik)=volcapa*(layer(ik+1)-layer(ik))
80     &                 /timestep
81        enddo
82
83      do ig=1,ngrid
84        ! d_k
85        do ik=1,nsoil-1
86          coefd(ig,ik)=thermdiff(ig,ik)/(mlayer(ik)-mlayer(ik-1))
87        enddo
88       
89        ! alph_{N-1}
90        alph(ig,nsoil-1)=coefd(ig,nsoil-1)/
91     &                  (coefq(nsoil-1)+coefd(ig,nsoil-1))
92        ! alph_k
93        do ik=nsoil-2,1,-1
94          alph(ig,ik)=coefd(ig,ik)/(coefq(ik)+coefd(ig,ik+1)*
95     &                              (1.-alph(ig,ik+1))+coefd(ig,ik))
96        enddo
97
98        ! capcal
99! Cstar
100        capcal(ig)=volcapa*layer(1)+
101     &              (thermdiff(ig,1)/(mlayer(1)-mlayer(0)))*
102     &              (timestep*(1.-alph(ig,1)))
103! Cs
104        capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))*
105     &                         thermdiff(ig,1)/mthermdiff(ig,0))
106!      write(*,*)'soil: ig=',ig,' capcal(ig)=',capcal(ig)
107      enddo ! of do ig=1,ngrid
108           
109      else ! of if (firstcall)
110
111!  1. Compute soil temperatures
112! First layer:
113      do ig=1,ngrid
114        tsoil(ig,1)=(tsurf(ig)+mu*beta(ig,1)*
115     &                         thermdiff(ig,1)/mthermdiff(ig,0))/
116     &              (1.+mu*(1.0-alph(ig,1))*
117     &               thermdiff(ig,1)/mthermdiff(ig,0))
118      enddo
119! Other layers:
120      do ik=1,nsoil-1
121        do ig=1,ngrid
122          tsoil(ig,ik+1)=alph(ig,ik)*tsoil(ig,ik)+beta(ig,ik)
123        enddo
124      enddo
125     
126      endif! of if (firstcall)
127
128!  2. Compute beta coefficients (preprocessing for next time step)
129! Bottom layer, beta_{N-1}
130      do ig=1,ngrid
131        beta(ig,nsoil-1)=coefq(nsoil-1)*tsoil(ig,nsoil)
132     &                   /(coefq(nsoil-1)+coefd(ig,nsoil-1))
133      enddo
134! Other layers
135      do ik=nsoil-2,1,-1
136        do ig=1,ngrid
137          beta(ig,ik)=(coefq(ik)*tsoil(ig,ik+1)+
138     &                 coefd(ig,ik+1)*beta(ig,ik+1))/
139     &                 (coefq(ik)+coefd(ig,ik+1)*(1.0-alph(ig,ik+1))
140     &                  +coefd(ig,ik))
141        enddo
142      enddo
143
144!  3. Compute surface diffusive flux & calorific capacity
145      do ig=1,ngrid
146! Cstar
147!        capcal(ig)=volcapa(ig,1)*layer(ig,1)+
148!     &              (thermdiff(ig,1)/(mlayer(ig,1)-mlayer(ig,0)))*
149!     &              (timestep*(1.-alph(ig,1)))
150! Fstar
151        fluxgrd(ig)=(thermdiff(ig,1)/(mlayer(1)-mlayer(0)))*
152     &              (beta(ig,1)+(alph(ig,1)-1.0)*tsoil(ig,1))
153
154!        mu=mlayer(ig,0)/(mlayer(ig,1)-mlayer(ig,0))
155!        capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))*
156!     &                         thermdiff(ig,1)/mthermdiff(ig,0))
157! Fs
158        fluxgrd(ig)=fluxgrd(ig)+(capcal(ig)/timestep)*
159     &              (tsoil(ig,1)*(1.+mu*(1.0-alph(ig,1))*
160     &                         thermdiff(ig,1)/mthermdiff(ig,0))
161     &               -tsurf(ig)-mu*beta(ig,1)*
162     &                          thermdiff(ig,1)/mthermdiff(ig,0))
163      enddo
164
165      end
166
Note: See TracBrowser for help on using the repository browser.