- Timestamp:
- 2019-10-01T15:07:45+02:00 (5 years ago)
- Location:
- NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/IOM/in_out_manager.F90
r11536 r11624 139 139 INTEGER :: numnul = -1 !: logical unit for /dev/null 140 140 ! ! early output can be collected; do not change 141 INTEGER :: numnam_ref = -1 !: logical unit for reference namelist142 INTEGER :: numnam_cfg = -1 !: logical unit for configuration specific namelist143 141 INTEGER :: numond = -1 !: logical unit for Output Namelist Dynamics 144 INTEGER :: numnam_ice_ref = -1 !: logical unit for ice reference namelist145 INTEGER :: numnam_ice_cfg = -1 !: logical unit for ice reference namelist146 142 INTEGER :: numoni = -1 !: logical unit for Output Namelist Ice 147 143 INTEGER :: numevo_ice = -1 !: logical unit for ice variables (temp. evolution) 148 144 INTEGER :: numrun = -1 !: logical unit for run statistics 149 145 INTEGER :: numdct_in = -1 !: logical unit for transports computing 150 INTEGER :: numdct_vol = -1 !: logical unit for vo ulume transports output151 INTEGER :: numdct_heat = -1 !: logical unit for heat 152 INTEGER :: numdct_salt = -1 !: logical unit for salt 146 INTEGER :: numdct_vol = -1 !: logical unit for volume transports output 147 INTEGER :: numdct_heat = -1 !: logical unit for heat transports output 148 INTEGER :: numdct_salt = -1 !: logical unit for salt transports output 153 149 INTEGER :: numfl = -1 !: logical unit for floats ascii output 154 150 INTEGER :: numflo = -1 !: logical unit for floats ascii output 151 ! 152 CHARACTER(LEN=:), ALLOCATABLE :: numnam_ref !: character buffer for reference namelist 153 CHARACTER(LEN=:), ALLOCATABLE :: numnam_cfg !: character buffer for configuration specific namelist 154 CHARACTER(LEN=:), ALLOCATABLE :: numnam_ice_ref !: character buffer for ice reference namelist 155 CHARACTER(LEN=:), ALLOCATABLE :: numnam_ice_cfg !: character buffer for ice configuration specific namelist 155 156 156 157 !!---------------------------------------------------------------------- -
NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/LBC/lib_mpp.F90
r11536 r11624 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 !!---------------------------------------------------------------------- … … 57 58 PRIVATE 58 59 ! 59 PUBLIC ctl_stop, ctl_warn, ctl_opn, ctl_nam 60 PUBLIC ctl_stop, ctl_warn, ctl_opn, ctl_nam, load_nml 60 61 PUBLIC mpp_start, mppstop, mppsync, mpp_comm_free 61 62 PUBLIC mpp_ini_north … … 1068 1069 1069 1070 !!---------------------------------------------------------------------- 1070 !! ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam routines1071 !! ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam, load_nml routines 1071 1072 !!---------------------------------------------------------------------- 1072 1073 … … 1279 1280 END FUNCTION get_unit 1280 1281 1282 SUBROUTINE load_nml( cdnambuff , cdnamfile, kout, ldwp) 1283 CHARACTER(LEN=:) , ALLOCATABLE, INTENT(INOUT) :: cdnambuff 1284 CHARACTER(LEN=*), INTENT(IN ) :: cdnamfile 1285 CHARACTER(LEN=256) :: chline 1286 INTEGER, INTENT(IN) :: kout 1287 LOGICAL, INTENT(IN) :: ldwp 1288 INTEGER :: itot, iun, iltc, inl, ios 1289 ! 1290 ! Check if the namelist buffer has already been allocated. Return if it has. 1291 ! 1292 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 1346 END SUBROUTINE load_nml 1347 1348 1281 1349 !!---------------------------------------------------------------------- 1282 1350 END MODULE lib_mpp -
NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/nemogcm.F90
r11536 r11624 307 307 IF( lwm ) CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) 308 308 ! open reference and configuration namelist files 309 CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1,-1, .FALSE. )310 CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1,-1, .FALSE. )309 CALL load_nml( numnam_ref, 'namelist_ref', -1, .FALSE. ) 310 CALL load_nml( numnam_cfg, 'namelist_cfg', -1, .FALSE. ) 311 311 IF( lwm ) CALL ctl_opn( numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. ) 312 312 ! open /dev/null file to be able to supress output write easily … … 317 317 ! !--------------------! 318 318 ! 319 REWIND( numnam_ref ) ! Namelist namctl in reference namelist320 319 READ ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 ) 321 320 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist' ) 322 REWIND( numnam_cfg ) ! Namelist namctl in confguration namelist323 321 READ ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 ) 324 322 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist' ) … … 375 373 ! !------------------------------------! 376 374 ! 377 REWIND( numnam_ref ) ! Namelist namcfg in reference namelist378 375 READ ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 ) 379 376 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist' ) 380 REWIND( numnam_cfg ) ! Namelist namcfg in confguration namelist381 377 READ ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 ) 382 378 904 IF( ios > 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist' ) … … 619 615 IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file 620 616 IF( numrun /= -1 ) CLOSE( numrun ) ! run statistics file 621 IF( numnam_ref /= -1 ) CLOSE( numnam_ref ) ! oce reference namelist622 IF( numnam_cfg /= -1 ) CLOSE( numnam_cfg ) ! oce configuration namelist623 617 IF( lwm.AND.numond /= -1 ) CLOSE( numond ) ! oce output namelist 624 IF( numnam_ice_ref /= -1 ) CLOSE( numnam_ice_ref ) ! ice reference namelist625 IF( numnam_ice_cfg /= -1 ) CLOSE( numnam_ice_cfg ) ! ice configuration namelist626 618 IF( lwm.AND.numoni /= -1 ) CLOSE( numoni ) ! ice output namelist 627 619 IF( numevo_ice /= -1 ) CLOSE( numevo_ice ) ! ice variables (temp. evolution)
Note: See TracChangeset
for help on using the changeset viewer.