1 | ! |
---|
2 | MODULE oasis |
---|
3 | ! |
---|
4 | ! This module contains subroutines for initialization, sending and receiving |
---|
5 | ! towards the coupler OASIS3. It also contains some parameters for the coupling. |
---|
6 | ! |
---|
7 | ! This module should always be compiled. With the coupler OASIS3 available the cpp key |
---|
8 | ! CPP_COUPLE should be set and the entier of this file will then be compiled. |
---|
9 | ! In a forced mode CPP_COUPLE should not be defined and the compilation ends before |
---|
10 | ! the CONTAINS, without compiling the subroutines. |
---|
11 | ! |
---|
12 | USE dimphy |
---|
13 | USE mod_phys_lmdz_para |
---|
14 | USE write_field_phy |
---|
15 | |
---|
16 | #ifdef CPP_COUPLE |
---|
17 | ! Use of Oasis-MCT coupler |
---|
18 | #if defined CPP_OMCT |
---|
19 | USE mod_prism |
---|
20 | ! Use of Oasis3 coupler |
---|
21 | #else |
---|
22 | USE mod_prism_proto |
---|
23 | USE mod_prism_def_partition_proto |
---|
24 | USE mod_prism_get_proto |
---|
25 | USE mod_prism_put_proto |
---|
26 | #endif |
---|
27 | #endif |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | |
---|
31 | ! Id for fields sent to ocean |
---|
32 | INTEGER, PARAMETER :: ids_tauxxu = 1 |
---|
33 | INTEGER, PARAMETER :: ids_tauyyu = 2 |
---|
34 | INTEGER, PARAMETER :: ids_tauzzu = 3 |
---|
35 | INTEGER, PARAMETER :: ids_tauxxv = 4 |
---|
36 | INTEGER, PARAMETER :: ids_tauyyv = 5 |
---|
37 | INTEGER, PARAMETER :: ids_tauzzv = 6 |
---|
38 | INTEGER, PARAMETER :: ids_windsp = 7 |
---|
39 | INTEGER, PARAMETER :: ids_shfice = 8 |
---|
40 | INTEGER, PARAMETER :: ids_shfoce = 9 |
---|
41 | INTEGER, PARAMETER :: ids_shftot = 10 |
---|
42 | INTEGER, PARAMETER :: ids_nsfice = 11 |
---|
43 | INTEGER, PARAMETER :: ids_nsfoce = 12 |
---|
44 | INTEGER, PARAMETER :: ids_nsftot = 13 |
---|
45 | INTEGER, PARAMETER :: ids_dflxdt = 14 |
---|
46 | INTEGER, PARAMETER :: ids_totrai = 15 |
---|
47 | INTEGER, PARAMETER :: ids_totsno = 16 |
---|
48 | INTEGER, PARAMETER :: ids_toteva = 17 |
---|
49 | INTEGER, PARAMETER :: ids_icevap = 18 |
---|
50 | INTEGER, PARAMETER :: ids_ocevap = 19 |
---|
51 | INTEGER, PARAMETER :: ids_calvin = 20 |
---|
52 | INTEGER, PARAMETER :: ids_liqrun = 21 |
---|
53 | INTEGER, PARAMETER :: ids_runcoa = 22 |
---|
54 | INTEGER, PARAMETER :: ids_rivflu = 23 |
---|
55 | INTEGER, PARAMETER :: ids_atmco2 = 24 |
---|
56 | INTEGER, PARAMETER :: ids_taumod = 25 |
---|
57 | INTEGER, PARAMETER :: ids_qraioc = 26 |
---|
58 | INTEGER, PARAMETER :: ids_qsnooc = 27 |
---|
59 | INTEGER, PARAMETER :: ids_qraiic = 28 |
---|
60 | INTEGER, PARAMETER :: ids_qsnoic = 29 |
---|
61 | INTEGER, PARAMETER :: ids_delta_sst = 30, ids_delta_sal = 31 |
---|
62 | |
---|
63 | INTEGER, PARAMETER :: maxsend = 31 ! Maximum number of fields to send |
---|
64 | |
---|
65 | ! Id for fields received from ocean |
---|
66 | |
---|
67 | INTEGER, PARAMETER :: idr_sisutw = 1 |
---|
68 | INTEGER, PARAMETER :: idr_icecov = 2 |
---|
69 | INTEGER, PARAMETER :: idr_icealw = 3 |
---|
70 | INTEGER, PARAMETER :: idr_icetem = 4 |
---|
71 | INTEGER, PARAMETER :: idr_curenx = 5 |
---|
72 | INTEGER, PARAMETER :: idr_cureny = 6 |
---|
73 | INTEGER, PARAMETER :: idr_curenz = 7 |
---|
74 | INTEGER, PARAMETER :: idr_oceco2 = 8 |
---|
75 | |
---|
76 | INTEGER, PARAMETER :: idr_sss = 9 |
---|
77 | ! bulk salinity of the surface layer of the ocean, in ppt |
---|
78 | |
---|
79 | INTEGER, PARAMETER :: maxrecv = 9 ! Maximum number of fields to receive |
---|
80 | |
---|
81 | |
---|
82 | TYPE, PUBLIC :: FLD_CPL ! Type for coupling field information |
---|
83 | CHARACTER(len = 8) :: name ! Name of the coupling field |
---|
84 | LOGICAL :: action ! To be exchanged or not |
---|
85 | INTEGER :: nid ! Id of the field |
---|
86 | END TYPE FLD_CPL |
---|
87 | |
---|
88 | TYPE(FLD_CPL), DIMENSION(maxsend), SAVE, PUBLIC :: infosend ! Information for sending coupling fields |
---|
89 | !$OMP THREADPRIVATE(infosend) |
---|
90 | TYPE(FLD_CPL), DIMENSION(maxrecv), SAVE, PUBLIC :: inforecv ! Information for receiving coupling fields |
---|
91 | !$OMP THREADPRIVATE(inforecv) |
---|
92 | |
---|
93 | LOGICAL,SAVE :: cpl_current |
---|
94 | !$OMP THREADPRIVATE(cpl_current) |
---|
95 | |
---|
96 | #ifdef CPP_COUPLE |
---|
97 | |
---|
98 | CONTAINS |
---|
99 | |
---|
100 | SUBROUTINE inicma |
---|
101 | !************************************************************************************ |
---|
102 | !**** *INICMA* - Initialize coupled mode communication for atmosphere |
---|
103 | ! and exchange some initial information with Oasis |
---|
104 | ! |
---|
105 | ! Rewrite to take the PRISM/psmile library into account |
---|
106 | ! LF 09/2003 |
---|
107 | ! |
---|
108 | USE IOIPSL |
---|
109 | USE surface_data, ONLY : version_ocean |
---|
110 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl |
---|
111 | #ifdef CPP_XIOS |
---|
112 | USE wxios, ONLY : wxios_context_init |
---|
113 | USE xios |
---|
114 | #endif |
---|
115 | USE print_control_mod, ONLY: lunout |
---|
116 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat |
---|
117 | USE geometry_mod, ONLY: ind_cell_glo |
---|
118 | USE mod_phys_lmdz_mpi_data, ONLY: klon_mpi_para_nb |
---|
119 | use config_ocean_skin_m, only: activate_ocean_skin |
---|
120 | |
---|
121 | ! Local variables |
---|
122 | !************************************************************************************ |
---|
123 | INTEGER :: comp_id |
---|
124 | INTEGER :: ierror, il_commlocal |
---|
125 | INTEGER :: il_part_id |
---|
126 | INTEGER, ALLOCATABLE :: ig_paral(:) |
---|
127 | INTEGER, DIMENSION(2) :: il_var_nodims |
---|
128 | INTEGER, DIMENSION(4) :: il_var_actual_shape |
---|
129 | INTEGER :: il_var_type |
---|
130 | INTEGER :: jf |
---|
131 | CHARACTER (len = 6) :: clmodnam |
---|
132 | CHARACTER (len = 20) :: modname = 'inicma' |
---|
133 | CHARACTER (len = 80) :: abort_message |
---|
134 | LOGICAL, SAVE :: cpl_current_omp |
---|
135 | |
---|
136 | !* 1. Initializations |
---|
137 | ! --------------- |
---|
138 | !************************************************************************************ |
---|
139 | WRITE(lunout,*) ' ' |
---|
140 | WRITE(lunout,*) ' ' |
---|
141 | WRITE(lunout,*) ' ROUTINE INICMA' |
---|
142 | WRITE(lunout,*) ' **************' |
---|
143 | WRITE(lunout,*) ' ' |
---|
144 | WRITE(lunout,*) ' ' |
---|
145 | |
---|
146 | ! |
---|
147 | ! Define the model name |
---|
148 | ! |
---|
149 | IF (grid_type==unstructured) THEN |
---|
150 | clmodnam = 'icosa' ! as in $NBMODEL in Cpl/Nam/namcouple.tmp |
---|
151 | ELSE IF (grid_type==regular_lonlat) THEN |
---|
152 | clmodnam = 'LMDZ' ! as in $NBMODEL in Cpl/Nam/namcouple.tmp |
---|
153 | ELSE |
---|
154 | abort_message='Pb : type of grid unknown' |
---|
155 | CALL abort_physic(modname,abort_message,1) |
---|
156 | ENDIF |
---|
157 | |
---|
158 | |
---|
159 | !************************************************************************************ |
---|
160 | ! Define if coupling ocean currents or not |
---|
161 | !************************************************************************************ |
---|
162 | !$OMP MASTER |
---|
163 | cpl_current_omp = .FALSE. |
---|
164 | CALL getin('cpl_current', cpl_current_omp) |
---|
165 | !$OMP END MASTER |
---|
166 | !$OMP BARRIER |
---|
167 | cpl_current = cpl_current_omp |
---|
168 | WRITE(lunout,*) 'Couple ocean currents, cpl_current = ',cpl_current |
---|
169 | |
---|
170 | !************************************************************************************ |
---|
171 | ! Define coupling variables |
---|
172 | !************************************************************************************ |
---|
173 | |
---|
174 | ! Atmospheric variables to send |
---|
175 | |
---|
176 | !$OMP MASTER |
---|
177 | infosend(:)%action = .FALSE. |
---|
178 | |
---|
179 | infosend(ids_tauxxu)%action = .TRUE. ; infosend(ids_tauxxu)%name = 'COTAUXXU' |
---|
180 | infosend(ids_tauyyu)%action = .TRUE. ; infosend(ids_tauyyu)%name = 'COTAUYYU' |
---|
181 | infosend(ids_tauzzu)%action = .TRUE. ; infosend(ids_tauzzu)%name = 'COTAUZZU' |
---|
182 | infosend(ids_tauxxv)%action = .TRUE. ; infosend(ids_tauxxv)%name = 'COTAUXXV' |
---|
183 | infosend(ids_tauyyv)%action = .TRUE. ; infosend(ids_tauyyv)%name = 'COTAUYYV' |
---|
184 | infosend(ids_tauzzv)%action = .TRUE. ; infosend(ids_tauzzv)%name = 'COTAUZZV' |
---|
185 | infosend(ids_windsp)%action = .TRUE. ; infosend(ids_windsp)%name = 'COWINDSP' |
---|
186 | infosend(ids_shfice)%action = .TRUE. ; infosend(ids_shfice)%name = 'COSHFICE' |
---|
187 | infosend(ids_nsfice)%action = .TRUE. ; infosend(ids_nsfice)%name = 'CONSFICE' |
---|
188 | infosend(ids_dflxdt)%action = .TRUE. ; infosend(ids_dflxdt)%name = 'CODFLXDT' |
---|
189 | infosend(ids_calvin)%action = .TRUE. ; infosend(ids_calvin)%name = 'COCALVIN' |
---|
190 | |
---|
191 | if (activate_ocean_skin == 2) then |
---|
192 | infosend(ids_delta_sst)%action = .TRUE. |
---|
193 | infosend(ids_delta_sst)%name = 'CODELSST' |
---|
194 | infosend(ids_delta_sal)%action = .TRUE. |
---|
195 | infosend(ids_delta_sal)%name = 'CODELSSS' |
---|
196 | end if |
---|
197 | |
---|
198 | IF (version_ocean=='nemo') THEN |
---|
199 | infosend(ids_shftot)%action = .TRUE. ; infosend(ids_shftot)%name = 'COQSRMIX' |
---|
200 | infosend(ids_nsftot)%action = .TRUE. ; infosend(ids_nsftot)%name = 'COQNSMIX' |
---|
201 | infosend(ids_totrai)%action = .TRUE. ; infosend(ids_totrai)%name = 'COTOTRAI' |
---|
202 | infosend(ids_totsno)%action = .TRUE. ; infosend(ids_totsno)%name = 'COTOTSNO' |
---|
203 | infosend(ids_toteva)%action = .TRUE. ; infosend(ids_toteva)%name = 'COTOTEVA' |
---|
204 | infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COICEVAP' |
---|
205 | infosend(ids_liqrun)%action = .TRUE. ; infosend(ids_liqrun)%name = 'COLIQRUN' |
---|
206 | infosend(ids_taumod)%action = .TRUE. ; infosend(ids_taumod)%name = 'COTAUMOD' |
---|
207 | IF (carbon_cycle_cpl) THEN |
---|
208 | infosend(ids_atmco2)%action = .TRUE. ; infosend(ids_atmco2)%name = 'COATMCO2' |
---|
209 | ENDIF |
---|
210 | infosend(ids_qraioc)%action = .TRUE. ; infosend(ids_qraioc)%name = 'COQRAIOC' |
---|
211 | infosend(ids_qsnooc)%action = .TRUE. ; infosend(ids_qsnooc)%name = 'COQSNOOC' |
---|
212 | infosend(ids_qraiic)%action = .TRUE. ; infosend(ids_qraiic)%name = 'COQRAIIC' |
---|
213 | infosend(ids_qsnoic)%action = .TRUE. ; infosend(ids_qsnoic)%name = 'COQSNOIC' |
---|
214 | |
---|
215 | ELSE IF (version_ocean=='opa8') THEN |
---|
216 | infosend(ids_shfoce)%action = .TRUE. ; infosend(ids_shfoce)%name = 'COSHFOCE' |
---|
217 | infosend(ids_nsfoce)%action = .TRUE. ; infosend(ids_nsfoce)%name = 'CONSFOCE' |
---|
218 | infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COTFSICE' |
---|
219 | infosend(ids_ocevap)%action = .TRUE. ; infosend(ids_ocevap)%name = 'COTFSOCE' |
---|
220 | infosend(ids_totrai)%action = .TRUE. ; infosend(ids_totrai)%name = 'COTOLPSU' |
---|
221 | infosend(ids_totsno)%action = .TRUE. ; infosend(ids_totsno)%name = 'COTOSPSU' |
---|
222 | infosend(ids_runcoa)%action = .TRUE. ; infosend(ids_runcoa)%name = 'CORUNCOA' |
---|
223 | infosend(ids_rivflu)%action = .TRUE. ; infosend(ids_rivflu)%name = 'CORIVFLU' |
---|
224 | ENDIF |
---|
225 | |
---|
226 | ! Oceanic variables to receive |
---|
227 | |
---|
228 | inforecv(:)%action = .FALSE. |
---|
229 | |
---|
230 | inforecv(idr_sisutw)%action = .TRUE. ; inforecv(idr_sisutw)%name = 'SISUTESW' |
---|
231 | inforecv(idr_icecov)%action = .TRUE. ; inforecv(idr_icecov)%name = 'SIICECOV' |
---|
232 | inforecv(idr_icealw)%action = .TRUE. ; inforecv(idr_icealw)%name = 'SIICEALW' |
---|
233 | inforecv(idr_icetem)%action = .TRUE. ; inforecv(idr_icetem)%name = 'SIICTEMW' |
---|
234 | |
---|
235 | if (activate_ocean_skin >= 1) then |
---|
236 | inforecv(idr_sss)%action = .TRUE. |
---|
237 | inforecv(idr_sss)%name = 'SISUSALW' |
---|
238 | end if |
---|
239 | |
---|
240 | IF (cpl_current ) THEN |
---|
241 | inforecv(idr_curenx)%action = .TRUE. ; inforecv(idr_curenx)%name = 'CURRENTX' |
---|
242 | inforecv(idr_cureny)%action = .TRUE. ; inforecv(idr_cureny)%name = 'CURRENTY' |
---|
243 | inforecv(idr_curenz)%action = .TRUE. ; inforecv(idr_curenz)%name = 'CURRENTZ' |
---|
244 | ENDIF |
---|
245 | |
---|
246 | IF (carbon_cycle_cpl ) THEN |
---|
247 | inforecv(idr_oceco2)%action = .TRUE. ; inforecv(idr_oceco2)%name = 'SICO2FLX' |
---|
248 | ENDIF |
---|
249 | |
---|
250 | !************************************************************************************ |
---|
251 | ! Here we go: psmile initialisation |
---|
252 | !************************************************************************************ |
---|
253 | IF (is_sequential) THEN |
---|
254 | CALL prism_init_comp_proto (comp_id, clmodnam, ierror) |
---|
255 | |
---|
256 | IF (ierror .NE. PRISM_Ok) THEN |
---|
257 | abort_message=' Probleme init dans prism_init_comp ' |
---|
258 | CALL abort_physic(modname,abort_message,1) |
---|
259 | ELSE |
---|
260 | WRITE(lunout,*) 'inicma : init psmile ok ' |
---|
261 | ENDIF |
---|
262 | ENDIF |
---|
263 | |
---|
264 | CALL prism_get_localcomm_proto (il_commlocal, ierror) |
---|
265 | !************************************************************************************ |
---|
266 | ! Domain decomposition |
---|
267 | !************************************************************************************ |
---|
268 | IF (grid_type==unstructured) THEN |
---|
269 | |
---|
270 | ALLOCATE( ig_paral(klon_mpi_para_nb(mpi_rank) + 2) ) |
---|
271 | |
---|
272 | ig_paral(1) = 4 ! points partition for // |
---|
273 | ig_paral(2) = klon_mpi_para_nb(mpi_rank) ! nb of local cells |
---|
274 | |
---|
275 | DO jf=1, klon_mpi_para_nb(mpi_rank) |
---|
276 | ig_paral(2+jf) = ind_cell_glo(jf) |
---|
277 | ENDDO |
---|
278 | |
---|
279 | ELSE IF (grid_type==regular_lonlat) THEN |
---|
280 | |
---|
281 | ALLOCATE( ig_paral(3) ) |
---|
282 | |
---|
283 | ig_paral(1) = 1 ! apple partition for // |
---|
284 | ig_paral(2) = (jj_begin-1)*nbp_lon+ii_begin-1 ! offset |
---|
285 | ig_paral(3) = (jj_end*nbp_lon+ii_end) - (jj_begin*nbp_lon+ii_begin) + 1 |
---|
286 | |
---|
287 | IF (mpi_rank==mpi_size-1) ig_paral(3)=ig_paral(3)+nbp_lon-1 |
---|
288 | ELSE |
---|
289 | abort_message='Pb : type of grid unknown' |
---|
290 | CALL abort_physic(modname,abort_message,1) |
---|
291 | ENDIF |
---|
292 | |
---|
293 | |
---|
294 | WRITE(lunout,*) mpi_rank,'ig_paral--->',ig_paral(2),ig_paral(3) |
---|
295 | |
---|
296 | ierror=PRISM_Ok |
---|
297 | CALL prism_def_partition_proto (il_part_id, ig_paral, ierror) |
---|
298 | |
---|
299 | IF (ierror .NE. PRISM_Ok) THEN |
---|
300 | abort_message=' Probleme dans prism_def_partition ' |
---|
301 | CALL abort_physic(modname,abort_message,1) |
---|
302 | ELSE |
---|
303 | WRITE(lunout,*) 'inicma : decomposition domaine psmile ok ' |
---|
304 | ENDIF |
---|
305 | |
---|
306 | il_var_nodims(1) = 2 ! rank of field array (1d or 2d) |
---|
307 | il_var_nodims(2) = 1 ! always 1 in current oasis version" doc oasis3mct p18 |
---|
308 | |
---|
309 | il_var_actual_shape(1) = 1 ! min of 1st dimension (always 1) |
---|
310 | il_var_actual_shape(2) = nbp_lon ! max of 1st dimension |
---|
311 | il_var_actual_shape(3) = 1 ! min of 2nd dimension (always 1) |
---|
312 | il_var_actual_shape(4) = nbp_lat ! max of 2nd dimension |
---|
313 | |
---|
314 | il_var_type = PRISM_Real |
---|
315 | |
---|
316 | !************************************************************************************ |
---|
317 | ! Oceanic Fields to receive |
---|
318 | ! Loop over all possible variables |
---|
319 | !************************************************************************************ |
---|
320 | DO jf=1, maxrecv |
---|
321 | IF (inforecv(jf)%action) THEN |
---|
322 | CALL prism_def_var_proto(inforecv(jf)%nid, inforecv(jf)%name, il_part_id, & |
---|
323 | il_var_nodims, PRISM_In, il_var_actual_shape, il_var_type, & |
---|
324 | ierror) |
---|
325 | IF (ierror .NE. PRISM_Ok) THEN |
---|
326 | WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',& |
---|
327 | inforecv(jf)%name |
---|
328 | abort_message=' Problem in call to prism_def_var_proto for fields to receive' |
---|
329 | CALL abort_physic(modname,abort_message,1) |
---|
330 | ENDIF |
---|
331 | ENDIF |
---|
332 | END DO |
---|
333 | |
---|
334 | !************************************************************************************ |
---|
335 | ! Atmospheric Fields to send |
---|
336 | ! Loop over all possible variables |
---|
337 | !************************************************************************************ |
---|
338 | DO jf=1,maxsend |
---|
339 | IF (infosend(jf)%action) THEN |
---|
340 | CALL prism_def_var_proto(infosend(jf)%nid, infosend(jf)%name, il_part_id, & |
---|
341 | il_var_nodims, PRISM_Out, il_var_actual_shape, il_var_type, & |
---|
342 | ierror) |
---|
343 | IF (ierror .NE. PRISM_Ok) THEN |
---|
344 | WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',& |
---|
345 | infosend(jf)%name |
---|
346 | abort_message=' Problem in call to prism_def_var_proto for fields to send' |
---|
347 | CALL abort_physic(modname,abort_message,1) |
---|
348 | ENDIF |
---|
349 | ENDIF |
---|
350 | END DO |
---|
351 | |
---|
352 | !************************************************************************************ |
---|
353 | ! End definition |
---|
354 | !************************************************************************************ |
---|
355 | #ifdef CPP_XIOS |
---|
356 | CALL xios_oasis_enddef() |
---|
357 | #endif |
---|
358 | CALL prism_enddef_proto(ierror) |
---|
359 | IF (ierror .NE. PRISM_Ok) THEN |
---|
360 | abort_message=' Problem in call to prism_endef_proto' |
---|
361 | CALL abort_physic(modname,abort_message,1) |
---|
362 | ELSE |
---|
363 | WRITE(lunout,*) 'inicma : endef psmile ok ' |
---|
364 | ENDIF |
---|
365 | |
---|
366 | #ifdef CPP_XIOS |
---|
367 | ! CALL wxios_context_init() |
---|
368 | #endif |
---|
369 | |
---|
370 | !$OMP END MASTER |
---|
371 | |
---|
372 | END SUBROUTINE inicma |
---|
373 | |
---|
374 | ! |
---|
375 | !************************************************************************************ |
---|
376 | ! |
---|
377 | |
---|
378 | SUBROUTINE fromcpl(ktime, tab_get) |
---|
379 | ! ====================================================================== |
---|
380 | ! L. Fairhead (09/2003) adapted From L.Z.X Li: this subroutine reads the SST |
---|
381 | ! and Sea-Ice provided by the coupler. Adaptation to psmile library |
---|
382 | !====================================================================== |
---|
383 | ! |
---|
384 | USE print_control_mod, ONLY: lunout |
---|
385 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat |
---|
386 | ! Input arguments |
---|
387 | !************************************************************************************ |
---|
388 | INTEGER, INTENT(IN) :: ktime |
---|
389 | |
---|
390 | ! Output arguments |
---|
391 | !************************************************************************************ |
---|
392 | REAL, DIMENSION(nbp_lon, jj_nb,maxrecv), INTENT(OUT) :: tab_get |
---|
393 | |
---|
394 | ! Local variables |
---|
395 | !************************************************************************************ |
---|
396 | INTEGER :: ierror, i |
---|
397 | INTEGER :: istart,iend |
---|
398 | CHARACTER (len = 20) :: modname = 'fromcpl' |
---|
399 | CHARACTER (len = 80) :: abort_message |
---|
400 | REAL, DIMENSION(nbp_lon*jj_nb) :: field |
---|
401 | |
---|
402 | !************************************************************************************ |
---|
403 | WRITE (lunout,*) ' ' |
---|
404 | WRITE (lunout,*) 'Fromcpl: Reading fields from CPL, ktime=',ktime |
---|
405 | WRITE (lunout,*) ' ' |
---|
406 | |
---|
407 | istart=ii_begin |
---|
408 | IF (is_south_pole_dyn) THEN |
---|
409 | iend=(jj_end-jj_begin)*nbp_lon+nbp_lon |
---|
410 | ELSE |
---|
411 | iend=(jj_end-jj_begin)*nbp_lon+ii_end |
---|
412 | ENDIF |
---|
413 | |
---|
414 | DO i = 1, maxrecv |
---|
415 | IF (inforecv(i)%action .AND. inforecv(i)%nid .NE. -1) THEN |
---|
416 | field(:) = -99999. |
---|
417 | CALL prism_get_proto(inforecv(i)%nid, ktime, field(istart:iend), ierror) |
---|
418 | tab_get(:,:,i) = RESHAPE(field(:),(/nbp_lon,jj_nb/)) |
---|
419 | |
---|
420 | IF (ierror .NE. PRISM_Ok .AND. ierror.NE.PRISM_Recvd .AND. & |
---|
421 | ierror.NE.PRISM_FromRest & |
---|
422 | .AND. ierror.NE.PRISM_Input .AND. ierror.NE.PRISM_RecvOut & |
---|
423 | .AND. ierror.NE.PRISM_FromRestOut) THEN |
---|
424 | WRITE (lunout,*) 'Error with receiving filed : ', inforecv(i)%name, ktime |
---|
425 | abort_message=' Problem in prism_get_proto ' |
---|
426 | CALL abort_physic(modname,abort_message,1) |
---|
427 | ENDIF |
---|
428 | ENDIF |
---|
429 | END DO |
---|
430 | |
---|
431 | |
---|
432 | END SUBROUTINE fromcpl |
---|
433 | |
---|
434 | ! |
---|
435 | !************************************************************************************ |
---|
436 | ! |
---|
437 | |
---|
438 | SUBROUTINE intocpl(ktime, last, tab_put) |
---|
439 | ! ====================================================================== |
---|
440 | ! L. Fairhead (09/2003) adapted From L.Z.X Li: this subroutine provides the |
---|
441 | ! atmospheric coupling fields to the coupler with the psmile library. |
---|
442 | ! IF last time step, writes output fields to binary files. |
---|
443 | ! ====================================================================== |
---|
444 | ! |
---|
445 | ! |
---|
446 | USE print_control_mod, ONLY: lunout |
---|
447 | USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat |
---|
448 | ! Input arguments |
---|
449 | !************************************************************************************ |
---|
450 | INTEGER, INTENT(IN) :: ktime |
---|
451 | LOGICAL, INTENT(IN) :: last |
---|
452 | REAL, DIMENSION(nbp_lon, jj_nb, maxsend), INTENT(IN) :: tab_put |
---|
453 | |
---|
454 | ! Local variables |
---|
455 | !************************************************************************************ |
---|
456 | LOGICAL :: checkout |
---|
457 | INTEGER :: istart,iend |
---|
458 | INTEGER :: wstart,wend |
---|
459 | INTEGER :: ierror, i |
---|
460 | REAL, DIMENSION(nbp_lon*jj_nb) :: field |
---|
461 | CHARACTER (len = 20),PARAMETER :: modname = 'intocpl' |
---|
462 | CHARACTER (len = 80) :: abort_message |
---|
463 | |
---|
464 | !************************************************************************************ |
---|
465 | checkout=.FALSE. |
---|
466 | |
---|
467 | WRITE(lunout,*) ' ' |
---|
468 | WRITE(lunout,*) 'Intocpl: sending fields to CPL, ktime= ', ktime |
---|
469 | WRITE(lunout,*) 'last = ', last |
---|
470 | WRITE(lunout,*) |
---|
471 | |
---|
472 | |
---|
473 | istart=ii_begin |
---|
474 | IF (is_south_pole_dyn) THEN |
---|
475 | iend=(jj_end-jj_begin)*nbp_lon+nbp_lon |
---|
476 | ELSE |
---|
477 | iend=(jj_end-jj_begin)*nbp_lon+ii_end |
---|
478 | ENDIF |
---|
479 | |
---|
480 | IF (checkout) THEN |
---|
481 | wstart=istart |
---|
482 | wend=iend |
---|
483 | IF (is_north_pole_dyn) wstart=istart+nbp_lon-1 |
---|
484 | IF (is_south_pole_dyn) wend=iend-nbp_lon+1 |
---|
485 | |
---|
486 | DO i = 1, maxsend |
---|
487 | IF (infosend(i)%action) THEN |
---|
488 | field = RESHAPE(tab_put(:,:,i),(/nbp_lon*jj_nb/)) |
---|
489 | CALL writefield_phy(infosend(i)%name,field(wstart:wend),1) |
---|
490 | END IF |
---|
491 | END DO |
---|
492 | END IF |
---|
493 | |
---|
494 | !************************************************************************************ |
---|
495 | ! PRISM_PUT |
---|
496 | !************************************************************************************ |
---|
497 | |
---|
498 | DO i = 1, maxsend |
---|
499 | IF (infosend(i)%action .AND. infosend(i)%nid .NE. -1 ) THEN |
---|
500 | field = RESHAPE(tab_put(:,:,i),(/nbp_lon*jj_nb/)) |
---|
501 | CALL prism_put_proto(infosend(i)%nid, ktime, field(istart:iend), ierror) |
---|
502 | |
---|
503 | IF (ierror .NE. PRISM_Ok .AND. ierror.NE.PRISM_Sent .AND. ierror.NE.PRISM_ToRest & |
---|
504 | .AND. ierror.NE.PRISM_LocTrans .AND. ierror.NE.PRISM_Output .AND. & |
---|
505 | ierror.NE.PRISM_SentOut .AND. ierror.NE.PRISM_ToRestOut) THEN |
---|
506 | WRITE (lunout,*) 'Error with sending field :', infosend(i)%name, ktime |
---|
507 | abort_message=' Problem in prism_put_proto ' |
---|
508 | CALL abort_physic(modname,abort_message,1) |
---|
509 | ENDIF |
---|
510 | ENDIF |
---|
511 | END DO |
---|
512 | |
---|
513 | !************************************************************************************ |
---|
514 | ! Finalize PSMILE for the case is_sequential, if parallel finalization is done |
---|
515 | ! from Finalize_parallel in dyn3dpar/parallel.F90 |
---|
516 | !************************************************************************************ |
---|
517 | |
---|
518 | IF (last) THEN |
---|
519 | IF (is_sequential) THEN |
---|
520 | CALL prism_terminate_proto(ierror) |
---|
521 | IF (ierror .NE. PRISM_Ok) THEN |
---|
522 | abort_message=' Problem in prism_terminate_proto ' |
---|
523 | CALL abort_physic(modname,abort_message,1) |
---|
524 | ENDIF |
---|
525 | ENDIF |
---|
526 | ENDIF |
---|
527 | |
---|
528 | |
---|
529 | END SUBROUTINE intocpl |
---|
530 | |
---|
531 | #endif |
---|
532 | |
---|
533 | END MODULE oasis |
---|