LST_global_write_collision_prob.F90 18.3 KB
Newer Older
Femi Kadri's avatar
Femi Kadri committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
SUBROUTINE LST_global_write_collision_prob(LST_local_fluid_surf_rxn_count,&
& My_MPI_Process_ID,ROOT,local_x_min_ghost,local_x_max_ghost,local_y_min_ghost,&
& local_y_max_ghost,local_z_min_ghost,local_z_max_ghost,&
& local_x_min_real,local_x_max_real,local_y_min_real,&
& local_y_max_real,local_z_min_real,local_z_max_real,&
& local_product_xyz_nodes_real,all_processes_local_bounds,&
& global_x_nodes_real,global_y_nodes_real,global_z_nodes_real,&
& Number_Of_Processes,cartesian_communicator,&
& tot_num_markers_plus_nonbrownian,LST_Time_Steps_Prev_Completed,&
& lattice_dimension)


!NUMBER COLLISIONS AT EACH SURFACE NODE DIVIDED BY TOTAL NUMBER OF COLLISIONS OVERALL


USE debug_module
USE precision_detector

	!THIS SUBROUTINE WILL GATHER A 3D ARRAY IN ALL THREE DIMENSIONS FROM ALL THE MPI PROCESSES TO ROOT, WHO IN TURN WILL WRITE THEM TO A FILE IN ORDER RECEIVED
	IMPLICIT NONE
	INCLUDE "mpif.h"

	!-----------INTENT(IN)------------------------------------------		
	INTEGER,INTENT(IN) :: My_MPI_Process_ID,ROOT,Number_Of_Processes,cartesian_communicator
	INTEGER,INTENT(IN) :: local_x_min_ghost,local_x_max_ghost
	INTEGER,INTENT(IN) :: local_y_min_ghost,local_y_max_ghost
	INTEGER,INTENT(IN) :: local_z_min_ghost,local_z_max_ghost
	INTEGER,INTENT(IN) :: local_x_min_real,local_x_max_real
	INTEGER,INTENT(IN) :: local_y_min_real,local_y_max_real
	INTEGER,INTENT(IN) :: local_z_min_real,local_z_max_real
	INTEGER,INTENT(IN) :: local_product_xyz_nodes_real,lattice_dimension
	INTEGER,INTENT(IN) :: tot_num_markers_plus_nonbrownian,LST_Time_Steps_Prev_Completed
	INTEGER,INTENT(IN) :: global_x_nodes_real,global_y_nodes_real,global_z_nodes_real
	INTEGER,INTENT(IN),DIMENSION(6 * Number_Of_Processes) :: all_processes_local_bounds
	INTEGER,INTENT(IN),DIMENSION(local_x_min_ghost:local_x_max_ghost,local_y_min_ghost:local_y_max_ghost,&
	& local_z_min_ghost:local_z_max_ghost) :: LST_local_fluid_surf_rxn_count
	LOGICAL*4,PARAMETER :: debug = GLOBAL_DEBUG
	!LOGICAL*4,PARAMETER :: debug = .true.
	!-----------INTENT(INOUT)------------------------------------------
	!-----------INTENT(OUT)------------------------------------------
	!-----------NO INTENT------------------------------------------
	INTEGER :: I,J,K
	INTEGER :: mpi_abort_error
	INTEGER :: index,SOURCE,mpi_error_code,send_size_integer
	INTEGER :: MPI_Process_Number,counter,send_size_surf_collision_count
	INTEGER :: destination

	INTEGER,PARAMETER :: tag_integer_communication = 6789
	INTEGER,PARAMETER :: surf_collision_count_comm_tag = 9876
	INTEGER :: local_fluid_surf_collisions_sum,global_fluid_surf_collisions_sum
	INTEGER,DIMENSION(0:Number_Of_Processes-1) :: root_receive_counts_integer,root_receive_counts_array
	INTEGER,ALLOCATABLE,DIMENSION(:) :: local_integer_send_buffer,local_integer_recv_buffer
	REAL :: Inv_total_fluid_surf_collisions
	REAL :: maximum_possible_collisions_num
	INTEGER,ALLOCATABLE,DIMENSION(:) :: local_collision_count_send_bufr,local_collision_count_recv_bufr		
	
	INTEGER :: status (MPI_STATUS_SIZE)

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'entered SUBROUTINE LST_global_write_collision_prob'

	!my_mpi_real_data_type = get_my_mpi_real_data_type ()  !FUNNEL OUT THE RESULT OF PRECISION TESTING (this automatically sets the MPI REAL DATA PRECISION TYPE)


	local_fluid_surf_collisions_sum = &
	& SUM(LST_local_fluid_surf_rxn_count(local_x_min_real:local_x_max_real,local_y_min_real:local_y_max_real,&
	& local_z_min_real:local_z_max_real))
	
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_global_write_collision_prob: local_fluid_surf_collisions_sum = ',local_fluid_surf_collisions_sum
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_global_write_collision_prob: local_fluid_surf_collisions_sum = ',local_fluid_surf_collisions_sum

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_global_write_collision_prob: about to CALL MPI_Allreduce:local_fluid_surf_collisions_sum'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_global_write_collision_prob: about to CALL MPI_Allreduce:local_fluid_surf_collisions_sum'

	CALL MPI_Allreduce(local_fluid_surf_collisions_sum,global_fluid_surf_collisions_sum,1,&
	& MPI_INTEGER,MPI_SUM,cartesian_communicator,mpi_error_code)
			
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_global_write_collision_prob: finished to CALL MPI_Allreduce:local_fluid_surf_collisions_sum'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_global_write_collision_prob: finished to CALL MPI_Allreduce:local_fluid_surf_collisions_sum'

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_global_write_collision_prob: global_fluid_surf_collisions_sum = ',global_fluid_surf_collisions_sum
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_global_write_collision_prob: global_fluid_surf_collisions_sum = ',global_fluid_surf_collisions_sum

	IF (My_MPI_Process_ID.EQ.ROOT) THEN 
	
		PRINT*,'global_fluid_surf_collisions_sum = ',global_fluid_surf_collisions_sum

	ENDIF !!My_MPI_Process_ID.EQ.ROOT

	IF(global_fluid_surf_collisions_sum.LE.0) THEN

		IF (My_MPI_Process_ID.EQ.ROOT) THEN 
		
			PRINT*,'ERROR:  LST_global_write_collision_prob: global_fluid_surf_collisions_sum.LE.0',global_fluid_surf_collisions_sum
		
		ENDIF !!My_MPI_Process_ID

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_global_write_collision_prob: ERROR: global_fluid_surf_collisions_sum.LE.0',global_fluid_surf_collisions_sum
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_global_write_collision_prob: ERROR: global_fluid_surf_collisions_sum.LE.0',global_fluid_surf_collisions_sum
		IF(debug) WRITE (29,*) My_MPI_Process_ID,'LST_global_write_collision_prob: ERROR: global_fluid_surf_collisions_sum.LE.0',global_fluid_surf_collisions_sum
		CALL MPI_Abort(cartesian_communicator,mpi_abort_error,mpi_error_code)

	ELSE

		Inv_total_fluid_surf_collisions = 1.0D0 / global_fluid_surf_collisions_sum

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_global_write_collision_prob: Inv_total_fluid_surf_collisions = ',Inv_total_fluid_surf_collisions
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_global_write_collision_prob: Inv_total_fluid_surf_collisions = ',Inv_total_fluid_surf_collisions


	ENDIF !LST_local_fluid_surf_rxn_count(I,J,K).GT.0


	maximum_possible_collisions_num = tot_num_markers_plus_nonbrownian * LST_Time_Steps_Prev_Completed

	IF( global_fluid_surf_collisions_sum.GT.maximum_possible_collisions_num) THEN
		!SHOULD NOT BE MORE COLLISIONS THAN TOTAL NUMBER OF PARTICLES X LST STEPS

		IF (My_MPI_Process_ID.EQ.ROOT) THEN 

			PRINT*,'ROOT ERROR:  LST_global_write_collision_prob: global_fluid_surf_collisions_sum.GT.maximum_possible_collisions_num!'
			PRINT*,'ROOT ERROR: LST_global_write_collision_prob: global_fluid_surf_collisions_sum',global_fluid_surf_collisions_sum
			PRINT*,'ROOT ERROR: LST_global_write_collision_prob: maximum_possible_collisions_num',maximum_possible_collisions_num
			PRINT*,'ROOT ERROR: LST_global_write_collision_prob: tot_num_markers_plus_nonbrownian',tot_num_markers_plus_nonbrownian
			PRINT*,'ROOT ERROR: LST_global_write_collision_prob: LST_Time_Steps_Prev_Completed',LST_Time_Steps_Prev_Completed
			PRINT*,'ROOT ERROR: LST_global_write_collision_prob: tot_num_markers_plus_nonbrownian * LST_Time_Steps_Prev_Completed',REAL(tot_num_markers_plus_nonbrownian * LST_Time_Steps_Prev_Completed)
	
		ENDIF !!My_MPI_Process_ID.EQ.ROOT
	
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: ROOT ERROR:  LST_global_write_collision_prob: global_fluid_surf_collisions_sum.GT.maximum_possible_collisions_num!'
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: LST_global_write_collision_prob: global_fluid_surf_collisions_sum',global_fluid_surf_collisions_sum
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: LST_global_write_collision_prob: maximum_possible_collisions_num',maximum_possible_collisions_num

		IF(debug) WRITE (9,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: ROOT ERROR:  LST_global_write_collision_prob: global_fluid_surf_collisions_sum.GT.maximum_possible_collisions_num!'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: LST_global_write_collision_prob: global_fluid_surf_collisions_sum',global_fluid_surf_collisions_sum
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: LST_global_write_collision_prob: maximum_possible_collisions_num',maximum_possible_collisions_num

		IF(debug) WRITE (29,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: ROOT ERROR:  LST_global_write_collision_prob: global_fluid_surf_collisions_sum.GT.maximum_possible_collisions_num!'
		IF(debug) WRITE (29,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: LST_global_write_collision_prob: global_fluid_surf_collisions_sum',global_fluid_surf_collisions_sum
		IF(debug) WRITE (29,*) My_MPI_Process_ID,'ERROR: LST_global_write_collision_prob: LST_global_write_collision_prob: maximum_possible_collisions_num',maximum_possible_collisions_num

!		CALL MPI_Abort(cartesian_communicator,mpi_abort_error,mpi_error_code)


	ENDIF !global_fluid_surf_collisions_sum.GT.(tot_num_markers_plus_nonbrownian*LST_Time_Steps_Prev_Completed)


	!ROOT OPENS THE FILE
	IF (My_MPI_Process_ID.EQ.ROOT) THEN 

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to write array values from ROOT'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to write array values from ROOT'
			
		OPEN (84, FILE = 'results_LST/LST_global_fluid_surf_collision_probability.txt', STATUS = 'unknown', FORM='formatted')  
		WRITE(84,*) 'VARIABLES = "X [cm]", "Y [cm]", "Z [cm]", "PROBABILITY [ ]"'
		WRITE(84,*) 'ZONE,i=',global_x_nodes_real,',j=',global_y_nodes_real,',k=',global_z_nodes_real,',F=POINT'

		!ROOT WRITES ITS OWN VALUES
			
		DO K = local_z_min_real,local_z_max_real	

			DO J = local_y_min_real,local_y_max_real

				DO I = local_x_min_real,local_x_max_real

					WRITE(84,'(3I6.5,E19.10)') I,J,K,&
					& REAL(LST_local_fluid_surf_rxn_count(I,J,K)) * Inv_total_fluid_surf_collisions

				END DO !I

			END DO	!J

		END DO !K 

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'finished writing array values from ROOT'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'finished writing array values from ROOT'
	
	ENDIF !! My_MPI_Process_ID.EQ.ROOT

	
	!COMMUNICATE DATA TO ROOT FROM ALL NON-ROOT PROCESSES(PACK IT INTO BUFFERS FIRST) AND THEN HAVE ROOT WRITE IT TO A FILE
	IF (My_MPI_Process_ID.NE.ROOT) THEN  !MAKE ALL THE NON-ROOT PROCESSES SEND THEIR BUFFERS TO ROOT
	
		send_size_integer = local_product_xyz_nodes_real*lattice_dimension		
		send_size_surf_collision_count = local_product_xyz_nodes_real
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'send_size_integer',send_size_integer,'send_size_surf_collision_count',send_size_surf_collision_count
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'send_size_integer',send_size_integer,'send_size_surf_collision_count',send_size_surf_collision_count
		ALLOCATE( local_integer_send_buffer(send_size_integer) )	
		ALLOCATE ( local_collision_count_send_bufr(send_size_surf_collision_count) )

		index = 1		
		counter = 1

		DO K = local_z_min_real,local_z_max_real	!PACK THE DATA IN THE SEND BUFFERS

			DO J = local_y_min_real,local_y_max_real

				DO I = local_x_min_real,local_x_max_real

					!STORE COORDINATES
					local_integer_send_buffer(index) = I 
					local_integer_send_buffer(index + 1) = J
					local_integer_send_buffer(index + 2) = K
			
					!STORE VELOCITIES
					local_collision_count_send_bufr(counter) = LST_local_fluid_surf_rxn_count(I,J,K)
					
					counter = counter + 1
					index = index + lattice_dimension

				END DO !I

			END DO	!J

		END DO !K

		destination = ROOT !SEND BUFFERS TO DESTINATION

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to send LST_global_write_collision_prob integer array'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to send LST_global_write_collision_prob integer array'
		CALL MPI_Send(local_integer_send_buffer,send_size_integer,MPI_INTEGER,destination,&
		& tag_integer_communication,cartesian_communicator,mpi_error_code)
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'finished sending LST_global_write_collision_prob integer array'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'finished sending LST_global_write_collision_prob integer array'

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to send LST_global_write_collision_prob local_collision_count_send_bufr array'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to send LST_global_write_collision_prob rlocal_collision_count_send_bufr array'
		CALL MPI_Send(local_collision_count_send_bufr,send_size_surf_collision_count,MPI_INTEGER,&
		& destination,surf_collision_count_comm_tag,cartesian_communicator,mpi_error_code)
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'finished sending LST_global_write_collision_prob local_collision_count_send_bufr array'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'finished sending LST_global_write_collision_prob local_collision_count_send_bufr array'

		DEALLOCATE( local_integer_send_buffer )	
		DEALLOCATE ( local_collision_count_send_bufr )

	ELSE  !!My_MPI_Process_ID.EQ.ROOT (SO THIS HAPPENS ONLY ON THE ROOT PROCESS)
		
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'Number_Of_Processes - 1',Number_Of_Processes - 1
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'Number_Of_Processes - 1',Number_Of_Processes - 1
		DO MPI_Process_Number = 0, Number_Of_Processes - 1  !CYCLE OVER ALL PROCESSES ON THE ROOT PROCESS
		
			IF(debug) WRITE (0,*) My_MPI_Process_ID,'ROOT',ROOT,'Cycling over MPI_Process_Number',MPI_Process_Number,'of',Number_Of_Processes - 1,'processes'
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'ROOT',ROOT,'Cycling over MPI_Process_Number',MPI_Process_Number,'of',Number_Of_Processes - 1,'processes'
			IF(MPI_Process_Number.NE.ROOT) THEN !THIS IS TO ACCOUNT FOR THE CASE IF ROOT IS NOT ZERO, WE COULD HAVE JUST STARTED THE LOOP AT 1 INSTEAD
				
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'THIS SHOULD BE ROOT CYCLING OVER NONROOT MPI_Process_Number',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'THIS SHOULD BE ROOT CYCLING OVER NONROOT MPI_Process_Number',MPI_Process_Number
				
				SOURCE = MPI_Process_Number !ASSIGN CURRENT PROCESS AS "SOURCE" FROM WHICH INFORMATION IS RECEIVED
				
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'ROOT is preparing to recv from SOURCE',SOURCE
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'ROOT is preparing to recv from SOURCE',SOURCE

				root_receive_counts_array(MPI_Process_Number) = ( all_processes_local_bounds(2 + MPI_Process_Number * 6) - all_processes_local_bounds(1 + MPI_Process_Number * 6) + 1 ) * &
				& ( all_processes_local_bounds(4 + MPI_Process_Number * 6) - all_processes_local_bounds(3 + MPI_Process_Number * 6) + 1 ) * &
				& ( all_processes_local_bounds(6 + MPI_Process_Number * 6) - all_processes_local_bounds(5 + MPI_Process_Number * 6) + 1 )
			
				root_receive_counts_integer(MPI_Process_Number) = lattice_dimension * root_receive_counts_array(MPI_Process_Number)
			
				IF(debug) WRITE (0,*),'SOURCE',SOURCE,'root_receive_counts_array',root_receive_counts_array(MPI_Process_Number),'root_receive_counts_integer',root_receive_counts_integer(MPI_Process_Number)
				IF(debug) WRITE (9,*),'SOURCE',SOURCE,'root_receive_counts_array',root_receive_counts_array(MPI_Process_Number),'root_receive_counts_integer',root_receive_counts_integer(MPI_Process_Number)
				ALLOCATE( local_integer_recv_buffer(root_receive_counts_integer(MPI_Process_Number)) )	
				ALLOCATE ( local_collision_count_recv_bufr(root_receive_counts_array(MPI_Process_Number)) )	
				
!				local_integer_recv_buffer(:)=0
!				local_collision_count_recv_bufr(:)=0

				!ROOT RECEIVES FROM ALL THE NON-ROOT PROCESSES THEIR BUFFERS
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to recv LST_global_write_collision_prob integer array'
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to recv LST_global_write_collision_prob integer array'
				CALL MPI_Recv( local_integer_recv_buffer,root_receive_counts_integer(MPI_Process_Number),&
				& MPI_INTEGER,SOURCE,tag_integer_communication, cartesian_communicator,status,mpi_error_code)
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'finished recv LST_global_write_collision_prob integer array'
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'finished recv LST_global_write_collision_prob integer array'
			
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to recv LST_global_write_collision_prob local_collision_count_recv_bufr array'
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to recv LST_global_write_collision_prob local_collision_count_recv_bufr array'
				CALL MPI_Recv( local_collision_count_recv_bufr,root_receive_counts_array(MPI_Process_Number),&
				& MPI_INTEGER,SOURCE,surf_collision_count_comm_tag, cartesian_communicator,status,mpi_error_code )
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'finished recv LST_global_write_collision_prob local_collision_count_recv_bufr array'
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'finished recv LST_global_write_collision_prob local_collision_count_recv_bufr array'
			
				!ROOT WRITES DATA RECIEVED FROM NON-ROOT PROCESSES TO A FILE
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to write 3D_array from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to write 3D_array from process',MPI_Process_Number

				COUNTER = 1

				DO index = 1,root_receive_counts_integer(MPI_Process_Number),lattice_dimension

					WRITE(84,'(3I6.5,E19.10)') &
					& local_integer_recv_buffer(index),&
					& local_integer_recv_buffer(index + 1),&
					& local_integer_recv_buffer(index + 2),&
					& REAL(local_collision_count_recv_bufr(COUNTER)) * Inv_total_fluid_surf_collisions

					COUNTER = COUNTER + 1
	
				END DO !index
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'finished writing 3D_array from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'finished writing 3D_array from process',MPI_Process_Number
			
				DEALLOCATE( local_integer_recv_buffer )	
				DEALLOCATE ( local_collision_count_recv_bufr )
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'deallocated 3D_array buffers from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'deallocated 3D_array buffers from process',MPI_Process_Number
	
			ENDIF !!MPI_Process_Number.NE.ROOT
		
		END DO !!MPI_Process_Number

	ENDIF !!My_MPI_Process_ID IS ROOT OR NON-ROOT

	!ROOT CLOSES THE FILE
	IF (My_MPI_Process_ID.EQ.ROOT) CLOSE (84)

IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to call barrier in SUBROUTINE LST_global_write_collision_prob'
CALL MPI_Barrier(cartesian_communicator,mpi_error_code)

RETURN
END SUBROUTINE LST_global_write_collision_prob