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

Last change on this file since 3026 was 2919, checked in by llange, 22 months ago

PCM
Flux_geo is now correctled initialized (wasnot correctly read in the startfi) for the 3D and 1D
Minor fix in the pem (wrong name for a variable)
LL

File size: 6.7 KB
RevLine 
[38]1      subroutine soil(ngrid,nsoil,firstcall,
2     &          therm_i,
3     &          timestep,tsurf,tsoil,
4     &          capcal,fluxgrd)
[1224]5
6      use comsoil_h, only: layer, mlayer, volcapa,
7     &                     mthermdiff, thermdiff, coefq,
[2887]8     &                     coefd, alph, beta, mu,flux_geo
[1047]9      use surfdat_h, only: watercaptag, inert_h2o_ice
[2900]10      use comslope_mod, ONLY: nslope
[38]11      implicit none
12
13!-----------------------------------------------------------------------
14!  Author: Ehouarn Millour
15!
16!  Purpose: Compute soil temperature using an implict 1st order scheme
17
18!  Note: depths of layers and mid-layers, soil thermal inertia and
[1047]19!        heat capacity are commons in comsoil_h
[38]20!-----------------------------------------------------------------------
21
[1266]22#include "callkeys.h"
[38]23
24c-----------------------------------------------------------------------
25!  arguments
26!  ---------
27!  inputs:
28      integer ngrid     ! number of (horizontal) grid-points
29      integer nsoil     ! number of soil layers
30      logical firstcall ! identifier for initialization call
[2900]31      real therm_i(ngrid,nsoil,nslope) ! thermal inertia
[38]32      real timestep         ! time step
[2900]33      real tsurf(ngrid,nslope)   ! surface temperature
[38]34! outputs:
[2900]35      real tsoil(ngrid,nsoil,nslope) ! soil (mid-layer) temperature
36      real capcal(ngrid,nslope) ! surface specific heat
37      real fluxgrd(ngrid,nslope) ! surface diffusive heat flux
[38]38
39! local variables:
[2900]40      integer ig,ik,islope
[38]41
42! 0. Initialisations and preprocessing step
[833]43      if (firstcall.or.tifeedback) then
[38]44      ! note: firstcall is set to .true. or .false. by the caller
45      !       and not changed by soil.F
46! 0.1 Build mthermdiff(:), the mid-layer thermal diffusivities
47      do ig=1,ngrid
[2900]48       do islope = 1,nslope
[283]49        if (watercaptag(ig)) then
50          do ik=0,nsoil-1
51! If we have permanent ice, we use the water ice thermal inertia from ground to last layer.
[2900]52              mthermdiff(ig,ik,islope)=inert_h2o_ice*
53     &            inert_h2o_ice/volcapa
[283]54          enddo
55        else
56          do ik=0,nsoil-1
[2900]57           mthermdiff(ig,ik,islope)=therm_i(ig,ik+1,islope)*
58     &         therm_i(ig,ik+1,islope)/volcapa
[283]59          enddo
60        endif
[38]61      enddo
[2900]62      enddo
[38]63
[285]64#ifdef MESOSCALE
65      do ig=1,ngrid
[2900]66       do islope = 1,nslope
67        if ( therm_i(ig,1,islope) .ge. inert_h2o_ice ) then
68          print *, "limit max TI ", therm_i(ig,1,islope), inert_h2o_ice
[285]69          do ik=0,nsoil-1
[2900]70               mthermdiff(ig,ik,islope)=inert_h2o_ice*
71     &    inert_h2o_ice/volcapa
[285]72          enddo
73        endif
[2900]74       enddo
[285]75      enddo
76#endif
77
[38]78! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities
79      do ig=1,ngrid
[2900]80       do islope = 1,nslope
[38]81        do ik=1,nsoil-1
[2900]82      thermdiff(ig,ik,islope)=((layer(ik)-mlayer(ik-1))
83     &                        *mthermdiff(ig,ik,islope)
84     &                +(mlayer(ik)-layer(ik))
85     &                *mthermdiff(ig,ik-1,islope))
[38]86     &                    /(mlayer(ik)-mlayer(ik-1))
87!       write(*,*),'soil: ik: ',ik,' thermdiff:',thermdiff(ig,ik)
88        enddo
[2900]89       enddo
[38]90      enddo
91
92! 0.3 Build coefficients mu, q_{k+1/2}, d_k, alpha_k and capcal
93      ! mu
94      mu=mlayer(0)/(mlayer(1)-mlayer(0))
95
96      ! q_{1/2}
97      coefq(0)=volcapa*layer(1)/timestep
98        ! q_{k+1/2}
99        do ik=1,nsoil-1
100          coefq(ik)=volcapa*(layer(ik+1)-layer(ik))
101     &                 /timestep
102        enddo
103
104      do ig=1,ngrid
[2900]105       do islope = 1,nslope
[38]106        ! d_k
107        do ik=1,nsoil-1
[2900]108          coefd(ig,ik,islope)=thermdiff(ig,ik,islope)
109     &        /(mlayer(ik)-mlayer(ik-1))
[38]110        enddo
111       
112        ! alph_{N-1}
[2900]113        alph(ig,nsoil-1,islope)=coefd(ig,nsoil-1,islope)/
114     &                  (coefq(nsoil-1)+coefd(ig,nsoil-1,islope))
[38]115        ! alph_k
116        do ik=nsoil-2,1,-1
[2900]117          alph(ig,ik,islope)=coefd(ig,ik,islope)/
118     &         (coefq(ik)+coefd(ig,ik+1,islope)*
119     &          (1.-alph(ig,ik+1,islope))+coefd(ig,ik,islope))
[38]120        enddo
121
122        ! capcal
123! Cstar
[2900]124        capcal(ig,islope)=volcapa*layer(1)+
125     &         (thermdiff(ig,1,islope)/(mlayer(1)-mlayer(0)))*
126     &         (timestep*(1.-alph(ig,1,islope)))
[38]127! Cs
[2900]128        capcal(ig,islope)=capcal(ig,islope)/
129     &            (1.+mu*(1.0-alph(ig,1,islope))*
130     &            thermdiff(ig,1,islope)/mthermdiff(ig,0,islope))
[38]131!      write(*,*)'soil: ig=',ig,' capcal(ig)=',capcal(ig)
[2900]132      enddo ! islope
[38]133      enddo ! of do ig=1,ngrid
134           
[833]135      endif ! of if (firstcall.or.tifeedback)
[38]136
137!  1. Compute soil temperatures
[833]138      IF (.not.firstcall) THEN
[38]139! First layer:
[2900]140      do islope = 1,nslope
[38]141      do ig=1,ngrid
[2900]142        tsoil(ig,1,islope)=(tsurf(ig,islope)+mu*beta(ig,1,islope)*
143     &      thermdiff(ig,1,islope)/mthermdiff(ig,0,islope))/
144     &      (1.+mu*(1.0-alph(ig,1,islope))*
145     &      thermdiff(ig,1,islope)/mthermdiff(ig,0,islope))
[38]146      enddo
147! Other layers:
148      do ik=1,nsoil-1
149        do ig=1,ngrid
[2900]150          tsoil(ig,ik+1,islope)=alph(ig,ik,islope)*
151     &    tsoil(ig,ik,islope)+beta(ig,ik,islope)
[38]152        enddo
153      enddo
[2900]154       enddo ! islope
[833]155      ENDIF! of if (.not.firstcall)
[38]156
157!  2. Compute beta coefficients (preprocessing for next time step)
158! Bottom layer, beta_{N-1}
[2900]159       do islope = 1,nslope
[38]160      do ig=1,ngrid
[2900]161        beta(ig,nsoil-1,islope)=coefq(nsoil-1)*tsoil(ig,nsoil,islope)
162     &      /(coefq(nsoil-1)+coefd(ig,nsoil-1,islope))
[2919]163     &      +flux_geo(ig,islope)/
164     &      (coefq(nsoil-1) + coefd(ig,nsoil-1,islope))
[38]165      enddo
[2887]166   
[38]167! Other layers
168      do ik=nsoil-2,1,-1
169        do ig=1,ngrid
[2900]170          beta(ig,ik,islope)=(coefq(ik)*tsoil(ig,ik+1,islope)+
171     &                 coefd(ig,ik+1,islope)*beta(ig,ik+1,islope))/
172     &                 (coefq(ik)+coefd(ig,ik+1,islope)*
173     &                 (1.0-alph(ig,ik+1,islope))
174     &                  +coefd(ig,ik,islope))
[38]175        enddo
176      enddo
177
178!  3. Compute surface diffusive flux & calorific capacity
179      do ig=1,ngrid
180! Cstar
181!        capcal(ig)=volcapa(ig,1)*layer(ig,1)+
182!     &              (thermdiff(ig,1)/(mlayer(ig,1)-mlayer(ig,0)))*
183!     &              (timestep*(1.-alph(ig,1)))
184! Fstar
[2900]185        fluxgrd(ig,islope)=(thermdiff(ig,1,islope)/
186     &              (mlayer(1)-mlayer(0)))*
187     &              (beta(ig,1,islope)+(alph(ig,1,islope)-1.0)
188     &              *tsoil(ig,1,islope))
[38]189
190!        mu=mlayer(ig,0)/(mlayer(ig,1)-mlayer(ig,0))
191!        capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))*
192!     &                         thermdiff(ig,1)/mthermdiff(ig,0))
193! Fs
[2900]194        fluxgrd(ig,islope)=fluxgrd(ig,islope)+(capcal(ig,islope)
195     &              /timestep)*
196     &              (tsoil(ig,1,islope)*
197     &              (1.+mu*(1.0-alph(ig,1,islope))*
198     &               thermdiff(ig,1,islope)/mthermdiff(ig,0,islope))
199     &               -tsurf(ig,islope)-mu*beta(ig,1,islope)*
200     &                thermdiff(ig,1,islope)/mthermdiff(ig,0,islope))
[38]201      enddo
[2900]202      enddo ! islope
[38]203      end
204
Note: See TracBrowser for help on using the repository browser.