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 1793 for trunk/NEMO/OPA_SRC – NEMO

Changeset 1793 for trunk/NEMO/OPA_SRC


Ignore:
Timestamp:
2010-01-06T20:20:12+01:00 (14 years ago)
Author:
rblod
Message:

Adaptation to use iomput with AGRIF, see ticket #630

Location:
trunk/NEMO/OPA_SRC
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/IOM/iom.F90

    r1792 r1793  
    4343   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .FALSE.       !: iom_put flag 
    4444#endif 
    45    PUBLIC iom_init, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put 
     45   PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put 
    4646 
    4747   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d 
     
    8686      !!---------------------------------------------------------------------- 
    8787      ! read the xml file 
    88       CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)... 
     88      IF( Agrif_Root() ) CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)... 
     89      CALL iom_swap 
    8990 
    9091      ! calendar parameters 
     
    119120 
    120121   END SUBROUTINE iom_init 
     122 
     123 
     124   SUBROUTINE iom_swap 
     125      !!--------------------------------------------------------------------- 
     126      !!                   ***  SUBROUTINE  iom_swap  *** 
     127      !! 
     128      !! ** Purpose :  swap context between different agrif grid for xmlio_server 
     129      !!--------------------------------------------------------------------- 
     130#if defined key_iomput 
     131 
     132     IF( TRIM(Agrif_CFixed()) == '0' ) THEN 
     133        CALL event__swap_context("nemo") 
     134     ELSE 
     135        CALL event__swap_context(TRIM(Agrif_CFixed())//"_nemo") 
     136     ENDIF 
     137 
     138#endif 
     139   END SUBROUTINE iom_swap 
    121140 
    122141 
  • trunk/NEMO/OPA_SRC/lib_mpp.F90

    r1718 r1793  
    112112   INTEGER ::   mppsize        ! number of process 
    113113   INTEGER ::   mpprank        ! process number  [ 0 - size-1 ] 
    114    INTEGER ::   mpi_comm_opa   ! opa local communicator 
     114!$AGRIF_DO_NOT_TREAT 
     115   INTEGER, PUBLIC ::   mpi_comm_opa   ! opa local communicator 
     116!$AGRIF_END_DO_NOT_TREAT 
    115117 
    116118   ! variables used in case of sea-ice 
     
    191193      WRITE(ldtxt(6),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer 
    192194 
    193 #if defined key_agrif 
    194       IF( Agrif_Root() ) THEN 
    195 #endif 
    196          !!bug RB : should be clean to use Agrif in coupled mode 
    197 #if ! defined key_agrif 
    198          CALL mpi_initialized ( mpi_was_called, code ) 
    199          IF( code /= MPI_SUCCESS ) THEN 
    200             WRITE(*, cform_err) 
    201             WRITE(*, *) 'lib_mpp: Error in routine mpi_initialized' 
    202             CALL mpi_abort( mpi_comm_world, code, ierr ) 
    203          ENDIF 
    204  
    205          IF( PRESENT(localComm) .and. mpi_was_called ) THEN 
    206             mpi_comm_opa = localComm 
    207             SELECT CASE ( cn_mpi_send ) 
    208             CASE ( 'S' )                ! Standard mpi send (blocking) 
    209                WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)' 
    210             CASE ( 'B' )                ! Buffer mpi send (blocking) 
    211                WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)' 
    212                CALL mpi_init_opa( ierr )  
    213             CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    214                WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)' 
    215                l_isend = .TRUE. 
    216             CASE DEFAULT 
    217                WRITE(ldtxt(7),cform_err) 
    218                WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send 
    219                nstop = nstop + 1 
    220             END SELECT 
    221          ELSE IF ( PRESENT(localComm) .and. .not. mpi_was_called ) THEN 
    222             WRITE(ldtxt(7),*) ' lib_mpp: You cannot provide a local communicator ' 
    223             WRITE(ldtxt(8),*) '          without calling MPI_Init before ! ' 
    224             nstop = nstop + 1 
    225          ELSE 
    226 #endif 
    227             SELECT CASE ( cn_mpi_send ) 
    228             CASE ( 'S' )                ! Standard mpi send (blocking) 
    229                WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)' 
    230                CALL mpi_init( ierr ) 
    231             CASE ( 'B' )                ! Buffer mpi send (blocking) 
    232                WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)' 
    233                CALL mpi_init_opa( ierr ) 
    234             CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    235                WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)' 
    236                l_isend = .TRUE. 
    237                CALL mpi_init( ierr ) 
    238             CASE DEFAULT 
    239                WRITE(ldtxt(7),cform_err) 
    240                WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send 
    241                nstop = nstop + 1 
    242             END SELECT 
    243  
    244 #if ! defined key_agrif 
    245             CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code) 
    246             IF( code /= MPI_SUCCESS ) THEN 
    247                WRITE(*, cform_err) 
    248                WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup' 
    249                CALL mpi_abort( mpi_comm_world, code, ierr ) 
    250             ENDIF 
    251             ! 
    252          ENDIF 
    253 #endif 
    254 #if defined key_agrif 
    255       ELSE 
     195      CALL mpi_initialized ( mpi_was_called, code ) 
     196      IF( code /= MPI_SUCCESS ) THEN 
     197         WRITE(*, cform_err) 
     198         WRITE(*, *) 'lib_mpp: Error in routine mpi_initialized' 
     199         CALL mpi_abort( mpi_comm_world, code, ierr ) 
     200      ENDIF 
     201 
     202      IF( mpi_was_called ) THEN 
     203         ! 
    256204         SELECT CASE ( cn_mpi_send ) 
    257205         CASE ( 'S' )                ! Standard mpi send (blocking) 
     
    259207         CASE ( 'B' )                ! Buffer mpi send (blocking) 
    260208            WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)' 
     209            CALL mpi_init_opa( ierr )  
    261210         CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
    262211            WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)' 
     
    267216            nstop = nstop + 1 
    268217         END SELECT 
     218      ELSE IF ( PRESENT(localComm) .and. .not. mpi_was_called ) THEN 
     219         WRITE(ldtxt(7),*) ' lib_mpp: You cannot provide a local communicator ' 
     220         WRITE(ldtxt(8),*) '          without calling MPI_Init before ! ' 
     221         nstop = nstop + 1 
     222      ELSE 
     223         SELECT CASE ( cn_mpi_send ) 
     224         CASE ( 'S' )                ! Standard mpi send (blocking) 
     225            WRITE(ldtxt(7),*) '           Standard blocking mpi send (send)' 
     226            CALL mpi_init( ierr ) 
     227         CASE ( 'B' )                ! Buffer mpi send (blocking) 
     228            WRITE(ldtxt(7),*) '           Buffer blocking mpi send (bsend)' 
     229            CALL mpi_init_opa( ierr ) 
     230         CASE ( 'I' )                ! Immediate mpi send (non-blocking send) 
     231            WRITE(ldtxt(7),*) '           Immediate non-blocking send (isend)' 
     232            l_isend = .TRUE. 
     233            CALL mpi_init( ierr ) 
     234         CASE DEFAULT 
     235            WRITE(ldtxt(7),cform_err) 
     236            WRITE(ldtxt(8),*) '           bad value for cn_mpi_send = ', cn_mpi_send 
     237            nstop = nstop + 1 
     238         END SELECT 
     239         ! 
    269240      ENDIF 
    270241 
    271       mpi_comm_opa = mpi_comm_world 
    272 #endif 
     242      IF( PRESENT(localComm) ) THEN  
     243         IF( Agrif_Root() ) THEN 
     244            mpi_comm_opa = localComm 
     245         ENDIF 
     246      ELSE 
     247         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_opa, code) 
     248         IF( code /= MPI_SUCCESS ) THEN 
     249            WRITE(*, cform_err) 
     250            WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup' 
     251            CALL mpi_abort( mpi_comm_world, code, ierr ) 
     252         ENDIF 
     253      ENDIF  
     254 
    273255      CALL mpi_comm_rank( mpi_comm_opa, mpprank, ierr ) 
    274256      CALL mpi_comm_size( mpi_comm_opa, mppsize, ierr ) 
  • trunk/NEMO/OPA_SRC/opa.F90

    r1725 r1793  
    156156      CALL opa_closefile 
    157157#if defined key_oasis3 || defined key_oasis4 
    158       CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS 
     158      IF( Agrif_Root() ) THEN 
     159         CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS 
     160     ENDIF  
    159161#else 
    160162      IF( lk_mpp )   CALL mppstop       ! end mpp communications 
     
    191193#if defined key_iomput 
    192194# if defined key_oasis3 || defined key_oasis4 
    193       CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis 
    194       CALL init_ioclient()                    ! io_server will get its communicators (if needed) from oasis (we don't see it) 
     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 
    195199# else 
    196       CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server 
     200      IF( Agrif_Root() ) THEN 
     201         CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server 
     202      ENDIF 
    197203# endif 
    198204      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection 
     
    200206#else 
    201207# if defined key_oasis3 || defined key_oasis4 
    202       CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis 
     208      IF( Agrif_Root() ) THEN 
     209         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis 
     210      ENDIF 
    203211      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection (control print return in cltxt) 
    204212# else 
  • trunk/NEMO/OPA_SRC/step.F90

    r1756 r1793  
    166166#if defined key_agrif 
    167167      kstp = nit000 + Agrif_Nb_Step() 
    168 !      IF ( Agrif_Root() .and. lwp) Write(*,*) '---' 
    169 !      IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp 
     168!      IF( Agrif_Root() .and. lwp) Write(*,*) '---' 
     169!      IF(lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp 
     170# if defined key_iomput 
     171      IF( Agrif_Nbstepint() == 0) CALL iom_swap 
     172# endif    
    170173#endif    
    171174      indic = 1                                       ! reset to no error condition 
Note: See TracChangeset for help on using the changeset viewer.