source: LMDZ6/branches/Ocean_skin/libf/phylmd/dyn1d/old_lmdz1d.F90 @ 3605

Last change on this file since 3605 was 3605, checked in by lguez, 4 years ago

Merge revisions 3427:3600 of trunk into branch Ocean_skin

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