[2794] | 1 | SUBROUTINE computeice_table(timelen,ngrid,nslope,nsoil_GCM,nsoil_PEM,tsoil,tsurf,q_co2,q_h2o,ps,ice_table) |
---|
| 2 | USE comsoil_h, only: inertiedat, volcapa |
---|
| 3 | USE vertical_layers_mod, ONLY: ap,bp |
---|
| 4 | USE comsoil_h_PEM, only: layer_PEM |
---|
| 5 | implicit none |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | integer,intent(in) :: timelen,ngrid,nslope,nsoil_PEM,nsoil_GCM |
---|
| 9 | real,intent(in) :: tsoil(ngrid,nsoil_PEM,nslope,timelen) ! soil temperature, timeseries [K] |
---|
| 10 | real,intent(in) :: tsurf(ngrid,nslope,timelen) ! surface temperature [K] |
---|
| 11 | real,intent(in) :: q_co2(ngrid,timelen) ! MMR tracer co2 [kg/kg] |
---|
| 12 | real,intent(in) :: q_h2o(ngrid,timelen) ! MMR tracer h2o [kg/kg] |
---|
| 13 | real,intent(in) :: ps(ngrid,timelen) ! surface pressure [Pa] |
---|
| 14 | real,intent(out) :: ice_table(ngrid,nslope) ! ice table [m] |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | real :: m_h2o = 18.01528E-3 |
---|
| 18 | real :: m_co2 = 44.01E-3 |
---|
| 19 | real :: m_noco2 = 33.37E-3 |
---|
| 20 | real :: A,B,z1,z2 |
---|
| 21 | real :: alpha = -6143.7 |
---|
| 22 | real :: beta = 29.9074 |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | integer ig, islope,isoil,it |
---|
| 26 | real,allocatable :: mass_mean(:,:) ! mean mass above the surface |
---|
| 27 | real,allocatable :: zplev_mean(:,:) ! pressure above the surface |
---|
| 28 | real,allocatable :: pvapor(:,:) ! partial pressure above the surface |
---|
| 29 | |
---|
| 30 | real,allocatable :: rhovapor(:,:,:) |
---|
| 31 | real,allocatable :: rhovapor_avg(:,:) ! mean vapor_density at the surface yearly averaged |
---|
| 32 | |
---|
| 33 | real :: psv_surf |
---|
| 34 | real,allocatable :: rho_soil(:,:,:,:) ! water vapor in the soil |
---|
| 35 | real,allocatable :: rho_soil_avg(:,:,:) ! water vapor in the soil yearly averaged |
---|
| 36 | |
---|
| 37 | real,allocatable :: diff_rho(:,:,:) ! difference of vapor content |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | allocate(rhovapor(ngrid,nslope,timelen)) |
---|
| 42 | allocate(rhovapor_avg(ngrid,nslope)) |
---|
| 43 | allocate(pvapor(ngrid,timelen)) |
---|
| 44 | |
---|
| 45 | allocate(mass_mean(ngrid,timelen)) |
---|
| 46 | allocate(zplev_mean(ngrid,timelen)) |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | ! 0. Some initializations |
---|
| 52 | |
---|
| 53 | A =(1/m_co2 - 1/m_noco2) |
---|
| 54 | B=1/m_noco2 |
---|
| 55 | ! 1. Compute rho surface yearly averaged |
---|
| 56 | |
---|
| 57 | ! 1.1 Compute the partial pressure of vapor |
---|
| 58 | !a. the molecular mass into the column |
---|
| 59 | do ig = 1,ngrid |
---|
| 60 | mass_mean(ig,:) = 1/(A*q_co2(ig,:) +B) |
---|
| 61 | enddo |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | ! b. pressure level |
---|
| 65 | do it = 1,timelen |
---|
| 66 | do ig = 1,ngrid |
---|
| 67 | zplev_mean(ig,it) = ap(1) + bp(1)*ps(ig,it) |
---|
| 68 | enddo |
---|
| 69 | enddo |
---|
| 70 | |
---|
| 71 | ! c. Vapor pressure |
---|
| 72 | pvapor(:,:) = mass_mean(:,:)/m_h2o*q_h2o(:,:)*zplev_mean(:,:) |
---|
| 73 | |
---|
| 74 | deallocate(mass_mean) |
---|
| 75 | deallocate(zplev_mean) |
---|
| 76 | |
---|
| 77 | ! 1.2 Check if there is frost at the surface and then compute the density |
---|
| 78 | ! at the surface |
---|
| 79 | do ig = 1,ngrid |
---|
| 80 | do islope = 1,nslope |
---|
| 81 | do it = 1,timelen |
---|
| 82 | psv_surf = exp(alpha/tsurf(ig,islope,it) +beta) |
---|
| 83 | if ((isnan(psv_surf)).or.(isnan(pvapor(ig,it)))) then |
---|
| 84 | write(*,*) 'pb vapor',ig,islope,it |
---|
| 85 | stop |
---|
| 86 | endif |
---|
| 87 | rhovapor(ig,islope,it) = min(psv_surf,pvapor(ig,it))/tsurf(ig,islope,it) |
---|
| 88 | enddo |
---|
| 89 | enddo |
---|
| 90 | enddo |
---|
| 91 | deallocate(pvapor) |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | ! 1.3 Density at the surface yearly averaged |
---|
| 97 | rhovapor_avg(:,:) = SUM(rhovapor(:,:,:),3)/timelen |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | deallocate(rhovapor) |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | ! 2. Compute rho soil vapor |
---|
| 106 | |
---|
| 107 | allocate(rho_soil_avg(ngrid,nslope,nsoil_PEM)) |
---|
| 108 | allocate(rho_soil(ngrid,nslope,nsoil_PEM,timelen)) |
---|
| 109 | |
---|
| 110 | do ig = 1,ngrid |
---|
| 111 | do islope = 1,nslope |
---|
| 112 | do isoil = 1,nsoil_PEM |
---|
| 113 | do it = 1,timelen |
---|
| 114 | rho_soil(ig,islope,isoil,it) = exp(alpha/tsoil(ig,isoil,islope,it) +beta)/tsoil(ig,isoil,islope,it) |
---|
| 115 | enddo |
---|
| 116 | enddo |
---|
| 117 | enddo |
---|
| 118 | enddo |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | rho_soil_avg(:,:,:) = SUM( rho_soil(:,:,:,:),4)/timelen |
---|
| 123 | deallocate(rho_soil) |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | ! 3. Computing ice table |
---|
| 128 | |
---|
| 129 | ice_table (:,:) = -1e4 |
---|
| 130 | |
---|
| 131 | allocate(diff_rho(ngrid,nslope,nsoil_PEM)) |
---|
| 132 | |
---|
| 133 | do isoil = 1,nsoil_PEM |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | diff_rho(:,:,isoil) = rhovapor_avg(:,:) - rho_soil_avg(:,:,isoil) |
---|
| 137 | ! write(*,*) 'diff =',ig,islope,isoil,diff_rho(ig,islope,isoil),rhovapor_avg(ig,islope) ,rho_soil_avg(ig,islope,isoil) |
---|
| 138 | enddo |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | deallocate(rhovapor_avg) |
---|
| 142 | deallocate(rho_soil_avg) |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | do ig = 1,ngrid |
---|
| 151 | do islope = 1,nslope |
---|
| 152 | if(diff_rho(ig,islope,1) > 0) then |
---|
| 153 | ice_table(ig,islope) = 0. |
---|
| 154 | else |
---|
| 155 | do isoil = 1,nsoil_PEM -1 |
---|
| 156 | if((diff_rho(ig,islope,isoil).lt.0).and.(diff_rho(ig,islope,isoil+1).gt.0.)) then |
---|
| 157 | z1 = (diff_rho(ig,islope,isoil) - diff_rho(ig,islope,isoil+1))/(layer_PEM(isoil) - layer_PEM(isoil+1)) |
---|
| 158 | z2 = -layer_PEM(isoil+1)*z1 + diff_rho(ig,islope,isoil+1) |
---|
| 159 | ice_table(ig,islope) = -z2/z1 |
---|
| 160 | exit |
---|
| 161 | endif |
---|
| 162 | enddo |
---|
| 163 | endif |
---|
| 164 | enddo |
---|
| 165 | enddo |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | deallocate(diff_rho) |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | !======================================================================= |
---|
| 176 | RETURN |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | END |
---|