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

Last change on this file since 5425 was 4368, checked in by lguez, 2 years ago

Sync latest trunk changes to Ocean_skin

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