LST_uniform_marker_release.F90 60.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 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
SUBROUTINE LST_uniform_marker_release(My_MPI_Process_ID,total_number_of_LST_markers,Number_Of_Processes,&
& lattice_dimension,ROOT,cartesian_communicator,&
& divide_x,divide_y,divide_z,local_x_min_ghost,local_x_max_ghost,&
& local_y_min_ghost,local_y_max_ghost,local_z_min_ghost,local_z_max_ghost,&
& global_x_min_real,global_x_max_real,global_y_min_real,global_y_max_real,&
& global_z_min_real,global_z_max_real,global_x_min_ghost,global_x_max_ghost,&
& global_y_min_ghost,global_y_max_ghost,global_z_min_ghost,global_z_max_ghost,&
& local_x_min_real_minus_half,local_y_min_real_minus_half,&
& local_z_min_real_minus_half,local_x_max_real_plus_half,&
& local_y_max_real_plus_half,local_z_max_real_plus_half,&
& local_x_min_real,local_x_max_real,&
& local_y_min_real,local_y_max_real,&
& local_z_min_real,local_z_max_real,&
& global_product_xyz_nodes_real,&
& IN,OUT,WEST,EAST,UP,DOWN,&
& local_x_nodes_real,local_y_nodes_real,local_z_nodes_real,&
& local_x_nodes_ghost,local_y_nodes_ghost,local_z_nodes_ghost,&
& global_x_nodes_real,global_y_nodes_real,global_z_nodes_real,&
& global_x_nodes_ghost,global_y_nodes_ghost,global_z_nodes_ghost,&
& LST_apply_volume_user_mask,&
& My_MPI_Process_ID_Digits,LST_local_walls, &
& Print_Results_MPI_ID,my_mpi_real_data_type,&
& global_marker_ID_recieve_buffer,global_position_recieve_buffer,&
& LST_local_possible_release_sites )

!THIS SUBROUTINE GENERATES RANDOM POSITIONS WITHIN THE SIMULATION GEOMETRY
!BY PRODUCING COORDINATES FROM A UNIFORM DISTRIBUTION
!ALL MPI PROCESSES TRY TO INSERT THE LST MARKERS INTO NONWALL SPACES
!2DO:  I NEED TO ACCOUNT FOR THE CASE WHERE ONLY SOLID NODES BELONG TO A MPI PROCESS
!(THIS WOULD CAUSE AN INFINITE LOOP!)

!THE SUBROUTINE IMPOSES TWO SIMPLE CHECKS WHEN PICKING INSERTION SITES AFTER THE RANDOM CANDIDATE INSERTION COORDINATES HAVE BEEN GENERATED
!1) NONE OF THE CLOSEST NEIGHBOR NODES CAN BE A WALL
!2) AT LEAST ONE OF THE NEIGHBORING NODES MUST BE A LST_local_possible_release_sites



USE random_number_generator
USE debug_module
!USE precision_detector

	IMPLICIT NONE

	INCLUDE "mpif.h"

	!-----------INTENT(IN)------------------------------------------
	INTEGER,INTENT(IN) :: My_MPI_Process_ID,total_number_of_LST_markers
	INTEGER,INTENT(IN) :: Number_Of_Processes,lattice_dimension
	INTEGER,INTENT(IN) :: ROOT,cartesian_communicator,My_MPI_Process_ID_Digits
	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_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) :: global_x_min_real,global_x_max_real
	INTEGER,INTENT(IN) :: global_y_min_real,global_y_max_real
	INTEGER,INTENT(IN) :: global_z_min_real,global_z_max_real
	INTEGER,INTENT(IN) :: global_x_min_ghost,global_x_max_ghost
	INTEGER,INTENT(IN) :: global_y_min_ghost,global_y_max_ghost
	INTEGER,INTENT(IN) :: global_z_min_ghost,global_z_max_ghost

	INTEGER,INTENT(IN) :: local_x_nodes_real,local_y_nodes_real,local_z_nodes_real
	INTEGER,INTENT(IN) :: local_x_nodes_ghost,local_y_nodes_ghost,local_z_nodes_ghost

	INTEGER,INTENT(IN) :: IN,OUT,WEST,EAST,UP,DOWN

	INTEGER,INTENT(IN) :: global_product_xyz_nodes_real

	INTEGER,INTENT(IN) :: my_mpi_real_data_type 

	INTEGER,INTENT(IN) :: global_x_nodes_real,global_y_nodes_real,global_z_nodes_real
	INTEGER,INTENT(IN) :: global_x_nodes_ghost,global_y_nodes_ghost,global_z_nodes_ghost
	
	REAL,INTENT(IN) :: local_x_min_real_minus_half,local_x_max_real_plus_half
	REAL,INTENT(IN) :: local_y_min_real_minus_half,local_y_max_real_plus_half
	REAL,INTENT(IN) :: local_z_min_real_minus_half,local_z_max_real_plus_half

	LOGICAL,INTENT(IN) :: divide_x,divide_y,divide_z
	LOGICAL,INTENT(IN) :: LST_apply_volume_user_mask
	
	LOGICAL*4,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_walls


	LOGICAL*4,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_possible_release_sites
	
	

	LOGICAL*4,PARAMETER :: debug = GLOBAL_DEBUG
	!LOGICAL*4,PARAMETER :: debug = .true.
	!-----------INTENT(OUT)------------------------------------------

!	INTEGER,INTENT(OUT) :: local_number_of_LST_markers
!	INTEGER,DIMENSION(0:2 * Number_Of_Processes-1) :: all_local_LST_marker_ID_bounds
!	INTEGER,INTENT(OUT) :: global_marker_ID_recieve_buffer(total_number_of_LST_markers)
	!-----------INTENT(INOUT)------------------------------------------
	INTEGER,INTENT(INOUT) :: global_marker_ID_recieve_buffer(total_number_of_LST_markers)
	
	REAL,INTENT(INOUT) :: global_position_recieve_buffer(lattice_dimension * total_number_of_LST_markers)

	!-----------NO INTENT------------------------------------------

	INTEGER,PARAMETER :: local_LST_marker_bds_send_count = 2
	INTEGER,PARAMETER :: ROOT_LST_marker_bds_recv_count = 2
	INTEGER,PARAMETER :: real_send_recv_tag = 9696
	INTEGER,PARAMETER :: integer_send_recv_tag = 6969

	INTEGER,PARAMETER :: x = 1
	INTEGER,PARAMETER :: y = 2
	INTEGER,PARAMETER :: z = 3

	INTEGER,PARAMETER :: num_of_LST_markers_send_count = 1
	INTEGER :: local_number_of_LST_markers,global_number_of_LST_markers
!	INTEGER :: LST_marker_loop_counter,LST_marker_loop_index
	INTEGER :: root_global_position_bcast_size
	INTEGER :: status (MPI_STATUS_SIZE)
