1 | MODULE xios_mod |
---|
2 | |
---|
3 | #ifdef CPP_USING_XIOS |
---|
4 | USE xios |
---|
5 | #endif |
---|
6 | |
---|
7 | PUBLIC |
---|
8 | LOGICAL,SAVE :: using_xios |
---|
9 | |
---|
10 | INTEGER,SAVE :: ncell_i |
---|
11 | !$OMP THREADPRIVATE(ncell_i) |
---|
12 | INTEGER,SAVE :: ncell_v |
---|
13 | !$OMP THREADPRIVATE(ncell_v) |
---|
14 | |
---|
15 | PRIVATE ncell_i,ncell_v |
---|
16 | |
---|
17 | CONTAINS |
---|
18 | |
---|
19 | #ifdef CPP_USING_XIOS |
---|
20 | |
---|
21 | SUBROUTINE xios_init |
---|
22 | USE getin_mod |
---|
23 | IMPLICIT NONE |
---|
24 | |
---|
25 | using_xios=.TRUE. |
---|
26 | |
---|
27 | END SUBROUTINE xios_init |
---|
28 | |
---|
29 | SUBROUTINE xios_init_write_field |
---|
30 | USE genmod |
---|
31 | USE mpipara |
---|
32 | USE xios |
---|
33 | USE grid_param |
---|
34 | USE domain_mod |
---|
35 | USE dimensions |
---|
36 | USE spherical_geom_mod |
---|
37 | USE geometry |
---|
38 | USE mpi_mod |
---|
39 | USE time_mod |
---|
40 | USE metric, ONLY : vup,vdown |
---|
41 | IMPLICIT NONE |
---|
42 | TYPE(xios_context) :: ctx_hdl |
---|
43 | TYPE(xios_duration) :: dtime |
---|
44 | REAL(rstd) :: lev_value(llm) |
---|
45 | REAL(rstd) :: lev_valuep1(llm+1) |
---|
46 | INTEGER :: ncell, ncell_tot, ncell_glo(0:mpi_size-1), displ |
---|
47 | INTEGER :: ind, i,j,k,l |
---|
48 | REAL(rstd),ALLOCATABLE :: lon(:), lat(:), bounds_lon(:,:), bounds_lat(:,:) |
---|
49 | TYPE(t_domain),POINTER :: d |
---|
50 | |
---|
51 | !$OMP BARRIER |
---|
52 | !$OMP MASTER |
---|
53 | CALL xios_context_initialize("icosagcm",comm_icosa) |
---|
54 | CALL xios_get_handle("icosagcm",ctx_hdl) |
---|
55 | CALL xios_set_current_context(ctx_hdl) |
---|
56 | lev_value(:) = (/ (l,l=1,llm) /) |
---|
57 | lev_valuep1(:) = (/ (l,l=1,llm+1) /) |
---|
58 | CALL xios_set_axis_attr("lev",n_glo=llm ,value=lev_value) ; |
---|
59 | CALL xios_set_axis_attr("levp1",n_glo=llm+1 ,value=lev_value) ; |
---|
60 | |
---|
61 | ncell=0 |
---|
62 | DO ind=1,ndomain |
---|
63 | d=>domain(ind) |
---|
64 | |
---|
65 | DO j=d%jj_begin,d%jj_end |
---|
66 | DO i=d%ii_begin,d%ii_end |
---|
67 | IF (domain(ind)%own(i,j)) ncell=ncell+1 |
---|
68 | ENDDO |
---|
69 | ENDDO |
---|
70 | ENDDO |
---|
71 | ncell_i=ncell |
---|
72 | |
---|
73 | CALL MPI_ALLGATHER(ncell,1,MPI_INTEGER,ncell_glo,1,MPI_INTEGER,comm_icosa,ierr) |
---|
74 | |
---|
75 | displ=0 |
---|
76 | DO i=1,mpi_rank |
---|
77 | displ=displ+ncell_glo(i-1) |
---|
78 | ENDDO |
---|
79 | |
---|
80 | ncell_tot=sum(ncell_glo(:)) |
---|
81 | |
---|
82 | ALLOCATE(lon(ncell), lat(ncell), bounds_lon(0:5,ncell), bounds_lat(0:5,ncell)) |
---|
83 | |
---|
84 | ncell=0 |
---|
85 | DO ind=1,ndomain |
---|
86 | d=>domain(ind) |
---|
87 | |
---|
88 | DO j=d%jj_begin,d%jj_end |
---|
89 | DO i=d%ii_begin,d%ii_end |
---|
90 | IF (domain(ind)%own(i,j)) THEN |
---|
91 | ncell=ncell+1 |
---|
92 | CALL xyz2lonlat(d%xyz(:,i,j),lon(ncell),lat(ncell)) |
---|
93 | lon(ncell)=lon(ncell)*180/Pi |
---|
94 | lat(ncell)=lat(ncell)*180/Pi |
---|
95 | DO k=0,5 |
---|
96 | CALL xyz2lonlat(d%vertex(:,k,i,j),bounds_lon(k,ncell), bounds_lat(k,ncell)) |
---|
97 | bounds_lat(k,ncell)=bounds_lat(k,ncell)*180/Pi |
---|
98 | bounds_lon(k,ncell)=bounds_lon(k,ncell)*180/Pi |
---|
99 | ENDDO |
---|
100 | ENDIF |
---|
101 | ENDDO |
---|
102 | ENDDO |
---|
103 | ENDDO |
---|
104 | |
---|
105 | |
---|
106 | CALL xios_set_domaingroup_attr("i",ni_glo=ncell_tot, ibegin=displ, ni=ncell) |
---|
107 | CALL xios_set_domaingroup_attr("i", data_dim=1, type='unstructured' , nvertex=6) |
---|
108 | CALL xios_set_domaingroup_attr("i",lonvalue_1d=lon, latvalue_1d=lat, bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat) |
---|
109 | |
---|
110 | DEALLOCATE(lon, lat, bounds_lon, bounds_lat) |
---|
111 | |
---|
112 | ncell=0 |
---|
113 | DO ind=1,ndomain |
---|
114 | d=>domain(ind) |
---|
115 | |
---|
116 | DO j=d%jj_begin+1,d%jj_end |
---|
117 | DO i=d%ii_begin,d%ii_end-1 |
---|
118 | ncell=ncell+1 |
---|
119 | ENDDO |
---|
120 | ENDDO |
---|
121 | |
---|
122 | DO j=d%jj_begin,d%jj_end-1 |
---|
123 | DO i=d%ii_begin+1,d%ii_end |
---|
124 | ncell=ncell+1 |
---|
125 | ENDDO |
---|
126 | ENDDO |
---|
127 | |
---|
128 | ENDDO |
---|
129 | |
---|
130 | ncell_v=ncell |
---|
131 | |
---|
132 | CALL MPI_ALLGATHER(ncell,1,MPI_INTEGER,ncell_glo,1,MPI_INTEGER,comm_icosa,ierr) |
---|
133 | |
---|
134 | displ=0 |
---|
135 | DO i=1,mpi_rank |
---|
136 | displ=displ+ncell_glo(i-1) |
---|
137 | ENDDO |
---|
138 | |
---|
139 | ncell_tot=sum(ncell_glo(:)) |
---|
140 | |
---|
141 | ALLOCATE(lon(ncell), lat(ncell), bounds_lon(0:2,ncell), bounds_lat(0:2,ncell)) |
---|
142 | |
---|
143 | ncell=0 |
---|
144 | DO ind=1,ndomain |
---|
145 | d=>domain(ind) |
---|
146 | |
---|
147 | DO j=d%jj_begin+1,d%jj_end |
---|
148 | DO i=d%ii_begin,d%ii_end-1 |
---|
149 | ncell=ncell+1 |
---|
150 | CALL xyz2lonlat(d%vertex(:,vdown,i,j),lon(ncell),lat(ncell)) |
---|
151 | lon(ncell)=lon(ncell)*180/Pi |
---|
152 | lat(ncell)=lat(ncell)*180/Pi |
---|
153 | |
---|
154 | CALL xyz2lonlat(d%xyz(:,i,j),bounds_lon(0,ncell), bounds_lat(0,ncell)) |
---|
155 | CALL xyz2lonlat(d%xyz(:,i,j-1),bounds_lon(1,ncell), bounds_lat(1,ncell)) |
---|
156 | CALL xyz2lonlat(d%xyz(:,i+1,j-1),bounds_lon(2,ncell), bounds_lat(2,ncell)) |
---|
157 | |
---|
158 | DO k=0,2 |
---|
159 | bounds_lat(k,ncell)=bounds_lat(k,ncell)*180/Pi |
---|
160 | bounds_lon(k,ncell)=bounds_lon(k,ncell)*180/Pi |
---|
161 | ENDDO |
---|
162 | ENDDO |
---|
163 | ENDDO |
---|
164 | |
---|
165 | DO j=d%jj_begin,d%jj_end-1 |
---|
166 | DO i=d%ii_begin+1,d%ii_end |
---|
167 | ncell=ncell+1 |
---|
168 | CALL xyz2lonlat(d%vertex(:,vup,i,j),lon(ncell),lat(ncell)) |
---|
169 | lon(ncell)=lon(ncell)*180/Pi |
---|
170 | lat(ncell)=lat(ncell)*180/Pi |
---|
171 | CALL xyz2lonlat(d%xyz(:,i,j),bounds_lon(0,ncell), bounds_lat(0,ncell)) |
---|
172 | CALL xyz2lonlat(d%xyz(:,i,j+1),bounds_lon(1,ncell), bounds_lat(1,ncell)) |
---|
173 | CALL xyz2lonlat(d%xyz(:,i-1,j+1),bounds_lon(2,ncell), bounds_lat(2,ncell)) |
---|
174 | |
---|
175 | DO k=0,2 |
---|
176 | bounds_lat(k,ncell)=bounds_lat(k,ncell)*180/Pi |
---|
177 | bounds_lon(k,ncell)=bounds_lon(k,ncell)*180/Pi |
---|
178 | ENDDO |
---|
179 | ENDDO |
---|
180 | ENDDO |
---|
181 | |
---|
182 | ENDDO |
---|
183 | |
---|
184 | |
---|
185 | CALL xios_set_domain_attr("v",ni_glo=ncell_tot, ibegin=displ, ni=ncell) |
---|
186 | CALL xios_set_domain_attr("v", data_dim=1, type='unstructured' , nvertex=3) |
---|
187 | CALL xios_set_domain_attr("v",lonvalue_1d=lon, latvalue_1d=lat, bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat) |
---|
188 | |
---|
189 | |
---|
190 | dtime%second=dt |
---|
191 | CALL xios_set_timestep(dtime) |
---|
192 | CALL xios_close_context_definition() |
---|
193 | !$OMP END MASTER |
---|
194 | !$OMP BARRIER |
---|
195 | |
---|
196 | END SUBROUTINE xios_init_write_field |
---|
197 | |
---|
198 | |
---|
199 | SUBROUTINE xios_write_field(name,field) |
---|
200 | USE field_mod |
---|
201 | IMPLICIT NONE |
---|
202 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
203 | TYPE(t_field), POINTER :: field(:) |
---|
204 | CHARACTER(LEN=10) :: str_number |
---|
205 | INTEGER :: iq |
---|
206 | |
---|
207 | !$OMP BARRIER |
---|
208 | !$OMP MASTER |
---|
209 | |
---|
210 | IF (Field(1)%field_type==field_T) THEN |
---|
211 | IF (field(1)%ndim==2) THEN |
---|
212 | CALL xios_write_field_scalar(name,field,1) |
---|
213 | ELSE IF (field(1)%ndim==3) THEN |
---|
214 | CALL xios_write_field_scalar(name,field,size(field(1)%rval3d,2)) |
---|
215 | ELSE IF (field(1)%ndim==4) THEN |
---|
216 | DO iq=1,size(field(1)%rval4d,3) |
---|
217 | WRITE(str_number,'(i10)') iq |
---|
218 | CALL xios_write_field_scalar(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq) |
---|
219 | ENDDO |
---|
220 | ELSE |
---|
221 | PRINT *, "xios_write_field : dimension > 4 are not supported for now" |
---|
222 | ENDIF |
---|
223 | ELSE IF (Field(1)%field_type==field_Z) THEN |
---|
224 | IF (field(1)%ndim==2) THEN |
---|
225 | CALL xios_write_field_vort(name,field,1) |
---|
226 | ELSE IF (field(1)%ndim==3) THEN |
---|
227 | CALL xios_write_field_vort(name,field,size(field(1)%rval3d,2)) |
---|
228 | ELSE IF (field(1)%ndim==4) THEN |
---|
229 | DO iq=1,size(field(1)%rval4d,3) |
---|
230 | WRITE(str_number,'(i10)') iq |
---|
231 | CALL xios_write_field_vort(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq) |
---|
232 | ENDDO |
---|
233 | ELSE |
---|
234 | PRINT *, "xios_write_field : dimension > 4 are not supported for now" |
---|
235 | ENDIF |
---|
236 | ENDIF |
---|
237 | !$OMP END MASTER |
---|
238 | !$OMP BARRIER |
---|
239 | |
---|
240 | END SUBROUTINE xios_write_field |
---|
241 | |
---|
242 | SUBROUTINE xios_read_field(name,field) |
---|
243 | USE field_mod |
---|
244 | IMPLICIT NONE |
---|
245 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
246 | TYPE(t_field), POINTER :: field(:) |
---|
247 | CHARACTER(LEN=10) :: str_number |
---|
248 | INTEGER :: iq |
---|
249 | |
---|
250 | !$OMP BARRIER |
---|
251 | !$OMP MASTER |
---|
252 | |
---|
253 | IF (Field(1)%field_type==field_T) THEN |
---|
254 | IF (field(1)%ndim==2) THEN |
---|
255 | CALL xios_read_field_scalar(name,field,1) |
---|
256 | ELSE IF (field(1)%ndim==3) THEN |
---|
257 | CALL xios_read_field_scalar(name,field,size(field(1)%rval3d,2)) |
---|
258 | ELSE IF (field(1)%ndim==4) THEN |
---|
259 | DO iq=1,size(field(1)%rval4d,3) |
---|
260 | WRITE(str_number,'(i10)') iq |
---|
261 | CALL xios_read_field_scalar(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq) |
---|
262 | ENDDO |
---|
263 | ELSE |
---|
264 | PRINT *, "xios_write_field : dimension > 4 are not supported for now" |
---|
265 | ENDIF |
---|
266 | ELSE IF (Field(1)%field_type==field_Z) THEN |
---|
267 | IF (field(1)%ndim==2) THEN |
---|
268 | CALL xios_read_field_vort(name,field,1) |
---|
269 | ELSE IF (field(1)%ndim==3) THEN |
---|
270 | CALL xios_read_field_vort(name,field,size(field(1)%rval3d,2)) |
---|
271 | ELSE IF (field(1)%ndim==4) THEN |
---|
272 | DO iq=1,size(field(1)%rval4d,3) |
---|
273 | WRITE(str_number,'(i10)') iq |
---|
274 | CALL xios_read_field_vort(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq) |
---|
275 | ENDDO |
---|
276 | ELSE |
---|
277 | PRINT *, "xios_write_field : dimension > 4 are not supported for now" |
---|
278 | ENDIF |
---|
279 | ENDIF |
---|
280 | !$OMP END MASTER |
---|
281 | !$OMP BARRIER |
---|
282 | |
---|
283 | END SUBROUTINE xios_read_field |
---|
284 | |
---|
285 | |
---|
286 | |
---|
287 | SUBROUTINE xios_write_field_scalar(name,field,nlev,iq) |
---|
288 | USE genmod |
---|
289 | USE mpipara |
---|
290 | USE xios |
---|
291 | USE grid_param |
---|
292 | USE domain_mod |
---|
293 | USE dimensions |
---|
294 | USE spherical_geom_mod |
---|
295 | USE geometry |
---|
296 | USE mpi_mod |
---|
297 | IMPLICIT NONE |
---|
298 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
299 | TYPE(t_field), POINTER :: field(:) |
---|
300 | INTEGER,INTENT(IN) :: nlev |
---|
301 | INTEGER,INTENT(IN),OPTIONAL :: iq |
---|
302 | |
---|
303 | REAL(rstd) :: field_tmp(ncell_i,nlev) |
---|
304 | TYPE(t_domain),POINTER :: d |
---|
305 | INTEGER :: n,i,j,ij,ind |
---|
306 | |
---|
307 | IF (field(1)%ndim==2) THEN |
---|
308 | n=0 |
---|
309 | DO ind=1,ndomain |
---|
310 | |
---|
311 | d=>domain(ind) |
---|
312 | |
---|
313 | DO j=d%jj_begin,d%jj_end |
---|
314 | DO i=d%ii_begin,d%ii_end |
---|
315 | IF (d%own(i,j)) THEN |
---|
316 | n=n+1 |
---|
317 | ij=d%iim*(j-1)+i |
---|
318 | field_tmp(n,1)=field(ind)%rval2d(ij) |
---|
319 | ENDIF |
---|
320 | ENDDO |
---|
321 | ENDDO |
---|
322 | ENDDO |
---|
323 | ELSE IF (field(1)%ndim==3) THEN |
---|
324 | n=0 |
---|
325 | DO ind=1,ndomain |
---|
326 | d=>domain(ind) |
---|
327 | |
---|
328 | DO j=d%jj_begin,d%jj_end |
---|
329 | DO i=d%ii_begin,d%ii_end |
---|
330 | IF (d%own(i,j)) THEN |
---|
331 | n=n+1 |
---|
332 | ij=d%iim*(j-1)+i |
---|
333 | field_tmp(n,:)=field(ind)%rval3d(ij,:) |
---|
334 | ENDIF |
---|
335 | ENDDO |
---|
336 | ENDDO |
---|
337 | ENDDO |
---|
338 | ELSE IF (field(1)%ndim==4) THEN |
---|
339 | n=0 |
---|
340 | DO ind=1,ndomain |
---|
341 | d=>domain(ind) |
---|
342 | |
---|
343 | DO j=d%jj_begin,d%jj_end |
---|
344 | DO i=d%ii_begin,d%ii_end |
---|
345 | IF (d%own(i,j)) THEN |
---|
346 | n=n+1 |
---|
347 | ij=d%iim*(j-1)+i |
---|
348 | field_tmp(n,:)=field(ind)%rval4d(ij,:,iq) |
---|
349 | ENDIF |
---|
350 | ENDDO |
---|
351 | ENDDO |
---|
352 | ENDDO |
---|
353 | ENDIF |
---|
354 | |
---|
355 | CALL xios_send_field(name,field_tmp) |
---|
356 | |
---|
357 | END SUBROUTINE xios_write_field_scalar |
---|
358 | |
---|
359 | |
---|
360 | SUBROUTINE xios_read_field_scalar(name,field,nlev,iq) |
---|
361 | USE genmod |
---|
362 | USE mpipara |
---|
363 | USE xios |
---|
364 | USE grid_param |
---|
365 | USE domain_mod |
---|
366 | USE dimensions |
---|
367 | USE spherical_geom_mod |
---|
368 | USE geometry |
---|
369 | USE mpi_mod |
---|
370 | IMPLICIT NONE |
---|
371 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
372 | TYPE(t_field), POINTER :: field(:) |
---|
373 | INTEGER,INTENT(IN) :: nlev |
---|
374 | INTEGER,INTENT(IN),OPTIONAL :: iq |
---|
375 | |
---|
376 | REAL(rstd) :: field_tmp(ncell_i,nlev) |
---|
377 | TYPE(t_domain),POINTER :: d |
---|
378 | INTEGER :: n,i,j,ij,ind |
---|
379 | |
---|
380 | CALL xios_recv_field(name,field_tmp) |
---|
381 | |
---|
382 | IF (field(1)%ndim==2) THEN |
---|
383 | n=0 |
---|
384 | DO ind=1,ndomain |
---|
385 | |
---|
386 | d=>domain(ind) |
---|
387 | |
---|
388 | DO j=d%jj_begin,d%jj_end |
---|
389 | DO i=d%ii_begin,d%ii_end |
---|
390 | IF (d%own(i,j)) THEN |
---|
391 | n=n+1 |
---|
392 | ij=d%iim*(j-1)+i |
---|
393 | field(ind)%rval2d(ij)=field_tmp(n,1) |
---|
394 | ENDIF |
---|
395 | ENDDO |
---|
396 | ENDDO |
---|
397 | ENDDO |
---|
398 | ELSE IF (field(1)%ndim==3) THEN |
---|
399 | n=0 |
---|
400 | DO ind=1,ndomain |
---|
401 | d=>domain(ind) |
---|
402 | |
---|
403 | DO j=d%jj_begin,d%jj_end |
---|
404 | DO i=d%ii_begin,d%ii_end |
---|
405 | IF (d%own(i,j)) THEN |
---|
406 | n=n+1 |
---|
407 | ij=d%iim*(j-1)+i |
---|
408 | field(ind)%rval3d(ij,:)=field_tmp(n,:) |
---|
409 | ENDIF |
---|
410 | ENDDO |
---|
411 | ENDDO |
---|
412 | ENDDO |
---|
413 | ELSE IF (field(1)%ndim==4) THEN |
---|
414 | n=0 |
---|
415 | DO ind=1,ndomain |
---|
416 | d=>domain(ind) |
---|
417 | |
---|
418 | DO j=d%jj_begin,d%jj_end |
---|
419 | DO i=d%ii_begin,d%ii_end |
---|
420 | IF (d%own(i,j)) THEN |
---|
421 | n=n+1 |
---|
422 | ij=d%iim*(j-1)+i |
---|
423 | field(ind)%rval4d(ij,:,iq)=field_tmp(n,:) |
---|
424 | ENDIF |
---|
425 | ENDDO |
---|
426 | ENDDO |
---|
427 | ENDDO |
---|
428 | ENDIF |
---|
429 | |
---|
430 | END SUBROUTINE xios_read_field_scalar |
---|
431 | |
---|
432 | |
---|
433 | |
---|
434 | SUBROUTINE xios_write_field_vort(name,field,nlev,iq) |
---|
435 | USE genmod |
---|
436 | USE mpipara |
---|
437 | USE xios |
---|
438 | USE grid_param |
---|
439 | USE domain_mod |
---|
440 | USE dimensions |
---|
441 | USE spherical_geom_mod |
---|
442 | USE geometry |
---|
443 | USE mpi_mod |
---|
444 | IMPLICIT NONE |
---|
445 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
446 | TYPE(t_field), POINTER :: field(:) |
---|
447 | INTEGER,INTENT(IN) :: nlev |
---|
448 | INTEGER,INTENT(IN),OPTIONAL :: iq |
---|
449 | |
---|
450 | REAL(rstd) :: field_tmp(ncell_v,nlev) |
---|
451 | TYPE(t_domain),POINTER :: d |
---|
452 | INTEGER :: n,i,j,ij,ind |
---|
453 | |
---|
454 | IF (field(1)%ndim==2) THEN |
---|
455 | n=0 |
---|
456 | DO ind=1,ndomain |
---|
457 | d=>domain(ind) |
---|
458 | CALL swap_dimensions(ind) |
---|
459 | |
---|
460 | DO j=d%jj_begin+1,d%jj_end |
---|
461 | DO i=d%ii_begin,d%ii_end-1 |
---|
462 | n=n+1 |
---|
463 | ij=iim*(j-1)+i |
---|
464 | Field_tmp(n,1)=field(ind)%rval2d(ij+z_down) |
---|
465 | ENDDO |
---|
466 | ENDDO |
---|
467 | |
---|
468 | DO j=d%jj_begin,d%jj_end-1 |
---|
469 | DO i=d%ii_begin+1,d%ii_end |
---|
470 | n=n+1 |
---|
471 | ij=iim*(j-1)+i |
---|
472 | Field_tmp(n,1)=field(ind)%rval2d(ij+z_up) |
---|
473 | ENDDO |
---|
474 | ENDDO |
---|
475 | |
---|
476 | ENDDO |
---|
477 | |
---|
478 | ELSE IF (field(1)%ndim==3) THEN |
---|
479 | n=0 |
---|
480 | DO ind=1,ndomain |
---|
481 | d=>domain(ind) |
---|
482 | CALL swap_dimensions(ind) |
---|
483 | |
---|
484 | DO j=d%jj_begin+1,d%jj_end |
---|
485 | DO i=d%ii_begin,d%ii_end-1 |
---|
486 | n=n+1 |
---|
487 | ij=iim*(j-1)+i |
---|
488 | Field_tmp(n,:)=field(ind)%rval3d(ij+z_down,:) |
---|
489 | ENDDO |
---|
490 | ENDDO |
---|
491 | |
---|
492 | DO j=d%jj_begin,d%jj_end-1 |
---|
493 | DO i=d%ii_begin+1,d%ii_end |
---|
494 | n=n+1 |
---|
495 | ij=iim*(j-1)+i |
---|
496 | Field_tmp(n,:)=field(ind)%rval3d(ij+z_up,:) |
---|
497 | ENDDO |
---|
498 | ENDDO |
---|
499 | |
---|
500 | ENDDO |
---|
501 | |
---|
502 | ELSE IF (field(1)%ndim==4) THEN |
---|
503 | n=0 |
---|
504 | DO ind=1,ndomain |
---|
505 | d=>domain(ind) |
---|
506 | CALL swap_dimensions(ind) |
---|
507 | |
---|
508 | DO j=d%jj_begin+1,d%jj_end |
---|
509 | DO i=d%ii_begin,d%ii_end-1 |
---|
510 | n=n+1 |
---|
511 | ij=iim*(j-1)+i |
---|
512 | Field_tmp(n,:)=field(ind)%rval4d(ij+z_down,:,iq) |
---|
513 | ENDDO |
---|
514 | ENDDO |
---|
515 | |
---|
516 | DO j=d%jj_begin,d%jj_end-1 |
---|
517 | DO i=d%ii_begin+1,d%ii_end |
---|
518 | n=n+1 |
---|
519 | ij=iim*(j-1)+i |
---|
520 | Field_tmp(n,:)=field(ind)%rval4d(ij+z_up,:,iq) |
---|
521 | ENDDO |
---|
522 | ENDDO |
---|
523 | |
---|
524 | ENDDO |
---|
525 | |
---|
526 | ENDIF |
---|
527 | |
---|
528 | CALL xios_send_field(name,field_tmp) |
---|
529 | |
---|
530 | END SUBROUTINE xios_write_field_vort |
---|
531 | |
---|
532 | SUBROUTINE xios_read_field_vort(name,field,nlev,iq) |
---|
533 | USE genmod |
---|
534 | USE mpipara |
---|
535 | USE xios |
---|
536 | USE grid_param |
---|
537 | USE domain_mod |
---|
538 | USE dimensions |
---|
539 | USE spherical_geom_mod |
---|
540 | USE geometry |
---|
541 | USE mpi_mod |
---|
542 | IMPLICIT NONE |
---|
543 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
544 | TYPE(t_field), POINTER :: field(:) |
---|
545 | INTEGER,INTENT(IN) :: nlev |
---|
546 | INTEGER,INTENT(IN),OPTIONAL :: iq |
---|
547 | |
---|
548 | REAL(rstd) :: field_tmp(ncell_v,nlev) |
---|
549 | TYPE(t_domain),POINTER :: d |
---|
550 | INTEGER :: n,i,j,ij,ind |
---|
551 | |
---|
552 | CALL xios_recv_field(name,field_tmp) |
---|
553 | |
---|
554 | |
---|
555 | IF (field(1)%ndim==2) THEN |
---|
556 | n=0 |
---|
557 | DO ind=1,ndomain |
---|
558 | d=>domain(ind) |
---|
559 | CALL swap_dimensions(ind) |
---|
560 | |
---|
561 | DO j=d%jj_begin+1,d%jj_end |
---|
562 | DO i=d%ii_begin,d%ii_end-1 |
---|
563 | n=n+1 |
---|
564 | ij=iim*(j-1)+i |
---|
565 | field(ind)%rval2d(ij+z_down)=Field_tmp(n,1) |
---|
566 | ENDDO |
---|
567 | ENDDO |
---|
568 | |
---|
569 | DO j=d%jj_begin,d%jj_end-1 |
---|
570 | DO i=d%ii_begin+1,d%ii_end |
---|
571 | n=n+1 |
---|
572 | ij=iim*(j-1)+i |
---|
573 | Field_tmp(n,1)=field(ind)%rval2d(ij+z_up) |
---|
574 | field(ind)%rval2d(ij+z_up)=Field_tmp(n,1) |
---|
575 | ENDDO |
---|
576 | ENDDO |
---|
577 | |
---|
578 | ENDDO |
---|
579 | |
---|
580 | ELSE IF (field(1)%ndim==3) THEN |
---|
581 | n=0 |
---|
582 | DO ind=1,ndomain |
---|
583 | d=>domain(ind) |
---|
584 | CALL swap_dimensions(ind) |
---|
585 | |
---|
586 | DO j=d%jj_begin+1,d%jj_end |
---|
587 | DO i=d%ii_begin,d%ii_end-1 |
---|
588 | n=n+1 |
---|
589 | ij=iim*(j-1)+i |
---|
590 | field(ind)%rval3d(ij+z_down,:)=Field_tmp(n,:) |
---|
591 | ENDDO |
---|
592 | ENDDO |
---|
593 | |
---|
594 | DO j=d%jj_begin,d%jj_end-1 |
---|
595 | DO i=d%ii_begin+1,d%ii_end |
---|
596 | n=n+1 |
---|
597 | ij=iim*(j-1)+i |
---|
598 | field(ind)%rval3d(ij+z_up,:)=Field_tmp(n,:) |
---|
599 | ENDDO |
---|
600 | ENDDO |
---|
601 | |
---|
602 | ENDDO |
---|
603 | |
---|
604 | ELSE IF (field(1)%ndim==4) THEN |
---|
605 | n=0 |
---|
606 | DO ind=1,ndomain |
---|
607 | d=>domain(ind) |
---|
608 | CALL swap_dimensions(ind) |
---|
609 | |
---|
610 | DO j=d%jj_begin+1,d%jj_end |
---|
611 | DO i=d%ii_begin,d%ii_end-1 |
---|
612 | n=n+1 |
---|
613 | ij=iim*(j-1)+i |
---|
614 | field(ind)%rval4d(ij+z_down,:,iq)=Field_tmp(n,:) |
---|
615 | ENDDO |
---|
616 | ENDDO |
---|
617 | |
---|
618 | DO j=d%jj_begin,d%jj_end-1 |
---|
619 | DO i=d%ii_begin+1,d%ii_end |
---|
620 | n=n+1 |
---|
621 | ij=iim*(j-1)+i |
---|
622 | field(ind)%rval4d(ij+z_up,:,iq)=Field_tmp(n,:) |
---|
623 | ENDDO |
---|
624 | ENDDO |
---|
625 | |
---|
626 | ENDDO |
---|
627 | |
---|
628 | ENDIF |
---|
629 | |
---|
630 | END SUBROUTINE xios_read_field_vort |
---|
631 | |
---|
632 | |
---|
633 | |
---|
634 | |
---|
635 | |
---|
636 | SUBROUTINE xios_write_field_finalize |
---|
637 | IMPLICIT NONE |
---|
638 | |
---|
639 | !$OMP BARRIER |
---|
640 | !$OMP MASTER |
---|
641 | CALL xios_context_finalize |
---|
642 | !$OMP END MASTER |
---|
643 | !$OMP BARRIER |
---|
644 | |
---|
645 | END SUBROUTINE xios_write_field_finalize |
---|
646 | |
---|
647 | SUBROUTINE xios_set_context |
---|
648 | IMPLICIT NONE |
---|
649 | TYPE(xios_context) :: ctx_hdl |
---|
650 | |
---|
651 | !$OMP MASTER |
---|
652 | CALL xios_get_handle("icosagcm",ctx_hdl) |
---|
653 | CALL xios_set_current_context(ctx_hdl) |
---|
654 | !$OMP END MASTER |
---|
655 | |
---|
656 | END SUBROUTINE xios_set_context |
---|
657 | #else |
---|
658 | |
---|
659 | SUBROUTINE xios_init |
---|
660 | IMPLICIT NONE |
---|
661 | |
---|
662 | using_xios=.FALSE. |
---|
663 | |
---|
664 | END SUBROUTINE xios_init |
---|
665 | |
---|
666 | SUBROUTINE xios_write_field(name,field) |
---|
667 | USE field_mod |
---|
668 | IMPLICIT NONE |
---|
669 | CHARACTER(LEN=*),INTENT(IN) :: name |
---|
670 | TYPE(t_field), POINTER :: field(:) |
---|
671 | END SUBROUTINE xios_write_field |
---|
672 | |
---|
673 | SUBROUTINE xios_update_calendar(step) |
---|
674 | IMPLICIT NONE |
---|
675 | INTEGER, INTENT(IN):: step |
---|
676 | END SUBROUTINE xios_update_calendar |
---|
677 | |
---|
678 | SUBROUTINE xios_write_field_finalize |
---|
679 | END SUBROUTINE xios_write_field_finalize |
---|
680 | |
---|
681 | SUBROUTINE xios_init_write_field |
---|
682 | END SUBROUTINE xios_init_write_field |
---|
683 | |
---|
684 | SUBROUTINE xios_set_context |
---|
685 | END SUBROUTINE xios_set_context |
---|
686 | |
---|
687 | |
---|
688 | #endif |
---|
689 | |
---|
690 | END MODULE xios_mod |
---|