source: LMDZ6/branches/contrails/libf/phylmd/dyn1d/scm.f90 @ 5760

Last change on this file since 5760 was 5717, checked in by aborella, 4 weeks ago

Merge with trunk r5653

File size: 43.5 KB
Line 
1SUBROUTINE scm
2
3   USE flux_arp_mod_h
4   USE compbl_mod_h
5   USE clesphys_mod_h
6   USE ioipsl, only: ju2ymds, ymds2ju, ioconf_calendar,getin
7   USE phys_state_var_mod, ONLY : phys_state_var_init, phys_state_var_end, &
8       clwcon, detr_therm, &
9       qsol, fevap, z0m, z0h, agesno, &
10       frac_tersrf, z0m_tersrf, ratio_z0m_z0h_tersrf, &
11       albedo_tersrf, beta_tersrf, inertie_tersrf, &
12       alpha_soil_tersrf, period_tersrf, hcond_tersrf, &
13       tsurfi_tersrf, tsoili_tersrf, tsoil_depth, &
14       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
15       falb_dir, falb_dif, &
16       ftsol, beta_aridity, pbl_tke, pctsrf, radsol, rain_fall, snow_fall, ratqs, &
17       rnebcon, rugoro, sig1, w01, solaire_etat0, sollw, sollwdown, &
18       solsw, solswfdiff, t_ancien, q_ancien, u_ancien, v_ancien, &
19       wake_delta_pbl_TKE, delta_tsurf, wake_fip, wake_pe, &
20       wake_deltaq, wake_deltat, wake_s, awake_s, wake_dens, &
21       awake_dens, cv_gen, wake_cstar, &
22       zgam, zmax0, zmea, zpic, zsig, &
23       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, &
24       ql_ancien, qs_ancien, qbs_ancien, &
25       cf_ancien, qvc_ancien, qvcon, qccon, cfa_ancien, pcf_ancien, qva_ancien, qia_ancien, &
26       prlw_ancien, prsw_ancien, prbsw_ancien, prw_ancien, &
27       u10m,v10m,ale_wake,ale_bl_stat, ratqs_inter_
28
29
30   USE dimphy
31   USE surface_data, only : type_ocean,ok_veget
32   USE pbl_surface_mod, only : ftsoil, pbl_surface_init, &
33                                 pbl_surface_final
34   USE fonte_neige_mod, only : fonte_neige_init, fonte_neige_final
35
36   USE infotrac ! new
37   USE control_mod
38   USE indice_sol_mod
39   USE phyaqua_mod
40   USE mod_1D_cases_read_std
41   USE print_control_mod, ONLY: lunout, prt_level
42   USE iniphysiq_mod, ONLY: iniphysiq
43   USE mod_const_mpi, ONLY: comm_lmdz
44   USE physiq_mod, ONLY: physiq
45   USE comvert_mod, ONLY: presnivs, ap, bp, dpres,nivsig, nivsigs, pa, &
46                          preff, aps, bps, pseudoalt, scaleheight
47   USE temps_mod, ONLY: annee_ref, calend, day_end, day_ini, day_ref, &
48                        itau_dyn, itau_phy, start_time, year_len
49   USE phys_cal_mod, ONLY : year_len_phys_cal_mod => year_len
50   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_OUTPUTPHYSSCM
51
52   USE dimensions_mod, ONLY: iim, jjm, llm, ndm
53   USE dimsoil_mod_h, ONLY: nsoilmx
54   USE yomcst_mod_h
55   USE tsoilnudge_mod_h
56   USE fcg_gcssold_mod_h
57   USE compar1d_mod_h
58   USE date_cas_mod_h
59implicit none
60
61!=====================================================================
62! DECLARATIONS
63!=====================================================================
64
65!---------------------------------------------------------------------
66!  Externals
67!---------------------------------------------------------------------
68      external fq_sat
69      real fq_sat
70
71!---------------------------------------------------------------------
72!  Arguments d' initialisations de la physique (USER DEFINE)
73!---------------------------------------------------------------------
74
75      integer, parameter :: ngrid=1
76      real :: zcufi    = 1.
77      real :: zcvfi    = 1.
78      real :: fnday
79      real :: day, daytime
80      real :: day1
81      real :: heure
82      integer :: jour
83      integer :: mois
84      integer :: an
85 
86!---------------------------------------------------------------------
87!  Declarations related to forcing and initial profiles
88!---------------------------------------------------------------------
89
90        integer :: kmax = llm
91        integer llm700,nq1,nq2,iflag_1d_vert_adv
92        INTEGER, PARAMETER :: nlev_max=1000, nqmx=1000
93        real timestep, frac
94        real height(nlev_max),tttprof(nlev_max),qtprof(nlev_max)
95        real  uprof(nlev_max),vprof(nlev_max),e12prof(nlev_max)
96        real  ugprof(nlev_max),vgprof(nlev_max),wfls(nlev_max)
97        real  dqtdxls(nlev_max),dqtdyls(nlev_max)
98        real  dqtdtls(nlev_max),thlpcar(nlev_max)
99        real  qprof(nlev_max,nqmx)
100
101!        integer :: forcing_type
102        logical :: forcing_les     = .false.
103        logical :: forcing_armcu   = .false.
104        logical :: forcing_rico    = .false.
105        logical :: forcing_radconv = .false.
106        logical :: forcing_toga    = .false.
107        logical :: forcing_twpice  = .false.
108        logical :: forcing_amma    = .false.
109        logical :: forcing_dice    = .false.
110        logical :: forcing_gabls4  = .false.
111
112        logical :: forcing_GCM2SCM = .false.
113        logical :: forcing_GCSSold = .false.
114        logical :: forcing_sandu   = .false.
115        logical :: forcing_astex   = .false.
116        logical :: forcing_fire    = .false.
117        logical :: forcing_case    = .false.
118        logical :: forcing_case2   = .false.
119        logical :: forcing_SCM   = .false.
120
121!flag forcings
122        logical :: nudge_wind=.true.
123        logical :: nudge_thermo=.false.
124        logical :: cptadvw=.true.
125
126
127!=====================================================================
128! DECLARATIONS FOR EACH CASE
129!=====================================================================
130!
131      INCLUDE "1D_decl_cases.h"
132!
133!---------------------------------------------------------------------
134!  Declarations related to nudging
135!---------------------------------------------------------------------
136     integer :: nudge_max
137     parameter (nudge_max=9)
138     integer :: inudge_RHT=1
139     integer :: inudge_UV=2
140     logical :: nudge(nudge_max)
141     real :: t_targ(llm)
142     real :: rh_targ(llm)
143     real :: u_targ(llm)
144     real :: v_targ(llm)
145!
146!---------------------------------------------------------------------
147!  Declarations related to vertical discretization:
148!---------------------------------------------------------------------
149      real :: pzero=1.e5
150      real :: play (llm),zlay (llm),sig_s(llm),plev(llm+1)
151      real :: playd(llm),zlayd(llm),ap_amma(llm+1),bp_amma(llm+1)
152
153!---------------------------------------------------------------------
154!  Declarations related to variables
155!---------------------------------------------------------------------
156
157      real :: phi(llm)
158      real :: teta(llm),tetal(llm),temp(llm),u(llm),v(llm),w(llm)
159      REAL rot(1, llm) ! relative vorticity, in s-1
160      real :: rlat_rad(1),rlon_rad(1)
161      real :: omega(llm),omega2(llm),rho(llm+1)
162      real :: ug(llm),vg(llm),fcoriolis
163      real :: sfdt, cfdt
164      real :: du_phys(llm),dv_phys(llm),dt_phys(llm)
165      real :: w_adv(llm),z_adv(llm)
166      real :: d_t_vert_adv(llm),d_u_vert_adv(llm),d_v_vert_adv(llm)
167      real :: dt_cooling(llm),d_t_adv(llm),d_t_nudge(llm)
168      real :: d_u_nudge(llm),d_v_nudge(llm)
169      real :: d_u_age(llm),d_v_age(llm)
170      real :: alpha
171      real :: ttt
172
173      REAL, ALLOCATABLE, DIMENSION(:,:):: q
174      REAL, ALLOCATABLE, DIMENSION(:,:):: dq
175      REAL, ALLOCATABLE, DIMENSION(:,:):: d_q_vert_adv
176      REAL, ALLOCATABLE, DIMENSION(:,:):: d_q_adv
177      REAL, ALLOCATABLE, DIMENSION(:,:):: d_q_nudge
178
179!---------------------------------------------------------------------
180!  Initialization of surface variables
181!---------------------------------------------------------------------
182      real :: run_off_lic_0(1)
183      real :: fder(1),snsrf(1,nbsrf),qsurfsrf(1,nbsrf)
184      real :: tsoil(1,nsoilmx,nbsrf)
185      ! AM
186      REAL, ALLOCATABLE, DIMENSION(:,:) :: tsoil_ter_srf2 ! resized initial soil temperature on vertical levels (K)
187      REAL, ALLOCATABLE, DIMENSION(:,:) :: tsoil_depths2  ! resized soil depth at which inititial temperature is given (m)
188
189!---------------------------------------------------------------------
190!  Call to phyredem
191!---------------------------------------------------------------------
192      logical :: ok_writedem =.true.
193      real :: sollw_in = 0.
194      real :: solsw_in = 0.
195     
196!---------------------------------------------------------------------
197!  Call to physiq
198!---------------------------------------------------------------------
199      logical :: firstcall=.true.
200      logical :: lastcall=.false.
201      real :: phis(1)    = 0.0
202      real :: dpsrf(1)
203
204!---------------------------------------------------------------------
205!  Initializations of boundary conditions
206!---------------------------------------------------------------------
207      real, allocatable :: phy_nat (:)  ! 0=ocean libre,1=land,2=glacier,3=banquise
208      real, allocatable :: phy_alb (:)  ! Albedo land only (old value condsurf_jyg=0.3)
209      real, allocatable :: phy_sst (:)  ! SST (will not be used; cf read_tsurf1d.F)
210      real, allocatable :: phy_bil (:)  ! Ne sert que pour les slab_ocean
211      real, allocatable :: phy_rug (:) ! Longueur rugosite utilisee sur land only
212      real, allocatable :: phy_ice (:) ! Fraction de glace
213      real, allocatable :: phy_fter(:) ! Fraction de terre
214      real, allocatable :: phy_foce(:) ! Fraction de ocean
215      real, allocatable :: phy_fsic(:) ! Fraction de glace
216      real, allocatable :: phy_flic(:) ! Fraction de glace
217
218!---------------------------------------------------------------------
219!  Fichiers et d'autres variables
220!---------------------------------------------------------------------
221      integer :: k,l,i,it=1,mxcalc
222      integer :: nsrf
223      integer jcode
224      INTEGER read_climoz
225      integer :: it_end ! iteration number of the last call
226      integer ecrit_slab_oc !1=ecrit,-1=lit,0=no file
227      data ecrit_slab_oc/-1/
228
229!     if flag_inhib_forcing = 0, tendencies of forcing are added
230!                           <> 0, tendencies of forcing are not added
231      INTEGER :: flag_inhib_forcing = 0
232      CHARACTER(len=80) :: abort_message
233      CHARACTER(len=20) :: modname = 'scm'
234
235      print*,'VOUS ENTREZ DANS LE 1D FORMAT STANDARD'
236
237!=====================================================================
238! INITIALIZATIONS
239!=====================================================================
240      du_phys(:)=0.
241      dv_phys(:)=0.
242      dt_phys(:)=0.
243      d_t_vert_adv(:)=0.
244      d_u_vert_adv(:)=0.
245      d_v_vert_adv(:)=0.
246      dt_cooling(:)=0.
247      d_t_adv(:)=0.
248      d_t_nudge(:)=0.
249      d_u_nudge(:)=0.
250      d_v_nudge(:)=0.
251      d_u_adv(:)=0.
252      d_v_adv(:)=0.
253      d_u_age(:)=0.
254      d_v_age(:)=0.
255     
256     
257! Initialization of Common turb_forcing
258       dtime_frcg = 0.
259       Turb_fcg_gcssold=.false.
260       hthturb_gcssold = 0.
261       hqturb_gcssold = 0.
262
263
264
265
266!---------------------------------------------------------------------
267! OPTIONS OF THE 1D SIMULATION (lmdz1d.def => unicol.def)
268!---------------------------------------------------------------------
269        call conf_unicol
270!Al1 moves this gcssold var from common fcg_gcssold to
271        Turb_fcg_gcssold = xTurb_fcg_gcssold
272! --------------------------------------------------------------------
273        close(1)
274        write(*,*) 'lmdz1d.def lu => unicol.def'
275
276       forcing_SCM = .true.
277       year_ini_cas=1997
278       ! It is possible that those parameters are run twice.
279       ! A REVOIR : LIRE PEUT ETRE AN MOIS JOUR DIRECETEMENT
280
281
282       call getin('anneeref',year_ini_cas)
283       call getin('dayref',day_deb)
284       mth_ini_cas=1 ! pour le moment on compte depuis le debut de l'annee
285       call getin('time_ini',heure_ini_cas)
286      print*,'NATURE DE LA SURFACE ',nat_surf
287
288! Initialization of the logical switch for nudging
289
290     jcode = iflag_nudge
291     do i = 1,nudge_max
292       nudge(i) = mod(jcode,10) .ge. 1
293       jcode = jcode/10
294     enddo
295! numerical scheme for vertical advection
296
297     iflag_1d_vert_adv=1
298     call getin('iflag_1d_vert_adv',iflag_1d_vert_adv)
299
300!-----------------------------------------------------------------------
301!  Definition of the run
302!-----------------------------------------------------------------------
303
304      call conf_gcm( 99, .TRUE. )
305     
306!-----------------------------------------------------------------------
307      allocate( phy_nat (year_len))  ! 0=ocean libre,1=land,2=glacier,3=banquise
308      phy_nat(:)=0.0
309      allocate( phy_alb (year_len))  ! Albedo land only (old value condsurf_jyg=0.3)
310      allocate( phy_sst (year_len))  ! SST (will not be used; cf read_tsurf1d.F)
311      allocate( phy_bil (year_len))  ! Ne sert que pour les slab_ocean
312      phy_bil(:)=1.0
313      allocate( phy_rug (year_len)) ! Longueur rugosite utilisee sur land only
314      allocate( phy_ice (year_len)) ! Fraction de glace
315      phy_ice(:)=0.0
316      allocate( phy_fter(year_len)) ! Fraction de terre
317      phy_fter(:)=0.0
318      allocate( phy_foce(year_len)) ! Fraction de ocean
319      phy_foce(:)=0.0
320      allocate( phy_fsic(year_len)) ! Fraction de glace
321      phy_fsic(:)=0.0
322      allocate( phy_flic(year_len)) ! Fraction de glace
323      phy_flic(:)=0.0
324
325
326!-----------------------------------------------------------------------
327!   Choix du calendrier
328!   -------------------
329
330!      calend = 'earth_365d'
331      if (calend == 'earth_360d') then
332        call ioconf_calendar('360_day')
333        write(*,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
334      else if (calend == 'earth_365d') then
335        call ioconf_calendar('noleap')
336        write(*,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
337      else if (calend == 'earth_366d') then
338        call ioconf_calendar('all_leap')
339        write(*,*)'CALENDRIER CHOISI: Terrestre bissextile'
340      else if (calend == 'gregorian') then
341        stop 'gregorian calend should not be used by normal user'
342        call ioconf_calendar('gregorian') ! not to be used by normal users
343        write(*,*)'CALENDRIER CHOISI: Gregorien'
344      else
345        write (*,*) 'ERROR : unknown calendar ', calend
346        stop 'calend should be 360d,earth_365d,earth_366d,gregorian'
347      endif
348!-----------------------------------------------------------------------
349!
350!c Date :
351!      La date est supposee donnee sous la forme [annee, numero du jour dans
352!      l annee] ; l heure est donnee dans time_ini, lu dans lmdz1d.def.
353!      On appelle ymds2ju pour convertir [annee, jour] en [jour Julien].
354!      Le numero du jour est dans "day". L heure est traitee separement.
355!      La date complete est dans "daytime" (l'unite est le jour).
356
357
358      if (nday>0) then
359         fnday=nday
360      else
361         fnday=-nday/float(day_step)
362      endif
363      print *,'fnday=',fnday
364!     start_time doit etre en FRACTION DE JOUR
365      start_time=time_ini/24.
366
367      annee_ref = anneeref
368      mois = 1
369      day_ref = dayref
370      heure = 0.
371      itau_dyn = 0
372      itau_phy = 0
373      call ymds2ju(annee_ref,mois,day_ref,heure,day)
374      day_ini = int(day)
375      day_end = day_ini + int(fnday)
376
377! Convert the initial date to Julian day
378      day_ini_cas=day_deb
379      print*,'time case',year_ini_cas,mth_ini_cas,day_ini_cas
380      call ymds2ju                                                         &
381     & (year_ini_cas,mth_ini_cas,day_ini_cas,heure_ini_cas*3600            &
382     & ,day_ju_ini_cas)
383      print*,'time case 2',day_ini_cas,day_ju_ini_cas
384      daytime = day + heure_ini_cas/24. ! 1st day and initial time of the simulation
385
386! Print out the actual date of the beginning of the simulation :
387      call ju2ymds(daytime,year_print, month_print,day_print,sec_print)
388      print *,' Time of beginning : ',                                      &
389     &        year_print, month_print, day_print, sec_print
390
391!---------------------------------------------------------------------
392! Initialization of dimensions, geometry and initial state
393!---------------------------------------------------------------------
394!     call init_phys_lmdz(1,1,llm,1,(/1/)) ! job now done via iniphysiq
395!     but we still need to initialize dimphy module (klon,klev,etc.)  here.
396      call init_dimphy1D(1,llm,nb_ter_srf,nb_tsoil_depths)
397      call suphel
398      call init_infotrac
399
400      if (nqtot>nqmx) STOP 'Augmenter nqmx dans lmdz1d.F'
401      allocate(q(llm,nqtot)) ; q(:,:)=0.
402      allocate(dq(llm,nqtot))
403      allocate(d_q_vert_adv(llm,nqtot))
404      allocate(d_q_adv(llm,nqtot))
405      allocate(d_q_nudge(llm,nqtot))
406
407      q(:,:) = 0.
408      dq(:,:) = 0.
409      d_q_vert_adv(:,:) = 0.
410      d_q_adv(:,:) = 0.
411      d_q_nudge(:,:) = 0.
412
413!   No ozone climatology need be read in this pre-initialization
414!          (phys_state_var_init is called again in physiq)
415      read_climoz = 0
416      nsw=6
417
418      call phys_state_var_init(read_climoz)
419
420      if (ngrid.ne.klon) then
421         print*,'stop in inifis'
422         print*,'Probleme de dimensions :'
423         print*,'ngrid = ',ngrid
424         print*,'klon  = ',klon
425         stop
426      endif
427!!!=====================================================================
428!!! Feedback forcing values for Gateaux differentiation (al1)
429!!!=====================================================================
430     
431      qsol = qsolinp
432      qsurf = fq_sat(tsurf,psurf/100.)
433      beta_aridity(:,:) = beta_surf
434      day1= day_ini
435      time=daytime-day
436      ts_toga(1)=tsurf ! needed by read_tsurf1d.F
437      rho(1)=psurf/(rd*tsurf*(1.+(rv/rd-1.)*qsurf))
438
439!! mpl et jyg le 22/08/2012 :
440!!  pour que les cas a flux de surface imposes marchent
441      IF(.NOT.ok_flux_surf.or.max(abs(wtsurf),abs(wqsurf))>0.) THEN
442       fsens=-wtsurf*rcpd*rho(1)
443       flat=-wqsurf*rlvtt*rho(1)
444       print *,'Flux: ok_flux wtsurf wqsurf',ok_flux_surf,wtsurf,wqsurf
445      ENDIF
446      print*,'Flux sol ',fsens,flat
447
448! Vertical discretization and pressure levels at half and mid levels:
449
450      pa   = 5e4
451!!      preff= 1.01325e5
452      preff = psurf
453      IF (ok_old_disvert) THEN
454        call disvert0(pa,preff,ap,bp,dpres,presnivs,nivsigs,nivsig)
455        print *,'On utilise disvert0'
456        aps(1:llm)=0.5*(ap(1:llm)+ap(2:llm+1))
457        bps(1:llm)=0.5*(bp(1:llm)+bp(2:llm+1))
458        scaleheight=8.
459        pseudoalt(1:llm)=-scaleheight*log(presnivs(1:llm)/preff)
460      ELSE
461        call disvert()
462        print *,'On utilise disvert'
463!       Nouvelle version disvert permettant d imposer ap,bp (modif L.Guez) MPL 18092012
464!       Dans ce cas, on lit ap,bp dans le fichier hybrid.txt
465      ENDIF
466
467      sig_s=presnivs/preff
468      plev =ap+bp*psurf
469      play = 0.5*(plev(1:llm)+plev(2:llm+1))
470      zlay=-rd*300.*log(play/psurf)/rg ! moved after reading profiles.
471
472      IF (forcing_type .eq. 59) THEN
473! pour forcing_sandu, on cherche l'indice le plus proche de 700hpa#3000m
474      write(*,*) '***********************'
475      do l = 1, llm
476       write(*,*) 'l,play(l),presnivs(l): ',l,play(l),presnivs(l)
477       if (trouve_700 .and. play(l).le.70000) then
478         llm700=l
479         print *,'llm700,play=',llm700,play(l)/100.
480         trouve_700= .false.
481       endif
482      enddo
483      write(*,*) '***********************'
484      ENDIF
485
486!
487!=====================================================================
488! EVENTUALLY, READ FORCING DATA :
489!=====================================================================
490
491      INCLUDE "1D_read_forc_cases.h"
492
493      if (forcing_GCM2SCM) then
494        write (*,*) 'forcing_GCM2SCM not yet implemented'
495        stop 'in initialization'
496      endif ! forcing_GCM2SCM
497
498
499!=====================================================================
500! Initialisation de la physique :
501!=====================================================================
502
503!  Rq: conf_phys.F90 lit tous les flags de physiq.def; conf_phys appele depuis physiq.F
504!
505! day_step, iphysiq lus dans gcm.def ci-dessus
506! timestep: calcule ci-dessous from rday et day_step
507! ngrid=1
508! llm: defini dans .../modipsl/modeles/LMDZ4/libf/grid/dimension
509! rday: defini dans suphel.F (86400.)
510! day_ini: lu dans run.def (dayref)
511! rlat_rad,rlon-rad: transformes en radian de rlat,rlon lus dans lmdz1d.def (en degres)
512! airefi,zcufi,zcvfi initialises au debut de ce programme
513! rday,ra,rg,rd,rcpd declares dans YOMCST.h et calcules dans suphel.F
514
515
516      day_step = float(nsplit_phys)*day_step/float(iphysiq)
517      write (*,*) 'Time step divided by nsplit_phys (=',nsplit_phys,')'
518      timestep =rday/day_step
519      dtime_frcg = timestep
520!
521      zcufi=airefi
522      zcvfi=airefi
523!
524      rlat_rad(1)=xlat*rpi/180.
525      rlon_rad(1)=xlon*rpi/180.
526
527     ! iniphysiq will call iniaqua who needs year_len from phys_cal_mod
528     year_len_phys_cal_mod=year_len
529           
530     ! Ehouarn: iniphysiq requires arrays related to (3D) dynamics grid,
531     ! e.g. for cell boundaries, which are meaningless in 1D; so pad these
532     ! with '0.' when necessary
533
534      call iniphysiq(iim,jjm,llm, &
535           1,comm_lmdz, &
536           rday,day_ini,timestep,  &
537           (/rlat_rad(1),0./),(/0./), &
538           (/0.,0./),(/rlon_rad(1),0./),  &
539           (/ (/airefi,0./),(/0.,0./) /), &
540           (/zcufi,0.,0.,0./), &
541           (/zcvfi,0./), &
542           ra,rg,rd,rcpd,1)
543      print*,'apres iniphysiq'
544
545! 2 PARAMETRES QUI DEVRAIENT ETRE LUS DANS run.def MAIS NE LE SONT PAS ICI:
546      co2_ppm= 330.0
547      solaire=1370.0
548
549! Ecriture du startphy avant le premier appel a la physique.
550! On le met juste avant pour avoir acces a tous les champs
551
552      if (ok_writedem) then
553
554!--------------------------------------------------------------------------
555! pbl_surface_init (called here) and pbl_surface_final (called by phyredem)
556! need : qsol fder snow qsurf evap rugos agesno ftsoil
557!--------------------------------------------------------------------------
558
559        type_ocean = "force"
560        run_off_lic_0(1) = restart_runoff
561        call fonte_neige_init(run_off_lic_0)
562
563        fder=0.
564        snsrf(1,:)=snowmass ! masse de neige des sous surface
565        qsurfsrf(1,:)=qsurf ! humidite de l'air des sous surface
566        fevap=0.
567        z0m(1,:)=rugos     ! couverture de neige des sous surface
568        z0h(1,:)=rugosh    ! couverture de neige des sous surface
569        agesno  = xagesno
570        tsoil(:,:,:)=tsurf
571
572        iflag_hetero_surf = 0
573        CALL getin('iflag_hetero_surf',iflag_hetero_surf)
574
575        IF (iflag_hetero_surf .GT. 0) THEN
576          PRINT*, 'scm iflag_hetero_surf', iflag_hetero_surf
577          IF ((nbtersrf .LT. 2) .OR. (nbtersrf .GT. max_nbtersrf)) THEN
578            abort_message='The number of continental sub-surfaces (nb_ter_srf) must be between 2 and 5'
579            CALL abort_physic(modname,abort_message,1)
580          ENDIF
581          ! resized initial soil temperature on vertical levels and soil depth at which inititial temperature is given
582          ALLOCATE(tsoil_ter_srf2(nbtsoildepths,nbtersrf))
583          ALLOCATE(tsoil_depths2(nbtsoildepths,nbtersrf))
584          tsoil_ter_srf2(:,:) = 0.
585          tsoil_depths2(:,:) = 0.
586          DO i=1, nbtersrf
587            DO l=1, nbtsoildepths
588              k = nbtsoildepths*(i-1)+l
589              tsoil_ter_srf2(l,i) = tsoil_ter_srf(k)
590              tsoil_depths2(l,i) = tsoil_depths(k)
591            ENDDO
592          ENDDO
593          !
594          DO i=1, nbtersrf
595            frac_tersrf(:,i) = frac_ter_srf(i)                   ! fraction of land surface heterogeneity (-)
596            z0m_tersrf(:,i) = rugos_ter_srf(i)                   ! roughness length for momentum of land sub-surfaces (m)
597            ratio_z0m_z0h_tersrf(:,i) = ratio_z0m_z0h_ter_srf(i) ! ratio of heat to momentum roughness length of land sub-surfaces (-)
598            albedo_tersrf(:,i) = albedo_ter_srf(i)               ! albedo of land sub-surfaces (-)
599            beta_tersrf(:,i) = beta_ter_srf(i)                   ! evapotranspiration coef of land sub-surfaces (-)
600            inertie_tersrf(:,i) = inertie_ter_srf(i)             ! soil thermal inertia of land sub-surfaces (J/m2/K/s1/2)
601            hcond_tersrf(:,i) = hcond_ter_srf(i)                 ! soil heat conductivity (W/(m.K))
602            tsurfi_tersrf(:,i) = tsurf_ter_srf(i)                ! initial surface temperature (K)
603            DO l=1, nbtsoildepths
604              tsoili_tersrf(:,l,i) = tsoil_ter_srf2(l,i)         ! initial soil temperature on vertical levels (K)
605              tsoil_depth(:,l,i) = tsoil_depths2(l,i)
606            ENDDO
607          ENDDO
608          alpha_soil_tersrf = alpha_soil_ter_srf               ! ratio between the thicknesses of 2 successive layers (-)
609          period_tersrf = period_ter_srf                       ! temperature oscillation amplitude period
610          !
611          DEALLOCATE(tsoil_ter_srf2)
612          DEALLOCATE(tsoil_depths2)
613        ENDIF
614
615!-----------------------------------------------------------------------
616        call pbl_surface_init(fder, snsrf, qsurfsrf, tsoil)
617
618!------------------ prepare limit conditions for limit.nc -----------------
619!--   Ocean force
620
621        print*,'avant phyredem'
622        pctsrf(1,:)=0.
623          if (nat_surf.eq.0.) then
624          pctsrf(1,is_oce)=1.
625          pctsrf(1,is_ter)=0.
626          pctsrf(1,is_lic)=0.
627          pctsrf(1,is_sic)=0.
628        else if (nat_surf .eq. 1) then
629          pctsrf(1,is_oce)=0.
630          pctsrf(1,is_ter)=1.
631          pctsrf(1,is_lic)=0.
632          pctsrf(1,is_sic)=0.
633        else if (nat_surf .eq. 2) then
634          pctsrf(1,is_oce)=0.
635          pctsrf(1,is_ter)=0.
636          pctsrf(1,is_lic)=1.
637          pctsrf(1,is_sic)=0.
638        else if (nat_surf .eq. 3) then
639          pctsrf(1,is_oce)=0.
640          pctsrf(1,is_ter)=0.
641          pctsrf(1,is_lic)=0.
642          pctsrf(1,is_sic)=1.
643
644     end if
645
646
647        print*,'nat_surf,pctsrf(1,is_oce),pctsrf(1,is_ter)',nat_surf         &
648     &        ,pctsrf(1,is_oce),pctsrf(1,is_ter)
649
650        zmasq=pctsrf(1,is_ter)+pctsrf(1,is_lic)
651        zpic = zpicinp
652        ftsol=tsurf
653        falb_dir=albedo
654        falb_dif=albedo
655        rugoro=rugos
656        t_ancien(1,:)=temp(:)
657        q_ancien(1,:)=q(:,1)
658        ql_ancien = 0.
659        qs_ancien = 0.
660        prlw_ancien = 0.
661        prsw_ancien = 0.
662        prw_ancien = 0.
663        IF ( ok_bs ) THEN
664           qbs_ancien = 0.
665           prbsw_ancien = 0.
666        ENDIF
667        IF ( ok_ice_supersat ) THEN
668          cf_ancien = 0.
669          qvc_ancien = 0.
670          qvcon = 0.
671          qccon = 0.
672        ENDIF
673        IF ( ok_plane_contrail ) THEN
674          cfa_ancien = 0.
675          pcf_ancien = 0.
676          qva_ancien = 0.
677          qia_ancien = 0.
678        ENDIF
679        rain_fall=0.
680        snow_fall=0.
681        solsw=0.
682        solswfdiff=0.
683        sollw=0.
684        sollwdown=rsigma*tsurf**4
685        radsol=0.
686        rnebcon=0.
687        ratqs=0.
688        clwcon=0.
689        zmax0 = 0.
690        zmea=zsurf
691        zstd=0.
692        zsig=0.
693        zgam=0.
694        zval=0.
695        zthe=0.
696        sig1=0.
697        w01=0.
698!
699        wake_deltaq = 0.
700        wake_deltat = 0.
701        wake_delta_pbl_TKE(:,:,:) = 0.
702        delta_tsurf = 0.
703        wake_fip = 0.
704        wake_pe = 0.
705        wake_s = 0.
706        awake_s = 0.
707        wake_dens = 0.
708        awake_dens = 0.
709        cv_gen = 0.
710        wake_cstar = 0.
711        ale_bl = 0.
712        ale_bl_trig = 0.
713        alp_bl = 0.
714        IF (ALLOCATED(du_gwd_rando)) du_gwd_rando = 0.
715        IF (ALLOCATED(du_gwd_front)) du_gwd_front = 0.
716        entr_therm = 0.
717        detr_therm = 0.
718        f0 = 0.
719        fm_therm = 0.
720        u_ancien(1,:)=u(:)
721        v_ancien(1,:)=v(:)
722 
723        u10m=0.
724        v10m=0.
725        ale_wake=0.
726        ale_bl_stat=0.
727        ratqs_inter_(:,:)= 0.002
728
729!------------------------------------------------------------------------
730! Make file containing restart for the physics (startphy.nc)
731!
732! NB: List of the variables to be written by phyredem (via put_field):
733! rlon,rlat,zmasq,pctsrf(:,is_ter),pctsrf(:,is_lic),pctsrf(:,is_oce)
734! pctsrf(:,is_sic),ftsol(:,nsrf),tsoil(:,isoil,nsrf),qsurf(:,nsrf)
735! qsol,falb_dir(:,nsrf),falb_dif(:,nsrf),evap(:,nsrf),snow(:,nsrf)
736! radsol,solsw,solswfdiff,sollw, sollwdown,fder,rain_fall,snow_fall,frugs(:,nsrf)
737! agesno(:,nsrf),zmea,zstd,zsig,zgam,zthe,zpic,zval,rugoro
738! t_ancien,q_ancien,,frugs(:,is_oce),clwcon(:,1),rnebcon(:,1),ratqs(:,1)
739! run_off_lic_0,pbl_tke(:,1:klev,nsrf), zmax0,f0,sig1,w01
740! wake_deltat,wake_deltaq,wake_s,awake_s,wake_dens,awake_dens,cv_gen,wake_cstar,
741! wake_fip,wake_delta_pbl_tke(:,1:klev,nsrf)
742!
743! NB2: The content of the startphy.nc file depends on some flags defined in
744! the ".def" files. However, since conf_phys is not called in lmdz1d.F90, these flags have
745! to be set at some arbitratry convenient values.
746!------------------------------------------------------------------------
747!Al1 =============== restart option ======================================
748        iflag_physiq=0
749        call getin('iflag_physiq',iflag_physiq)
750
751        if (.not.restart) then
752          iflag_pbl = 5
753          call phyredem ("startphy.nc")
754        else
755! (desallocations)
756        print*,'callin surf final'
757          call pbl_surface_final( fder, snsrf, qsurfsrf, tsoil)
758        print*,'after surf final'
759          CALL fonte_neige_final(run_off_lic_0)
760        endif
761
762        ok_writedem=.false.
763        print*,'apres phyredem'
764
765      endif ! ok_writedem
766     
767!------------------------------------------------------------------------
768! Make file containing boundary conditions (limit.nc) **Al1->restartdyn***
769! --------------------------------------------------
770! NB: List of the variables to be written in limit.nc
771!     (by writelim.F, subroutine of 1DUTILS.h):
772!        phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
773!        phy_fter,phy_foce,phy_flic,phy_fsic)
774!------------------------------------------------------------------------
775      do i=1,year_len
776        phy_nat(i)  = nat_surf
777        phy_alb(i)  = albedo
778        phy_sst(i)  = tsurf ! read_tsurf1d will be used instead
779        phy_rug(i)  = rugos
780        phy_fter(i) = pctsrf(1,is_ter)
781        phy_foce(i) = pctsrf(1,is_oce)
782        phy_fsic(i) = pctsrf(1,is_sic)
783        phy_flic(i) = pctsrf(1,is_lic)
784      enddo
785
786! fabrication de limit.nc
787      call writelim (1,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,             &
788     &               phy_ice,phy_fter,phy_foce,phy_flic,phy_fsic)
789
790
791      call phys_state_var_end
792      if (restart) then
793        print*,'call to restart dyn 1d'
794        Call dyn1deta0("start1dyn.nc",plev,play,phi,phis,presnivs,          &
795     &              u,v,temp,q,omega2)
796
797       print*,'fnday,annee_ref,day_ref,day_ini',                            &
798     &     fnday,annee_ref,day_ref,day_ini
799       day = day_ini
800       day_end = day_ini + nday
801       daytime = day + time_ini/24. ! 1st day and initial time of the simulation
802
803! Print out the actual date of the beginning of the simulation :
804       call ju2ymds(daytime, an, mois, jour, heure)
805       print *,' Time of beginning : y m d h',an, mois,jour,heure/3600.
806
807       day = int(daytime)
808       time=daytime-day
809 
810       print*,'****** intialised fields from restart1dyn *******'
811       print*,'plev,play,phi,phis,presnivs,u,v,temp,q,omega2'
812       print*,'temp(1),q(1,1),u(1),v(1),plev(1),phis :'
813       print*,temp(1),q(1,1),u(1),v(1),plev(1),phis(1)
814! raz for safety
815       do l=1,llm
816         d_q_vert_adv(l,:) = 0.
817       enddo
818      endif
819!======================  end restart =================================
820      IF (ecrit_slab_oc.eq.1) then
821         open(97,file='div_slab.dat',STATUS='UNKNOWN')
822       elseif (ecrit_slab_oc.eq.0) then
823         open(97,file='div_slab.dat',STATUS='OLD')
824       endif
825!
826!=====================================================================
827IF (CPPKEY_OUTPUTPHYSSCM) THEN
828       CALL iophys_ini(timestep)
829END IF
830
831!=====================================================================
832! START OF THE TEMPORAL LOOP :
833!=====================================================================
834           
835      it_end = nint(fnday*day_step)
836      do while(it.le.it_end)
837
838       if (prt_level.ge.1) then
839         print*,'XXXXXXXXXXXXXXXXXXX ITAP,day,time=',                       &
840     &             it,day,time,it_end,day_step
841         print*,'PAS DE TEMPS ',timestep
842       endif
843       if (it.eq.it_end) lastcall=.True.
844
845!---------------------------------------------------------------------
846! Interpolation of forcings in time and onto model levels
847!---------------------------------------------------------------------
848
849      INCLUDE "1D_interp_cases.h"
850
851!---------------------------------------------------------------------
852!  Geopotential :
853!---------------------------------------------------------------------
854        phis(1)=zsurf*RG
855
856        ! Calculate geopotential from the ground surface since phi and phis are added in physiq_mod
857        phi(1)=RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
858
859        do l = 1, llm-1
860          phi(l+1)=phi(l)+RD*(temp(l)+temp(l+1))*                           &
861     &    (play(l)-play(l+1))/(play(l)+play(l+1))
862        enddo
863
864!---------------------------------------------------------------------
865!  Vertical advection
866!---------------------------------------------------------------------
867
868   IF ( forc_w+forc_omega > 0 ) THEN
869
870      IF ( forc_w == 1 ) THEN
871         w_adv=w_mod_cas
872         z_adv=phi/RG
873      ELSE
874         w_adv=omega
875         z_adv=play
876      ENDIF
877     
878      ! calculation of potential temperature for the advection
879      teta=temp*(pzero/play)**rkappa
880
881      ! vertical tendencies computed as d X / d t = -W  d X / d z
882
883      IF (iflag_1d_vert_adv .EQ. 0) THEN
884
885      ! old centered numerical scheme
886      do l=2,llm-1
887        d_u_vert_adv(l)=-w_adv(l)*(u(l+1)-u(l-1))/(z_adv(l+1)-z_adv(l-1))
888        d_v_vert_adv(l)=-w_adv(l)*(v(l+1)-v(l-1))/(z_adv(l+1)-z_adv(l-1))
889        ! d theta / dt = -W d theta / d z, transformed into d temp / d t dividing by (pzero/play(l))**rkappa
890        d_t_vert_adv(l)=-w_adv(l)*(teta(l+1)-teta(l-1))/(z_adv(l+1)-z_adv(l-1)) / (pzero/play(l))**rkappa
891        d_q_vert_adv(l,:)=-w_adv(l)*(q(l+1,:)-q(l-1,:))/(z_adv(l+1)-z_adv(l-1))
892      enddo
893
894
895      ELSE IF (iflag_1d_vert_adv .EQ. 1) THEN
896      ! upstream numerical scheme
897
898      do l=2,llm-1
899        IF ( ( ( forc_w .EQ. 1 ) .AND. ( w_adv(l) .GT. 0. ) ) .OR. &
900             ( ( forc_w .NE. 1 ) .AND. ( w_adv(l) .LT. 0. ) ) ) THEN
901          d_u_vert_adv(l)=-w_adv(l)*(u(l)-u(l-1))/(z_adv(l)-z_adv(l-1))
902          d_v_vert_adv(l)=-w_adv(l)*(v(l)-v(l-1))/(z_adv(l)-z_adv(l-1))
903          ! d theta / dt = -W d theta / d z, transformed into d temp / d t dividing by (pzero/play(l))**rkappa
904          d_t_vert_adv(l)=-w_adv(l)*(teta(l)-teta(l-1))/(z_adv(l)-z_adv(l-1)) / (pzero/play(l))**rkappa
905          d_q_vert_adv(l,:)=-w_adv(l)*(q(l,:)-q(l-1,:))/(z_adv(l)-z_adv(l-1))
906        ELSE
907          d_u_vert_adv(l)=-w_adv(l)*(u(l+1)-u(l))/(z_adv(l+1)-z_adv(l))
908          d_v_vert_adv(l)=-w_adv(l)*(v(l+1)-v(l))/(z_adv(l+1)-z_adv(l))
909          ! d theta / dt = -W d theta / d z, transformed into d temp / d t dividing by (pzero/play(l))**rkappa
910          d_t_vert_adv(l)=-w_adv(l)*(teta(l+1)-teta(l))/(z_adv(l+1)-z_adv(l)) / (pzero/play(l))**rkappa
911          d_q_vert_adv(l,:)=-w_adv(l)*(q(l+1,:)-q(l,:))/(z_adv(l+1)-z_adv(l))
912        ENDIF
913      enddo
914
915
916      ENDIF ! numerical scheme for vertical advection
917     
918     
919      IF (flag_inhib_forcing == 0) then ! if tendency of forcings should be added
920          u(1:mxcalc)=u(1:mxcalc) + timestep * d_u_vert_adv(1:mxcalc)
921          v(1:mxcalc)=v(1:mxcalc) + timestep * d_v_vert_adv(1:mxcalc)
922          q(1:mxcalc,:)=q(1:mxcalc,:) + timestep * d_q_vert_adv(1:mxcalc,:)
923          temp(1:mxcalc)=temp(1:mxcalc) + timestep * d_t_vert_adv(1:mxcalc)
924          teta=temp*(pzero/play)**rkappa
925      ENDIF
926   
927   ENDIF
928
929!---------------------------------------------------------------------
930! Listing output for debug prt_level>=1
931!---------------------------------------------------------------------
932       if (prt_level>=1) then
933         print *,' avant physiq : -------- day time ',day,time
934         write(*,*) 'firstcall,lastcall,phis',                               &
935     &               firstcall,lastcall,phis
936       end if
937       if (prt_level>=5) then
938         write(*,'(a10,2a4,4a13)') 'BEFOR1 IT=','it','l',                   &
939     &        'presniv','plev','play','phi'
940         write(*,'(a10,2i4,4f13.2)') ('BEFOR1 IT= ',it,l,                   &
941     &         presnivs(l),plev(l),play(l),phi(l),l=1,llm)
942         write(*,'(a11,2a4,a11,6a8)') 'BEFOR2','it','l',                    &
943     &         'presniv','u','v','temp','q1','q2','omega2'
944         write(*,'(a11,2i4,f11.2,5f8.2,e10.2)') ('BEFOR2 IT= ',it,l,         &
945     &   presnivs(l),u(l),v(l),temp(l),q(l,1),q(l,2),omega2(l),l=1,llm)
946       endif
947
948!---------------------------------------------------------------------
949!   Call physiq :
950!---------------------------------------------------------------------
951       call physiq(ngrid,llm, &
952                    firstcall,lastcall,timestep, &
953                    plev,play,phi,phis,presnivs, &
954                    u,v, rot, temp,q,omega2, &
955                    du_phys,dv_phys,dt_phys,dq,dpsrf)
956                firstcall=.false.
957
958!---------------------------------------------------------------------
959! Listing output for debug
960!---------------------------------------------------------------------
961        if (prt_level>=5) then
962          write(*,'(a11,2a4,4a13)') 'AFTER1 IT=','it','l',                  &
963     &        'presniv','plev','play','phi'
964          write(*,'(a11,2i4,4f13.2)') ('AFTER1 it= ',it,l,                  &
965     &    presnivs(l),plev(l),play(l),phi(l),l=1,llm)
966          write(*,'(a11,2a4,a11,6a8)') 'AFTER2','it','l',                   &
967     &         'presniv','u','v','temp','q1','q2','omega2'
968          write(*,'(a11,2i4,f11.2,5f8.2,e10.2)') ('AFTER2 it= ',it,l,       &
969     &    presnivs(l),u(l),v(l),temp(l),q(l,1),q(l,2),omega2(l),l=1,llm)
970          write(*,'(a11,2a4,a11,5a8)') 'AFTER3','it','l',                   &
971     &         'presniv','du_phys','dv_phys','dt_phys','dq1','dq2'   
972           write(*,'(a11,2i4,f11.2,5f8.2)') ('AFTER3 it= ',it,l,            &
973     &      presnivs(l),86400*du_phys(l),86400*dv_phys(l),                   &
974     &       86400*dt_phys(l),86400*dq(l,1),dq(l,2),l=1,llm)
975          write(*,*) 'dpsrf',dpsrf
976        endif
977!---------------------------------------------------------------------
978!   Add physical tendencies :
979!---------------------------------------------------------------------
980
981       fcoriolis=2.*sin(rpi*xlat/180.)*romega
982
983      IF (prt_level >= 5) print*, 'fcoriolis, xlat,mxcalc ', &
984                                   fcoriolis, xlat,mxcalc
985
986!---------------------------------------------------------------------
987! Geostrophic forcing
988!---------------------------------------------------------------------
989
990      IF ( forc_geo == 0 ) THEN
991              d_u_age(1:mxcalc)=0.
992              d_v_age(1:mxcalc)=0.
993      ELSE
994       sfdt = sin(0.5*fcoriolis*timestep)
995       cfdt = cos(0.5*fcoriolis*timestep)
996
997        d_u_age(1:mxcalc)= -2.*sfdt/timestep*                                &
998     &          (sfdt*(u(1:mxcalc)-ug(1:mxcalc)) -                          &
999     &           cfdt*(v(1:mxcalc)-vg(1:mxcalc))  )
1000!!     : fcoriolis*(v(1:mxcalc)-vg(1:mxcalc))
1001!
1002       d_v_age(1:mxcalc)= -2.*sfdt/timestep*                                 &
1003     &          (cfdt*(u(1:mxcalc)-ug(1:mxcalc)) +                           &
1004     &           sfdt*(v(1:mxcalc)-vg(1:mxcalc))  )
1005!!     : -fcoriolis*(u(1:mxcalc)-ug(1:mxcalc))
1006      ENDIF
1007!
1008!---------------------------------------------------------------------
1009!  Nudging
1010!---------------------------------------------------------------------
1011      d_t_nudge(:) = 0.
1012      d_u_nudge(:) = 0.
1013      d_v_nudge(:) = 0.
1014      d_q_nudge(:,:) = 0.
1015
1016      DO l=1,llm
1017
1018         IF (nudging_u .LT. 0) THEN
1019             
1020             d_u_nudge(l)=(u_nudg_mod_cas(l)-u(l))*invtau_u_nudg_mod_cas(l)
1021       
1022         ELSE
1023
1024             IF ( play(l) < p_nudging_u .AND. nint(nudging_u) /= 0 ) &
1025             & d_u_nudge(l)=(u_nudg_mod_cas(l)-u(l))/nudging_u
1026
1027         ENDIF
1028
1029
1030         IF (nudging_v .LT. 0) THEN
1031             
1032             d_v_nudge(l)=(v_nudg_mod_cas(l)-v(l))*invtau_v_nudg_mod_cas(l)
1033       
1034         ELSE
1035
1036
1037             IF ( play(l) < p_nudging_v .AND. nint(nudging_v) /= 0 ) &
1038             & d_v_nudge(l)=(v_nudg_mod_cas(l)-v(l))/nudging_v
1039
1040         ENDIF
1041
1042
1043         IF (nudging_t .LT. 0) THEN
1044             
1045             d_t_nudge(l)=(temp_nudg_mod_cas(l)-temp(l))*invtau_temp_nudg_mod_cas(l)
1046       
1047         ELSE
1048
1049
1050             IF ( play(l) < p_nudging_t .AND. nint(nudging_t) /= 0 ) &
1051             & d_t_nudge(l)=(temp_nudg_mod_cas(l)-temp(l))/nudging_t
1052
1053          ENDIF
1054
1055
1056         IF (nudging_qv .LT. 0) THEN
1057             
1058             d_q_nudge(l,1)=(qv_nudg_mod_cas(l)-q(l,1))*invtau_qv_nudg_mod_cas(l)
1059       
1060         ELSE
1061
1062             IF ( play(l) < p_nudging_qv .AND. nint(nudging_qv) /= 0 ) &
1063             & d_q_nudge(l,1)=(qv_nudg_mod_cas(l)-q(l,1))/nudging_qv
1064
1065         ENDIF
1066
1067      ENDDO
1068
1069!-----------------------------------------------------------
1070! horizontal forcings (advection) and nudging
1071!-----------------------------------------------------------
1072
1073    IF (flag_inhib_forcing == 0) then ! if tendency of forcings should be added
1074
1075        u(1:mxcalc)=u(1:mxcalc) + timestep*(                                &
1076     &              du_phys(1:mxcalc)                                       &
1077     &             +d_u_age(1:mxcalc)+d_u_adv(1:mxcalc)                       &
1078     &             +d_u_nudge(1:mxcalc) )           
1079        v(1:mxcalc)=v(1:mxcalc) + timestep*(                                 &
1080     &              dv_phys(1:mxcalc)                                       &
1081     &             +d_v_age(1:mxcalc)+d_v_adv(1:mxcalc)                       &
1082     &             +d_v_nudge(1:mxcalc) )
1083        q(1:mxcalc,:)=q(1:mxcalc,:)+timestep*(                              &
1084     &                dq(1:mxcalc,:)                                        &
1085     &               +d_q_adv(1:mxcalc,:)                                   &
1086     &               +d_q_nudge(1:mxcalc,:) )
1087
1088
1089        temp(1:mxcalc)=temp(1:mxcalc)+timestep*(                            &
1090     &              dt_phys(1:mxcalc)                                       &
1091     &             +d_t_adv(1:mxcalc)                                       &
1092     &             +d_t_nudge(1:mxcalc)                                     &
1093     &             +dt_cooling(1:mxcalc))  ! Taux de chauffage ou refroid.
1094
1095!---------------------------------------------------------------------
1096!  Optional outputs
1097!---------------------------------------------------------------------
1098
1099IF (CPPKEY_OUTPUTPHYSSCM) THEN
1100      CALL iophys_ecrit('w_adv',klev,'w_adv','K/day',w_adv)
1101      CALL iophys_ecrit('z_adv',klev,'z_adv','K/day',z_adv)
1102      CALL iophys_ecrit('dtadv',klev,'dtadv','K/day',86400*d_t_adv)
1103      CALL iophys_ecrit('dtdyn',klev,'dtdyn','K/day',86400*d_t_vert_adv)
1104      CALL iophys_ecrit('qv',klev,'qv','g/kg',1000*q(:,1))
1105      CALL iophys_ecrit('qvnud',klev,'qvnud','g/kg',1000*u_nudg_mod_cas)
1106      CALL iophys_ecrit('u',klev,'u','m/s',u)
1107      CALL iophys_ecrit('unud',klev,'unud','m/s',u_nudg_mod_cas)
1108      CALL iophys_ecrit('v',klev,'v','m/s',v)
1109      CALL iophys_ecrit('vnud',klev,'vnud','m/s',v_nudg_mod_cas)
1110      CALL iophys_ecrit('temp',klev,'temp','K',temp)
1111      CALL iophys_ecrit('tempnud',klev,'temp_nudg_mod_cas','K',temp_nudg_mod_cas)
1112      CALL iophys_ecrit('dtnud',klev,'dtnud','K/day',86400*d_t_nudge)
1113      CALL iophys_ecrit('dqnud',klev,'dqnud','K/day',1000*86400*d_q_nudge(:,1))
1114END IF
1115
1116
1117
1118! CONSERVE EN ATTENDANT QUE LE CAS EN QUESTION FONCTIONNE EN STD !!
1119
1120        teta=temp*(pzero/play)**rkappa
1121
1122!---------------------------------------------------------------------
1123!   Nudge soil temperature if requested
1124!---------------------------------------------------------------------
1125
1126      IF (nudge_tsoil .AND. .NOT. lastcall) THEN
1127       ftsoil(1,isoil_nudge,:) = ftsoil(1,isoil_nudge,:)                     &
1128     &  -timestep/tau_soil_nudge*(ftsoil(1,isoil_nudge,:)-Tsoil_nudge)
1129      ENDIF
1130
1131
1132   END IF ! end if in case tendency should be added
1133
1134!---------------------------------------------------------------------
1135!   Air temperature :
1136!---------------------------------------------------------------------       
1137        if (lastcall) then
1138          print*,'Pas de temps final ',it
1139          call ju2ymds(daytime, an, mois, jour, heure)
1140          print*,'a la date : a m j h',an, mois, jour ,heure/3600.
1141        endif
1142
1143!  incremente day time
1144        daytime = daytime+1./day_step
1145        day = int(daytime+0.1/day_step)
1146        time = time_ini/24.+real(mod(it,day_step))/day_step
1147        it=it+1
1148
1149      enddo
1150
1151      if (ecrit_slab_oc.ne.-1) close(97)
1152
1153!Al1 Call to 1D equivalent of dynredem (an,mois,jour,heure ?)
1154! ---------------------------------------------------------------------------
1155       call dyn1dredem("restart1dyn.nc",                                    &
1156     &              plev,play,phi,phis,presnivs,                            &
1157     &              u,v,temp,q,omega2)
1158
1159        CALL abort_gcm ('lmdz1d   ','The End  ',0)
1160
1161END SUBROUTINE scm
Note: See TracBrowser for help on using the repository browser.