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.
Changeset 2481 – NEMO

Changeset 2481


Ignore:
Timestamp:
2010-12-17T18:27:02+01:00 (13 years ago)
Author:
smasson
Message:

v33b: additional cleaning in libmpp, see ticket #779

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90

    r2480 r2481  
    175175      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt  
    176176      INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm 
    177       INTEGER ::   mynode, ierr, code 
     177      INTEGER ::   mynode, ierr, code, ji, ii 
    178178      LOGICAL ::   mpi_was_called 
    179179       
     
    181181      !!---------------------------------------------------------------------- 
    182182      ! 
    183       WRITE(ldtxt(1),*) 
    184       WRITE(ldtxt(2),*) 'mynode : mpi initialisation' 
    185       WRITE(ldtxt(3),*) '~~~~~~ ' 
     183      ii = 1 
     184      WRITE(ldtxt(ii),*)                                                                          ;   ii = ii + 1 
     185      WRITE(ldtxt(ii),*) 'mynode : mpi initialisation'                                            ;   ii = ii + 1 
     186      WRITE(ldtxt(ii),*) '~~~~~~ '                                                                ;   ii = ii + 1 
    186187      ! 
    187188      REWIND( numnam )               ! Namelist namrun : parameters of the run 
    188189      READ  ( numnam, nammpp ) 
    189190      !                              ! control print 
    190       WRITE(ldtxt(4),*) '   Namelist nammpp' 
    191       WRITE(ldtxt(5),*) '      mpi send type                      cn_mpi_send = ', cn_mpi_send 
    192       WRITE(ldtxt(6),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer 
     191      WRITE(ldtxt(ii),*) '   Namelist nammpp'                                                     ;   ii = ii + 1 
     192      WRITE(ldtxt(ii),*) '      mpi send type                      cn_mpi_send = ', cn_mpi_send   ;   ii = ii + 1 
     193      WRITE(ldtxt(ii),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer     ;   ii = ii + 1 
    193194 
    194195      CALL mpi_initialized ( mpi_was_called, code ) 
    195196      IF( code /= MPI_SUCCESS ) THEN 
     197         DO ji = 1, SIZE(ldtxt)  
     198            IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode 
     199         END DO          
    196200         WRITE(*, cform_err) 
    197201         WRITE(*, *) 'lib_mpp: Error in routine mpi_initialized' 
     
    203207         SELECT CASE ( cn_mpi_send ) 
    204208         CASE ( 'S' )                ! Standard mpi send (blocking) 
    205             WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)' 
     209            WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'                     ;   ii = ii + 1 
    206210         CASE ( 'B' )                ! Buffer mpi send (blocking) 
    207             WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)' 
    208             CALL mpi_init_opa( ierr )  
     211            WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'                      ;   ii = ii + 1 
     212            IF( Agrif_Root() )   CALL mpi_init_opa( ldtxt, ii, ierr )  
    209213         CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    210             WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)' 
     214            WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'                   ;   ii = ii + 1 
    211215            l_isend = .TRUE. 
    212216         CASE DEFAULT 
    213             WRITE(ldtxt(7),cform_err) 
    214             WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send 
     217            WRITE(ldtxt(ii),cform_err)                                                            ;   ii = ii + 1 
     218            WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send             ;   ii = ii + 1 
    215219            nstop = nstop + 1 
    216220         END SELECT 
    217221      ELSE IF ( PRESENT(localComm) .and. .not. mpi_was_called ) THEN 
    218          WRITE(ldtxt(7),*) ' lib_mpp: You cannot provide a local communicator ' 
    219          WRITE(ldtxt(8),*) '          without calling MPI_Init before ! ' 
     222         WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '                  ;   ii = ii + 1 
     223         WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                        ;   ii = ii + 1 
    220224         nstop = nstop + 1 
    221225      ELSE 
    222226         SELECT CASE ( cn_mpi_send ) 
    223227         CASE ( 'S' )                ! Standard mpi send (blocking) 
    224             WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)' 
     228            WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'                     ;   ii = ii + 1 
    225229            CALL mpi_init( ierr ) 
    226230         CASE ( 'B' )                ! Buffer mpi send (blocking) 
    227             WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)' 
    228             CALL mpi_init_opa( ierr ) 
     231            WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'                      ;   ii = ii + 1 
     232            IF( Agrif_Root() )   CALL mpi_init_opa( ldtxt, ii, ierr ) 
    229233         CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    230             WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)' 
     234            WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'                   ;   ii = ii + 1 
    231235            l_isend = .TRUE. 
    232236            CALL mpi_init( ierr ) 
    233237         CASE DEFAULT 
    234             WRITE(ldtxt(7),cform_err) 
    235             WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send 
     238            WRITE(ldtxt(ii),cform_err)                                                            ;   ii = ii + 1 
     239            WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send             ;   ii = ii + 1 
    236240            nstop = nstop + 1 
    237241         END SELECT 
     
    246250         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code) 
    247251         IF( code /= MPI_SUCCESS ) THEN 
     252            DO ji = 1, SIZE(ldtxt)  
     253               IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode 
     254            END DO 
    248255            WRITE(*, cform_err) 
    249256            WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup' 
     
    22822289 
    22832290 
    2284    SUBROUTINE mpi_init_opa( code ) 
     2291   SUBROUTINE mpi_init_opa( ldtxt, ksft, code ) 
    22852292      !!--------------------------------------------------------------------- 
    22862293      !!                   ***  routine mpp_init.opa  *** 
     
    22942301      !!            08/04 :: R. Benshila, generalisation 
    22952302      !!--------------------------------------------------------------------- 
    2296       INTEGER                                 :: code, ierr 
    2297       LOGICAL                                 :: mpi_was_called 
     2303      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt  
     2304      INTEGER                      , INTENT(inout) ::   ksft 
     2305      INTEGER                      , INTENT(  out) ::   code 
     2306      INTEGER                                      ::   ierr, ji 
     2307      LOGICAL                                      ::   mpi_was_called 
    22982308      !!--------------------------------------------------------------------- 
    22992309      ! 
    23002310      CALL mpi_initialized( mpi_was_called, code )      ! MPI initialization 
    23012311      IF ( code /= MPI_SUCCESS ) THEN 
    2302          CALL ctl_stop( ' lib_mpp: Error in routine mpi_initialized' ) 
     2312         DO ji = 1, SIZE(ldtxt)  
     2313            IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode 
     2314         END DO          
     2315         WRITE(*, cform_err) 
     2316         WRITE(*, *) ' lib_mpp: Error in routine mpi_initialized' 
    23032317         CALL mpi_abort( mpi_comm_world, code, ierr ) 
    23042318      ENDIF 
     
    23082322         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code ) 
    23092323         IF ( code /= MPI_SUCCESS ) THEN 
    2310             CALL ctl_stop( ' lib_mpp: Error in routine mpi_comm_dup' ) 
     2324            DO ji = 1, SIZE(ldtxt)  
     2325               IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode 
     2326            END DO 
     2327            WRITE(*, cform_err) 
     2328            WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup' 
    23112329            CALL mpi_abort( mpi_comm_world, code, ierr ) 
    23122330         ENDIF 
     
    23142332      ! 
    23152333      IF( nn_buffer > 0 ) THEN 
    2316          IF ( lwp ) WRITE(numout,*) 'mpi_bsend, buffer allocation of  : ', nn_buffer 
     2334         WRITE(ldtxt(ksft),*) 'mpi_bsend, buffer allocation of  : ', nn_buffer   ;   ksft = ksft + 1 
    23172335         ! Buffer allocation and attachment 
    2318          ALLOCATE( tampon(nn_buffer) ) 
    2319          CALL mpi_buffer_attach( tampon, nn_buffer,code ) 
     2336         ALLOCATE( tampon(nn_buffer), stat = ierr ) 
     2337         IF (ierr /= 0) THEN  
     2338            DO ji = 1, SIZE(ldtxt)  
     2339               IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode 
     2340            END DO 
     2341            WRITE(*, cform_err) 
     2342            WRITE(*, *) ' lib_mpp: Error in ALLOCATE', ierr 
     2343            CALL mpi_abort( mpi_comm_world, code, ierr ) 
     2344         END IF 
     2345         CALL mpi_buffer_attach( tampon, nn_buffer, code ) 
    23202346      ENDIF 
    23212347      ! 
Note: See TracChangeset for help on using the changeset viewer.