source: LMDZ6/trunk/libf/phylmd/dyn1d/scm.F90 @ 3593

Last change on this file since 3593 was 3593, checked in by fhourdin, 5 years ago

Significant progress for the SCM standard format

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