source: LMDZ6/trunk/libf/phylmd/phyredem.F90 @ 5229

Last change on this file since 5229 was 5204, checked in by Laurent Fairhead, 8 weeks ago

Integrating A.Borella's work on cirrus in the trunk

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