source: LMDZ5/trunk/libf/phylmd/phyredem.F90 @ 2483

Last change on this file since 2483 was 2395, checked in by Ehouarn Millour, 9 years ago

Bug fix for aquaplanets: "rlat" and "rlon" were uninitialized when written to startphy.nc; phyredem should write "longitude_deg" and "latitude_deg" to the file. Overall "rlat" and "rlon" should not be used and "latitude_deg" and "longitude_deg" should be used instead in the physics. To be further cleaned up.
Some cleanup on that mater also made in phydev.
Note that this change will make bench test results different for longitudes and latitudes, because of roundoff effects.
EM

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