New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
opa.F90 in branches/DEV_1879_mpp_sca/NEMO/OPA_SRC – NEMO

source: branches/DEV_1879_mpp_sca/NEMO/OPA_SRC/opa.F90 @ 1926

Last change on this file since 1926 was 1926, checked in by acc, 14 years ago

First implementation of mpp scalability modifications (branch:DEV_1879_mpp_sca

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 24.5 KB
Line 
1MODULE opa
2   !!==============================================================================
3   !!                       ***  MODULE opa   ***
4   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
5   !!==============================================================================
6   !! History :  OPA  ! 1990-10  (C. Levy, G. Madec)  Original code
7   !!            7.0  ! 1991-11  (M. Imbard, C. Levy, G. Madec)
8   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
9   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes )  release 7.1
10   !!             -   ! 1992-06  (L.Terray)  coupling implementation
11   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice
12   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
13   !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy)  release 8.0
14   !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
15   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model
16   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
17   !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
18   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
19   !!             -   ! 2004-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
20   !!             -   ! 2004-08  (C. Talandier) New trends organization
21   !!             -   ! 2005-06  (C. Ethe) Add the 1D configuration possibility
22   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
23   !!             -   ! 2006-03  (L. Debreu, C. Mazauric)  Agrif implementation
24   !!             -   ! 2006-04  (G. Madec, R. Benshila)  Step reorganization
25   !!             -   ! 2007-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
26   !!            3.2  ! 2009-08  (S. Masson)  open/write in the listing file in mpp
27   !!----------------------------------------------------------------------
28
29   !!----------------------------------------------------------------------
30   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
31   !!   opa_init       : initialization of the opa model
32   !!   opa_flg        : initialisation of algorithm flag
33   !!   opa_closefile  : close remaining files
34   !!----------------------------------------------------------------------
35   USE oce             ! dynamics and tracers variables
36   USE dom_oce         ! ocean space domain variables
37   USE sbc_oce         ! surface boundary condition: ocean
38   USE trdmod_oce      ! ocean variables trends
39   USE domcfg          ! domain configuration               (dom_cfg routine)
40   USE mppini          ! shared/distributed memory setting (mpp_init routine)
41   USE domain          ! domain initialization             (dom_init routine)
42   USE obc_par         ! open boundary cond. parameters
43   USE obcini          ! open boundary cond. initialization (obc_ini routine)
44   USE bdy_par         ! unstructured open boundary cond. parameters
45   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
46   USE istate          ! initial state setting          (istate_init routine)
47   USE sbcmod          ! surface boundary condition
48   USE eosbn2          ! equation of state                 (eos_init routine)
49   USE dynhpg          ! hydrostatic pressure gradient
50   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
51   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
52   USE zdfini
53   USE phycst          ! physical constant                  (par_cst routine)
54   USE trdmod          ! momentum/tracers trends       (trd_mod_init routine)
55   USE diaptr          ! poleward transports           (dia_ptr_init routine)
56   USE step            ! OPA time-stepping                  (stp     routine)
57#if defined key_oasis3
58   USE cpl_oasis3      ! OASIS3 coupling
59#elif defined key_oasis4
60   USE cpl_oasis4      ! OASIS4 coupling (not working)
61#endif
62   USE dynspg_oce      ! Control choice of surface pressure gradient schemes
63   USE prtctl          ! Print control                 (prt_ctl_init routine)
64   USE c1d             ! 1D configuration
65   USE dyncor_c1d      ! Coriolis factor at T-point
66   USE step_c1d        ! Time stepping loop for the 1D configuration
67#if defined key_top
68   USE trcini          ! passive tracer initialisation
69#endif
70   
71   USE iom
72   USE in_out_manager  ! I/O manager
73   USE lib_mpp         ! distributed memory computing
74#if defined key_iomput
75   USE mod_ioclient
76#endif
77
78   IMPLICIT NONE
79   PRIVATE
80
81   PUBLIC   opa_model   ! called by model.F90
82   PUBLIC   opa_init    ! needed by AGRIF
83
84   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
85
86   !!----------------------------------------------------------------------
87   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
88   !! $Id$
89   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
90   !!----------------------------------------------------------------------
91
92CONTAINS
93
94   SUBROUTINE opa_model
95      !!----------------------------------------------------------------------
96      !!                     ***  ROUTINE opa  ***
97      !!
98      !! ** Purpose :   opa solves the primitive equations on an orthogonal
99      !!              curvilinear mesh on the sphere.
100      !!
101      !! ** Method  : - model general initialization
102      !!              - launch the time-stepping (stp routine)
103      !!              - finalize the run by closing files and communications
104      !!
105      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
106      !!              Madec, 2008, internal report, IPSL.
107      !!----------------------------------------------------------------------
108      INTEGER ::   istp       ! time step index
109      !!----------------------------------------------------------------------
110
111#if defined key_agrif
112      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
113#endif
114
115      !                            !-----------------------!
116      CALL opa_init                !==  Initialisations  ==!
117      !                            !-----------------------!
118
119      ! check that all process are still there... If some process have an error,
120      ! they will never enter in step and other processes will wait until the end of the cpu time!
121      IF( lk_mpp )   CALL mpp_max( nstop )
122
123      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
124
125      !                            !-----------------------!
126      !                            !==   time stepping   ==!
127      !                            !-----------------------!
128      istp = nit000
129      IF( lk_c1d ) THEN                 !==  1D configuration  ==!
130         DO WHILE ( istp <= nitend .AND. nstop == 0 )
131            CALL stp_c1d( istp )
132            istp = istp + 1
133         END DO
134      ELSE                              !==  3D ocean with  ==!
135         DO WHILE ( istp <= nitend .AND. nstop == 0 )
136#if defined key_agrif
137            CALL Agrif_Step( stp )           ! AGRIF: time stepping
138#else
139            CALL stp( istp )                 ! standard time stepping
140#endif
141            istp = istp + 1
142            IF( lk_mpp )   CALL mpp_max( nstop )
143         END DO
144      ENDIF
145       
146      !                            !------------------------!
147      !                            !==  finalize the run  ==!
148      !                            !------------------------!
149      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
150      !
151      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
152         WRITE(numout,cform_err)
153         WRITE(numout,*) nstop, ' error have been found' 
154      ENDIF
155      !
156      CALL opa_closefile
157#if defined key_oasis3 || defined key_oasis4
158      IF( Agrif_Root() ) THEN
159         CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS
160     ENDIF 
161#else
162      IF( lk_mpp )   CALL mppstop       ! end mpp communications
163#endif
164      !
165   END SUBROUTINE opa_model
166
167
168   SUBROUTINE opa_init
169      !!----------------------------------------------------------------------
170      !!                     ***  ROUTINE opa_init  ***
171      !!
172      !! ** Purpose :   initialization of the opa model
173      !!
174      !!----------------------------------------------------------------------
175#if defined key_oasis3 || defined key_oasis4 || defined key_iomput
176      INTEGER :: ilocal_comm
177#endif
178      CHARACTER(len=80),dimension(10) ::   cltxt = ''
179      INTEGER                         ::   ji   ! local loop indices
180      !!
181      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
182         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench, nn_bit_cmp
183      !!----------------------------------------------------------------------
184      !
185      !                             ! open Namelist file
186      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
187      !
188      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
189      !
190      !                             !--------------------------------------------!
191      !                             !  set communicator & select the local node  !
192      !                             !--------------------------------------------!
193#if defined key_iomput
194# if defined key_oasis3 || defined key_oasis4
195      IF( Agrif_Root() ) THEN
196         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
197         CALL init_ioclient()                    ! io_server will get its communicators (if needed) from oasis (we don't see it)
198      ENDIF
199# else
200      IF( Agrif_Root() ) THEN
201         CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server
202      ENDIF
203# endif
204      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
205
206#else
207# if defined key_oasis3 || defined key_oasis4
208      IF( Agrif_Root() ) THEN
209         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
210      ENDIF
211      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection (control print return in cltxt)
212# else
213      narea = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
214# endif
215#endif
216      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
217
218      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
219
220      IF(lwp) THEN                            ! open listing units
221         !
222         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
223         !
224         WRITE(numout,*)
225         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
226         WRITE(numout,*) '                       NEMO team'
227         WRITE(numout,*) '            Ocean General Circulation Model'
228         WRITE(numout,*) '                  version 3.2  (2009) '
229         WRITE(numout,*)
230         WRITE(numout,*)
231         DO ji = 1, SIZE(cltxt) 
232            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
233         END DO
234         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
235         !
236      ENDIF
237      !                             !--------------------------------!
238      !                             !  Model general initialization  !
239      !                             !--------------------------------!
240
241      CALL opa_flg                          ! Control prints & Benchmark
242
243                                            ! Domain decomposition
244      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
245      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
246      ENDIF
247     
248      CALL phy_cst                          ! Physical constants
249      CALL eos_init                         ! Equation of state
250      CALL dom_cfg                          ! Domain configuration
251      CALL dom_init                         ! Domain
252!!gm c1d case can be moved in dom_init routine
253      IF( lk_c1d ) THEN                          ! 1D configuration
254         CALL cor_c1d                            ! Coriolis defined at T-point
255         umask(:,:,:) = tmask(:,:,:)             ! U, V and T-points are the same
256         vmask(:,:,:) = tmask(:,:,:)             !
257      ENDIF
258!!gm c1d end
259
260      CALL opa_northcomms                   ! Initialise the northfold neighbour lists (must be done after the masks are defined)
261
262      IF( ln_ctl )   CALL prt_ctl_init      ! Print control
263
264      IF( lk_obc )   CALL obc_init          ! Open boundaries
265      IF( lk_bdy )   CALL bdy_init          ! Unstructured open boundaries
266
267      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
268
269      !                                     ! Ocean physics
270      CALL sbc_init                             ! Read namsbc namelist : surface module (needed for iom_init)
271      CALL ldf_tra_init                         ! Lateral ocean tracer physics
272      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
273      CALL zdf_init                             ! Vertical ocean physics
274
275#if defined key_top
276      CALL trc_ini                          ! Passive tracers
277#endif
278
279      !                                     ! diagnostics
280      CALL iom_init                             ! iom_put initialization
281      CALL dia_ptr_init                         ! Poleward TRansports initialization
282      CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
283      !
284   END SUBROUTINE opa_init
285
286
287   SUBROUTINE opa_flg
288      !!----------------------------------------------------------------------
289      !!                     ***  ROUTINE opa  ***
290      !!
291      !! ** Purpose :   Initialise logical flags that control the choice of
292      !!              some algorithm or control print
293      !!
294      !! ** Method  : - print namctl information
295      !!              - Read in namilist namflg logical flags
296      !!----------------------------------------------------------------------
297      NAMELIST/namdyn_hpg/ ln_hpg_zco   , ln_hpg_zps   , ln_hpg_sco, ln_hpg_hel,   &
298         &                 ln_hpg_wdj   , ln_hpg_djc   , ln_hpg_rot, rn_gamma  ,   &
299         &                 ln_dynhpg_imp, nn_dynhpg_rst
300      !!----------------------------------------------------------------------
301
302      IF(lwp) THEN                 ! Parameter print
303         WRITE(numout,*)
304         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
305         WRITE(numout,*) '~~~~~~~ '
306         WRITE(numout,*) '   Namelist namctl'
307         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
308         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
309         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
310         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
311         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
312         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
313         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
314         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
315         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
316         WRITE(numout,*) '      bit comparison mode (0/1)       nn_bit_cmp = ', nn_bit_cmp
317      ENDIF
318
319      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
320      nictls    = nn_ictls
321      nictle    = nn_ictle
322      njctls    = nn_jctls
323      njctle    = nn_jctle
324      isplt     = nn_isplt
325      jsplt     = nn_jsplt
326      nbench    = nn_bench
327      nbit_cmp  = nn_bit_cmp
328
329      !                           ! Parameter control
330      !
331      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
332         IF( lk_mpp ) THEN
333            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real splitted domain
334         ELSE
335            IF( isplt == 1 .AND. jsplt == 1  ) THEN
336               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
337                  &           ' - the print control will be done over the whole domain' )
338            ENDIF
339            ijsplt = isplt * jsplt            ! total number of processors ijsplt
340         ENDIF
341         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
342         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
343         !
344         !                              ! indices used for the SUM control
345         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
346            lsp_area = .FALSE.                       
347         ELSE                                             ! print control done over a specific  area
348            lsp_area = .TRUE.
349            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
350               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
351               nictls = 1
352            ENDIF
353            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
354               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
355               nictle = jpiglo
356            ENDIF
357            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
358               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
359               njctls = 1
360            ENDIF
361            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
362               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
363               njctle = jpjglo
364            ENDIF
365         ENDIF
366      ENDIF
367
368      IF( nbench == 1 )   THEN            ! Benchmark
369         SELECT CASE ( cp_cfg )
370         CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
371         CASE DEFAULT      ;   CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:',   &
372            &                                 ' key_gyre must be used or set nbench = 0' )
373         END SELECT
374      ENDIF
375
376      IF( nbit_cmp == 1 )   THEN          ! Bit compare
377         CALL ctl_warn( ' Bit comparison enabled. Single and multiple processor results must bit compare', &
378              &         ' WARNING: RESULTS ARE NOT PHYSICAL.' )
379      ENDIF
380
381      REWIND( numnam )              ! Read Namelist namdyn_hpg : ln_dynhpg_imp must be read at the initialisation phase
382      READ  ( numnam, namdyn_hpg )
383      !
384   END SUBROUTINE opa_flg
385
386
387   SUBROUTINE opa_closefile
388      !!----------------------------------------------------------------------
389      !!                     ***  ROUTINE opa_closefile  ***
390      !!
391      !! ** Purpose :   Close the files
392      !!----------------------------------------------------------------------
393      USE dtatem        ! temperature data
394      USE dtasal        ! salinity data
395      !!----------------------------------------------------------------------
396      !
397      IF( lk_mpp )   CALL mppsync
398      !
399      CALL iom_close                                 ! close all input/output files managed by iom_*
400      !
401      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
402      IF( numsol     /= -1 )   CLOSE( numsol     )   ! solver file
403      IF( numnam     /= -1 )   CLOSE( numnam     )   ! oce namelist
404      IF( numnam_ice /= -1 )   CLOSE( numnam_ice )   ! ice namelist
405      IF( numevo_ice /= -1 )   CLOSE( numevo_ice )   ! ice variables (temp. evolution)
406      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
407      numout = 6   ! redefine numout in case it is used after this point...
408      !
409   END SUBROUTINE opa_closefile
410
411   SUBROUTINE opa_northcomms
412      !!======================================================================
413      !!                     ***  ROUTINE  opa_northcomms  ***
414      !! opa_northcomms    :  Setup for north fold exchanges with explicit peer to peer messaging
415      !!=====================================================================
416      !!----------------------------------------------------------------------
417      !!
418      !! ** Purpose :   Initialization of the northern neighbours lists.
419      !!----------------------------------------------------------------------
420
421      INTEGER ::   ji, jj, jk, ij    ! dummy loop indices
422      INTEGER ::   ijpj              ! ???
423      INTEGER,  DIMENSION (jpi,4,4) ::   ifoldnbrs
424      REAL(wp), DIMENSION (jpi,jpj) ::   znnbrs     ! workspace
425      LOGICAL,  DIMENSION (jpnij)   ::   lrankset   ! workspace
426
427      IF(lwp) WRITE(numout,*)
428      IF(lwp) WRITE(numout,*) 'opa_northcomms : Initialization of the northern neighbours lists'
429      IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
430
431      !!----------------------------------------------------------------------
432      nsndto = 0
433      isendto = -1
434      ijpj   = 4
435      !
436! Exchange and store ranks on northern rows
437
438      lrankset = .FALSE.
439      znnbrs = narea * tmask(:,:,1)
440      CALL lbc_lnk( znnbrs, 'T', 1. )
441
442      IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN
443        do jj = nlcj-ijpj+1, nlcj
444         ij = jj - nlcj + ijpj
445         ifoldnbrs(:,ij,1) = int(znnbrs(:,jj))
446         do ji = 1,jpi
447          if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) &
448         &       lrankset(int(znnbrs(ji,jj))) = .true.
449         end do
450        end do
451
452        do jj = 1,jpnij
453         IF (lrankset(jj)) THEN
454          nsndto(1) = nsndto(1) + 1
455          IF(nsndto(1) .gt. jpmaxngh ) THEN
456           CALL ctl_stop( ' Too many neighbours in opa_northcomms ', &
457           &              ' jpmaxngh will need to be increased ')
458          ENDIF
459          isendto(nsndto(1),1) = jj-1   ! narea converted to MPI rank
460         ENDIF
461        end do
462      ENDIF
463     
464      lrankset = .FALSE.
465      znnbrs = narea * umask(:,:,1)
466      CALL lbc_lnk( znnbrs, 'U', 1. )
467
468      IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN
469        do jj = nlcj-ijpj+1, nlcj
470         ij = jj - nlcj + ijpj
471         ifoldnbrs(:,ij,2) = int(znnbrs(:,jj))
472         do ji = 1,jpi
473          if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) &
474         &       lrankset(int(znnbrs(ji,jj))) = .true.
475         end do
476        end do
477
478        do jj = 1,jpnij
479         IF (lrankset(jj)) THEN
480          nsndto(2) = nsndto(2) + 1
481          IF(nsndto(2) .gt. jpmaxngh ) THEN
482           CALL ctl_stop( ' Too many neighbours in opa_northcomms ', &
483           &              ' jpmaxngh will need to be increased ')
484          ENDIF
485          isendto(nsndto(2),2) = jj-1   ! narea converted to MPI rank
486         ENDIF
487        end do
488      ENDIF
489
490      lrankset = .FALSE.
491      znnbrs = narea * vmask(:,:,1)
492      CALL lbc_lnk( znnbrs, 'V', 1. )
493
494      IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN
495        do jj = nlcj-ijpj+1, nlcj
496         ij = jj - nlcj + ijpj
497         ifoldnbrs(:,ij,3) = int(znnbrs(:,jj))
498         do ji = 1,jpi
499          if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) &
500         &       lrankset(int(znnbrs(ji,jj))) = .true.
501         end do
502        end do
503
504        do jj = 1,jpnij
505         IF (lrankset(jj)) THEN
506          nsndto(3) = nsndto(3) + 1
507          IF(nsndto(3) .gt. jpmaxngh ) THEN
508           CALL ctl_stop( ' Too many neighbours in opa_northcomms ', &
509           &              ' jpmaxngh will need to be increased ')
510          ENDIF
511          isendto(nsndto(3),3) = jj-1   ! narea converted to MPI rank
512         ENDIF
513        end do
514      ENDIF
515
516      lrankset = .FALSE.
517      znnbrs = narea * fmask(:,:,1)
518!
519! filter top rows to counter any strong slip conditions
520!
521      do jj = nlcj-ijpj+1, nlcj
522      do ji = 1,jpi
523       znnbrs(ji,jj) = narea * MIN(1.0,fmask(ji,jj,1))
524      end do
525      enddo
526      CALL lbc_lnk( znnbrs, 'F', 1. )
527
528      IF ( njmppt(narea) .eq. MAXVAL( njmppt )) THEN
529        do jj = nlcj-ijpj+1, nlcj
530         ij = jj - nlcj + ijpj
531         ifoldnbrs(:,ij,4) = int(znnbrs(:,jj))
532         do ji = 1,jpi
533          if(int(znnbrs(ji,jj)) .ne. 0 .and. int(znnbrs(ji,jj)) .ne. narea ) &
534         &       lrankset(int(znnbrs(ji,jj))) = .true.
535         end do
536        end do
537
538        do jj = 1,jpnij
539         IF (lrankset(jj)) THEN
540          nsndto(4) = nsndto(4) + 1
541          IF(nsndto(4) .gt. jpmaxngh ) THEN
542           CALL ctl_stop( ' Too many neighbours in opa_northcomms ', &
543           &              ' jpmaxngh will need to be increased ')
544          ENDIF
545          isendto(nsndto(4),4) = jj-1   ! narea converted to MPI rank
546         ENDIF
547        end do
548
549        lnorth_nogather = .TRUE.
550      ENDIF
551
552   END SUBROUTINE opa_northcomms
553   !!======================================================================
554END MODULE opa
Note: See TracBrowser for help on using the repository browser.