source: codes/icosagcm/trunk/src/radiation_mod.F @ 149

Last change on this file since 149 was 149, checked in by sdubey, 11 years ago
Added few new routines to read NC files and compute diagnostics to r145.
Few routines of dry physics including radiation module, surface process and convective adjustment in new routine phyparam.f90. dynetat to read start files for dynamics. check_conserve routine to compute conservation of quatities like mass, energy etc.etat0_heldsz.f90 for held-suarez test case initial conditions. new Key time_style=lmd or dcmip to use day_step, ndays like in LMDZ
File size: 27.4 KB
Line 
1        MODULE RADIATION
2         USE ICOSA
3         USE dimphys_mod
4!        USE PHY
5        contains
6
7!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8         SUBROUTINE zerophys(n,x)
9      IMPLICIT NONE
10      INTEGER n
11      REAL x(n)
12      INTEGER i
13
14      DO i=1,n
15         x(i)=0.
16      ENDDO
17      RETURN
18      END subroutine zerophys
19!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21         SUBROUTINE solarlong(pday,psollong)
22      IMPLICIT NONE
23c=======================================================================
24c
25c   Objet:
26c   ------
27c
28c      Calcul de la distance soleil-planete et de la declinaison
29c   en fonction du jour de l'annee.
30c
31c
32c   Methode:
33c   --------
34c
35c      Calcul complet de l'elipse
36c
37c   Interface:
38c   ----------
39c
40c      Uncommon comprenant les parametres orbitaux.
41c
42c   Arguments:
43c   ----------
44c
45c   Input:
46c   ------
47c   pday          jour de l'annee (le jour 0 correspondant a l'equinoxe)
48c   lwrite        clef logique pour sorties de controle
49c
50c   Output:
51c   -------
52c   pdist_sol     distance entre le soleil et la planete
53c                 ( en unite astronomique pour utiliser la constante 
54c                  solaire terrestre 1370 Wm-2 )
55c   pdecli        declinaison ( en radians )
56c
57c=======================================================================
58c-----------------------------------------------------------------------
59c   Declarations:
60c   -------------
61
62c arguments:
63c ----------
64
65      REAL pday,pdist_sol,pdecli,psollong
66      LOGICAL lwrite
67
68c Local:
69c ------
70
71      REAL zanom,xref,zx0,zdx,zteta,zz
72      INTEGER iter
73
74
75c-----------------------------------------------------------------------
76c calcul de l'angle polaire et de la distance au soleil :
77c -------------------------------------------------------
78
79c  calcul de l'zanomalie moyenne
80
81      zz=(pday-peri_day)/year_day
82      zanom=2.*pi*(zz-nint(zz))
83      xref=abs(zanom)
84
85c  resolution de lequation horaire  zx0 - e * sin (zx0) = xref
86c  methode de Newton
87
88      zx0=xref+e_elips*sin(xref)
89      DO 110 iter=1,10
90         zdx=-(zx0-e_elips*sin(zx0)-xref)/(1.-e_elips*cos(zx0))
91         if(abs(zdx).le.(1.e-7)) goto 120
92         zx0=zx0+zdx
93110   continue
94120   continue
95      zx0=zx0+zdx
96      if(zanom.lt.0.) zx0=-zx0
97
98c zteta est la longitude solaire
99
100      zteta=2.*atan(sqrt((1.+e_elips)/(1.-e_elips))*tan(zx0/2.))
101
102      psollong=zteta-timeperi
103
104      IF(psollong.LT.0.) psollong=psollong+2.*pi
105      IF(psollong.GT.2.*pi) psollong=psollong-2.*pi
106
107      RETURN
108      END SUBROUTINE solarlong
109
110!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111
112        SUBROUTINE orbite(pls,pdist_sol,pdecli)
113      IMPLICIT NONE
114c====================================================================
115c
116c   Objet:
117c   ------
118c
119c   Distance from sun and declimation as a function of the solar
120c   longitude Ls
121c
122c   Interface:
123c   ----------
124c   Arguments:
125c   ----------
126c
127c   Input:
128c   ------
129c   pls          Ls
130c
131c   Output:
132c   -------
133c   pdist_sol     Distance Sun-Planet in UA
134c   pdecli        declinaison ( en radians )
135c
136c====================================================================
137c-----------------------------------------------------------------------
138c   Declarations:
139c   -------------
140c arguments:
141c ----------
142
143      REAL pday,pdist_sol,pdecli,pls
144
145c-----------------------------------------------------------------------
146
147c Distance Sun-Planet
148
149      pdist_sol=p_elips/(1.+e_elips*cos(pls+timeperi))
150
151c Solar declination
152
153      pdecli= asin (sin(pls)*sin(obliquit*pi/180.))
154
155c-----------------------------------------------------------------------
156c   sorties eventuelles:
157c   ---------------------
158
159      END SUBROUTINE orbite
160!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162        SUBROUTINE iniorbit
163     $     (paphelie,pperiheli,pyear_day,pperi_day,pobliq)
164      IMPLICIT NONE
165c=====================================================================
166c
167c   Auteur:
168c   -------
169c     Frederic Hourdin      22 Fevrier 1991
170c
171c   Objet:
172c   ------
173c    Initialisation du sous programme orbite qui calcule
174c    a une date donnee de l'annee de duree year_day commencant
175c    a l'equinoxe de printemps et dont le perihelie se situe
176c    a la date peri_day, la distance au soleil et la declinaison.
177c
178c   Interface:
179c   ----------
180c   - Doit etre appele avant d'utiliser orbite.
181c   - initialise le common comorbit
182c
183c   Arguments:
184c   ----------
185c
186c   Input:
187c   ------
188c   aphelie       \   aphelie et perihelie de l'orbite
189c   periheli      /   en millions de kilometres.
190c
191c=====================================================================
192c   Declarations:
193c   -------------
194c   Arguments:
195c   ----------
196
197      REAL paphelie,pperiheli,pyear_day,pperi_day,pobliq
198
199c   Local:
200c   ------
201
202      REAL zxref,zanom,zz,zx0,zdx
203      INTEGER iter
204
205c'-----------------------------------------------------------------------
206
207      aphelie =paphelie
208      periheli=pperiheli
209      year_day=pyear_day
210      obliquit=pobliq
211      peri_day=pperi_day
212
213      PRINT*,'Perihelie en Mkm  ',periheli
214      PRINT*,'Aphelise  en Mkm  ',aphelie
215      PRINT*,'obliquite en degres  :',obliquit
216      unitastr=149.597927
217      e_elips=(aphelie-periheli)/(periheli+aphelie)
218      p_elips=0.5*(periheli+aphelie)*(1-e_elips*e_elips)/unitastr
219
220      print*,'e_elips',e_elips
221      print*,'p_elips',p_elips
222
223c-----------------------------------------------------------------------
224c calcul de l'angle polaire et de la distance au soleil :
225c -------------------------------------------------------
226
227c  calcul de l'zanomalie moyenne
228
229      zz=(year_day-pperi_day)/year_day
230      zanom=2.*pi*(zz-nint(zz))
231      zxref=abs(zanom)
232      PRINT*,'zanom  ',zanom
233
234c  resolution de lequation horaire  zx0 - e * sin (zx0) = zxref
235c  methode de Newton
236
237      zx0=zxref+e_elips*sin(zxref)
238      DO 110 iter=1,100
239         zdx=-(zx0-e_elips*sin(zx0)-zxref)/(1.-e_elips*cos(zx0))
240         if(abs(zdx).le.(1.e-12)) goto 120
241         zx0=zx0+zdx
242110   continue
243120   continue
244      zx0=zx0+zdx
245      if(zanom.lt.0.) zx0=-zx0
246      PRINT*,'zx0   ',zx0
247
248c zteta est la longitude solaire
249
250      timeperi=2.*atan(sqrt((1.+e_elips)/(1.-e_elips))*tan(zx0/2.))
251      PRINT*,'longitude solaire du perihelie timeperi = ',timeperi
252
253      RETURN
254      END SUBROUTINE iniorbit
255!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256
257      SUBROUTINE mucorr(npts,pdeclin, plat, pmu, pfract,phaut,prad)
258      IMPLICIT NONE
259
260c=======================================================================
261c
262c   Calcul of equivalent solar angle and and fraction of day whithout
263c   diurnal cycle.
264c
265c   parmeters :
266c   -----------
267c
268c      Input :
269c      -------
270c         npts             number of points
271c         pdeclin          solar declinaison
272c         plat(npts)        latitude
273c         phaut            hauteur typique de l'atmosphere
274c         prad             rayon planetaire '
275c
276c      Output :
277c      --------
278c         pmu(npts)          equivalent cosinus of the solar angle
279c         pfract(npts)       fractionnal day
280c
281c=======================================================================
282
283c-----------------------------------------------------------------------
284c
285c    0. Declarations :
286c    -----------------
287
288c     Arguments :
289c     -----------
290      INTEGER npts
291      REAL plat(npts),pmu(npts), pfract(npts)
292      REAL phaut,prad,pdeclin
293c
294c     Local variables :
295c     -----------------
296      INTEGER j,i,ij,ig
297      REAL pi
298      REAL z,cz,sz,tz,phi,cphi,sphi,tphi
299      REAL ap,a,t,b
300      REAL alph
301
302c-----------------------------------------------------------------------
303
304      !print*,'npts,pdeclin'
305      !print*,npts,pdeclin
306      pi = 4. * atan(1.0)
307      !print*,'PI=',pi
308      pi=2.*asin(1.)
309      z = pdeclin
310      cz = cos (z)
311      sz = sin (z)
312      !print*,'cz,sz',cz,sz
313
314!       DO j=jj_begin-offset,jj_end+offset
315!         DO i=ii_begin-offset,ii_end+offset
316!             ig=(j-1)*iim+i
317
318          DO ig=1,npts
319             phi = plat(ig)
320             cphi = cos(phi)
321           if (cphi.le.1.e-9) cphi=1.e-9
322            sphi = sin(phi)
323            tphi = sphi / cphi
324               b = cphi * cz
325               t = -tphi * sz / cz
326               a = 1.0 - t*t
327              ap = a
328             IF(t.eq.0.) then
329               t=0.5*pi
330             ELSE
331                IF (a.lt.0.) a = 0.
332                  t = sqrt(a) / t
333                IF (t.lt.0.) then
334                  t = -atan (-t) + pi
335                 ELSE
336                  t = atan(t)
337                ENDIF
338             ENDIF
339   
340            pmu(ig) = (sphi*sz*t) / pi + b*sin(t)/pi
341            pfract(ig) = t / pi
342            IF (ap .lt.0.) then
343             pmu(ig) = sphi * sz
344             pfract(ig) = 1.0
345            ENDIF
346            IF (pmu(ig).le.0.0) pmu(ig) = 0.0
347             pmu(ig) = pmu(ig) / pfract(ig)
348            IF (pmu(ig).eq.0.) pfract(ig) = 0.
349          ENDDO
350!       ENDDO
351c-----------------------------------------------------------------------
352c   correction de rotondite:
353c   ------------------------
354
355              alph=phaut/prad
356!       DO j=jj_begin-offset,jj_end+offset
357!         DO i=ii_begin-offset,ii_end+offset
358!                          ig=(j-1)*iim+i
359           DO ig = 1,npts
360            pmu(ig)=sqrt(1224.*pmu(ig)*pmu(ig)+1.)/35.
361
362c    $    (sqrt(alph*alph*pmu(ig)*pmu(ig)+2.*alph+1.)-alph*pmu(ig))
363         ENDDO
364!       ENDDO
365
366      RETURN
367      END SUBROUTINE mucorr
368!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
369       
370              SUBROUTINE sw(ngrid,nlayer,ldiurn,
371     $              coefvis,albedo,
372     $              plevel,ps_rad,pmu,pfract,psolarf0,
373     $              fsrfvis,dtsw,
374     $              lwrite)
375      IMPLICIT NONE
376c=======================================================================
377c
378c   Rayonnement solaire en atmosphere non diffusante avec un
379c   coefficient d'absoprption gris.
380c'
381c=======================================================================
382c
383c   declarations:
384c   -------------
385c   arguments:
386c   ----------
387c
388      INTEGER ngrid,nlayer,i,j,ij
389      REAL albedo(ngrid),coefvis
390      REAL pmu(ngrid),pfract(ngrid)
391      REAL plevel(ngrid,nlayer+1),ps_rad
392      REAL psolarf0
393      REAL fsrfvis(ngrid),dtsw(ngrid,nlayer)
394      LOGICAL lwrite,ldiurn
395c
396c   variables locales:
397c   ------------------
398c
399
400      REAL zalb(ngrid),zmu(ngrid),zfract(ngrid)
401      REAL zplev(ngrid,nlayer+1)
402      REAL zflux(ngrid),zdtsw(ngrid,nlayer)
403
404      INTEGER ig,l,nlevel,ncount,igout
405        INTEGER,DIMENSION(ngrid)::index
406      REAL ztrdir(ngrid,nlayer+1),ztrref(ngrid,nlayer+1)
407      REAL zfsrfref(ngrid)
408      REAL z1(ngrid)
409      REAL zu(ngrid,nlayer+1)
410      REAL tau0
411
412      EXTERNAL SSUM
413      EXTERNAL ismax
414      REAL ismax
415
416      LOGICAL firstcall
417      SAVE firstcall
418      DATA firstcall/.true./
419
420c-----------------------------------------------------------------------
421c   1. initialisations:
422c   -------------------
423
424
425 
426      IF (firstcall) THEN
427 
428      IF (ngrid.NE.ngrid) THEN
429         PRINT*,'STOP in inifis'
430         PRINT*,'Probleme de dimenesions :'
431         PRINT*,'ngrid     = ',ngrid
432         PRINT*,'ngrid   = ',ngrid
433         STOP
434      ENDIF
435 
436 
437      IF (nlayer.NE.llm) THEN
438         PRINT*,'STOP in inifis'
439         PRINT*,'Probleme de dimenesions :'
440         PRINT*,'nlayer     = ',nlayer
441         PRINT*,'llm   = ',llm
442         STOP
443      ENDIF
444 
445      ENDIF
446
447      nlevel=nlayer+1
448c-----------------------------------------------------------------------
449c   Definitions des tableaux locaux pour les points ensoleilles:
450c   ------------------------------------------------------------
451
452      IF (ldiurn) THEN
453         ncount=0
454        DO j=jj_begin-offset,jj_end+offset
455           DO i=ii_begin-offset,ii_end+offset
456            ig=(j-1)*iim+i
457            index(ig)=0
458           ENDDO
459         ENDDO
460         DO j=jj_begin-offset,jj_end+offset
461          DO i=ii_begin-offset,ii_end+offset
462             ig=(j-1)*iim+i
463           IF(pfract(ig).GT.1.e-6) THEN
464             ncount=ncount+1
465             index(ncount)=ig
466           ENDIF
467          ENDDO
468         ENDDO
469!       SARVESH CHANGED NCOUNT TO NGRID TO BE CONSISTENT ???
470
471         CALL monGATHER(ncount,zfract,pfract,index)
472         CALL monGATHER(ncount,zmu,pmu,index)
473         CALL monGATHER(ncount,zalb,albedo,index)
474         DO l=1,nlevel
475            CALL monGATHER(ncount,zplev(1,l),plevel(1,l),index)
476         ENDDO
477      ELSE
478         ncount=ngrid
479         zfract(:)=pfract(:)
480         zmu(:)=pmu(:)
481         zalb(:)=albedo(:)
482         zplev(:,:)=plevel(:,:)
483      ENDIF
484
485c-----------------------------------------------------------------------
486c   calcul des profondeurs optiques integres depuis p=0:
487c   ----------------------------------------------------
488
489      tau0=-.5*log(coefvis)
490
491c calcul de la partie homogene de l'opacite
492c'
493      tau0=tau0/ps_rad
494
495
496      DO l=1,nlayer+1
497        DO j=jj_begin-offset,jj_end+offset
498          DO i=ii_begin-offset,ii_end+offset
499            ig=(j-1)*iim+i
500            zu(ig,l)=tau0*zplev(ig,l)
501           ENDDO
502         ENDDO
503        ENDDO
504
505c-----------------------------------------------------------------------
506c   2. calcul de la transmission depuis le sommet de l'atmosphere:
507c'   -----------------------------------------------------------
508
509       DO l=1,nlevel
510         DO j=jj_begin-offset,jj_end+offset
511           DO i=ii_begin-offset,ii_end+offset
512            ig=(j-1)*iim+i
513            ztrdir(ig,l)=exp(-zu(ig,l)/zmu(ig))
514           ENDDO
515          ENDDO
516        ENDDO
517
518      IF (lwrite) THEN
519         igout=ncount/2+1
520         PRINT*
521         PRINT*,'Diagnostique des transmission dans le spectre solaire'
522         PRINT*,'zfract, zmu, zalb'
523         PRINT*,zfract(igout), zmu(igout), zalb(igout)
524         PRINT*,'Pression, quantite d abs, transmission'
525         DO l=1,nlayer+1
526            PRINT*,zplev(igout,l),zu(igout,l),ztrdir(igout,l)
527         ENDDO
528      ENDIF
529
530c-----------------------------------------------------------------------
531c   3. taux de chauffage, ray. solaire direct:
532c   ------------------------------------------
533
534      DO l=1,nlayer
535        DO j=jj_begin-offset,jj_end+offset
536          DO i=ii_begin-offset,ii_end+offset
537            ig=(j-1)*iim+i
538            zdtsw(ig,l)=g*psolarf0*zfract(ig)*zmu(ig)*
539     $                     (ztrdir(ig,l+1)-ztrdir(ig,l))/
540     $                     (cpp*(zplev(ig,l)-zplev(ig,l+1)))
541           ENDDO
542          ENDDO
543       ENDDO
544      IF (lwrite) THEN
545         PRINT*
546         PRINT*,'Diagnostique des taux de chauffage solaires:'
547         PRINT*,' 1 taux de chauffage lie au ray. solaire  direct'
548         DO l=1,nlayer
549            PRINT*,zdtsw(igout,l)
550         ENDDO
551      ENDIF
552
553
554c-----------------------------------------------------------------------
555c   4. calcul du flux solaire arrivant sur le sol:
556c   ----------------------------------------------
557
558       DO j=jj_begin-offset,jj_end+offset
559        DO i=ii_begin-offset,ii_end+offset
560          ig=(j-1)*iim+i
561          z1(ig)=zfract(ig)*zmu(ig)*psolarf0*ztrdir(ig,1)
562          zflux(ig)=(1.-zalb(ig))*z1(ig)
563          zfsrfref(ig)=    zalb(ig)*z1(ig)
564        ENDDO
565       ENDDO
566      IF (lwrite) THEN
567         PRINT*
568         PRINT*,'Diagnostique des taux de chauffage solaires:'
569         PRINT*,' 2 flux solaire net incident sur le sol'
570         PRINT*,zflux(igout)
571      ENDIF
572
573
574c-----------------------------------------------------------------------
575c   5.calcul des traansmissions depuis le sol, cas diffus:
576c   ------------------------------------------------------
577
578      DO l=1,nlevel
579       DO j=jj_begin-offset,jj_end+offset
580        DO i=ii_begin-offset,ii_end+offset
581          ig=(j-1)*iim+i
582            ztrref(ig,l)=exp(-(zu(ig,1)-zu(ig,l))*1.66)
583         ENDDO
584        ENDDO
585       ENDDO
586
587      IF (lwrite) THEN
588         PRINT*
589         PRINT*,'Diagnostique des taux de chauffage solaires'
590         PRINT*,' 3 transmission avec les sol'
591         PRINT*,'niveau     transmission'
592         DO l=1,nlevel
593            PRINT*,l,ztrref(igout,l)
594         ENDDO
595      ENDIF
596
597c-----------------------------------------------------------------------
598c   6.ajout a l'echauffement de la contribution du ray. sol. reflechit: 
599c' -------------------------------------------------------------------
600
601      DO l=1,nlayer
602       DO j=jj_begin-offset,jj_end+offset
603        DO i=ii_begin-offset,ii_end+offset
604          ig=(j-1)*iim+i
605            zdtsw(ig,l)=zdtsw(ig,l)+
606     $      g*zfsrfref(ig)*(ztrref(ig,l+1)-ztrref(ig,l))/
607     $      (cpp*(zplev(ig,l+1)-zplev(ig,l)))
608         ENDDO
609        ENDDO
610       ENDDO
611
612c-----------------------------------------------------------------------
613c   10. sorites eventuelles:
614c   ------------------------
615
616      IF (lwrite) THEN
617         PRINT*
618         PRINT*,'Diagnostique des taux de chauffage solaires:'
619         PRINT*,' 3 taux de chauffage total'
620         DO l=1,nlayer
621            PRINT*,zdtsw(igout,l)
622         ENDDO
623      ENDIF
624
625      IF (ldiurn) THEN
626         CALL zerophys(ngrid,fsrfvis)
627         CALL monscatter(ncount,fsrfvis,index,zflux)
628         CALL zerophys(ngrid*nlayer,dtsw)
629         DO l=1,nlayer
630            CALL monscatter(ncount,dtsw(1,l),index,zdtsw(1,l))
631         ENDDO
632      ELSE
633         !print*,'NOT DIURNE'
634         fsrfvis(:)=zflux(:)
635         dtsw(:,:)=zdtsw(:,:)
636      ENDIF
637
638      RETURN
639      END  SUBROUTINE sw
640!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
641      SUBROUTINE lw(ngrid,nlayer,coefir,emissiv,
642     $             pp,ps_rad,ptsurf,pt,
643     $             pfluxir,pdtlw,
644     $             lwrite)
645
646      IMPLICIT NONE
647c=======================================================================
648c
649c   calcul de l'evolution de la temperature sous l'effet du rayonnement
650c   infra-rouge.
651c   Pour simplifier, les transmissions sont precalculees et ne
652c   dependent que de l'altitude.
653c
654c   arguments:
655c   ----------
656c'
657c   entree:
658c   -------
659c      ngrid             nombres de points de la grille horizontale
660c      nlayer              nombre de couches
661c      ptsurf(ngrid)     temperature de la surface
662c      pt(ngrid,nlayer)    temperature des couches
663c      pp(ngrid,nlayer+1)  pression entre les couches
664c      lwrite            variable logique pour sorties
665c
666c   sortie:
667c   -------
668c      pdtlw(ngrid,nlayer) taux de refroidissement
669c      pfluxir(ngrid)    flux infrarouge sur le sol
670c
671c=======================================================================
672
673!c   declarations:
674!c   -------------
675!c   arguments:
676!c'   ----------
677
678      INTEGER ngrid,nlayer
679      REAL coefir,emissiv(ngrid),ps_rad
680      REAL ptsurf(ngrid),pt(ngrid,nlayer),pp(ngrid,nlayer+1)
681      REAL pdtlw(ngrid,nlayer),pfluxir(ngrid)
682      LOGICAL lwrite
683
684c   variables locales:
685c   ------------------
686
687      INTEGER nlevel,ilev,ig,i,il
688      REAL zplanck(ngridmx,nlayermx+1),zcoef
689      REAL zfluxup(ngridmx,nlayermx+1),zfluxdn(ngridmx,nlayermx+1)
690      REAL zflux(ngridmx,nlayermx+1)
691      REAL zlwtr1(ngridmx),zlwtr2(ngridmx)
692      REAL zup(ngridmx,nlayermx+1),zdup(ngridmx)
693      REAL stephan
694
695      LOGICAL lstrong
696      SAVE lstrong,stephan
697      DATA lstrong/.true./
698c-----------------------------------------------------------------------
699c   initialisations:
700c   ----------------
701
702      nlevel=nlayer+1
703      stephan=5.67e-08
704
705
706        pfluxir=0.0
707        pdtlw=0.0
708        !print*,"ngr,nlay,coefi",ngrid,nlayer,coefir
709c-----------------------------------------------------------------------
710c   2. calcul des quantites d'absorbants:
711c'   -------------------------------------
712
713c   absorption forte
714      IF(lstrong) THEN
715         DO ilev=1,nlevel
716            DO ig=1,ngrid
717               zup(ig,ilev)=pp(ig,ilev)*pp(ig,ilev)/(2.*g)
718            ENDDO
719         ENDDO
720         IF(lwrite) THEN
721            DO ilev=1,nlayer
722             PRINT*,' up(',ilev,')  =  ',zup(ngrid/2+1,ilev)
723            ENDDO
724         ENDIF
725         zcoef=-log(coefir)/sqrt(ps_rad*ps_rad/(2.*g))
726
727c   absorption faible
728      ELSE
729         DO ilev=1,nlevel
730            DO ig=1,ngrid
731               zup(ig,ilev)=pp(ig,ilev)
732            ENDDO
733         ENDDO
734         zcoef=-log(coefir)/ps_rad
735      ENDIF
736
737
738c-----------------------------------------------------------------------
739c   2. calcul de la fonction de corps noir:
740c   ---------------------------------------
741
742      DO ilev=1,nlayer
743         DO ig=1,ngrid
744            zplanck(ig,ilev)=pt(ig,ilev)*pt(ig,ilev)
745            zplanck(ig,ilev)=stephan*
746     $      zplanck(ig,ilev)*zplanck(ig,ilev)
747         ENDDO
748      ENDDO
749
750c-----------------------------------------------------------------------
751c   4. flux descendants:
752c   --------------------
753
754      DO ilev=1,nlayer
755         DO ig=1,ngrid
756            zfluxdn(ig,ilev)=0.
757                 ENDDO
758         DO ig=1,ngrid
759            zdup(ig)=zup(ig,ilev)-zup(ig,nlevel)
760         ENDDO
761         CALL lwtr(ngrid,zcoef,lstrong,zdup,zlwtr1)
762
763         DO il=nlayer,ilev,-1
764            zlwtr2(:)=zlwtr1(:)
765            DO ig=1,ngrid
766               zdup(ig)=zup(ig,ilev)-zup(ig,il)
767            ENDDO
768            CALL lwtr(ngrid,zcoef,lstrong,zdup,zlwtr1)
769            DO ig=1,ngrid
770               zfluxdn(ig,ilev)=zfluxdn(ig,ilev)+
771     $         zplanck(ig,il)*(zlwtr1(ig)-zlwtr2(ig))
772                        ENDDO
773                 ENDDO
774      ENDDO
775
776      DO ig=1,ngrid
777         zfluxdn(ig,nlevel)=0.
778         pfluxir(ig)=emissiv(ig)*zfluxdn(ig,1)
779      ENDDO
780
781      DO ig=1,ngrid
782         zfluxup(ig,1)=ptsurf(ig)*ptsurf(ig)
783         zfluxup(ig,1)=emissiv(ig)*stephan*zfluxup(ig,1)*zfluxup(ig,1)
784     $   +(1.-emissiv(ig))*zfluxdn(ig,1)
785      ENDDO
786
787c-----------------------------------------------------------------------
788c   3. flux montants:
789c   ------------------
790
791      DO ilev=1,nlayer
792         DO ig=1,ngrid
793            zdup(ig)=zup(ig,1)-zup(ig,ilev+1)
794         ENDDO
795         CALL lwtr(ngrid,zcoef,lstrong,zdup,zlwtr1)
796         DO ig=1,ngrid
797            zfluxup(ig,ilev+1)=zfluxup(ig,1)*zlwtr1(ig)
798                 ENDDO
799         DO il=1,ilev
800            zlwtr2(:)=zlwtr1(:)
801            DO ig=1,ngrid
802               zdup(ig)=zup(ig,il+1)-zup(ig,ilev+1)
803            ENDDO
804            CALL lwtr(ngrid,zcoef,lstrong,zdup,zlwtr1)
805            DO ig=1,ngrid
806               zfluxup(ig,ilev+1)=zfluxup(ig,ilev+1)+
807     $         zplanck(ig,il)*(zlwtr1(ig)-zlwtr2(ig))
808                        ENDDO
809         ENDDO
810
811      ENDDO
812
813c-----------------------------------------------------------------------
814c   5. calcul des flux nets:
815c   ------------------------
816
817      DO ilev=1,nlevel
818         DO ig=1,ngrid
819            zflux(ig,ilev)=zfluxup(ig,ilev)-zfluxdn(ig,ilev)
820                 ENDDO
821      ENDDO
822
823c-----------------------------------------------------------------------
824c   6. Calcul des taux de refroidissement:
825c   --------------------------------------
826   
827      DO ilev=1,nlayer
828         DO ig=1,ngrid
829            pdtlw(ig,ilev)=(zflux(ig,ilev+1)-zflux(ig,ilev))*
830     $           g/(cpp*(pp(ig,ilev+1)-pp(ig,ilev)))
831                 ENDDO
832      ENDDO
833
834c-----------------------------------------------------------------------
835c   10. sorties eventuelles:
836c   ------------------------
837
838      IF (lwrite) THEN
839
840         PRINT*
841         PRINT*,'Diagnostique rayonnement thermique'
842         PRINT*
843         PRINT*,'temperature     ',
844     $   'flux montant    flux desc.     taux de refroid.'
845         i=ngrid/2+1
846         WRITE(6,9000) ptsurf(i)
847         DO ilev=1,nlayer
848            WRITE(6,'(i4,4e18.4)') ilev,pt(i,ilev),
849     $      zfluxup(i,ilev),zfluxdn(i,ilev),pdtlw(i,ilev)
850                 ENDDO
851         WRITE(6,9000) zfluxup(i,nlevel),zfluxdn(i,nlevel)
852
853      ENDIF
854
855c-----------------------------------------------------------------------
856
857      RETURN
8589000  FORMAT(4e18.4)
859      END SUBROUTINE lw 
860!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
861
862              subroutine solang ( kgrid,psilon,pcolon,psilat,pcolat,
863     &                    ptim1,ptim2,ptim3,pmu0,pfract )
864      IMPLICIT NONE
865
866C
867C**** *LW*   - ORGANIZES THE LONGWAVE CALCULATIONS
868C
869C     PURPOSE.
870C     --------
871C          CALCULATES THE SOLAR ANGLE FOR ALL THE POINTS OF THE GRID
872C     ==== INPUTS  ===
873C
874C PSILON(KGRID)   : SINUS OF THE LONGITUDE
875C PCOLON(KGRID)   : COSINUS OF THE LONGITUDE
876C PSILAT(KGRID)   : SINUS OF THE LATITUDE
877C PCOLAT(KGRID)   : COSINUS OF THE LATITUDE
878C PTIM1           : SIN(DECLI)
879C PTIM2           : COS(DECLI)*COS(TIME)
880C PTIM3           : SIN(DECLI)*SIN(TIME)
881C
882C     ==== OUTPUTS ===
883C
884C PMU0 (KGRID)    : SOLAR ANGLE
885C PFRACT(KGRID)   : DAY FRACTION OF THE TIME INTERVAL
886C
887C        IMPLICIT ARGUMENTS :   NONE
888C        --------------------
889C
890C     METHOD.
891C     -------
892C
893C     EXTERNALS.
894C     ----------
895C
896C         NONE
897C
898C     REFERENCE.
899C     ----------
900C
901C         RADIATIVE PROCESSES IN METEOROLOGIE AND CLIMATOLOGIE
902C         PALTRIDGE AND PLATT
903C
904C     AUTHOR.
905C     -------
906C        FREDERIC HOURDIN
907C
908C     MODIFICATIONS.
909C     --------------
910C        ORIGINAL :90-01-14
911C                  92-02-14 CALCULATIONS DONE THE ENTIER GRID (J.Polcher)
912C-----------------------------------------------------------------------
913C
914C     ------------------------------------------------------------------
915
916C-----------------------------------------------------------------------
917C
918C*      0.1   ARGUMENTS
919C             ---------
920C
921      INTEGER kgrid
922      REAL ptim1,ptim2,ptim3
923      REAL psilon(kgrid),pcolon(kgrid),pmu0(kgrid),pfract(kgrid)
924      REAL psilat(kgrid), pcolat(kgrid)
925C
926      INTEGER jl,i,j
927      REAL ztim1,ztim2,ztim3
928C------------------------------------------------------------------------
929C------------------------------------------------------------------------
930C---------------------------------------------------------------------
931C
932C--------------------------------------------------------------------
933C
934C*     1.     INITIALISATION
935C             --------------
936C
937!!!!!! 100  CONTINUE
938C
939      DO j=jj_begin-offset,jj_end+offset
940       DO i=ii_begin-offset,ii_end+offset
941         jl=(j-1)*iim+i
942        pmu0(jl)=0.
943        pfract(jl)=0.
944       ENDDO
945      ENDDO
946!C
947!C*     1.1     COMPUTATION OF THE SOLAR ANGLE
948!C              ------------------------------
949!C
950       DO j=jj_begin-offset,jj_end+offset
951         DO i=ii_begin-offset,ii_end+offset
952          jl=(j-1)*iim+i
953         ztim1=psilat(jl)*ptim1
954         ztim2=pcolat(jl)*ptim2
955         ztim3=pcolat(jl)*ptim3
956         pmu0(jl)=ztim1+ztim2*pcolon(jl)+ztim3*psilon(jl)
957        ENDDO
958      ENDDO
959!C
960!C*     1.2      DISTINCTION BETWEEN DAY AND NIGHT
961!C               ---------------------------------
962!C
963       DO j=jj_begin-offset,jj_end+offset
964        DO i=ii_begin-offset,ii_end+offset
965          jl=(j-1)*iim+i     
966          IF (pmu0(jl).gt.0.) THEN
967            pfract(jl)=1.
968           ELSE
969            pmu0(jl)=0.
970            pfract(jl)=0.
971          ENDIF
972         ENDDO
973        ENDDO
974      RETURN
975      END SUBROUTINE solang
976!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
977
978              SUBROUTINE monGATHER(n,a,b,index)
979c
980      IMPLICIT NONE
981C
982      INTEGER n,ng,index(n),i,j,ij
983      REAL a(n),b(n)
984c
985      DO 100 i=1,n
986        a(i)=b(index(i))
987100   CONTINUE
988
989!       DO j=jj_begin-offset,jj_end+offset
990!         DO i=ii_begin-offset,ii_end+offset
991!          ij=(j-1)*iim+i
992!          a(ij)=b(index(ij))
993!c
994      RETURN
995      END  SUBROUTINE monGATHER
996!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997
998       subroutine monscatter(n,a,index,b)
999C
1000       implicit none
1001       integer N,INDEX(n),I
1002       real A(n),B(n)
1003c
1004c
1005       DO 100 I=1,N
1006          A(INDEX(I))=B(I)
1007100    CONTINUE
1008c
1009       return
1010       end SUBROUTINE monscatter
1011!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012
1013              SUBROUTINE lwtr(ngrid,coef,lstrong,dup,transm)
1014      IMPLICIT NONE
1015      INTEGER ngrid
1016      REAL coef
1017      LOGICAL lstrong
1018      REAL dup(ngrid),transm(ngrid)
1019      INTEGER ig
1020
1021      IF(lstrong) THEN
1022         DO ig=1,ngrid
1023            transm(ig)=exp(-coef*sqrt(dup(ig)))
1024         ENDDO
1025      ELSE
1026         DO ig=1,ngrid
1027            transm(ig)=exp(-coef*dup(ig))
1028         ENDDO
1029      ENDIF
1030      RETURN
1031      END subroutine lwtr 
1032!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1033       END MODULE RADIATION 
Note: See TracBrowser for help on using the repository browser.