source: LMDZ6/trunk/libf/phylmd/dyn1d/lmdz1d.F90 @ 3538

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

Modification pour la derniere version du format standard 1D.
Catherine et Frédéric

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