!	INTEGER :: idate(8)
!    INTEGER :: i,iseed
	INTEGER :: memory_status,mpi_abort_error_code
	INTEGER :: mpi_abort_error
	INTEGER,PARAMETER :: memory_success = 0

	INTEGER :: remote_numbr_of_LST_markers_max,remote_numbr_of_LST_markers_min
	INTEGER :: position_start_buffer_location

	INTEGER :: send_size_integer_buffer,recv_size_integer_buffer
	INTEGER :: send_size_real_buffer,recv_size_real_buffer

	INTEGER,DIMENSION(0:2 * Number_Of_Processes-1) :: all_local_LST_marker_ID_bounds
	INTEGER :: local_number_of_LST_markers_min,local_number_of_LST_markers_max

	INTEGER :: successful_init_position_count

	INTEGER :: LST_marker_loop_counter,LST_marker_loop_index
	INTEGER :: temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10,temp11,temp12,temp13
	INTEGER :: vertex000_x,vertex100_x,vertex010_x,vertex001_x,vertex101_x,vertex011_x,vertex110_x,vertex111_x
	INTEGER :: vertex000_y,vertex100_y,vertex010_y,vertex001_y,vertex101_y,vertex011_y,vertex110_y,vertex111_y
	INTEGER :: vertex000_z,vertex100_z,vertex010_z,vertex001_z,vertex101_z,vertex011_z,vertex110_z,vertex111_z
	INTEGER :: mpi_error_code,mpi_send_destination,SOURCE,mpi_process_number
!	INTEGER :: global_number_of_LST_markers

!	LOGICAL :: LST_particle_in_volume_user_mask
	LOGICAL :: LST_particle_position_obeys_mask
	LOGICAL :: LST_particle_NOT_placed_in_wall

	INTEGER,DIMENSION(2) :: send_buffer_local_bounds

	INTEGER,DIMENSION(:),ALLOCATABLE :: local_marker_ID_send_buffer !,global_marker_ID_recieve_buffer
	INTEGER,DIMENSION(:),ALLOCATABLE :: local_marker_ID_recv_buffer

	REAL :: local_2_global_insert_site_ratio
	REAL :: rand_LST_marker_old_position_x,rand_LST_marker_old_position_y,rand_LST_marker_old_position_z
	REAL :: local_x_real_domain_length,local_y_real_domain_length,local_z_real_domain_length
	REAL,DIMENSION(:),ALLOCATABLE :: local_position_send_buffer !,global_position_recieve_buffer
	REAL,DIMENSION(:),ALLOCATABLE :: local_position_recv_buffer

	LOGICAL*4,DIMENSION(:,:,:),ALLOCATABLE :: LST_local_vol_of_int_user_mask



	CHARACTER(LEN = My_MPI_Process_ID_Digits) Print_Results_MPI_ID

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

	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_x_min_ghost',local_x_min_ghost
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_x_max_ghost',local_x_max_ghost
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_y_min_ghost',local_y_min_ghost
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_y_max_ghost',local_y_max_ghost
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_z_min_ghost',local_z_min_ghost
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_z_max_ghost',local_z_max_ghost

	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_x_min_real',local_x_min_real
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_x_max_real',local_x_max_real
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_y_min_real',local_y_min_real
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_y_max_real',local_y_max_real
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_z_min_real',local_z_min_real
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_z_max_real',local_z_max_real


	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_x_max_real_plus_half',local_x_max_real_plus_half
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_x_max_real_plus_half',local_x_max_real_plus_half
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_y_max_real_plus_half',local_y_max_real_plus_half
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_y_max_real_plus_half',local_y_max_real_plus_half
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_z_max_real_plus_half',local_z_max_real_plus_half
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_z_max_real_plus_half',local_z_max_real_plus_half


	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_x_min_real_minus_half',local_x_min_real_minus_half
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_x_min_real_minus_half',local_x_min_real_minus_half
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_y_min_real_minus_half',local_y_min_real_minus_half
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_y_min_real_minus_half',local_y_min_real_minus_half
	IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_z_min_real_minus_half',local_z_min_real_minus_half
	IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_z_min_real_minus_half',local_z_min_real_minus_half


	IF(LST_apply_volume_user_mask) THEN

		ALLOCATE ( LST_local_vol_of_int_user_mask(local_x_min_ghost:local_x_max_ghost,&
		& local_y_min_ghost:local_y_max_ghost,&
		& local_z_min_ghost:local_z_max_ghost),STAT=memory_status )

		IF (memory_status /= memory_success) THEN
	
			WRITE (0,*) My_MPI_Process_ID, &
			&     "LST_uniform_marker_release ERROR: can't allocate LST_local_vol_of_int_user_mask of dimensions ", &
			&     local_x_min_ghost, ":", local_x_max_ghost, ",", &
			&     local_y_min_ghost, ":", local_y_max_ghost, ",", &
			&     local_z_min_ghost, ":", local_z_max_ghost, ")"
			CALL MPI_Abort(cartesian_communicator,mpi_abort_error,mpi_error_code)
	
		END IF !! (memory_status /= memory_success)	

		WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: READING USER DEFINIED LST QHULL MASK FROM FILE ...'
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to call local_read_global_logical_array LST_local_vol_of_int_user_mask'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to call local_read_global_logical_array LST_local_vol_of_int_user_mask'

		CALL local_read_LOGICAL_array_simple(local_x_min_ghost,local_x_max_ghost,local_y_min_ghost,local_y_max_ghost,&
		& local_z_min_ghost,local_z_max_ghost,global_product_xyz_nodes_real,global_x_min_real,global_x_max_real,global_y_min_real,&
		& global_y_max_real,global_z_min_real,global_z_max_real,&
		& My_MPI_Process_ID,divide_x,divide_y,divide_z,IN,OUT,WEST,EAST,UP,DOWN,cartesian_communicator,&
		& 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_x_nodes_real,local_y_nodes_real,local_z_nodes_real,local_x_nodes_ghost,local_y_nodes_ghost,local_z_nodes_ghost,&
		& global_x_min_ghost,global_x_max_ghost,global_y_min_ghost,global_y_max_ghost,global_z_min_ghost,global_z_max_ghost,&
		& global_x_nodes_real,global_y_nodes_real,global_z_nodes_real,&
		& global_x_nodes_ghost,global_y_nodes_ghost,global_z_nodes_ghost,&
		& ROOT,&
		& LST_local_vol_of_int_user_mask,&
		& 22,'LST_logical_qhull_mask')

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: finished calling local_read_global_logical_array LST_local_vol_of_int_user_mask'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: finished calling local_read_global_logical_array LST_local_vol_of_int_user_mask'
		WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: FINISHED READING USER DEFINIED LST QHULL MASK!'

		WHERE(LST_local_vol_of_int_user_mask.AND.LST_local_possible_release_sites) 
		
			LST_local_vol_of_int_user_mask = .TRUE.

		ELSEWHERE

			LST_local_vol_of_int_user_mask = .FALSE.

		ENDWHERE

	ENDIF !! LST_apply_volume_user_mask

		!SANITY CHECK: CHECK TO MAKE SURE THAT THE NUMBER OF LST MARKERS IS NOT LESS THAN THE NUMBER OR MPI PROCESSES(REQUIRED TO SPREAD UNIFORMLY)
!		IF(total_number_of_LST_markers.LT.Number_Of_Processes) THEN
		
