[1047] | 1 | module comsoil_h |
---|
| 2 | |
---|
| 3 | implicit none |
---|
| 4 | ! nsoilmx : number of subterranean layers |
---|
| 5 | !EM: old soil routine: integer, parameter :: nsoilmx = 10 |
---|
| 6 | integer, parameter :: nsoilmx = 18 |
---|
| 7 | |
---|
| 8 | real,save,allocatable,dimension(:) :: layer ! soil layer depths |
---|
| 9 | real,save,allocatable,dimension(:) :: mlayer ! soil mid-layer depths |
---|
[2942] | 10 | real,save,allocatable,dimension(:,:) :: inertiedat ! soil thermal inertia for present climate |
---|
| 11 | real,save,allocatable,dimension(:,:,:) :: inertiesoil ! soil thermal inertia |
---|
[1047] | 12 | real,save :: volcapa ! soil volumetric heat capacity |
---|
| 13 | ! NB: volcapa is read fromn control(35) from physicq start file |
---|
| 14 | ! in physdem (or set via tabfi, or initialized in |
---|
| 15 | ! soil_settings.F) |
---|
| 16 | |
---|
[2951] | 17 | !$OMP THREADPRIVATE(layer,mlayer,inertiedat,inertiesoil,volcapa) |
---|
[2578] | 18 | |
---|
[1770] | 19 | ! variables (FC: built in firstcall in soil.F) |
---|
[2900] | 20 | REAL,SAVE,ALLOCATABLE :: tsoil(:,:,:) ! sub-surface temperatures (K) |
---|
| 21 | real,save,allocatable :: mthermdiff(:,:,:) ! (FC) mid-layer thermal diffusivity |
---|
| 22 | real,save,allocatable :: thermdiff(:,:,:) ! (FC) inter-layer thermal diffusivity |
---|
[1770] | 23 | real,save,allocatable :: coefq(:) ! (FC) q_{k+1/2} coefficients |
---|
[2900] | 24 | real,save,allocatable :: coefd(:,:,:) ! (FC) d_k coefficients |
---|
| 25 | real,save,allocatable :: alph(:,:,:) ! (FC) alpha_k coefficients |
---|
| 26 | real,save,allocatable :: beta(:,:,:) ! beta_k coefficients |
---|
[1224] | 27 | real,save :: mu |
---|
[2919] | 28 | real,save,allocatable :: flux_geo(:,:) ! Geothermal Flux (W/m^2) |
---|
[1224] | 29 | |
---|
[2887] | 30 | !$OMP THREADPRIVATE(tsoil,mthermdiff,thermdiff,coefq,coefd,alph,beta,mu,flux_geo) |
---|
[2578] | 31 | |
---|
[1047] | 32 | contains |
---|
| 33 | |
---|
[2900] | 34 | subroutine ini_comsoil_h(ngrid,nslope) |
---|
[1047] | 35 | |
---|
| 36 | implicit none |
---|
| 37 | integer,intent(in) :: ngrid ! number of atmospheric columns |
---|
[2900] | 38 | integer,intent(in) :: nslope ! number of sub grid slopes |
---|
[1047] | 39 | allocate(layer(nsoilmx)) !soil layer depths |
---|
| 40 | allocate(mlayer(0:nsoilmx-1)) ! soil mid-layer depths |
---|
[2942] | 41 | allocate(inertiedat(ngrid,nsoilmx)) ! soil thermal inertia for present climate |
---|
| 42 | allocate(inertiesoil(ngrid,nsoilmx,nslope)) ! soil thermal inertia |
---|
[2900] | 43 | allocate(tsoil(ngrid,nsoilmx,nslope)) ! soil temperatures |
---|
| 44 | allocate(mthermdiff(ngrid,0:nsoilmx-1,nslope)) |
---|
| 45 | allocate(thermdiff(ngrid,nsoilmx-1,nslope)) |
---|
[1224] | 46 | allocate(coefq(0:nsoilmx-1)) |
---|
[2900] | 47 | allocate(coefd(ngrid,nsoilmx-1,nslope)) |
---|
| 48 | allocate(alph(ngrid,nsoilmx-1,nslope)) |
---|
| 49 | allocate(beta(ngrid,nsoilmx-1,nslope)) |
---|
[2919] | 50 | allocate(flux_geo(ngrid,nslope)) |
---|
[1224] | 51 | |
---|
[1047] | 52 | end subroutine ini_comsoil_h |
---|
| 53 | |
---|
[1770] | 54 | |
---|
| 55 | subroutine end_comsoil_h |
---|
| 56 | |
---|
| 57 | implicit none |
---|
| 58 | |
---|
| 59 | if (allocated(layer)) deallocate(layer) |
---|
| 60 | if (allocated(mlayer)) deallocate(mlayer) |
---|
| 61 | if (allocated(inertiedat)) deallocate(inertiedat) |
---|
[2942] | 62 | if (allocated(inertiesoil)) deallocate(inertiesoil) |
---|
[1770] | 63 | if (allocated(tsoil)) deallocate(tsoil) |
---|
| 64 | if (allocated(mthermdiff)) deallocate(mthermdiff) |
---|
| 65 | if (allocated(thermdiff)) deallocate(thermdiff) |
---|
| 66 | if (allocated(coefq)) deallocate(coefq) |
---|
| 67 | if (allocated(coefd)) deallocate(coefd) |
---|
| 68 | if (allocated(alph)) deallocate(alph) |
---|
| 69 | if (allocated(beta)) deallocate(beta) |
---|
[2887] | 70 | if (allocated(flux_geo)) deallocate(flux_geo) |
---|
[1770] | 71 | end subroutine end_comsoil_h |
---|
| 72 | |
---|
[2909] | 73 | subroutine ini_comsoil_h_slope_var(ngrid,nslope) |
---|
| 74 | |
---|
| 75 | implicit none |
---|
| 76 | integer,intent(in) :: ngrid ! number of atmospheric columns |
---|
| 77 | integer,intent(in) :: nslope ! number of sub grid slopes |
---|
| 78 | |
---|
| 79 | allocate(tsoil(ngrid,nsoilmx,nslope)) ! soil temperatures |
---|
[2942] | 80 | allocate(inertiesoil(ngrid,nsoilmx,nslope)) ! soil thermal inertia |
---|
[2909] | 81 | allocate(mthermdiff(ngrid,0:nsoilmx-1,nslope)) |
---|
| 82 | allocate(thermdiff(ngrid,nsoilmx-1,nslope)) |
---|
| 83 | allocate(coefd(ngrid,nsoilmx-1,nslope)) |
---|
| 84 | allocate(alph(ngrid,nsoilmx-1,nslope)) |
---|
| 85 | allocate(beta(ngrid,nsoilmx-1,nslope)) |
---|
[2952] | 86 | allocate(flux_geo(ngrid,nslope)) |
---|
[2909] | 87 | |
---|
| 88 | end subroutine ini_comsoil_h_slope_var |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | subroutine end_comsoil_h_slope_var |
---|
| 92 | |
---|
| 93 | implicit none |
---|
| 94 | |
---|
| 95 | if (allocated(tsoil)) deallocate(tsoil) |
---|
[2942] | 96 | if (allocated(inertiesoil)) deallocate(inertiesoil) |
---|
[2909] | 97 | if (allocated(mthermdiff)) deallocate(mthermdiff) |
---|
| 98 | if (allocated(thermdiff)) deallocate(thermdiff) |
---|
| 99 | if (allocated(coefd)) deallocate(coefd) |
---|
| 100 | if (allocated(alph)) deallocate(alph) |
---|
| 101 | if (allocated(beta)) deallocate(beta) |
---|
[2952] | 102 | if (allocated(flux_geo)) deallocate(flux_geo) |
---|
[2909] | 103 | |
---|
| 104 | end subroutine end_comsoil_h_slope_var |
---|
| 105 | |
---|
[1047] | 106 | end module comsoil_h |
---|