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

Last change on this file since 5924 was 5877, checked in by aborella, 3 weeks ago

Bugfix for compiling SCM and with ecRad with contrails

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