!			IF(debug) WRITE (0,*) 'ERROR: LST_uniform_marker_release: total_number_of_LST_markers.LT.Number_Of_Processes!!!(cannot spread uniformly)'
!			IF(debug) WRITE (9,*) 'ERROR: LST_uniform_marker_release: total_number_of_LST_markers.LT.Number_Of_Processes!!!(cannot spread uniformly)'
!			PRINT*,'ERROR: LST_uniform_marker_release: total_number_of_LST_markers.LT.Number_Of_Processes!!!(cannot spread uniformly)'
!			WRITE (29,*) 'ERROR: LST_uniform_marker_release: total_number_of_LST_markers.LT.Number_Of_Processes!!!(cannot spread uniformly)'
!			STOP

!		ENDIF !!total_number_of_LST_markers.LT.Number_Of_Processes


!		LST_marker_loop_counter = 0
!		DO LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension
			
!			LST_marker_loop_counter = LST_marker_loop_counter + 1
!			global_marker_ID_recieve_buffer(LST_marker_loop_counter) = LST_marker_loop_counter
!			global_position_recieve_buffer(LST_marker_loop_index) = initial_LST_marker_old_position_x
!			global_position_recieve_buffer(LST_marker_loop_index + 1 ) = initial_LST_marker_old_position_y
!			global_position_recieve_buffer(LST_marker_loop_index + 2 ) = initial_LST_marker_old_position_z
!
!		END DO

		   !SPREAD THE LST MARKERS ACROSS THE MPI PROCESSES AS EVENLY AS POSSIBLE
!	       IF(debug) WRITE (0,*) "LST_uniform_marker_release: about to call LAYOUT_MPI for LST MARKER POSITIONS" !LAYOUT_MPI WILL DETERMINE WHICH PROCESS WILL GET HOW MANY LST MARKERS
!		call LAYOUT_MPI(My_MPI_Process_ID,total_number_of_LST_markers,1,1,&
!		& Number_Of_Processes,lattice_dimension,local_number_of_LST_markers_min,&
!		& local_number_of_LST_markers_max,temp1, &
!		& temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10,&
!		& local_number_of_LST_markers,temp11, &
!		& temp12,.TRUE.,.FALSE.,.FALSE.,temp13,My_MPI_Process_ID_Digits)
!			IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_uniform_marker_release: done calling  LAYOUT_MPI for LST MARKER POSITIONS"
		
!		local_number_of_LST_markers_min = 1
!
!		local_number_of_LST_markers_max = 3

		IF(LST_apply_volume_user_mask) THEN

			!THIS SUBROUTINE WILL DISTRIBUTE THE LST MARKERS AMONG MPI PROCESES
			!BASED ON local_2_global_insert_site_ratio
			!IT WILL *NOT* DO THE ACTUAL INSERTION OF THE MARKERS
			IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'
			CALL LST_uniform_marker_distribution(My_MPI_Process_ID,&
			& total_number_of_LST_markers,&
			& Number_Of_Processes,lattice_dimension,ROOT,&
			& cartesian_communicator,my_mpi_real_data_type,&
			& LST_local_vol_of_int_user_mask,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_number_of_LST_markers_min,&
			& local_number_of_LST_markers_max,&
			& local_number_of_LST_markers)
			IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'

		ELSE

			!THIS SUBROUTINE WILL DISTRIBUTE THE LST MARKERS AMONG MPI PROCESES
			!BASED ON local_2_global_insert_site_ratio
			!IT WILL *NOT* DO THE ACTUAL INSERTION OF THE MARKERS
			IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'
			CALL LST_uniform_marker_distribution(My_MPI_Process_ID,&
			& total_number_of_LST_markers,&
			& Number_Of_Processes,lattice_dimension,ROOT,&
			& cartesian_communicator,my_mpi_real_data_type,&
			& LST_local_possible_release_sites,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_number_of_LST_markers_min,&
			& local_number_of_LST_markers_max,&
			& local_number_of_LST_markers)
			IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL LST_uniform_marker_distribution'

		ENDIF !!LST_apply_volume_user_mask


		!SEND LOCAL LST MARKER ID BOUNDS TO ROOT
		send_buffer_local_bounds = (/local_number_of_LST_markers_min,local_number_of_LST_markers_max/)

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL MPI_Gather: send_buffer_local_bounds',send_buffer_local_bounds
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to CALL MPI_Gather: send_buffer_local_bounds',send_buffer_local_bounds
		
		CALL MPI_Gather(send_buffer_local_bounds,local_LST_marker_bds_send_count,MPI_INTEGER, &
		& all_local_LST_marker_ID_bounds,ROOT_LST_marker_bds_recv_count,MPI_INTEGER,ROOT,&
		& cartesian_communicator,mpi_error_code)
		
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_uniform_marker_release: finished calling MPI_Gather: all_local_LST_marker_ID_bounds',all_local_LST_marker_ID_bounds
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_uniform_marker_release: finished calling MPI_Gather: all_local_LST_marker_ID_bounds',all_local_LST_marker_ID_bounds
		!END:  SEND LOCAL LST MARKER ID BOUNDS TO ROOT

		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers',local_number_of_LST_markers
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers',local_number_of_LST_markers

		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers_min',local_number_of_LST_markers_min
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers_min',local_number_of_LST_markers_min

		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers_max',local_number_of_LST_markers_max
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers_max',local_number_of_LST_markers_max


			!CHECK TO MAKE SURE THAT THE SUM OF local_number_of_LST_markers ADDS UP TO total_number_of_LST_markers
		IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_uniform_marker_release: about to CALL Allreduce: local_number_of_LST_markers",local_number_of_LST_markers
		IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_uniform_marker_release: about to CALL Allreduce: local_number_of_LST_markers",local_number_of_LST_markers
		
		CALL MPI_AllReduce(local_number_of_LST_markers,global_number_of_LST_markers,&
		& num_of_LST_markers_send_count,MPI_INTEGER,MPI_SUM,&
		& cartesian_communicator,mpi_error_code)
		
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE (0,*) 'ROOT LST_uniform_marker_release:  finished calling Allreduce: global_number_of_LST_markers',global_number_of_LST_markers
		IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_uniform_marker_release: finished calling Allreduce: global_number_of_LST_markers",global_number_of_LST_markers
		IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_uniform_marker_release: finished calling Allreduce: global_number_of_LST_markers",global_number_of_LST_markers

			
		!SANITY CHECK
		IF(global_number_of_LST_markers.NE.total_number_of_LST_markers) THEN

			IF(debug) WRITE (0,*) 'ERROR: LST_uniform_marker_release: global_number_of_LST_markers.NE.total_number_of_LST_markers!!!'
			IF(debug) WRITE (0,*) 'global_number_of_LST_markers',global_number_of_LST_markers
			IF(debug) WRITE (0,*) 'total_number_of_LST_markers',total_number_of_LST_markers
			IF(debug) WRITE (9,*) 'ERROR: LST_uniform_marker_release: global_number_of_LST_markers.NE.total_number_of_LST_markers!!!'
			PRINT*,'ERROR: LST_uniform_marker_release: global_number_of_LST_markers.NE.total_number_of_LST_markers!!!'
			WRITE (29,*) 'ERROR: LST_uniform_marker_release: global_number_of_LST_markers.NE.total_number_of_LST_markers!!!'
			STOP

		ENDIF !!global_number_of_LST_markers.NE.total_number_of_LST_markers

