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

Last change on this file since 2339 was 2335, checked in by lguez, 9 years ago

Fixed regression from revision 2333. Add argument rot in call to
physiq from lmdz1d.

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