source: LMDZ6/branches/Ocean_skin/libf/phylmdiso/phyetat0_mod.F90 @ 4926

Last change on this file since 4926 was 4369, checked in by lguez, 19 months ago

Sync latest trunk changes to branch Ocean_skin

File size: 22.9 KB
Line 
1! $Id: phyetat0.F90 3890 2021-05-05 15:15:06Z jyg $
2
3MODULE phyetat0_mod
4
5  PRIVATE
6  PUBLIC :: phyetat0
7
8CONTAINS
9
10SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
11
12  USE dimphy, only: klon, zmasq, klev
13  USE iophy, ONLY : init_iophy_new
14  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
15  USE fonte_neige_mod,  ONLY : fonte_neige_init
16  USE pbl_surface_mod,  ONLY : pbl_surface_init
17#ifdef ISO
18  USE fonte_neige_mod,  ONLY : fonte_neige_init_iso
19  USE pbl_surface_mod,  ONLY : pbl_surface_init_iso
20#endif
21  USE phyetat0_get_mod, ONLY : phyetat0_get, phyetat0_srf
22  USE surface_data,     ONLY : type_ocean, version_ocean
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, &
27       ftsol, pbl_tke, pctsrf, q_ancien, ql_ancien, qs_ancien, rneb_ancien, radpas, radsol, rain_fall, ratqs, &
28       rnebcon, rugoro, sig1, snow_fall, solaire_etat0, sollw, sollwdown, &
29       solsw, solswfdiff, t_ancien, u_ancien, v_ancien, w01, wake_cstar, wake_deltaq, &
30       wake_deltat, wake_delta_pbl_TKE, delta_tsurf, beta_aridity, wake_fip, wake_pe, &
31       wake_s, wake_dens, awake_dens, cv_gen, zgam, zmax0, zmea, zpic, zsig, &
32#ifdef ISO
33       fxtevap, xtsol, xt_ancien, xtl_ancien, xts_ancien, wake_deltaxt, &
34       xtrain_fall,xtsnow_fall, &
35#endif
36       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, u10m, v10m, treedrg, &
37       ale_wake, ale_bl_stat, ds_ns, dt_ns, delta_sst, delta_sal, ratqs_inter
38!FC
39  USE geometry_mod,     ONLY: longitude_deg, latitude_deg
40  USE iostart,          ONLY: close_startphy, get_field, get_var, open_startphy
41  USE infotrac_phy,     ONLY: nqtot, nbtr, type_trac, types_trac, tracers
42  USE readTracFiles_mod,ONLY: maxlen, new2oldH2O
43  USE traclmdz_mod,     ONLY: traclmdz_from_restart
44  USE carbon_cycle_mod, ONLY: carbon_cycle_init, carbon_cycle_cpl, carbon_cycle_tr, carbon_cycle_rad, co2_send, RCO2_glo
45  USE indice_sol_mod,   ONLY: nbsrf, is_ter, epsfra, is_lic, is_oce, is_sic
46  USE ocean_slab_mod,   ONLY: nslay, tslab, seaice, tice, ocean_slab_init
47  USE time_phylmdz_mod, ONLY: init_iteration, pdtphys, itau_phy
48#ifdef CPP_XIOS
49  USE wxios, ONLY: missing_val
50#else
51  use netcdf, only: missing_val => nf90_fill_real
52#endif
53  use config_ocean_skin_m, only: activate_ocean_skin
54#ifdef ISO
55  USE infotrac_phy, ONLY: niso
56  USE isotopes_routines_mod, ONLY: phyisoetat0
57  USE isotopes_mod, ONLY: iso_eau
58#ifdef ISOVERIF
59  USE isotopes_verif_mod, ONLY: iso_verif_egalite_vect2D,iso_verif_egalite
60#endif
61#endif
62
63  IMPLICIT none
64  !======================================================================
65  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
66  ! Objet: Lecture de l'etat initial pour la physique
67  !======================================================================
68  include "dimsoil.h"
69  include "clesphys.h"
70  include "alpale.h"
71  include "compbl.h"
72  include "YOMCST.h"
73  !======================================================================
74  CHARACTER*(*) fichnom
75
76  ! les variables globales lues dans le fichier restart
77
78  REAL tsoil(klon, nsoilmx, nbsrf)
79  REAL qsurf(klon, nbsrf)
80  REAL snow(klon, nbsrf)
81  real fder(klon)
82  REAL run_off_lic_0(klon)
83  REAL fractint(klon)
84  REAL trs(klon, nbtr)
85  REAL zts(klon)
86  ! pour drag arbres FC
87  REAL drg_ter(klon,klev)
88
89  CHARACTER*6 ocean_in
90  LOGICAL ok_veget_in
91
92  INTEGER        longcles
93  PARAMETER    ( longcles = 20 )
94  REAL clesphy0( longcles )
95
96  REAL xmin, xmax
97
98  INTEGER nid, nvarid
99  INTEGER ierr, i, nsrf, isoil , k
100  INTEGER length
101  PARAMETER (length=100)
102  INTEGER it, iq, isw
103  REAL tab_cntrl(length), tabcntr0(length)
104  CHARACTER*7 str7
105  CHARACTER*2 str2
106  LOGICAL :: found
107  REAL :: lon_startphy(klon), lat_startphy(klon)
108  CHARACTER(LEN=maxlen) :: tname, t(2)
109
110#ifdef ISO
111  REAL xtsnow(niso,klon, nbsrf)
112  REAL xtrun_off_lic_0(niso,klon)
113  REAL Rland_ice(niso,klon)
114#endif
115  ! FH1D
116  !     real iolat(jjm+1)
117  !real iolat(jjm+1-1/(iim*jjm))
118
119  ! Ouvrir le fichier contenant l'etat initial:
120
121  CALL open_startphy(fichnom)
122
123  ! Lecture des parametres de controle:
124
125  CALL get_var("controle", tab_cntrl)
126
127!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
128  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
129  ! Les constantes de la physiques sont lues dans la physique seulement.
130  ! Les egalites du type
131  !             tab_cntrl( 5 )=clesphy0(1)
132  ! sont remplacees par
133  !             clesphy0(1)=tab_cntrl( 5 )
134  ! On inverse aussi la logique.
135  ! On remplit les tab_cntrl avec les parametres lus dans les .def
136!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
137
138  DO i = 1, length
139     tabcntr0( i ) = tab_cntrl( i )
140  ENDDO
141
142  tab_cntrl(1)=pdtphys
143  tab_cntrl(2)=radpas
144
145  ! co2_ppm : value from the previous time step
146
147  ! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
148  co2_ppm0 = 284.32
149  ! when no initial value is available e.g., from a restart
150  ! this variable must be set  in a .def file which will then be
151  ! used by the conf_phys_m.F90 routine.
152  ! co2_ppm0 = 284.32 (illustrative example on how to set the variable in .def
153  ! file, for a pre-industrial CO2 concentration value)
154
155  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
156     co2_ppm = tab_cntrl(3)
157     RCO2    = co2_ppm * 1.0e-06 * RMCO2 / RMD
158     IF (tab_cntrl(17) > 0. .AND. carbon_cycle_rad) THEN
159           RCO2_glo = tab_cntrl(17)
160       ELSE
161           RCO2_glo    = co2_ppm0 * 1.0e-06 * RMCO2 / RMD
162     ENDIF
163     ! ELSE : keep value from .def
164  ENDIF
165
166  solaire_etat0      = tab_cntrl(4)
167  tab_cntrl(5)=iflag_con
168  tab_cntrl(6)=nbapp_rad
169
170  IF (iflag_cycle_diurne.GE.1) tab_cntrl( 7) = iflag_cycle_diurne
171  IF (soil_model) tab_cntrl( 8) =1.
172  IF (new_oliq) tab_cntrl( 9) =1.
173  IF (ok_orodr) tab_cntrl(10) =1.
174  IF (ok_orolf) tab_cntrl(11) =1.
175  IF (ok_limitvrai) tab_cntrl(12) =1.
176
177  itau_phy = tab_cntrl(15)
178
179  clesphy0(1)=tab_cntrl( 5 )
180  clesphy0(2)=tab_cntrl( 6 )
181  clesphy0(3)=tab_cntrl( 7 )
182  clesphy0(4)=tab_cntrl( 8 )
183  clesphy0(5)=tab_cntrl( 9 )
184  clesphy0(6)=tab_cntrl( 10 )
185  clesphy0(7)=tab_cntrl( 11 )
186  clesphy0(8)=tab_cntrl( 12 )
187  clesphy0(9)=tab_cntrl( 17 )
188
189  ! set time iteration
190   CALL init_iteration(itau_phy)
191
192  ! read latitudes and make a sanity check (because already known from dyn)
193  CALL get_field("latitude",lat_startphy)
194  DO i=1,klon
195    IF (ABS(lat_startphy(i)-latitude_deg(i))>=1) THEN
196      WRITE(*,*) "phyetat0: Error! Latitude discrepancy wrt startphy file:",&
197                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
198                 " latitude_deg(i)=",latitude_deg(i)
199      ! This is presumably serious enough to abort run
200      CALL abort_physic("phyetat0","discrepancy in latitudes!",1)
201    ENDIF
202    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.0001) THEN
203      WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
204                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
205                 " latitude_deg(i)=",latitude_deg(i)
206    ENDIF
207  ENDDO
208
209  ! read longitudes and make a sanity check (because already known from dyn)
210  CALL get_field("longitude",lon_startphy)
211  DO i=1,klon
212    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
213      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i)))>=1) THEN
214        WRITE(*,*) "phyetat0: Error! Longitude discrepancy wrt startphy file:",&
215                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
216                   " longitude_deg(i)=",longitude_deg(i)
217        ! This is presumably serious enough to abort run
218        CALL abort_physic("phyetat0","discrepancy in longitudes!",1)
219      ENDIF
220    ENDIF
221    IF (ABS(lon_startphy(i)-longitude_deg(i))>=1) THEN
222      IF (ABS(360-ABS(lon_startphy(i)-longitude_deg(i))) > 0.0001) THEN
223        WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
224                   " i=",i," lon_startphy(i)=",lon_startphy(i),&
225                   " longitude_deg(i)=",longitude_deg(i)
226      ENDIF
227    ENDIF
228  ENDDO
229
230  ! Lecture du masque terre mer
231
232  CALL get_field("masque", zmasq, found)
233  IF (.NOT. found) THEN
234     PRINT*, 'phyetat0: Le champ <masque> est absent'
235     PRINT *, 'fichier startphy non compatible avec phyetat0'
236  ENDIF
237
238  ! Lecture des fractions pour chaque sous-surface
239
240  ! initialisation des sous-surfaces
241
242  pctsrf = 0.
243
244  ! fraction de terre
245
246  CALL get_field("FTER", pctsrf(:, is_ter), found)
247  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
248
249  ! fraction de glace de terre
250
251  CALL get_field("FLIC", pctsrf(:, is_lic), found)
252  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
253
254  ! fraction d'ocean
255
256  CALL get_field("FOCE", pctsrf(:, is_oce), found)
257  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
258
259  ! fraction glace de mer
260
261  CALL get_field("FSIC", pctsrf(:, is_sic), found)
262  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
263
264  !  Verification de l'adequation entre le masque et les sous-surfaces
265
266  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
267       + pctsrf(1 : klon, is_lic)
268  DO i = 1 , klon
269     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
270        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
271             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
272             , pctsrf(i, is_lic)
273        WRITE(*, *) 'Je force la coherence zmasq=fractint'
274        zmasq(i) = fractint(i)
275     ENDIF
276  ENDDO
277  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
278       + pctsrf(1 : klon, is_sic)
279  DO i = 1 , klon
280     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
281        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
282             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
283             , pctsrf(i, is_sic)
284        WRITE(*, *) 'Je force la coherence zmasq=1.-fractint'
285        zmasq(i) = 1. - fractint(i)
286     ENDIF
287  ENDDO
288
289!===================================================================
290! Lecture des temperatures du sol:
291!===================================================================
292
293  found=phyetat0_get(ftsol(:,1),"TS","Surface temperature",283.)
294  IF (found) THEN
295     DO nsrf=2,nbsrf
296        ftsol(:,nsrf)=ftsol(:,1)
297     ENDDO
298  ELSE
299     found=phyetat0_srf(ftsol,"TS","Surface temperature",283.)
300  ENDIF
301
302!===================================================================
303  ! Lecture des albedo difus et direct
304!===================================================================
305
306  DO nsrf = 1, nbsrf
307     DO isw=1, nsw
308        IF (isw.GT.99) THEN
309           PRINT*, "Trop de bandes SW"
310           call abort_physic("phyetat0", "", 1)
311        ENDIF
312        WRITE(str2, '(i2.2)') isw
313        found=phyetat0_srf(falb_dir(:, isw,:),"A_dir_SW"//str2//"srf","Direct Albedo",0.2)
314        found=phyetat0_srf(falb_dif(:, isw,:),"A_dif_SW"//str2//"srf","Direct Albedo",0.2)
315     ENDDO
316  ENDDO
317
318  found=phyetat0_srf(u10m,"U10M","u a 10m",0.)
319  found=phyetat0_srf(v10m,"V10M","v a 10m",0.)
320
321!===================================================================
322  ! Lecture des temperatures du sol profond:
323!===================================================================
324
325   DO isoil=1, nsoilmx
326        IF (isoil.GT.99) THEN
327           PRINT*, "Trop de couches "
328           call abort_physic("phyetat0", "", 1)
329        ENDIF
330        WRITE(str2,'(i2.2)') isoil
331        found=phyetat0_srf(tsoil(:, isoil,:),"Tsoil"//str2//"srf","Temp soil",0.)
332        IF (.NOT. found) THEN
333           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
334           PRINT*, "          Il prend donc la valeur de surface"
335           tsoil(:, isoil, :)=ftsol(:, :)
336        ENDIF
337   ENDDO
338
339!=======================================================================
340! Lecture precipitation/evaporation
341!=======================================================================
342
343  found=phyetat0_srf(qsurf,"QS","Near surface hmidity",0.)
344  found=phyetat0_get(qsol,"QSOL","Surface hmidity / bucket",0.)
345  found=phyetat0_srf(snow,"SNOW","Surface snow",0.)
346  found=phyetat0_srf(fevap,"EVAP","evaporation",0.)
347  found=phyetat0_get(snow_fall,"snow_f","snow fall",0.)
348  found=phyetat0_get(rain_fall,"rain_f","rain fall",0.)
349
350!=======================================================================
351! Radiation
352!=======================================================================
353
354  found=phyetat0_get(solsw,"solsw","net SW radiation surf",0.)
355  found=phyetat0_get(solswfdiff,"solswfdiff","fraction of SW radiation surf that is diffuse",1.)
356  found=phyetat0_get(sollw,"sollw","net LW radiation surf",0.)
357  found=phyetat0_get(sollwdown,"sollwdown","down LW radiation surf",0.)
358  IF (.NOT. found) THEN
359     sollwdown(:) = 0. ;  zts(:)=0.
360     DO nsrf=1,nbsrf
361        zts(:)=zts(:)+ftsol(:,nsrf)*pctsrf(:,nsrf)
362     ENDDO
363     sollwdown(:)=sollw(:)+RSIGMA*zts(:)**4
364  ENDIF
365
366  found=phyetat0_get(radsol,"RADS","Solar radiation",0.)
367  found=phyetat0_get(fder,"fder","Flux derivative",0.)
368
369
370  ! Lecture de la longueur de rugosite
371  found=phyetat0_srf(z0m,"RUG","Z0m ancien",0.001)
372  IF (found) THEN
373     z0h(:,1:nbsrf)=z0m(:,1:nbsrf)
374  ELSE
375     found=phyetat0_srf(z0m,"Z0m","Roughness length, momentum ",0.001)
376     found=phyetat0_srf(z0h,"Z0h","Roughness length, enthalpy ",0.001)
377  ENDIF
378!FC
379  IF (ifl_pbltree>0) THEN
380!CALL get_field("FTER", pctsrf(:, is_ter), found)
381    treedrg(:,1:klev,1:nbsrf)= 0.0
382    CALL get_field("treedrg_ter", drg_ter(:,:), found)
383!  found=phyetat0_srf(treedrg,"treedrg","drag from vegetation" , 0.)
384    !lecture du profile de freinage des arbres
385    IF (.not. found ) THEN
386      treedrg(:,1:klev,1:nbsrf)= 0.0
387    ELSE
388      treedrg(:,1:klev,is_ter)= drg_ter(:,:)
389!     found=phyetat0_get(treedrg,"treedrg","freinage arbres",0.)
390    ENDIF
391  ELSE
392    ! initialize treedrg(), because it will be written in restartphy.nc
393    treedrg(:,:,:) = 0.0
394  ENDIF
395
396  ! Lecture de l'age de la neige:
397  found=phyetat0_srf(agesno,"AGESNO","SNOW AGE",0.001)
398
399  ancien_ok=.true.
400  ancien_ok=ancien_ok.AND.phyetat0_get(t_ancien,"TANCIEN","TANCIEN",0.)
401  ancien_ok=ancien_ok.AND.phyetat0_get(q_ancien,"QANCIEN","QANCIEN",0.)
402  ancien_ok=ancien_ok.AND.phyetat0_get(ql_ancien,"QLANCIEN","QLANCIEN",0.)
403  ancien_ok=ancien_ok.AND.phyetat0_get(qs_ancien,"QSANCIEN","QSANCIEN",0.)
404  ancien_ok=ancien_ok.AND.phyetat0_get(rneb_ancien,"RNEBANCIEN","RNEBANCIEN",0.)
405  ancien_ok=ancien_ok.AND.phyetat0_get(u_ancien,"UANCIEN","UANCIEN",0.)
406  ancien_ok=ancien_ok.AND.phyetat0_get(v_ancien,"VANCIEN","VANCIEN",0.)
407  ancien_ok=ancien_ok.AND.phyetat0_get(prw_ancien,"PRWANCIEN","PRWANCIEN",0.)
408  ancien_ok=ancien_ok.AND.phyetat0_get(prlw_ancien,"PRLWANCIEN","PRLWANCIEN",0.)
409  ancien_ok=ancien_ok.AND.phyetat0_get(prsw_ancien,"PRSWANCIEN","PRSWANCIEN",0.)
410
411  ! Ehouarn: addtional tests to check if t_ancien, q_ancien contain
412  !          dummy values (as is the case when generated by ce0l,
413  !          or by iniaqua)
414  IF ( (maxval(q_ancien).EQ.minval(q_ancien))       .OR. &
415       (maxval(ql_ancien).EQ.minval(ql_ancien))     .OR. &
416       (maxval(qs_ancien).EQ.minval(qs_ancien))     .OR. &
417       (maxval(rneb_ancien).EQ.minval(rneb_ancien)) .OR. &
418       (maxval(prw_ancien).EQ.minval(prw_ancien))   .OR. &
419       (maxval(prlw_ancien).EQ.minval(prlw_ancien)) .OR. &
420       (maxval(prsw_ancien).EQ.minval(prsw_ancien)) .OR. &
421       (maxval(t_ancien).EQ.minval(t_ancien)) ) THEN
422    ancien_ok=.false.
423  ENDIF
424
425  found=phyetat0_get(clwcon,"CLWCON","CLWCON",0.)
426  found=phyetat0_get(rnebcon,"RNEBCON","RNEBCON",0.)
427  found=phyetat0_get(ratqs,"RATQS","RATQS",0.)
428
429  found=phyetat0_get(run_off_lic_0,"RUNOFFLIC0","RUNOFFLIC0",0.)
430
431!==================================
432!  TKE
433!==================================
434!
435  IF (iflag_pbl>1) then
436     found=phyetat0_srf(pbl_tke,"TKE","Turb. Kinetic. Energ. ",1.e-8)
437  ENDIF
438
439  IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1 ) then
440    found=phyetat0_srf(wake_delta_pbl_tke,"DELTATKE","Del TKE wk/env",0.)
441!!    found=phyetat0_srf(delta_tsurf,"DELTA_TSURF","Delta Ts wk/env ",0.)
442    found=phyetat0_srf(delta_tsurf,"DELTATS","Delta Ts wk/env ",0.)
443!!    found=phyetat0_srf(beta_aridity,"BETA_S","Aridity factor ",1.)
444    found=phyetat0_srf(beta_aridity,"BETAS","Aridity factor ",1.)
445  ENDIF   !(iflag_pbl>1 .AND. iflag_wake>=1 .AND. iflag_pbl_split >=1 )
446
447!==================================
448!  thermiques, poches, convection
449!==================================
450
451! Emanuel
452  found=phyetat0_get(sig1,"sig1","sig1",0.)
453  found=phyetat0_get(w01,"w01","w01",0.)
454
455! Wake
456  found=phyetat0_get(wake_deltat,"WAKE_DELTAT","Delta T wake/env",0.)
457  found=phyetat0_get(wake_deltaq,"WAKE_DELTAQ","Delta hum. wake/env",0.)
458  found=phyetat0_get(wake_s,"WAKE_S","Wake frac. area",0.)
459!jyg<
460!  Set wake_dens to -1000. when there is no restart so that the actual
461!  initialization is made in calwake.
462!!  found=phyetat0_get(1,wake_dens,"WAKE_DENS","Wake num. /unit area",0.)
463  found=phyetat0_get(wake_dens,"WAKE_DENS","Wake num. /unit area",-1000.)
464  found=phyetat0_get(awake_dens,"AWAKE_DENS","Active Wake num. /unit area",0.)
465  found=phyetat0_get(cv_gen,"CV_GEN","CB birth rate",0.)
466!>jyg
467  found=phyetat0_get(wake_cstar,"WAKE_CSTAR","WAKE_CSTAR",0.)
468  found=phyetat0_get(wake_pe,"WAKE_PE","WAKE_PE",0.)
469  found=phyetat0_get(wake_fip,"WAKE_FIP","WAKE_FIP",0.)
470
471! Thermiques
472  found=phyetat0_get(zmax0,"ZMAX0","ZMAX0",40.)
473  found=phyetat0_get(f0,"F0","F0",1.e-5)
474  found=phyetat0_get(fm_therm,"FM_THERM","Thermals mass flux",0.)
475  found=phyetat0_get(entr_therm,"ENTR_THERM","Thermals Entrain.",0.)
476  found=phyetat0_get(detr_therm,"DETR_THERM","Thermals Detrain.",0.)
477
478! ALE/ALP
479  found=phyetat0_get(ale_bl,"ALE_BL","ALE BL",0.)
480  found=phyetat0_get(ale_bl_trig,"ALE_BL_TRIG","ALE BL_TRIG",0.)
481  found=phyetat0_get(alp_bl,"ALP_BL","ALP BL",0.)
482  found=phyetat0_get(ale_wake,"ALE_WAKE","ALE_WAKE",0.)
483  found=phyetat0_get(ale_bl_stat,"ALE_BL_STAT","ALE_BL_STAT",0.)
484
485! fisrtilp/Clouds 0.002 could be ratqsbas. But can stay like this as well
486  found=phyetat0_get(ratqs_inter,"RATQS_INTER","Relative width of the lsc sugrid scale water",0.002)
487
488!===========================================
489  ! Read and send field trs to traclmdz
490!===========================================
491
492!--OB now this is for co2i - ThL: and therefore also for inco
493  IF (ANY(types_trac == 'co2i') .OR. ANY(types_trac == 'inco')) THEN
494     IF (carbon_cycle_cpl) THEN
495        ALLOCATE(co2_send(klon), stat=ierr)
496        IF (ierr /= 0) CALL abort_physic('phyetat0', 'pb allocation co2_send', 1)
497        found=phyetat0_get(co2_send,"co2_send","co2 send",co2_ppm0)
498     ENDIF
499  ELSE IF (type_trac == 'lmdz') THEN
500     it = 0
501     DO iq = 1, nqtot
502        IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
503        it = it+1
504        tname = tracers(iq)%name
505        t(1) = 'trs_'//TRIM(tname); t(2) = 'trs_'//TRIM(new2oldH2O(tname))
506        found = phyetat0_get(trs(:,it), t(:), "Surf trac"//TRIM(tname), 0.)
507     END DO
508     CALL traclmdz_from_restart(trs)
509  ENDIF
510
511#ifdef ISO
512        ! initialise les isotopes       
513        write(*,*) 'phyetat0 1069'
514         CALL phyisoetat0 (snow,run_off_lic_0, &
515     &           xtsnow,xtrun_off_lic_0, &
516     &           Rland_ice)
517#ifdef ISOVERIF
518      write(*,*) 'phyetat0 1074'
519      if (iso_eau.gt.0) then
520      call iso_verif_egalite_vect2D(  &
521     &           xtsnow,snow, &
522     &           'phyetat0 1101a',niso,klon,nbsrf)
523        do i=1,klon 
524              call iso_verif_egalite(Rland_ice(iso_eau,i),1.0, &
525     &         'phyetat0 1101b')
526         enddo
527      endif
528      write(*,*) 'phyetat0 1102'
529#endif
530#endif
531
532!===========================================
533!  ondes de gravite / relief
534!===========================================
535
536!  ondes de gravite non orographiques
537  IF (ok_gwd_rando) found = &
538       phyetat0_get(du_gwd_rando,"du_gwd_rando","du_gwd_rando",0.)
539  IF (.NOT. ok_hines .AND. ok_gwd_rando) found &
540       = phyetat0_get(du_gwd_front,"du_gwd_front","du_gwd_front",0.)
541
542!  prise en compte du relief sous-maille
543  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
544  found=phyetat0_get(zstd,"ZSTD","sub grid orography",0.)
545  found=phyetat0_get(zsig,"ZSIG","sub grid orography",0.)
546  found=phyetat0_get(zgam,"ZGAM","sub grid orography",0.)
547  found=phyetat0_get(zthe,"ZTHE","sub grid orography",0.)
548  found=phyetat0_get(zpic,"ZPIC","sub grid orography",0.)
549  found=phyetat0_get(zval,"ZVAL","sub grid orography",0.)
550  found=phyetat0_get(zmea,"ZMEA","sub grid orography",0.)
551  found=phyetat0_get(rugoro,"RUGSREL","sub grid orography",0.)
552
553!===========================================
554! Initialize ocean
555!===========================================
556
557  IF ( type_ocean == 'slab' ) THEN
558      CALL ocean_slab_init(phys_tstep, pctsrf)
559      IF (nslay.EQ.1) THEN
560        found=phyetat0_get(tslab,["tslab01","tslab  "],"tslab",0.)
561      ELSE
562          DO i=1,nslay
563            WRITE(str2,'(i2.2)') i
564            found=phyetat0_get(tslab(:,i),"tslab"//str2,"tslab",0.) 
565          ENDDO
566      ENDIF
567      IF (.NOT. found) THEN
568          PRINT*, "phyetat0: Le champ <tslab> est absent"
569          PRINT*, "Initialisation a tsol_oce"
570          DO i=1,nslay
571              tslab(:,i)=MAX(ftsol(:,is_oce),271.35)
572          ENDDO
573      ENDIF
574
575      ! Sea ice variables
576      IF (version_ocean == 'sicINT') THEN
577          found=phyetat0_get(tice,"slab_tice","slab_tice",0.)
578          IF (.NOT. found) THEN
579              PRINT*, "phyetat0: Le champ <tice> est absent"
580              PRINT*, "Initialisation a tsol_sic"
581                  tice(:)=ftsol(:,is_sic)
582          ENDIF
583          found=phyetat0_get(seaice,"seaice","seaice",0.)
584          IF (.NOT. found) THEN
585              PRINT*, "phyetat0: Le champ <seaice> est absent"
586              PRINT*, "Initialisation a 0/1m suivant fraction glace"
587              seaice(:)=0.
588              WHERE (pctsrf(:,is_sic).GT.EPSFRA)
589                  seaice=917.
590              ENDWHERE
591          ENDIF
592      ENDIF !sea ice INT
593  ENDIF ! Slab       
594
595  if (activate_ocean_skin >= 1) then
596     if (activate_ocean_skin == 2 .and. type_ocean == 'couple') then
597        found = phyetat0_get(delta_sal, "delta_sal", &
598             "ocean-air interface salinity minus bulk salinity", 0.)
599        found = phyetat0_get(delta_sst, "delta_SST", &
600             "ocean-air interface temperature minus bulk SST", 0.)
601     end if
602     
603     found = phyetat0_get(ds_ns, "dS_ns", "delta salinity near surface", 0.)
604     found = phyetat0_get(dt_ns, "dT_ns", "delta temperature near surface", &
605          0.)
606
607     where (pctsrf(:, is_oce) == 0.)
608        ds_ns = missing_val
609        dt_ns = missing_val
610        delta_sst = missing_val
611        delta_sal = missing_val
612     end where
613  end if
614
615  ! on ferme le fichier
616  CALL close_startphy
617
618  ! Initialize module pbl_surface_mod
619
620#ifdef ISOVERIF
621        write(*,*) 'phyetat0 572: snow(994,:)=',snow(994,2)
622        write(*,*) 'xtsnow(:,994,2)=',xtsnow(:,994,2)
623#endif
624
625  CALL pbl_surface_init(fder, snow, qsurf, tsoil)
626#ifdef ISO
627  CALL pbl_surface_init_iso(xtsnow,Rland_ice)
628#endif
629
630  ! Initialize module ocean_cpl_mod for the case of coupled ocean
631  IF ( type_ocean == 'couple' ) THEN
632     CALL ocean_cpl_init(phys_tstep, longitude_deg, latitude_deg)
633  ENDIF
634
635!  CALL init_iophy_new(latitude_deg, longitude_deg)
636
637  ! Initilialize module fonte_neige_mod     
638  CALL fonte_neige_init(run_off_lic_0)
639#ifdef ISO
640   CALL fonte_neige_init_iso(xtrun_off_lic_0)
641#endif
642
643END SUBROUTINE phyetat0
644
645END MODULE phyetat0_mod
646
Note: See TracBrowser for help on using the repository browser.