source: CPL/oasis3/trunk/src/mod/oasis3/src/inicmc.F @ 1677

Last change on this file since 1677 was 1677, checked in by aclsce, 12 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 24.1 KB
Line 
1      SUBROUTINE inicmc
2C****
3C               *****************************
4C               * OASIS ROUTINE  -  LEVEL C *
5C               * -------------     ------- *
6C               *****************************
7C
8C**** *inicmc*  - Initialize coupled mode communication for coupler
9C
10C     Purpose:
11C     -------
12C     Use either PIPE, CLIM, SIPC or GMEM library to start communication with
13C     the models being coupled. The PIPE library uses named pipes(fifo)
14C     while CLIM uses message passing library MPI-1 or MPI-2.
15C     The SIPC library uses shared memory segments based on system V IPC.
16C     The GMEM library uses the global memory concept of NEC machines.
17C     In cases SIPC, GMEM or PIPE, signal handling is implemented to trap 
18C     oasis or child status changes.
19C
20C**   Interface:
21C     ---------
22C       *CALL*  *inicmc*
23C
24C     Input:
25C     -----
26C     None
27C
28C     Output:
29C     ------
30C     None
31C
32C     Workspace:
33C     ---------
34C     None
35C
36C     Externals:
37C     ---------
38C     (CLIM-PIPE-SIPC)_Init, (CLIM-PIPE-SIPC)_Define, (CLIM-PIPE-SIPC)_Stepi, 
39C     CLIM_Start, chksgc
40C
41C     Reference:
42C     ---------
43C     See OASIS manual (2000)
44C
45C     History:
46C     -------
47C       Version   Programmer     Date      Description
48C       -------   ----------     ----      ----------- 
49C       1.0       L. Terray      94/01/01  created
50C       2.0       L. Terray      95/09/01  modified : new structure
51C       2.1       L. Terray      96/09/03  mofified : norm DOCTOR (loop
52C                                          index jp --> jl)
53C       2.2       S. Valcke      97/06/20  added: introduction of SVIPC
54C       2.2       L. Terray      97/09/20  general cleaning + call chksgc
55C       2.3       S. Valcke      99/04/30  added: printing levels
56C       2.3       L. Terray      99/09/15  added: GMEM branch
57C       2.4       S. Valcke      2K/05/01  added: llmodel for CLIM/MPI2
58C       2.5       S. Valcke      2K/09/04  Remove cmach
59C       2.5       S. Valcke      2K/09/08  -Remove llmodel
60C                                          -Modified CALL to CLIM_Init
61C       2.5       J. Latour      01/11/28  added : MPI1 use of mpirun
62C
63C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64C
65C* ---------------- Include files and USE of modules---------------------------
66C
67      USE mod_kinds_oasis
68#if defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
69      USE mod_clim
70      USE mod_clim_def
71      USE mod_comclim
72#endif
73      USE mod_parameter
74      USE mod_parallel
75      USE mod_string
76      USE mod_unitncdf
77      USE mod_experiment
78      USE mod_timestep
79      USE mod_unit
80      USE mod_hardware
81      USE mod_printing
82      USE mod_analysis
83      USE mod_label
84      USE mod_gauss
85#if defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
86#include <mpif.h>
87#endif
88C
89C* ---------------------------- Local declarations ----------------------
90C
91      INTEGER (kind=ip_intwp_p) il_dimid(2)
92      INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: info 
93      INTEGER (kind=ip_intwp_p) iparal(3)
94      INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: il_sizold,
95     $    il_siznew, il_maxaux
96      CHARACTER*8 clpinp, clpout
97      CHARACTER*8 clwork, clstrg
98      CHARACTER(len=8), DIMENSION(:), ALLOCATABLE :: cl_auxaf, cl_auxbf
99      INTEGER (kind=ip_intwp_p) :: il_ibyt, il_bufsendsize, 
100     $    il_bufsendsizebyt, il_varid, ii, io_size, integer_io_size
101      INTEGER (kind=ip_intwp_p) :: integer_byte_size
102      REAL(kind=ip_double_p) rl_testvar
103c
104C
105C* ---------------------------- Poema verses ----------------------------
106C
107C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108C
109C*    1. Allocation and initializations 
110C        ------------------------------
111C
112      IF (nlogprt .GE. 1) THEN
113          WRITE (UNIT = nulou,FMT = *) ' '
114          WRITE (UNIT = nulou,FMT = *) ' '
115          WRITE (UNIT = nulou,FMT = *) 
116     $    '           ROUTINE inicmc  -  Level C'
117          WRITE (UNIT = nulou,FMT = *) 
118     $    '           **************     *******'
119          WRITE (UNIT = nulou,FMT = *) ' '
120          WRITE (UNIT = nulou,FMT = *) ' Process stuff initialization'
121          WRITE (UNIT = nulou,FMT = *) ' '
122          WRITE (UNIT = nulou,FMT = *) ' '
123      ENDIF
124      iparal(:)=0
125C
126C* Set up signal handling
127C
128      CALL chksgc
129C
130C* Allocate and initialize error codes (only if all fields aren't exchanged
131C  directly)
132C
133      IF (lg_oasis_field) THEN
134         ALLOCATE(info(ig_nfield))
135         CALL izero (info, ig_nfield)
136      ENDIF
137   
138C
139c
140C* PIPE initialization
141c     
142#ifdef use_comm_PIPE
143C     
144C* Open pipes between models to exchange checking data
145C
146      infos = 0
147      CALL PIPE_Init (cjobnam, cmodnam, ig_nmodel, infos)
148      IF (infos .NE. 0) THEN
149         WRITE (UNIT = nulou,FMT = *)
150     $        ' WARNING : Problem with model pipe initialization'
151         WRITE (UNIT = nulou,FMT = *)
152     $        ' =======   Error code number = ',infos
153         CALL HALTE('STOP in inicmc')
154      ENDIF
155C     
156C* SVIPC or GMEM initialization
157C     
158#elif defined use_comm_SIPC || defined use_comm_GMEM
159C     
160C* Open shared memory pools used by models to exchange initial infos
161C     
162      infos = 0
163      CALL SIPC_Init (cjobnam, cmodnam, ig_nmodel, infos)
164      IF (infos .NE. 0) THEN
165         WRITE (UNIT = nulou,FMT = *) 
166     $ 'WARNING : Problem with model shared memory pool initialization'
167         WRITE (UNIT = nulou,FMT = *)
168     $        ' =======   Error code number = ',infos
169         CALL HALTE('STOP in inicmc')
170      ENDIF
171C
172C* CLIM/MPI2 or MPI1 initialization
173C
174#elif defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
175      ione = 1
176      IF (cchan .EQ. 'MPI1') cmpiarg(:)=' '
177      CALL CLIM_Init_Oasis(cjobnam, 'Oasis',
178     $     ig_nmodel, cmodnam, nbcplproc, nbtotproc, cmpiarg,
179     $     iga_unitmod, nultr, infos)
180      IF (infos .NE. CLIM_Ok) THEN
181         WRITE (UNIT = nulou,FMT = *)
182     $        ' WARNING : Problem with MPI initialization '
183         WRITE (UNIT = nulou,FMT = *)
184     $        ' =======  CLIM error code number = ',infos
185         CALL HALTE('STOP in inicmc')
186      ENDIF
187      IF (.not. lg_oasis_field) THEN
188         WRITE (UNIT = nulou,FMT = *)
189     $        '===>>> All the fields are exchanged directly '
190         WRITE (UNIT = nulou,FMT = *)
191     $        ' Oasis calls only his MPI initialization and 
192     $        sleeps until his MPI finalization'
193      ENDIF
194#else
195C     
196C* No message passing case
197C
198      IF (cchan .EQ. 'NONE') THEN
199         IF (nlogprt .GE. 1) THEN
200            WRITE (UNIT = nulou, FMT = *)
201     $           ' NOTE : No message passing used in this run'
202            WRITE (UNIT = nulou,FMT = *)
203     $           ' ======= '
204         ENDIF
205      ELSE
206         CALL prcout('WARNING: your $CHANNEL option is wrong:',
207     $        cchan,1)
208         CALL HALTE('Wrong $CHANNEL option: STOP in inicmc')
209      ENDIF
210C     
211#endif
212C
213C* Put here stuff moved from inipar_alloc because grids.nc (and therefore
214C  grid dimensions) is not available yet.
215C*      If grids.nc file exists, get grid dimensions there.
216C
217        il_dimid(:)=0
218        il_auxbf=0
219        il_auxaf=0
220        allocate(cl_auxbf(ig_nfield))
221        cl_auxbf(:)=' '
222        allocate(cl_auxaf(ig_nfield))
223        cl_auxaf(:)=' '
224        ig_maxold_grid = 0
225        ig_maxnew_grid = 0
226C
227        IF (lncdfgrd) CALL hdlerr
228     $      (NF_OPEN(cgrdnam//'.nc', NF_NOWRITE, nc_grdid), 'inicmc0')
229C       
230        DO 252 jf=1,ig_total_nfield
231          IF (ig_total_state(jf) .ne. ip_input) THEN
232              IF (lncdfgrd) THEN
233C
234C*                Initial dimensions
235                  clwork = cga_locatorbf(jf)
236                  icount = ilenstr(clwork,jpeight)
237                  clstrg = clwork(1:icount)//cglonsuf
238                  CALL hdlerr
239     $                (NF_INQ_VARID(nc_grdid, clstrg, il_varid),
240     $                'inicmc1')
241                  CALL hdlerr
242     $                (NF_INQ_VARDIMID(nc_grdid,il_varid, il_dimid),
243     $                'inicmc2')
244                  CALL hdlerr
245     $                (NF_INQ_DIMLEN(nc_grdid, il_dimid(1), il_len),
246     $                'inicmc3')
247                  IF (lg_state(jf))
248     $                nlonbf(ig_number_field(jf)) = il_len
249                  CALL hdlerr
250     $                (NF_INQ_DIMLEN(nc_grdid, il_dimid(2), il_len),
251     $                'inicmc4')
252                  IF (lg_state(jf))
253     $                nlatbf(ig_number_field(jf)) = il_len
254C     
255C*                Final dimensions
256                  clwork = cga_locatoraf(jf)
257                  icount = ilenstr(clwork,jpeight)
258                  clstrg = clwork(1:icount)//cglonsuf
259                  CALL hdlerr
260     $                (NF_INQ_VARID(nc_grdid, clstrg, il_varid),
261     $                'inicmc5')
262                  CALL hdlerr
263     $                (NF_INQ_VARDIMID(nc_grdid,il_varid, il_dimid),
264     $                'inicmc6')
265                  CALL hdlerr
266     $                (NF_INQ_DIMLEN(nc_grdid, il_dimid(1), il_len),
267     $                'inicmc7')
268                  IF (lg_state(jf))
269     $                nlonaf(ig_number_field(jf)) = il_len
270                  CALL hdlerr
271     $                (NF_INQ_DIMLEN(nc_grdid, il_dimid(2), il_len),
272     $                'inicmc8')
273                  IF (lg_state(jf))
274     $                nlataf(ig_number_field(jf)) = il_len
275C
276C
277               ENDIF
278           ENDIF
279C
280C* Get the number of different grids used
281C
282           IF (lg_state(jf)) then
283              IF (ig_number_field(jf).eq.1) THEN
284                 cl_auxbf(1) = cficbf(1)
285                 cl_auxaf(1) = cficaf(1)
286                 ig_grid_nbrbf(1)=1
287                 ig_grid_nbraf(1)=1
288                 il_auxbf = 1
289                 il_auxaf = 1
290                 ig_maxold_grid = nlonbf(ig_number_field(jf)) *
291     $                nlatbf(ig_number_field(jf))
292                 ig_maxnew_grid = nlonaf(ig_number_field(jf)) *
293     $                nlataf(ig_number_field(jf))
294              ELSEIF (ig_number_field(jf).gt.1) THEN
295                 IF (ALL(cl_auxbf.ne.
296     $                cficbf(ig_number_field(jf)))) THEN
297                    il_auxbf=il_auxbf + 1
298                    cl_auxbf(il_auxbf)=cficbf(ig_number_field(jf))
299                    ig_grid_nbrbf(ig_number_field(jf))=il_auxbf
300                    ig_maxold_grid = ig_maxold_grid +
301     $                   (nlonbf(ig_number_field(jf)) *
302     $                   nlatbf(ig_number_field(jf)))
303                 ELSE
304                    DO ib = 1, il_auxbf
305                       IF (cficbf(ig_number_field(jf)).eq.
306     $                      cl_auxbf(ib))
307     $                      ig_grid_nbrbf(ig_number_field(jf))= ib
308                    ENDDO
309                 ENDIF
310                 IF (ALL(cl_auxaf.ne.
311     $                cficaf(ig_number_field(jf)))) THEN
312                    il_auxaf=il_auxaf + 1
313                    cl_auxaf(il_auxaf)=cficaf(ig_number_field(jf))
314                    ig_grid_nbraf(ig_number_field(jf))=il_auxaf
315                    ig_maxnew_grid = ig_maxnew_grid +
316     $                   (nlonaf(ig_number_field(jf)) *
317     $                   nlataf(ig_number_field(jf)))
318                 ELSE
319                    DO ib = 1, il_auxaf
320                       IF (cficaf(ig_number_field(jf)).eq.
321     $                      cl_auxaf(ib))
322     $                      ig_grid_nbraf(ig_number_field(jf))= ib
323                    ENDDO
324                 ENDIF 
325             ENDIF
326         ENDIF
327 252   END DO
328C
329C*     Close netcdf file
330       IF (lncdfgrd) call hdlerr (NF_CLOSE(nc_grdid),'inicmc9')
331C
332       IF (lg_oasis_field) THEN
333          ALLOCATE (il_sizold(ig_nfield))
334          ALLOCATE (il_siznew(ig_nfield))
335          il_sizold(:) = 0
336          il_siznew(:) = 0
337          DO jf=1,ig_nfield
338            il_sizold (jf) = nlonbf(jf)*nlatbf(jf)
339            il_siznew (jf) = nlonaf(jf)*nlataf(jf)
340            ig_maxgrd = imaxim(il_sizold, ig_nfield)
341            IF (imaxim(il_siznew, ig_nfield).gt.ig_maxgrd)
342     $          ig_maxgrd = imaxim(il_siznew, ig_nfield)
343          ENDDO
344          WRITE(nulou,*)
345     $        'Maximum size of the different grids of indirect fields:',
346     $        ig_maxgrd
347          WRITE(nulou,*)' '
348C
349#if defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
350          ig_CLIMmax = 3 + CLIM_Clength + 2*ig_total_nfield *
351     $    (CLIM_Clength + 5 + CLIM_ParSize)
352          IF (ig_CLIMmax.lt.ig_maxgrd )
353     $        ig_CLIMmax = ig_maxgrd
354          ALLOCATE (pkwork(ig_CLIMmax), stat = il_ERR)
355          IF (il_ERR.NE.0) WRITE(nulou,*)
356     $        'Error in pkwork allocation in inicmc '
357          pkwork(:)=0
358#endif       
359C     
360C*          Search sum of grids sizes of fields before and after interpolation
361C     
362          ig_maxold = isumi (il_sizold, ig_nfield)
363          ig_maxnew = isumi (il_siznew, ig_nfield)
364          WRITE(nulou,*)
365     $        'Sum of grid sizes of fields before interpolation : ',
366     $        ig_maxold
367          WRITE(nulou,*)' '
368          WRITE(nulou,*)
369     $        'Sum of grid sizes of fields after interpolation : ',
370     $        ig_maxnew
371          WRITE(nulou,*)' '
372C     
373C*          Search dimension of "nwork" array
374C     
375          ALLOCATE (il_maxaux(ig_nfield))
376          il_maxaux(:)=0
377          DO jf = 1,ig_nfield
378            il_redu = 0
379            IF (ntronca(jf) .NE. 0) THEN
380                IF (ntronca(jf) .EQ. 16) THEN
381                    il_redu = nredu16
382                ELSE IF (ntronca(jf) .EQ. 24)  THEN
383                    il_redu = nredu24
384                ELSE IF (ntronca(jf) .EQ. 32)  THEN
385                    il_redu = nredu32
386                ELSE IF (ntronca(jf) .EQ. 48)  THEN
387                    il_redu = nredu48   
388                ELSE IF (ntronca(jf) .EQ. 80)  THEN
389                    il_redu = nredu80
390                ELSE IF (ntronca(jf) .EQ. 160)  THEN
391                    il_redu = nredu160
392                ELSE
393                    CALL prtout
394     $                  ('WARNING!!! Oasis cannot treat this grid with
395     $                  2*NO latitude lines with NO = ',
396     $                  ntronca(jf), 2)
397                ENDIF
398            ENDIF
399            IF (il_siznew(jf).ge.(il_redu+nlatbf(jf))) THEN
400                il_maxaux(jf) = il_siznew(jf)
401            ELSE
402                il_maxaux(jf) = il_redu+nlatbf(jf)
403            ENDIF
404          END DO
405          ig_nwork = imaxim (il_maxaux, ig_nfield)
406C     
407C*          Search dimension of "work" array
408C     
409          CALL izero(il_maxaux, ig_nfield)
410          DO jf = 1, ig_nfield
411            il_maxaux(jf) = nbnfld(jf)*il_siznew(jf)
412            IF (il_maxaux(jf).lt.(nbofld(jf)*il_sizold(jf)))
413     $          il_maxaux(jf) = nbofld(jf)*il_sizold(jf)
414            IF (il_maxaux(jf).lt.(nlonaf(jf)+nlataf(jf)
415     $          +2*il_sizold(jf)+2*il_siznew(jf)))
416     $          il_maxaux(jf) = nlonaf(jf) + nlataf(jf)
417     $          +2*il_sizold(jf) + 2*il_siznew(jf)
418          END DO
419          ig_work = imaxim(il_maxaux, ig_nfield)
420          IF (ig_work.lt.(3*ig_maxgrd))
421     $        ig_work = 3*ig_maxgrd
422C     
423          DEALLOCATE (il_maxaux)
424          DEALLOCATE (il_sizold)
425          DEALLOCATE (il_siznew)
426      ENDIF
427      DEALLOCATE (cl_auxbf)
428      DEALLOCATE (cl_auxaf)
429#if defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
430      IF (lg_bsend) THEN
431          ii=0
432          rl_testvar = 0.0_ip_double_p
433          integer_byte_size = BIT_SIZE(ii)/8
434          INQUIRE (iolength=io_size) ii
435          integer_io_size = io_size
436          INQUIRE (iolength=io_size) rl_testvar
437          il_ibyt = io_size/integer_io_size*integer_byte_size
438          il_bufsendsize = 2*ig_clim_nfield*
439     $        (ig_maxgrd + MPI_BSEND_OVERHEAD/il_ibyt+1)
440          ALLOCATE (dg_bufsend(il_bufsendsize), stat = il_err)
441          IF (il_ERR.ne.0) WRITE(nulou,*)'Error in dg_bufsend
442     $        allocation in CLIM_Init_Oasis'
443          dg_bufsend(:)=0
444          il_bufsendsizebyt = il_bufsendsize * il_ibyt
445C
446C*   Attach a buffer able to contain the maximum possible number of
447C    coupling fields with maximum possible
448C    size (ig_maxgrd) supposed to be declared as DOUBLE. 
449          CALL MPI_Buffer_Attach(dg_bufsend, il_bufsendsizebyt,mpi_err)
450          WRITE(nulou,*)'Attached buffer of size=', il_bufsendsizebyt
451      ENDIF
452#endif
453C
454C* END of stuff moved from inipar_alloc         
455C
456C* Define ports and start the communication only if one field (at least)
457C  goes through Oasis
458C
459      IF (lg_oasis_field) THEN
460C     
461C*    2. Define ports or files for data exchange
462C     ---------------------------------------
463C     
464C     * PIPE case: define and open pipe files (FIFO)
465C     
466#ifdef use_comm_PIPE
467         infos = 0
468         DO 250 jf = 1, ig_nfield
469C     
470C     * Define pipes actual names for each field
471C     
472C     - Reading
473C     
474            clpinp = cnaminp(jf)
475C     - Writing
476            clpout = cnamout(jf)
477C     
478C     * Create pipes
479C     
480            CALL PIPE_Define (cnaminp(jf), cnamout(jf),
481     $           clpinp, clpout , info(jf))
482            infos = infos + info(jf)
483 250     CONTINUE
484         IF (infos .NE. 0) THEN
485            WRITE (UNIT = nulou,FMT = *)
486     $           ' WARNING : Problem with field pipe initialization'
487            WRITE (UNIT = nulou,FMT = *)
488     $           ' =======   Error code number = ',infos
489            CALL HALTE('STOP in inicmc')
490         ENDIF
491c         ENDIF
492C     
493C     * SIPC case
494C     
495#elif defined use_comm_SIPC || defined use_comm_GMEM
496         infos = 0
497         DO 260 jf = 1, ig_nfield
498C     
499C     * Create two shared memory pools for each field
500C     
501            CALL SIPC_Define (jf, info(jf)) 
502            infos = infos + info(jf)
503 260     CONTINUE
504         IF (infos .NE. 0) THEN
505            WRITE (UNIT = nulou,FMT = *)
506     $           'WARNING : Problem with field shared memory pool 
507     $           initialization'
508            WRITE (UNIT = nulou,FMT = *)
509     $           ' =======   Error code number = ',infos
510            CALL HALTE('STOP in inicmc')
511         ELSE
512C     
513C     * If everything went alright, open one dummy file signaling 
514C     that pools for exchange are opened
515C     
516            OPEN (UNIT = nudum, FILE = 'DUMMY_SIPC', STATUS
517     $           = 'NEW')
518            CLOSE (UNIT = nudum)
519            IF (nlogprt .GE. 1) THEN
520               WRITE (UNIT = nulou,FMT = *)
521     $              '* ===>>> : file DUMMY_SIPC created'
522               WRITE (UNIT = nulou,FMT = *)
523     $              '  ------   -----------------------'
524            ENDIF
525        ENDIF
526C     
527C     * CLIM case: define ports
528C
529#elif defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
530C     
531C     * Input ports for incoming fields
532C
533         infos = CLIM_Ok
534         iparal(CLIM_Strategy) = CLIM_Serial
535         iparal(CLIM_Offset) = 0
536         DO 210 jf = 1, ig_nfield
537            iparal(CLIM_Length) = nlonbf(jf) * nlatbf(jf)
538            CALL CLIM_Define (ig_portin_id(jf),cnaminp(jf),CLIM_In,
539     $           CLIM_Real,iparal, info(jf))
540            infos = infos + info(jf)
541 210     CONTINUE
542         IF (infos .NE. CLIM_Ok) THEN
543            DO 220 jf = 1, ig_nfield
544               IF (info(jf) .NE. CLIM_Ok) THEN
545                  WRITE (UNIT = nulou,FMT = *)
546     $                 ' WARNING : Problem with port ', cnaminp(jf)
547                  WRITE (UNIT = nulou,FMT = *)
548     $                 ' =======   Error code number = ',info(jf)
549               ENDIF
550 220        CONTINUE
551            CALL HALTE ('STOP in inicmc')
552         ENDIF
553C     
554C     * Output ports for outgoing fields : serial decomposition
555C     
556         infos = CLIM_Ok
557         iparal(CLIM_Strategy) = CLIM_Serial
558         iparal(CLIM_Offset) = 0
559         DO 230 jf = 1, ig_nfield
560            iparal(CLIM_Length) = nlonaf(jf) * nlataf(jf)
561            CALL CLIM_Define (ig_portout_id(jf), cnamout(jf),
562     $           CLIM_Out, CLIM_Real, iparal, info(jf))
563            infos = infos + info(jf)
564 230     CONTINUE
565         IF (infos .NE. CLIM_Ok) THEN
566            DO 240 jf = 1, ig_nfield
567               IF (info(jf) .NE. CLIM_Ok) THEN
568                  WRITE (UNIT = nulou,FMT = *)
569     $                 ' WARNING : Problem with port ', cnamout(jf)
570                  WRITE (UNIT = nulou,FMT = *)
571     $                 ' =======   Error code number = ',info(jf)
572               ENDIF
573 240        CONTINUE
574            CALL HALTE ('STOP in inicmc')
575         ENDIF
576#endif
577C     
578C*    3. Start the communication and get timestep information
579C     ----------------------------------------------------
580#ifdef use_comm_PIPE
581         infos = 0
582         DO 320 jm = 1, ig_nmodel
583            CALL PIPE_Stepi (cmodnam(jm), jm,
584     $           istep, ifcpl, idt, infos)
585            IF (infos .NE. 0) THEN
586               WRITE (UNIT = nulou,FMT = *)
587     $              ' WARNING : Problem in getting step info 
588     $              from model ', cmodnam(jm)
589               WRITE (UNIT = nulou,FMT = *)
590     $              ' =======   Error code number = ',infos
591               CALL HALTE('STOP in inicmc')
592            ELSE
593               IF (nlogprt .GE. 1) THEN
594                  WRITE (UNIT = nulou,FMT = *)
595     $                 ' Got step information from model ',
596     $                 cmodnam(jm)
597               ENDIF
598            ENDIF
599            mstep(jm) = istep
600            mfcpl(jm) = ifcpl
601            mdt(jm) = idt
602 320     CONTINUE
603C     
604C     * SIPC or GMEM Case
605C     
606#elif defined use_comm_SIPC || defined use_comm_GMEM
607         infos = 0
608         DO 330 jm = 1, ig_nmodel
609            CALL SIPC_Stepi (cmodnam(jm), jm,
610     $           istep, ifcpl, idt, infos)
611            IF (infos .NE. 0) THEN
612               CALL prcout
613     $              ('WARNING: Problem in getting step info from 
614     $              model', cmodnam(jm), 1)
615               CALL prtout('Error code number = ',infos,1)
616               CALL HALTE('STOP in inicmc')
617            ELSE
618               CALL prcout
619     $              ('Got step information from model ',
620     $              cmodnam(jm), 1)
621            ENDIF
622            mstep(jm) = istep
623            mfcpl(jm) = ifcpl
624            mdt(jm) = idt
625 330     CONTINUE
626c
627C     * CLIM CASE
628C
629#elif defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE
630c
631         CALL CLIM_Start (infos)
632         IF (infos .NE. CLIM_Ok) THEN
633            WRITE (UNIT = nulou,FMT = *)
634     $           ' WARNING : Problem in starting CLIM '
635            WRITE (UNIT = nulou,FMT = *)
636     $           ' =======   Error code number = ',infos
637         ENDIF
638         DO 310 jm = 1, ig_nmodel
639            CALL CLIM_Stepi (cmodnam(jm), infos)
640            IF (infos .lt. nbcplproc(jm)) THEN
641               WRITE (UNIT = nulou,FMT = *)
642     $              'PROBLEM: Got initial informations only from',
643     $              infos
644               WRITE (UNIT = nulou,FMT = *)
645     $              'processes of model',  cmodnam(jm)
646               CALL halte ('STOP in inicmc.f')
647            ELSE
648               IF (nlogprt .GE. 1) THEN 
649                  WRITE (UNIT = nulou,FMT = *)
650     $                 ' Got step informations from model ',
651     $                 cmodnam(jm)
652               ENDIF
653            ENDIF
654 310     CONTINUE
655#endif
656      ENDIF
657C
658C
659C*    4. End of routine
660C        --------------
661C
662      IF (lg_oasis_field) DEALLOCATE(info)
663C
664      IF (nlogprt .GE. 1) THEN
665          WRITE (UNIT = nulou,FMT = *) ' '
666          WRITE (UNIT = nulou,FMT = *)
667     $    '          --------- End of routine inicmc ---------'
668          CALL FLUSH (nulou)
669      ENDIF
670      RETURN
671      END
Note: See TracBrowser for help on using the repository browser.