source: lmdz_wrf/WRFV3/dyn_em/module_avgflx_em.F @ 1

Last change on this file since 1 was 1, checked in by lfita, 10 years ago
  • -- --- Opening of the WRF+LMDZ coupling repository --- -- -

WRF: version v3.3
LMDZ: version v1818

More details in:

File size: 4.7 KB
Line 
1!WRF:MODEL_LAYER:DYNAMICS
2!
3MODULE module_avgflx_em
4
5  USE module_bc
6  USE module_model_constants
7  USE module_wrf_error
8
9CONTAINS
10
11!-------------------------------------------------------------------------------
12
13
14  subroutine zero_avgflx(avgflx_rum,avgflx_rvm,avgflx_wwm, &
15       & ids, ide, jds, jde, kds, kde,           &
16       & ims, ime, jms, jme, kms, kme,           &
17       & its, ite, jts, jte, kts, kte, do_cu,    &
18       & avgflx_cfu1,avgflx_cfd1,avgflx_dfu1,avgflx_efu1,avgflx_dfd1,avgflx_efd1 )
19
20    IMPLICIT NONE
21
22    INTEGER , INTENT(IN)        :: ids, ide, jds, jde, kds, kde,  &
23         ims, ime, jms, jme, kms, kme,  &
24         its, ite, jts, jte, kts, kte
25
26    LOGICAL, INTENT(IN) :: do_cu
27
28    REAL,     DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(INOUT) ::    &
29         avgflx_rum,avgflx_rvm,avgflx_wwm
30
31    REAL,     OPTIONAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(INOUT) ::    &
32         avgflx_cfu1,avgflx_cfd1,avgflx_dfu1,avgflx_efu1,avgflx_dfd1,avgflx_efd1
33
34    INTEGER :: i,j,k
35
36    DO j=jts,jte
37       DO k=kts,kte
38          DO i=its,ite
39             avgflx_rum(i,k,j) = 0.
40             avgflx_rvm(i,k,j) = 0.
41             avgflx_wwm(i,k,j) = 0.
42          end DO
43       end DO
44    end DO
45
46    if (do_cu .and. &
47         & present(avgflx_cfu1) .and. present(avgflx_cfd1) .and. present(avgflx_dfu1) &
48         & .and. present(avgflx_efu1) .and. present(avgflx_dfd1) .and. present(avgflx_efd1) ) then
49       DO j=jts,jte
50          DO k=kts,kte
51             DO i=its,ite
52                avgflx_cfu1(i,k,j) = 0.
53                avgflx_cfd1(i,k,j) = 0.
54                avgflx_dfu1(i,k,j) = 0.
55                avgflx_efu1(i,k,j) = 0.
56                avgflx_dfd1(i,k,j) = 0.
57                avgflx_efd1(i,k,j) = 0.
58             end DO
59          end DO
60       end DO
61    end if
62
63    return
64  end subroutine zero_avgflx
65
66  subroutine upd_avgflx(avgflx_count,avgflx_rum,avgflx_rvm,avgflx_wwm, &
67       &   ru_m, rv_m, ww_m, &
68       & ids, ide, jds, jde, kds, kde,           &
69       & ims, ime, jms, jme, kms, kme,           &
70       & its, ite, jts, jte, kts, kte, do_cu,    &
71       & cfu1,cfd1,dfu1,efu1,dfd1,efd1,          &
72       & avgflx_cfu1,avgflx_cfd1,avgflx_dfu1,avgflx_efu1,avgflx_dfd1,avgflx_efd1 )
73
74    IMPLICIT NONE
75
76    INTEGER , INTENT(IN)        :: ids, ide, jds, jde, kds, kde,  &
77         ims, ime, jms, jme, kms, kme,  &
78         its, ite, jts, jte, kts, kte
79
80    INTEGER , INTENT(IN)        :: avgflx_count
81    LOGICAL, INTENT(IN) :: do_cu
82    REAL, DIMENSION(ims:ime, kms:kme, jms:jme) , INTENT(IN) :: ru_m, &
83         rv_m, &
84         ww_m
85
86    REAL,     DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(INOUT) ::    &
87         avgflx_rum,avgflx_rvm,avgflx_wwm
88
89    REAL,     OPTIONAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(IN) ::    &
90         cfu1,cfd1,dfu1,efu1,dfd1,efd1
91    REAL,     OPTIONAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(INOUT) ::    &
92         avgflx_cfu1,avgflx_cfd1,avgflx_dfu1,avgflx_efu1,avgflx_dfd1,avgflx_efd1
93
94    INTEGER :: i,j,k
95    REAL :: local_count
96
97    local_count = real(avgflx_count)
98    DO j=jts,jte
99       DO k=kts,kte
100          DO i=its,ite
101             avgflx_rum(i,k,j) = (local_count*avgflx_rum(i,k,j) + ru_m(i,k,j))/(local_count+1.)
102             avgflx_rvm(i,k,j) = (local_count*avgflx_rvm(i,k,j) + rv_m(i,k,j))/(local_count+1.)
103             avgflx_wwm(i,k,j) = (local_count*avgflx_wwm(i,k,j) + ww_m(i,k,j))/(local_count+1.)
104          end DO
105       end DO
106    end DO
107
108    if (do_cu .and. &
109         & present(avgflx_cfu1) .and. present(avgflx_cfd1) .and. present(avgflx_dfu1) &
110         & .and. present(avgflx_efu1) .and. present(avgflx_dfd1) .and. present(avgflx_efd1) &
111         & .and. present(cfu1) .and. present(cfd1) .and. present(dfu1) &
112         & .and. present(efu1) .and. present(dfd1) .and. present(efd1) ) then
113       DO j=jts,jte
114          DO k=kts,kte
115             DO i=its,ite
116                avgflx_cfu1(i,k,j) = (local_count*avgflx_cfu1(i,k,j) + &
117                     & cfu1(i,k,j)) / (local_count+1.)
118                avgflx_cfd1(i,k,j) = (local_count*avgflx_cfd1(i,k,j) + &
119                     & cfd1(i,k,j)) / (local_count+1.)
120                avgflx_dfu1(i,k,j) = (local_count*avgflx_dfu1(i,k,j) + &
121                     & dfu1(i,k,j)) / (local_count+1.)
122                avgflx_efu1(i,k,j) = (local_count*avgflx_efu1(i,k,j) + &
123                     & efu1(i,k,j)) / (local_count+1.)
124                avgflx_dfd1(i,k,j) = (local_count*avgflx_dfd1(i,k,j) + &
125                     & dfd1(i,k,j)) / (local_count+1.)
126                avgflx_efd1(i,k,j) = (local_count*avgflx_efd1(i,k,j) + &
127                     & efd1(i,k,j)) / (local_count+1.)
128             end DO
129          end DO
130       end DO
131    end if
132
133    return
134  end subroutine upd_avgflx
135end MODULE module_avgflx_em
Note: See TracBrowser for help on using the repository browser.