!		WRITE(0,*)'debug',debug,'My_MPI_Process_ID',My_MPI_Process_ID,'ROOT',ROOT
!		WRITE(9,*)'debug',debug,'My_MPI_Process_ID',My_MPI_Process_ID,'ROOT',ROOT
		IF(debug) WRITE(0,*) 'LST_uniform_marker_release: CHECKED FOR LST ERROR'
		IF(debug) WRITE(9,*) 'LST_uniform_marker_release: CHECKED FOR LST ERROR'



		IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_x_min_real_minus_half',local_x_min_real_minus_half
		IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_x_min_real_minus_half',local_x_min_real_minus_half
		IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_y_min_real_minus_half',local_y_min_real_minus_half
		IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_y_min_real_minus_half',local_y_min_real_minus_half
		IF(debug) WRITE(0,*) 'LST_uniform_marker_release: local_z_min_real_minus_half',local_z_min_real_minus_half
		IF(debug) WRITE(9,*) 'LST_uniform_marker_release: local_z_min_real_minus_half',local_z_min_real_minus_half

		!CALCULATE THE LOCAL REAL DOMAIN LENGTH
		local_x_real_domain_length = local_x_max_real_plus_half - local_x_min_real_minus_half
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT: local_x_real_domain_length',local_x_real_domain_length
		local_y_real_domain_length = local_y_max_real_plus_half - local_y_min_real_minus_half
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT: local_y_real_domain_length',local_y_real_domain_length
		local_z_real_domain_length = local_z_max_real_plus_half - local_z_min_real_minus_half
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT: local_z_real_domain_length',local_z_real_domain_length

!		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT ABOUT TO ALLOCATE SEND BUFFERS'
!		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(9,*) 'ROOT ABOUT TO ALLOCATE SEND BUFFERS'

		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: total_number_of_LST_markers',total_number_of_LST_markers
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: total_number_of_LST_markers',total_number_of_LST_markers

!		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( global_marker_ID_recieve_buffer(total_number_of_LST_markers) )'
!		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( global_marker_ID_recieve_buffer(total_number_of_LST_markers) )'
!		ALLOCATE ( global_marker_ID_recieve_buffer(total_number_of_LST_markers) )
!		global_marker_ID_recieve_buffer(:) = 0
	
