source: trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90 @ 1897

Last change on this file since 1897 was 1897, checked in by jvatant, 7 years ago

Making Titan's hazy again - part II
+ Major updates of J.Burgalat YAMMS library and optical coupling, including :
++ Added the routines for haze optics inside YAMMS
++ Calling rad. transf. with interactive haze is plugged
in but should stay unactive as long as the microphysics is
in test phase : cf "uncoupl_optic_haze" flag : true for now !
++ Also some sanity checks for negative tendencies and
some others upkeep of YAMMS model
+ Also added a temporary CPP key USE_QTEST in physiq_mod
that enables to have microphysical tendencies separated
from dynamics for debugging and test phases
-- JVO and JB

File size: 18.1 KB
Line 
1MODULE inifis_mod
2IMPLICIT NONE
3
4CONTAINS
5
6  SUBROUTINE inifis(ngrid,nlayer,nq, &
7             day_ini,pdaysec,nday,ptimestep, &
8             plat,plon,parea, &
9             prad,pg,pr,pcpp)
10
11  use init_print_control_mod, only: init_print_control
12  use radinc_h, only: ini_radinc_h
13  use datafile_mod
14  use comdiurn_h, only: sinlat, coslat, sinlon, coslon
15  use comgeomfi_h, only: totarea, totarea_planet
16  use comsoil_h, only: ini_comsoil_h, nsoilmx, lay1_soil, alpha_soil
17  use time_phylmdz_mod, only: ecritphy,day_step,iphysiq, &
18                              init_time, daysec, dtphys
19  use comcstfi_mod, only: rad, cpp, g, r, rcp, &
20                          mugaz, pi, avocado, kbol
21  use planete_mod, only: nres
22  use planetwide_mod, only: planetwide_sumval
23  use callkeys_mod
24  use mod_phys_lmdz_para, only : is_parallel
25
26!=======================================================================
27!
28!   purpose:
29!   -------
30!
31!   Initialisation for the physical parametrisations of the LMD
32!   Generic Model.
33!
34!   author: Frederic Hourdin 15 / 10 /93
35!   -------
36!   modified: Sebastien Lebonnois 11/06/2003 (new callphys.def)
37!             Ehouarn Millour (oct. 2008) tracers are now identified
38!              by their names and may not be contiguously
39!              stored in the q(:,:,:,:) array
40!             E.M. (june 2009) use getin routine to load parameters
41!
42!
43!   arguments:
44!   ----------
45!
46!   input:
47!   ------
48!
49!    ngrid                 Size of the horizontal grid.
50!                          All internal loops are performed on that grid.
51!    nlayer                Number of vertical layers.
52!    pdayref               Day of reference for the simulation
53!    pday                  Number of days counted from the North. Spring
54!                          equinoxe.
55!
56!=======================================================================
57!
58!-----------------------------------------------------------------------
59!   declarations:
60!   -------------
61  use ioipsl_getin_p_mod, only: getin_p
62  IMPLICIT NONE
63
64
65
66  REAL,INTENT(IN) :: prad,pg,pr,pcpp,pdaysec,ptimestep
67  INTEGER,INTENT(IN) :: nday
68  INTEGER,INTENT(IN) :: ngrid,nlayer,nq
69  REAL,INTENT(IN) :: plat(ngrid),plon(ngrid),parea(ngrid)
70  integer,intent(in) :: day_ini
71  INTEGER ig,ierr
72 
73  EXTERNAL iniorbit,orbite
74  EXTERNAL SSUM
75  REAL SSUM
76 
77  ! Initialize flags lunout, prt_level, debug (in print_control_mod)
78  CALL init_print_control
79
80  ! initialize constants in comcstfi_mod
81  rad=prad
82  cpp=pcpp
83  g=pg
84  r=pr
85  rcp=r/cpp
86  pi=2.*asin(1.)
87  avocado = 6.02214179e23   ! added by RW
88  kbol = 1.38064852e-23  ! added by JVO for Titan chem
89
90  ! Initialize some "temporal and calendar" related variables
91  CALL init_time(day_ini,pdaysec,nday,ptimestep)
92
93  ! read in some parameters from "run.def" for physics,
94  ! or shared between dynamics and physics.
95  call getin_p("ecritphy",ecritphy) ! frequency of outputs in physics,
96                                    ! in dynamical steps
97  call getin_p("day_step",day_step) ! number of dynamical steps per day
98  call getin_p("iphysiq",iphysiq) ! call physics every iphysiq dyn step
99
100  ! do we read a startphy.nc file? (default: .true.)
101  call getin_p("startphy_file",startphy_file)
102 
103! --------------------------------------------------------------
104!  Reading the "callphys.def" file controlling some key options
105! --------------------------------------------------------------
106     
107  ! check that 'callphys.def' file is around
108  OPEN(99,file='callphys.def',status='old',form='formatted',iostat=ierr)
109  CLOSE(99)
110  IF(ierr.EQ.0) iscallphys=.true. !iscallphys initialised as false in callkeys_mod module
111     
112!!!      IF(ierr.EQ.0) THEN
113  IF(iscallphys) THEN
114     PRINT*
115     PRINT*
116     PRINT*,'--------------------------------------------'
117     PRINT*,' inifis: Parametres pour la physique (callphys.def)'
118     PRINT*,'--------------------------------------------'
119
120     write(*,*) "Directory where external input files are:"
121     ! default 'datadir' is set in "datadir_mod"
122     call getin_p("datadir",datadir) ! default path
123     write(*,*) " datadir = ",trim(datadir)
124
125     write(*,*) "Run with or without tracer transport ?"
126     tracer=.false. ! default value
127     call getin_p("tracer",tracer)
128     write(*,*) " tracer = ",tracer
129
130     write(*,*) "Run with or without atm mass update ", &
131            " due to tracer evaporation/condensation?"
132     mass_redistrib=.false. ! default value
133     call getin_p("mass_redistrib",mass_redistrib)
134     write(*,*) " mass_redistrib = ",mass_redistrib
135
136     write(*,*) "Diurnal cycle ?"
137     write(*,*) "(if diurnal=false, diurnal averaged solar heating)"
138     diurnal=.true. ! default value
139     call getin_p("diurnal",diurnal)
140     write(*,*) " diurnal = ",diurnal
141
142     write(*,*) "Seasonal cycle ?"
143     write(*,*) "(if season=false, Ls stays constant, to value ", &
144         "set in 'start'"
145     season=.true. ! default value
146     call getin_p("season",season)
147     write(*,*) " season = ",season
148
149     write(*,*) "Tidally resonant rotation ?"
150     tlocked=.false. ! default value
151     call getin_p("tlocked",tlocked)
152     write(*,*) "tlocked = ",tlocked
153
154     write(*,*) "Saturn ring shadowing ?"
155     rings_shadow = .false.
156     call getin_p("rings_shadow", rings_shadow)
157     write(*,*) "rings_shadow = ", rings_shadow
158         
159     write(*,*) "Compute latitude-dependent gravity field?"
160     oblate = .false.
161     call getin_p("oblate", oblate)
162     write(*,*) "oblate = ", oblate
163
164     write(*,*) "Flattening of the planet (a-b)/a "
165     flatten = 0.0
166     call getin_p("flatten", flatten)
167     write(*,*) "flatten = ", flatten         
168
169     write(*,*) "Needed if oblate=.true.: J2"
170     J2 = 0.0
171     call getin_p("J2", J2)
172     write(*,*) "J2 = ", J2
173         
174     write(*,*) "Needed if oblate=.true.: Planet mass (*1e24 kg)"
175     MassPlanet = 0.0
176     call getin_p("MassPlanet", MassPlanet)
177     write(*,*) "MassPlanet = ", MassPlanet         
178
179     write(*,*) "Needed if oblate=.true.: Planet mean radius (m)"
180     Rmean = 0.0
181     call getin_p("Rmean", Rmean)
182     write(*,*) "Rmean = ", Rmean
183         
184! Test of incompatibility:
185! if tlocked, then diurnal should be false
186     if (tlocked.and.diurnal) then
187       print*,'If diurnal=true, we should turn off tlocked.'
188       stop
189     endif
190
191     write(*,*) "Tidal resonance ratio ?"
192     nres=0          ! default value
193     call getin_p("nres",nres)
194     write(*,*) "nres = ",nres
195
196     write(*,*) "Write some extra output to the screen ?"
197     lwrite=.false. ! default value
198     call getin_p("lwrite",lwrite)
199     write(*,*) " lwrite = ",lwrite
200
201     write(*,*) "Save statistics in file stats.nc ?"
202     callstats=.true. ! default value
203     call getin_p("callstats",callstats)
204     write(*,*) " callstats = ",callstats
205
206     write(*,*) "Test energy conservation of model physics ?"
207     enertest=.false. ! default value
208     call getin_p("enertest",enertest)
209     write(*,*) " enertest = ",enertest
210
211     write(*,*) "Check to see if cpp values used match gases.def ?"
212     check_cpp_match=.true. ! default value
213     call getin_p("check_cpp_match",check_cpp_match)
214     write(*,*) " check_cpp_match = ",check_cpp_match
215
216     write(*,*) "call radiative transfer ?"
217     callrad=.true. ! default value
218     call getin_p("callrad",callrad)
219     write(*,*) " callrad = ",callrad
220
221     write(*,*) "call correlated-k radiative transfer ?"
222     corrk=.true. ! default value
223     call getin_p("corrk",corrk)
224     write(*,*) " corrk = ",corrk
225     
226     if (corrk) then
227       ! default path is set in datadir
228       write(*,*) "callcorrk: Correlated-k data base folder:",trim(datadir)
229       call getin_p("corrkdir",corrkdir)
230       write(*,*) " corrkdir = ",corrkdir
231     endif
232     
233     if (corrk .and. ngrid.eq.1) then
234       write(*,*) "simulate global averaged conditions ?"
235       global1d = .false. ! default value
236       call getin_p("global1d",global1d)
237       write(*,*) " global1d = ",global1d
238       
239       ! Test of incompatibility : if global1d is true, there should not be any diurnal cycle.
240       if (global1d.and.diurnal) then
241          write(*,*) "if global1d is true, diurnal must be set to false"
242          stop
243       endif
244
245       if (global1d) then
246          write(*,*) "Solar Zenith angle (deg.) ?"
247          write(*,*) "(assumed for averaged solar flux S/4)"
248          szangle=60.0  ! default value
249          call getin_p("szangle",szangle)
250          write(*,*) " szangle = ",szangle
251       endif
252     endif
253
254     write(*,*) "prohibit calculations outside corrk T grid?"
255     strictboundcorrk=.true. ! default value
256     call getin_p("strictboundcorrk",strictboundcorrk)
257     write(*,*) "strictboundcorrk = ",strictboundcorrk
258
259     write(*,*) "call gaseous absorption in the visible bands?", &
260                    "(matters only if callrad=T)"
261     callgasvis=.false. ! default value
262     call getin_p("callgasvis",callgasvis)
263     write(*,*) " callgasvis = ",callgasvis
264       
265     write(*,*) "call continuum opacities in radiative transfer ?", &
266                    "(matters only if callrad=T)"
267     continuum=.true. ! default value
268     call getin_p("continuum",continuum)
269     write(*,*) " continuum = ",continuum
270 
271     write(*,*) "call turbulent vertical diffusion ?"
272     calldifv=.true. ! default value
273     call getin_p("calldifv",calldifv)
274     write(*,*) " calldifv = ",calldifv
275
276     write(*,*) "use turbdiff instead of vdifc ?"
277     UseTurbDiff=.true. ! default value
278     call getin_p("UseTurbDiff",UseTurbDiff)
279     write(*,*) " UseTurbDiff = ",UseTurbDiff
280
281     write(*,*) "call convective adjustment ?"
282     calladj=.true. ! default value
283     call getin_p("calladj",calladj)
284     write(*,*) " calladj = ",calladj
285
286     write(*,*) "Radiative timescale for Newtonian cooling ?"
287     tau_relax=30. ! default value
288     call getin_p("tau_relax",tau_relax)
289     write(*,*) " tau_relax = ",tau_relax
290     tau_relax=tau_relax*24*3600 ! convert Earth days --> seconds
291
292     write(*,*)"call thermal conduction in the soil ?"
293     callsoil=.true. ! default value
294     call getin_p("callsoil",callsoil)
295     write(*,*) " callsoil = ",callsoil
296         
297     write(*,*)"Rad transfer is computed every iradia", &
298                   " physical timestep"
299     iradia=1 ! default value
300     call getin_p("iradia",iradia)
301     write(*,*)" iradia = ",iradia
302       
303     write(*,*)"Rayleigh scattering ?"
304     rayleigh=.false.
305     call getin_p("rayleigh",rayleigh)
306     write(*,*)" rayleigh = ",rayleigh
307
308     write(*,*) "Use blackbody for stellar spectrum ?"
309     stelbbody=.false. ! default value
310     call getin_p("stelbbody",stelbbody)
311     write(*,*) " stelbbody = ",stelbbody
312
313     write(*,*) "Stellar blackbody temperature ?"
314     stelTbb=5800.0 ! default value
315     call getin_p("stelTbb",stelTbb)
316     write(*,*) " stelTbb = ",stelTbb
317
318     write(*,*)"Output mean OLR in 1D?"
319     meanOLR=.false.
320     call getin_p("meanOLR",meanOLR)
321     write(*,*)" meanOLR = ",meanOLR
322
323     write(*,*)"Output spectral OLR in 3D?"
324     specOLR=.false.
325     call getin_p("specOLR",specOLR)
326     write(*,*)" specOLR = ",specOLR
327
328     write(*,*)"Uniform absorption in radiative transfer?"
329     graybody=.false.
330     call getin_p("graybody",graybody)
331     write(*,*)" graybody = ",graybody
332
333! Chemistry
334
335     write(*,*) "Run with or without chemistry?"
336     callchim=.false. ! default value
337     call getin_p("callchim",callchim)
338     write(*,*) " callchim = ",callchim
339
340     ! sanity check
341     if (callchim.and.(.not.tracer)) then
342       print*,"You are running chemistry without tracer"
343       print*,"Please start again with tracer =.true."
344       stop
345     endif
346
347     write(*,*)"Chemistry is computed every ichim", &
348                   " physical timestep"
349     ichim=1 ! default value
350     call getin_p("ichim",ichim)
351     write(*,*)" ichim = ",ichim
352
353! Microphysics
354
355     write(*,*) "Run with or without microphysics?"
356     callmufi=.false. ! default value
357     call getin_p("callmufi",callmufi)
358     write(*,*)" callmufi = ",callmufi
359
360     ! sanity check
361     if (callmufi.and.(.not.tracer)) then
362       print*,"You are running microphysics without tracer"
363       print*,"Please start again with tracer =.true."
364       stop
365     endif
366
367     write(*,*) "Compute clouds?"
368     callclouds=.false. ! default value
369     call getin_p("callclouds",callclouds)
370     write(*,*)" callclouds = ",callclouds
371
372     ! sanity check
373     if (callclouds.and.(.not.callmufi)) then
374       print*,"You are trying to make clouds without microphysics !"
375       print*,"Please start again with callmufi =.true."
376       stop
377     endif
378
379     write(*,*) "Disable the coupling of microphysics within rad. transf. ?"
380     write(*,*) "If disabled we will assume a planetwide vert. profile of extinction ..."
381     uncoupl_optic_haze=.true. ! default value - true as long as the microphysics is bugged
382     call getin_p("uncoupl_optic_haze",uncoupl_optic_haze)
383     write(*,*)" uncoupl_optic_haze = ",uncoupl_optic_haze
384
385     write(*,*) "Pressure level of aer. production (Pa) ?"
386     p_prod=1.0 ! default value
387     call getin_p("p_prod",p_prod)
388     write(*,*)" p_prod = ",p_prod
389     
390     write(*,*) "Aerosol production rate (kg.m-2.s-1) ?"
391     tx_prod=3.5e-13 ! default value
392     call getin_p("tx_prod",tx_prod)
393     write(*,*)" tx_prod = ",tx_prod
394
395     write(*,*) "Equivalent radius production (m) ?"
396     rc_prod=2.0e-8 ! default value
397     call getin_p("rc_prod",rc_prod)
398     write(*,*)" rhc_prod = ",rc_prod
399
400     write(*,*) "Radius of air (nitrogen) molecule (m) ?"
401     air_rad=1.75e-10 ! default value
402     call getin_p("air_rad",air_rad)
403     write(*,*)" air_rad = ",air_rad
404
405     write(*,*) "Path to microphys. config file ?"
406     config_mufi='datagcm/microphysics/config.cfg' ! default value
407     call getin_p("config_mufi",config_mufi)
408     write(*,*)" config_mufi = ",config_mufi
409
410! Soil model
411     write(*,*)"Number of sub-surface layers for soil scheme?"
412     ! default value of nsoilmx set in comsoil_h
413     call getin_p("nsoilmx",nsoilmx)
414     write(*,*)" nsoilmx=",nsoilmx
415     
416     write(*,*)"Thickness of topmost soil layer (m)?"
417     ! default value of lay1_soil set in comsoil_h
418     call getin_p("lay1_soil",lay1_soil)
419     write(*,*)" lay1_soil = ",lay1_soil
420     
421     write(*,*)"Coefficient for soil layer thickness distribution?"
422     ! default value of alpha_soil set in comsoil_h
423     call getin_p("alpha_soil",alpha_soil)
424     write(*,*)" alpha_soil = ",alpha_soil
425
426     write(*,*)"Remove lower boundary?"
427     nosurf=.false.
428     call getin_p("nosurf",nosurf)
429     write(*,*)" nosurf = ",nosurf
430
431! Tests of incompatibility:
432     if (nosurf.and.callsoil) then
433       print*,'nosurf not compatible with soil scheme!'
434       print*,'... got to make a choice!'
435       call abort
436     endif
437
438     write(*,*)"Add an internal heat flux?", &
439                   "... matters only if callsoil=F"
440     intheat=0.
441     call getin_p("intheat",intheat)
442     write(*,*)" intheat = ",intheat
443
444     write(*,*)"Use Newtonian cooling for radiative transfer?"
445     newtonian=.false.
446     call getin_p("newtonian",newtonian)
447     write(*,*)" newtonian = ",newtonian
448
449! Tests of incompatibility:
450     if (newtonian.and.corrk) then
451       print*,'newtonian not compatible with correlated-k!'
452       call abort
453     endif
454     if (newtonian.and.calladj) then
455       print*,'newtonian not compatible with adjustment!'
456       call abort
457     endif
458     if (newtonian.and.calldifv) then
459       print*,'newtonian not compatible with a boundary layer!'
460       call abort
461     endif
462
463     write(*,*)"Test physics timescale in 1D?"
464     testradtimes=.false.
465     call getin_p("testradtimes",testradtimes)
466     write(*,*)" testradtimes = ",testradtimes
467
468! Test of incompatibility:
469! if testradtimes used, we must be in 1D
470     if (testradtimes.and.(ngrid.gt.1)) then
471       print*,'testradtimes can only be used in 1D!'
472       call abort
473     endif
474
475     write(*,*)"Which star?"
476     startype=1 ! default value = Sol
477     call getin_p("startype",startype)
478     write(*,*)" startype = ",startype
479
480     write(*,*)"Value of stellar flux at 1 AU?"
481     Fat1AU=1356.0 ! default value = Sol today
482     call getin_p("Fat1AU",Fat1AU)
483     write(*,*)" Fat1AU = ",Fat1AU
484
485     write(*,*) "Does user want to force cpp and mugaz?"
486     force_cpp=.false. ! default value
487     call getin_p("force_cpp",force_cpp)
488     write(*,*) " force_cpp = ",force_cpp
489
490     if (force_cpp) then
491       mugaz = -99999.
492       PRINT *,'MEAN MOLECULAR MASS in g mol-1 ?'
493       call getin_p("mugaz",mugaz)
494       IF (mugaz.eq.-99999.) THEN
495           PRINT *, "mugaz must be set if force_cpp = T"
496           STOP
497       ELSE
498           write(*,*) "mugaz=",mugaz
499       ENDIF
500       cpp = -99999.
501       PRINT *,'SPECIFIC HEAT CAPACITY in J K-1 kg-1 ?'
502       call getin_p("cpp",cpp)
503       IF (cpp.eq.-99999.) THEN
504           PRINT *, "cpp must be set if force_cpp = T"
505           STOP
506       ELSE
507           write(*,*) "cpp=",cpp
508       ENDIF
509!         else
510!           mugaz=8.314*1000./pr
511     endif ! of if (force_cpp)
512     
513     
514     call su_gases(nlayer,tracer)     
515     call calc_cpp_mugaz
516     
517     
518     PRINT*,'--------------------------------------------'
519     PRINT*
520     PRINT*
521  ELSE
522     write(*,*)
523     write(*,*) 'Cannot read file callphys.def. Is it here ?'
524     stop
525  ENDIF ! of IF(iscallphys)
526
527  PRINT*
528  PRINT*,'inifis: daysec',daysec
529  PRINT*
530  PRINT*,'inifis: The radiative transfer is computed:'
531  PRINT*,'           each ',iradia,' physical time-step'
532  PRINT*,'        or each ',iradia*dtphys,' seconds'
533  PRINT*
534  PRINT*,'inifis: Chemistry is computed:'
535  PRINT*,'           each ',ichim,' physical time-step'
536  PRINT*,'        or each ',ichim*dtphys,' seconds'
537  PRINT*
538
539!-----------------------------------------------------------------------
540!     Some more initialization:
541!     ------------------------
542
543  ! Initializations for comgeomfi_h
544  totarea=SSUM(ngrid,parea,1)
545  call planetwide_sumval(parea,totarea_planet)
546
547  !! those are defined in comdiurn_h.F90
548  IF (.not.ALLOCATED(sinlat)) ALLOCATE(sinlat(ngrid))
549  IF (.not.ALLOCATED(coslat)) ALLOCATE(coslat(ngrid))
550  IF (.not.ALLOCATED(sinlon)) ALLOCATE(sinlon(ngrid))
551  IF (.not.ALLOCATED(coslon)) ALLOCATE(coslon(ngrid))
552
553  DO ig=1,ngrid
554     sinlat(ig)=sin(plat(ig))
555     coslat(ig)=cos(plat(ig))
556     sinlon(ig)=sin(plon(ig))
557     coslon(ig)=cos(plon(ig))
558  ENDDO
559
560  ! initialize variables in radinc_h
561  call ini_radinc_h(nlayer)
562 
563  ! allocate "comsoil_h" arrays
564  call ini_comsoil_h(ngrid)
565     
566  END SUBROUTINE inifis
567
568END MODULE inifis_mod
Note: See TracBrowser for help on using the repository browser.