1 | SUBROUTINE DSOLVER(NL,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP, |
---|
2 | * BSURF,RSF,XK1,XK2) |
---|
3 | |
---|
4 | C GCM2.0 Feb 2003 |
---|
5 | C |
---|
6 | C DOUBLE PRECISION VERSION OF SOLVER |
---|
7 | |
---|
8 | PARAMETER (NMAX=201) |
---|
9 | IMPLICIT REAL*8 (A-H,O-Z) |
---|
10 | DIMENSION GAMA(NL),CP(NL),CM(NL),CPM1(NL),CMM1(NL),XK1(NL), |
---|
11 | * XK2(NL),E1(NL),E2(NL),E3(NL),E4(NL) |
---|
12 | DIMENSION AF(NMAX),BF(NMAX),CF(NMAX),DF(NMAX),XK(NMAX) |
---|
13 | C********************************************************* |
---|
14 | C* THIS SUBROUTINE SOLVES FOR THE COEFFICIENTS OF THE * |
---|
15 | C* TWO STREAM SOLUTION FOR GENERAL BOUNDARY CONDITIONS * |
---|
16 | C* NO ASSUMPTION OF THE DEPENDENCE ON OPTICAL DEPTH OF * |
---|
17 | C* C-PLUS OR C-MINUS HAS BEEN MADE. * |
---|
18 | C* NL = NUMBER OF LAYERS IN THE MODEL * |
---|
19 | C* CP = C-PLUS EVALUATED AT TAO=0 (TOP) * |
---|
20 | C* CM = C-MINUS EVALUATED AT TAO=0 (TOP) * |
---|
21 | C* CPM1 = C-PLUS EVALUATED AT TAOSTAR (BOTTOM) * |
---|
22 | C* CMM1 = C-MINUS EVALUATED AT TAOSTAR (BOTTOM) * |
---|
23 | C* EP = EXP(LAMDA*DTAU) * |
---|
24 | C* EM = 1/EP * |
---|
25 | C* E1 = EP + GAMA *EM * |
---|
26 | C* E2 = EP - GAMA *EM * |
---|
27 | C* E3 = GAMA*EP + EM * |
---|
28 | C* E4 = GAMA*EP - EM * |
---|
29 | C* BTOP = THE DIFFUSE RADIATION INTO THE MODEL AT TOP * |
---|
30 | C* BSURF = THE DIFFUSE RADIATION INTO THE MODEL AT * |
---|
31 | C* THE BOTTOM: INCLUDES EMMISION AND REFLECTION * |
---|
32 | C* OF THE UNATTENUATED PORTION OF THE DIRECT * |
---|
33 | C* BEAM. BSTAR+RSF*FO*EXP(-TAOSTAR/U0) * |
---|
34 | C* RSF = REFLECTIVITY OF THE SURFACE * |
---|
35 | C* XK1 = COEFFICIENT OF THE POSITIVE EXP TERM * |
---|
36 | C* XK2 = COEFFICIENT OF THE NEGATIVE EXP TERM * |
---|
37 | C********************************************************* |
---|
38 | |
---|
39 | C======================================================================C |
---|
40 | |
---|
41 | L=2*NL |
---|
42 | |
---|
43 | C ************MIXED COEFFICENTS********** |
---|
44 | C THIS VERSION AVOIDS SINGULARITIES ASSOC. |
---|
45 | C WITH W0=0 BY SOLVING FOR XK1+XK2, AND XK1-XK2. |
---|
46 | |
---|
47 | AF(1) = 0.0 |
---|
48 | BF(1) = GAMA(1)+1. |
---|
49 | CF(1) = GAMA(1)-1. |
---|
50 | DF(1) = BTOP-CMM1(1) |
---|
51 | N = 0 |
---|
52 | LM2 = L-2 |
---|
53 | |
---|
54 | C EVEN TERMS |
---|
55 | |
---|
56 | DO I=2,LM2,2 |
---|
57 | N = N+1 |
---|
58 | AF(I) = (E1(N)+E3(N))*(GAMA(N+1)-1.) |
---|
59 | BF(I) = (E2(N)+E4(N))*(GAMA(N+1)-1.) |
---|
60 | CF(I) = 2.0*(1.-GAMA(N+1)**2) |
---|
61 | DF(I) = (GAMA(N+1)-1.) * (CPM1(N+1) - CP(N)) + |
---|
62 | * (1.-GAMA(N+1))* (CM(N)-CMM1(N+1)) |
---|
63 | END DO |
---|
64 | |
---|
65 | N = 0 |
---|
66 | LM1 = L-1 |
---|
67 | DO I=3,LM1,2 |
---|
68 | N = N+1 |
---|
69 | AF(I) = 2.0*(1.-GAMA(N)**2) |
---|
70 | BF(I) = (E1(N)-E3(N))*(1.+GAMA(N+1)) |
---|
71 | CF(I) = (E1(N)+E3(N))*(GAMA(N+1)-1.) |
---|
72 | DF(I) = E3(N)*(CPM1(N+1) - CP(N)) + E1(N)*(CM(N) - CMM1(N+1)) |
---|
73 | END DO |
---|
74 | |
---|
75 | AF(L) = E1(NL)-RSF*E3(NL) |
---|
76 | BF(L) = E2(NL)-RSF*E4(NL) |
---|
77 | CF(L) = 0.0 |
---|
78 | DF(L) = BSURF-CP(NL)+RSF*CM(NL) |
---|
79 | |
---|
80 | CALL DTRIDGL(L,AF,BF,CF,DF,XK) |
---|
81 | |
---|
82 | C ***UNMIX THE COEFFICIENTS**** |
---|
83 | |
---|
84 | DO 28 N=1,NL |
---|
85 | XK1(N) = XK(2*N-1)+XK(2*N) |
---|
86 | XK2(N) = XK(2*N-1)-XK(2*N) |
---|
87 | |
---|
88 | C NOW TEST TO SEE IF XK2 IS REALLY ZERO TO THE LIMIT OF THE |
---|
89 | C MACHINE ACCURACY = 1 .E -30 |
---|
90 | C XK2 IS THE COEFFICEINT OF THE GROWING EXPONENTIAL AND MUST |
---|
91 | C BE TREATED CAREFULLY |
---|
92 | |
---|
93 | IF(XK2(N) .EQ. 0.0) GO TO 28 |
---|
94 | c IF (ABS (XK2(N)/XK(2*N-1)) .LT. 1.E-30) XK2(N)=0.0 |
---|
95 | IF (ABS (XK2(N)/(XK(2*N-1)+1.e-20)) .LT. 1.E-30) XK2(N)=0.0 ! For debug only (with -Ktrap=fp option) |
---|
96 | |
---|
97 | 28 CONTINUE |
---|
98 | |
---|
99 | RETURN |
---|
100 | END |
---|