Directory: | ./ |
---|---|
File: | phys/plevel.f90 |
Date: | 2022-01-11 19:19:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 26 | 27 | 96.3% |
Branches: | 33 | 44 | 75.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | |||
2 | ! $Header$ | ||
3 | |||
4 | ! ================================================================ | ||
5 | ! ================================================================ | ||
6 | 4320 | SUBROUTINE plevel(ilon, ilev, lnew, pgcm, pres, qgcm, qpres) | |
7 | ! ================================================================ | ||
8 | ! ================================================================ | ||
9 | USE netcdf | ||
10 | USE dimphy | ||
11 | USE phys_state_var_mod, ONLY: missing_val_nf90 | ||
12 | IMPLICIT NONE | ||
13 | |||
14 | ! ================================================================ | ||
15 | |||
16 | ! Interpoler des champs 3-D u, v et g du modele a un niveau de | ||
17 | ! pression donnee (pres) | ||
18 | |||
19 | ! INPUT: ilon ----- nombre de points | ||
20 | ! ilev ----- nombre de couches | ||
21 | ! lnew ----- true si on doit reinitialiser les poids | ||
22 | ! pgcm ----- pressions modeles | ||
23 | ! pres ----- pression vers laquelle on interpolle | ||
24 | ! Qgcm ----- champ GCM | ||
25 | ! Qpres ---- champ interpolle au niveau pres | ||
26 | |||
27 | ! ================================================================ | ||
28 | |||
29 | ! arguments : | ||
30 | ! ----------- | ||
31 | |||
32 | INTEGER ilon, ilev | ||
33 | LOGICAL lnew | ||
34 | |||
35 | REAL pgcm(ilon, ilev) | ||
36 | REAL qgcm(ilon, ilev) | ||
37 | REAL pres | ||
38 | REAL qpres(ilon) | ||
39 | |||
40 | ! local : | ||
41 | ! ------- | ||
42 | |||
43 | ! ym INTEGER lt(klon), lb(klon) | ||
44 | ! ym REAL ptop, pbot, aist(klon), aisb(klon) | ||
45 | |||
46 | ! ym save lt,lb,ptop,pbot,aist,aisb | ||
47 | INTEGER, ALLOCATABLE, SAVE, DIMENSION (:) :: lt, lb | ||
48 | REAL, ALLOCATABLE, SAVE, DIMENSION (:) :: aist, aisb | ||
49 | !$OMP THREADPRIVATE(lt,lb,aist,aisb) | ||
50 | REAL, SAVE :: ptop, pbot | ||
51 | !$OMP THREADPRIVATE(ptop, pbot) | ||
52 | LOGICAL, SAVE :: first = .TRUE. | ||
53 | !$OMP THREADPRIVATE(first) | ||
54 | INTEGER i, k | ||
55 | |||
56 | ! REAL missing_val | ||
57 | REAL :: missing_val | ||
58 | |||
59 | ! missing_val = nf90_fill_real | ||
60 | |||
61 | missing_val=missing_val_nf90 | ||
62 | |||
63 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4319 times.
|
4320 | IF (first) THEN |
64 |
10/20✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 times.
|
1 | ALLOCATE (lt(klon), lb(klon), aist(klon), aisb(klon)) |
65 | 1 | first = .FALSE. | |
66 | END IF | ||
67 | |||
68 | ! ===================================================================== | ||
69 |
2/2✓ Branch 0 taken 960 times.
✓ Branch 1 taken 3360 times.
|
4320 | IF (lnew) THEN |
70 | ! on r�nitialise les r�ndicages et les poids | ||
71 | ! ===================================================================== | ||
72 | |||
73 | |||
74 | ! Chercher les 2 couches les plus proches du niveau a obtenir | ||
75 | |||
76 | ! Eventuellement, faire l'extrapolation a partir des deux couches | ||
77 | ! les plus basses ou les deux couches les plus hautes: | ||
78 |
2/2✓ Branch 0 taken 954240 times.
✓ Branch 1 taken 960 times.
|
955200 | DO i = 1, klon |
79 |
2/2✓ Branch 0 taken 713080 times.
✓ Branch 1 taken 241160 times.
|
955200 | IF (abs(pres-pgcm(i,ilev))<abs(pres-pgcm(i,1))) THEN |
80 | 713080 | lt(i) = ilev ! 2 | |
81 | 713080 | lb(i) = ilev - 1 ! 1 | |
82 | ELSE | ||
83 | 241160 | lt(i) = 2 | |
84 | 241160 | lb(i) = 1 | |
85 | END IF | ||
86 | END DO | ||
87 |
2/2✓ Branch 0 taken 36960 times.
✓ Branch 1 taken 960 times.
|
37920 | DO k = 1, ilev - 1 |
88 |
2/2✓ Branch 0 taken 36738240 times.
✓ Branch 1 taken 36960 times.
|
36776160 | DO i = 1, klon |
89 | 36738240 | pbot = pgcm(i, k) | |
90 | 36738240 | ptop = pgcm(i, k+1) | |
91 |
4/4✓ Branch 0 taken 23979294 times.
✓ Branch 1 taken 12758946 times.
✓ Branch 2 taken 954240 times.
✓ Branch 3 taken 23025054 times.
|
36775200 | IF (ptop<=pres .AND. pbot>=pres) THEN |
92 | 954240 | lt(i) = k + 1 | |
93 | 954240 | lb(i) = k | |
94 | END IF | ||
95 | END DO | ||
96 | END DO | ||
97 | |||
98 | ! Interpolation lineaire: | ||
99 | |||
100 |
2/2✓ Branch 0 taken 954240 times.
✓ Branch 1 taken 960 times.
|
955200 | DO i = 1, klon |
101 | ! interpolation en logarithme de pression: | ||
102 | |||
103 | ! ... Modif . P. Le Van ( 20/01/98) .... | ||
104 | ! Modif Fr��ic Hourdin (3/01/02) | ||
105 | |||
106 | 954240 | aist(i) = log(pgcm(i,lb(i))/pres)/log(pgcm(i,lb(i))/pgcm(i,lt(i))) | |
107 | 955200 | aisb(i) = log(pres/pgcm(i,lt(i)))/log(pgcm(i,lb(i))/pgcm(i,lt(i))) | |
108 | END DO | ||
109 | |||
110 | |||
111 | END IF ! lnew | ||
112 | |||
113 | ! ====================================================================== | ||
114 | ! inteprollation | ||
115 | ! ====================================================================== | ||
116 | |||
117 |
2/2✓ Branch 0 taken 4294080 times.
✓ Branch 1 taken 4320 times.
|
4298400 | DO i = 1, klon |
118 | 4298400 | qpres(i) = qgcm(i, lb(i))*aisb(i) + qgcm(i, lt(i))*aist(i) | |
119 | END DO | ||
120 | |||
121 | ! Je mets les vents a zero quand je rencontre une montagne | ||
122 |
2/2✓ Branch 0 taken 4294080 times.
✓ Branch 1 taken 4320 times.
|
4298400 | DO i = 1, klon |
123 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4294080 times.
|
4298400 | IF (pgcm(i,1)<pres) THEN |
124 | ✗ | qpres(i) = missing_val | |
125 | END IF | ||
126 | END DO | ||
127 | |||
128 | |||
129 | 4320 | RETURN | |
130 | END SUBROUTINE plevel | ||
131 |