source: LMDZ6/branches/contrails/libf/phylmd/oasis.F90 @ 5450

Last change on this file since 5450 was 5310, checked in by abarral, 7 weeks ago

unify abort_gcm
rename wxios -> wxios_mod

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