!		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( global_position_recieve_buffer(lattice_dimension * total_number_of_LST_markers) )'
!		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( global_position_recieve_buffer(lattice_dimension * total_number_of_LST_markers) )'
!		ALLOCATE ( global_position_recieve_buffer(lattice_dimension * total_number_of_LST_markers) )
!		global_position_recieve_buffer(:) = 0.0
!		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT FINISHED ALLOCATING GLOBAL SEND BUFFERS'
!		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(9,*) 'RROOT FINISHED ALLOCATING GLOBAL SEND BUFFERS'


		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers',local_number_of_LST_markers
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: local_number_of_LST_markers',local_number_of_LST_markers


		!ALLOCATE BUFFERS
		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( local_marker_ID_send_buffer(local_number_of_LST_markers) )'
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( local_marker_ID_send_buffer(local_number_of_LST_markers) )'
		ALLOCATE ( local_marker_ID_send_buffer(local_number_of_LST_markers) )


		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( local_position_send_buffer(lattice_dimension * local_number_of_LST_markers) )'
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: about to ALLOCATE ( local_position_send_buffer(lattice_dimension * local_number_of_LST_markers) )'
		ALLOCATE ( local_position_send_buffer(lattice_dimension * local_number_of_LST_markers) )
		
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT FINISHED ALLOCATING SEND BUFFERS'
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(9,*) 'ROOT FINISHED ALLOCATING SEND BUFFERS'


		successful_init_position_count = 0  !initialize successful_init_position_count

		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT successful_init_position_count',successful_init_position_count
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(9,*) 'ROOT successful_init_position_count',successful_init_position_count

		LST_marker_loop_index = 1
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'ROOT LST_marker_loop_index',LST_marker_loop_index
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(9,*) 'ROOT LST_marker_loop_index',LST_marker_loop_index

		!DO LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension

		IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release:  about to DO WHILE'
		IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE (0,*) 'ROOT LST_uniform_marker_release:  about to DO WHILE'
		IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release:  about to DO WHILE'
		!LOOP UNTIL total_number_of_LST_markers SUCCESSFUL RANDOM INITIAL POSITIONS HAVE BEEN FOUND

		!STOP
		
		
		!=====================================START MARKER INSERTION LOOP===============================================

		!DO WHILE (successful_init_position_count.LE.total_number_of_LST_markers)
		DO WHILE (successful_init_position_count.LT.local_number_of_LST_markers)
		
			IF(debug) write(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: successful_init_position_count',successful_init_position_count  
			IF(debug) write(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: successful_init_position_count',successful_init_position_count  

			!GENERATE MARKER POSITIONS FROM A UNIFORM DISTRIBUTION, WITHIN THE LOCAL DOMAIN
			rand_LST_marker_old_position_x = ( genrand_real1() * local_x_real_domain_length ) + local_x_min_real_minus_half
			rand_LST_marker_old_position_y = ( genrand_real1() * local_y_real_domain_length ) + local_y_min_real_minus_half
			rand_LST_marker_old_position_z = ( genrand_real1() * local_z_real_domain_length ) + local_z_min_real_minus_half

			!THIS SUBROUTINE WILL CALCULAT THE NEIGHBORING LATTICE NODE COORDINATES
			CALL LST_calc_marker_unit_cube_vertex(divide_x,divide_y,divide_z,&
			& vertex000_x,vertex100_x,vertex010_x,vertex001_x,vertex101_x,vertex011_x,&
			& vertex110_x,vertex111_x,vertex000_y,vertex100_y,vertex010_y,vertex001_y,&
			& vertex101_y,vertex011_y,vertex110_y,vertex111_y,vertex000_z,vertex100_z,&
			& vertex010_z,vertex001_z,vertex101_z,vertex011_z,vertex110_z,vertex111_z,&
			& rand_LST_marker_old_position_x,rand_LST_marker_old_position_y,&
			& rand_LST_marker_old_position_z,My_MPI_Process_ID,&
			& 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,&
			& global_x_min_real,global_x_max_real,&
			& global_y_min_real,global_y_max_real,&
			& global_z_min_real,global_z_max_real,&
			& cartesian_communicator)

			!CHECK THAT IT IS CONTAINED WITHIN THE QHULL VOLUME
!			IF(LST_apply_volume_user_mask) THEN

!				IF( LST_local_vol_of_int_user_mask(vertex000_x,vertex000_y,vertex000_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex100_x,vertex100_y,vertex100_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex010_x,vertex010_y,vertex010_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex001_x,vertex001_y,vertex001_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex101_x,vertex101_y,vertex101_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex011_x,vertex011_y,vertex011_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex110_x,vertex110_y,vertex110_z).AND.&
!				& LST_local_vol_of_int_user_mask(vertex111_x,vertex111_y,vertex111_z) )   ) THEN
!					
!					LST_particle_in_volume_user_mask = .TRUE.
!
!				ELSE
!
!					LST_particle_in_volume_user_mask = .FALSE.
!			
!				ENDIF !!QHULL VOLUME MASK CHECK
!
!			ELSE !.NOT. LST_apply_volume_user_mask
!
!				LST_particle_in_volume_user_mask = .TRUE.
!
!			ENDIF !! LST_apply_volume_user_mask


			!CHECK TO MAKE SURE THAT THE PARTICLE IS NOT PLACES INSIDE A WALL
			IF( .NOT.( LST_local_walls(vertex000_x,vertex000_y,vertex000_z).OR.&
			& LST_local_walls(vertex100_x,vertex100_y,vertex100_z).OR.&
			& LST_local_walls(vertex010_x,vertex010_y,vertex010_z).OR.&
			& LST_local_walls(vertex001_x,vertex001_y,vertex001_z).OR.&
			& LST_local_walls(vertex101_x,vertex101_y,vertex101_z).OR.&
			& LST_local_walls(vertex011_x,vertex011_y,vertex011_z).OR.&
			& LST_local_walls(vertex110_x,vertex110_y,vertex110_z).OR.&
			& LST_local_walls(vertex111_x,vertex111_y,vertex111_z) ) ) THEN
					
				LST_particle_NOT_placed_in_wall = .TRUE.

			ELSE

				LST_particle_NOT_placed_in_wall = .FALSE.
		
			ENDIF !!CHECK TO MAKE SURE THAT THE PARTICLE IS NOT PLACED INSIDE A WALL



			IF(LST_apply_volume_user_mask) THEN

				!AT LEAST ONE NEIGHBOR NODE IS A PART OF THE MASK
				IF ( LST_local_vol_of_int_user_mask(vertex000_x,vertex000_y,vertex000_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex100_x,vertex100_y,vertex100_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex010_x,vertex010_y,vertex010_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex001_x,vertex001_y,vertex001_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex101_x,vertex101_y,vertex101_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex011_x,vertex011_y,vertex011_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex110_x,vertex110_y,vertex110_z).AND.&
				& LST_local_vol_of_int_user_mask(vertex111_x,vertex111_y,vertex111_z) ) THEN  
		
					LST_particle_position_obeys_mask = .TRUE.

				ELSE

					LST_particle_position_obeys_mask = .FALSE.

				ENDIF !!CHECK TO MAKE SURE THAT THE PARTICLE PLACEMENT OBEYS THE USER DEFINED LOGICAL MASK

			ELSE !.NOT.LST_apply_volume_user_mask

				!AT LEAST ONE NEIGHBOR NODE IS A PART OF THE MASK
				IF ( LST_local_possible_release_sites(vertex000_x,vertex000_y,vertex000_z).OR.&
				& LST_local_possible_release_sites(vertex100_x,vertex100_y,vertex100_z).OR.&
				& LST_local_possible_release_sites(vertex010_x,vertex010_y,vertex010_z).OR.&
				& LST_local_possible_release_sites(vertex001_x,vertex001_y,vertex001_z).OR.&
				& LST_local_possible_release_sites(vertex101_x,vertex101_y,vertex101_z).OR.&
				& LST_local_possible_release_sites(vertex011_x,vertex011_y,vertex011_z).OR.&
				& LST_local_possible_release_sites(vertex110_x,vertex110_y,vertex110_z).OR.&
				& LST_local_possible_release_sites(vertex111_x,vertex111_y,vertex111_z) ) THEN  
		
					LST_particle_position_obeys_mask = .TRUE.

				ELSE

					LST_particle_position_obeys_mask = .FALSE.

				ENDIF !!CHECK TO MAKE SURE THAT THE PARTICLE PLACEMENT OBEYS THE USER DEFINED LOGICAL MASK

			ENDIF !! LST_apply_volume_user_mask

			!CHECK TO MAKE SURE THAT THE MARKER IS NOT PLACED INSIDE A WALL IN THE LOCAL DOMAIN
			!THE RANDOMLY GENERATED POSITION WILL ONLY BE ACCEPTED IF ITS NOT PLACED IN A WALL
			!ALSO CHECK THAT IT OBEYS THE USER SPECIFIED RELEASE MASK (IF APPLICABLE)
			!ALSO CHECK THAT IT IS INSERTED INSIDE THE QHULL VOLUME (IF APPLICABLE)
			IF( LST_particle_NOT_placed_in_wall.AND.&
			& LST_particle_position_obeys_mask) THEN
				
				!write(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: rand_LST_marker_old_position_x',rand_LST_marker_old_position_x
!				write(29,*) My_MPI_Process_ID,'LST_uniform_marker_release: rand_LST_marker_old_position_x',rand_LST_marker_old_position_x

				!write(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: rand_LST_marker_old_position_y',rand_LST_marker_old_position_y
!				write(29,*) My_MPI_Process_ID,'LST_uniform_marker_release: rand_LST_marker_old_position_y',rand_LST_marker_old_position_y

				!write(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: rand_LST_marker_old_position_z',rand_LST_marker_old_position_z
!				write(29,*) My_MPI_Process_ID,'LST_uniform_marker_release: rand_LST_marker_old_position_z',rand_LST_marker_old_position_z

!				write(29,*) 'vertex000_x,	vertex000_y,	vertex000_z',vertex000_x,	vertex000_y,	vertex000_z
!				write(29,*) LST_local_walls(vertex000_x,	vertex000_y,	vertex000_z)
!				write(29,*) 'vertex100_x,	vertex100_y,	vertex100_z',vertex100_x,	vertex100_y,	vertex100_z
!				write(29,*) LST_local_walls(vertex100_x,	vertex100_y,	vertex100_z)
!				write(29,*) 'vertex010_x,	vertex010_y,	vertex010_z',vertex010_x,	vertex010_y,	vertex010_z
!				write(29,*) LST_local_walls(vertex010_x,	vertex010_y,	vertex010_z)
!				write(29,*) 'vertex001_x,	vertex001_y,	vertex001_z',vertex001_x,	vertex001_y,	vertex001_z
!				write(29,*) LST_local_walls(vertex001_x,	vertex001_y,	vertex001_z)
!				write(29,*) 'vertex101_x,	vertex101_y,	vertex101_z',vertex101_x,	vertex101_y,	vertex101_z
!				write(29,*) LST_local_walls(vertex101_x,	vertex101_y,	vertex101_z)
!				write(29,*) 'vertex011_x,	vertex011_y,	vertex011_z',vertex011_x,	vertex011_y,	vertex011_z
!				write(29,*) LST_local_walls(vertex011_x,	vertex011_y,	vertex011_z)
!				write(29,*) 'vertex110_x,	vertex110_y,	vertex110_z',vertex110_x,	vertex110_y,	vertex110_z
!				write(29,*) LST_local_walls(vertex110_x,	vertex110_y,	vertex110_z)
!				write(29,*) 'vertex111_x,	vertex111_y,	vertex111_z',vertex111_x,	vertex111_y,	vertex111_z
!				write(29,*) LST_local_walls(vertex111_x,	vertex111_y,	vertex111_z)

				IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: LST_marker_loop_index',LST_marker_loop_index
				IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: LST_marker_loop_index',LST_marker_loop_index
				
				IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(0,*) 'LST_uniform_marker_release: LST_marker_loop_index'
				IF(debug.AND.My_MPI_Process_ID.EQ.ROOT) WRITE(9,*) 'LST_uniform_marker_release: LST_marker_loop_index'

				local_position_send_buffer(LST_marker_loop_index)      = rand_LST_marker_old_position_x
				local_position_send_buffer(LST_marker_loop_index + 1 ) = rand_LST_marker_old_position_y
				local_position_send_buffer(LST_marker_loop_index + 2 ) = rand_LST_marker_old_position_z

				LST_marker_loop_index = LST_marker_loop_index + lattice_dimension
				
				successful_init_position_count = successful_init_position_count + 1

				IF(debug) WRITE(0,*) My_MPI_Process_ID,'LST_uniform_marker_release: LST_marker_loop_index',LST_marker_loop_index
				IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_uniform_marker_release: LST_marker_loop_index',LST_marker_loop_index

				local_marker_ID_send_buffer(successful_init_position_count) = local_number_of_LST_markers_min + successful_init_position_count - 1

			ENDIF !! CHECK NEIGHBOR WALLS

		END DO !DO WHILE (successful_init_position_count.LE.total_number_of_LST_markers)  
		
		!=====================================END MARKER INSERTION LOOP===============================================

	IF(debug) WRITE(9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to initialize positions'
	!WRITE LOCAL SEND BUFFERS FOR DEBUG PURPOSES
	IF(debug) THEN
		
		OPEN (94, FILE = 'debug/LST_local_position_send_buffer_'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

		LST_marker_loop_counter = 0
		DO LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension
		
			LST_marker_loop_counter = LST_marker_loop_counter + 1
						
				WRITE(94,'(I6.5,3E19.10)') local_marker_ID_send_buffer(LST_marker_loop_counter), local_position_send_buffer(LST_marker_loop_index),&
				& local_position_send_buffer(LST_marker_loop_index + 1 ),local_position_send_buffer(LST_marker_loop_index + 2 )
						
		END DO  !!LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension

		CLOSE(94) !!OPEN (94, FILE = 'debug/LST_local_initial_marker_positions_'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

	ENDIF !!DEBUG



	IF (My_MPI_Process_ID.NE.ROOT) THEN
!	IF (.false.) THEN

	!		LST_marker_loop_counter = LST_marker_loop_counter + 1
		mpi_send_destination = ROOT

		send_size_integer_buffer = local_number_of_LST_markers
		send_size_real_buffer = lattice_dimension * local_number_of_LST_markers

		!COMMUNICATE THE LOCAL BUFFERS TO ROOT INTO A GLOBAL BUFFER
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','about to send local_marker_ID_send_buffer to root'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','about to send local_marker_ID_send_buffer to root'
		CALL MPI_Send(local_marker_ID_send_buffer,send_size_integer_buffer,MPI_INTEGER,mpi_send_destination,&
		& integer_send_recv_tag,cartesian_communicator,mpi_error_code)
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','finished sending local_marker_ID_send_buffer to root'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','finished sending local_marker_ID_send_buffer to root'


		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_marker_ID_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_marker_ID_send_buffer )'
		
		DEALLOCATE( local_marker_ID_send_buffer )

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_marker_ID_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_marker_ID_send_buffer )'



		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','about to send local_position_send_buffer to root'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','about to send local_position_send_buffer to root'
		CALL MPI_Send(local_position_send_buffer,send_size_real_buffer,my_mpi_real_data_type,mpi_send_destination,&
		& real_send_recv_tag,cartesian_communicator,mpi_error_code)
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','finished sending local_position_send_buffer to root'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','finished sending local_position_send_buffer to root'

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_position_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_position_send_buffer )'

		DEALLOCATE( local_position_send_buffer )

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_position_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_position_send_buffer )'


	ELSE !!My_MPI_Process_ID.EQ.ROOT (SO THIS HAPPENS ONLY ON THE ROOT PROCESS)




		!ROOT STORES ITS OWN VALUES TO THE global_position_recieve_buffer AND TO global_marker_ID_recieve_buffer
		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','ROOT about to store its own values'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','ROOT about to store its own values'
			


		
		LST_marker_loop_counter = 0
		DO LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension
		
			LST_marker_loop_counter = LST_marker_loop_counter + 1
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: LST_marker_loop_counter',LST_marker_loop_counter
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: LST_marker_loop_index',LST_marker_loop_index

			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: local_marker_ID_send_buffer',local_marker_ID_send_buffer(LST_marker_loop_counter)
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: local_position_send_bufferX',local_position_send_buffer(LST_marker_loop_index)
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: local_position_send_bufferY',local_position_send_buffer(LST_marker_loop_index+1)
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: local_position_send_bufferZ',local_position_send_buffer(LST_marker_loop_index+2)
			
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: global_position_recieve_bufferX',local_number_of_LST_markers_min + LST_marker_loop_index - 1
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: global_position_recieve_bufferY',local_number_of_LST_markers_min + LST_marker_loop_index 
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: global_position_recieve_bufferZ',local_number_of_LST_markers_min + LST_marker_loop_index + 1

			global_marker_ID_recieve_buffer(local_number_of_LST_markers_min+LST_marker_loop_counter-1) = &
			& local_marker_ID_send_buffer(LST_marker_loop_counter)


			!X-POSITION
			global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index - 1 ) = &
			& local_position_send_buffer(LST_marker_loop_index)

			!Y-POSITION

			global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index ) = &
			& local_position_send_buffer(LST_marker_loop_index + 1 )

			!Z-POSITION
			global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index + 1 ) = &
			& local_position_send_buffer(LST_marker_loop_index + 2 )

		END DO  !!LST_marker_loop_index = local_number_of_LST_markers_min, lattice_dimension * local_number_of_LST_markers, lattice_dimension

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','ROOT finished store its own values'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','ROOT finished store its own values'

		IF(debug) THEN
		
			OPEN (96, FILE = 'debug/global_position_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

			LST_marker_loop_counter = 0
			DO LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension
		
				LST_marker_loop_counter = LST_marker_loop_counter + 1
						
!					WRITE(96,'(I6.5,3E19.10)') global_marker_ID_recieve_buffer(LST_marker_loop_counter), global_position_recieve_buffer(LST_marker_loop_index),&
!					& global_position_recieve_buffer(LST_marker_loop_index + 1 ),global_position_recieve_buffer(LST_marker_loop_index + 2 )

					WRITE(96,'(I6.5,3E19.10)') global_marker_ID_recieve_buffer(LST_marker_loop_counter),&
					& global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index - 1 ),&
					& global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index ),&
					& global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index + 1 )
						
			END DO  !!LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension

			CLOSE(96) !!OPEN (96, FILE = 'debug/global_position_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

		ENDIF !!DEBUG


		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_position_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_position_send_buffer )'

		DEALLOCATE( local_position_send_buffer )

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_position_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_position_send_buffer )'

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_marker_ID_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: about to DEALLOCATE( local_marker_ID_send_buffer )'
		
		DEALLOCATE( local_marker_ID_send_buffer )

		IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_marker_ID_send_buffer )'
		IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions: finished to DEALLOCATE( local_marker_ID_send_buffer )'

		!------------END ROOT STORES ITS OWN VALUES TO THE global_position_recieve_buffer AND TO global_marker_ID_recieve_buffer--------------




		!===============================ROOT RECEIVES VALUES FROM OTHER PROCESSORS =====================================
		DO MPI_Process_Number = 0, Number_Of_Processes - 1  !CYCLE OVER ALL PROCESSES ON THE ROOT PROCESS
		
			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

				SOURCE = MPI_Process_Number !ASSIGN CURRENT PROCESS AS "SOURCE" FROM WHICH INFORMATION IS RECEIVED
				
				IF(debug) WRITE (0,*) 'LST_initialize_marker_positions:','ROOT: about to cycle process',MPI_Process_Number,'of', Number_Of_Processes - 1 ,'processes'
				IF(debug) WRITE (9,*) 'LST_initialize_marker_positions:','ROOT: about to cycle process',MPI_Process_Number,'of', Number_Of_Processes - 1 ,'processes'
			

				remote_numbr_of_LST_markers_max = all_local_LST_marker_ID_bounds(2 * MPI_Process_Number + 1)
				IF(debug) WRITE (0,*) MPI_Process_Number,'LST_initialize_marker_positions:','remote_numbr_of_LST_markers_max',remote_numbr_of_LST_markers_max
				IF(debug) WRITE (9,*) MPI_Process_Number,'LST_initialize_marker_positions:','remote_numbr_of_LST_markers_max',remote_numbr_of_LST_markers_max

				remote_numbr_of_LST_markers_min = all_local_LST_marker_ID_bounds(2 * MPI_Process_Number)
				IF(debug) WRITE (0,*) MPI_Process_Number,'LST_initialize_marker_positions:','remote_numbr_of_LST_markers_min',remote_numbr_of_LST_markers_min
				IF(debug) WRITE (9,*) MPI_Process_Number,'LST_initialize_marker_positions:','remote_numbr_of_LST_markers_min',remote_numbr_of_LST_markers_min

				recv_size_integer_buffer =  remote_numbr_of_LST_markers_max - remote_numbr_of_LST_markers_min + 1
				

				IF(debug) WRITE (0,*) MPI_Process_Number,'ROOT LST_initialize_marker_positions: recv_size_integer_buffer',recv_size_integer_buffer
				IF(debug) WRITE (9,*) MPI_Process_Number,'ROOT LST_initialize_marker_positions: recv_size_integer_buffer',recv_size_integer_buffer


				ALLOCATE ( local_marker_ID_recv_buffer(recv_size_integer_buffer),STAT=memory_status )	

				IF (memory_status /= memory_success) THEN
					WRITE (0,*) My_MPI_Process_ID,"ERROR: ROOT can't allocate local_marker_ID_recv_buffer of size ",recv_size_integer_buffer
					CALL MPI_Abort(cartesian_communicator,mpi_abort_error_code,mpi_error_code)
				END IF

				recv_size_real_buffer = recv_size_integer_buffer * lattice_dimension
				IF(debug) WRITE (0,*) MPI_Process_Number,'ROOT LST_initialize_marker_positions: recv_size_real_buffer',recv_size_real_buffer
				IF(debug) WRITE (9,*) MPI_Process_Number,'ROOT LST_initialize_marker_positions: recv_size_real_buffer',recv_size_real_buffer
				

				ALLOCATE ( local_position_recv_buffer(recv_size_real_buffer),STAT=memory_status )	

				IF (memory_status /= memory_success) THEN
					WRITE (0,*) My_MPI_Process_ID,"ERROR: ROOT can't allocate local_position_recv_buffer of size ",recv_size_real_buffer
					CALL MPI_Abort(cartesian_communicator,mpi_abort_error_code,mpi_error_code)
				END IF


				!ROOT RECEIVES FROM ALL THE NON-ROOT PROCESSES THEIR BUFFERS
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'ROOT LST_initialize_marker_positions:','about to recv INTEGER buffer from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'ROOT LST_initialize_marker_positions:','about to recv INTEGER buffer from process',MPI_Process_Number
				CALL MPI_Recv( local_marker_ID_recv_buffer,recv_size_integer_buffer,MPI_INTEGER,SOURCE,&
				& integer_send_recv_tag, cartesian_communicator,status,mpi_error_code )
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'ROOT LST_initialize_marker_positions:','finished recving INTEGER buffer from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'ROOT LST_initialize_marker_positions:','finished recving INTEGER buffer from process',MPI_Process_Number



				IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','about to recv REAL buffer from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','about to recv REAL buffer from process',MPI_Process_Number
				CALL MPI_Recv( local_position_recv_buffer,recv_size_real_buffer,my_mpi_real_data_type,SOURCE,&
				& real_send_recv_tag,cartesian_communicator,status,mpi_error_code )
				IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','finished recving REAL buffer from process',MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:','finished recving REAL buffer from process',MPI_Process_Number
				
				!===============================END ROOT RECEIVES VALUES FROM OTHER PROCESSOR =====================================				

				!WRITE LOCAL RECV BUFFERS FOR DEBUG PURPOSES
				IF(debug) THEN
				
				OPEN (95, FILE = 'debug/LST_ROOT_local_position_recv_buffer.txt',POSITION = 'append', STATUS = 'unknown')

				LST_marker_loop_counter = 0
				DO LST_marker_loop_index = 1, lattice_dimension * recv_size_integer_buffer, lattice_dimension
		
					LST_marker_loop_counter = LST_marker_loop_counter + 1
						
						WRITE(95,'(2I6.5,3E19.10)') SOURCE,local_marker_ID_recv_buffer(LST_marker_loop_counter), local_position_recv_buffer(LST_marker_loop_index),&
						& local_position_recv_buffer(LST_marker_loop_index + 1 ),local_position_recv_buffer(LST_marker_loop_index + 2 )
						
				END DO  !!LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension

				CLOSE(95) !!OPEN (95, FILE = 'debug/LST_local_initial_marker_positions_'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

				ENDIF !!DEBUG
				
				
				!======================= ROOT START STORING BUFFERS FROM OTHER PROCESSOR ================================
				IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS PREPARING TO STORE BUFFERS",MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS PREPARING TO STORE BUFFERS",MPI_Process_Number
				
				position_start_buffer_location = (remote_numbr_of_LST_markers_min -1) * lattice_dimension + 1
				LST_marker_loop_counter = 0
				DO LST_marker_loop_index = 1, lattice_dimension * recv_size_integer_buffer, lattice_dimension
		
					LST_marker_loop_counter = LST_marker_loop_counter + 1
					

					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote LST_marker_loop_counter',LST_marker_loop_counter
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote LST_marker_loop_index',LST_marker_loop_index

					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote local_marker_ID_recv_buffer',local_marker_ID_recv_buffer(LST_marker_loop_counter)
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote local_position_recv_bufferX',local_position_recv_buffer(LST_marker_loop_index)
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote local_position_recv_bufferY',local_position_recv_buffer(LST_marker_loop_index+1)
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote local_position_recv_bufferZ',local_position_recv_buffer(LST_marker_loop_index+2)
		
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote global_position_recv_bufferX',position_start_buffer_location + LST_marker_loop_index - 1
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote global_position_recv_bufferY',position_start_buffer_location + LST_marker_loop_index 
					IF(debug) WRITE (9,*) SOURCE,'LST_initialize_marker_positions: remote global_position_recv_bufferZ',position_start_buffer_location + LST_marker_loop_index + 1


	
					global_marker_ID_recieve_buffer(remote_numbr_of_LST_markers_min + LST_marker_loop_counter - 1) = &
					&  local_marker_ID_recv_buffer(LST_marker_loop_counter)
					

					!X-POSITION
					global_position_recieve_buffer(position_start_buffer_location + LST_marker_loop_index - 1) = &
					&  local_position_recv_buffer(LST_marker_loop_index)

					!Y-POSITION
					global_position_recieve_buffer(position_start_buffer_location + LST_marker_loop_index ) = &
					&  local_position_recv_buffer(LST_marker_loop_index + 1)


					!Z-POSITION
					global_position_recieve_buffer(position_start_buffer_location + LST_marker_loop_index + 1) = &
					&  local_position_recv_buffer(LST_marker_loop_index + 2)

				END DO  !!LST_marker_loop_index = local_number_of_LST_markers_min, lattice_dimension * local_number_of_LST_markers, lattice_dimension


				IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS STORING BUFFERS",MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS STORING BUFFERS",MPI_Process_Number

!				IF(debug) THEN
		
!					OPEN (96, FILE = 'debug/global_position_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

!					LST_marker_loop_counter = 0
!					DO LST_marker_loop_index = 1, lattice_dimension * recv_size_integer_buffer, lattice_dimension
		
!						LST_marker_loop_counter = LST_marker_loop_counter + 1
						
!						WRITE(96,'(I6.5,3E19.10)') global_marker_ID_recieve_buffer(LST_marker_loop_counter), global_position_recieve_buffer(LST_marker_loop_index),&
!						& global_position_recieve_buffer(LST_marker_loop_index + 1 ),global_position_recieve_buffer(LST_marker_loop_index + 2 )
!
!						WRITE(96,'(I6.5,3E19.10)') global_marker_ID_recieve_buffer(LST_marker_loop_counter),&
!						& global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index - 1 ),&
!						& global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index ),&
!						& global_position_recieve_buffer(local_number_of_LST_markers_min + LST_marker_loop_index + 1 )
						
