Index: NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/LBC/lib_mpp.F90	(revision 11642)
+++ NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/LBC/lib_mpp.F90	(revision 11648)
@@ -51,4 +51,5 @@
    !!   mpp_ini_north : initialisation of north fold
    !!   mpp_lbc_north_icb : alternative to mpp_nfd for extra outer halo with icebergs
+   !!   mpp_bcast_nml : broadcast/receive namelist character buffer from reading process to all others
    !!----------------------------------------------------------------------
    USE dom_oce        ! ocean space and time domain
@@ -67,4 +68,5 @@
    PUBLIC   mppsend, mpprecv                          ! needed by TAM and ICB routines
    PUBLIC   mpp_report
+   PUBLIC   mpp_bcast_nml
    PUBLIC   tic_tac
 #if ! defined key_mpp_mpi
@@ -500,4 +502,27 @@
 #endif
    END SUBROUTINE mpp_delay_rcv
+
+   SUBROUTINE mpp_bcast_nml( cdnambuff , kleng )
+      CHARACTER(LEN=:)    , ALLOCATABLE, INTENT(INOUT) :: cdnambuff
+      INTEGER                          , INTENT(INOUT) :: kleng
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_bcast_nml  ***
+      !!
+      !! ** Purpose :   broadcast namelist character buffer
+      !!
+      !!----------------------------------------------------------------------
+      !!
+      INTEGER ::   iflag
+      !!----------------------------------------------------------------------
+      !
+#if defined key_mpp_mpi
+      call MPI_BCAST(kleng, 1, MPI_INT, 0, mpi_comm_oce, iflag)
+      call MPI_BARRIER(mpi_comm_oce, iflag)
+      IF ( .NOT. ALLOCATED(cdnambuff) ) ALLOCATE( CHARACTER(LEN=kleng) :: cdnambuff )
+      call MPI_BCAST(cdnambuff, kleng, MPI_CHARACTER, 0, mpi_comm_oce, iflag)
+      call MPI_BARRIER(mpi_comm_oce, iflag)
+#endif
+      !
+   END SUBROUTINE mpp_bcast_nml
 
    
@@ -1285,5 +1310,5 @@
       CHARACTER(LEN=256)                           :: chline
       INTEGER, INTENT(IN)                          :: kout
-      LOGICAL, INTENT(IN)                          :: ldwp
+      LOGICAL, INTENT(IN)                          :: ldwp  !: .true. only for the root broadcaster
       INTEGER                                      :: itot, iun, iltc, inl, ios
       !
@@ -1291,57 +1316,63 @@
       !
       IF ( ALLOCATED( cdnambuff ) ) RETURN
-      !
-      ! Open namelist file
-      !
-      CALL ctl_opn( iun, cdnamfile, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, kout, ldwp )
-      !
-      ! First pass: count characters excluding comments and trimable white space
-      !
-      itot=0
-  10  READ(iun,'(A256)',END=20,ERR=20) chline
-      iltc = LEN_TRIM(chline)
-      IF ( iltc.GT.0 ) THEN
-       inl = INDEX(chline, '!') 
-       IF( inl.eq.0 ) THEN
-        itot = itot + iltc + 1                                ! +1 for the newline character
-       ELSEIF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl-1) ).GT.0 ) THEN
-        itot = itot + inl                                  !  includes +1 for the newline character
-       ENDIF
-      ENDIF
-      GOTO 10
-  20  CONTINUE
-      !
-      ! Allocate text cdnambuff for condensed namelist
-      !
-      ALLOCATE( CHARACTER(LEN=itot) :: cdnambuff )
-      WRITE(*,*) 'ALLOCATED ', itot
-      !
-      ! Second pass: read and transfer pruned characters into cdnambuff
-      !
-      REWIND(iun)
-      itot=1
-  30  READ(iun,'(A256)',END=40,ERR=40) chline
-      iltc = LEN_TRIM(chline)
-      IF ( iltc.GT.0 ) THEN
-       inl = INDEX(chline, '!')
-       IF( inl.eq.0 ) THEN
-        inl = iltc
-       ELSE
-        inl = inl - 1
-       ENDIF
-       IF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl) ).GT.0 ) THEN
-          cdnambuff(itot:itot+inl-1) = chline(1:inl)
-          WRITE( cdnambuff(itot+inl:itot+inl), '(a)' ) NEW_LINE('A')
-          itot = itot + inl + 1
-       ENDIF
-      ENDIF
-      GOTO 30
-  40  CONTINUE
-      WRITE(*,*) 'ASSIGNED ',itot - 1
-      !
-      ! Close namelist file
-      !
-      CLOSE(iun)
-      !write(*,'(32A)') cdnambuff
+      IF( ldwp ) THEN
+         !
+         ! Open namelist file
+         !
+         CALL ctl_opn( iun, cdnamfile, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, kout, ldwp )
+         !
+         ! First pass: count characters excluding comments and trimable white space
+         !
+         itot=0
+     10  READ(iun,'(A256)',END=20,ERR=20) chline
+         iltc = LEN_TRIM(chline)
+         IF ( iltc.GT.0 ) THEN
+          inl = INDEX(chline, '!') 
+          IF( inl.eq.0 ) THEN
+           itot = itot + iltc + 1                                ! +1 for the newline character
+          ELSEIF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl-1) ).GT.0 ) THEN
+           itot = itot + inl                                  !  includes +1 for the newline character
+          ENDIF
+         ENDIF
+         GOTO 10
+     20  CONTINUE
+         !
+         ! Allocate text cdnambuff for condensed namelist
+         !
+         ALLOCATE( CHARACTER(LEN=itot) :: cdnambuff )
+         WRITE(*,*) 'ALLOCATED ', itot
+         !
+         ! Second pass: read and transfer pruned characters into cdnambuff
+         !
+         REWIND(iun)
+         itot=1
+     30  READ(iun,'(A256)',END=40,ERR=40) chline
+         iltc = LEN_TRIM(chline)
+         IF ( iltc.GT.0 ) THEN
+          inl = INDEX(chline, '!')
+          IF( inl.eq.0 ) THEN
+           inl = iltc
+          ELSE
+           inl = inl - 1
+          ENDIF
+          IF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl) ).GT.0 ) THEN
+             cdnambuff(itot:itot+inl-1) = chline(1:inl)
+             WRITE( cdnambuff(itot+inl:itot+inl), '(a)' ) NEW_LINE('A')
+             itot = itot + inl + 1
+          ENDIF
+         ENDIF
+         GOTO 30
+     40  CONTINUE
+         itot = itot - 1
+         WRITE(*,*) 'ASSIGNED ',itot
+         !
+         ! Close namelist file
+         !
+         CLOSE(iun)
+         !write(*,'(32A)') cdnambuff
+      ENDIF
+#if defined key_mpp_mpi
+      CALL mpp_bcast_nml( cdnambuff, itot )
+#endif
   END SUBROUTINE load_nml
 
Index: NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/nemogcm.F90	(revision 11642)
+++ NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/nemogcm.F90	(revision 11648)
@@ -307,6 +307,6 @@
       IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
       ! open reference and configuration namelist files
-                  CALL load_nml( numnam_ref,        'namelist_ref',                                           -1, .FALSE. )
-                  CALL load_nml( numnam_cfg,        'namelist_cfg',                                           -1, .FALSE. )
+                  CALL load_nml( numnam_ref,        'namelist_ref',                                           -1, lwm )
+                  CALL load_nml( numnam_cfg,        'namelist_cfg',                                           -1, lwm )
       IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
       ! open /dev/null file to be able to supress output write easily
