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

Last change on this file since 5003 was 2839, checked in by Laurent Fairhead, 7 years ago

Merged trunk changes r2785:2838 into testing branch

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