source: trunk/LMDZ.MARS/libf/phymars/callradite_mod.F @ 3807

Last change on this file since 3807 was 3756, checked in by emillour, 6 weeks ago

Mars PCM:
Code tidying: turn aerave.F and suaer.F90 into modules and modernize
"blackl" routine (enforce "implicit none", make true constants "parameters")
and include it in the aerave module since it is only called there.
EM

File size: 24.1 KB
Line 
1      MODULE callradite_mod
2
3      IMPLICIT NONE
4
5      CONTAINS
6
7      SUBROUTINE callradite(icount,ngrid,nlayer,nq,zday,ls,pq,albedo,
8     $     emis,mu0,pplev,pplay,pt,tsurf,fract,dist_sol,igout,
9     $     dtlw,dtsw,fluxsurf_lw,fluxsurf_dn_sw,fluxsurf_up_sw,
10     $     fluxtop_lw,fluxtop_dn_sw,fluxtop_up_sw,
11     &     tau_pref_scenario,tau_pref_gcm,
12     &     tau,aerosol,dsodust,tauscaling,dust_rad_adjust,IRtoVIScoef,
13     $     taucloudtes,rdust,rice,nuice,riceco2,nuiceco2,co2ice,
14     $     rstormdust,rtopdust,totstormfract,clearatm,dsords,dsotop,
15     $     nohmons,clearsky,totcloudfrac)
16
17      use aeropacity_mod, only: aeropacity
18      use updatereffrad_mod, only: updatereffrad
19      use dimradmars_mod, only: ndomainsz, nflev, nsun, nir
20      use dimradmars_mod, only: naerkind, name_iaer,
21     &            iaer_dust_conrath,iaer_dust_doubleq,
22     &            iaer_dust_submicron, iaer_h2o_ice, iaer_co2_ice,
23     &            iaer_stormdust_doubleq,iaer_topdust_doubleq,flux_1AU
24      use yomlw_h, only: gcp, nlaylte
25      use comcstfi_h, only: g,cpp
26      use time_phylmdz_mod, only: daysec
27      use lwmain_mod, only: lwmain
28      use swmain_mod, only: swmain
29      use suaer_mod, only: suaer
30      use dust_param_mod, only: doubleq, active, submicron
31      use callkeys_mod, only: water, activice, rdstorm, topflows,
32     &                        co2clouds, activeco2ice
33      IMPLICIT NONE
34c=======================================================================
35c   subject:
36c   --------
37c   Subroutine designed to call the main canonic
38c   radiative transfer subroutine "lwmain" et "swmain"
39c   to compute radiative heating and cooling rate and
40c   radiative fluxes to the surface.
41c
42c   These calculations are only valid on the part of the atmosphere
43c   where Local Thermal Equilibrium (LTE) is verified. In practice
44c   the calculations are only performed for the first "nlaylte"
45c   parameters (nlaylte is calculated by subroutine "nlthermeq"
46c   and stored in module "yomlw_h").
47c
48c   The purpose of this subroutine is to:
49c      1) Make some initial calculation at first call
50c      2) Split the calculation in several sub-grid
51c        ("sub-domain") to save memory and
52c        be able run on a workstation at high resolution
53c        The sub-grid size is defined in dimradmars_mod
54c      3) Compute the 3D scattering parameters depending on the
55c        size distribution of the different tracers (added by JBM)
56c      4) call "lwmain" and "swmain"
57c
58c
59c   authors:   
60c   ------
61c   Francois Forget / Christophe Hourdin / J.-B. Madeleine (2009)
62c
63c
64c   3D scattering scheme user's guide (J.-B. Madeleine)
65c   ---------------------------------
66c
67c   This routine has been modified to take into account 3D, time
68c   dependent scattering properties of the aerosols.
69c---- The look-up tables that contain the scattering parameters
70c   of a given tracer, for different sizes, are read by SUAER.F90.
71c   The names of the corresponding ASCII files have to be set in
72c   this subroutine (file_id variable), and files must be in the
73c   directory specified in datafile_mod. Please make sure that the
74c   ASCII files are correctly written, and that the range
75c   of particle sizes is consistent with what you would expect.
76c---- SUAER.F90 is in charge of reading the ASCII files and averaging
77c   the scattering parameters in each GCM channel, using the three last
78c   equations of Forget et al. 1998 (GRL 25, No.7, p.1105-1108).
79c---- These look-up tables, loaded during the firstcall, are then
80c   constantly used by the subroutine "aeroptproperties.F" to compute,
81c   online, the 3D scattering parameters, based on the size distribution
82c   (reffrad and nueffrad) of the different tracers, in each grid box.
83c   These 3D size distributions are loaded by the "updatereffrad.F"
84c   subroutine. A log-normal distribution is then assumed in
85c   "aeroptproperties.F", along with a Gauss-Legendre integration.
86c---- The optical depth at the visible reference wavelength (set in
87c   SUAER.F90, after the file_id variable) is then computed by
88c   the subroutine "aeropacity.F", by using the size and spatial
89c   distribution of the corresponding tracer. This connection has to
90c   be implemented in "aeropacity.F" when adding a new tracer. To do so,
91c   one can use equation 2 of Forget et al. 1998 (Icarus 131, p.302-316).
92c---- The resulting variables "aerosol", "QVISsQREF3d", "omegaVIS3d" and
93c   "gVIS3d" (same in the infrared) are finally used by lwmain.F and
94c   swmain.F to solve the radiative transfer equation.
95c
96c   changes:
97c   -------
98c
99c   > SRL 7/2000
100c   
101c   This version has been modified to only calculate radiative tendencies
102c   over layers 1..NFLEV (set in dimradmars_mod).  Returns zero for higher
103c   layers, if any.
104c   In other routines, nlayer -> nflev.
105c   Routines affected: lwflux, lwi, lwmain, lwxb, lwxd, lwxn.
106c
107c   > J.-B. Madeleine 10W12
108c   This version uses the variable's splitting, which can be usefull
109c     when performing very high resolution simulation like LES.
110c
111c   ----------
112c   Here, solar band#1 is spectral interval between "long1vis" and "long2vis"
113c   set in dimradmars_mod
114c   Here, solar band#2 is spectral interval between "long2vis" and "long3vis"
115c   set in dimradmars_mod
116c
117c   input:
118c   -----
119c   icount                counter of call to subroutine physic by gcm
120c   ngrid                 number of gridpoint of horizontal grid
121c   nlayer                Number of layer
122c   nq                    Number of tracer
123c   ls                    Solar longitude (Ls) , radian
124c   zday                  Date (time since Ls=0, in martian days)
125c   pq(ngrid,nlayer,nq)   Advected fields
126c
127c   albedo (ngrid,2)      hemispheric surface albedo
128c                         albedo (i,1) : mean albedo for solar band#1
129c                                        (see below)
130c                         albedo (i,2) : mean albedo for solar band#2
131c                                        (see below)
132c   emis                  Thermal IR surface emissivity (no unit)
133c   mu0(ngrid)           cos of solar zenith angle
134c                           (=1 when sun at zenith)
135c   pplay(ngrid,nlayer)    pressure (Pa) in the middle of each layer
136c   pplev(ngrid,nlayer+1)  pressure (Pa) at boundaries of each layer
137c   pt(ngrid,nlayer)       atmospheric temperature in each layer (K)
138c   tsurf(ngrid)           surface temperature (K)
139c   fract(ngrid)         day fraction of the time interval
140c                          =1 during the full day ; =0 during the night
141c   declin                 latitude of subsolar point
142c   dist_sol               sun-Mars distance (AU)
143c   igout                  coordinate of analysed point for debugging
144c   reffrad(ngrid,nlayer,naerkind)  Aerosol effective radius
145c   nueffrad(ngrid,nlayer,naerkind) Aerosol effective variance
146
147c=======================================================================
148c
149c    Declarations :
150c    -------------
151c
152
153c-----------------------------------------------------------------------
154c    Input/Output
155c    ------------
156      INTEGER,INTENT(IN) :: icount       
157      INTEGER,INTENT(IN) :: ngrid,nlayer,nq
158      INTEGER,INTENT(IN) :: igout
159
160      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq)
161      REAL,INTENT(INOUT) :: tauscaling(ngrid) ! Conversion factor for
162                               ! qdust and Ndust
163      REAL,INTENT(INOUT) :: dust_rad_adjust(ngrid) ! Radiative adjustment
164                          ! factor for dust
165      REAL,INTENT(INOUT) :: IRtoVIScoef(ngrid) ! conversion coefficient to apply on
166                                               ! scenario absorption IR (9.3um) CDOD
167                                               ! = tau_pref_gcm_VIS / tau_pref_gcm_IR
168      REAL,INTENT(IN) :: albedo(ngrid,2),emis(ngrid)
169      REAL,INTENT(IN) :: ls,zday
170
171      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1),pplay(ngrid,nlayer)
172      REAL,INTENT(IN) :: pt(ngrid,nlayer)
173      REAL,INTENT(IN) :: tsurf(ngrid)
174      REAL,INTENT(IN) :: dist_sol,mu0(ngrid),fract(ngrid)
175      REAL,INTENT(OUT) :: dtlw(ngrid,nlayer) ! longwave (IR) heating rate (K/s)
176      REAL,INTENT(OUT) :: dtsw(ngrid,nlayer) ! shortwave (Solar) heating rate (K/s)
177      REAL,INTENT(OUT) :: fluxsurf_lw(ngrid) ! total LW (thermal IR) downward flux
178                                             ! (W.m-2) at the surface
179      REAL,INTENT(OUT) :: fluxtop_lw(ngrid) ! outgoing total LW (thermal IR)
180                                     ! upward flux (W.m-2) at the top of the atm.
181      REAL,INTENT(OUT) :: fluxsurf_dn_sw(ngrid,2) ! surface downward SW flux for
182                                      ! solar bands #1 and #2 (W.m-2)
183      REAL,INTENT(OUT) :: fluxsurf_up_sw(ngrid,2) ! surface upward SW flux for
184                                      ! solar bands #1 and #2 (W.m-2)
185      REAL,INTENT(OUT) :: fluxtop_dn_sw(ngrid,2) ! incoming downward SW flux for
186                                 ! solar bands #1 and #2 (W.m-2) at top of atm.
187      REAL,INTENT(OUT) :: fluxtop_up_sw(ngrid,2) ! outgoing upward SW flux for
188                                 ! solar bands #1 and #2 (W.m-2) at top of atm.
189      REAL,INTENT(OUT) :: tau_pref_scenario(ngrid) ! prescribed dust column
190                          ! visible opacity at odpref from scenario
191      REAL,INTENT(OUT) :: tau_pref_gcm(ngrid) ! computed dust column
192                          ! visible opacity at odpref in the GCM
193      REAL,INTENT(OUT) :: tau(ngrid,naerkind) ! Column visible optical depth
194                          ! for each aerosol
195      REAL,INTENT(OUT) :: taucloudtes(ngrid)! Cloud opacity at infrared
196                               !   reference wavelength using
197                               !   Qabs instead of Qext
198                               !   (direct comparison with TES)
199      REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! aerosol extinction
200                          ! optical depth at reference wavelength "longrefvis",
201                          ! set in dimradmars_h, for each kind of aerosol
202      REAL,INTENT(INOUT) :: dsodust(ngrid,nlayer)
203      REAL,INTENT(OUT) :: rdust(ngrid,nlayer)  ! Dust geometric mean radius (m)
204      REAL,INTENT(OUT) :: rice(ngrid,nlayer)   ! Ice geometric mean radius (m)
205      REAL,INTENT(OUT) :: nuice(ngrid,nlayer)  ! Estimated effective variance
206      double precision,INTENT(OUT) :: riceco2(ngrid,nlayer) ! CO2 ice mean radius(m)
207      REAL,INTENT(OUT) :: nuiceco2(ngrid,nlayer) ! Effective variance
208      REAL,INTENT(IN) :: co2ice(ngrid)           ! co2 ice surface layer (kg.m-2)
209
210c     rocket dust storm
211      LOGICAL,INTENT(IN) :: clearatm ! true for background dust
212      REAL,INTENT(IN) :: totstormfract(ngrid) ! dust storm mesh fraction
213      REAL,INTENT(OUT) :: rstormdust(ngrid,nlayer)  ! Storm dust geometric mean radius (m)
214      REAL,INTENT(OUT) :: dsords(ngrid,nlayer) ! density scaled opacity for rocket dust storm dust
215     
216c     entrainment by mountain top dust flows
217      LOGICAL, INTENT(IN) :: nohmons ! true for background dust
218      REAL,INTENT(OUT) :: rtopdust(ngrid,nlayer)  ! Topdust geometric mean radius (m)
219      REAL,INTENT(OUT) :: dsotop(ngrid,nlayer) ! density scaled opacity for topmons dust
220     
221c     sub-grid scale water ice clouds
222      LOGICAL,INTENT(IN) :: clearsky
223      REAL,INTENT(IN) :: totcloudfrac(ngrid)
224
225c
226c    Local variables :
227c    -----------------
228
229      INTEGER j,l,ig,n,ich
230      INTEGER aer_count,iaer
231      INTEGER jd,ig0,nd
232
233      real  cste_mars ! solar constant on Mars (Wm-2)
234      REAL ptlev(ngrid,nlayer+1)
235
236      INTEGER :: ndomain
237
238c     Thermal IR net radiative budget (W m-2)
239
240      real znetrad(ndomainsz,nflev)
241
242      real zfluxd_sw(ndomainsz,nflev+1,2)
243      real zfluxu_sw(ndomainsz,nflev+1,2)
244
245      REAL zplev(ndomainsz,nflev+1)
246      REAL zztlev(ndomainsz,nflev+1)
247      REAL zplay(ndomainsz,nflev)
248      REAL zt(ndomainsz,nflev)
249      REAL zaerosol(ndomainsz,nflev,naerkind)
250      REAL zalbedo(ndomainsz,2)
251      REAL zdp(ndomainsz,nflev)
252      REAL zdt0(ndomainsz)
253
254      REAL zzdtlw(ndomainsz,nflev)
255      REAL zzdtsw(ndomainsz,nflev)
256      REAL zzflux(ndomainsz,6)
257      real zrmuz
258
259      REAL :: zQVISsQREF3d(ndomainsz,nflev,nsun,naerkind)
260      REAL :: zomegaVIS3d(ndomainsz,nflev,nsun,naerkind)
261      REAL :: zgVIS3d(ndomainsz,nflev,nsun,naerkind)
262
263      REAL :: zQIRsQREF3d(ndomainsz,nflev,nir,naerkind)
264      REAL :: zomegaIR3d(ndomainsz,nflev,nir,naerkind)
265      REAL :: zgIR3d(ndomainsz,nflev,nir,naerkind)
266
267c     Aerosol size distribution
268      REAL :: reffrad(ngrid,nlayer,naerkind)
269      REAL :: nueffrad(ngrid,nlayer,naerkind)
270c     Aerosol optical properties
271      REAL :: QVISsQREF3d(ngrid,nlayer,nsun,naerkind)
272      REAL :: omegaVIS3d(ngrid,nlayer,nsun,naerkind)
273      REAL :: gVIS3d(ngrid,nlayer,nsun,naerkind)
274
275      REAL :: QIRsQREF3d(ngrid,nlayer,nir,naerkind)
276      REAL :: omegaIR3d(ngrid,nlayer,nir,naerkind)
277      REAL :: gIR3d(ngrid,nlayer,nir,naerkind)
278
279      REAL :: QREFvis3d(ngrid,nlayer,naerkind)
280      ! QREFvis3d : Extinction efficiency at the VISible reference wavelength
281      REAL :: QREFir3d(ngrid,nlayer,naerkind)
282      ! QREFir3d : Extinction efficiency at the InfraRed reference wavelength
283
284      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
285      REAL :: omegaREFir3d(ngrid,nlayer,naerkind)
286
287c   local saved variables
288c   ---------------------
289
290      real zco2   ! volume fraction of CO2 in Mars atmosphere
291!$OMP THREADPRIVATE(zco2)
292      DATA zco2/0.95/
293      SAVE zco2
294
295      LOGICAL firstcall
296!$OMP THREADPRIVATE(firstcall)
297      DATA firstcall/.true./
298      SAVE firstcall
299
300
301
302c----------------------------------------------------------------------
303
304c     Initialisation
305c     --------------
306
307! compute ndomain
308! AS: moved out of firstcall to allow nesting+evoluting domain
309! ------------------------------------------------------------
310      ndomain= (ngrid-1) / ndomainsz + 1
311
312      IF (firstcall) THEN
313
314         write(*,*) 'Splitting radiative calculations: ',
315     $              ' ngrid,ndomainsz,ndomain',
316     $                ngrid,ndomainsz,ndomain
317
318c        Assign a number to the different scatterers
319c        -------------------------------------------
320
321         iaer_dust_conrath=0
322         iaer_dust_doubleq=0
323         iaer_dust_submicron=0
324         iaer_h2o_ice=0
325         iaer_co2_ice=0
326         iaer_stormdust_doubleq=0
327         iaer_topdust_doubleq=0
328
329         aer_count=0
330         if (.NOT.active) then
331           do iaer=1,naerkind
332             if (name_iaer(iaer).eq."dust_conrath") then
333               iaer_dust_conrath = iaer
334               aer_count = aer_count + 1
335             endif
336           enddo
337         endif
338         if (doubleq.AND.active) then
339           do iaer=1,naerkind
340             if (name_iaer(iaer).eq."dust_doubleq") then
341               iaer_dust_doubleq = iaer
342               aer_count = aer_count + 1
343             endif
344           enddo
345         endif
346         if (submicron.AND.active) then
347           do iaer=1,naerkind
348             if (name_iaer(iaer).eq."dust_submicron") then
349               iaer_dust_submicron = iaer
350               aer_count = aer_count + 1
351             endif
352           enddo
353         endif
354         if (water.AND.activice) then
355           do iaer=1,naerkind
356             if (name_iaer(iaer).eq."h2o_ice") then
357               iaer_h2o_ice = iaer
358               aer_count = aer_count + 1
359             endif
360           enddo
361         endif
362         if (co2clouds.AND.activeco2ice) then
363           do iaer=1,naerkind
364             if (name_iaer(iaer).eq."co2_ice") then
365               iaer_co2_ice = iaer
366               aer_count = aer_count + 1
367             endif
368           enddo
369         endif
370         if (rdstorm.AND.active) then
371           do iaer=1,naerkind
372             if (name_iaer(iaer).eq."stormdust_doubleq") then
373               iaer_stormdust_doubleq = iaer
374               aer_count = aer_count + 1
375             endif
376           enddo
377         end if
378         if (topflows.AND.active) then
379           do iaer=1,naerkind
380             if (name_iaer(iaer).eq."topdust_doubleq") then
381               iaer_topdust_doubleq = iaer
382               aer_count = aer_count + 1
383             endif
384           enddo
385         end if
386
387c        Check that we identified all tracers:
388         if (aer_count.ne.naerkind) then
389           write(*,*) "callradite: found only ",aer_count," scatterers"
390           write(*,*) "               expected ",naerkind
391           write(*,*) "please make sure that the number of"
392           write(*,*) "scatterers in scatterers.h, the names"
393           write(*,*) "in callradite.F, and the flags in"
394           write(*,*) "callphys.def are all consistent!"
395           do iaer=1,naerkind
396             write(*,*)'      ',iaer,' ',trim(name_iaer(iaer))
397           enddo
398           call abort_physic("callradite","incoherent scatterers",1)
399         else
400           write(*,*) "callradite: found all scatterers, namely:"
401           do iaer=1,naerkind
402             write(*,*)'      ',iaer,' ',trim(name_iaer(iaer))
403           enddo
404         endif
405c        -------------------------------------------
406
407         gcp = g/cpp
408
409
410c        Loading the optical properties in external look-up tables:
411
412         CALL SUAER
413         
414!         CALL SULW ! this step is now done in ini_yomlw_h
415
416         if (ngrid .EQ. 1) then
417           if (ndomainsz .NE. 1) then
418             print*
419             print*,'ATTENTION !!!'
420             print*,'pour tourner en 1D, '
421             print*,'fixer ndomainsz=1 dans phymars/dimradmars_h'
422             print*
423             call exit(1)
424           endif
425         endif
426
427         firstcall=.false.
428      END IF
429
430c     Computing aerosol optical properties and opacity
431c     ------------------------------------------------
432c     Updating aerosol size distributions:
433      CALL updatereffrad(ngrid,nlayer,
434     &                rdust,rstormdust,rtopdust,rice,nuice,
435     &                reffrad,nueffrad, riceco2, nuiceco2,
436     &                pq,tauscaling,tau,pplay, pt)
437c     Computing 3D scattering parameters:
438      gVIS3d(:,:,:,:) = 0.
439      CALL aeroptproperties(ngrid,nlayer,reffrad,nueffrad,
440     &                      QVISsQREF3d,omegaVIS3d,gVIS3d,
441     &                      QIRsQREF3d,omegaIR3d,gIR3d,
442     &                      QREFvis3d,QREFir3d,
443     &                      omegaREFvis3d,omegaREFir3d)
444c     Computing aerosol optical depth in each layer:
445      CALL aeropacity(ngrid,nlayer,nq,zday,pplay,pplev,ls,
446     &    pq,pt,tauscaling,dust_rad_adjust,IRtoVIScoef,
447     &    tau_pref_scenario,tau_pref_gcm,tau,taucloudtes,
448     &    aerosol,dsodust,reffrad,
449     &    QREFvis3d,QREFir3d,omegaREFir3d,
450     &    totstormfract,clearatm,dsords,dsotop,
451     &    nohmons,clearsky,totcloudfrac)
452     
453c     Starting loop on sub-domain
454c     ----------------------------
455      zgVIS3d(:,:,:,:) = 0.
456      zfluxd_sw(:,:,:) = 0.
457      zfluxu_sw(:,:,:) = 0.
458      zQVISsQREF3d(:,:,:,:) = 0.
459      zomegaVIS3d(:,:,:,:) = 0.
460      DO jd=1,ndomain
461        ig0=(jd-1)*ndomainsz
462        if (jd.eq.ndomain) then
463         nd=ngrid-ig0
464        else
465         nd=ndomainsz
466        endif
467
468c       Spliting input variable in sub-domain input variables
469c       ---------------------------------------------------
470
471        do l=1,nlaylte
472         do ig = 1,nd
473           do iaer = 1, naerkind
474             do ich = 1, nsun
475               zQVISsQREF3d(ig,l,ich,iaer) =
476     &                           QVISsQREF3d(ig0+ig,l,ich,iaer)
477               zomegaVIS3d(ig,l,ich,iaer) =
478     &                           omegaVIS3d(ig0+ig,l,ich,iaer)
479               zgVIS3d(ig,l,ich,iaer) =
480     &                           gVIS3d(ig0+ig,l,ich,iaer)
481             enddo
482             do ich = 1, nir
483               zQIRsQREF3d(ig,l,ich,iaer) =
484     &                           QIRsQREF3d(ig0+ig,l,ich,iaer)
485               zomegaIR3d(ig,l,ich,iaer) =
486     &                           omegaIR3d(ig0+ig,l,ich,iaer)
487               zgIR3d(ig,l,ich,iaer) =
488     &                           gIR3d(ig0+ig,l,ich,iaer)
489             enddo
490           enddo
491         enddo
492        enddo
493        zplev(:,:) = 0.
494        do l=1,nlaylte+1
495         do ig = 1,nd
496          zplev(ig,l) = pplev(ig0+ig,l)
497         enddo
498        enddo
499        zdp(:,:) = 0.
500       
501        do l=1,nlaylte
502         do ig = 1,nd
503          zplay(ig,l) = pplay(ig0+ig,l)
504          zt(ig,l) = pt(ig0+ig,l)
505c         Thickness of each layer (Pa) :
506          zdp(ig,l)= pplev(ig0+ig,l) - pplev(ig0+ig,l+1)
507         enddo
508        enddo
509        zaerosol(:,:,:) = 0.
510        do n=1,naerkind
511          do l=1,nlaylte
512            do ig=1,nd
513              zaerosol(ig,l,n) = aerosol(ig0+ig,l,n)
514            enddo
515          enddo
516        enddo
517        zalbedo(:,:) = 0.
518        do j=1,2
519          do ig = 1,nd
520           zalbedo(ig,j) = albedo(ig0+ig,j)
521          enddo
522        enddo
523
524c       Intermediate  levels: (computing tlev)
525c       ---------------------------------------
526c       Extrapolation for the air temperature above the surface
527        DO ig=1,nd
528              zztlev(ig,1)=zt(ig,1)+
529     s        (zplev(ig,1)-zplay(ig,1))*
530     s        (zt(ig,1)-zt(ig,2))/(zplay(ig,1)-zplay(ig,2))
531
532              zdt0(ig) = tsurf(ig0+ig) - zztlev(ig,1)
533        ENDDO
534
535        DO l=2,nlaylte
536         DO ig=1, nd
537               zztlev(ig,l)=0.5*(zt(ig,l-1)+zt(ig,l))
538         ENDDO
539        ENDDO
540
541        DO ig=1, nd
542           zztlev(ig,nlaylte+1)=zt(ig,nlaylte)
543        ENDDO
544
545
546c       Longwave ("lw") radiative transfer (= thermal infrared)
547c       -------------------------------------------------------
548        call lwmain (ig0,icount,nd,nflev
549     .        ,zdp,zdt0,emis(ig0+1),zplev,zztlev,zt
550     .        ,zaerosol,zzdtlw
551     .        ,fluxsurf_lw(ig0+1),fluxtop_lw(ig0+1)
552     .        ,znetrad
553     &        ,zQIRsQREF3d,zomegaIR3d,zgIR3d
554     &        ,co2ice(ig0+1))
555
556c       Shortwave ("sw") radiative transfer (= solar radiation)
557c       -------------------------------------------------------
558c          Mars solar constant (W m-2)
559c          flux_1AU = 1370 W.m-2 is the solar constant at 1 AU.
560           cste_mars=flux_1AU/(dist_sol*dist_sol)
561           zzdtsw(:,:) = 0.
562           call swmain ( nd, nflev,
563     S     cste_mars, zalbedo,
564     S     mu0(ig0+1), zdp, zplev, zaerosol, fract(ig0+1),
565     S     zzdtsw, zfluxd_sw, zfluxu_sw,
566     &     zQVISsQREF3d,zomegaVIS3d,zgVIS3d)
567c       ------------------------------------------------------------
568c       Un-spliting output variable from sub-domain input variables
569c       ------------------------------------------------------------
570
571        do l=1,nlaylte
572         do ig = 1,nd
573          dtlw(ig0+ig,l) = zzdtlw(ig,l)
574          dtsw(ig0+ig,l) = zzdtsw(ig,l)
575         enddo
576        enddo
577
578        ptlev(:, :) = 0.
579        do l=1,nlaylte+1
580         do ig = 1,nd
581          ptlev(ig0+ig,l) = zztlev(ig,l)
582         enddo
583        enddo
584
585        ! copy SW fluxes at surface and TOA
586        do ig = 1,nd
587          ! surface downward SW flux
588          fluxsurf_dn_sw(ig0+ig,1) = zfluxd_sw(ig,1,1)
589          fluxsurf_dn_sw(ig0+ig,2) = zfluxd_sw(ig,1,2)
590          ! surface upward SW flux
591          fluxsurf_up_sw(ig0+ig,1) = zfluxu_sw(ig,1,1)
592          fluxsurf_up_sw(ig0+ig,2) = zfluxu_sw(ig,1,2)
593          ! downward SW flux at top of atmosphere
594          fluxtop_dn_sw(ig0+ig,1) = zfluxd_sw(ig,nlaylte+1,1)
595          fluxtop_dn_sw(ig0+ig,2) = zfluxd_sw(ig,nlaylte+1,2)         
596          ! upward SW flux at top of atmosphere
597          fluxtop_up_sw(ig0+ig,1) = zfluxu_sw(ig,nlaylte+1,1)
598          fluxtop_up_sw(ig0+ig,2) = zfluxu_sw(ig,nlaylte+1,2)
599        enddo
600
601      ENDDO         !   (boucle jd=1, ndomain)
602
603c     Zero tendencies for any remaining layers between nlaylte and nlayer
604      if (nlayer.gt.nlaylte) then
605         do l = nlaylte+1, nlayer
606            do ig = 1, ngrid
607               dtlw(ig, l) = 0.
608               dtsw(ig, l) = 0.
609            enddo
610         enddo
611      endif
612c     Output for debugging
613c     --------------------------------
614c     Write all nlayer layers, even though only nlaylte layers may have
615c     non-zero tendencies.
616
617c            PRINT*,'Diagnotique for the radiation'
618c            PRINT*,'albedo, emissiv, mu0,fract,fluxsurf_lw,fluxsurf_sw'
619c            PRINT*,albedo(igout,1),emis(igout),mu0(igout),
620c     s           fract(igout), fluxsurf_lw(igout),
621c     $     fluxsurf_dn_sw(igout,1)+fluxsurf_dn_sw(igout,2)
622c            PRINT*,'Tlay Tlev Play Plev dT/dt SW dT/dt LW (K/s)'
623c            PRINT*,'daysec',daysec
624c            DO l=1,nlayer
625c               PRINT*,pt(igout,l),ptlev(igout,l),
626c     s         pplay(igout,l),pplev(igout,l),
627c     s         dtsw(igout,l),dtlw(igout,l)
628c            ENDDO
629
630
631      END SUBROUTINE callradite
632
633      END MODULE callradite_mod
Note: See TracBrowser for help on using the repository browser.