Changeset 4107 for palm/trunk/SOURCE/data_output_binary_module.f90
- Timestamp:
- Jul 22, 2019 8:51:35 AM (5 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.