[1403] | 1 | ! $Id: iniacademic.F90 5186 2024-09-11 16:03:07Z abarral $ |
---|
[5099] | 2 | |
---|
[5118] | 3 | SUBROUTINE iniacademic(vcov, ucov, teta, q, masse, ps, phis, time_0) |
---|
[524] | 4 | |
---|
[5106] | 5 | USE lmdz_filtreg, ONLY: inifilr |
---|
[5182] | 6 | USE lmdz_infotrac, ONLY: nqtot, niso, iqIsoPha, tracers, getKey, isoName |
---|
[5118] | 7 | USE control_mod, ONLY: day_step, planet_type |
---|
[5117] | 8 | USE exner_hyb_m, ONLY: exner_hyb |
---|
| 9 | USE exner_milieu_m, ONLY: exner_milieu |
---|
[2083] | 10 | USE IOIPSL, ONLY: getin |
---|
[5117] | 11 | USE lmdz_write_field |
---|
[2597] | 12 | USE comconst_mod, ONLY: cpp, kappa, g, daysec, dtvr, pi, im, jm |
---|
[2603] | 13 | USE logic_mod, ONLY: iflag_phys, read_start |
---|
[4376] | 14 | USE comvert_mod, ONLY: ap, bp, preff, pa, presnivs, pressure_exner |
---|
[2601] | 15 | USE temps_mod, ONLY: annee_ref, day_ini, day_ref |
---|
[5118] | 16 | USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0 |
---|
[5117] | 17 | USE lmdz_readTracFiles, ONLY: addPhase |
---|
[5118] | 18 | USE netcdf, ONLY: nf90_nowrite, nf90_open, nf90_noerr, nf90_inq_varid, nf90_close, nf90_get_var |
---|
[5117] | 19 | USE lmdz_ran1, ONLY: ran1 |
---|
[5118] | 20 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
[5134] | 21 | USE lmdz_academic, ONLY: tetarappel, knewt_t, kfrict, knewt_g, clat4 |
---|
[5136] | 22 | USE lmdz_comgeom |
---|
[1146] | 23 | |
---|
[1472] | 24 | ! Author: Frederic Hourdin original: 15/01/93 |
---|
[1474] | 25 | ! The forcing defined here is from Held and Suarez, 1994, Bulletin |
---|
| 26 | ! of the American Meteorological Society, 75, 1825. |
---|
[524] | 27 | |
---|
[5159] | 28 | USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm |
---|
| 29 | USE lmdz_paramet |
---|
[5186] | 30 | USE lmdz_check_isotopes, ONLY: check_isotopes_seq |
---|
| 31 | |
---|
[1472] | 32 | IMPLICIT NONE |
---|
[524] | 33 | |
---|
[1472] | 34 | ! Declararations: |
---|
| 35 | ! --------------- |
---|
[524] | 36 | |
---|
| 37 | |
---|
[5159] | 38 | |
---|
| 39 | |
---|
[1472] | 40 | ! Arguments: |
---|
| 41 | ! ---------- |
---|
[1146] | 42 | |
---|
[5118] | 43 | REAL, INTENT(OUT) :: time_0 |
---|
[1146] | 44 | |
---|
[2083] | 45 | ! fields |
---|
[5118] | 46 | REAL, INTENT(OUT) :: vcov(ip1jm, llm) ! meridional covariant wind |
---|
| 47 | REAL, INTENT(OUT) :: ucov(ip1jmp1, llm) ! zonal covariant wind |
---|
| 48 | REAL, INTENT(OUT) :: teta(ip1jmp1, llm) ! potential temperature (K) |
---|
| 49 | REAL, INTENT(OUT) :: q(ip1jmp1, llm, nqtot) ! advected tracers (.../kg_of_air) |
---|
| 50 | REAL, INTENT(OUT) :: ps(ip1jmp1) ! surface pressure (Pa) |
---|
| 51 | REAL, INTENT(OUT) :: masse(ip1jmp1, llm) ! air mass in grid cell (kg) |
---|
| 52 | REAL, INTENT(OUT) :: phis(ip1jmp1) ! surface geopotential |
---|
[524] | 53 | |
---|
[1472] | 54 | ! Local: |
---|
| 55 | ! ------ |
---|
[524] | 56 | |
---|
[5118] | 57 | REAL p (ip1jmp1, llmp1) ! pression aux interfac.des couches |
---|
[1472] | 58 | REAL pks(ip1jmp1) ! exner au sol |
---|
[5118] | 59 | REAL pk(ip1jmp1, llm) ! exner au milieu des couches |
---|
| 60 | REAL phi(ip1jmp1, llm) ! geopotentiel |
---|
| 61 | REAL ddsin, zsig, tetapv, w_pv ! variables auxiliaires |
---|
[5117] | 62 | REAL tetastrat ! potential temperature in the stratosphere, in K |
---|
[5118] | 63 | REAL tetajl(jjp1, llm) |
---|
| 64 | INTEGER i, j, l, lsup, ij, iq, iName, iPhase, iqParent |
---|
[524] | 65 | |
---|
[5118] | 66 | INTEGER :: nid_relief, varid, ierr |
---|
| 67 | REAL, DIMENSION(iip1, jjp1) :: relief |
---|
[4419] | 68 | |
---|
[5118] | 69 | REAL teta0, ttp, delt_y, delt_z, eps ! Constantes pour profil de T |
---|
| 70 | REAL k_f, k_c_a, k_c_s ! Constantes de rappel |
---|
[1472] | 71 | LOGICAL ok_geost ! Initialisation vent geost. ou nul |
---|
| 72 | LOGICAL ok_pv ! Polar Vortex |
---|
[5118] | 73 | REAL phi_pv, dphi_pv, gam_pv, tetanoise ! Constantes pour polar vortex |
---|
[1454] | 74 | |
---|
[5117] | 75 | REAL zz |
---|
| 76 | INTEGER idum |
---|
[524] | 77 | |
---|
[4325] | 78 | REAL zdtvr, tnat, alpha_ideal |
---|
[5118] | 79 | LOGICAL, PARAMETER :: tnat1 = .TRUE. |
---|
[524] | 80 | |
---|
[5118] | 81 | CHARACTER(LEN = *), parameter :: modname = "iniacademic" |
---|
| 82 | CHARACTER(LEN = 80) :: abort_message |
---|
| 83 | |
---|
[2083] | 84 | ! Sanity check: verify that options selected by user are not incompatible |
---|
[5117] | 85 | IF ((iflag_phys==1).AND. .NOT. read_start) THEN |
---|
[5118] | 86 | WRITE(lunout, *) trim(modname), " error: if read_start is set to ", & |
---|
| 87 | " false then iflag_phys should not be 1" |
---|
| 88 | WRITE(lunout, *) "You most likely want an aquaplanet initialisation", & |
---|
| 89 | " (iflag_phys >= 100)" |
---|
| 90 | CALL abort_gcm(modname, "incompatible iflag_phys==1 and read_start==.FALSE.", 1) |
---|
[5117] | 91 | ENDIF |
---|
[5118] | 92 | |
---|
[1472] | 93 | !----------------------------------------------------------------------- |
---|
| 94 | ! 1. Initializations for Earth-like case |
---|
| 95 | ! -------------------------------------- |
---|
[5099] | 96 | |
---|
[1472] | 97 | ! initialize planet radius, rotation rate,... |
---|
[5101] | 98 | CALL conf_planete |
---|
[524] | 99 | |
---|
[5118] | 100 | time_0 = 0. |
---|
| 101 | day_ref = 1 |
---|
| 102 | annee_ref = 0 |
---|
[1403] | 103 | |
---|
[5118] | 104 | im = iim |
---|
| 105 | jm = jjm |
---|
| 106 | day_ini = 1 |
---|
| 107 | dtvr = daysec / REAL(day_step) |
---|
| 108 | zdtvr = dtvr |
---|
| 109 | etot0 = 0. |
---|
| 110 | ptot0 = 0. |
---|
| 111 | ztot0 = 0. |
---|
| 112 | stot0 = 0. |
---|
| 113 | ang0 = 0. |
---|
[524] | 114 | |
---|
[5117] | 115 | IF (llm == 1) THEN |
---|
[5118] | 116 | ! specific initializations for the shallow water case |
---|
| 117 | kappa = 1 |
---|
[5117] | 118 | ENDIF |
---|
[524] | 119 | |
---|
[1472] | 120 | CALL iniconst |
---|
| 121 | CALL inigeom |
---|
| 122 | CALL inifilr |
---|
[524] | 123 | |
---|
[4419] | 124 | |
---|
| 125 | !------------------------------------------------------------------ |
---|
[5103] | 126 | ! Initialize pressure and mass field if read_start=.FALSE. |
---|
[4419] | 127 | !------------------------------------------------------------------ |
---|
| 128 | |
---|
[3976] | 129 | IF (.NOT. read_start) THEN |
---|
[4056] | 130 | |
---|
[5118] | 131 | !------------------------------------------------------------------ |
---|
| 132 | ! Lecture eventuelle d'un fichier de relief interpollee sur la grille |
---|
| 133 | ! du modele. |
---|
| 134 | ! On suppose que le fichier relief_in.nc est stoké sur une grille |
---|
| 135 | ! iim*jjp1 |
---|
| 136 | ! Facile a créer à partir de la commande |
---|
| 137 | ! cdo remapcon,fichier_output_phys.nc Relief.nc relief_in.nc |
---|
| 138 | !------------------------------------------------------------------ |
---|
[4419] | 139 | |
---|
[5118] | 140 | relief = 0. |
---|
| 141 | ierr = nf90_open ('relief_in.nc', nf90_nowrite, nid_relief) |
---|
| 142 | IF (ierr==nf90_noerr) THEN |
---|
| 143 | ierr = nf90_inq_varid(nid_relief, 'RELIEF', varid) |
---|
| 144 | IF (ierr==nf90_noerr) THEN |
---|
| 145 | ierr = nf90_get_var(nid_relief, varid, relief(1:iim, 1:jjp1)) |
---|
| 146 | relief(iip1, :) = relief(1, :) |
---|
| 147 | else |
---|
| 148 | CALL abort_gcm ('iniacademic', 'variable RELIEF pas la', 1) |
---|
| 149 | endif |
---|
| 150 | endif |
---|
| 151 | ierr = nf90_close (nid_relief) |
---|
[4419] | 152 | |
---|
[5118] | 153 | !------------------------------------------------------------------ |
---|
| 154 | ! Initialisation du geopotentiel au sol et de la pression |
---|
| 155 | !------------------------------------------------------------------ |
---|
[4419] | 156 | |
---|
[5118] | 157 | PRINT*, 'relief=', minval(relief), maxval(relief), 'g=', g |
---|
[5158] | 158 | DO j = 1, jjp1 |
---|
| 159 | DO i = 1, iip1 |
---|
[5118] | 160 | phis((j - 1) * iip1 + i) = g * relief(i, j) |
---|
| 161 | enddo |
---|
| 162 | enddo |
---|
| 163 | PRINT*, 'phis=', minval(phis), maxval(phis), 'g=', g |
---|
[4419] | 164 | |
---|
[5118] | 165 | ! ground geopotential |
---|
| 166 | !phis(:)=0. |
---|
| 167 | ps(:) = preff |
---|
| 168 | CALL pression (ip1jmp1, ap, bp, ps, p) |
---|
[4056] | 169 | |
---|
[5118] | 170 | IF (pressure_exner) THEN |
---|
| 171 | CALL exner_hyb(ip1jmp1, ps, p, pks, pk) |
---|
| 172 | else |
---|
| 173 | CALL exner_milieu(ip1jmp1, ps, p, pks, pk) |
---|
| 174 | endif |
---|
| 175 | CALL massdair(p, masse) |
---|
[3976] | 176 | ENDIF |
---|
| 177 | |
---|
[5117] | 178 | IF (llm == 1) THEN |
---|
[5118] | 179 | ! initialize fields for the shallow water case, if required |
---|
| 180 | IF (.NOT.read_start) THEN |
---|
| 181 | phis(:) = 0. |
---|
| 182 | q(:, :, :) = 0 |
---|
| 183 | CALL sw_case_williamson91_6(vcov, ucov, teta, masse, ps) |
---|
| 184 | endif |
---|
[5117] | 185 | ENDIF |
---|
[524] | 186 | |
---|
[5116] | 187 | academic_case: if (iflag_phys >= 2) THEN |
---|
[5118] | 188 | ! initializations |
---|
[524] | 189 | |
---|
[5118] | 190 | ! 1. local parameters |
---|
| 191 | ! by convention, winter is in the southern hemisphere |
---|
| 192 | ! Geostrophic wind or no wind? |
---|
| 193 | ok_geost = .TRUE. |
---|
| 194 | CALL getin('ok_geost', ok_geost) |
---|
| 195 | ! Constants for Newtonian relaxation and friction |
---|
| 196 | k_f = 1. !friction |
---|
| 197 | CALL getin('k_j', k_f) |
---|
| 198 | k_f = 1. / (daysec * k_f) |
---|
| 199 | k_c_s = 4. !cooling surface |
---|
| 200 | CALL getin('k_c_s', k_c_s) |
---|
| 201 | k_c_s = 1. / (daysec * k_c_s) |
---|
| 202 | k_c_a = 40. !cooling free atm |
---|
| 203 | CALL getin('k_c_a', k_c_a) |
---|
| 204 | k_c_a = 1. / (daysec * k_c_a) |
---|
| 205 | ! Constants for Teta equilibrium profile |
---|
| 206 | teta0 = 315. ! mean Teta (S.H. 315K) |
---|
| 207 | CALL getin('teta0', teta0) |
---|
| 208 | ttp = 200. ! Tropopause temperature (S.H. 200K) |
---|
| 209 | CALL getin('ttp', ttp) |
---|
| 210 | eps = 0. ! Deviation to N-S symmetry(~0-20K) |
---|
| 211 | CALL getin('eps', eps) |
---|
| 212 | delt_y = 60. ! Merid Temp. Gradient (S.H. 60K) |
---|
| 213 | CALL getin('delt_y', delt_y) |
---|
| 214 | delt_z = 10. ! Vertical Gradient (S.H. 10K) |
---|
| 215 | CALL getin('delt_z', delt_z) |
---|
| 216 | ! Polar vortex |
---|
| 217 | ok_pv = .FALSE. |
---|
| 218 | CALL getin('ok_pv', ok_pv) |
---|
| 219 | phi_pv = -50. ! Latitude of edge of vortex |
---|
| 220 | CALL getin('phi_pv', phi_pv) |
---|
| 221 | phi_pv = phi_pv * pi / 180. |
---|
| 222 | dphi_pv = 5. ! Width of the edge |
---|
| 223 | CALL getin('dphi_pv', dphi_pv) |
---|
| 224 | dphi_pv = dphi_pv * pi / 180. |
---|
| 225 | gam_pv = 4. ! -dT/dz vortex (in K/km) |
---|
| 226 | CALL getin('gam_pv', gam_pv) |
---|
| 227 | tetanoise = 0.005 |
---|
| 228 | CALL getin('tetanoise', tetanoise) |
---|
[524] | 229 | |
---|
[5118] | 230 | ! 2. Initialize fields towards which to relax |
---|
| 231 | ! Friction |
---|
| 232 | knewt_g = k_c_a |
---|
| 233 | DO l = 1, llm |
---|
| 234 | zsig = presnivs(l) / preff |
---|
| 235 | knewt_t(l) = (k_c_s - k_c_a) * MAX(0., (zsig - 0.7) / 0.3) |
---|
| 236 | kfrict(l) = k_f * MAX(0., (zsig - 0.7) / 0.3) |
---|
| 237 | ENDDO |
---|
| 238 | DO j = 1, jjp1 |
---|
| 239 | clat4((j - 1) * iip1 + 1:j * iip1) = cos(rlatu(j))**4 |
---|
| 240 | ENDDO |
---|
[524] | 241 | |
---|
[5118] | 242 | ! Potential temperature |
---|
| 243 | DO l = 1, llm |
---|
| 244 | zsig = presnivs(l) / preff |
---|
| 245 | tetastrat = ttp * zsig**(-kappa) |
---|
| 246 | tetapv = tetastrat |
---|
| 247 | IF ((ok_pv).AND.(zsig<0.1)) THEN |
---|
| 248 | tetapv = tetastrat * (zsig * 10.)**(kappa * cpp * gam_pv / 1000. / g) |
---|
| 249 | ENDIF |
---|
| 250 | DO j = 1, jjp1 |
---|
| 251 | ! Troposphere |
---|
| 252 | ddsin = sin(rlatu(j)) |
---|
| 253 | tetajl(j, l) = teta0 - delt_y * ddsin * ddsin + eps * ddsin & |
---|
| 254 | - delt_z * (1. - ddsin * ddsin) * log(zsig) |
---|
| 255 | IF (planet_type=="giant") THEN |
---|
| 256 | tetajl(j, l) = teta0 + (delt_y * & |
---|
| 257 | ((sin(rlatu(j) * 3.14159 * eps + 0.0001))**2) & |
---|
| 258 | / ((rlatu(j) * 3.14159 * eps + 0.0001)**2)) & |
---|
| 259 | - delt_z * log(zsig) |
---|
| 260 | endif |
---|
| 261 | ! Profil stratospherique isotherme (+vortex) |
---|
| 262 | w_pv = (1. - tanh((rlatu(j) - phi_pv) / dphi_pv)) / 2. |
---|
| 263 | tetastrat = tetastrat * (1. - w_pv) + tetapv * w_pv |
---|
| 264 | tetajl(j, l) = MAX(tetajl(j, l), tetastrat) |
---|
| 265 | ENDDO |
---|
| 266 | ENDDO |
---|
[524] | 267 | |
---|
[5118] | 268 | ! CALL writefield('theta_eq',tetajl) |
---|
[524] | 269 | |
---|
[5158] | 270 | DO l = 1, llm |
---|
| 271 | DO j = 1, jjp1 |
---|
| 272 | DO i = 1, iip1 |
---|
[5118] | 273 | ij = (j - 1) * iip1 + i |
---|
| 274 | tetarappel(ij, l) = tetajl(j, l) |
---|
[1472] | 275 | enddo |
---|
[5118] | 276 | enddo |
---|
| 277 | enddo |
---|
[1472] | 278 | |
---|
[5118] | 279 | ! 3. Initialize fields (if necessary) |
---|
| 280 | IF (.NOT. read_start) THEN |
---|
| 281 | ! bulk initialization of temperature |
---|
| 282 | IF (iflag_phys>10000) THEN |
---|
[3976] | 283 | ! Particular case to impose a constant temperature T0=0.01*iflag_physx |
---|
[5118] | 284 | teta(:, :) = 0.01 * iflag_phys / (pk(:, :) / cpp) |
---|
| 285 | ELSE |
---|
| 286 | teta(:, :) = tetarappel(:, :) |
---|
| 287 | ENDIF |
---|
| 288 | ! geopotential |
---|
| 289 | CALL geopot(ip1jmp1, teta, pk, pks, phis, phi) |
---|
[1472] | 290 | |
---|
[5118] | 291 | DO l = 1, llm |
---|
| 292 | PRINT*, 'presnivs,play,l', presnivs(l), (pk(1, l) / cpp)**(1. / kappa) * preff |
---|
| 293 | !pks(ij) = (cpp/preff) * ps(ij) |
---|
| 294 | !pk(ij,1) = .5*pks(ij) |
---|
| 295 | ! pk = cpp * (p/preff)^kappa |
---|
| 296 | ENDDO |
---|
[3976] | 297 | |
---|
[5118] | 298 | ! winds |
---|
| 299 | IF (ok_geost) THEN |
---|
| 300 | CALL ugeostr(phi, ucov) |
---|
| 301 | else |
---|
| 302 | ucov(:, :) = 0. |
---|
| 303 | endif |
---|
| 304 | vcov(:, :) = 0. |
---|
[1472] | 305 | |
---|
[5118] | 306 | ! bulk initialization of tracers |
---|
| 307 | IF (planet_type=="earth") THEN |
---|
| 308 | ! Earth: first two tracers will be water |
---|
[5158] | 309 | DO iq = 1, nqtot |
---|
[5118] | 310 | q(:, :, iq) = 0. |
---|
| 311 | IF(tracers(iq)%name == addPhase('H2O', 'g')) q(:, :, iq) = 1.e-10 |
---|
| 312 | IF(tracers(iq)%name == addPhase('H2O', 'l')) q(:, :, iq) = 1.e-15 |
---|
[2270] | 313 | |
---|
[5118] | 314 | ! CRisi: init des isotopes |
---|
| 315 | ! distill de Rayleigh très simplifiée |
---|
| 316 | iName = tracers(iq)%iso_iName |
---|
| 317 | IF (niso <= 0 .OR. iName <= 0) CYCLE |
---|
| 318 | iPhase = tracers(iq)%iso_iPhase |
---|
| 319 | iqParent = tracers(iq)%iqParent |
---|
| 320 | IF(tracers(iq)%iso_iZone == 0) THEN |
---|
| 321 | IF (tnat1) THEN |
---|
| 322 | tnat = 1.0 |
---|
| 323 | alpha_ideal = 1.0 |
---|
| 324 | WRITE(*, *) 'Attention dans iniacademic: alpha_ideal=1' |
---|
| 325 | else |
---|
| 326 | IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) & |
---|
| 327 | CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1) |
---|
| 328 | endif |
---|
| 329 | q(:, :, iq) = q(:, :, iqParent) * tnat * (q(:, :, iqParent) / 30.e-3)**(alpha_ideal - 1.) |
---|
| 330 | ELSE !IF(tracers(iq)%iso_iZone == 0) THEN |
---|
| 331 | IF(tracers(iq)%iso_iZone == 1) THEN |
---|
| 332 | ! correction le 14 mai 2024 pour que tous les traceurs soient de la couleur 1. |
---|
| 333 | ! Sinon, on va avoir des porblèmes de conservation de masse de traceurs. |
---|
| 334 | q(:, :, iq) = q(:, :, iqIsoPha(iName, iPhase)) |
---|
| 335 | else !IF(tracers(iq)%iso_iZone == 1) THEN |
---|
| 336 | q(:, :, iq) = 0. |
---|
| 337 | endif !IF(tracers(iq)%iso_iZone == 1) THEN |
---|
| 338 | END IF !IF(tracers(iq)%iso_iZone == 0) THEN |
---|
| 339 | enddo |
---|
| 340 | else |
---|
| 341 | q(:, :, :) = 0 |
---|
| 342 | endif ! of if (planet_type=="earth") |
---|
[1472] | 343 | |
---|
[5186] | 344 | CALL check_isotopes_seq(q, ip1jmp1, 'iniacademic_loc') |
---|
[2270] | 345 | |
---|
[5118] | 346 | ! add random perturbation to temperature |
---|
| 347 | idum = -1 |
---|
| 348 | zz = ran1(idum) |
---|
| 349 | idum = 0 |
---|
[5158] | 350 | DO l = 1, llm |
---|
| 351 | DO ij = iip2, ip1jm |
---|
[5118] | 352 | teta(ij, l) = teta(ij, l) * (1. + tetanoise * ran1(idum)) |
---|
[1472] | 353 | enddo |
---|
[5118] | 354 | enddo |
---|
[1472] | 355 | |
---|
[5118] | 356 | ! maintain periodicity in longitude |
---|
[5158] | 357 | DO l = 1, llm |
---|
| 358 | DO ij = 1, ip1jmp1, iip1 |
---|
[5118] | 359 | teta(ij + iim, l) = teta(ij, l) |
---|
[1472] | 360 | enddo |
---|
[5118] | 361 | enddo |
---|
[1472] | 362 | |
---|
[5118] | 363 | ENDIF ! of IF (.NOT. read_start) |
---|
[5117] | 364 | ENDIF academic_case |
---|
[1472] | 365 | |
---|
| 366 | END SUBROUTINE iniacademic |
---|