source: LMDZ6/trunk/libf/dyn3dmem/mod_xios_dyn3dmem.F90 @ 4264

Last change on this file since 4264 was 4146, checked in by Laurent Fairhead, 3 years ago

Source code and xml files needed for XIOS output in the LMDZ LonLat? dynamical core.
One flag controls everything: ok_dyn_xios. Parameters controlling outputs need to be put in the xml
files, nothing is set in the code
Work to follow on the dynzon file and the modipsl/libIGCM framework.
ok_dyn_xios = n should not change anything

File size: 6.6 KB
Line 
1!
2! $Id$
3!
4! This module contains the interface between the LMDZ dynamics dyn3dmem module and XIOS.
5!
6! Lists of subroutines
7!      xios_dyn3dmem_init : context / calendar / domain / axis initialisations
8!
9! Initialisation of communicator between LMDZ and XIOS is done elsewhere: wxios_init called by init_const_mpi
10!                                                                         (one of the first calls in gcm.F90)
11! L. Fairhead 11/2017
12!
13!
14#ifdef CPP_XIOS
15
16MODULE mod_xios_dyn3dmem
17
18     USE xios
19     USE wxios, ONLY : g_comm
20     CHARACTER(len=100), SAVE :: dyn3d_ctx_name = "LMDZDYN"
21     TYPE(xios_context), SAVE :: dyn3d_ctx_handle
22!$OMP THREADPRIVATE(dyn3d_ctx_name, dyn3d_ctx_handle)
23 
24  INTERFACE writefield_dyn_u
25     MODULE PROCEDURE writefield_dyn1d_u, writefield_dyn2d_u
26  END INTERFACE writefield_dyn_u
27
28  INTERFACE writefield_dyn_v
29     MODULE PROCEDURE writefield_dyn1d_v, writefield_dyn2d_v
30  END INTERFACE writefield_dyn_v
31 
32
33   CONTAINS
34
35   SUBROUTINE xios_dyn3dmem_init(xios_cal_type, anref, moisref, jourref,heureref, an, mois, jour, heure, zdtvr)
36
37
38     USE comvert_mod, ONLY: presnivs
39     USE parallel_lmdz
40
41     IMPLICIT NONE
42
43     INCLUDE 'dimensions.h'
44     INCLUDE "paramet.h"
45     INCLUDE 'comgeom.h'
46
47     TYPE(xios_duration) :: tstep_xios
48     TYPE(xios_date)                :: start_date
49     TYPE(xios_date)                :: time_origin
50     INTEGER :: an, mois, jour
51     REAL :: heure
52     CHARACTER (len=10) :: xios_cal_type
53     INTEGER :: anref, moisref, jourref
54     REAL :: heureref
55     REAL :: zdtvr
56     TYPE(xios_domain) :: dom_grid_U, dom_grid_V, dom_grid_T
57     REAL :: rlong(iip1), rlat(jjp1)
58     REAL :: pi
59     INTEGER :: ii, jj, jjb, jje, jjn
60
61!      WRITE(*,*)'Entree mod_xios_dyn3dmem'
62
63! 0 Initialisations
64     pi = 4. * ATAN (1.)
65
66! 1 Context initialisation
67!$OMP MASTER
68     CALL xios_context_initialize(dyn3d_ctx_name, g_comm)
69     CALL xios_get_handle(dyn3d_ctx_name, dyn3d_ctx_handle)
70     CALL xios_set_current_context(dyn3d_ctx_handle) 
71
72!     WRITE(*,*)'apres context initialisation mod_xios_dyn3dmem'
73
74! 2 calendar stuff
75
76     tstep_xios%second=zdtvr
77     CALL xios_define_calendar(type=xios_cal_type, start_date=xios_date(an, mois, jour,INT(heure),0,0), &
78            time_origin=xios_date(anref,moisref,jourref,INT(heureref),0,0), timestep=tstep_xios)
79
80!     WRITE(*,*)'apres  calendrier mod_xios_dyn3dmem'
81
82! 3 domain / grids / axis
83! Domains:
84      rlong(:) = rlonu(:) * 180. / pi
85      rlat(:) = rlatu(:) * 180. / pi
86
87      CALL xios_set_domain_attr("domain_U", ni_glo=iip1, nj_glo=jjp1,          &
88          type="rectilinear",ibegin=0, ni=iip1, jbegin=jj_begin-1, nj=jj_nb,   &
89          data_dim = 2, lonvalue_1d=rlong(1:iip1), latvalue_1d=rlat(jj_begin:jj_end))
90
91      jjb=jj_begin
92      jje=jj_end
93      jjn=jj_nb
94      IF (pole_sud) jjn=jjn-1
95      IF (pole_sud) jje=jje-1
96
97
98      rlong(:) = rlonv(:) * 180. / pi
99      do jj = jjb, jje
100        rlat(jj) = rlatv(jj) * 180. / pi
101      enddo
102     
103      CALL xios_set_domain_attr("domain_V", ni_glo=iip1, nj_glo=jjm,            &
104          type="rectilinear",ibegin=0, ni=iip1, jbegin=jj_begin-1, nj=jjn,   &
105          data_dim = 2, lonvalue_1d=rlong(1:iip1), latvalue_1d=rlat(jjb:jje))
106
107
108      rlong(:) = rlonv(:) * 180. / pi
109      rlat(:) = rlatu(:) * 180. / pi
110      CALL xios_set_domain_attr("domain_T", ni_glo=iip1, nj_glo=jjp1,          &
111          type="rectilinear",ibegin=0, ni=iip1, jbegin=jj_begin-1, nj=jj_nb,   &
112          data_dim = 2, lonvalue_1d=rlong(1:iip1), latvalue_1d=rlat(jj_begin:jj_end))
113     
114!     WRITE(*,*)'apres  domaine mod_xios_dyn3dmem'
115! Vertical axis
116       CALL xios_set_axis_attr("presnivs",n_glo=llm,value=presnivs)
117!     WRITE(*,*)'apres  vertical axis mod_xios_dyn3dmem'
118! 4 end of context definition
119       CALL xios_close_context_definition()
120!     WRITE(*,*)'apres close context init. axis mod_xios_dyn3dmem'
121!$OMP END MASTER
122   END SUBROUTINE xios_dyn3dmem_init
123
124   SUBROUTINE  writefield_dyn1d_u(name,Field)
125
126     USE parallel_lmdz
127     IMPLICIT NONE
128     include 'dimensions.h'
129     include 'paramet.h'
130     CHARACTER(LEN=*)   :: name
131     REAL, DIMENSION(ij_begin:ij_end) :: Field
132     REAL, DIMENSION(iip1,  jj_begin:jj_end) :: NewField
133      LOGICAL,SAVE :: debuglf=.true.
134!$OMP THREADPRIVATE(debuglf)
135     
136     NewField(:,jj_begin:jj_end)=reshape(Field(ij_begin:ij_end),(/iip1,jj_nb/))
137
138!$OMP BARRIER       
139!$OMP MASTER
140     CALL xios_send_field(name, NewField)
141!$OMP END MASTER   
142 
143   END SUBROUTINE  writefield_dyn1d_u
144
145   SUBROUTINE  writefield_dyn2d_u(name,Field)
146
147     USE parallel_lmdz
148     IMPLICIT NONE
149     include 'dimensions.h'
150     include 'paramet.h'
151     CHARACTER(LEN=*)   :: name
152     REAL, DIMENSION(ij_begin:ij_end,llm) :: Field
153     REAL, DIMENSION(iip1, jj_begin:jj_end,llm) :: NewField
154     INTEGER :: i,j,l, count
155
156!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
157     DO l = 1, llm
158       NewField(:,jj_begin:jj_end,l)=reshape(Field(ij_begin:ij_end,l),(/iip1,jj_nb/))
159     ENDDO
160!$OMP ENDDO
161!$OMP BARRIER
162
163!$OMP MASTER
164!!     write(14,*)'iip1,ij_begin,ij_end,llm,jj_begin,jj_end,jj_nb ',iip1,ij_begin,ij_end,llm,jj_begin,jj_end,jj_nb
165
166     CALL xios_send_field(name, NewField)
167!$OMP END MASTER   
168 
169   END SUBROUTINE  writefield_dyn2d_u
170
171   SUBROUTINE  writefield_dyn1d_v(name,Field)
172
173     USE parallel_lmdz
174     IMPLICIT NONE
175     include 'dimensions.h'
176     include 'paramet.h'
177     CHARACTER(LEN=*)   :: name
178     REAL, DIMENSION(ij_begin:ij_end) :: Field
179     REAL, DIMENSION(iip1,  jj_begin:jj_end) :: NewField
180     INTEGER ::  jje, ije, jjn
181
182     IF (pole_sud) THEN
183       jje=jj_end-1
184       ije=ij_end-iip1
185       jjn=jj_nb-1
186     ELSE
187       jje=jj_end
188       ije=ij_end
189       jjn=jj_nb
190     ENDIF
191
192     NewField(:,jj_begin:jje)=reshape(Field(ij_begin:ije),(/iip1,jjn/))
193
194!$OMP BARRIER       
195!$OMP MASTER
196     CALL xios_send_field(name, NewField(:,jj_begin:jje))
197!$OMP END MASTER   
198 
199   END SUBROUTINE  writefield_dyn1d_v
200
201   SUBROUTINE  writefield_dyn2d_v(name,Field)
202
203     USE parallel_lmdz
204     IMPLICIT NONE
205     include 'dimensions.h'
206     include 'paramet.h'
207     CHARACTER(LEN=*)   :: name
208     REAL, DIMENSION(ij_begin:ij_end,llm) :: Field
209     REAL, DIMENSION(iip1,  jj_begin:jj_end,llm) :: NewField
210     INTEGER :: l, jje, ije, jjn
211
212     IF (pole_sud) THEN
213       jje=jj_end-1
214       ije=ij_end-iip1
215       jjn=jj_nb-1
216     ELSE
217       jje=jj_end
218       ije=ij_end
219       jjn=jj_nb
220     ENDIF
221
222
223!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
224     DO l = 1, llm
225        NewField(:,jj_begin:jje,l)=reshape(Field(ij_begin:ije,l),(/iip1,jjn/))
226     ENDDO
227!$OMP ENDDO
228
229!$OMP BARRIER       
230!$OMP MASTER
231     CALL xios_send_field(name, NewField(:,jj_begin:jje,:))
232!$OMP END MASTER   
233 
234   END SUBROUTINE  writefield_dyn2d_v
235   
236END MODULE mod_xios_dyn3dmem
237#endif
238
Note: See TracBrowser for help on using the repository browser.