source: LMDZ6/trunk/libf/phylmd/dyn1d/old_lmdz1d.f90 @ 5308

Last change on this file since 5308 was 5302, checked in by abarral, 39 hours ago

Turn compar1d.h date_cas.h into module
Move fcg_racmo.h to obsolete

File size: 51.3 KB
RevLine 
[3541]1!
2! $Id: lmdz1d.F90 3540 2019-06-25 14:50:13Z fairhead $
3!
4
5      SUBROUTINE old_lmdz1d
6
[5301]7USE flux_arp_mod_h
8      USE compbl_mod_h
[5296]9         USE clesphys_mod_h
[5282]10      USE ioipsl, only: ju2ymds, ymds2ju, ioconf_calendar,getin
[3541]11   USE phys_state_var_mod, ONLY : phys_state_var_init, phys_state_var_end, &
12       clwcon, detr_therm, &
13       qsol, fevap, z0m, z0h, agesno, &
14       du_gwd_rando, du_gwd_front, entr_therm, f0, fm_therm, &
15       falb_dir, falb_dif, &
[3888]16       ftsol, beta_aridity, pbl_tke, pctsrf, radsol, rain_fall, snow_fall, ratqs, &
[3541]17       rnebcon, rugoro, sig1, w01, solaire_etat0, sollw, sollwdown, &
[5205]18       solsw, solswfdiff, t_ancien, q_ancien, u_ancien, v_ancien, &
[3541]19       wake_delta_pbl_TKE, delta_tsurf, wake_fip, wake_pe, &
[4744]20       wake_deltaq, wake_deltat, wake_s, awake_s, wake_dens, &
[3956]21       awake_dens, cv_gen, wake_cstar, &
[3541]22       zgam, zmax0, zmea, zpic, zsig, &
[5212]23       zstd, zthe, zval, ale_bl, ale_bl_trig, alp_bl, &
[5213]24       ql_ancien, qs_ancien, qbs_ancien, cf_ancien, rvc_ancien, &
25       prlw_ancien, prsw_ancien, prbsw_ancien, prw_ancien, &
[3575]26       u10m,v10m,ale_wake,ale_bl_stat
27
[5282]28
[3541]29   USE dimphy
30   USE surface_data, only : type_ocean,ok_veget
31   USE pbl_surface_mod, only : ftsoil, pbl_surface_init, &
32                                 pbl_surface_final
[5282]33   USE fonte_neige_mod, only : fonte_neige_init, fonte_neige_final
[3541]34
35   USE infotrac ! new
36   USE control_mod
37   USE indice_sol_mod
38   USE phyaqua_mod
39!  USE mod_1D_cases_read
40   USE mod_1D_cases_read2
41   USE mod_1D_amma_read
42   USE print_control_mod, ONLY: lunout, prt_level
43   USE iniphysiq_mod, ONLY: iniphysiq
44   USE mod_const_mpi, ONLY: comm_lmdz
45   USE physiq_mod, ONLY: physiq
46   USE comvert_mod, ONLY: presnivs, ap, bp, dpres,nivsig, nivsigs, pa, &
47                          preff, aps, bps, pseudoalt, scaleheight
48   USE temps_mod, ONLY: annee_ref, calend, day_end, day_ini, day_ref, &
49                        itau_dyn, itau_phy, start_time, year_len
[5260]50   USE phys_cal_mod, ONLY : year_len_phys_cal_mod => year_len
51   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_OUTPUTPHYSSCM
[3541]52
[5273]53   USE dimensions_mod, ONLY: iim, jjm, llm, ndm
54   USE dimsoil_mod_h, ONLY: nsoilmx
[5301]55  USE yomcst_mod_h
56  USE tsoilnudge_mod_h
57  USE fcg_gcssold_mod_h
[5302]58        USE compar1d_mod_h
59        USE date_cas_mod_h
[5271]60implicit none
61
[4593]62!!!      INCLUDE "fbforcing.h"
[3541]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!
[4593]165      INCLUDE "old_1D_decl_cases.h"
[3541]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.
[5084]368      elseif (forcing_type .eq.1) THEN
[3541]369       forcing_radconv = .true.
[5084]370      elseif (forcing_type .eq.2) THEN
[3541]371       forcing_toga    = .true.
[5084]372      elseif (forcing_type .eq.3) THEN
[3541]373       forcing_GCM2SCM = .true.
[5084]374      elseif (forcing_type .eq.4) THEN
[3541]375       forcing_twpice = .true.
[5084]376      elseif (forcing_type .eq.5) THEN
[3541]377       forcing_rico = .true.
[5084]378      elseif (forcing_type .eq.6) THEN
[3541]379       forcing_amma = .true.
[5084]380      elseif (forcing_type .eq.7) THEN
[3541]381       forcing_dice = .true.
[5084]382      elseif (forcing_type .eq.8) THEN
[3541]383       forcing_gabls4 = .true.
[5084]384      elseif (forcing_type .eq.101) THEN ! Cindynamo starts 1-10-2011 0h
[3541]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
[5084]391      elseif (forcing_type .eq.102) THEN ! Bomex starts 24-6-1969 0h
[3541]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
[5084]398      elseif (forcing_type .eq.103) THEN ! Arm_cu starts 21-6-1997 11h30
[3541]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
[5084]405      elseif (forcing_type .eq.104) THEN ! rico starts 16-12-2004 0h
[3541]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
[5084]412      elseif (forcing_type .eq.105) THEN ! bomex starts 16-12-2004 0h
[3541]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
[5084]419      elseif (forcing_type .eq.106) THEN ! ayotte_24SC starts 6-11-1992 0h
[3541]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
[5084]426      elseif (forcing_type .eq.113) THEN ! Arm_cu starts 21-6-1997 11h30
[3541]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)
[5084]434      elseif (forcing_type .eq.40) THEN
[3541]435       forcing_GCSSold = .true.
[5084]436      elseif (forcing_type .eq.50) THEN
[3541]437       forcing_fire = .true.
[5084]438      elseif (forcing_type .eq.59) THEN
[3541]439       forcing_sandu   = .true.
[5084]440      elseif (forcing_type .eq.60) THEN
[3541]441       forcing_astex   = .true.
[5084]442      elseif (forcing_type .eq.61) THEN
[3541]443       forcing_armcu = .true.
[5084]444       IF(llm.NE.19.AND.llm.NE.40) stop 'Erreur nombre de niveaux !!'
[3541]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
[5084]463       nudge(i) = mod(jcode,10) .ge. 1
[3541]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
[4361]496        call ioconf_calendar('360_day')
[3541]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)
[5084]530      IF(forcing_type .EQ. 61) fnday=53100./86400.
531      IF(forcing_type .EQ. 103) fnday=53100./86400.
[3541]532! Special case for amma which lasts less than one day : 64800s !! (MPL 20120216)
[5084]533      IF(forcing_type .EQ. 6) fnday=64800./86400.
[3541]534!     IF(forcing_type .EQ. 6) fnday=50400./86400.
[5084]535 IF(forcing_type .EQ. 8 ) fnday=129600./86400.
[3541]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
[5084]546      IF (forcing_type .eq.2) THEN
[3541]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
[5084]551      ELSEIF (forcing_type .eq.4) THEN
[3541]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)
[5084]556      ELSEIF (forcing_type .eq.6) THEN
[3541]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)
[5084]561      ELSEIF (forcing_type .eq.7) THEN
[3541]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)
[5084]566 ELSEIF (forcing_type .eq.8 ) THEN
[3541]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)
[5084]571      ELSEIF (forcing_type .gt.100) THEN
[3541]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
[5084]579      ELSEIF (forcing_type .eq.59) THEN
[3541]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
[5084]585      ELSEIF (forcing_type .eq.60) THEN
[3541]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
[5084]591      ELSEIF (forcing_type .eq.61) THEN
[3541]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
[5084]598      IF (forcing_type .gt.100) THEN
[3541]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
[4325]615      call init_infotrac
[3541]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
[3781]635      nsw=6          ! EV et LF: sinon, falb_dir et falb_dif ne peuvent etre alloues
636
637
[3541]638      call phys_state_var_init(read_climoz)
639
[5084]640      if (ngrid.ne.klon) then
[3541]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.)
[3890]659      beta_surf = 1.
[3888]660      beta_aridity(:,:) = beta_surf
[3541]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
[5084]704      IF (forcing_type .eq. 59) THEN
[3541]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)
[5084]709       if (trouve_700 .and. play(l).le.70000) then
[3541]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
[4593]723      INCLUDE "old_1D_read_forc_cases.h"
[3541]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
[3780]735! EV tg instead of ts_cur
736
737      tg = tsurf ! SST used in read_tsurf1d
[3541]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.
[3888]800        snsrf(1,:)=snowmass ! masse de neige des sous surface
[3780]801        print *, 'snsrf', snsrf
[3541]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.
[5084]828          if (nat_surf.eq.0.) then
[3541]829          pctsrf(1,is_oce)=1.
830          pctsrf(1,is_ter)=0.
831          pctsrf(1,is_lic)=0.
832          pctsrf(1,is_sic)=0.
[5084]833        else if (nat_surf .eq. 1) then
[3541]834          pctsrf(1,is_oce)=0.
835          pctsrf(1,is_ter)=1.
836          pctsrf(1,is_lic)=0.
837          pctsrf(1,is_sic)=0.
[5084]838        else if (nat_surf .eq. 2) then
[3541]839          pctsrf(1,is_oce)=0.
840          pctsrf(1,is_ter)=0.
841          pctsrf(1,is_lic)=1.
842          pctsrf(1,is_sic)=0.
[5084]843        else if (nat_surf .eq. 3) then
[3541]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.
[5213]867        IF ( ok_bs ) THEN
868          qbs_ancien = 0.
869          prbsw_ancien = 0.
870        ENDIF
[5212]871        IF ( ok_ice_supersat ) THEN
872          cf_ancien = 0.
873          rvc_ancien = 0.
874        ENDIF
[3541]875!jyg<
876!!        pbl_tke(:,:,:)=1.e-8
877        pbl_tke(:,:,:)=0.
878        pbl_tke(:,2,:)=1.e-2
879        PRINT *, ' pbl_tke dans lmdz1d '
[5084]880        if (prt_level .ge. 5) then
[3541]881         DO nsrf = 1,4
882           PRINT *,'pbl_tke(1,:,',nsrf,') ',pbl_tke(1,:,nsrf)
883         ENDDO
884        end if
885
886!>jyg
887
888        rain_fall=0.
889        snow_fall=0.
890        solsw=0.
[3956]891        solswfdiff=0.
[3541]892        sollw=0.
893        sollwdown=rsigma*tsurf**4
894        radsol=0.
895        rnebcon=0.
896        ratqs=0.
897        clwcon=0.
898        zmax0 = 0.
[4104]899        zmea=zsurf
[3541]900        zstd=0.
901        zsig=0.
902        zgam=0.
903        zval=0.
904        zthe=0.
905        sig1=0.
906        w01=0.
[3956]907!
[3541]908        wake_deltaq = 0.
909        wake_deltat = 0.
910        wake_delta_pbl_TKE(:,:,:) = 0.
911        delta_tsurf = 0.
912        wake_fip = 0.
913        wake_pe = 0.
914        wake_s = 0.
[4744]915        awake_s = 0.
[3541]916        wake_dens = 0.
[3956]917        awake_dens = 0.
918        cv_gen = 0.
919        wake_cstar = 0.
[3541]920        ale_bl = 0.
921        ale_bl_trig = 0.
922        alp_bl = 0.
923        IF (ALLOCATED(du_gwd_rando)) du_gwd_rando = 0.
924        IF (ALLOCATED(du_gwd_front)) du_gwd_front = 0.
925        entr_therm = 0.
926        detr_therm = 0.
927        f0 = 0.
928        fm_therm = 0.
929        u_ancien(1,:)=u(:)
930        v_ancien(1,:)=v(:)
[3575]931
[3780]932        u10m=0.
933        v10m=0.
934        ale_wake=0.
935        ale_bl_stat=0.
[3541]936 
937!------------------------------------------------------------------------
938! Make file containing restart for the physics (startphy.nc)
939!
940! NB: List of the variables to be written by phyredem (via put_field):
941! rlon,rlat,zmasq,pctsrf(:,is_ter),pctsrf(:,is_lic),pctsrf(:,is_oce)
942! pctsrf(:,is_sic),ftsol(:,nsrf),tsoil(:,isoil,nsrf),qsurf(:,nsrf)
943! qsol,falb_dir(:,nsrf),falb_dif(:,nsrf),evap(:,nsrf),snow(:,nsrf)
[3956]944! radsol,solsw,solswfdiff,sollw, sollwdown,fder,rain_fall,snow_fall,frugs(:,nsrf)
[3541]945! agesno(:,nsrf),zmea,zstd,zsig,zgam,zthe,zpic,zval,rugoro
946! t_ancien,q_ancien,,frugs(:,is_oce),clwcon(:,1),rnebcon(:,1),ratqs(:,1)
947! run_off_lic_0,pbl_tke(:,1:klev,nsrf), zmax0,f0,sig1,w01
[4744]948! wake_deltat,wake_deltaq,wake_s,awake_s,wake_dens,awake_dens,cv_gen,wake_cstar,
[3541]949! wake_fip,wake_delta_pbl_tke(:,1:klev,nsrf)
950!
951! NB2: The content of the startphy.nc file depends on some flags defined in
952! the ".def" files. However, since conf_phys is not called in lmdz1d.F90, these flags have
953! to be set at some arbitratry convenient values.
954!------------------------------------------------------------------------
955!Al1 =============== restart option ==========================
[4553]956        iflag_physiq=0
[4537]957        call getin('iflag_physiq',iflag_physiq)
958
[3541]959        if (.not.restart) then
960          iflag_pbl = 5
961          call phyredem ("startphy.nc")
962        else
963! (desallocations)
964        print*,'callin surf final'
965          call pbl_surface_final( fder, snsrf, qsurfsrf, tsoil)
966        print*,'after surf final'
967          CALL fonte_neige_final(run_off_lic_0)
968        endif
969
970        ok_writedem=.false.
971        print*,'apres phyredem'
972
973      endif ! ok_writedem
974     
975!------------------------------------------------------------------------
976! Make file containing boundary conditions (limit.nc) **Al1->restartdyn***
977! --------------------------------------------------
978! NB: List of the variables to be written in limit.nc
979!     (by writelim.F, subroutine of 1DUTILS.h):
980!        phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
981!        phy_fter,phy_foce,phy_flic,phy_fsic)
982!------------------------------------------------------------------------
983      do i=1,year_len
984        phy_nat(i)  = nat_surf
985        phy_alb(i)  = albedo
986        phy_sst(i)  = tsurf ! read_tsurf1d will be used instead
987        phy_rug(i)  = rugos
988        phy_fter(i) = pctsrf(1,is_ter)
989        phy_foce(i) = pctsrf(1,is_oce)
990        phy_fsic(i) = pctsrf(1,is_sic)
991        phy_flic(i) = pctsrf(1,is_lic)
992      enddo
993
994! fabrication de limit.nc
995      call writelim (1,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,             &
996     &               phy_ice,phy_fter,phy_foce,phy_flic,phy_fsic)
997
998
999      call phys_state_var_end
1000!Al1
1001      if (restart) then
1002        print*,'call to restart dyn 1d'
1003        Call dyn1deta0("start1dyn.nc",plev,play,phi,phis,presnivs,          &
1004     &              u,v,temp,q,omega2)
1005
1006       print*,'fnday,annee_ref,day_ref,day_ini',                            &
1007     &     fnday,annee_ref,day_ref,day_ini
1008!**      call ymds2ju(annee_ref,mois,day_ini,heure,day)
1009       day = day_ini
1010       day_end = day_ini + nday
1011       daytime = day + time_ini/24. ! 1st day and initial time of the simulation
1012
1013! Print out the actual date of the beginning of the simulation :
1014       call ju2ymds(daytime, an, mois, jour, heure)
1015       print *,' Time of beginning : y m d h',an, mois,jour,heure/3600.
1016
1017       day = int(daytime)
1018       time=daytime-day
1019 
1020       print*,'****** intialised fields from restart1dyn *******'
1021       print*,'plev,play,phi,phis,presnivs,u,v,temp,q,omega2'
1022       print*,'temp(1),q(1,1),u(1),v(1),plev(1),phis :'
1023       print*,temp(1),q(1,1),u(1),v(1),plev(1),phis
1024! raz for safety
1025       do l=1,llm
1026         dq_dyn(l,1) = 0.
1027       enddo
1028      endif
1029!Al1 ================  end restart =================================
[5084]1030      IF (ecrit_slab_oc.eq.1) then
[3541]1031         open(97,file='div_slab.dat',STATUS='UNKNOWN')
[5084]1032       elseif (ecrit_slab_oc.eq.0) then
[3541]1033         open(97,file='div_slab.dat',STATUS='OLD')
1034       endif
1035!
1036!---------------------------------------------------------------------
1037!    Initialize target profile for RHT nudging if needed
1038!---------------------------------------------------------------------
1039      if (nudge(inudge_RHT)) then
1040        call nudge_RHT_init(plev,play,temp,q(:,1),t_targ,rh_targ)
1041      endif
1042      if (nudge(inudge_UV)) then
1043        call nudge_UV_init(plev,play,u,v,u_targ,v_targ)
1044      endif
1045!
1046!=====================================================================
[5260]1047IF (CPPKEY_OUTPUTPHYSSCM) THEN
[3977]1048       CALL iophys_ini(timestep)
[5260]1049END IF
[3541]1050! START OF THE TEMPORAL LOOP :
1051!=====================================================================
1052           
1053      it_end = nint(fnday*day_step)
1054!test JLD     it_end = 10
[5084]1055      do while(it.le.it_end)
[3541]1056
[5084]1057       if (prt_level.ge.1) then
[3541]1058         print*,'XXXXXXXXXXXXXXXXXXX ITAP,day,time=',                       &
1059     &             it,day,time,it_end,day_step
1060         print*,'PAS DE TEMPS ',timestep
1061       endif
1062!Al1 demande de restartphy.nc
[5084]1063       if (it.eq.it_end) lastcall=.True.
[3541]1064
1065!---------------------------------------------------------------------
[4105]1066!  Geopotential :
1067!---------------------------------------------------------------------
1068
1069        phi(1)=RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
1070        do l = 1, llm-1
1071          phi(l+1)=phi(l)+RD*(temp(l)+temp(l+1))*                           &
1072     &    (play(l)-play(l+1))/(play(l)+play(l+1))
1073        enddo
1074
1075!---------------------------------------------------------------------
[3541]1076! Interpolation of forcings in time and onto model levels
1077!---------------------------------------------------------------------
1078
[4593]1079      INCLUDE "old_1D_interp_cases.h"
[3541]1080
1081      if (forcing_GCM2SCM) then
1082        write (*,*) 'forcing_GCM2SCM not yet implemented'
1083        stop 'in time loop'
1084      endif ! forcing_GCM2SCM
1085
[4105]1086!!!!---------------------------------------------------------------------
1087!!!!  Geopotential :
1088!!!!---------------------------------------------------------------------
1089!!!
1090!!!        phi(1)=RD*temp(1)*(plev(1)-play(1))/(.5*(plev(1)+play(1)))
1091!!!        do l = 1, llm-1
1092!!!          phi(l+1)=phi(l)+RD*(temp(l)+temp(l+1))*                           &
1093!!!     &    (play(l)-play(l+1))/(play(l)+play(l+1))
1094!!!        enddo
[3541]1095
1096!---------------------------------------------------------------------
1097! Listing output for debug prt_level>=1
1098!---------------------------------------------------------------------
1099       if (prt_level>=1) then
1100         print *,' avant physiq : -------- day time ',day,time
1101         write(*,*) 'firstcall,lastcall,phis',                               &
1102     &               firstcall,lastcall,phis
1103       end if
1104       if (prt_level>=5) then
1105         write(*,'(a10,2a4,4a13)') 'BEFOR1 IT=','it','l',                   &
1106     &        'presniv','plev','play','phi'
1107         write(*,'(a10,2i4,4f13.2)') ('BEFOR1 IT= ',it,l,                   &
1108     &         presnivs(l),plev(l),play(l),phi(l),l=1,llm)
1109         write(*,'(a11,2a4,a11,6a8)') 'BEFOR2','it','l',                    &
1110     &         'presniv','u','v','temp','q1','q2','omega2'
1111         write(*,'(a11,2i4,f11.2,5f8.2,e10.2)') ('BEFOR2 IT= ',it,l,         &
1112     &   presnivs(l),u(l),v(l),temp(l),q(l,1),q(l,2),omega2(l),l=1,llm)
1113       endif
1114
1115!---------------------------------------------------------------------
1116!   Call physiq :
1117!---------------------------------------------------------------------
1118       call physiq(ngrid,llm, &
1119                    firstcall,lastcall,timestep, &
1120                    plev,play,phi,phis,presnivs, &
1121                    u,v, rot, temp,q,omega2, &
1122                    du_phys,dv_phys,dt_phys,dq,dpsrf)
1123                firstcall=.false.
1124
1125!---------------------------------------------------------------------
1126! Listing output for debug
1127!---------------------------------------------------------------------
1128        if (prt_level>=5) then
1129          write(*,'(a11,2a4,4a13)') 'AFTER1 IT=','it','l',                  &
1130     &        'presniv','plev','play','phi'
1131          write(*,'(a11,2i4,4f13.2)') ('AFTER1 it= ',it,l,                  &
1132     &    presnivs(l),plev(l),play(l),phi(l),l=1,llm)
1133          write(*,'(a11,2a4,a11,6a8)') 'AFTER2','it','l',                   &
1134     &         'presniv','u','v','temp','q1','q2','omega2'
1135          write(*,'(a11,2i4,f11.2,5f8.2,e10.2)') ('AFTER2 it= ',it,l,       &
1136     &    presnivs(l),u(l),v(l),temp(l),q(l,1),q(l,2),omega2(l),l=1,llm)
1137          write(*,'(a11,2a4,a11,5a8)') 'AFTER3','it','l',                   &
1138     &         'presniv','du_phys','dv_phys','dt_phys','dq1','dq2'   
1139           write(*,'(a11,2i4,f11.2,5f8.2)') ('AFTER3 it= ',it,l,            &
1140     &      presnivs(l),86400*du_phys(l),86400*dv_phys(l),                   &
1141     &       86400*dt_phys(l),86400*dq(l,1),dq(l,2),l=1,llm)
1142          write(*,*) 'dpsrf',dpsrf
1143        endif
1144!---------------------------------------------------------------------
1145!   Add physical tendencies :
1146!---------------------------------------------------------------------
1147
1148       fcoriolis=2.*sin(rpi*xlat/180.)*romega
1149       if (forcing_radconv .or. forcing_fire) then
1150         fcoriolis=0.0
1151         dt_cooling=0.0
1152         d_t_adv=0.0
1153         d_q_adv=0.0
1154       endif
1155!      print*, 'calcul de fcoriolis ', fcoriolis
1156
1157       if (forcing_toga .or. forcing_GCSSold .or. forcing_twpice            &
[5084]1158     &    .or.forcing_amma .or. forcing_type.eq.101) then
[3541]1159         fcoriolis=0.0 ; ug=0. ; vg=0.
1160       endif
1161
1162       if(forcing_rico) then
1163          dt_cooling=0.
1164       endif
1165
1166!CRio:Attention modif sp??cifique cas de Caroline
1167      if (forcing_type==-1) then
1168         fcoriolis=0.
1169!Nudging
1170       
1171!on calcule dt_cooling
1172        do l=1,llm
[5084]1173        if (play(l).ge.20000.) then
[3541]1174            dt_cooling(l)=-1.5/86400.
[5084]1175        elseif ((play(l).ge.10000.).and.((play(l).lt.20000.))) then
[3541]1176            dt_cooling(l)=-1.5/86400.*(play(l)-10000.)/(10000.)-1./86400.*(20000.-play(l))/10000.*(temp(l)-200.)
1177        else
1178            dt_cooling(l)=-1.*(temp(l)-200.)/86400.
1179        endif
1180        enddo
1181
1182      endif     
1183!RC
1184      if (forcing_sandu) then
1185         ug(1:llm)=u_mod(1:llm)
1186         vg(1:llm)=v_mod(1:llm)
1187      endif
1188
1189      IF (prt_level >= 5) print*, 'fcoriolis, xlat,mxcalc ', &
1190                                   fcoriolis, xlat,mxcalc
1191
1192!       print *,'u-ug=',u-ug
1193
1194!!!!!!!!!!!!!!!!!!!!!!!!
1195! Geostrophic wind
1196! Le calcul ci dessous est insuffisamment precis
1197!      du_age(1:mxcalc)=fcoriolis*(v(1:mxcalc)-vg(1:mxcalc))
1198!      dv_age(1:mxcalc)=-fcoriolis*(u(1:mxcalc)-ug(1:mxcalc))
1199!!!!!!!!!!!!!!!!!!!!!!!!
1200       sfdt = sin(0.5*fcoriolis*timestep)
1201       cfdt = cos(0.5*fcoriolis*timestep)
1202!       print *,'fcoriolis,sfdt,cfdt,timestep',fcoriolis,sfdt,cfdt,timestep
1203!
1204        du_age(1:mxcalc)= -2.*sfdt/timestep*                                &
1205     &          (sfdt*(u(1:mxcalc)-ug(1:mxcalc)) -                          &
1206     &           cfdt*(v(1:mxcalc)-vg(1:mxcalc))  )
1207!!     : fcoriolis*(v(1:mxcalc)-vg(1:mxcalc))
1208!
1209       dv_age(1:mxcalc)= -2.*sfdt/timestep*                                 &
1210     &          (cfdt*(u(1:mxcalc)-ug(1:mxcalc)) +                           &
1211     &           sfdt*(v(1:mxcalc)-vg(1:mxcalc))  )
1212!!     : -fcoriolis*(u(1:mxcalc)-ug(1:mxcalc))
1213!
1214!!!!!!!!!!!!!!!!!!!!!!!!
1215!  Nudging
1216!!!!!!!!!!!!!!!!!!!!!!!!
1217      d_t_nudge(:) = 0.
1218      d_q_nudge(:,:) = 0.
1219      d_u_nudge(:) = 0.
1220      d_v_nudge(:) = 0.
1221      if (nudge(inudge_RHT)) then
1222        call nudge_RHT(timestep,plev,play,t_targ,rh_targ,temp,q(:,1),     &
1223    &                  d_t_nudge,d_q_nudge(:,1))
1224      endif
1225      if (nudge(inudge_UV)) then
1226        call nudge_UV(timestep,plev,play,u_targ,v_targ,u,v,     &
1227    &                  d_u_nudge,d_v_nudge)
1228      endif
1229!
1230       if (forcing_fire) THEN
1231
1232!let ww=if ( alt le 1100 ) then alt*-0.00001 else 0
1233!let wt=if ( alt le 1100 ) then min( -3.75e-5 , -7.5e-8*alt)  else 0
1234!let wq=if ( alt le 1100 ) then max( 1.5e-8 , 3e-11*alt)  else 0
1235           d_t_adv=0.
1236           d_q_adv=0.
1237           teta=temp*(pzero/play)**rkappa
1238           d_t_adv=0.
1239           d_q_adv=0.
1240           do l=2,llm-1
1241              if (zlay(l)<=1100) then
1242                  wwww=-0.00001*zlay(l)
1243                  d_t_adv(l)=-wwww*(teta(l)-teta(l+1))/(zlay(l)-zlay(l+1)) /(pzero/play(l))**rkappa
1244                  d_q_adv(l,1:2)=-wwww*(q(l,1:2)-q(l+1,1:2))/(zlay(l)-zlay(l+1))
1245                  d_t_adv(l)=d_t_adv(l)+min(-3.75e-5 , -7.5e-8*zlay(l))
1246                  d_q_adv(l,1)=d_q_adv(l,1)+max( 1.5e-8 , 3e-11*zlay(l))
1247              endif
1248           enddo
1249
1250        endif
1251
1252!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1253!         call  writefield_phy('dv_age' ,dv_age,llm)
1254!         call  writefield_phy('du_age' ,du_age,llm)
1255!         call  writefield_phy('du_phys' ,du_phys,llm)
1256!         call  writefield_phy('u_tend' ,u,llm)
1257!         call  writefield_phy('u_g' ,ug,llm)
1258!
1259!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1260!! Increment state variables
1261!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1262    IF (flag_inhib_forcing == 0) then ! if tendency of forcings should be added
1263
1264! pour les cas sandu et astex, on reclacule u,v,q,temp et teta dans 1D_nudge_sandu_astex.h
1265! au dessus de 700hpa, on relaxe vers les profils initiaux
1266      if (forcing_sandu .OR. forcing_astex) then
[4593]1267      INCLUDE "1D_nudge_sandu_astex.h"
[3541]1268      else
1269        u(1:mxcalc)=u(1:mxcalc) + timestep*(                                &
1270     &              du_phys(1:mxcalc)                                       &
1271     &             +du_age(1:mxcalc)+du_adv(1:mxcalc)                       &
1272     &             +d_u_nudge(1:mxcalc) )           
1273        v(1:mxcalc)=v(1:mxcalc) + timestep*(                                 &
1274     &              dv_phys(1:mxcalc)                                       &
1275     &             +dv_age(1:mxcalc)+dv_adv(1:mxcalc)                       &
1276     &             +d_v_nudge(1:mxcalc) )
1277        q(1:mxcalc,:)=q(1:mxcalc,:)+timestep*(                              &
1278     &                dq(1:mxcalc,:)                                        &
1279     &               +d_q_adv(1:mxcalc,:)                                   &
1280     &               +d_q_nudge(1:mxcalc,:) )
1281
[5084]1282        if (prt_level.ge.3) then
[3541]1283          print *,                                                          &
1284     &    'physiq-> temp(1),dt_phys(1),d_t_adv(1),dt_cooling(1) ',         &
1285     &              temp(1),dt_phys(1),d_t_adv(1),dt_cooling(1)
1286           print* ,'dv_phys=',dv_phys
1287           print* ,'dv_age=',dv_age
1288           print* ,'dv_adv=',dv_adv
1289           print* ,'d_v_nudge=',d_v_nudge
1290           print*, v
1291           print*, vg
1292        endif
1293
1294        temp(1:mxcalc)=temp(1:mxcalc)+timestep*(                            &
1295     &              dt_phys(1:mxcalc)                                       &
1296     &             +d_t_adv(1:mxcalc)                                      &
1297     &             +d_t_nudge(1:mxcalc)                                      &
1298     &             +dt_cooling(1:mxcalc))  ! Taux de chauffage ou refroid.
1299
[5260]1300IF (CPPKEY_OUTPUTPHYSSCM) THEN
[3594]1301      CALL iophys_ecrit('d_t_adv',klev,'d_t_adv','m/s',d_t_adv)
1302      CALL iophys_ecrit('d_t_nudge',klev,'d_t_nudge','m/s',d_t_nudge)
[5260]1303END IF
[3594]1304
[3541]1305      endif  ! forcing_sandu or forcing_astex
1306
1307        teta=temp*(pzero/play)**rkappa
1308!
1309!---------------------------------------------------------------------
1310!   Nudge soil temperature if requested
1311!---------------------------------------------------------------------
1312
1313      IF (nudge_tsoil .AND. .NOT. lastcall) THEN
1314       ftsoil(1,isoil_nudge,:) = ftsoil(1,isoil_nudge,:)                     &
1315     &  -timestep/tau_soil_nudge*(ftsoil(1,isoil_nudge,:)-Tsoil_nudge)
1316      ENDIF
1317
1318!---------------------------------------------------------------------
1319!   Add large-scale tendencies (advection, etc) :
1320!---------------------------------------------------------------------
1321
1322!cc nrlmd
1323!cc        tmpvar=teta
1324!cc        call advect_vert(llm,omega,timestep,tmpvar,plev)
1325!cc
1326!cc        teta(1:mxcalc)=tmpvar(1:mxcalc)
1327!cc        tmpvar(:)=q(:,1)
1328!cc        call advect_vert(llm,omega,timestep,tmpvar,plev)
1329!cc        q(1:mxcalc,1)=tmpvar(1:mxcalc)
1330!cc        tmpvar(:)=q(:,2)
1331!cc        call advect_vert(llm,omega,timestep,tmpvar,plev)
1332!cc        q(1:mxcalc,2)=tmpvar(1:mxcalc)
1333
1334   END IF ! end if tendency of tendency should be added
1335
1336!---------------------------------------------------------------------
1337!   Air temperature :
1338!---------------------------------------------------------------------       
1339        if (lastcall) then
1340          print*,'Pas de temps final ',it
1341          call ju2ymds(daytime, an, mois, jour, heure)
1342          print*,'a la date : a m j h',an, mois, jour ,heure/3600.
1343        endif
1344
1345!  incremente day time
1346!        print*,'daytime bef',daytime,1./day_step
1347        daytime = daytime+1./day_step
1348!Al1dbg
1349        day = int(daytime+0.1/day_step)
1350!        time = max(daytime-day,0.0)
1351!Al1&jyg: correction de bug
1352!cc        time = real(mod(it,day_step))/day_step
1353        time = time_ini/24.+real(mod(it,day_step))/day_step
1354!        print*,'daytime nxt time',daytime,time
1355        it=it+1
1356
1357      enddo
1358
1359!Al1
[5084]1360      if (ecrit_slab_oc.ne.-1) close(97)
[3541]1361
1362!Al1 Call to 1D equivalent of dynredem (an,mois,jour,heure ?)
1363! -------------------------------------
1364       call dyn1dredem("restart1dyn.nc",                                    &
1365     &              plev,play,phi,phis,presnivs,                            &
1366     &              u,v,temp,q,omega2)
1367
1368        CALL abort_gcm ('lmdz1d   ','The End  ',0)
1369
1370        END SUBROUTINE old_lmdz1d
1371
[4593]1372        INCLUDE "old_1DUTILS_read_interp.h"
Note: See TracBrowser for help on using the repository browser.