source: LMDZ6/branches/Amaury_dev/libf/dyn3dmem/friction_loc.f90 @ 5423

Last change on this file since 5423 was 5159, checked in by abarral, 5 months ago

Put dimensions.h and paramet.h into modules

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 5.4 KB
Line 
1! $Id: friction_p.F 1299 2010-01-20 14:27:21Z fairhead $
2
3!=======================================================================
4SUBROUTINE friction_loc(ucov, vcov, pdt)
5  USE parallel_lmdz
6  USE control_mod
7  USE IOIPSL
8  USE comconst_mod, ONLY: pi
9  USE lmdz_iniprint, ONLY: lunout, prt_level
10  USE lmdz_academic, ONLY: tetarappel, knewt_t, kfrict, knewt_g, clat4
11  USE lmdz_comgeom2
12
13  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
14  USE lmdz_paramet
15  IMPLICIT NONE
16
17  !=======================================================================
18
19  !   Friction for the Newtonian case:
20  !   --------------------------------
21  !    2 possibilities (depending on flag 'friction_type'
22  ! friction_type=0 : A friction that is only applied to the lowermost
23  !                   atmospheric layer
24  ! friction_type=1 : Friction applied on all atmospheric layer (but
25  !   (default)       with stronger magnitude near the surface; see
26  !                   iniacademic.F)
27  !=======================================================================
28
29
30
31
32  ! arguments:
33  REAL, INTENT(INOUT) :: ucov(iip1, jjb_u:jje_u, llm)
34  REAL, INTENT(INOUT) :: vcov(iip1, jjb_v:jje_v, llm)
35  REAL, INTENT(IN) :: pdt ! time step
36
37  ! local variables:
38
39  REAL :: modv(iip1, jjb_u:jje_u), zco, zsi
40  REAL :: vpn, vps, upoln, upols, vpols, vpoln
41  REAL :: u2(iip1, jjb_u:jje_u), v2(iip1, jjb_v:jje_v)
42  INTEGER :: i, j, l
43  REAL, PARAMETER :: cfric = 1.e-5
44  LOGICAL, SAVE :: firstcall = .TRUE.
45  INTEGER, SAVE :: friction_type = 1
46  CHARACTER(len = 20) :: modname = "friction_p"
47  CHARACTER(len = 80) :: abort_message
48  !$OMP THREADPRIVATE(firstcall,friction_type)
49  INTEGER :: jjb, jje
50
51  !$OMP SINGLE
52  IF (firstcall) THEN
53    ! set friction type
54    CALL getin("friction_type", friction_type)
55    IF ((friction_type<0).OR.(friction_type>1)) THEN
56      abort_message = "wrong friction type"
57      WRITE(lunout, *)'Friction: wrong friction type', friction_type
58      CALL abort_gcm(modname, abort_message, 42)
59    endif
60    firstcall = .FALSE.
61  ENDIF
62  !$OMP END SINGLE COPYPRIVATE(friction_type,firstcall)
63
64  IF (friction_type==0) then ! friction on first layer only
65    !$OMP SINGLE
66    !   calcul des composantes au carre du vent naturel
67    jjb = jj_begin
68    jje = jj_end + 1
69    IF (pole_sud) jje = jj_end
70
71    DO j = jjb, jje
72      DO i = 1, iip1
73        u2(i, j) = ucov(i, j, 1) * ucov(i, j, 1) * unscu2(i, j)
74      enddo
75    enddo
76
77    jjb = jj_begin - 1
78    jje = jj_end + 1
79    IF (pole_nord) jjb = jj_begin
80    IF (pole_sud) jje = jj_end - 1
81
82    DO j = jjb, jje
83      DO i = 1, iip1
84        v2(i, j) = vcov(i, j, 1) * vcov(i, j, 1) * unscv2(i, j)
85      enddo
86    enddo
87
88    !   calcul du module de V en dehors des poles
89    jjb = jj_begin
90    jje = jj_end + 1
91    IF (pole_nord) jjb = jj_begin + 1
92    IF (pole_sud) jje = jj_end - 1
93
94    DO j = jjb, jje
95      DO i = 2, iip1
96        modv(i, j) = sqrt(0.5 * (u2(i - 1, j) + u2(i, j) + v2(i, j - 1) + v2(i, j)))
97      enddo
98      modv(1, j) = modv(iip1, j)
99    enddo
100
101    !   les deux composantes du vent au pole sont obtenues comme
102    !   premiers modes de fourier de v pres du pole
103    IF (pole_nord) THEN
104      upoln = 0.
105      vpoln = 0.
106
107      DO i = 2, iip1
108        zco = cos(rlonv(i)) * (rlonu(i) - rlonu(i - 1))
109        zsi = sin(rlonv(i)) * (rlonu(i) - rlonu(i - 1))
110        vpn = vcov(i, 1, 1) / cv(i, 1)
111        upoln = upoln + zco * vpn
112        vpoln = vpoln + zsi * vpn
113      enddo
114      vpn = sqrt(upoln * upoln + vpoln * vpoln) / pi
115      DO i = 1, iip1
116        ! modv(i,1)=vpn
117        modv(i, 1) = modv(i, 2)
118      enddo
119
120    ENDIF
121
122    IF (pole_sud) THEN
123      upols = 0.
124      vpols = 0.
125      DO i = 2, iip1
126        zco = cos(rlonv(i)) * (rlonu(i) - rlonu(i - 1))
127        zsi = sin(rlonv(i)) * (rlonu(i) - rlonu(i - 1))
128        vps = vcov(i, jjm, 1) / cv(i, jjm)
129        upols = upols + zco * vps
130        vpols = vpols + zsi * vps
131      enddo
132      vps = sqrt(upols * upols + vpols * vpols) / pi
133      DO i = 1, iip1
134        ! modv(i,jjp1)=vps
135        modv(i, jjp1) = modv(i, jjm)
136      enddo
137
138    ENDIF
139
140    !   calcul du frottement au sol.
141
142    jjb = jj_begin
143    jje = jj_end
144    IF (pole_nord) jjb = jj_begin + 1
145    IF (pole_sud) jje = jj_end - 1
146
147    DO j = jjb, jje
148      DO i = 1, iim
149        ucov(i, j, 1) = ucov(i, j, 1) &
150                - cfric * pdt * 0.5 * (modv(i + 1, j) + modv(i, j)) * ucov(i, j, 1)
151      enddo
152      ucov(iip1, j, 1) = ucov(1, j, 1)
153    enddo
154
155    jjb = jj_begin
156    jje = jj_end
157    IF (pole_sud) jje = jj_end - 1
158
159    DO j = jjb, jje
160      DO i = 1, iip1
161        vcov(i, j, 1) = vcov(i, j, 1) &
162                - cfric * pdt * 0.5 * (modv(i, j + 1) + modv(i, j)) * vcov(i, j, 1)
163      enddo
164      vcov(iip1, j, 1) = vcov(1, j, 1)
165    enddo
166    !$OMP END SINGLE
167  ENDIF ! of if (friction_type.EQ.0)
168
169  IF (friction_type==1) THEN
170    ! for ucov()
171    jjb = jj_begin
172    jje = jj_end
173    IF (pole_nord) jjb = jj_begin + 1
174    IF (pole_sud) jje = jj_end - 1
175
176    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
177    DO l = 1, llm
178      ucov(1:iip1, jjb:jje, l) = ucov(1:iip1, jjb:jje, l) * &
179              (1. - pdt * kfrict(l))
180    enddo
181    !$OMP END DO NOWAIT
182
183    ! for vcoc()
184    jjb = jj_begin
185    jje = jj_end
186    IF (pole_sud) jje = jj_end - 1
187
188    !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
189    DO l = 1, llm
190      vcov(1:iip1, jjb:jje, l) = vcov(1:iip1, jjb:jje, l) * &
191              (1. - pdt * kfrict(l))
192    enddo
193    !$OMP END DO
194  ENDIF ! of if (friction_type.EQ.1)
195
196END SUBROUTINE friction_loc
197
Note: See TracBrowser for help on using the repository browser.