1 | SUBROUTINE mucorr(npts,pdeclin, plat, pmu,pfract,phaut,prad,pflat) |
---|
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, pflat |
---|
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, rap |
---|
44 | REAL alph |
---|
45 | |
---|
46 | c----------------------------------------------------------------------- |
---|
47 | |
---|
48 | c----- SG: geometry adapted to a flattened planet (Feb2014) |
---|
49 | |
---|
50 | pi = 4. * atan(1.0) |
---|
51 | z = pdeclin |
---|
52 | cz = cos (z) |
---|
53 | sz = sin (z) |
---|
54 | rap = 1./((1.-pflat)**2) |
---|
55 | |
---|
56 | DO 20 j = 1, npts |
---|
57 | |
---|
58 | phi = plat(j) |
---|
59 | cphi = cos(phi) |
---|
60 | if (cphi.le.1.e-9) cphi=1.e-9 |
---|
61 | sphi = sin(phi) |
---|
62 | tphi = sphi / cphi |
---|
63 | b = cphi * cz |
---|
64 | t = -rap*tphi * sz / cz |
---|
65 | a = 1.0 - t*t |
---|
66 | ap = a |
---|
67 | |
---|
68 | IF(t.eq.0.) then |
---|
69 | tp=0.5*pi |
---|
70 | ELSE |
---|
71 | IF (a.lt.0.) a = 0. |
---|
72 | t = sqrt(a) / t |
---|
73 | IF (t.lt.0.) then |
---|
74 | tp = -atan (-t) + pi |
---|
75 | ELSE |
---|
76 | tp = atan(t) |
---|
77 | ENDIF |
---|
78 | ENDIF |
---|
79 | t = tp |
---|
80 | |
---|
81 | pmu(j) = (sphi*sz*t*rap) / pi + b*sin(t)/pi |
---|
82 | pfract(j) = t / pi |
---|
83 | IF (ap .lt.0.) then |
---|
84 | pmu(j) = sphi * sz*rap |
---|
85 | pfract(j) = 1.0 |
---|
86 | ENDIF |
---|
87 | IF (pmu(j).le.0.0) pmu(j) = 0.0 |
---|
88 | pmu(j) = pmu(j) / pfract(j) |
---|
89 | IF (pmu(j).eq.0.) pfract(j) = 0. |
---|
90 | |
---|
91 | pmu(j)=pmu(j)/SQRT(cphi**2 + (rap**2) * (sphi**2)) |
---|
92 | |
---|
93 | 20 CONTINUE |
---|
94 | |
---|
95 | c----------------------------------------------------------------------- |
---|
96 | c correction de rotondite: |
---|
97 | c ------------------------ |
---|
98 | |
---|
99 | ! condition added to avoid errors when rad is not set (e.g. 1D runs) |
---|
100 | IF (prad.ne.0) THEN |
---|
101 | |
---|
102 | alph=phaut/prad |
---|
103 | DO 30 j=1,npts |
---|
104 | c !!!!!! |
---|
105 | !!!!!!! AS: how generic is this??? |
---|
106 | pmu(j)=sqrt(1224.*pmu(j)*pmu(j)+1.)/35. |
---|
107 | c $ (sqrt(alph*alph*pmu(j)*pmu(j)+2.*alph+1.)-alph*pmu(j)) |
---|
108 | 30 CONTINUE |
---|
109 | |
---|
110 | ENDIF |
---|
111 | |
---|
112 | RETURN |
---|
113 | END |
---|