- Timestamp:
- 2019-11-25T18:19:39+01:00 (5 years ago)
- 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 3 3 ^/utils/build/mk@HEAD mk 4 4 ^/utils/tools@HEAD tools 5 ^/vendors/AGRIF/dev @HEAD ext/AGRIF5 ^/vendors/AGRIF/dev_r11615_ENHANCE-04_namelists_as_internalfiles_agrif@HEAD ext/AGRIF 6 6 ^/vendors/FCM@HEAD ext/FCM 7 7 ^/vendors/IOIPSL@HEAD ext/IOIPSL
-
- Property svn:externals
-
NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/LBC/lib_mpp.F90
r11949 r11960 32 32 !! ctl_opn : Open file and check if required file is available. 33 33 !! 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 34 35 !!---------------------------------------------------------------------- 35 36 !!---------------------------------------------------------------------- … … 50 51 !! mpp_ini_north : initialisation of north fold 51 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 52 54 !!---------------------------------------------------------------------- 53 55 USE dom_oce ! ocean space and time domain … … 57 59 PRIVATE 58 60 ! 59 PUBLIC ctl_stop, ctl_warn, ctl_opn, ctl_nam 61 PUBLIC ctl_stop, ctl_warn, ctl_opn, ctl_nam, load_nml 60 62 PUBLIC mpp_start, mppstop, mppsync, mpp_comm_free 61 63 PUBLIC mpp_ini_north … … 66 68 PUBLIC mppsend, mpprecv ! needed by TAM and ICB routines 67 69 PUBLIC mpp_report 70 PUBLIC mpp_bcast_nml 68 71 PUBLIC tic_tac 69 72 #if ! defined key_mpp_mpi … … 498 501 #endif 499 502 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 500 528 501 529 … … 1066 1094 1067 1095 !!---------------------------------------------------------------------- 1068 !! ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam routines1096 !! ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam, load_nml routines 1069 1097 !!---------------------------------------------------------------------- 1070 1098 … … 1277 1305 END FUNCTION get_unit 1278 1306 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 1279 1382 !!---------------------------------------------------------------------- 1280 1383 END MODULE lib_mpp
Note: See TracChangeset
for help on using the changeset viewer.