Changeset 4107 for palm/trunk
- Timestamp:
- Jul 22, 2019 8:51:35 AM (5 years ago)
- Location:
- palm/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/data_output_binary_module.f90
r4106 r4107 56 56 CHARACTER(LEN=*), PARAMETER :: config_file_name = 'BINARY_TO_NETCDF_CONFIG' !< name of config file 57 57 CHARACTER(LEN=*), PARAMETER :: mode_binary = 'binary' !< string to select operation mode of module 58 CHARACTER(LEN=*), PARAMETER :: prefix = 'BIN_' !< file prefix for binary files 59 58 CHARACTER(LEN=*), PARAMETER :: file_prefix = 'BIN_' !< file prefix for binary files 59 60 CHARACTER(LEN=charlen) :: file_suffix = '' !< file suffix added to each file name 60 61 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message 61 62 CHARACTER(LEN=800) :: temp_string !< dummy string … … 65 66 INTEGER(iwp) :: debug_output_unit !< Fortran Unit Number of the debug-output file 66 67 INTEGER(iwp) :: global_id_in_file = -1 !< value of global ID within a file 68 INTEGER :: master_rank !< master rank for tasks to be executed by single PE only 67 69 INTEGER(iwp) :: next_available_unit !< next unit number available for new file 70 INTEGER :: output_group_comm !< MPI communicator addressing all MPI ranks which participate in output 68 71 69 72 INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: files_highest_var_id !< highest assigned ID of variable or dimension in a file … … 133 136 !> Initialize data-output module. 134 137 !--------------------------------------------------------------------------------------------------! 135 SUBROUTINE binary_init_module( program_debug_output_unit, debug_output, dom_global_id ) 138 SUBROUTINE binary_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, & 139 master_output_rank, & 140 program_debug_output_unit, debug_output, dom_global_id ) 141 142 CHARACTER(LEN=*), INTENT(IN) :: file_suffix_of_output_group !> file-name suffix added to each file; 143 !> must be unique for each output group 136 144 137 145 INTEGER(iwp), INTENT(IN) :: dom_global_id !< global id within a file defined by DOM 146 INTEGER, INTENT(IN) :: master_output_rank !< MPI rank executing tasks which must be executed by a single PE 147 INTEGER, INTENT(IN) :: mpi_comm_of_output_group !< MPI communicator specifying the rank group participating in output 138 148 INTEGER(iwp), INTENT(IN) :: program_debug_output_unit !< file unit number for debug output 139 149 … … 141 151 142 152 153 file_suffix = file_suffix_of_output_group 154 output_group_comm = mpi_comm_of_output_group 155 master_rank = master_output_rank 156 143 157 debug_output_unit = program_debug_output_unit 144 145 158 print_debug_output = debug_output 146 159 147 160 global_id_in_file = dom_global_id 148 149 161 150 162 END SUBROUTINE binary_init_module … … 159 171 CHARACTER(LEN=charlen) :: bin_filename = '' !< actual name of binary file 160 172 CHARACTER(LEN=charlen), INTENT(IN) :: filename !< name of file 161 CHARACTER(LEN=7) :: my id_char !< string containing value of myidwith leading zeros173 CHARACTER(LEN=7) :: my_rank_char !< string containing value of my_rank with leading zeros 162 174 CHARACTER(LEN=*), INTENT(IN) :: mode !< operation mode 163 175 … … 165 177 166 178 INTEGER(iwp), INTENT(OUT) :: file_id !< file ID 167 INTEGER(iwp) :: myid !< id of local processor id (MPI rank) 179 INTEGER :: my_rank !< MPI rank of local processor 180 INTEGER :: nrank !< number of MPI ranks participating in output 168 181 INTEGER(iwp), INTENT(OUT) :: return_value !< return value 169 182 … … 176 189 177 190 #if defined( __parallel ) 178 CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, return_value ) 191 CALL MPI_COMM_SIZE( output_group_comm, nrank, return_value ) 192 IF ( return_value == 0 ) CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value ) 179 193 IF ( return_value == 0 ) THEN 180 WRITE( my id_char, '("_",I6.6)' ) myid194 WRITE( my_rank_char, '("_",I6.6)' ) my_rank 181 195 ELSE 182 CALL internal_message( ' debug', routine_name // ': MPI_COMM_RANKerror' )196 CALL internal_message( 'error', routine_name // ': MPI error' ) 183 197 ENDIF 184 198 #else 185 myid = 0 186 myid_char = '_' // REPEAT('0', 6) 199 nrank = 1 200 my_rank = master_rank 201 WRITE( my_rank_char, '("_",I6.6)' ) my_rank 187 202 #endif 188 203 … … 196 211 config_file_unit = binary_file_lowest_unit 197 212 198 IF ( my id == 0) THEN213 IF ( my_rank == master_rank ) THEN 199 214 200 215 !-- Remove any pre-existing file 201 INQUIRE( FILE=TRIM( config_file_name ), EXIST=file_exists ) 216 INQUIRE( FILE=TRIM( config_file_name ) // TRIM( file_suffix ), & 217 EXIST=file_exists ) 202 218 203 219 IF ( file_exists ) THEN 204 CALL internal_message( 'debug', routine_name // & 205 ': Remove existing file ' // & 206 TRIM( config_file_name ) ) 207 CALL SYSTEM( 'rm ' // TRIM( config_file_name ) ) 220 CALL internal_message( 'debug', routine_name // & 221 ': Remove existing file ' // & 222 TRIM( config_file_name ) // TRIM( file_suffix ) ) 223 CALL EXECUTE_COMMAND_LINE( & 224 COMMAND='rm ' // TRIM( config_file_name ) // TRIM( file_suffix ), & 225 WAIT=.TRUE., EXITSTAT=return_value ) 208 226 ENDIF 209 227 210 OPEN( config_file_unit, FILE=TRIM( config_file_name ) , &228 OPEN( config_file_unit, FILE=TRIM( config_file_name ) // TRIM( file_suffix ), & 211 229 FORM='UNFORMATTED', STATUS='NEW', IOSTAT=return_value ) 212 230 … … 216 234 217 235 !-- Write some general information to config file 218 WRITE( config_file_unit ) LEN( prefix ) 219 WRITE( config_file_unit ) prefix 236 WRITE( config_file_unit ) nrank 237 WRITE( config_file_unit ) master_rank 238 WRITE( config_file_unit ) LEN( file_prefix ) 239 WRITE( config_file_unit ) file_prefix 220 240 WRITE( config_file_unit ) charlen 221 241 WRITE( config_file_unit ) global_id_in_file … … 237 257 IF ( return_value == 0 ) THEN 238 258 239 bin_filename = prefix // TRIM( filename ) // myid_char259 bin_filename = file_prefix // TRIM( filename ) // TRIM( file_suffix ) // my_rank_char 240 260 241 261 !-- Remove any pre-existing file … … 245 265 CALL internal_message( 'debug', routine_name // & 246 266 ': remove existing file ' // TRIM( bin_filename ) ) 247 CALL SYSTEM( 'rm ' // TRIM( bin_filename ) ) 267 CALL EXECUTE_COMMAND_LINE( COMMAND='rm ' // TRIM( bin_filename ), & 268 WAIT=.TRUE., EXITSTAT=return_value ) 248 269 ENDIF 249 270 … … 256 277 257 278 !-- Add filename to config file 258 IF ( my id == 0) THEN279 IF ( my_rank == master_rank ) THEN 259 280 WRITE( config_file_unit ) filename 260 281 ENDIF -
palm/trunk/SOURCE/data_output_module.f90
r4106 r4107 136 136 137 137 CHARACTER(LEN=charlen) :: output_file_format = 'binary' !< file format (namelist parameter) 138 CHARACTER(LEN=charlen) :: output_file_suffix = '' !< file suffix added to each file name 138 139 139 140 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message … … 142 143 INTEGER(iwp) :: debug_output_unit !< Fortran Unit Number of the debug-output file 143 144 INTEGER(iwp) :: nf !< number of files 145 INTEGER :: master_rank = 0 !< master rank for tasks to be executed by single PE only 146 INTEGER :: output_group_comm !< MPI communicator addressing all MPI ranks which participate in output 144 147 145 148 INTEGER(iwp), PARAMETER :: no_var_id = -1 !< value of var_id if no variable is selected … … 223 226 !> Initialize data-output module 224 227 !--------------------------------------------------------------------------------------------------! 225 SUBROUTINE dom_init( program_debug_output_unit, debug_output ) 226 227 INTEGER(iwp), INTENT(IN) :: program_debug_output_unit !< file unit number for debug output 228 SUBROUTINE dom_init( file_suffix_of_output_group, mpi_comm_of_output_group, master_output_rank, & 229 program_debug_output_unit, debug_output ) 230 231 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: file_suffix_of_output_group !< file-name suffix added to each file; 232 !> must be unique for each output group 233 234 INTEGER, INTENT(IN), OPTIONAL :: master_output_rank !< MPI rank executing tasks which must 235 !> be executed by a single PE only 236 INTEGER, INTENT(IN) :: mpi_comm_of_output_group !< MPI communicator specifying the MPI group 237 !> which participate in the output 238 INTEGER, INTENT(IN) :: program_debug_output_unit !< file unit number for debug output 228 239 229 240 LOGICAL, INTENT(IN) :: debug_output !< if true, debug output is printed 230 241 231 242 243 IF ( PRESENT( file_suffix_of_output_group ) ) output_file_suffix = file_suffix_of_output_group 244 IF ( PRESENT( master_output_rank ) ) master_rank = master_output_rank 245 246 output_group_comm = mpi_comm_of_output_group 247 232 248 debug_output_unit = program_debug_output_unit 233 234 249 print_debug_output = debug_output 235 250 236 CALL binary_init_module( debug_output_unit, debug_output, no_var_id ) 237 238 CALL netcdf4_init_module( debug_output_unit, debug_output, no_var_id ) 251 CALL binary_init_module( output_file_suffix, output_group_comm, master_rank, & 252 debug_output_unit, debug_output, no_var_id ) 253 254 CALL netcdf4_init_module( output_file_suffix, output_group_comm, master_rank, & 255 debug_output_unit, debug_output, no_var_id ) 239 256 240 257 END SUBROUTINE dom_init -
palm/trunk/SOURCE/data_output_netcdf4_module.f90
r4106 r4107 56 56 57 57 CHARACTER(LEN=800) :: internal_error_message = '' !< string containing the last error message 58 CHARACTER(LEN=100) :: file_suffix = '' !< file suffix added to each file name 58 59 CHARACTER(LEN=800) :: temp_string !< dummy string 59 60 … … 63 64 INTEGER(iwp) :: debug_output_unit !< Fortran Unit Number of the debug-output file 64 65 INTEGER(iwp) :: global_id_in_file = -1 !< value of global ID within a file 66 INTEGER :: master_rank !< master rank for tasks to be executed by single PE only 67 INTEGER :: output_group_comm !< MPI communicator addressing all MPI ranks which participate in output 65 68 66 69 LOGICAL :: print_debug_output = .FALSE. !< if true, debug output is printed … … 126 129 !> Initialize data-output module. 127 130 !--------------------------------------------------------------------------------------------------! 128 SUBROUTINE netcdf4_init_module( program_debug_output_unit, debug_output, dom_global_id ) 131 SUBROUTINE netcdf4_init_module( file_suffix_of_output_group, mpi_comm_of_output_group, & 132 master_output_rank, & 133 program_debug_output_unit, debug_output, dom_global_id ) 134 135 CHARACTER(LEN=*), INTENT(IN) :: file_suffix_of_output_group !> file-name suffix added to each file; 136 !> must be unique for each output group 129 137 130 138 INTEGER(iwp), INTENT(IN) :: dom_global_id !< global id within a file defined by DOM 139 INTEGER, INTENT(IN) :: master_output_rank !< MPI rank executing tasks which must be executed by a single PE 140 INTEGER, INTENT(IN) :: mpi_comm_of_output_group !< MPI communicator specifying the rank group participating in output 131 141 INTEGER(iwp), INTENT(IN) :: program_debug_output_unit !< file unit number for debug output 132 142 … … 134 144 135 145 146 file_suffix = file_suffix_of_output_group 147 output_group_comm = mpi_comm_of_output_group 148 master_rank = master_output_rank 149 136 150 debug_output_unit = program_debug_output_unit 137 138 151 print_debug_output = debug_output 139 152 … … 155 168 156 169 INTEGER(iwp), INTENT(OUT) :: file_id !< file ID 170 INTEGER :: my_rank !< MPI rank of processor 157 171 INTEGER(iwp) :: nc_stat !< netcdf return value 158 172 INTEGER(iwp), INTENT(OUT) :: return_value !< return value … … 160 174 161 175 return_value = 0 176 file_id = -1 162 177 163 178 !-- Open new file … … 167 182 168 183 #if defined( __netcdf4 ) 169 nc_stat = NF90_CREATE( TRIM( filename ), & 170 IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), & 171 file_id ) 172 #else 173 file_id = -1 184 #if defined( __parallel ) 185 CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value ) 186 IF ( return_value /= 0 ) THEN 187 CALL internal_message( 'error', routine_name // ': MPI_COMM_RANK error' ) 188 ENDIF 189 IF ( my_rank /= master_rank ) THEN 190 return_value = 1 191 CALL internal_message( 'error', routine_name // & 192 ': trying to define a NetCDF file in serial mode by an MPI ' // & 193 'rank other than the master output rank. Serial NetCDF ' // & 194 'files can only be defined by the master output rank!' ) 195 ENDIF 196 #else 197 my_rank = master_rank 198 return_value = 0 199 #endif 200 201 IF ( return_value == 0 ) & 202 nc_stat = NF90_CREATE( TRIM( filename ) // TRIM( file_suffix ), & 203 IOR( NF90_NOCLOBBER, NF90_NETCDF4 ), & 204 file_id ) 205 #else 174 206 nc_stat = 0 175 207 return_value = 1 … … 182 214 183 215 #if defined( __parallel ) && defined( __netcdf4 ) && defined( __netcdf4_parallel ) 184 nc_stat = NF90_CREATE( TRIM( filename ) ,&216 nc_stat = NF90_CREATE( TRIM( filename ) // TRIM( file_suffix ), & 185 217 IOR( NF90_NOCLOBBER, IOR( NF90_NETCDF4, NF90_MPIIO ) ), & 186 file_id, COMM = MPI_COMM_WORLD, INFO = MPI_INFO_NULL ) 187 #else 188 file_id = -1 218 file_id, COMM = output_group_comm, INFO = MPI_INFO_NULL ) 219 #else 189 220 nc_stat = 0 190 221 return_value = 1 … … 196 227 197 228 ELSE 198 file_id = -1199 229 nc_stat = 0 200 230 return_value = 1 … … 205 235 206 236 #if defined( __netcdf4 ) 207 IF ( nc_stat /= NF90_NOERR ) THEN237 IF ( nc_stat /= NF90_NOERR .AND. return_value == 0 ) THEN 208 238 return_value = 1 209 239 CALL internal_message( 'error', routine_name // ': NetCDF error while opening file "' // & … … 477 507 INTEGER(iwp) :: d !< loop index 478 508 INTEGER(iwp), INTENT(IN) :: file_id !< file ID 479 INTEGER (iwp) :: myid !< id number of processor element509 INTEGER :: my_rank !< MPI rank of processor 480 510 INTEGER(iwp) :: nc_stat !< netcdf return value 481 511 INTEGER(iwp) :: ndim !< number of dimensions of variable in file … … 532 562 533 563 #if defined( __parallel ) 534 CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, return_value )564 CALL MPI_COMM_RANK( output_group_comm, my_rank, return_value ) 535 565 IF ( return_value /= 0 ) THEN 536 566 CALL internal_message( 'error', routine_name // ': MPI_COMM_RANK error' ) 537 567 ENDIF 538 568 #else 539 my id = 0569 my_rank = master_rank 540 570 return_value = 0 541 571 #endif 542 572 543 IF ( return_value == 0 .AND. ( .NOT. is_global .OR. my id == 0) ) THEN573 IF ( return_value == 0 .AND. ( .NOT. is_global .OR. my_rank == master_rank ) ) THEN 544 574 545 575 WRITE( temp_string, * ) var_id -
palm/trunk/UTIL/binary_to_netcdf.f90
r4075 r4107 82 82 83 83 84 CHARACTER(LEN=200) :: temp_string !< dummy string 85 86 CHARACTER(LEN=:), ALLOCATABLE :: filename_prefix !< prefix of names of files to be read 87 88 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_to_netcdf' !< name of routine 89 CHARACTER(LEN=*), PARAMETER :: config_file_name = 'BINARY_TO_NETCDF_CONFIG' !< name of configuration file 90 91 CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE :: filename_list !< list of netcdf file names 84 CHARACTER(LEN=charlen_internal) :: temp_string !< dummy string 85 CHARACTER(LEN=:), ALLOCATABLE :: filename_prefix !< prefix of names of files to be read 86 CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE :: group_names !< names of output groups 87 CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE :: filename_list !< list of netcdf file names 88 89 CHARACTER(LEN=*), PARAMETER :: routine_name = 'binary_to_netcdf' !< name of routine 90 CHARACTER(LEN=*), PARAMETER :: config_file_name_base = 'BINARY_TO_NETCDF_CONFIG' !< name of config file 91 CHARACTER(LEN=*), PARAMETER :: & 92 config_file_list_name = 'BINARY_CONFIG_LIST' !< file containing list of binary config files of each output group 92 93 93 94 INTEGER(iwp) :: charlen !< length of characters (strings) in binary file 94 95 INTEGER(iwp) :: dom_global_id !< global ID within a single file defined by DOM 96 INTEGER :: dom_master_rank !< master MPI rank in DOM (rank which wrote additional information in DOM) 97 INTEGER :: dom_nrank !< number of MPI ranks used by DOM 95 98 INTEGER(iwp) :: file_index !< loop index to loop over files 99 INTEGER :: group !< loop index to loop over groups 96 100 INTEGER(iwp) :: nc_file_id !< ID of netcdf output file 97 101 INTEGER(iwp) :: nfiles !< number of output files defined in config file 102 INTEGER :: ngroup !< number of output-file groups 98 103 INTEGER :: return_value !< return value 99 104 INTEGER :: your_return_value !< returned value of called routine … … 104 109 INTEGER(iwp) :: dummy_intwp !< dummy variable used for reading 105 110 106 INTEGER, PARAMETER :: bin_file_unit = 2 !< Fortran unit of binary file 107 INTEGER, PARAMETER :: config_file_unit = 1 !< Fortran unit of configuration file 111 INTEGER, PARAMETER :: bin_file_unit = 12 !< Fortran unit of binary file 112 INTEGER, PARAMETER :: config_file_unit = 11 !< Fortran unit of configuration file 113 INTEGER, PARAMETER :: config_file_list_unit = 10 !< Fortran unit of file containing config-file list 108 114 109 115 INTEGER, DIMENSION(:), ALLOCATABLE :: dim_id_netcdf !< mapped dimension id within NetCDF file: … … 126 132 return_value = 0 127 133 128 CALL internal_message( 'info', routine_name // ': Start converting binary files...' ) 129 130 CALL read_config( your_return_value ) 131 132 IF ( your_return_value == 0 ) THEN 133 DO file_index = 1, nfiles 134 135 CALL internal_message( 'info', routine_name // & 136 ': create file ' // TRIM( filename_list(file_index) ) ) 137 138 CALL read_binary_header( TRIM( filename_list(file_index) ), your_return_value ) 134 CALL internal_message( 'info', 'Start ' // routine_name // ' ...' ) 135 136 CALL get_group_names( return_value ) 137 138 IF ( return_value == 0 ) THEN 139 140 !-- Go through each group of output files (all marked by same file suffix) 141 DO group = 1, ngroup 142 143 CALL internal_message( 'info', 'Start converting ' // TRIM( group_names(group) ) // & 144 ' binary files:' ) 145 146 CALL read_config( TRIM( group_names(group) ), your_return_value ) 139 147 140 148 IF ( your_return_value == 0 ) THEN 141 CALL define_netcdf_files( TRIM( filename_list(file_index) ), your_return_value ) 149 DO file_index = 1, nfiles 150 151 CALL internal_message( 'info', 'Create file ' // TRIM( filename_list(file_index) ) ) 152 153 CALL read_binary_header( TRIM( filename_list(file_index) ), your_return_value ) 154 155 IF ( your_return_value == 0 ) THEN 156 CALL define_netcdf_files( TRIM( filename_list(file_index) ), your_return_value ) 157 ELSE 158 return_value = your_return_value 159 ENDIF 160 161 IF ( your_return_value == 0 ) THEN 162 CALL convert_data_to_netcdf( TRIM( filename_list(file_index) ), your_return_value ) 163 ELSE 164 return_value = your_return_value 165 ENDIF 166 167 ENDDO 142 168 ELSE 143 169 return_value = your_return_value 144 170 ENDIF 145 171 146 IF ( your_return_value == 0 ) THEN 147 CALL convert_data_to_netcdf( TRIM( filename_list(file_index) ), your_return_value ) 148 ELSE 149 return_value = your_return_value 150 ENDIF 172 IF ( ALLOCATED( filename_list ) ) DEALLOCATE( filename_list ) 173 IF ( ALLOCATED( filename_prefix ) ) DEALLOCATE( filename_prefix ) 151 174 152 175 ENDDO 153 ELSE 154 return_value = your_return_value 176 155 177 ENDIF 156 178 157 179 IF ( return_value == 0 ) THEN 158 CALL internal_message( 'info', routine_name // ':Execution finished' )180 CALL internal_message( 'info', 'Execution finished' ) 159 181 ELSE 160 182 CALL internal_message( 'error', routine_name // ': Error during execution! Check results!' ) … … 168 190 ! Description: 169 191 ! ------------ 192 !> Check if any configuration file is present in the current directory and get the list of all 193 !> these files and extract the output-group names. 194 !--------------------------------------------------------------------------------------------------! 195 SUBROUTINE get_group_names( return_value ) 196 197 CHARACTER(LEN=charlen_internal) :: file_name !< file name read from list 198 199 CHARACTER(LEN=*), PARAMETER :: routine_name = 'get_group_names' !< name of routine 200 201 INTEGER :: i !< loop index 202 INTEGER :: io_stat !< status of Fortran I/O operations 203 INTEGER, INTENT(OUT) :: return_value !< return value 204 205 206 CALL internal_message( 'info', 'Check if anything to convert...' ) 207 208 !-- Search for configuration files and save the list of file names in a separate file 209 CALL EXECUTE_COMMAND_LINE( & 210 COMMAND='find . -type f -name "' // config_file_name_base // '*" | ' // & 211 'sed -r "s/^\.\/(' // config_file_name_base // ')?(.+)$/\1\2/" > ' // & 212 config_file_list_name, & 213 WAIT=.TRUE., & 214 EXITSTAT=return_value ) 215 216 !-- Read the config-file-name list and extract the group names from the file names 217 IF ( return_value /= 0 ) THEN 218 219 CALL internal_message( 'error', routine_name // & 220 ': error while searching for configuration files: ' // & 221 'System returned non-zero exit status. ' // & 222 'Please report this error to the developers!' ) 223 224 ELSE 225 226 OPEN( config_file_list_unit, FILE=config_file_list_name, FORM='formatted', & 227 STATUS='OLD', IOSTAT=io_stat ) 228 229 !-- Count the configuration files 230 ngroup = 0 231 DO WHILE ( io_stat == 0 ) 232 READ( config_file_list_unit, '(A)', IOSTAT=io_stat ) file_name 233 IF ( io_stat == 0 ) ngroup = ngroup + 1 234 ENDDO 235 REWIND( config_file_list_unit ) 236 237 IF ( ngroup /= 0 ) THEN 238 239 ALLOCATE( group_names(ngroup) ) 240 241 !-- Extract the group names 242 DO i = 1, ngroup 243 READ( config_file_list_unit, '(A)', IOSTAT=io_stat ) file_name 244 IF ( INDEX( TRIM( file_name ), config_file_name_base ) == 1 ) THEN 245 IF ( TRIM( file_name ) == TRIM( config_file_name_base ) ) THEN 246 group_names(i) = '' 247 ELSE 248 group_names(i) = file_name(LEN_TRIM( config_file_name_base )+1:) 249 ENDIF 250 ELSE 251 return_value = 1 252 CALL internal_message( 'error', routine_name // & 253 ': error while getting list of binary config files: ' // & 254 'Unexpected text found in file list. ' // & 255 'Please report this error to the developers!' ) 256 EXIT 257 ENDIF 258 ENDDO 259 260 ELSE 261 CALL internal_message( 'info', 'No configuration files found. ' // & 262 'No binary files to convert to NetCDF.' ) 263 ENDIF 264 265 CLOSE( config_file_list_unit ) 266 267 ENDIF 268 269 END SUBROUTINE get_group_names 270 271 !--------------------------------------------------------------------------------------------------! 272 ! Description: 273 ! ------------ 170 274 !> Read configuration file. 171 275 !--------------------------------------------------------------------------------------------------! 172 SUBROUTINE read_config( return_value )276 SUBROUTINE read_config( group_name, return_value ) 173 277 174 278 CHARACTER(LEN=:), ALLOCATABLE :: read_string !< string read from file 279 CHARACTER(LEN=*), INTENT(IN) :: group_name !< group name 175 280 CHARACTER(LEN=*), PARAMETER :: routine_name = 'read_config' !< name of routine 281 282 CHARACTER(LEN=charlen_internal) :: config_file_name !< config file name with additional suffix 176 283 177 284 CHARACTER(LEN=charlen_internal), DIMENSION(:), ALLOCATABLE :: filename_list_tmp !< temporary list of file names … … 183 290 184 291 return_value = 0 292 293 config_file_name = config_file_name_base // group_name 185 294 186 295 OPEN( config_file_unit, FILE=config_file_name, FORM='unformatted', & … … 196 305 IF ( return_value == 0 ) THEN 197 306 307 READ( config_file_unit ) dom_nrank 308 309 IF ( dom_nrank > 1000000 ) THEN 310 dom_nrank = 1000000 311 CALL internal_message( 'info', routine_name // & 312 ': number of MPI ranks used in PALM is greater than the maximum ' // & 313 'amount I can handle. I will only consider the first 1000000 output files.' ) 314 ENDIF 315 316 READ( config_file_unit ) dom_master_rank 198 317 READ( config_file_unit ) filename_prefix_length 199 318 … … 201 320 202 321 READ( config_file_unit ) filename_prefix 203 204 322 READ( config_file_unit ) charlen 205 206 323 READ( config_file_unit ) dom_global_id 207 324 … … 233 350 ENDIF 234 351 235 filename_list(nfiles) = TRIM( read_string ) 352 filename_list(nfiles) = TRIM( read_string ) // group_name 236 353 237 354 ENDIF … … 280 397 return_value = 0 281 398 282 !-- Open binary file of PE0 283 bin_filename = TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_000000' 399 !-- Open binary file written by dom_master_rank 400 WRITE( bin_filename , '(A,I6.6)' ) & 401 TRIM( filename_prefix ) // TRIM( bin_filename_body ) // '_', dom_master_rank 284 402 285 403 CALL internal_message( 'debug', routine_name // ': read file ' // TRIM( bin_filename ) ) … … 426 544 ENDDO ! iterate over file header 427 545 546 CLOSE( bin_file_unit ) 547 428 548 END SUBROUTINE read_binary_header 429 549 … … 679 799 680 800 !-- Open binary files of every possible PE 681 DO pe_id = 0, 999999801 DO pe_id = 0, dom_nrank - 1 682 802 683 803 WRITE( bin_filename, '(A, I6.6)' ) & … … 689 809 IF ( file_exists ) THEN 690 810 691 !-- Open file and skip header (file of PE0 is already opened) 692 IF ( pe_id /= 0 ) THEN 693 694 OPEN( bin_file_unit, FILE=bin_filename, FORM='UNFORMATTED', STATUS='OLD' ) 695 696 CALL internal_message( 'debug', routine_name // & 697 ': read binary file ' // TRIM( bin_filename ) ) 698 699 read_string = '' 700 DO WHILE ( TRIM( read_string ) /= '*** end file header ***' ) 701 702 READ( bin_file_unit ) read_string 703 704 SELECT CASE ( TRIM( read_string ) ) 705 706 CASE ( 'char' ) 707 READ( bin_file_unit ) read_string 708 709 CASE ( 'int8' ) 710 READ( bin_file_unit ) dummy_int8 711 712 CASE ( 'int16' ) 713 READ( bin_file_unit ) dummy_int16 714 715 CASE ( 'int32' ) 716 READ( bin_file_unit ) dummy_int32 717 718 CASE ( 'real32' ) 719 READ( bin_file_unit ) dummy_real32 720 721 CASE ( 'real64' ) 722 READ( bin_file_unit ) dummy_real64 723 724 END SELECT 725 726 ENDDO 727 728 ENDIF 811 OPEN( bin_file_unit, FILE=bin_filename, FORM='UNFORMATTED', STATUS='OLD' ) 812 813 CALL internal_message( 'debug', routine_name // & 814 ': read binary file ' // TRIM( bin_filename ) ) 815 816 read_string = '' 817 DO WHILE ( TRIM( read_string ) /= '*** end file header ***' ) 818 819 READ( bin_file_unit ) read_string 820 821 SELECT CASE ( TRIM( read_string ) ) 822 823 CASE ( 'char' ) 824 READ( bin_file_unit ) read_string 825 826 CASE ( 'int8' ) 827 READ( bin_file_unit ) dummy_int8 828 829 CASE ( 'int16' ) 830 READ( bin_file_unit ) dummy_int16 831 832 CASE ( 'int32' ) 833 READ( bin_file_unit ) dummy_int32 834 835 CASE ( 'real32' ) 836 READ( bin_file_unit ) dummy_real32 837 838 CASE ( 'real64' ) 839 READ( bin_file_unit ) dummy_real64 840 841 END SELECT 842 843 ENDDO 729 844 730 845 !-- Read variable data … … 873 988 CLOSE( bin_file_unit ) 874 989 875 ELSE876 877 EXIT878 879 990 ENDIF ! if file exists 880 991
Note: See TracChangeset
for help on using the changeset viewer.