source: LMDZ6/trunk/libf/phylmd/dyn1d/old_lmdz1d.F90 @ 3977

Last change on this file since 3977 was 3977, checked in by fhourdin, 3 years ago

Modification des routines iotd* pour mieux gerer les coordonnees.
Utile notamment pour la physique a 20 parametres.

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