Changeset 11648 for NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/LBC/lib_mpp.F90
- Timestamp:
- 2019-10-03T17:57:40+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/LBC/lib_mpp.F90
r11624 r11648 51 51 !! mpp_ini_north : initialisation of north fold 52 52 !! 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 53 54 !!---------------------------------------------------------------------- 54 55 USE dom_oce ! ocean space and time domain … … 67 68 PUBLIC mppsend, mpprecv ! needed by TAM and ICB routines 68 69 PUBLIC mpp_report 70 PUBLIC mpp_bcast_nml 69 71 PUBLIC tic_tac 70 72 #if ! defined key_mpp_mpi … … 500 502 #endif 501 503 END SUBROUTINE mpp_delay_rcv 504 505 SUBROUTINE mpp_bcast_nml( cdnambuff , kleng ) 506 CHARACTER(LEN=:) , ALLOCATABLE, INTENT(INOUT) :: cdnambuff 507 INTEGER , INTENT(INOUT) :: kleng 508 !!---------------------------------------------------------------------- 509 !! *** routine mpp_bcast_nml *** 510 !! 511 !! ** Purpose : broadcast namelist character buffer 512 !! 513 !!---------------------------------------------------------------------- 514 !! 515 INTEGER :: iflag 516 !!---------------------------------------------------------------------- 517 ! 518 #if defined key_mpp_mpi 519 call MPI_BCAST(kleng, 1, MPI_INT, 0, mpi_comm_oce, iflag) 520 call MPI_BARRIER(mpi_comm_oce, iflag) 521 IF ( .NOT. ALLOCATED(cdnambuff) ) ALLOCATE( CHARACTER(LEN=kleng) :: cdnambuff ) 522 call MPI_BCAST(cdnambuff, kleng, MPI_CHARACTER, 0, mpi_comm_oce, iflag) 523 call MPI_BARRIER(mpi_comm_oce, iflag) 524 #endif 525 ! 526 END SUBROUTINE mpp_bcast_nml 502 527 503 528 … … 1285 1310 CHARACTER(LEN=256) :: chline 1286 1311 INTEGER, INTENT(IN) :: kout 1287 LOGICAL, INTENT(IN) :: ldwp 1312 LOGICAL, INTENT(IN) :: ldwp !: .true. only for the root broadcaster 1288 1313 INTEGER :: itot, iun, iltc, inl, ios 1289 1314 ! … … 1291 1316 ! 1292 1317 IF ( ALLOCATED( cdnambuff ) ) RETURN 1293 ! 1294 ! Open namelist file 1295 ! 1296 CALL ctl_opn( iun, cdnamfile, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, kout, ldwp ) 1297 ! 1298 ! First pass: count characters excluding comments and trimable white space 1299 ! 1300 itot=0 1301 10 READ(iun,'(A256)',END=20,ERR=20) chline 1302 iltc = LEN_TRIM(chline) 1303 IF ( iltc.GT.0 ) THEN 1304 inl = INDEX(chline, '!') 1305 IF( inl.eq.0 ) THEN 1306 itot = itot + iltc + 1 ! +1 for the newline character 1307 ELSEIF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl-1) ).GT.0 ) THEN 1308 itot = itot + inl ! includes +1 for the newline character 1309 ENDIF 1310 ENDIF 1311 GOTO 10 1312 20 CONTINUE 1313 ! 1314 ! Allocate text cdnambuff for condensed namelist 1315 ! 1316 ALLOCATE( CHARACTER(LEN=itot) :: cdnambuff ) 1317 WRITE(*,*) 'ALLOCATED ', itot 1318 ! 1319 ! Second pass: read and transfer pruned characters into cdnambuff 1320 ! 1321 REWIND(iun) 1322 itot=1 1323 30 READ(iun,'(A256)',END=40,ERR=40) chline 1324 iltc = LEN_TRIM(chline) 1325 IF ( iltc.GT.0 ) THEN 1326 inl = INDEX(chline, '!') 1327 IF( inl.eq.0 ) THEN 1328 inl = iltc 1329 ELSE 1330 inl = inl - 1 1331 ENDIF 1332 IF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl) ).GT.0 ) THEN 1333 cdnambuff(itot:itot+inl-1) = chline(1:inl) 1334 WRITE( cdnambuff(itot+inl:itot+inl), '(a)' ) NEW_LINE('A') 1335 itot = itot + inl + 1 1336 ENDIF 1337 ENDIF 1338 GOTO 30 1339 40 CONTINUE 1340 WRITE(*,*) 'ASSIGNED ',itot - 1 1341 ! 1342 ! Close namelist file 1343 ! 1344 CLOSE(iun) 1345 !write(*,'(32A)') cdnambuff 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 ALLOCATE( CHARACTER(LEN=itot) :: cdnambuff ) 1343 WRITE(*,*) 'ALLOCATED ', itot 1344 ! 1345 ! Second pass: read and transfer pruned characters into cdnambuff 1346 ! 1347 REWIND(iun) 1348 itot=1 1349 30 READ(iun,'(A256)',END=40,ERR=40) chline 1350 iltc = LEN_TRIM(chline) 1351 IF ( iltc.GT.0 ) THEN 1352 inl = INDEX(chline, '!') 1353 IF( inl.eq.0 ) THEN 1354 inl = iltc 1355 ELSE 1356 inl = inl - 1 1357 ENDIF 1358 IF( inl.GT.0 .AND. LEN_TRIM( chline(1:inl) ).GT.0 ) THEN 1359 cdnambuff(itot:itot+inl-1) = chline(1:inl) 1360 WRITE( cdnambuff(itot+inl:itot+inl), '(a)' ) NEW_LINE('A') 1361 itot = itot + inl + 1 1362 ENDIF 1363 ENDIF 1364 GOTO 30 1365 40 CONTINUE 1366 itot = itot - 1 1367 WRITE(*,*) 'ASSIGNED ',itot 1368 ! 1369 ! Close namelist file 1370 ! 1371 CLOSE(iun) 1372 !write(*,'(32A)') cdnambuff 1373 ENDIF 1374 #if defined key_mpp_mpi 1375 CALL mpp_bcast_nml( cdnambuff, itot ) 1376 #endif 1346 1377 END SUBROUTINE load_nml 1347 1378
Note: See TracChangeset
for help on using the changeset viewer.