source: LMDZ6/branches/contrails/libf/phylmd/phyetat0_mod.f90 @ 5791

Last change on this file since 5791 was 5791, checked in by aborella, 4 months ago

Merge with trunk r5789

  • 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
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.0 KB
Line 
1! $Id: phyetat0_mod.f90 5791 2025-07-28 17:23:15Z aborella $
2
3MODULE phyetat0_mod
4
5  PRIVATE
6  PUBLIC :: phyetat0
7
8CONTAINS
9
10SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
11
12  USE clesphys_mod_h
13  USE dimphy, only: klon, zmasq, klev, nbtersrf, nbtsoildepths
14  USE iophy, ONLY : init_iophy_new
15  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
16  USE fonte_neige_mod,  ONLY : fonte_neige_init
17  USE pbl_surface_mod,  ONLY : pbl_surface_init
18!GG  USE surface_data,     ONLY : type_ocean, version_ocean
19  USE surface_data,     ONLY : type_ocean, version_ocean, iflag_seaice, &
20                                   iflag_seaice_alb, iflag_leads
21!GG
22  USE phyetat0_get_mod, ONLY : phyetat0_get, phyetat0_srf
23  USE phys_state_var_mod, ONLY : ancien_ok, clwcon, detr_therm, phys_tstep, &
24       qsol, fevap, z0m, z0h, agesno, &
25       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
26       falb_dir, falb_dif, prw_ancien, prlw_ancien, prsw_ancien, prbsw_ancien, &
27       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, qbs_ancien, &
28       cf_ancien, qvc_ancien, qvcon, qccon, cfc_ancien, qtc_ancien, nic_ancien, &
29       tke_ancien, radpas, radsol, rain_fall, ratqs, &
30       rnebcon, rugoro, sig1, snow_fall, bs_fall, solaire_etat0, sollw, sollwdown, &
31       solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
32       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
33       wake_s, awake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
34       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
35       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, dter, dser, &
36!GG       dt_ds, ratqs_inter_
37       dt_ds, ratqs_inter_, &
38       hice, tice, bilg_cumul, &
39!GG
40       frac_tersrf, z0m_tersrf, ratio_z0m_z0h_tersrf, &
41       albedo_tersrf, beta_tersrf, inertie_tersrf, alpha_soil_tersrf, &
42       period_tersrf, hcond_tersrf, tsurfi_tersrf, tsoili_tersrf, tsoil_depth, &
43       qsurf_tersrf, tsurf_tersrf, tsoil_tersrf, tsurf_new_tersrf, cdragm_tersrf, &
44       cdragh_tersrf, swnet_tersrf, lwnet_tersrf, fluxsens_tersrf, fluxlat_tersrf
45!FC
46  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
47  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
48  USE infotrac_phy,     ONLY: nqtot, nbtr, type_trac, tracers, new2oldH2O
49  USE strings_mod,      ONLY: maxlen
50  USE traclmdz_mod,     ONLY: traclmdz_from_restart
51  USE carbon_cycle_mod, ONLY: carbon_cycle_init, carbon_cycle_cpl, carbon_cycle_tr, carbon_cycle_rad, co2_send, RCO2_glo
52  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
53  !GG USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
54  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice_slab, ocean_slab_init
55  !GG
56  USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
57  use wxios_mod, ONLY: missing_val_xios => missing_val, using_xios
58  use netcdf, only: missing_val_netcdf => nf90_fill_real
59  use config_ocean_skin_m, only: activate_ocean_skin
60  USE surf_param_mod, ONLY: average_surf_var, interpol_tsoil !AM
61  USE dimsoil_mod_h, ONLY: nsoilmx
62  USE yomcst_mod_h
63  USE alpale_mod
64  USE compbl_mod_h
65IMPLICIT none
66  !======================================================================
67  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
68  ! Objet: Lecture de l'etat initial pour la physique
69  !======================================================================
70  CHARACTER*(*) fichnom
71
72  ! les variables globales lues dans le fichier restart
73
74  REAL tsoil(klon, nsoilmx, nbsrf)
75  REAL qsurf(klon, nbsrf)
76  REAL snow(klon, nbsrf)
77  real fder(klon)
78  REAL run_off_lic_0(klon)
79  REAL fractint(klon)
80  REAL trs(klon, nbtr)
81  REAL zts(klon)
82  ! pour drag arbres FC
83  REAL drg_ter(klon,klev)
84
85  CHARACTER*6 ocean_in
86  LOGICAL ok_veget_in
87
88  INTEGER        longcles
89  PARAMETER    ( longcles = 20 )
90  REAL clesphy0( longcles )
91
92  REAL xmin, xmax
93
94  INTEGER nid, nvarid
95  INTEGER ierr, i, nsrf, isoil , k
96  INTEGER length
97  PARAMETER (length=100)
98  INTEGER it, iq, isw
99  REAL tab_cntrl(length), tabcntr0(length)
100  CHARACTER*7 str7
101  CHARACTER*2 str2
102  LOGICAL :: found
103  REAL :: lon_startphy(klon), lat_startphy(klon)
104  CHARACTER(LEN=maxlen) :: tname, t(2)
105  REAL :: missing_val
106
107  IF (using_xios) THEN
108    missing_val=missing_val_xios
109  ELSE
110    missing_val=missing_val_netcdf
111  ENDIF
112 
113  ! FH1D
114  !     real iolat(jjm+1)
115  !real iolat(jjm+1-1/(iim*jjm))
116
117  ! Ouvrir le fichier contenant l'etat initial:
118
119  CALL open_startphy(fichnom)
120
121  ! Lecture des parametres de controle:
122
123  CALL get_var("controle", tab_cntrl)
124
125!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
126  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
127  ! Les constantes de la physiques sont lues dans la physique seulement.
128  ! Les egalites du type
129  !             tab_cntrl( 5 )=clesphy0(1)
130  ! sont remplacees par
131  !             clesphy0(1)=tab_cntrl( 5 )
132  ! On inverse aussi la logique.
133  ! On remplit les tab_cntrl avec les parametres lus dans les .def
134!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
135
136  DO i = 1, length
137     tabcntr0( i ) = tab_cntrl( i )
138  ENDDO
139
140  tab_cntrl(1)=pdtphys
141  tab_cntrl(2)=radpas
142
143  ! co2_ppm : value from the previous time step
144
145  ! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
146  co2_ppm0 = 284.32
147  ! when no initial value is available e.g., from a restart
148  ! this variable must be set  in a .def file which will then be
149  ! used by the conf_phys_m.F90 routine.
150  ! co2_ppm0 = 284.32 (illustrative example on how to set the variable in .def
151  ! file, for a pre-industrial CO2 concentration value)
152
153  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
154     co2_ppm = tab_cntrl(3)
155     RCO2    = co2_ppm * 1.0e-06 * RMCO2 / RMD
156     IF (tab_cntrl(17) > 0. .AND. carbon_cycle_rad) THEN
157           RCO2_glo = tab_cntrl(17)
158       ELSE
159           RCO2_glo    = co2_ppm0 * 1.0e-06 * RMCO2 / RMD
160     ENDIF
161     ! ELSE : keep value from .def
162  ENDIF
163
164  solaire_etat0      = tab_cntrl(4)
165  tab_cntrl(5)=iflag_con
166  tab_cntrl(6)=nbapp_rad
167
168  IF (iflag_cycle_diurne.GE.1) tab_cntrl( 7) = iflag_cycle_diurne
169  IF (soil_model) tab_cntrl( 8) =1.
170  IF (liqice_in_radocond) tab_cntrl( 9) =1.
171  IF (ok_orodr) tab_cntrl(10) =1.
172  IF (ok_orolf) tab_cntrl(11) =1.
173  IF (ok_limitvrai) tab_cntrl(12) =1.
174  !GG
175  tab_cntrl(18) =iflag_seaice
176  tab_cntrl(19) =iflag_seaice_alb
177  tab_cntrl(20) =iflag_leads
178  !GG
179
180  itau_phy = tab_cntrl(15)
181
182  clesphy0(1)=tab_cntrl( 5 )
183  clesphy0(2)=tab_cntrl( 6 )
184  clesphy0(3)=tab_cntrl( 7 )
185  clesphy0(4)=tab_cntrl( 8 )
186  clesphy0(5)=tab_cntrl( 9 )
187  clesphy0(6)=tab_cntrl( 10 )
188  clesphy0(7)=tab_cntrl( 11 )
189  clesphy0(8)=tab_cntrl( 12 )
190  clesphy0(9)=tab_cntrl( 17 )
191
192  ! set time iteration
193   CALL init_iteration(itau_phy)
194
195  ! read latitudes and make a sanity check (because already known from dyn)
196  CALL get_field("latitude",lat_startphy)
197  DO i=1,klon
198    IF (ABS(lat_startphy(i)-latitude_deg(i))>=1) THEN
199      WRITE(*,*) "phyetat0: Error! Latitude discrepancy wrt startphy file:",&
200                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
201                 " latitude_deg(i)=",latitude_deg(i)
202      ! This is presumably serious enough to abort run
203      CALL abort_physic("phyetat0","discrepancy in latitudes!",1)
204    ENDIF
205    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.0001) THEN
206      WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
207                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
208                 " latitude_deg(i)=",latitude_deg(i)
209    ENDIF
210  ENDDO
211
212  ! read longitudes and make a sanity check (because already known from dyn)
213  CALL get_field("longitude",lon_startphy)
214  DO i=1,klon
215    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
216      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i)))>=1) THEN
217        WRITE(*,*) "phyetat0: Error! Longitude discrepancy wrt startphy file:",&
218                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
219                   " longitude_deg(i)=",longitude_deg(i)
220        ! This is presumably serious enough to abort run
221        CALL abort_physic("phyetat0","discrepancy in longitudes!",1)
222      ENDIF
223    ENDIF
224    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
225      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i))) > 0.0001) THEN
226        WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
227                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
228                   " longitude_deg(i)=",longitude_deg(i)
229      ENDIF
230    ENDIF
231  ENDDO
232
233  ! Lecture du masque terre mer
234
235  CALL get_field("masque", zmasq, found)
236  IF (.NOT. found) THEN
237     PRINT*, 'phyetat0: Le champ <masque> est absent'
238     PRINT *, 'fichier startphy non compatible avec phyetat0'
239  ENDIF
240
241  ! Lecture des fractions pour chaque sous-surface
242
243  ! initialisation des sous-surfaces
244
245  pctsrf = 0.
246
247  ! fraction de terre
248
249  CALL get_field("FTER", pctsrf(:, is_ter), found)
250  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
251
252  ! fraction de glace de terre
253
254  CALL get_field("FLIC", pctsrf(:, is_lic), found)
255  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
256
257  ! fraction d'ocean
258
259  CALL get_field("FOCE", pctsrf(:, is_oce), found)
260  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
261
262  ! fraction glace de mer
263
264  CALL get_field("FSIC", pctsrf(:, is_sic), found)
265  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
266
267  !  Verification de l'adequation entre le masque et les sous-surfaces
268
269  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
270       + pctsrf(1 : klon, is_lic)
271  DO i = 1 , klon
272     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
273        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
274             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
275             , pctsrf(i, is_lic)
276        WRITE(*, *) 'Je force la coherence zmasq=fractint'
277        zmasq(i) = fractint(i)
278     ENDIF
279  ENDDO
280  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
281       + pctsrf(1 : klon, is_sic)
282  DO i = 1 , klon
283     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
284        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
285             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
286             , pctsrf(i, is_sic)
287        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
288        zmasq(i) = 1. - fractint(i)
289     ENDIF
290  ENDDO
291
292!===================================================================
293! Lecture des temperatures du sol:
294!===================================================================
295
296  found=phyetat0_get(ftsol(:,1),"TS","Surface temperature",283.)
297  IF (found) THEN
298     DO nsrf=2,nbsrf
299        ftsol(:,nsrf)=ftsol(:,1)
300     ENDDO
301  ELSE
302     found=phyetat0_srf(ftsol,"TS","Surface temperature",283.)
303  ENDIF
304
305!===================================================================
306  ! Lecture des albedo difus et direct
307!===================================================================
308
309  DO nsrf = 1, nbsrf
310     DO isw=1, nsw
311        IF (isw.GT.99) THEN
312           PRINT*, "Trop de bandes SW"
313           call abort_physic("phyetat0", "", 1)
314        ENDIF
315        WRITE(str2, '(i2.2)') isw
316        found=phyetat0_srf(falb_dir(:, isw,:),"A_dir_SW"//str2//"srf","Direct Albedo",0.2)
317        found=phyetat0_srf(falb_dif(:, isw,:),"A_dif_SW"//str2//"srf","Direct Albedo",0.2)
318     ENDDO
319  ENDDO
320
321  found=phyetat0_srf(u10m,"U10M","u a 10m",0.)
322  found=phyetat0_srf(v10m,"V10M","v a 10m",0.)
323
324!===================================================================
325! Lecture dans le cas iflag_pbl_surface =1
326!===================================================================
327
328   if ( iflag_physiq <= 1 ) then
329!===================================================================
330  ! Lecture des temperatures du sol profond:
331!===================================================================
332
333   DO isoil=1, nsoilmx
334        IF (isoil.GT.99) THEN
335           PRINT*, "Trop de couches "
336           call abort_physic("phyetat0", "", 1)
337        ENDIF
338        WRITE(str2,'(i2.2)') isoil
339        found=phyetat0_srf(tsoil(:, isoil,:),"Tsoil"//str2//"srf","Temp soil",0.)
340        IF (.NOT. found) THEN
341           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
342           PRINT*, "          Il prend donc la valeur de surface"
343           tsoil(:, isoil, :)=ftsol(:, :)
344        ENDIF
345   ENDDO
346
347!=======================================================================
348! Lecture precipitation/evaporation
349!=======================================================================
350
351  found=phyetat0_srf(qsurf,"QS","Near surface hmidity",0.)
352  found=phyetat0_get(qsol,"QSOL","Surface hmidity / bucket",0.)
353  found=phyetat0_srf(snow,"SNOW","Surface snow",0.)
354  found=phyetat0_srf(fevap,"EVAP","evaporation",0.)
355  found=phyetat0_get(snow_fall,"snow_f","snow fall",0.)
356  found=phyetat0_get(rain_fall,"rain_f","rain fall",0.)
357  IF (ok_bs) THEN
358     found=phyetat0_get(bs_fall,"bs_f","blowing snow fall",0.)
359  ELSE
360     bs_fall(:)=0.
361  ENDIF
362!=======================================================================
363! Radiation
364!=======================================================================
365
366  found=phyetat0_get(solsw,"solsw","net SW radiation surf",0.)
367  found=phyetat0_get(solswfdiff,"solswfdiff","fraction of SW radiation surf that is diffuse",1.)
368  found=phyetat0_get(sollw,"sollw","net LW radiation surf",0.)
369  found=phyetat0_get(sollwdown,"sollwdown","down LW radiation surf",0.)
370  IF (.NOT. found) THEN
371     sollwdown(:) = 0. ;  zts(:)=0.
372     DO nsrf=1,nbsrf
373        zts(:)=zts(:)+ftsol(:,nsrf)*pctsrf(:,nsrf)
374     ENDDO
375     sollwdown(:)=sollw(:)+RSIGMA*zts(:)**4
376  ENDIF
377
378  found=phyetat0_get(radsol,"RADS","Solar radiation",0.)
379  found=phyetat0_get(fder,"fder","Flux derivative",0.)
380
381
382  ! Lecture de la longueur de rugosite
383  found=phyetat0_srf(z0m,"RUG","Z0m ancien",0.001)
384  IF (found) THEN
385     z0h(:,1:nbsrf)=z0m(:,1:nbsrf)
386  ELSE
387     found=phyetat0_srf(z0m,"Z0m","Roughness length, momentum ",0.001)
388     found=phyetat0_srf(z0h,"Z0h","Roughness length, enthalpy ",0.001)
389  ENDIF
390!FC
391  IF (ifl_pbltree>0) THEN
392!CALL get_field("FTER", pctsrf(:, is_ter), found)
393    treedrg(:,1:klev,1:nbsrf)= 0.0
394    CALL get_field("treedrg_ter", drg_ter(:,:), found)
395!  found=phyetat0_srf(treedrg,"treedrg","drag from vegetation" , 0.)
396    !lecture du profile de freinage des arbres
397    IF (.not. found ) THEN
398      treedrg(:,1:klev,1:nbsrf)= 0.0
399    ELSE
400      treedrg(:,1:klev,is_ter)= drg_ter(:,:)
401!     found=phyetat0_get(treedrg,"treedrg","freinage arbres",0.)
402    ENDIF
403  ELSE
404    ! initialize treedrg(), because it will be written in restartphy.nc
405    treedrg(:,:,:) = 0.0
406  ENDIF
407
408  IF (iflag_hetero_surf .GT. 0) THEN
409    found=phyetat0_srf(frac_tersrf,"frac_tersrf","fraction of continental sub-surfaces",0.)
410    found=phyetat0_srf(z0m_tersrf,"z0m_tersrf","roughness length for momentum of continental sub-surfaces",0.)
411    found=phyetat0_srf(ratio_z0m_z0h_tersrf,"ratio_z0m_z0h_tersrf","ratio of heat to momentum roughness length of continental sub-surfaces",0.)
412    found=phyetat0_srf(albedo_tersrf,"albedo_tersrf","albedo of continental sub-surfaces",0.)
413    found=phyetat0_srf(beta_tersrf,"beta_tersrf","evapotranspiration coef of continental sub-surfaces",0.)
414    found=phyetat0_srf(inertie_tersrf,"inertie_tersrf","soil thermal inertia of continental sub-surfaces",0.)
415    found=phyetat0_srf(hcond_tersrf,"hcond_tersrf","heat conductivity of continental sub-surfaces",0.)
416    found=phyetat0_srf(tsurfi_tersrf,"tsurfi_tersrf","initial surface temperature of continental sub-surfaces",0.)
417    !
418    ! Check if the sum of the sub-surface fractions is equal to 1
419    DO it=1,klon
420      IF (SUM(frac_tersrf(it,:)) .NE. 1.) THEN
421        PRINT*, 'SUM(frac_tersrf) = ', SUM(frac_tersrf(it,:))
422        CALL abort_physic('conf_phys', 'the sum of fractions of heterogeneous land subsurfaces must be equal &
423                          & to 1 for iflag_hetero_surf = 1 and 2',1)
424      ENDIF
425    ENDDO
426    !
427    ! Initialisation of surface and soil temperatures (potentially different initial temperatures between sub-surfaces)
428    DO iq=1,nbtersrf
429      DO it=1,klon
430        tsurf_tersrf(it,iq) = tsurfi_tersrf(it,iq)
431      ENDDO
432    ENDDO
433    !
434    DO isoil=1, nbtsoildepths
435      IF (isoil.GT.99) THEN
436        PRINT*, "Trop de couches "
437        CALL abort_physic("phyetat0", "", 1)
438      ENDIF
439      WRITE(str2,'(i2.2)') isoil
440      found=phyetat0_srf(tsoil_depth(:,isoil,:),"tsoil_depth"//str2//"srf","soil depth of continental sub-surfaces",0.)
441      found=phyetat0_srf(tsoili_tersrf(:,isoil,:),"Tsoili"//str2//"srf","initial soil temperature of continental sub-surfaces",0.)
442      IF (.NOT. found) THEN
443        PRINT*, "phyetat0: Le champ <Tsoili"//str2//"> est absent"
444        PRINT*, "          Il prend donc la valeur de surface"
445        tsoili_tersrf(:, isoil, :) = tsurfi_tersrf(:, :)
446      ENDIF
447    ENDDO
448    !
449    tsoil_tersrf = interpol_tsoil(klon, nbtersrf, nsoilmx, nbtsoildepths, alpha_soil_tersrf, period_tersrf, &
450                   inertie_tersrf, hcond_tersrf, tsoil_depth, tsurf_tersrf, tsoili_tersrf)
451    !
452    ! initialise also average surface and soil temperatures
453    ftsol(:,is_ter) = average_surf_var(klon, nbtersrf, tsurf_tersrf, frac_tersrf, 'ARI')
454    DO k=1, nsoilmx
455      tsoil(:,k,is_ter) = average_surf_var(klon, nbtersrf, tsoil_tersrf(:,k,:), frac_tersrf, 'ARI')
456    ENDDO
457    !
458  ENDIF ! iflag_hetero_surf > 0
459
460  endif ! iflag_physiq <= 1
461
462  ! Lecture de l'age de la neige:
463  found=phyetat0_srf(agesno,"AGESNO","SNOW AGE",0.001)
464
465  ancien_ok=.true.
466  ancien_ok=ancien_ok.AND.phyetat0_get(t_ancien,"TANCIEN","TANCIEN",0.)
467  ancien_ok=ancien_ok.AND.phyetat0_get(q_ancien,"QANCIEN","QANCIEN",0.)
468  ancien_ok=ancien_ok.AND.phyetat0_get(ql_ancien,"QLANCIEN","QLANCIEN",0.)
469  ancien_ok=ancien_ok.AND.phyetat0_get(qs_ancien,"QSANCIEN","QSANCIEN",0.)
470  ancien_ok=ancien_ok.AND.phyetat0_get(u_ancien,"UANCIEN","UANCIEN",0.)
471  ancien_ok=ancien_ok.AND.phyetat0_get(v_ancien,"VANCIEN","VANCIEN",0.)
472  ancien_ok=ancien_ok.AND.phyetat0_get(prw_ancien,"PRWANCIEN","PRWANCIEN",0.)
473  ancien_ok=ancien_ok.AND.phyetat0_get(prlw_ancien,"PRLWANCIEN","PRLWANCIEN",0.)
474  ancien_ok=ancien_ok.AND.phyetat0_get(prsw_ancien,"PRSWANCIEN","PRSWANCIEN",0.)
475
476  ! cas specifique des variables de la neige soufflee
477  IF (ok_bs) THEN
478     ancien_ok=ancien_ok.AND.phyetat0_get(qbs_ancien,"QBSANCIEN","QBSANCIEN",0.)
479     ancien_ok=ancien_ok.AND.phyetat0_get(prbsw_ancien,"PRBSWANCIEN","PRBSWANCIEN",0.)
480  ELSE
481     qbs_ancien(:,:)=0.
482     prbsw_ancien(:)=0.
483  ENDIF
484 
485  ! cas specifique des variables de la sursaturation par rapport a la glace
486  IF ( ok_ice_supersat ) THEN
487    ancien_ok=ancien_ok.AND.phyetat0_get(cf_ancien,"CFANCIEN","CFANCIEN",0.)
488    ancien_ok=ancien_ok.AND.phyetat0_get(qvc_ancien,"QVCANCIEN","QVCANCIEN",0.)
489    found=phyetat0_get(qvcon,"QVCON","QVCON",0.)
490    found=phyetat0_get(qccon,"QCCON","QCCON",0.)
491  ELSE
492    cf_ancien(:,:)=0.
493    qvc_ancien(:,:)=0.
494  ENDIF
495
496  ! cas specifique des variables de l'aviation
497  IF ( ok_plane_contrail ) THEN
498    ancien_ok=ancien_ok.AND.phyetat0_get(cfc_ancien,"CFCANCIEN","CFCANCIEN",0.)
499    ancien_ok=ancien_ok.AND.phyetat0_get(qtc_ancien,"QTCANCIEN","QTCANCIEN",0.)
500    ancien_ok=ancien_ok.AND.phyetat0_get(nic_ancien,"NICANCIEN","NICANCIEN",0.)
501  ELSE
502    cfc_ancien(:,:)=0.
503    qtc_ancien(:,:)=0.
504    nic_ancien(:,:)=0.
505  ENDIF
506
507  ! Ehouarn: addtional tests to check if t_ancien, q_ancien contain
508  !          dummy values (as is the case when generated by ce0l,
509  !          or by iniaqua)
510  IF ( (maxval(q_ancien).EQ.minval(q_ancien))       .OR. &
511       (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
512       (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
513       (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
514       (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
515       (maxval(prsw_ancien).EQ.minval(prsw_ancien)) .OR. &
516       (maxval(t_ancien).EQ.minval(t_ancien)) ) THEN
517    ancien_ok=.false.
518  ENDIF
519
520  IF (ok_bs) THEN
521    IF ( (maxval(qbs_ancien).EQ.minval(qbs_ancien))       .OR. &
522         (maxval(prbsw_ancien).EQ.minval(prbsw_ancien)) ) THEN
523       ancien_ok=.false.
524    ENDIF
525  ENDIF
526
527  IF ( ok_ice_supersat ) THEN
528    IF ( (maxval(cf_ancien).EQ.minval(cf_ancien))     .OR. &
529         (maxval(qvc_ancien).EQ.minval(qvc_ancien)) ) THEN
530       ancien_ok=.false.
531     ENDIF
532  ENDIF
533
534  IF ( ok_plane_contrail ) THEN
535    IF ( ( maxval(cfc_ancien).EQ.minval(cfc_ancien) ) .OR. &
536         ( maxval(qtc_ancien).EQ.minval(qtc_ancien) ) .OR. &
537         ( maxval(nic_ancien).EQ.minval(nic_ancien) ) ) THEN
538       ancien_ok=.false.
539     ENDIF
540  ENDIF
541
542  found=phyetat0_get(clwcon,"CLWCON","CLWCON",0.)
543  found=phyetat0_get(rnebcon,"RNEBCON","RNEBCON",0.)
544  found=phyetat0_get(ratqs,"RATQS","RATQS",0.)
545
546  found=phyetat0_get(run_off_lic_0,"RUNOFFLIC0","RUNOFFLIC0",0.)
547
548!==================================
549!  TKE
550!==================================
551!
552  ! cas specifique de l'advection de TKE
553  IF (ok_advtke) THEN
554       ancien_ok=ancien_ok.AND.phyetat0_get(tke_ancien,"TKEANCIEN","TKEANCIEN",0.)
555  ELSE
556    tke_ancien(:,:)=0.
557  ENDIF
558
559  IF (ok_advtke) THEN
560    IF ( (maxval(tke_ancien).EQ.minval(tke_ancien))) THEN
561       ancien_ok=.false.
562    ENDIF
563  ENDIF
564
565  IF ((iflag_pbl>1)) then
566     found=phyetat0_srf(pbl_tke,"TKE","Turb. Kinetic. Energ. ",1.e-8)
567  ENDIF
568
569  IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
570    found=phyetat0_srf(wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
571!!    found=phyetat0_srf(delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
572    found=phyetat0_srf(delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
573!!    found=phyetat0_srf(beta_aridity,"BETA_S","Aridity factor ",1.)
574    found=phyetat0_srf(beta_aridity,"BETAS","Aridity factor ",1.)
575  ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
576
577!==================================
578!  thermiques, poches, convection
579!==================================
580
581! Emanuel
582  found=phyetat0_get(sig1,"sig1","sig1",0.)
583  found=phyetat0_get(w01,"w01","w01",0.)
584
585! Wake
586  found=phyetat0_get(wake_deltat,"WAKE_DELTAT","Delta T wake/env",0.)
587  found=phyetat0_get(wake_deltaq,"WAKE_DELTAQ","Delta hum. wake/env",0.)
588  found=phyetat0_get(wake_s,"WAKE_S","Wake frac. area",0.)
589  found=phyetat0_get(awake_s,"AWAKE_S","Active Wake frac. area",0.)
590!jyg<
591!  Set wake_dens to -1000. when there is no restart so that the actual
592!  initialization is made in calwake.
593!!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
594  found=phyetat0_get(wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
595  found=phyetat0_get(awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
596  found=phyetat0_get(cv_gen,"CV_GEN","CB birth rate",0.)
597!>jyg
598  found=phyetat0_get(wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
599  found=phyetat0_get(wake_pe,"WAKE_PE","WAKE_PE",0.)
600  found=phyetat0_get(wake_fip,"WAKE_FIP","WAKE_FIP",0.)
601
602! Thermiques
603  found=phyetat0_get(zmax0,"ZMAX0","ZMAX0",40.)
604  found=phyetat0_get(f0,"F0","F0",1.e-5)
605  found=phyetat0_get(fm_therm,"FM_THERM","Thermals mass flux",0.)
606  found=phyetat0_get(entr_therm,"ENTR_THERM","Thermals Entrain.",0.)
607  found=phyetat0_get(detr_therm,"DETR_THERM","Thermals Detrain.",0.)
608
609! ALE/ALP
610  found=phyetat0_get(ale_bl,"ALE_BL","ALE BL",0.)
611  found=phyetat0_get(ale_bl_trig,"ALE_BL_TRIG","ALE BL_TRIG",0.)
612  found=phyetat0_get(alp_bl,"ALP_BL","ALP BL",0.)
613  found=phyetat0_get(ale_wake,"ALE_WAKE","ALE_WAKE",0.)
614  found=phyetat0_get(ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
615
616! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
617  found=phyetat0_get(ratqs_inter_,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
618
619!===========================================
620  ! Read and send field trs to traclmdz
621!===========================================
622
623!--OB now this is for co2i - ThL: and therefore also for inco
624  IF (ANY(type_trac == ['co2i','inco'])) THEN
625     IF (carbon_cycle_cpl) THEN
626        ALLOCATE(co2_send(klon), stat=ierr)
627        IF (ierr /= 0) CALL abort_physic('phyetat0', 'pb allocation co2_send', 1)
628        found=phyetat0_get(co2_send,"co2_send","co2 send",co2_ppm0)
629     ENDIF
630  ELSE IF (type_trac == 'lmdz') THEN
631     it = 0
632     DO iq = 1, nqtot
633        IF(.NOT.tracers(iq)%isInPhysics) CYCLE
634        it = it+1
635        tname = tracers(iq)%name
636        t(1) = 'trs_'//TRIM(tname); t(2) = 'trs_'//TRIM(new2oldH2O(tname))
637        found = phyetat0_get(trs(:,it), t(:), "Surf trac"//TRIM(tname), 0.)
638     END DO
639     CALL traclmdz_from_restart(trs)
640  ENDIF
641
642
643!===========================================
644!  ondes de gravite / relief
645!===========================================
646
647!  ondes de gravite non orographiques
648  IF (ok_gwd_rando) found = &
649       phyetat0_get(du_gwd_rando,"du_gwd_rando","du_gwd_rando",0.)
650  IF (.NOT. ok_hines .AND. ok_gwd_rando) found &
651       = phyetat0_get(du_gwd_front,"du_gwd_front","du_gwd_front",0.)
652
653!  prise en compte du relief sous-maille
654  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
655  found=phyetat0_get(zstd,"ZSTD","sub grid orography",0.)
656  found=phyetat0_get(zsig,"ZSIG","sub grid orography",0.)
657  found=phyetat0_get(zgam,"ZGAM","sub grid orography",0.)
658  found=phyetat0_get(zthe,"ZTHE","sub grid orography",0.)
659  found=phyetat0_get(zpic,"ZPIC","sub grid orography",0.)
660  found=phyetat0_get(zval,"ZVAL","sub grid orography",0.)
661  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
662  found=phyetat0_get(rugoro,"RUGSREL","sub grid orography",0.)
663
664!===========================================
665! Initialize ocean
666!===========================================
667
668  IF ( type_ocean == 'slab' ) THEN
669      CALL ocean_slab_init(phys_tstep, pctsrf)
670      IF (nslay.EQ.1) THEN
671        found=phyetat0_get(tslab,["tslab01","tslab  "],"tslab",0.)
672      ELSE
673          DO i=1,nslay
674            WRITE(str2,'(i2.2)') i
675            found=phyetat0_get(tslab(:,i),"tslab"//str2,"tslab",0.) 
676          ENDDO
677      ENDIF
678      IF (.NOT. found) THEN
679          PRINT*, "phyetat0: Le champ <tslab> est absent"
680          PRINT*, "Initialisation a tsol_oce"
681          DO i=1,nslay
682              tslab(:,i)=MAX(ftsol(:,is_oce),271.35)
683          ENDDO
684      ENDIF
685
686      ! Sea ice variables
687      IF (version_ocean == 'sicINT') THEN
688          found=phyetat0_get(tice_slab,"slab_tice","slab_tice",0.)
689  !GG        found=phyetat0_get(tice,"slab_tice","slab_tice",0.)
690          IF (.NOT. found) THEN
691  !GG            PRINT*, "phyetat0: Le champ <tice> est absent"
692              PRINT*, "phyetat0: Le champ <tice_slab> est absent"
693              PRINT*, "Initialisation a tsol_sic"
694  !GG                tice(:)=ftsol(:,is_sic)
695                  tice_slab(:)=ftsol(:,is_sic)
696          ENDIF
697          found=phyetat0_get(seaice,"seaice","seaice",0.)
698          IF (.NOT. found) THEN
699              PRINT*, "phyetat0: Le champ <seaice> est absent"
700              PRINT*, "Initialisation a 0/1m suivant fraction glace"
701              seaice(:)=0.
702              WHERE (pctsrf(:,is_sic).GT.EPSFRA)
703                  seaice=917.
704              ENDWHERE
705          ENDIF
706      ENDIF !sea ice INT
707  ENDIF ! Slab       
708
709  if (activate_ocean_skin >= 1) then
710     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
711        found = phyetat0_get(delta_sal, "delta_sal", &
712             "ocean-air interface salinity minus bulk salinity", 0.)
713        found = phyetat0_get(delta_sst, "delta_SST", &
714             "ocean-air interface temperature minus bulk SST", 0.)
715        found = phyetat0_get(dter, "dter", &
716             "ocean-air interface temperature minus subskin temperature", 0.)
717        found = phyetat0_get(dser, "dser", &
718             "ocean-air interface salinity minus subskin salinity", 0.)
719        found = phyetat0_get(dt_ds, "dt_ds", "(tks / tkt) * dTer", 0.)
720
721        where (pctsrf(:, is_oce) == 0.)
722           delta_sst = missing_val
723           delta_sal = missing_val
724           dter = missing_val
725           dser = missing_val
726           dt_ds = missing_val
727        end where
728     end if
729     
730     found = phyetat0_get(ds_ns, "dS_ns", "delta salinity near surface", 0.)
731     found = phyetat0_get(dt_ns, "dT_ns", "delta temperature near surface", &
732          0.)
733
734     where (pctsrf(:, is_oce) == 0.)
735        ds_ns = missing_val
736        dt_ns = missing_val
737        delta_sst = missing_val
738        delta_sal = missing_val
739     end where
740  end if
741
742  !GG
743  ! Sea ice
744  !IF (iflag_seaice == 2) THEN
745
746  found=phyetat0_get(hice,"hice","Ice thickness",0.)
747  IF (.NOT. found) THEN
748       PRINT*, "phyetat0: Le champ <hice> est absent"
749       PRINT*, "Initialisation a hice=1m "
750       hice(:)=1.0
751  END IF
752  found=phyetat0_get(tice,"tice","Sea Ice temperature",0.)
753  IF (.NOT. found) THEN
754       PRINT*, "phyetat0: Le champ <tice> est absent"
755       PRINT*, "Initialisation a tsol_sic"
756       tice(:)=ftsol(:,is_sic)
757  END IF
758  found=phyetat0_get(bilg_cumul,"bilg_cumul","Flux conductivite + transmit sea-ice",0.)
759  IF (.NOT. found) THEN
760       PRINT*, "phyetat0: Le champ <bilg_cumul> est absent"
761       PRINT*, "Initialisation a zero"
762       bilg_cumul(:)=0.0
763  END IF
764
765  !END IF
766  !GG
767  ! on ferme le fichier
768  CALL close_startphy
769
770  ! Initialize module pbl_surface_mod
771
772  if ( iflag_physiq <= 1 ) then
773  !GG CALL pbl_surface_init(fder, snow, qsurf, tsoil)
774  CALL pbl_surface_init(fder, snow, qsurf, tsoil, hice, tice, bilg_cumul)
775  !GG
776  endif
777
778  ! Initialize module ocean_cpl_mod for the case of coupled ocean
779  IF ( type_ocean == 'couple' ) THEN
780     CALL ocean_cpl_init(phys_tstep, longitude_deg, latitude_deg)
781  ENDIF
782
783!  CALL init_iophy_new(latitude_deg, longitude_deg)
784
785  ! Initilialize module fonte_neige_mod     
786  CALL fonte_neige_init(run_off_lic_0)
787
788END SUBROUTINE phyetat0
789
790END MODULE phyetat0_mod
791
Note: See TracBrowser for help on using the repository browser.