source: LMDZ5/trunk/libf/phylmd/dyn1d/lmdz1d.F90 @ 2786

Last change on this file since 2786 was 2786, checked in by Ehouarn Millour, 7 years ago

Further convergence with planetary models:

  • move vertical_layers_mod.F90 to phy_common and call init_vertical_layers in inigeomphy_mod
  • add aps and bps (mid-layer coordinates) to vertical_layers_mod.F90
  • same adaptations for the 1D case

EM

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