source: dynamico_lmdz/simple_physics/phyparam/param/mucorr.F @ 4191

Last change on this file since 4191 was 4176, checked in by dubos, 6 years ago

simple_physics : copy code from FH

File size: 2.6 KB
Line 
1      SUBROUTINE mucorr(npts,pdeclin, plat, pmu, pfract,phaut,prad)
2      IMPLICIT NONE
3
4c=======================================================================
5c
6c   Calcul of equivalent solar angle and and fraction of day whithout
7c   diurnal cycle.
8c
9c   parmeters :
10c   -----------
11c
12c      Input :
13c      -------
14c         npts             number of points
15c         pdeclin          solar declinaison
16c         plat(npts)        latitude
17c         phaut            hauteur typique de l'atmosphere
18c         prad             rayon planetaire
19c
20c      Output :
21c      --------
22c         pmu(npts)          equivalent cosinus of the solar angle
23c         pfract(npts)       fractionnal day
24c
25c=======================================================================
26
27c-----------------------------------------------------------------------
28c
29c    0. Declarations :
30c    -----------------
31
32c     Arguments :
33c     -----------
34      INTEGER npts
35      REAL plat(npts),pmu(npts), pfract(npts)
36      REAL phaut,prad,pdeclin
37c
38c     Local variables :
39c     -----------------
40      INTEGER j
41      REAL pi
42      REAL z,cz,sz,tz,phi,cphi,sphi,tphi
43      REAL ap,a,t,b
44      REAL alph
45
46c-----------------------------------------------------------------------
47
48      print*,'npts,pdeclin'
49      print*,npts,pdeclin
50      pi = 4. * atan(1.0)
51      print*,'PI=',pi
52      pi=2.*asin(1.)
53      print*,'PI=B',pi
54      z = pdeclin
55      cz = cos (z)
56      sz = sin (z)
57       print*,'cz,sz',cz,sz
58
59      DO 20 j = 1, npts
60
61         phi = plat(j)
62         cphi = cos(phi)
63         if (cphi.le.1.e-9) cphi=1.e-9
64         sphi = sin(phi)
65         tphi = sphi / cphi
66         b = cphi * cz
67         t = -tphi * sz / cz
68         a = 1.0 - t*t
69         ap = a
70   
71         IF(t.eq.0.) then
72            t=0.5*pi
73         ELSE
74            IF (a.lt.0.) a = 0.
75            t = sqrt(a) / t
76            IF (t.lt.0.) then
77               t = -atan (-t) + pi
78            ELSE
79               t = atan(t)
80            ENDIF
81         ENDIF
82   
83         pmu(j) = (sphi*sz*t) / pi + b*sin(t)/pi
84         pfract(j) = t / pi
85         IF (ap .lt.0.) then
86            pmu(j) = sphi * sz
87            pfract(j) = 1.0
88         ENDIF
89         IF (pmu(j).le.0.0) pmu(j) = 0.0
90         pmu(j) = pmu(j) / pfract(j)
91         IF (pmu(j).eq.0.) pfract(j) = 0.
92
93   20 CONTINUE
94
95c-----------------------------------------------------------------------
96c   correction de rotondite:
97c   ------------------------
98
99      alph=phaut/prad
100      DO 30 j=1,npts
101c !!!!!!
102         pmu(j)=sqrt(1224.*pmu(j)*pmu(j)+1.)/35.
103c    $          (sqrt(alph*alph*pmu(j)*pmu(j)+2.*alph+1.)-alph*pmu(j))
10430    CONTINUE
105
106      RETURN
107      END
Note: See TracBrowser for help on using the repository browser.