@@ -1114,47 +1114,83 @@ contains
11141114 integer , intent (in ) :: t_step
11151115 character (len= path_len + 2 * name_len) :: file_loc
11161116 integer :: i, ios, file_unit, ierr
1117+ integer :: r, nlocal, gbl_id
11171118 integer , parameter :: NFIELDS_PER_IB = 20
11181119 real (wp) :: ib_buf(NFIELDS_PER_IB)
11191120 logical :: file_exist
1121+ character (len= 10 ) :: t_step_string
11201122
1121- write (file_loc, ' (A,I0,A) ' ) ' /restart_data/ib_state_ ' , t_step, ' .dat '
1122- file_loc = trim (case_dir) // trim (file_loc )
1123+ if (file_per_process) then
1124+ call s_int_to_str(t_step, t_step_string )
11231125
1124- if (proc_rank == 0 ) then
1125- inquire (FILE= trim (file_loc), EXIST= file_exist)
1126- if (.not. file_exist) then
1127- call s_mpi_abort(' Cannot open IB state file for restart: ' // trim (file_loc))
1128- end if
1126+ do r = 0 , num_procs - 1
1127+ write (file_loc, ' (A,I0,A,i7.7,A)' ) ' ib_state_' , t_step, ' _' , r, ' .dat'
1128+ file_loc = trim (case_dir) // ' /restart_data/lustre_' // trim (t_step_string) // ' /' // trim (file_loc)
11291129
1130- open (newunit= file_unit, file= trim (file_loc), form= ' unformatted' , access= ' stream' , status= ' old' , iostat= ios)
1131- if (ios /= 0 ) call s_mpi_abort(' Error opening IB state restart file: ' // trim (file_loc))
1130+ inquire (FILE= trim (file_loc), EXIST= file_exist)
1131+ if (.not. file_exist) call s_mpi_abort(' Cannot open IB state file for restart: ' // trim (file_loc))
1132+
1133+ open (newunit= file_unit, file= trim (file_loc), form= ' unformatted' , access= ' stream' , status= ' old' , iostat= ios)
1134+ if (ios /= 0 ) call s_mpi_abort(' Error opening IB state restart file: ' // trim (file_loc))
1135+
1136+ read (file_unit, iostat= ios) nlocal
1137+ if (ios /= 0 ) call s_mpi_abort(' Error reading IB state file header: ' // trim (file_loc))
1138+
1139+ do i = 1 , nlocal
1140+ read (file_unit, iostat= ios) gbl_id
1141+ if (ios /= 0 ) call s_mpi_abort(' Error reading IB patch ID: ' // trim (file_loc))
1142+ read (file_unit, iostat= ios) ib_buf
1143+ if (ios /= 0 ) call s_mpi_abort(' Error reading IB state data: ' // trim (file_loc))
1144+
1145+ patch_ib(gbl_id)%vel = ib_buf(8 :10 )
1146+ patch_ib(gbl_id)%angular_vel = ib_buf(11 :13 )
1147+ patch_ib(gbl_id)%angles = ib_buf(14 :16 )
1148+ patch_ib(gbl_id)%x_centroid = ib_buf(17 )
1149+ patch_ib(gbl_id)%y_centroid = ib_buf(18 )
1150+ patch_ib(gbl_id)%z_centroid = ib_buf(19 )
1151+ end do
11321152
1133- do i = 1 , num_ibs
1134- read (file_unit, iostat= ios) ib_buf
1135- if (ios /= 0 ) call s_mpi_abort(' Error reading IB state restart file' )
1136-
1137- patch_ib(i)%vel = ib_buf(8 :10 )
1138- patch_ib(i)%angular_vel = ib_buf(11 :13 )
1139- patch_ib(i)%angles = ib_buf(14 :16 )
1140- patch_ib(i)%x_centroid = ib_buf(17 )
1141- patch_ib(i)%y_centroid = ib_buf(18 )
1142- patch_ib(i)%z_centroid = ib_buf(19 )
1153+ close (file_unit)
11431154 end do
1155+ else
1156+ write (file_loc, ' (A,I0,A)' ) ' /restart_data/ib_state_' , t_step, ' .dat'
1157+ file_loc = trim (case_dir) // trim (file_loc)
11441158
1145- close (file_unit)
1146- end if
1159+ if (proc_rank == 0 ) then
1160+ inquire (FILE= trim (file_loc), EXIST= file_exist)
1161+ if (.not. file_exist) then
1162+ call s_mpi_abort(' Cannot open IB state file for restart: ' // trim (file_loc))
1163+ end if
1164+
1165+ open (newunit= file_unit, file= trim (file_loc), form= ' unformatted' , access= ' stream' , status= ' old' , iostat= ios)
1166+ if (ios /= 0 ) call s_mpi_abort(' Error opening IB state restart file: ' // trim (file_loc))
1167+
1168+ do i = 1 , num_ibs
1169+ read (file_unit, iostat= ios) ib_buf
1170+ if (ios /= 0 ) call s_mpi_abort(' Error reading IB state restart file' )
1171+
1172+ patch_ib(i)%vel = ib_buf(8 :10 )
1173+ patch_ib(i)%angular_vel = ib_buf(11 :13 )
1174+ patch_ib(i)%angles = ib_buf(14 :16 )
1175+ patch_ib(i)%x_centroid = ib_buf(17 )
1176+ patch_ib(i)%y_centroid = ib_buf(18 )
1177+ patch_ib(i)%z_centroid = ib_buf(19 )
1178+ end do
1179+
1180+ close (file_unit)
1181+ end if
11471182
11481183#ifdef MFC_MPI
1149- do i = 1 , num_ibs
1150- call MPI_BCAST(patch_ib(i)%vel, 3 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1151- call MPI_BCAST(patch_ib(i)%angular_vel, 3 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1152- call MPI_BCAST(patch_ib(i)%angles, 3 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1153- call MPI_BCAST(patch_ib(i)%x_centroid, 1 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1154- call MPI_BCAST(patch_ib(i)%y_centroid, 1 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1155- call MPI_BCAST(patch_ib(i)%z_centroid, 1 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1156- end do
1184+ do i = 1 , num_ibs
1185+ call MPI_BCAST(patch_ib(i)%vel, 3 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1186+ call MPI_BCAST(patch_ib(i)%angular_vel, 3 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1187+ call MPI_BCAST(patch_ib(i)%angles, 3 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1188+ call MPI_BCAST(patch_ib(i)%x_centroid, 1 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1189+ call MPI_BCAST(patch_ib(i)%y_centroid, 1 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1190+ call MPI_BCAST(patch_ib(i)%z_centroid, 1 , mpi_p, 0 , MPI_COMM_WORLD, ierr)
1191+ end do
11571192#endif
1193+ end if
11581194
11591195 end subroutine s_read_ib_restart_data
11601196
0 commit comments