| 1 | MODULE comsoil_h |
|---|
| 2 | |
|---|
| 3 | implicit none |
|---|
| 4 | |
|---|
| 5 | ! nsoilmx : number of subterranean layers |
|---|
| 6 | integer, parameter :: nsoilmx = 57 |
|---|
| 7 | |
|---|
| 8 | real, save, allocatable, dimension(:) :: layer ! soil layer depths |
|---|
| 9 | real, save, allocatable, dimension(:) :: mlayer ! soil mid-layer depths |
|---|
| 10 | real, save, allocatable, dimension(:,:) :: inertiedat ! soil thermal inertia for present climate |
|---|
| 11 | real, save, allocatable, dimension(:,:,:) :: inertiesoil ! soil thermal inertia |
|---|
| 12 | real, save :: volcapa ! soil volumetric heat capacity |
|---|
| 13 | ! NB: volcapa is read from control(35) from physics start file |
|---|
| 14 | ! in physdem (or set via tabfi, or initialized in soil_settings.F) |
|---|
| 15 | |
|---|
| 16 | !$OMP THREADPRIVATE(layer,mlayer,inertiedat,inertiesoil,volcapa) |
|---|
| 17 | |
|---|
| 18 | ! Variables (FC: built in firstcall in soil.F) |
|---|
| 19 | real, save, allocatable, dimension(:,:,:) :: tsoil ! sub-surface temperatures (K) |
|---|
| 20 | real, save, allocatable, dimension(:,:,:) :: mthermdiff ! (FC) mid-layer thermal diffusivity |
|---|
| 21 | real, save, allocatable, dimension(:,:,:) :: thermdiff ! (FC) inter-layer thermal diffusivity |
|---|
| 22 | real, save, allocatable, dimension(:) :: coefq ! (FC) q_{k+1/2} coefficients |
|---|
| 23 | real, save, allocatable, dimension(:,:,:) :: coefd ! (FC) d_k coefficients |
|---|
| 24 | real, save, allocatable, dimension(:,:,:) :: alph ! (FC) alpha_k coefficients |
|---|
| 25 | real, save, allocatable, dimension(:,:,:) :: beta ! beta_k coefficients |
|---|
| 26 | real, save, allocatable, dimension(:,:) :: flux_geo ! Geothermal Flux (W/m^2) |
|---|
| 27 | real, save :: mu |
|---|
| 28 | |
|---|
| 29 | !$OMP THREADPRIVATE(tsoil,mthermdiff,thermdiff,coefq,coefd,alph,beta,mu,flux_geo) |
|---|
| 30 | |
|---|
| 31 | ! Subsurface tracers: |
|---|
| 32 | logical, save :: adsorption_soil ! boolean to call adosrption (or not) |
|---|
| 33 | real, save :: choice_ads ! Choice for adsorption isotherm (3 means no adsorption, see soilwater.F90) |
|---|
| 34 | real, save, allocatable, dimension(:,:,:,:) :: qsoil ! subsurface tracers (kg/m^3 of regol) |
|---|
| 35 | integer, parameter :: nqsoil = 3 ! number of subsurface tracers, only three when working with water |
|---|
| 36 | integer, parameter :: igcm_h2o_vap_soil = 1 |
|---|
| 37 | integer, parameter :: igcm_h2o_ice_soil = 2 |
|---|
| 38 | integer, parameter :: igcm_h2o_vap_ads = 3 |
|---|
| 39 | REAL, parameter :: porosity_reg = 0.45 |
|---|
| 40 | !$OMP THREADPRIVATE(adsorption_soil,qsoil,choice_ads) |
|---|
| 41 | |
|---|
| 42 | !======================================================================= |
|---|
| 43 | contains |
|---|
| 44 | !======================================================================= |
|---|
| 45 | |
|---|
| 46 | subroutine ini_comsoil_h(ngrid,nslope) |
|---|
| 47 | |
|---|
| 48 | implicit none |
|---|
| 49 | |
|---|
| 50 | integer,intent(in) :: ngrid ! number of atmospheric columns |
|---|
| 51 | integer,intent(in) :: nslope ! number of sub grid slopes |
|---|
| 52 | |
|---|
| 53 | allocate(layer(nsoilmx)) !soil layer depths |
|---|
| 54 | allocate(mlayer(0:nsoilmx - 1)) ! soil mid-layer depths |
|---|
| 55 | allocate(inertiedat(ngrid,nsoilmx)) ! soil thermal inertia for present climate |
|---|
| 56 | allocate(inertiesoil(ngrid,nsoilmx,nslope)) ! soil thermal inertia |
|---|
| 57 | allocate(tsoil(ngrid,nsoilmx,nslope)) ! soil temperatures |
|---|
| 58 | allocate(mthermdiff(ngrid,0:nsoilmx - 1,nslope)) |
|---|
| 59 | allocate(thermdiff(ngrid,nsoilmx - 1,nslope)) |
|---|
| 60 | allocate(coefq(0:nsoilmx - 1)) |
|---|
| 61 | allocate(coefd(ngrid,nsoilmx - 1,nslope)) |
|---|
| 62 | allocate(alph(ngrid,nsoilmx - 1,nslope)) |
|---|
| 63 | allocate(beta(ngrid,nsoilmx - 1,nslope)) |
|---|
| 64 | allocate(flux_geo(ngrid,nslope)) |
|---|
| 65 | allocate(qsoil(ngrid,nsoilmx,nqsoil,nslope)) |
|---|
| 66 | |
|---|
| 67 | END SUBROUTINE ini_comsoil_h |
|---|
| 68 | |
|---|
| 69 | !======================================================================= |
|---|
| 70 | SUBROUTINE end_comsoil_h |
|---|
| 71 | |
|---|
| 72 | implicit none |
|---|
| 73 | |
|---|
| 74 | if (allocated(layer)) deallocate(layer) |
|---|
| 75 | if (allocated(mlayer)) deallocate(mlayer) |
|---|
| 76 | if (allocated(inertiedat)) deallocate(inertiedat) |
|---|
| 77 | if (allocated(inertiesoil)) deallocate(inertiesoil) |
|---|
| 78 | if (allocated(tsoil)) deallocate(tsoil) |
|---|
| 79 | if (allocated(mthermdiff)) deallocate(mthermdiff) |
|---|
| 80 | if (allocated(thermdiff)) deallocate(thermdiff) |
|---|
| 81 | if (allocated(coefq)) deallocate(coefq) |
|---|
| 82 | if (allocated(coefd)) deallocate(coefd) |
|---|
| 83 | if (allocated(alph)) deallocate(alph) |
|---|
| 84 | if (allocated(beta)) deallocate(beta) |
|---|
| 85 | if (allocated(flux_geo)) deallocate(flux_geo) |
|---|
| 86 | if (allocated(qsoil)) deallocate(qsoil) |
|---|
| 87 | |
|---|
| 88 | END SUBROUTINE end_comsoil_h |
|---|
| 89 | |
|---|
| 90 | !======================================================================= |
|---|
| 91 | SUBROUTINE ini_comsoil_h_slope_var(ngrid,nslope) |
|---|
| 92 | |
|---|
| 93 | implicit none |
|---|
| 94 | |
|---|
| 95 | integer,intent(in) :: ngrid ! number of atmospheric columns |
|---|
| 96 | integer,intent(in) :: nslope ! number of sub grid slopes |
|---|
| 97 | |
|---|
| 98 | allocate(tsoil(ngrid,nsoilmx,nslope)) ! soil temperatures |
|---|
| 99 | allocate(inertiesoil(ngrid,nsoilmx,nslope)) ! soil thermal inertia |
|---|
| 100 | allocate(mthermdiff(ngrid,0:nsoilmx - 1,nslope)) |
|---|
| 101 | allocate(thermdiff(ngrid,nsoilmx - 1,nslope)) |
|---|
| 102 | allocate(coefd(ngrid,nsoilmx - 1,nslope)) |
|---|
| 103 | allocate(alph(ngrid,nsoilmx - 1,nslope)) |
|---|
| 104 | allocate(beta(ngrid,nsoilmx - 1,nslope)) |
|---|
| 105 | allocate(flux_geo(ngrid,nslope)) |
|---|
| 106 | allocate(qsoil(ngrid,nsoilmx,nqsoil,nslope)) |
|---|
| 107 | |
|---|
| 108 | END SUBROUTINE ini_comsoil_h_slope_var |
|---|
| 109 | |
|---|
| 110 | !======================================================================= |
|---|
| 111 | SUBROUTINE end_comsoil_h_slope_var |
|---|
| 112 | |
|---|
| 113 | implicit none |
|---|
| 114 | |
|---|
| 115 | if (allocated(tsoil)) deallocate(tsoil) |
|---|
| 116 | if (allocated(inertiesoil)) deallocate(inertiesoil) |
|---|
| 117 | if (allocated(mthermdiff)) deallocate(mthermdiff) |
|---|
| 118 | if (allocated(thermdiff)) deallocate(thermdiff) |
|---|
| 119 | if (allocated(coefd)) deallocate(coefd) |
|---|
| 120 | if (allocated(alph)) deallocate(alph) |
|---|
| 121 | if (allocated(beta)) deallocate(beta) |
|---|
| 122 | if (allocated(flux_geo)) deallocate(flux_geo) |
|---|
| 123 | if (allocated(qsoil)) deallocate(qsoil) |
|---|
| 124 | |
|---|
| 125 | END SUBROUTINE end_comsoil_h_slope_var |
|---|
| 126 | |
|---|
| 127 | END MODULE comsoil_h |
|---|