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