!					END DO  !!LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension

!					CLOSE(96) !!OPEN (96, FILE = 'debug/global_position_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

!				ENDIF !!DEBUG


	!======================= END WRITING FILES ================================
				DEALLOCATE ( local_marker_ID_recv_buffer )
				
				IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS FINISHED DEALLOCATE ( local_marker_ID_recv_buffer )",MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS FINISHED DEALLOCATE ( local_marker_ID_recv_buffer )",MPI_Process_Number
				
			
				DEALLOCATE ( local_position_recv_buffer )
				
				IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS FINISHED DEALLOCATE ( local_position_recv_buffer )",MPI_Process_Number
				IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS FINISHED DEALLOCATE ( local_position_recv_buffer )",MPI_Process_Number
	
			ENDIF !!MPI_Process_Number.NE/EQ.ROOT
		
		END DO !!MPI_Process_Number

		IF(debug) WRITE (0,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS FINISHED MPI_Process_Number LOOP"
		IF(debug) WRITE (9,*) My_MPI_Process_ID,"LST_initialize_marker_positions: ROOT IS FINISHED MPI_Process_Number LOOP"


				IF(debug) THEN
		
					OPEN (53, FILE = 'debug/LST_ROOT_global_position_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

					LST_marker_loop_counter = 0
					DO LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension
		
						LST_marker_loop_counter = LST_marker_loop_counter + 1
						
						WRITE(53,'(I6.5,3E19.10)') global_marker_ID_recieve_buffer(LST_marker_loop_counter), global_position_recieve_buffer(LST_marker_loop_index),&
						& global_position_recieve_buffer(LST_marker_loop_index + 1 ),global_position_recieve_buffer(LST_marker_loop_index + 2 )
					
					END DO  !!LST_marker_loop_index = 1, lattice_dimension * local_number_of_LST_markers, lattice_dimension

					CLOSE(53) !!OPEN (53, FILE = 'debug/LST_ROOT_global_position_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

				ENDIF !!DEBUG


	ENDIF !!My_MPI_Process_ID IS ROOT OR NON-ROOT

	!ROOT BROADCASTS SUCCESSFUL POSITIONS TO THE REST OF MPI PROCESSES
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  about to CALL MPI_Bcast(global_marker_ID_recieve_buffer)'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  about to CALL MPI_Bcast(global_marker_ID_recieve_buffer)'
	CALL MPI_Bcast(global_marker_ID_recieve_buffer,total_number_of_LST_markers,&
	& MPI_INTEGER,ROOT,cartesian_communicator,mpi_error_code)
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  finished to CALL MPI_Bcast(global_marker_ID_recieve_buffer)'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  finished to CALL MPI_Bcast(global_marker_ID_recieve_buffer)'


	root_global_position_bcast_size =lattice_dimension * total_number_of_LST_markers

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  about to CALL MPI_Bcast(global_position_recieve_buffer)'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  about to CALL MPI_Bcast(global_position_recieve_buffer)'
	CALL MPI_Bcast(global_position_recieve_buffer,root_global_position_bcast_size,&
	& my_mpi_real_data_type,ROOT,cartesian_communicator,mpi_error_code)
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  finished to CALL MPI_Bcast(global_position_recieve_buffer)'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_initialize_marker_positions:  finished to CALL MPI_Bcast(global_position_recieve_buffer)'


				IF(DEBUG) THEN
					OPEN (65, FILE = 'debug/FINAL_LST_global_position_marker_ID_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

					LST_marker_loop_counter = 0
					DO LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension
		
						LST_marker_loop_counter = LST_marker_loop_counter + 1
						
						WRITE(65,'(I6.5,3E19.10)') global_marker_ID_recieve_buffer(LST_marker_loop_counter),&
						& global_position_recieve_buffer(LST_marker_loop_index),&
						& global_position_recieve_buffer(LST_marker_loop_index + 1 ),&
						& global_position_recieve_buffer(LST_marker_loop_index + 2 )
						
					END DO  !!LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension

					CLOSE(65) !!OPEN (65, FILE = 'debug/FINAL_LST_global_position_marker_ID_recieve_buffer'//Print_Results_MPI_ID//'.txt', STATUS = 'unknown')

				ENDIF !!DEBUG

!	global_avg_absolute_position_x = 0.0
!	global_avg_absolute_position_y = 0.0 
!	global_avg_absolute_position_z = 0.0

	!CALCULATE INITIAL POSITION AVERAGES
!	LST_marker_loop_counter = 0
!	DO LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension

!		LST_marker_loop_counter = LST_marker_loop_counter + 1
						
!		global_avg_absolute_position_x = global_avg_absolute_position_x + global_position_recieve_buffer(LST_marker_loop_index)
!		global_avg_absolute_position_y = global_avg_absolute_position_y + global_position_recieve_buffer(LST_marker_loop_index + 1 )
!		global_avg_absolute_position_z = global_avg_absolute_position_z + global_position_recieve_buffer(LST_marker_loop_index + 2 )
						
!	END DO  !!LST_marker_loop_index = 1, lattice_dimension * total_number_of_LST_markers, lattice_dimension

	IF(LST_apply_volume_user_mask) THEN

		DEALLOCATE ( LST_local_vol_of_int_user_mask )

	ENDIF !!LST_apply_volume_user_mask


	IF(debug) WRITE (0,*) My_MPI_Process_ID,'about to END SUBROUTINE LST_uniform_marker_release'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'about to END SUBROUTINE LST_uniform_marker_release'


RETURN
END SUBROUTINE LST_uniform_marker_release