LST_read_resume_files.F90 6.98 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
SUBROUTINE LST_read_resume_files(global_marker_ID_recieve_buffer,global_position_recieve_buffer,&
& total_number_of_LST_markers,My_MPI_Process_ID,LST_Time_Steps_Prev_Completed,&
& Number_Of_Prev_LST_Step_Digits,LST_marker_reacted_probability,&
& tot_num_markers_plus_nonbrownian,lattice_dimension,&
& global_VOLMSK_marker_list_INST,&
& global_TARGET_marker_list_INST,&
& global_TARGET_VIRGIN_list_INST,&
& global_TARGET_marker_list_CUMLTV)

!THIS SUBRUTINE READS LST RESUME FILES 

USE debug_module

	IMPLICIT NONE

	INCLUDE "mpif.h"

	!-----------INTENT(IN)------------------------------------------
	INTEGER,INTENT(IN) :: total_number_of_LST_markers,lattice_dimension
	INTEGER,INTENT(IN) :: My_MPI_Process_ID,tot_num_markers_plus_nonbrownian
	INTEGER,INTENT(IN) :: LST_Time_Steps_Prev_Completed,Number_Of_Prev_LST_Step_Digits


	LOGICAL*4,PARAMETER :: debug = GLOBAL_DEBUG
		
	!-----------INTENT(OUT)------------------------------------------
	INTEGER,INTENT(OUT) :: global_marker_ID_recieve_buffer(tot_num_markers_plus_nonbrownian)
	REAL,INTENT(OUT) :: global_position_recieve_buffer(lattice_dimension * tot_num_markers_plus_nonbrownian)
	REAL,INTENT(OUT) :: LST_marker_reacted_probability(0:1,total_number_of_LST_markers)
	LOGICAL,INTENT(OUT),DIMENSION(tot_num_markers_plus_nonbrownian) :: global_VOLMSK_marker_list_INST
	LOGICAL,INTENT(OUT),DIMENSION(tot_num_markers_plus_nonbrownian) :: global_TARGET_marker_list_INST
	LOGICAL,INTENT(OUT),DIMENSION(tot_num_markers_plus_nonbrownian) :: global_TARGET_VIRGIN_list_INST
	
	LOGICAL,INTENT(OUT),DIMENSION(tot_num_markers_plus_nonbrownian) :: global_TARGET_marker_list_CUMLTV
	
	
	

	!-----------NO INTENT------------------------------------------
	INTEGER :: LST_marker_loop_index,LST_marker_ID
	INTEGER :: LST_marker_ID_times_three
	INTEGER,PARAMETER :: LST_Past_Reacted_Step = 0
	INTEGER,PARAMETER :: LST_Current_Reacted_Step = 1

	REAL :: LST_marker_position_x,LST_marker_position_y,LST_marker_position_z
	LOGICAL :: binary_LST_resume_file_exists
	LOGICAL*4 :: marker_ID_is_non_brownian
	CHARACTER(LEN = 103) Completed_LSTstep_Format_String
	CHARACTER(LEN = Number_Of_Prev_LST_Step_Digits) Print_Completed_LST_Step_Number

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

	global_marker_ID_recieve_buffer(:) = 0
	global_position_recieve_buffer(:) = 0.0
	LST_marker_reacted_probability(:,:) = 0.0

		WRITE (Completed_LSTstep_Format_String(1:2),'(A2)') '  '
		WRITE (Completed_LSTstep_Format_String(103:103),'(A)') ')'
		WRITE (Completed_LSTstep_Format_String(3:102),'(I100)') Number_Of_Prev_LST_Step_Digits
		Completed_LSTstep_Format_String = ADJUSTL(Completed_LSTstep_Format_String)
		Completed_LSTstep_Format_String='(I'//Completed_LSTstep_Format_String

	WRITE (Print_Completed_LST_Step_Number,Completed_LSTstep_Format_String) LST_Time_Steps_Prev_Completed

	INQUIRE(FILE = 'backup/LST_binary_resume_lattice_units_'//Print_Completed_LST_Step_Number//'.dat',EXIST = binary_LST_resume_file_exists)

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_read_resume_files:  binary_LST_resume_file_exists',binary_LST_resume_file_exists
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_read_resume_files:  binary_LST_resume_file_exists',binary_LST_resume_file_exists



	IF(binary_LST_resume_file_exists) THEN
		
		OPEN (49, FILE = 'backup/LST_binary_resume_lattice_units_'//Print_Completed_LST_Step_Number//'.dat',STATUS = 'unknown', form='unformatted')
		
	ELSE !!.NOT.binary_LST_resume_file_exists

		OPEN (49, FILE = 'backup/LST_asci_resume_lattice_units_'//Print_Completed_LST_Step_Number//'.txt',STATUS = 'unknown', form='formatted')

	ENDIF !!binary_LST_resume_file_exists

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_read_resume_files:  OPENed (49,'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_read_resume_files:  OPENed (49,'

	
	DO LST_marker_loop_index = 1, tot_num_markers_plus_nonbrownian

			
			!READ THE LST_marker_ID WITHOUT GOING TO NEXT LINE
			IF(binary_LST_resume_file_exists) THEN
				
				READ(49)   LST_marker_ID

			ELSE !!.NOT.binary_LST_resume_file_exists

				READ(49,*) LST_marker_ID

			ENDIF !!binary_LST_resume_file_exists


			IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_read_resume_files:  LST_marker_ID',LST_marker_ID
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_read_resume_files:  LST_marker_ID',LST_marker_ID


			!CHECK IF THE CURRENT MARKER IS non-brownian OR NOT
			IF(LST_marker_ID.LE.total_number_of_LST_markers) THEN

				marker_ID_is_non_brownian = .FALSE.

			ELSE

				marker_ID_is_non_brownian = .TRUE.

			ENDIF !!LST_marker_ID.LE.total_number_of_LST_markers


			IF(debug) WRITE (0,*) My_MPI_Process_ID,'LST_read_resume_files:  marker_ID_is_non_brownian',marker_ID_is_non_brownian
			IF(debug) WRITE (9,*) My_MPI_Process_ID,'LST_read_resume_files:  marker_ID_is_non_brownian',marker_ID_is_non_brownian

	
			IF(.NOT.marker_ID_is_non_brownian) THEN  !READ LST_marker_reacted_probability

				IF(binary_LST_resume_file_exists) THEN
					
					READ(49) LST_marker_reacted_probability(LST_Past_Reacted_Step,LST_marker_ID),&
					& LST_marker_reacted_probability(LST_Current_Reacted_Step,LST_marker_ID),&
					& LST_marker_position_x,LST_marker_position_y,LST_marker_position_z,&
					& global_VOLMSK_marker_list_INST(LST_marker_ID),&
					& global_TARGET_marker_list_INST(LST_marker_ID),&
					& global_TARGET_VIRGIN_list_INST(LST_marker_ID),&
					& global_TARGET_marker_list_CUMLTV(LST_marker_ID)

				ELSE

					READ(49,*) LST_marker_reacted_probability(LST_Past_Reacted_Step,LST_marker_ID),&
					& LST_marker_reacted_probability(LST_Current_Reacted_Step,LST_marker_ID),&
					& LST_marker_position_x,LST_marker_position_y,LST_marker_position_z,&
					& global_VOLMSK_marker_list_INST(LST_marker_ID),&
					& global_TARGET_marker_list_INST(LST_marker_ID),&
					& global_TARGET_VIRGIN_list_INST(LST_marker_ID),&
					& global_TARGET_marker_list_CUMLTV(LST_marker_ID)

				ENDIF !! binary_LST_resume_file_exists

			ELSE

				IF(binary_LST_resume_file_exists) THEN !DO NOT READ LST_marker_reacted_probability

					READ(49) LST_marker_position_x,LST_marker_position_y,LST_marker_position_z

				ELSE

					READ(49,*) LST_marker_position_x,LST_marker_position_y,LST_marker_position_z

				ENDIF !! binary_LST_resume_file_exists
				
			ENDIF !! .NOT.marker_ID_is_non_brownian

			global_marker_ID_recieve_buffer(LST_marker_ID) = LST_marker_ID

			LST_marker_ID_times_three = 3 * LST_marker_ID
			
			!STORE POSITIONS TO A BUFFER	
			global_position_recieve_buffer( LST_marker_ID_times_three - 2 ) = LST_marker_position_x
			global_position_recieve_buffer( LST_marker_ID_times_three - 1 ) = LST_marker_position_y
			global_position_recieve_buffer( LST_marker_ID_times_three     ) = LST_marker_position_z

	END DO !!LST_marker_loop_index = 1, tot_num_markers_plus_nonbrownian


	CLOSE (49)  


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


RETURN
END SUBROUTINE LST_read_resume_files