@@ -1364,28 +1364,28 @@ contains
13641364 real(wp), dimension(:), allocatable :: angle_x, angle_y, angle_z
13651365 real(wp), dimension(:), allocatable :: ib_diameter
13661366
1367- ! Build path to per-timestep IB state file
1368- write (file_loc, ' (A,I0,A)' ) ' / restart_data/ ib_state_' , t_step, ' .dat'
1369- file_loc = trim(case_dir) // trim(file_loc)
1367+ if (proc_rank == 0) then
1368+ ! Build path to per-timestep IB state file
1369+ write (file_loc, ' (A,I0,A)' ) ' / restart_data/ ib_state_' , t_step, ' .dat'
1370+ file_loc = trim(case_dir) // trim(file_loc)
13701371
1371- inquire (FILE=trim(file_loc), EXIST=file_exist)
1372- if (.not. file_exist) then
1373- call s_mpi_abort(' Restart file ' // trim(file_loc) // ' does not exist!' )
1374- end if
1372+ inquire (FILE=trim(file_loc), EXIST=file_exist)
1373+ if (.not. file_exist) then
1374+ call s_mpi_abort(' Restart file ' // trim(file_loc) // ' does not exist!' )
1375+ end if
13751376
1376- nBodies = num_ibs
1377+ nBodies = num_ibs
13771378
1378- if (nBodies > 0) then
1379- allocate (ib_data(nBodies, NFIELDS_PER_IB))
1380- allocate (px(nBodies), py(nBodies), pz(nBodies))
1381- allocate (force_x(nBodies), force_y(nBodies), force_z(nBodies))
1382- allocate (torque_x(nBodies), torque_y(nBodies), torque_z(nBodies))
1383- allocate (vel_x(nBodies), vel_y(nBodies), vel_z(nBodies))
1384- allocate (omega_x(nBodies), omega_y(nBodies), omega_z(nBodies))
1385- allocate (angle_x(nBodies), angle_y(nBodies), angle_z(nBodies))
1386- allocate (ib_diameter(nBodies))
1379+ if (nBodies > 0) then
1380+ allocate (ib_data(nBodies, NFIELDS_PER_IB))
1381+ allocate (px(nBodies), py(nBodies), pz(nBodies))
1382+ allocate (force_x(nBodies), force_y(nBodies), force_z(nBodies))
1383+ allocate (torque_x(nBodies), torque_y(nBodies), torque_z(nBodies))
1384+ allocate (vel_x(nBodies), vel_y(nBodies), vel_z(nBodies))
1385+ allocate (omega_x(nBodies), omega_y(nBodies), omega_z(nBodies))
1386+ allocate (angle_x(nBodies), angle_y(nBodies), angle_z(nBodies))
1387+ allocate (ib_diameter(nBodies))
13871388
1388- if (proc_rank == 0) then
13891389 open (newunit=file_unit, file=trim(file_loc), form=' unformatted' , access=' stream' , status=' old' , iostat=ios)
13901390 if (ios /= 0) call s_mpi_abort(' Cannot open IB state file: ' // trim(file_loc))
13911391
@@ -1430,12 +1430,12 @@ contains
14301430 call s_write_ib_variable(' ib_angle_y' , t_step, angle_y, nBodies)
14311431 call s_write_ib_variable(' ib_angle_z' , t_step, angle_z, nBodies)
14321432 call s_write_ib_variable(' ib_diameter' , t_step, ib_diameter, nBodies)
1433- end if
14341433
1435- deallocate (ib_data, px, py, pz, force_x, force_y, force_z)
1436- deallocate (torque_x, torque_y, torque_z, vel_x, vel_y, vel_z)
1437- deallocate (omega_x, omega_y, omega_z, angle_x, angle_y, angle_z)
1438- deallocate (ib_diameter)
1434+ deallocate (ib_data, px, py, pz, force_x, force_y, force_z)
1435+ deallocate (torque_x, torque_y, torque_z, vel_x, vel_y, vel_z)
1436+ deallocate (omega_x, omega_y, omega_z, angle_x, angle_y, angle_z)
1437+ deallocate (ib_diameter)
1438+ end if
14391439 end if
14401440#endif
14411441
0 commit comments