1 | subroutine soil_settings_PEM(ngrid,nslope,nsoil_PEM,nsoil_GCM, |
---|
2 | & TI_GCM,TI_PEM) |
---|
3 | |
---|
4 | |
---|
5 | ! use netcdf |
---|
6 | use comsoil_h_PEM, only: layer_PEM, mlayer_PEM |
---|
7 | use comsoil_h, only: inertiedat,layer,mlayer, volcapa |
---|
8 | use iostart, only: inquire_field_ndims, get_var, get_field, |
---|
9 | & inquire_field, inquire_dimension_length |
---|
10 | |
---|
11 | implicit none |
---|
12 | |
---|
13 | !====================================================================== |
---|
14 | ! Author: Ehouarn Millour (07/2006) |
---|
15 | ! |
---|
16 | ! Purpose: Read and/or initialise soil depths and properties |
---|
17 | ! |
---|
18 | ! Modifications: Aug.2010 EM : use NetCDF90 to load variables (enables using |
---|
19 | ! r4 or r8 restarts independently of having compiled |
---|
20 | ! the GCM in r4 or r8) |
---|
21 | ! June 2013 TN : Possibility to read files with a time axis |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! This subroutine reads from a NetCDF file (opened by the caller) |
---|
25 | ! of "startfi.nc" format. |
---|
26 | ! The various actions and variable read/initialized are: |
---|
27 | ! 1. Check out the number of soil layers (in datafile); if it isn't equal |
---|
28 | ! to nsoil, then some interpolation will be required |
---|
29 | ! Also check if data in file "startfi.nc" is in older format (ie: |
---|
30 | ! thermal inertia was depth-independent; and there was no "depth" |
---|
31 | ! coordinate. |
---|
32 | ! Read/build layer (and midlayer) depths |
---|
33 | ! 2. Read volumetric specific heat (or initialise it to default value) |
---|
34 | ! 3. Read Thermal inertia |
---|
35 | ! 4. Read soil temperatures |
---|
36 | ! 5. Interpolate thermal inertia and temperature on the new grid, if |
---|
37 | ! necessary |
---|
38 | !====================================================================== |
---|
39 | |
---|
40 | !====================================================================== |
---|
41 | ! arguments |
---|
42 | ! --------- |
---|
43 | ! inputs: |
---|
44 | integer,intent(in) :: ngrid ! # of horizontal grid points |
---|
45 | integer,intent(in) :: nslope ! # of subslope wihtin the mesh |
---|
46 | integer,intent(in) :: nsoil_PEM ! # of soil layers in the PEM |
---|
47 | integer,intent(in) :: nsoil_GCM ! # of soil layers in the GCM |
---|
48 | real,intent(in) :: TI_GCM(ngrid,nsoil_GCM,nslope) ! # of soil layers in the GCM |
---|
49 | real,intent(inout) :: TI_PEM(ngrid,nsoil_PEM,nslope) ! # of soil layers in the PEM |
---|
50 | |
---|
51 | !====================================================================== |
---|
52 | ! local variables: |
---|
53 | integer ig,iloop,islope ! loop counters |
---|
54 | logical found |
---|
55 | |
---|
56 | real alpha,lay1 ! coefficients for building layers |
---|
57 | real xmin,xmax ! to display min and max of a field |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | !====================================================================== |
---|
62 | |
---|
63 | ! 1. Depth coordinate |
---|
64 | ! ------------------- |
---|
65 | |
---|
66 | ! 1.4 Build mlayer(), if necessary |
---|
67 | ! if (interpol) then |
---|
68 | ! default mlayer distribution, following a power law: |
---|
69 | ! mlayer(k)=lay1*alpha**(k-1/2) |
---|
70 | lay1=2.e-4 |
---|
71 | alpha=2 |
---|
72 | do iloop=0,nsoil_PEM-1 |
---|
73 | mlayer_PEM(iloop)=lay1*(alpha**(iloop-0.5)) |
---|
74 | enddo |
---|
75 | ! endif |
---|
76 | |
---|
77 | ! 1.5 Build layer(); following the same law as mlayer() |
---|
78 | ! Assuming layer distribution follows mid-layer law: |
---|
79 | ! layer(k)=lay1*alpha**(k-1) |
---|
80 | lay1=sqrt(mlayer_PEM(0)*mlayer_PEM(1)) |
---|
81 | alpha=mlayer_PEM(1)/mlayer_PEM(0) |
---|
82 | do iloop=1,nsoil_PEM |
---|
83 | layer_PEM(iloop)=lay1*(alpha**(iloop-1)) |
---|
84 | enddo |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | ! 2. Thermal inertia (note: it is declared in comsoil_h) |
---|
90 | ! ------------------ |
---|
91 | |
---|
92 | |
---|
93 | do ig = 1,ngrid |
---|
94 | do islope = 1,nslope |
---|
95 | do iloop = 1,nsoil_GCM |
---|
96 | TI_PEM(ig,iloop,islope) = TI_GCM(ig,iloop,islope) |
---|
97 | enddo |
---|
98 | if(nsoil_PEM.gt.nsoil_GCM) then |
---|
99 | do iloop = nsoil_GCM+1,nsoil_PEM |
---|
100 | TI_PEM(ig,iloop,islope) = TI_GCM(ig,nsoil_GCM,islope) |
---|
101 | enddo |
---|
102 | endif |
---|
103 | enddo |
---|
104 | enddo |
---|
105 | end subroutine soil_settings_PEM |
---|