source: LMDZ6/branches/Ocean_skin/libf/phylmd/phyredem.F90 @ 3601

Last change on this file since 3601 was 3458, checked in by lguez, 6 years ago

Introduce variable activate_ocean_skin in module config_ocean_skin_m.

Bug fix in phys_state_var_end: we need to deallocate variables for
lmdz1d (although it is useless for a 3D run).

  • 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: 12.2 KB
Line 
1!
2! $Id: phyredem.F90 3458 2019-01-30 16:55:48Z lguez $
3!
4SUBROUTINE phyredem (fichnom)
5!
6!-------------------------------------------------------------------------------
7! Author: Z.X. Li (LMD/CNRS), 1993/08/18
8!-------------------------------------------------------------------------------
9! Purpose: Write restart state for physics.
10!-------------------------------------------------------------------------------
11  USE dimphy, ONLY: klon, klev
12  USE fonte_neige_mod,  ONLY : fonte_neige_final
13  USE pbl_surface_mod,  ONLY : pbl_surface_final
14  USE phys_state_var_mod, ONLY: radpas, zmasq, pctsrf, ftsol, falb_dir,      &
15                                falb_dif, qsol, fevap, radsol, solsw, sollw, &
16                                sollwdown, rain_fall, snow_fall, z0m, z0h,   &
17                                agesno, zmea, zstd, zsig, zgam, zthe, zpic,  &
18                                zval, rugoro, t_ancien, q_ancien,            &
19                                prw_ancien, prlw_ancien, prsw_ancien,        &
20                                ql_ancien, qs_ancien,  u_ancien,             &
21                                v_ancien, clwcon, rnebcon, ratqs, pbl_tke,   &
22                                wake_delta_pbl_tke, zmax0, f0, sig1, w01,    &
23                                wake_deltat, wake_deltaq, wake_s, wake_dens, &
24                                wake_cstar,                                  &
25                                wake_pe, wake_fip, fm_therm, entr_therm,     &
26                                detr_therm, ale_bl, ale_bl_trig, alp_bl,     &
27                                ale_wake, ale_bl_stat,                       &
28                                du_gwd_rando, du_gwd_front, u10m, v10m,      &
29                                treedrg, ds_ns, dt_ns
30  USE geometry_mod, ONLY : longitude_deg, latitude_deg
31  USE iostart, ONLY: open_restartphy, close_restartphy, put_field, put_var
32  USE traclmdz_mod, ONLY : traclmdz_to_restart
33  USE infotrac_phy, ONLY: type_trac, niadv, tname, nbtr, nqo
34  USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
35  USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic, epsfra
36  USE surface_data, ONLY: type_ocean, version_ocean
37  USE ocean_slab_mod, ONLY : nslay, tslab, seaice, tice, fsic
38  USE time_phylmdz_mod, ONLY: annee_ref, day_end, itau_phy, pdtphys
39  use config_ocean_skin_m, only: activate_ocean_skin 
40
41  IMPLICIT none
42
43  include "dimsoil.h"
44  include "clesphys.h"
45  include "thermcell.h"
46  include "compbl.h"
47  !======================================================================
48  CHARACTER*(*) fichnom
49
50  ! les variables globales ecrites dans le fichier restart
51
52  REAL tsoil(klon, nsoilmx, nbsrf)
53  REAL qsurf(klon, nbsrf)
54  REAL snow(klon, nbsrf)
55  real fder(klon)
56  REAL run_off_lic_0(klon)
57  REAL trs(klon, nbtr)
58
59  INTEGER nid, nvarid, idim1, idim2, idim3
60  INTEGER ierr
61  INTEGER length
62  PARAMETER (length=100)
63  REAL tab_cntrl(length)
64
65  INTEGER isoil, nsrf,isw
66  CHARACTER (len=2) :: str2
67  CHARACTER (len=256) :: nam, lnam
68  INTEGER           :: it, iiq
69
70  !======================================================================
71
72  ! Get variables which will be written to restart file from module
73  ! pbl_surface_mod
74  CALL pbl_surface_final(fder, snow, qsurf,  tsoil)
75
76  ! Get a variable calculated in module fonte_neige_mod
77  CALL fonte_neige_final(run_off_lic_0)
78
79  !======================================================================
80
81  CALL open_restartphy(fichnom)
82
83  DO ierr = 1, length
84     tab_cntrl(ierr) = 0.0
85  ENDDO
86  tab_cntrl(1) = pdtphys
87  tab_cntrl(2) = radpas
88  ! co2_ppm : current value of atmospheric CO2
89  tab_cntrl(3) = co2_ppm
90  tab_cntrl(4) = solaire
91  tab_cntrl(5) = iflag_con
92  tab_cntrl(6) = nbapp_rad
93
94  IF( iflag_cycle_diurne.GE.1 ) tab_cntrl( 7 ) = iflag_cycle_diurne
95  IF(   soil_model ) tab_cntrl( 8 ) = 1.
96  IF(     new_oliq ) tab_cntrl( 9 ) = 1.
97  IF(     ok_orodr ) tab_cntrl(10 ) = 1.
98  IF(     ok_orolf ) tab_cntrl(11 ) = 1.
99
100  tab_cntrl(13) = day_end
101  tab_cntrl(14) = annee_ref
102  tab_cntrl(15) = itau_phy
103
104  ! co2_ppm0 : initial value of atmospheric CO2
105  tab_cntrl(16) = co2_ppm0
106
107  CALL put_var("controle", "Parametres de controle", tab_cntrl)
108
109  CALL put_field("longitude", &
110       "Longitudes de la grille physique", longitude_deg)
111
112  CALL put_field("latitude", "Latitudes de la grille physique", latitude_deg)
113
114  ! PB ajout du masque terre/mer
115
116  CALL put_field("masque", "masque terre mer", zmasq)
117
118  ! BP ajout des fraction de chaque sous-surface
119
120  ! Get last fractions from slab ocean
121  IF (type_ocean == 'slab' .AND. version_ocean == "sicINT") THEN
122      WHERE (1.-zmasq(:).GT.EPSFRA)
123          pctsrf(:,is_oce)=(1.-fsic(:))*(1.-zmasq(:))
124          pctsrf(:,is_sic)=fsic(:)*(1.-zmasq(:))
125      END WHERE
126  END IF
127
128  ! 1. fraction de terre
129
130  CALL put_field("FTER", "fraction de continent", pctsrf(:, is_ter))
131
132  ! 2. Fraction de glace de terre
133
134  CALL put_field("FLIC", "fraction glace de terre", pctsrf(:, is_lic))
135
136  ! 3. fraction ocean
137
138  CALL put_field("FOCE", "fraction ocean", pctsrf(:, is_oce))
139
140  ! 4. Fraction glace de mer
141
142  CALL put_field("FSIC", "fraction glace mer", pctsrf(:, is_sic))
143
144  IF(nbsrf>99) THEN
145    PRINT*, "Trop de sous-mailles";  CALL abort_physic("phyredem", "", 1)
146  END IF
147  IF(nsoilmx>99) THEN
148    PRINT*, "Trop de sous-surfaces"; CALL abort_physic("phyredem", "", 1)
149  END IF
150  IF(nsw>99) THEN
151    PRINT*, "Trop de bandes"; CALL abort_physic("phyredem", "", 1)
152  END IF
153
154  CALL put_field_srf1("TS","Temperature",ftsol(:,:))
155
156! ================== Albedo =======================================
157  print*,'PHYREDEM NOUVEAU'
158  CALL put_field_srf2("A_dir_SW","Albedo direct",falb_dir(:,:,:))
159  CALL put_field_srf2("A_dif_SW","Albedo diffus",falb_dif(:,:,:))
160
161  CALL put_field_srf1("U10M", "u a 10m", u10m)
162
163  CALL put_field_srf1("V10M", "v a 10m", v10m)
164
165
166! ================== Tsoil =========================================
167  CALL put_field_srf2("Tsoil","Temperature",tsoil(:,:,:))
168!FC
169!  CALL put_field_srf2("treedrg","freinage arbres",treedrg(:,:,:))
170  CALL put_field("treedrg_ter","freinage arbres",treedrg(:,:,is_ter))
171
172
173  CALL put_field_srf1("QS"  , "Humidite",qsurf(:,:))
174
175  CALL put_field     ("QSOL", "Eau dans le sol (mm)", qsol)
176
177  CALL put_field_srf1("EVAP", "Evaporation", fevap(:,:))
178
179  CALL put_field_srf1("SNOW", "Neige", snow(:,:))
180
181  CALL put_field("RADS", "Rayonnement net a la surface", radsol)
182
183  CALL put_field("solsw", "Rayonnement solaire a la surface", solsw)
184
185  CALL put_field("sollw", "Rayonnement IF a la surface", sollw)
186
187  CALL put_field("sollwdown", "Rayonnement down IF a la surface", sollwdown)
188
189  CALL put_field("fder", "Derive de flux", fder)
190
191  CALL put_field("rain_f", "precipitation liquide", rain_fall)
192
193  CALL put_field("snow_f", "precipitation solide", snow_fall)
194
195  CALL put_field_srf1("Z0m", "rugosite", z0m(:,:))
196
197  CALL put_field_srf1("Z0h", "rugosite", z0h(:,:))
198
199  CALL put_field_srf1("AGESNO", "Age de la neige", agesno(:,:))
200
201  CALL put_field("ZMEA", "ZMEA", zmea)
202
203  CALL put_field("ZSTD", "ZSTD", zstd)
204
205  CALL put_field("ZSIG", "ZSIG", zsig)
206
207  CALL put_field("ZGAM", "ZGAM", zgam)
208
209  CALL put_field("ZTHE", "ZTHE", zthe)
210
211  CALL put_field("ZPIC", "ZPIC", zpic)
212
213  CALL put_field("ZVAL", "ZVAL", zval)
214
215  CALL put_field("RUGSREL", "RUGSREL", rugoro)
216
217  CALL put_field("TANCIEN", "TANCIEN", t_ancien)
218
219  CALL put_field("QANCIEN", "QANCIEN", q_ancien)
220
221  CALL put_field("QLANCIEN", "QLANCIEN", ql_ancien)
222
223  CALL put_field("QSANCIEN", "QSANCIEN", qs_ancien)
224
225  CALL put_field("PRWANCIEN", "PRWANCIEN", prw_ancien)
226
227  CALL put_field("PRLWANCIEN", "PRLWANCIEN", prlw_ancien)
228
229  CALL put_field("PRSWANCIEN", "PRSWANCIEN", prsw_ancien)
230
231  CALL put_field("UANCIEN", "UANCIEN", u_ancien)
232
233  CALL put_field("VANCIEN", "VANCIEN", v_ancien)
234
235  CALL put_field("CLWCON", "Eau liquide convective", clwcon)
236
237  CALL put_field("RNEBCON", "Nebulosite convective", rnebcon)
238
239  CALL put_field("RATQS", "Ratqs", ratqs)
240
241  ! run_off_lic_0
242
243  CALL put_field("RUNOFFLIC0", "Runofflic0", run_off_lic_0)
244
245  ! DEB TKE PBL !
246
247  IF (iflag_pbl>1) then
248    CALL put_field_srf3("TKE", "Energ. Cineti. Turb.", &
249         pbl_tke(:,:,:))
250    CALL put_field_srf3("DELTATKE", "Del TKE wk/env.", &
251         wake_delta_pbl_tke(:,:,:))
252  END IF
253
254  ! FIN TKE PBL !
255  !IM ajout zmax0, f0, sig1, w01
256  !IM wake_deltat, wake_deltaq, wake_s, wake_cstar, wake_pe, wake_fip
257
258  CALL put_field("ZMAX0", "ZMAX0", zmax0)
259
260  CALL put_field("F0", "F0", f0)
261
262  CALL put_field("sig1", "sig1 Emanuel", sig1)
263
264  CALL put_field("w01", "w01 Emanuel", w01)
265
266  ! wake_deltat
267  CALL put_field("WAKE_DELTAT", "WAKE_DELTAT", wake_deltat)
268
269  CALL put_field("WAKE_DELTAQ", "WAKE_DELTAQ", wake_deltaq)
270
271  CALL put_field("WAKE_S", "Wake frac. area", wake_s)
272
273  CALL put_field("WAKE_DENS", "Wake num. /unit area", wake_dens)
274
275  CALL put_field("WAKE_CSTAR", "WAKE_CSTAR", wake_cstar)
276
277  CALL put_field("WAKE_PE", "WAKE_PE", wake_pe)
278
279  CALL put_field("WAKE_FIP", "WAKE_FIP", wake_fip)
280
281  ! thermiques
282
283  CALL put_field("FM_THERM", "FM_THERM", fm_therm)
284
285  CALL put_field("ENTR_THERM", "ENTR_THERM", entr_therm)
286
287  CALL put_field("DETR_THERM", "DETR_THERM", detr_therm)
288
289  CALL put_field("ALE_BL", "ALE_BL", ale_bl)
290
291  CALL put_field("ALE_BL_TRIG", "ALE_BL_TRIG", ale_bl_trig)
292
293  CALL put_field("ALP_BL", "ALP_BL", alp_bl)
294
295  CALL put_field("ALE_WAKE", "ALE_WAKE", ale_wake)
296
297  CALL put_field("ALE_BL_STAT", "ALE_BL_STAT", ale_bl_stat)
298
299
300  ! trs from traclmdz_mod
301  IF (type_trac == 'lmdz') THEN
302     CALL traclmdz_to_restart(trs)
303     DO it=1, nbtr
304!!        iiq=niadv(it+2)                                                           ! jyg
305        iiq=niadv(it+nqo)                                                           ! jyg
306        CALL put_field("trs_"//tname(iiq), "", trs(:, it))
307     END DO
308     IF (carbon_cycle_cpl) THEN
309        IF (.NOT. ALLOCATED(co2_send)) THEN
310           ! This is the case of create_etat0_limit, ce0l
311           ALLOCATE(co2_send(klon))
312           co2_send(:) = co2_ppm0
313        END IF
314        CALL put_field("co2_send", "co2_ppm for coupling", co2_send)
315     END IF
316  END IF
317
318  ! Restart variables for Slab ocean
319  IF (type_ocean == 'slab') THEN
320      IF (nslay.EQ.1) THEN
321        CALL put_field("tslab", "Slab ocean temperature", tslab)
322      ELSE
323        DO it=1,nslay
324          WRITE(str2,'(i2.2)') it
325          CALL put_field("tslab"//str2, "Slab ocean temperature", tslab(:,it))
326        END DO
327      END IF
328      IF (version_ocean == 'sicINT') THEN
329          CALL put_field("seaice", "Slab seaice (kg/m2)", seaice)
330          CALL put_field("slab_tice", "Slab sea ice temperature", tice)
331      END IF
332  END IF
333
334  if (ok_gwd_rando) call put_field("du_gwd_rando", &
335       "tendency on zonal wind due to flott gravity waves", du_gwd_rando)
336
337  IF (.not. ok_hines .and. ok_gwd_rando) call put_field("du_gwd_front", &
338       "tendency on zonal wind due to acama gravity waves", du_gwd_front)
339
340  if (activate_ocean_skin >= 1) then
341     CALL put_field("ds_ns", "delta salinity near surface", ds_ns)
342     CALL put_field("dT_ns", "delta temperature near surface", dT_ns)
343  end if
344 
345  CALL close_restartphy
346  !$OMP BARRIER
347
348
349  CONTAINS
350
351
352SUBROUTINE put_field_srf1(nam,lnam,field)
353
354  IMPLICIT NONE
355  CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
356  REAL,              INTENT(IN) :: field(:,:)
357  CHARACTER(LEN=256) :: nm, lm, str
358  DO nsrf = 1, SIZE(field,2)
359    WRITE(str, '(i2.2)') nsrf
360    nm=TRIM(nam)//TRIM(str)
361    lm=TRIM(lnam)//" de surface No. "//TRIM(str)
362    CALL put_field(nm,lm,field(:,nsrf))
363  END DO
364
365END SUBROUTINE put_field_srf1
366
367
368SUBROUTINE put_field_srf2(nam,lnam,field)
369
370  IMPLICIT NONE
371  CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
372  REAL,              INTENT(IN) :: field(:,:,:)
373  CHARACTER(LEN=256) :: nm, lm, str
374  DO nsrf = 1, SIZE(field,3)
375    DO isoil=1, SIZE(field,2)
376      WRITE(str, '(i2.2,"srf",i2.2)')isoil,nsrf
377!      WRITE(lunout,*)"PHYREDEM ",TRIM(nam)//TRIM(str)
378      nm=TRIM(nam)//TRIM(str)
379      lm=TRIM(lnam)//" du sol No. "//TRIM(str)
380      CALL put_field(nm,lm,field(:,isoil,nsrf))
381    END DO
382  END DO
383
384END SUBROUTINE put_field_srf2
385
386
387SUBROUTINE put_field_srf3(nam,lnam,field)
388
389  IMPLICIT NONE
390  CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
391  REAL,              INTENT(IN) :: field(:,:,:)
392  CHARACTER(LEN=256) :: nm, lm, str
393  DO nsrf = 1, SIZE(field,3)
394    WRITE(str, '(i2.2)') nsrf
395    nm=TRIM(nam)//TRIM(str)
396    lm=TRIM(lnam)//TRIM(str)
397    CALL put_field(nm,lm,field(:,1:klev+1,nsrf))
398  END DO
399
400END SUBROUTINE put_field_srf3
401
402
403END SUBROUTINE phyredem
Note: See TracBrowser for help on using the repository browser.