1 | MODULE distrib_icosa_lmdz_mod |
---|
2 | |
---|
3 | TYPE t_distrib_physic |
---|
4 | INTEGER,POINTER :: index(:) ! list of index used for thread entering in lmdz physic |
---|
5 | INTEGER :: nindex ! number of index used |
---|
6 | INTEGER :: domain_ind ! index of the related domain |
---|
7 | END TYPE t_distrib_physic |
---|
8 | |
---|
9 | INTEGER, SAVE :: ndomain_distrib ! number of domain needed for thread data |
---|
10 | !$OMP THREADPRIVATE(ndomain_distrib) |
---|
11 | |
---|
12 | TYPE(t_distrib_physic),ALLOCATABLE, SAVE :: distrib_physic(:) |
---|
13 | !$OMP THREADPRIVATE(distrib_physic) |
---|
14 | |
---|
15 | |
---|
16 | INTERFACE transfer_icosa_to_lmdz |
---|
17 | MODULE PROCEDURE transfer_icosa_to_lmdz1d,transfer_icosa_to_lmdz2d,transfer_icosa_to_lmdz3d |
---|
18 | END INTERFACE transfer_icosa_to_lmdz |
---|
19 | |
---|
20 | INTERFACE transfer_lmdz_to_icosa |
---|
21 | MODULE PROCEDURE transfer_lmdz1d_to_icosa,transfer_lmdz2d_to_icosa,transfer_lmdz3d_to_icosa |
---|
22 | END INTERFACE transfer_lmdz_to_icosa |
---|
23 | |
---|
24 | CONTAINS |
---|
25 | |
---|
26 | |
---|
27 | SUBROUTINE init_distrib_icosa_lmdz |
---|
28 | USE mod_phys_lmdz_omp_data, ONLY: klon_omp_begin, klon_omp_end |
---|
29 | USE domain_mod |
---|
30 | USE dimensions |
---|
31 | IMPLICIT NONE |
---|
32 | INTEGER :: pos,pos_tmp,nindex |
---|
33 | INTEGER :: ind, i,j,ij |
---|
34 | |
---|
35 | ALLOCATE(distrib_physic(ndomain)) |
---|
36 | |
---|
37 | ndomain_distrib=0 |
---|
38 | pos=0 |
---|
39 | DO ind=1,ndomain |
---|
40 | CALL swap_dimensions(ind) |
---|
41 | |
---|
42 | ! first guess to determine number of indices for this domain |
---|
43 | pos_tmp=pos |
---|
44 | nindex=0 |
---|
45 | DO j=jj_begin,jj_end |
---|
46 | DO i=ii_begin,ii_end |
---|
47 | IF (domain(ind)%own(i,j)) THEN |
---|
48 | pos_tmp=pos_tmp+1 |
---|
49 | IF (pos_tmp >= klon_omp_begin .AND. pos_tmp <= klon_omp_end) nindex=nindex+1 |
---|
50 | ENDIF |
---|
51 | ENDDO |
---|
52 | ENDDO |
---|
53 | |
---|
54 | ! fill the index array |
---|
55 | |
---|
56 | IF (nindex>0) THEN |
---|
57 | ndomain_distrib=ndomain_distrib+1 |
---|
58 | ALLOCATE(distrib_physic(ndomain_distrib)%index(nindex)) |
---|
59 | distrib_physic(ndomain_distrib)%nindex=nindex |
---|
60 | distrib_physic(ndomain_distrib)%domain_ind=ind |
---|
61 | |
---|
62 | nindex=0 |
---|
63 | DO j=jj_begin,jj_end |
---|
64 | DO i=ii_begin,ii_end |
---|
65 | ij=(j-1)*iim+i |
---|
66 | IF (domain(ind)%own(i,j)) THEN |
---|
67 | pos=pos+1 |
---|
68 | IF (pos >= klon_omp_begin .AND. pos <= klon_omp_end) THEN |
---|
69 | nindex=nindex+1 |
---|
70 | distrib_physic(ndomain_distrib)%index(nindex)=ij |
---|
71 | ENDIF |
---|
72 | ENDIF |
---|
73 | ENDDO |
---|
74 | ENDDO |
---|
75 | ELSE |
---|
76 | pos=pos_tmp |
---|
77 | ENDIF |
---|
78 | |
---|
79 | ENDDO |
---|
80 | |
---|
81 | END SUBROUTINE init_distrib_icosa_lmdz |
---|
82 | |
---|
83 | SUBROUTINE transfer_icosa_to_lmdz1d(f_field_icosa, field_lmdz) |
---|
84 | USE field_mod |
---|
85 | IMPLICIT NONE |
---|
86 | TYPE(t_field),POINTER :: f_field_icosa(:) |
---|
87 | REAL(rstd) :: field_lmdz(:) |
---|
88 | REAL(rstd),POINTER :: field_icosa(:) |
---|
89 | INTEGER :: pos, nindex,ind,i |
---|
90 | INTEGER,POINTER :: index(:) |
---|
91 | |
---|
92 | pos=0 |
---|
93 | DO ind=1,ndomain_distrib |
---|
94 | field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind) |
---|
95 | index=>distrib_physic(ind)%index |
---|
96 | nindex=distrib_physic(ind)%nindex |
---|
97 | DO i=1,nindex |
---|
98 | pos=pos+1 |
---|
99 | field_lmdz(pos)=field_icosa(index(i)) |
---|
100 | ENDDO |
---|
101 | ENDDO |
---|
102 | |
---|
103 | END SUBROUTINE transfer_icosa_to_lmdz1d |
---|
104 | |
---|
105 | SUBROUTINE transfer_icosa_to_lmdz2d(f_field_icosa, field_lmdz) |
---|
106 | USE field_mod |
---|
107 | IMPLICIT NONE |
---|
108 | TYPE(t_field),POINTER :: f_field_icosa(:) |
---|
109 | REAL(rstd) :: field_lmdz(:,:) |
---|
110 | |
---|
111 | REAL(rstd),POINTER :: field_icosa(:,:) |
---|
112 | INTEGER :: pos, nindex,ind,i |
---|
113 | INTEGER,POINTER :: index(:) |
---|
114 | INTEGER :: l |
---|
115 | |
---|
116 | DO l=1,size(field_lmdz,2) |
---|
117 | pos=0 |
---|
118 | DO ind=1,ndomain_distrib |
---|
119 | field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind) |
---|
120 | index=>distrib_physic(ind)%index |
---|
121 | nindex=distrib_physic(ind)%nindex |
---|
122 | DO i=1,nindex |
---|
123 | pos=pos+1 |
---|
124 | field_lmdz(pos,l)=field_icosa(index(i),l) |
---|
125 | ENDDO |
---|
126 | ENDDO |
---|
127 | ENDDO |
---|
128 | |
---|
129 | END SUBROUTINE transfer_icosa_to_lmdz2d |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | SUBROUTINE transfer_icosa_to_lmdz3d(f_field_icosa, field_lmdz) |
---|
134 | USE field_mod |
---|
135 | IMPLICIT NONE |
---|
136 | TYPE(t_field),POINTER :: f_field_icosa(:) |
---|
137 | REAL(rstd) :: field_lmdz(:,:,:) |
---|
138 | REAL(rstd),POINTER :: field_icosa(:,:,:) |
---|
139 | INTEGER :: pos, nindex,ind,i |
---|
140 | INTEGER,POINTER :: index(:) |
---|
141 | INTEGER :: l,q |
---|
142 | |
---|
143 | DO q=1,size(field_lmdz,3) |
---|
144 | DO l=1,size(field_lmdz,2) |
---|
145 | pos=0 |
---|
146 | DO ind=1,ndomain_distrib |
---|
147 | field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind) |
---|
148 | index=>distrib_physic(ind)%index |
---|
149 | nindex=distrib_physic(ind)%nindex |
---|
150 | DO i=1,nindex |
---|
151 | pos=pos+1 |
---|
152 | field_lmdz(pos,l,q)=field_icosa(index(i),l,q) |
---|
153 | ENDDO |
---|
154 | ENDDO |
---|
155 | ENDDO |
---|
156 | ENDDO |
---|
157 | |
---|
158 | END SUBROUTINE transfer_icosa_to_lmdz3d |
---|
159 | |
---|
160 | SUBROUTINE transfer_lmdz1d_to_icosa(field_lmdz,f_field_icosa) |
---|
161 | USE field_mod |
---|
162 | IMPLICIT NONE |
---|
163 | REAL(rstd) :: field_lmdz(:) |
---|
164 | TYPE(t_field),POINTER :: f_field_icosa(:) |
---|
165 | REAL(rstd),POINTER :: field_icosa(:) |
---|
166 | INTEGER :: pos, nindex,ind,i |
---|
167 | INTEGER,POINTER :: index(:) |
---|
168 | |
---|
169 | pos=0 |
---|
170 | DO ind=1,ndomain_distrib |
---|
171 | field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind) |
---|
172 | index=>distrib_physic(ind)%index |
---|
173 | nindex=distrib_physic(ind)%nindex |
---|
174 | DO i=1,nindex |
---|
175 | pos=pos+1 |
---|
176 | field_icosa(index(i))=field_lmdz(pos) |
---|
177 | ENDDO |
---|
178 | ENDDO |
---|
179 | END SUBROUTINE transfer_lmdz1d_to_icosa |
---|
180 | |
---|
181 | SUBROUTINE transfer_lmdz2d_to_icosa(field_lmdz,f_field_icosa) |
---|
182 | USE field_mod |
---|
183 | IMPLICIT NONE |
---|
184 | REAL(rstd) :: field_lmdz(:,:) |
---|
185 | TYPE(t_field),POINTER :: f_field_icosa(:) |
---|
186 | REAL(rstd),POINTER :: field_icosa(:,:) |
---|
187 | INTEGER :: pos, nindex,ind,i |
---|
188 | INTEGER,POINTER :: index(:) |
---|
189 | INTEGER :: l |
---|
190 | |
---|
191 | DO l=1,size(field_lmdz,2) |
---|
192 | pos=0 |
---|
193 | DO ind=1,ndomain_distrib |
---|
194 | field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind) |
---|
195 | index=>distrib_physic(ind)%index |
---|
196 | nindex=distrib_physic(ind)%nindex |
---|
197 | DO i=1,nindex |
---|
198 | pos=pos+1 |
---|
199 | field_icosa(index(i),l)=field_lmdz(pos,l) |
---|
200 | ENDDO |
---|
201 | ENDDO |
---|
202 | ENDDO |
---|
203 | |
---|
204 | END SUBROUTINE transfer_lmdz2d_to_icosa |
---|
205 | |
---|
206 | |
---|
207 | SUBROUTINE transfer_lmdz3d_to_icosa(field_lmdz,f_field_icosa) |
---|
208 | USE field_mod |
---|
209 | IMPLICIT NONE |
---|
210 | REAL(rstd) :: field_lmdz(:,:,:) |
---|
211 | TYPE(t_field),POINTER :: f_field_icosa(:) |
---|
212 | REAL(rstd),POINTER :: field_icosa(:,:,:) |
---|
213 | INTEGER :: pos, nindex,ind,i |
---|
214 | INTEGER,POINTER :: index(:) |
---|
215 | INTEGER :: l,q |
---|
216 | |
---|
217 | DO q=1,size(field_lmdz,3) |
---|
218 | DO l=1,size(field_lmdz,2) |
---|
219 | pos=0 |
---|
220 | DO ind=1,ndomain_distrib |
---|
221 | field_icosa=f_field_icosa(distrib_physic(ind)%domain_ind) |
---|
222 | index=>distrib_physic(ind)%index |
---|
223 | nindex=distrib_physic(ind)%nindex |
---|
224 | DO i=1,nindex |
---|
225 | pos=pos+1 |
---|
226 | field_icosa(index(i),l,q)=field_lmdz(pos,l,q) |
---|
227 | ENDDO |
---|
228 | ENDDO |
---|
229 | ENDDO |
---|
230 | ENDDO |
---|
231 | |
---|
232 | END SUBROUTINE transfer_lmdz3d_to_icosa |
---|
233 | |
---|
234 | END MODULE distrib_icosa_lmdz_mod |
---|