| 1 | MODULE etat0_heldsz_mod |
|---|
| 2 | USE icosa |
|---|
| 3 | IMPLICIT NONE |
|---|
| 4 | PRIVATE |
|---|
| 5 | |
|---|
| 6 | TYPE(t_field),POINTER :: f_theta_eq(:) |
|---|
| 7 | TYPE(t_field),POINTER :: f_theta(:) |
|---|
| 8 | |
|---|
| 9 | REAL(rstd),ALLOCATABLE,SAVE :: knewt_t(:),kfrict(:) |
|---|
| 10 | !$OMP THREADPRIVATE(knewt_t,kfrict) |
|---|
| 11 | LOGICAL, SAVE :: done=.FALSE. |
|---|
| 12 | !$OMP THREADPRIVATE(done) |
|---|
| 13 | |
|---|
| 14 | REAL(rstd),SAVE :: teta0,ttp,delt_y,delt_z,eps |
|---|
| 15 | !$OMP THREADPRIVATE(teta0,ttp,delt_y,delt_z,eps) |
|---|
| 16 | |
|---|
| 17 | REAL(rstd),SAVE :: knewt_g, k_f,k_c_a,k_c_s |
|---|
| 18 | !$OMP THREADPRIVATE(knewt_g, k_f,k_c_a,k_c_s) |
|---|
| 19 | |
|---|
| 20 | PUBLIC :: etat0, held_suarez |
|---|
| 21 | |
|---|
| 22 | CONTAINS |
|---|
| 23 | |
|---|
| 24 | SUBROUTINE test_etat0_heldsz |
|---|
| 25 | USE icosa |
|---|
| 26 | USE kinetic_mod |
|---|
| 27 | IMPLICIT NONE |
|---|
| 28 | TYPE(t_field),POINTER :: f_ps(:) |
|---|
| 29 | TYPE(t_field),POINTER :: f_phis(:) |
|---|
| 30 | TYPE(t_field),POINTER :: f_theta_rhodz(:) |
|---|
| 31 | TYPE(t_field),POINTER :: f_u(:) |
|---|
| 32 | TYPE(t_field),POINTER :: f_q(:) |
|---|
| 33 | TYPE(t_field),POINTER :: f_Ki(:) |
|---|
| 34 | |
|---|
| 35 | REAL(rstd),POINTER :: Ki(:,:) |
|---|
| 36 | INTEGER :: ind |
|---|
| 37 | |
|---|
| 38 | CALL allocate_field(f_ps,field_t,type_real) |
|---|
| 39 | CALL allocate_field(f_phis,field_t,type_real) |
|---|
| 40 | CALL allocate_field(f_theta_rhodz,field_t,type_real,llm) |
|---|
| 41 | CALL allocate_field(f_u,field_u,type_real,llm) |
|---|
| 42 | CALL allocate_field(f_Ki,field_t,type_real,llm) |
|---|
| 43 | |
|---|
| 44 | CALL etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q) |
|---|
| 45 | CALL kinetic(f_u,f_Ki) |
|---|
| 46 | |
|---|
| 47 | CALL writefield('ps',f_ps) |
|---|
| 48 | CALL writefield('theta',f_theta_rhodz) |
|---|
| 49 | END SUBROUTINE test_etat0_heldsz |
|---|
| 50 | |
|---|
| 51 | SUBROUTINE etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q) |
|---|
| 52 | USE icosa |
|---|
| 53 | USE theta2theta_rhodz_mod |
|---|
| 54 | IMPLICIT NONE |
|---|
| 55 | TYPE(t_field),POINTER :: f_ps(:) |
|---|
| 56 | TYPE(t_field),POINTER :: f_phis(:) |
|---|
| 57 | TYPE(t_field),POINTER :: f_theta_rhodz(:) |
|---|
| 58 | TYPE(t_field),POINTER :: f_u(:) |
|---|
| 59 | TYPE(t_field),POINTER :: f_q(:) |
|---|
| 60 | |
|---|
| 61 | REAL(rstd),POINTER :: ps(:) |
|---|
| 62 | REAL(rstd),POINTER :: phis(:) |
|---|
| 63 | REAL(rstd),POINTER :: theta_rhodz(:,:) |
|---|
| 64 | REAL(rstd),POINTER :: u(:,:) |
|---|
| 65 | REAL(rstd),POINTER :: q(:,:,:) |
|---|
| 66 | REAL(rstd),POINTER :: theta_eq(:,:) |
|---|
| 67 | REAL(rstd),POINTER :: theta(:,:) |
|---|
| 68 | |
|---|
| 69 | INTEGER :: ind |
|---|
| 70 | |
|---|
| 71 | CALL Init_Teq |
|---|
| 72 | DO ind=1,ndomain |
|---|
| 73 | IF (.NOT. assigned_domain(ind)) CYCLE |
|---|
| 74 | CALL swap_dimensions(ind) |
|---|
| 75 | CALL swap_geometry(ind) |
|---|
| 76 | |
|---|
| 77 | theta_eq=f_theta_eq(ind) |
|---|
| 78 | CALL compute_Teq(lat_i,theta_eq) ! FIXME : already done by Init_Teq |
|---|
| 79 | |
|---|
| 80 | ps=f_ps(ind) |
|---|
| 81 | phis=f_phis(ind) |
|---|
| 82 | u=f_u(ind) |
|---|
| 83 | ps(:)=1e5 |
|---|
| 84 | phis(:)=0. |
|---|
| 85 | u(:,:)=0 |
|---|
| 86 | |
|---|
| 87 | theta_rhodz=f_theta_rhodz(ind) |
|---|
| 88 | theta=f_theta(ind) |
|---|
| 89 | CALL compute_etat0_heldsz(theta_eq,theta) |
|---|
| 90 | CALL compute_theta2theta_rhodz(ps,theta,theta_rhodz,1) |
|---|
| 91 | q=f_q(ind) |
|---|
| 92 | q(:,:,:)=1e2 |
|---|
| 93 | ENDDO |
|---|
| 94 | END SUBROUTINE etat0 |
|---|
| 95 | |
|---|
| 96 | SUBROUTINE init_Teq |
|---|
| 97 | USE icosa |
|---|
| 98 | USE disvert_mod, ONLY : ap,bp |
|---|
| 99 | IMPLICIT NONE |
|---|
| 100 | REAL(rstd),POINTER :: clat(:) |
|---|
| 101 | REAL(rstd),POINTER :: theta_eq(:,:) |
|---|
| 102 | REAL(rstd) :: zsig |
|---|
| 103 | INTEGER :: ind, l |
|---|
| 104 | |
|---|
| 105 | IF(.NOT.done) THEN |
|---|
| 106 | done = .TRUE. |
|---|
| 107 | |
|---|
| 108 | CALL allocate_field(f_theta,field_t,type_real,llm) |
|---|
| 109 | CALL allocate_field(f_theta_eq,field_t,type_real,llm) |
|---|
| 110 | ALLOCATE(knewt_t(llm)); ALLOCATE( kfrict(llm)) |
|---|
| 111 | |
|---|
| 112 | k_f=1. !friction |
|---|
| 113 | CALL getin('k_j',k_f) |
|---|
| 114 | k_f=1./(daysec*k_f) |
|---|
| 115 | k_c_s=4. !cooling surface |
|---|
| 116 | CALL getin('k_c_s',k_c_s) |
|---|
| 117 | k_c_s=1./(daysec*k_c_s) |
|---|
| 118 | k_c_a=40. !cooling free atm |
|---|
| 119 | CALL getin('k_c_a',k_c_a) |
|---|
| 120 | k_c_a=1./(daysec*k_c_a) |
|---|
| 121 | ! Constants for Teta equilibrium profile |
|---|
| 122 | teta0=315. ! mean Teta (S.H. 315K) |
|---|
| 123 | CALL getin('teta0',teta0) |
|---|
| 124 | ttp=200. ! Tropopause temperature (S.H. 200K) |
|---|
| 125 | CALL getin('ttp',ttp) |
|---|
| 126 | eps=0. ! Deviation to N-S symmetry(~0-20K) |
|---|
| 127 | CALL getin('eps',eps) |
|---|
| 128 | delt_y=60. ! Merid Temp. Gradient (S.H. 60K) |
|---|
| 129 | CALL getin('delt_y',delt_y) |
|---|
| 130 | delt_z=10. ! Vertical Gradient (S.H. 10K) |
|---|
| 131 | CALL getin('delt_z',delt_z) |
|---|
| 132 | |
|---|
| 133 | !----------------------------------------------------------- |
|---|
| 134 | knewt_g=k_c_a |
|---|
| 135 | DO l=1,llm |
|---|
| 136 | zsig=ap(l)/preff+bp(l) |
|---|
| 137 | knewt_t(l)=(k_c_s-k_c_a)*MAX(0.,(zsig-0.7)/0.3) |
|---|
| 138 | kfrict(l)=k_f*MAX(0.,(zsig-0.7)/0.3) |
|---|
| 139 | ENDDO |
|---|
| 140 | |
|---|
| 141 | DO ind=1,ndomain |
|---|
| 142 | IF (.NOT. assigned_domain(ind)) CYCLE |
|---|
| 143 | CALL swap_dimensions(ind) |
|---|
| 144 | CALL swap_geometry(ind) |
|---|
| 145 | theta_eq=f_theta_eq(ind) |
|---|
| 146 | CALL compute_Teq(lat_i,theta_eq) |
|---|
| 147 | ENDDO |
|---|
| 148 | |
|---|
| 149 | ELSE |
|---|
| 150 | PRINT *, 'Init_Teq called twice' |
|---|
| 151 | CALL ABORT |
|---|
| 152 | END IF |
|---|
| 153 | |
|---|
| 154 | END SUBROUTINE init_Teq |
|---|
| 155 | |
|---|
| 156 | SUBROUTINE compute_Teq(lat,theta_eq) |
|---|
| 157 | USE icosa |
|---|
| 158 | USE disvert_mod |
|---|
| 159 | IMPLICIT NONE |
|---|
| 160 | REAL(rstd),INTENT(IN) :: lat(iim*jjm) |
|---|
| 161 | REAL(rstd),INTENT(OUT) :: theta_eq(iim*jjm,llm) |
|---|
| 162 | |
|---|
| 163 | REAL(rstd) :: r, zsig, ddsin, tetastrat, tetajl |
|---|
| 164 | INTEGER :: i,j,l,ij |
|---|
| 165 | |
|---|
| 166 | DO l=1,llm |
|---|
| 167 | zsig=ap(l)/preff+bp(l) |
|---|
| 168 | tetastrat=ttp*zsig**(-kappa) |
|---|
| 169 | DO j=jj_begin-1,jj_end+1 |
|---|
| 170 | DO i=ii_begin-1,ii_end+1 |
|---|
| 171 | ij=(j-1)*iim+i |
|---|
| 172 | ddsin=SIN(lat(ij)) |
|---|
| 173 | tetajl=teta0-delt_y*ddsin*ddsin+eps*ddsin & |
|---|
| 174 | -delt_z*(1.-ddsin*ddsin)*log(zsig) |
|---|
| 175 | theta_eq(ij,l)=MAX(tetajl,tetastrat) |
|---|
| 176 | ENDDO |
|---|
| 177 | ENDDO |
|---|
| 178 | ENDDO |
|---|
| 179 | END SUBROUTINE compute_Teq |
|---|
| 180 | |
|---|
| 181 | SUBROUTINE compute_etat0_heldsz(theta_eq, theta) |
|---|
| 182 | USE icosa |
|---|
| 183 | USE disvert_mod |
|---|
| 184 | USE pression_mod |
|---|
| 185 | USE exner_mod |
|---|
| 186 | USE geopotential_mod |
|---|
| 187 | USE theta2theta_rhodz_mod |
|---|
| 188 | IMPLICIT NONE |
|---|
| 189 | REAL(rstd),INTENT(IN) :: theta_eq(iim*jjm,llm) |
|---|
| 190 | REAL(rstd),INTENT(OUT) :: theta(iim*jjm,llm) |
|---|
| 191 | |
|---|
| 192 | REAL(rstd) :: r ! random number |
|---|
| 193 | INTEGER :: i,j,l,ij |
|---|
| 194 | |
|---|
| 195 | DO l=1,llm |
|---|
| 196 | DO j=jj_begin-1,jj_end+1 |
|---|
| 197 | DO i=ii_begin-1,ii_end+1 |
|---|
| 198 | ij=(j-1)*iim+i |
|---|
| 199 | CALL RANDOM_NUMBER(r); r = 0.0 |
|---|
| 200 | theta(ij,l)=theta_eq(ij,l)*(1.+0.0005*r) |
|---|
| 201 | ENDDO |
|---|
| 202 | ENDDO |
|---|
| 203 | ENDDO |
|---|
| 204 | |
|---|
| 205 | END SUBROUTINE compute_etat0_heldsz |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | SUBROUTINE held_suarez(f_ps,f_theta_rhodz,f_u) |
|---|
| 209 | USE icosa |
|---|
| 210 | IMPLICIT NONE |
|---|
| 211 | TYPE(t_field),POINTER :: f_theta_rhodz(:) |
|---|
| 212 | TYPE(t_field),POINTER :: f_u(:) |
|---|
| 213 | TYPE(t_field),POINTER :: f_ps(:) |
|---|
| 214 | REAL(rstd),POINTER :: theta_rhodz(:,:) |
|---|
| 215 | REAL(rstd),POINTER :: u(:,:) |
|---|
| 216 | REAL(rstd),POINTER :: ps(:) |
|---|
| 217 | REAL(rstd),POINTER :: theta_eq(:,:) |
|---|
| 218 | REAL(rstd),POINTER :: theta(:,:) |
|---|
| 219 | REAL(rstd),POINTER :: clat(:) |
|---|
| 220 | INTEGER::ind |
|---|
| 221 | |
|---|
| 222 | DO ind=1,ndomain |
|---|
| 223 | IF (.NOT. assigned_domain(ind)) CYCLE |
|---|
| 224 | CALL swap_dimensions(ind) |
|---|
| 225 | CALL swap_geometry(ind) |
|---|
| 226 | theta_rhodz=f_theta_rhodz(ind) |
|---|
| 227 | u=f_u(ind) |
|---|
| 228 | ps=f_ps(ind) |
|---|
| 229 | theta_eq=f_theta_eq(ind) |
|---|
| 230 | theta=f_theta(ind) |
|---|
| 231 | CALL compute_heldsz(ps,theta_eq,lat_i, theta_rhodz,u, theta) |
|---|
| 232 | ENDDO |
|---|
| 233 | END SUBROUTINE held_suarez |
|---|
| 234 | |
|---|
| 235 | SUBROUTINE compute_heldsz(ps,theta_eq,lat, theta_rhodz,u, theta) |
|---|
| 236 | USE icosa |
|---|
| 237 | USE theta2theta_rhodz_mod |
|---|
| 238 | IMPLICIT NONE |
|---|
| 239 | REAL(rstd),INTENT(IN) :: ps(iim*jjm) |
|---|
| 240 | REAL(rstd),INTENT(IN) :: theta_eq(iim*jjm,llm) |
|---|
| 241 | REAL(rstd),INTENT(IN) :: lat(iim*jjm) |
|---|
| 242 | REAL(rstd),INTENT(INOUT) :: theta_rhodz(iim*jjm,llm) |
|---|
| 243 | REAL(rstd),INTENT(INOUT) :: u(3*iim*jjm,llm) |
|---|
| 244 | REAL(rstd),INTENT(OUT) :: theta(iim*jjm,llm) |
|---|
| 245 | |
|---|
| 246 | INTEGER :: i,j,l,ij |
|---|
| 247 | |
|---|
| 248 | CALL compute_theta_rhodz2theta(ps,theta_rhodz,theta,1) |
|---|
| 249 | DO l=1,llm |
|---|
| 250 | DO j=jj_begin-1,jj_end+1 |
|---|
| 251 | DO i=ii_begin-1,ii_end+1 |
|---|
| 252 | ij=(j-1)*iim+i |
|---|
| 253 | theta(ij,l)=theta(ij,l) - dt*(theta(ij,l)-theta_eq(ij,l))* & |
|---|
| 254 | (knewt_g+knewt_t(l)*COS(lat(ij))**4 ) |
|---|
| 255 | ENDDO |
|---|
| 256 | ENDDO |
|---|
| 257 | ENDDO |
|---|
| 258 | CALL compute_theta2theta_rhodz(ps,theta,theta_rhodz,1) |
|---|
| 259 | |
|---|
| 260 | Do l=1,llm |
|---|
| 261 | u(:,l)=u(:,l)*(1.-dt*kfrict(l)) |
|---|
| 262 | END DO |
|---|
| 263 | |
|---|
| 264 | END SUBROUTINE compute_heldsz |
|---|
| 265 | |
|---|
| 266 | END MODULE etat0_heldsz_mod |
|---|