source: LMDZ5/branches/testing/libf/phylmd/dyn1d/lmdz1d.F90 @ 2594

Last change on this file since 2594 was 2594, checked in by Laurent Fairhead, 8 years ago

Merged trunk changes r2545:2589 into testing branch

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