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 12928 for NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser/src/OCE/LBC/lib_mpp.F90 – NEMO

Ignore:
Timestamp:
2020-05-14T21:46:00+02:00 (4 years ago)
Author:
smueller
Message:

Synchronizing with /NEMO/trunk@12925 (ticket #2170)

Location:
NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser

    • Property svn:externals
      •  

        old new  
        66^/vendors/FCM@HEAD            ext/FCM 
        77^/vendors/IOIPSL@HEAD         ext/IOIPSL 
         8 
         9# SETTE 
         10^/utils/CI/sette@HEAD         sette 
  • NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser/src/OCE/LBC/lib_mpp.F90

    r12178 r12928  
    3232   !!   ctl_opn       : Open file and check if required file is available. 
    3333   !!   ctl_nam       : Prints informations when an error occurs while reading a namelist 
     34   !!   load_nml      : Read, condense and buffer namelist file into character array for use as an internal file 
    3435   !!---------------------------------------------------------------------- 
    3536   !!---------------------------------------------------------------------- 
     
    5051   !!   mpp_ini_north : initialisation of north fold 
    5152   !!   mpp_lbc_north_icb : alternative to mpp_nfd for extra outer halo with icebergs 
     53   !!   mpp_bcast_nml : broadcast/receive namelist character buffer from reading process to all others 
    5254   !!---------------------------------------------------------------------- 
    5355   USE dom_oce        ! ocean space and time domain 
     
    5759   PRIVATE 
    5860   ! 
    59    PUBLIC   ctl_stop, ctl_warn, ctl_opn, ctl_nam 
     61   PUBLIC   ctl_stop, ctl_warn, ctl_opn, ctl_nam, load_nml 
    6062   PUBLIC   mpp_start, mppstop, mppsync, mpp_comm_free 
    6163   PUBLIC   mpp_ini_north 
     
    6668   PUBLIC   mppsend, mpprecv                          ! needed by TAM and ICB routines 
    6769   PUBLIC   mpp_report 
     70   PUBLIC   mpp_bcast_nml 
    6871   PUBLIC   tic_tac 
    6972#if ! defined key_mpp_mpi 
     
    139142   INTEGER, PUBLIC                               ::   ncom_stp = 0                 !: copy of time step # istp 
    140143   INTEGER, PUBLIC                               ::   ncom_fsbc = 1                !: copy of sbc time step # nn_fsbc 
    141    INTEGER, PUBLIC                               ::   ncom_dttrc = 1               !: copy of top time step # nn_dttrc 
    142144   INTEGER, PUBLIC                               ::   ncom_freq                    !: frequency of comm diagnostic 
    143145   INTEGER, PUBLIC , DIMENSION(:,:), ALLOCATABLE ::   ncomm_sequence               !: size of communicated arrays (halos) 
     
    170172   LOGICAL, PUBLIC ::   l_north_nogather = .FALSE.  !: internal control of northfold comms 
    171173    
     174   !! * Substitutions 
     175#  include "do_loop_substitute.h90" 
    172176   !!---------------------------------------------------------------------- 
    173177   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
     
    398402# if defined key_mpi2 
    399403      IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.) 
    400       CALL  mpi_allreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ndelayid(idvar), ierr ) 
     404      CALL  mpi_allreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ierr ) 
     405      ndelayid(idvar) = 1 
    401406      IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.) 
    402407# else 
     
    465470# if defined key_mpi2 
    466471      IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.) 
    467       CALL  mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ndelayid(idvar), ierr ) 
     472      CALL  mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ierr ) 
     473      ndelayid(idvar) = 1 
    468474      IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.) 
    469475# else 
     
    499505#endif 
    500506   END SUBROUTINE mpp_delay_rcv 
     507 
     508   SUBROUTINE mpp_bcast_nml( cdnambuff , kleng ) 
     509      CHARACTER(LEN=:)    , ALLOCATABLE, INTENT(INOUT) :: cdnambuff 
     510      INTEGER                          , INTENT(INOUT) :: kleng 
     511      !!---------------------------------------------------------------------- 
     512      !!                  ***  routine mpp_bcast_nml  *** 
     513      !! 
     514      !! ** Purpose :   broadcast namelist character buffer 
     515      !! 
     516      !!---------------------------------------------------------------------- 
     517      !! 
     518      INTEGER ::   iflag 
     519      !!---------------------------------------------------------------------- 
     520      ! 
     521#if defined key_mpp_mpi 
     522      call MPI_BCAST(kleng, 1, MPI_INT, 0, mpi_comm_oce, iflag) 
     523      call MPI_BARRIER(mpi_comm_oce, iflag) 
     524!$AGRIF_DO_NOT_TREAT 
     525      IF ( .NOT. ALLOCATED(cdnambuff) ) ALLOCATE( CHARACTER(LEN=kleng) :: cdnambuff ) 
     526!$AGRIF_END_DO_NOT_TREAT 
     527      call MPI_BCAST(cdnambuff, kleng, MPI_CHARACTER, 0, mpi_comm_oce, iflag) 
     528      call MPI_BARRIER(mpi_comm_oce, iflag) 
     529#endif 
     530      ! 
     531   END SUBROUTINE mpp_bcast_nml 
    501532 
    502533    
     
    921952      ! 
    922953      ! find the smallest common frequency: default = frequency product, if multiple, choose the larger of the 2 frequency 
    923       IF( ncom_dttrc /= 1 )   CALL ctl_stop( 'STOP', 'mpp_report, ncom_dttrc /= 1 not coded...' )  
    924954      ncom_freq = ncom_fsbc 
    925955      ! 
     
    10681098 
    10691099   !!---------------------------------------------------------------------- 
    1070    !!   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam   routines 
     1100   !!   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam, load_nml   routines 
    10711101   !!---------------------------------------------------------------------- 
    10721102 
     
    12041234         &  OPEN(UNIT=knum,FILE='NUL', FORM=cdform, ACCESS=cdacce, STATUS=cdstat                      , ERR=100, IOSTAT=iost )    
    12051235      IF( iost == 0 ) THEN 
    1206          IF(ldwp) THEN 
     1236         IF(ldwp .AND. kout > 0) THEN 
    12071237            WRITE(kout,*) '     file   : ', TRIM(clfile),' open ok' 
    12081238            WRITE(kout,*) '     unit   = ', knum 
     
    12791309   END FUNCTION get_unit 
    12801310 
     1311   SUBROUTINE load_nml( cdnambuff , cdnamfile, kout, ldwp) 
     1312      CHARACTER(LEN=:)    , ALLOCATABLE, INTENT(INOUT) :: cdnambuff 
     1313      CHARACTER(LEN=*), INTENT(IN )                :: cdnamfile 
     1314      CHARACTER(LEN=256)                           :: chline 
     1315      CHARACTER(LEN=1)                             :: csp 
     1316      INTEGER, INTENT(IN)                          :: kout 
     1317      LOGICAL, INTENT(IN)                          :: ldwp  !: .true. only for the root broadcaster 
     1318      INTEGER                                      :: itot, iun, iltc, inl, ios, itotsav 
     1319      ! 
     1320      !csp = NEW_LINE('A') 
     1321      ! a new line character is the best seperator but some systems (e.g.Cray) 
     1322      ! seem to terminate namelist reads from internal files early if they  
     1323      ! encounter new-lines. Use a single space for safety. 
     1324      csp = ' ' 
     1325      ! 
     1326      ! Check if the namelist buffer has already been allocated. Return if it has. 
     1327      ! 
     1328      IF ( ALLOCATED( cdnambuff ) ) RETURN 
     1329      IF( ldwp ) THEN 
     1330         ! 
     1331         ! Open namelist file 
     1332         ! 
     1333         CALL ctl_opn( iun, cdnamfile, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, kout, ldwp ) 
     1334         ! 
     1335         ! First pass: count characters excluding comments and trimable white space 
     1336         ! 
     1337         itot=0 
     1338     10  READ(iun,'(A256)',END=20,ERR=20) chline 
     1339         iltc = LEN_TRIM(chline) 
     1340         IF ( iltc.GT.0 ) THEN 
     1341          inl = INDEX(chline, '!')  
     1342          IF( inl.eq.0 ) THEN 
     1343           itot = itot + iltc + 1                                ! +1 for the newline character 
     1344          ELSEIF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl-1) ).GT.0 ) THEN 
     1345           itot = itot + inl                                  !  includes +1 for the newline character 
     1346          ENDIF 
     1347         ENDIF 
     1348         GOTO 10 
     1349     20  CONTINUE 
     1350         ! 
     1351         ! Allocate text cdnambuff for condensed namelist 
     1352         ! 
     1353!$AGRIF_DO_NOT_TREAT 
     1354         ALLOCATE( CHARACTER(LEN=itot) :: cdnambuff ) 
     1355!$AGRIF_END_DO_NOT_TREAT 
     1356         itotsav = itot 
     1357         ! 
     1358         ! Second pass: read and transfer pruned characters into cdnambuff 
     1359         ! 
     1360         REWIND(iun) 
     1361         itot=1 
     1362     30  READ(iun,'(A256)',END=40,ERR=40) chline 
     1363         iltc = LEN_TRIM(chline) 
     1364         IF ( iltc.GT.0 ) THEN 
     1365          inl = INDEX(chline, '!') 
     1366          IF( inl.eq.0 ) THEN 
     1367           inl = iltc 
     1368          ELSE 
     1369           inl = inl - 1 
     1370          ENDIF 
     1371          IF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl) ).GT.0 ) THEN 
     1372             cdnambuff(itot:itot+inl-1) = chline(1:inl) 
     1373             WRITE( cdnambuff(itot+inl:itot+inl), '(a)' ) csp 
     1374             itot = itot + inl + 1 
     1375          ENDIF 
     1376         ENDIF 
     1377         GOTO 30 
     1378     40  CONTINUE 
     1379         itot = itot - 1 
     1380         IF( itotsav .NE. itot ) WRITE(*,*) 'WARNING in load_nml. Allocated ',itotsav,' for read buffer; but used ',itot 
     1381         ! 
     1382         ! Close namelist file 
     1383         ! 
     1384         CLOSE(iun) 
     1385         !write(*,'(32A)') cdnambuff 
     1386      ENDIF 
     1387#if defined key_mpp_mpi 
     1388      CALL mpp_bcast_nml( cdnambuff, itot ) 
     1389#endif 
     1390  END SUBROUTINE load_nml 
     1391 
     1392 
    12811393   !!---------------------------------------------------------------------- 
    12821394END MODULE lib_mpp 
Note: See TracChangeset for help on using the changeset viewer.