source: LMDZ6/branches/Amaury_dev/libf/dyn3dmem/iniacademic_loc.F90 @ 5153

Last change on this file since 5153 was 5136, checked in by abarral, 8 weeks ago

Put comgeom.h, comgeom2.h into modules

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 12.8 KB
RevLine 
[1749]1! $Id: iniacademic.F90 1625 2012-05-09 13:14:48Z lguez $
[5099]2
[5118]3SUBROUTINE iniacademic_loc(vcov, ucov, teta, q, masse, ps, phis, time_0)
[1749]4
[5106]5  USE lmdz_filtreg, ONLY: inifilr
[5118]6  USE infotrac, ONLY: nqtot, niso, iqIsoPha, tracers, getKey, isoName
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 parallel_lmdz, ONLY: ijb_u, ije_u, ijb_v, ije_v
11  USE IOIPSL, ONLY: getin
[5117]12  USE lmdz_write_field
[2597]13  USE comconst_mod, ONLY: cpp, kappa, g, daysec, dtvr, pi, im, jm
[2603]14  USE logic_mod, ONLY: iflag_phys, read_start
[4376]15  USE comvert_mod, ONLY: ap, bp, preff, pa, presnivs, pressure_exner
[2601]16  USE temps_mod, ONLY: annee_ref, day_ini, day_ref
[5118]17  USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0
[5117]18  USE lmdz_readTracFiles, ONLY: addPhase
[5118]19  USE netcdf, ONLY: nf90_nowrite, nf90_open, nf90_noerr, nf90_inq_varid, nf90_close, nf90_get_var
[5117]20  USE lmdz_ran1, ONLY: ran1
[5118]21  USE lmdz_iniprint, ONLY: lunout, prt_level
[5134]22  USE lmdz_academic, ONLY: tetarappel, knewt_t, kfrict, knewt_g, clat4
[5136]23  USE lmdz_comgeom
[1749]24
25  !   Author:    Frederic Hourdin      original: 15/01/93
26  ! The forcing defined here is from Held and Suarez, 1994, Bulletin
27  ! of the American Meteorological Society, 75, 1825.
28
29  IMPLICIT NONE
30
31  !   Declararations:
32  !   ---------------
33
[5134]34  INCLUDE "dimensions.h"
35  INCLUDE "paramet.h"
[1749]36
37  !   Arguments:
38  !   ----------
39
[5118]40  REAL, INTENT(OUT) :: time_0
[1749]41
[2083]42  !   fields
[5118]43  REAL, INTENT(OUT) :: vcov(ijb_v:ije_v, llm) ! meridional covariant wind
44  REAL, INTENT(OUT) :: ucov(ijb_u:ije_u, llm) ! zonal covariant wind
45  REAL, INTENT(OUT) :: teta(ijb_u:ije_u, llm) ! potential temperature (K)
46  REAL, INTENT(OUT) :: q(ijb_u:ije_u, llm, nqtot) ! advected tracers (.../kg_of_air)
47  REAL, INTENT(OUT) :: ps(ijb_u:ije_u) ! surface pressure (Pa)
48  REAL, INTENT(OUT) :: masse(ijb_u:ije_u, llm) ! air mass in grid cell (kg)
49  REAL, INTENT(OUT) :: phis(ijb_u:ije_u) ! surface geopotential
[1749]50
51  !   Local:
52  !   ------
53
[5118]54  REAL, ALLOCATABLE :: vcov_glo(:, :), ucov_glo(:, :), teta_glo(:, :)
55  REAL, ALLOCATABLE :: q_glo(:, :), masse_glo(:, :), ps_glo(:)
56  REAL, ALLOCATABLE :: phis_glo(:)
57  REAL p (ip1jmp1, llmp1)               ! pression aux interfac.des couches
[1749]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
[1749]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
[1749]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
[1749]74
[5117]75  REAL zz
76  INTEGER idum
[1749]77
[4325]78  REAL zdtvr, tnat, alpha_ideal
[5118]79  LOGICAL, PARAMETER :: tnat1 = .TRUE.
[1749]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
[1749]93  !-----------------------------------------------------------------------
94  ! 1. Initializations for Earth-like case
95  ! --------------------------------------
[5099]96
[1749]97  ! initialize planet radius, rotation rate,...
[5101]98  CALL conf_planete
[1749]99
[5118]100  time_0 = 0.
101  day_ref = 1
[3435]102  ! annee_ref=0
[1749]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.
[1749]114
[5117]115  IF (llm == 1) THEN
[5118]116    ! specific initializations for the shallow water case
117    kappa = 1
[5117]118  ENDIF
[1749]119
120  CALL iniconst
121  CALL inigeom
122  CALL inifilr
123
[5103]124  ! Initialize pressure and mass field if read_start=.FALSE.
[3976]125  IF (.NOT. read_start) THEN
126    ! allocate global fields:
[5118]127    !    allocate(vcov_glo(ip1jm,llm))
[4419]128
[5118]129    allocate(ucov_glo(ip1jmp1, llm))
130    allocate(teta_glo(ip1jmp1, llm))
[3976]131    allocate(ps_glo(ip1jmp1))
[5118]132    allocate(masse_glo(ip1jmp1, llm))
[3976]133    allocate(phis_glo(ip1jmp1))
134
[5118]135    ! surface pressure
136    ps_glo(:) = preff
[4056]137
[5118]138    !------------------------------------------------------------------
139    ! Lecture eventuelle d'un fichier de relief interpollee sur la grille
140    ! du modele.
141    ! On suppose que le fichier relief_in.nc est stoké sur une grille
142    ! iim*jjp1
143    ! Facile a créer à partir de la commande
144    ! cdo remapcon,fichier_output_phys.nc Relief.nc relief_in.nc
145    !------------------------------------------------------------------
[4419]146
[5118]147    relief = 0.
148    ierr = nf90_open ('relief_in.nc', nf90_nowrite, nid_relief)
149    IF (ierr==nf90_noerr) THEN
150      ierr = nf90_inq_varid(nid_relief, 'RELIEF', varid)
151      IF (ierr==nf90_noerr) THEN
152        ierr = nf90_get_var(nid_relief, varid, relief(1:iim, 1:jjp1))
153        relief(iip1, :) = relief(1, :)
154      else
155        CALL abort_gcm ('iniacademic', 'variable RELIEF pas la', 1)
156      endif
157    endif
158    ierr = nf90_close (nid_relief)
[4419]159
160
[5118]161    !------------------------------------------------------------------
162    ! Initialisation du geopotentiel au sol et de la pression
163    !------------------------------------------------------------------
[4419]164
[5118]165    PRINT*, 'relief=', minval(relief), maxval(relief), 'g=', g
166    do j = 1, jjp1
167      do i = 1, iip1
168        phis_glo((j - 1) * iip1 + i) = g * relief(i, j)
169      enddo
170    enddo
171    PRINT*, 'phis=', minval(phis), maxval(phis), 'g=', g
[4419]172
[5118]173    CALL pression (ip1jmp1, ap, bp, ps_glo, p)
174    IF (pressure_exner) THEN
175      CALL exner_hyb(ip1jmp1, ps_glo, p, pks, pk)
176    else
177      CALL exner_milieu(ip1jmp1, ps_glo, p, pks, pk)
178    endif
179    CALL massdair(p, masse_glo)
[3976]180  ENDIF
181
[5117]182  IF (llm == 1) THEN
[5118]183    ! initialize fields for the shallow water case, if required
184    IF (.NOT.read_start) THEN
185      phis(ijb_u:ije_u) = 0.
186      q(ijb_u:ije_u, 1:llm, 1:nqtot) = 0
187      CALL sw_case_williamson91_6_loc(vcov, ucov, teta, masse, ps)
188    endif
[5117]189  ENDIF
[1749]190
[5116]191  academic_case: if (iflag_phys >= 2) THEN
[5118]192    ! initializations
[1749]193
[5118]194    ! 1. local parameters
195    ! by convention, winter is in the southern hemisphere
196    ! Geostrophic wind or no wind?
197    ok_geost = .TRUE.
198    CALL getin('ok_geost', ok_geost)
199    ! Constants for Newtonian relaxation and friction
200    k_f = 1.                !friction
201    CALL getin('k_j', k_f)
202    k_f = 1. / (daysec * k_f)
203    k_c_s = 4.  !cooling surface
204    CALL getin('k_c_s', k_c_s)
205    k_c_s = 1. / (daysec * k_c_s)
206    k_c_a = 40. !cooling free atm
207    CALL getin('k_c_a', k_c_a)
208    k_c_a = 1. / (daysec * k_c_a)
209    ! Constants for Teta equilibrium profile
210    teta0 = 315.     ! mean Teta (S.H. 315K)
211    CALL getin('teta0', teta0)
212    ttp = 200.       ! Tropopause temperature (S.H. 200K)
213    CALL getin('ttp', ttp)
214    eps = 0.         ! Deviation to N-S symmetry(~0-20K)
215    CALL getin('eps', eps)
216    delt_y = 60.     ! Merid Temp. Gradient (S.H. 60K)
217    CALL getin('delt_y', delt_y)
218    delt_z = 10.     ! Vertical Gradient (S.H. 10K)
219    CALL getin('delt_z', delt_z)
220    ! Polar vortex
221    ok_pv = .FALSE.
222    CALL getin('ok_pv', ok_pv)
223    phi_pv = -50.            ! Latitude of edge of vortex
224    CALL getin('phi_pv', phi_pv)
225    phi_pv = phi_pv * pi / 180.
226    dphi_pv = 5.             ! Width of the edge
227    CALL getin('dphi_pv', dphi_pv)
228    dphi_pv = dphi_pv * pi / 180.
229    gam_pv = 4.              ! -dT/dz vortex (in K/km)
230    CALL getin('gam_pv', gam_pv)
231    tetanoise = 0.005
232    CALL getin('tetanoise', tetanoise)
[1749]233
[5118]234    ! 2. Initialize fields towards which to relax
235    ! Friction
236    knewt_g = k_c_a
237    DO l = 1, llm
238      zsig = presnivs(l) / preff
239      knewt_t(l) = (k_c_s - k_c_a) * MAX(0., (zsig - 0.7) / 0.3)
240      kfrict(l) = k_f * MAX(0., (zsig - 0.7) / 0.3)
241    ENDDO
242    DO j = 1, jjp1
243      clat4((j - 1) * iip1 + 1:j * iip1) = cos(rlatu(j))**4
244    ENDDO
[1749]245
[5118]246    ! Potential temperature
247    DO l = 1, llm
248      zsig = presnivs(l) / preff
249      tetastrat = ttp * zsig**(-kappa)
250      tetapv = tetastrat
251      IF ((ok_pv).AND.(zsig<0.1)) THEN
252        tetapv = tetastrat * (zsig * 10.)**(kappa * cpp * gam_pv / 1000. / g)
253      ENDIF
254      DO j = 1, jjp1
255        ! Troposphere
256        ddsin = sin(rlatu(j))
257        tetajl(j, l) = teta0 - delt_y * ddsin * ddsin + eps * ddsin &
258                - delt_z * (1. - ddsin * ddsin) * log(zsig)
259        IF (planet_type=="giant") THEN
260          tetajl(j, l) = teta0 + (delt_y * &
261                  ((sin(rlatu(j) * 3.14159 * eps + 0.0001))**2)   &
262                  / ((rlatu(j) * 3.14159 * eps + 0.0001)**2))     &
263                  - delt_z * log(zsig)
264        endif
265        ! Profil stratospherique isotherme (+vortex)
266        w_pv = (1. - tanh((rlatu(j) - phi_pv) / dphi_pv)) / 2.
267        tetastrat = tetastrat * (1. - w_pv) + tetapv * w_pv
268        tetajl(j, l) = MAX(tetajl(j, l), tetastrat)
269      ENDDO
270    ENDDO
[1749]271
[5118]272    !          CALL writefield('theta_eq',tetajl)
[1749]273
[5118]274    do l = 1, llm
275      do j = 1, jjp1
276        do i = 1, iip1
277          ij = (j - 1) * iip1 + i
278          tetarappel(ij, l) = tetajl(j, l)
[1749]279        enddo
[5118]280      enddo
281    enddo
[1749]282
[5118]283    ! 3. Initialize fields (if necessary)
284    IF (.NOT. read_start) THEN
285      ! bulk initialization of temperature
286      IF (iflag_phys>10000) THEN
[3976]287        ! Particular case to impose a constant temperature T0=0.01*iflag_phys
[5118]288        teta_glo(:, :) = 0.01 * iflag_phys / (pk(:, :) / cpp)
289      ELSE
290        teta_glo(:, :) = tetarappel(:, :)
291      ENDIF
292      ! geopotential
293      CALL geopot(ip1jmp1, teta_glo, pk, pks, phis_glo, phi)
[1749]294
[5118]295      ! winds
296      IF (ok_geost) THEN
297        CALL ugeostr(phi, ucov_glo)
298      else
299        ucov_glo(:, :) = 0.
300      endif
301      vcov(ijb_v:ije_v, 1:llm) = 0.
[1749]302
[5118]303      ! bulk initialization of tracers
304      IF (planet_type=="earth") THEN
305        ! Earth: first two tracers will be water
306        do iq = 1, nqtot
307          q(ijb_u:ije_u, :, iq) = 0.
308          IF(tracers(iq)%name == addPhase('H2O', 'g')) q(ijb_u:ije_u, :, iq) = 1.e-10
309          IF(tracers(iq)%name == addPhase('H2O', 'l')) q(ijb_u:ije_u, :, iq) = 1.e-15
[2270]310
[5118]311          ! CRisi: init des isotopes
312          ! distill de Rayleigh très simplifiée
313          iName = tracers(iq)%iso_iName
314          IF (niso <= 0 .OR. iName <= 0) CYCLE
315          iPhase = tracers(iq)%iso_iPhase
316          iqParent = tracers(iq)%iqParent
317          IF(tracers(iq)%iso_iZone == 0) THEN
318            IF (tnat1) THEN
319              tnat = 1.0
320              alpha_ideal = 1.0
321              WRITE(*, *) 'Attention dans iniacademic: alpha_ideal=1'
322            else
323              IF(getKey('tnat', tnat, isoName(iName)) .OR. getKey('alpha', alpha_ideal, isoName(iName))) &
324                      CALL abort_gcm(TRIM(modname), 'missing isotopic parameters', 1)
325            endif
326            q(ijb_u:ije_u, :, iq) = q(ijb_u:ije_u, :, iqParent) * tnat * (q(ijb_u:ije_u, :, iqParent) / 30.e-3)**(alpha_ideal - 1.)
327          ELSE !IF(tracers(iq)%iso_iZone == 0) THEN
328            IF(tracers(iq)%iso_iZone == 1) THEN ! a verifier.
329              ! correction le 14 mai 2024 pour que tous les traceurs soient de la couleur 1.
330              ! Sinon, on va avoir des porblèmes de conservation de masse de traceurs.
331              q(ijb_u:ije_u, :, iq) = q(ijb_u:ije_u, :, iqIsoPha(iName, iPhase))
332            else !IF(tracers(iq)%iso_iZone == 1) THEN
333              q(ijb_u:ije_u, :, iq) = 0.0
334            endif !IF(tracers(iq)%iso_iZone == 1) THEN
335          END IF !IF(tracers(iq)%iso_iZone == 0) THEN
336        enddo
337      else
338        q(ijb_u:ije_u, :, :) = 0
339      endif ! of if (planet_type=="earth")
[1749]340
[5118]341      CALL check_isotopes(q, ijb_u, ije_u, 'iniacademic_loc')
[2270]342
[5118]343      ! add random perturbation to temperature
344      idum = -1
345      zz = ran1(idum)
346      idum = 0
347      do l = 1, llm
348        do ij = iip2, ip1jm
349          teta_glo(ij, l) = teta_glo(ij, l) * (1. + tetanoise * ran1(idum))
[1749]350        enddo
[5118]351      enddo
[1749]352
[5118]353      ! maintain periodicity in longitude
354      do l = 1, llm
355        do ij = 1, ip1jmp1, iip1
356          teta_glo(ij + iim, l) = teta_glo(ij, l)
[1749]357        enddo
[5118]358      enddo
[1749]359
[5118]360      ! copy data from global array to local array:
361      teta(ijb_u:ije_u, :) = teta_glo(ijb_u:ije_u, :)
362      ucov(ijb_u:ije_u, :) = ucov_glo(ijb_u:ije_u, :)
363      !        vcov(ijb_v:ije_v,:)=vcov_glo(ijb_v:ije_v,:)
364      masse(ijb_u:ije_u, :) = masse_glo(ijb_u:ije_u, :)
365      ps(ijb_u:ije_u) = ps_glo(ijb_u:ije_u)
366      phis(ijb_u:ije_u) = phis_glo(ijb_u:ije_u)
[1749]367
[5118]368      deallocate(teta_glo)
369      deallocate(ucov_glo)
370      !        deallocate(vcov_glo)
371      deallocate(masse_glo)
372      deallocate(ps_glo)
373      deallocate(phis_glo)
374    ENDIF ! of IF (.NOT. read_start)
[5117]375  ENDIF academic_case
[1749]376
377END SUBROUTINE iniacademic_loc
Note: See TracBrowser for help on using the repository browser.