source: LMDZ5/trunk/libf/phylmd/dyn1d/lmdz1d.F90 @ 2933

Last change on this file since 2933 was 2933, checked in by fhourdin, 7 years ago

Les insectes ont parfois une carapace solide.
Correction d'une correction qui en avait oublié un précédente.
(Frédéric pour Marie-Pierre)

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