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

Last change on this file since 2133 was 2133, checked in by jvatant, 6 years ago

Fic a bug in r2131 the writediagfi cannot be called
in RT routines because of the iradia it goes crazy with outputs freq ...
--JVO

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