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

Ignore:
Timestamp:
2019-11-25T18:19:39+01:00 (4 years ago)
Author:
acc
Message:

Branch 2019/dev_r11943_MERGE_2019. Merge in changes from 2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles. (svn merge -r 11614:11954). Resolved tree conflicts and one actual conflict. Sette tested(these changes alter the ext/AGRIF reference; remember to update). See ticket #2341

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

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11943_MERGE_2019

    • Property svn:externals
      •  

        old new  
        33^/utils/build/mk@HEAD         mk 
        44^/utils/tools@HEAD            tools 
        5 ^/vendors/AGRIF/dev@HEAD      ext/AGRIF 
         5^/vendors/AGRIF/dev_r11615_ENHANCE-04_namelists_as_internalfiles_agrif@HEAD      ext/AGRIF 
        66^/vendors/FCM@HEAD            ext/FCM 
        77^/vendors/IOIPSL@HEAD         ext/IOIPSL 
  • NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/LBC/lib_mpp.F90

    r11949 r11960  
    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 
     
    498501#endif 
    499502   END SUBROUTINE mpp_delay_rcv 
     503 
     504   SUBROUTINE mpp_bcast_nml( cdnambuff , kleng ) 
     505      CHARACTER(LEN=:)    , ALLOCATABLE, INTENT(INOUT) :: cdnambuff 
     506      INTEGER                          , INTENT(INOUT) :: kleng 
     507      !!---------------------------------------------------------------------- 
     508      !!                  ***  routine mpp_bcast_nml  *** 
     509      !! 
     510      !! ** Purpose :   broadcast namelist character buffer 
     511      !! 
     512      !!---------------------------------------------------------------------- 
     513      !! 
     514      INTEGER ::   iflag 
     515      !!---------------------------------------------------------------------- 
     516      ! 
     517#if defined key_mpp_mpi 
     518      call MPI_BCAST(kleng, 1, MPI_INT, 0, mpi_comm_oce, iflag) 
     519      call MPI_BARRIER(mpi_comm_oce, iflag) 
     520!$AGRIF_DO_NOT_TREAT 
     521      IF ( .NOT. ALLOCATED(cdnambuff) ) ALLOCATE( CHARACTER(LEN=kleng) :: cdnambuff ) 
     522!$AGRIF_END_DO_NOT_TREAT 
     523      call MPI_BCAST(cdnambuff, kleng, MPI_CHARACTER, 0, mpi_comm_oce, iflag) 
     524      call MPI_BARRIER(mpi_comm_oce, iflag) 
     525#endif 
     526      ! 
     527   END SUBROUTINE mpp_bcast_nml 
    500528 
    501529    
     
    10661094 
    10671095   !!---------------------------------------------------------------------- 
    1068    !!   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam   routines 
     1096   !!   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam, load_nml   routines 
    10691097   !!---------------------------------------------------------------------- 
    10701098 
     
    12771305   END FUNCTION get_unit 
    12781306 
     1307   SUBROUTINE load_nml( cdnambuff , cdnamfile, kout, ldwp) 
     1308      CHARACTER(LEN=:)    , ALLOCATABLE, INTENT(INOUT) :: cdnambuff 
     1309      CHARACTER(LEN=*), INTENT(IN )                :: cdnamfile 
     1310      CHARACTER(LEN=256)                           :: chline 
     1311      INTEGER, INTENT(IN)                          :: kout 
     1312      LOGICAL, INTENT(IN)                          :: ldwp  !: .true. only for the root broadcaster 
     1313      INTEGER                                      :: itot, iun, iltc, inl, ios, itotsav 
     1314      ! 
     1315      ! Check if the namelist buffer has already been allocated. Return if it has. 
     1316      ! 
     1317      IF ( ALLOCATED( cdnambuff ) ) RETURN 
     1318      IF( ldwp ) THEN 
     1319         ! 
     1320         ! Open namelist file 
     1321         ! 
     1322         CALL ctl_opn( iun, cdnamfile, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, kout, ldwp ) 
     1323         ! 
     1324         ! First pass: count characters excluding comments and trimable white space 
     1325         ! 
     1326         itot=0 
     1327     10  READ(iun,'(A256)',END=20,ERR=20) chline 
     1328         iltc = LEN_TRIM(chline) 
     1329         IF ( iltc.GT.0 ) THEN 
     1330          inl = INDEX(chline, '!')  
     1331          IF( inl.eq.0 ) THEN 
     1332           itot = itot + iltc + 1                                ! +1 for the newline character 
     1333          ELSEIF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl-1) ).GT.0 ) THEN 
     1334           itot = itot + inl                                  !  includes +1 for the newline character 
     1335          ENDIF 
     1336         ENDIF 
     1337         GOTO 10 
     1338     20  CONTINUE 
     1339         ! 
     1340         ! Allocate text cdnambuff for condensed namelist 
     1341         ! 
     1342!$AGRIF_DO_NOT_TREAT 
     1343         ALLOCATE( CHARACTER(LEN=itot) :: cdnambuff ) 
     1344!$AGRIF_END_DO_NOT_TREAT 
     1345         itotsav = itot 
     1346         ! 
     1347         ! Second pass: read and transfer pruned characters into cdnambuff 
     1348         ! 
     1349         REWIND(iun) 
     1350         itot=1 
     1351     30  READ(iun,'(A256)',END=40,ERR=40) chline 
     1352         iltc = LEN_TRIM(chline) 
     1353         IF ( iltc.GT.0 ) THEN 
     1354          inl = INDEX(chline, '!') 
     1355          IF( inl.eq.0 ) THEN 
     1356           inl = iltc 
     1357          ELSE 
     1358           inl = inl - 1 
     1359          ENDIF 
     1360          IF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl) ).GT.0 ) THEN 
     1361             cdnambuff(itot:itot+inl-1) = chline(1:inl) 
     1362             WRITE( cdnambuff(itot+inl:itot+inl), '(a)' ) NEW_LINE('A') 
     1363             itot = itot + inl + 1 
     1364          ENDIF 
     1365         ENDIF 
     1366         GOTO 30 
     1367     40  CONTINUE 
     1368         itot = itot - 1 
     1369         IF( itotsav .NE. itot ) WRITE(*,*) 'WARNING in load_nml. Allocated ',itotsav,' for read buffer; but used ',itot 
     1370         ! 
     1371         ! Close namelist file 
     1372         ! 
     1373         CLOSE(iun) 
     1374         !write(*,'(32A)') cdnambuff 
     1375      ENDIF 
     1376#if defined key_mpp_mpi 
     1377      CALL mpp_bcast_nml( cdnambuff, itot ) 
     1378#endif 
     1379  END SUBROUTINE load_nml 
     1380 
     1381 
    12791382   !!---------------------------------------------------------------------- 
    12801383END MODULE lib_mpp 
Note: See TracChangeset for help on using the changeset viewer.