source: LMDZ6/trunk/libf/phylmd/dyn1d/scm.f90 @ 5669

Last change on this file since 5669 was 5669, checked in by Laurent Fairhead, 3 weeks ago

Initialisation problem for 1D

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