Prepare SPHLite 0.2.0 development baseline
This commit is contained in:
@@ -2,7 +2,8 @@ module sph_output_csv
|
||||
use sph_precision, only: rk
|
||||
use sph_error, only: SPH_SUCCESS, SPH_ERROR_ARGUMENT, SPH_ERROR_IO, sph_error_set
|
||||
use sph_control, only: output_directory, output_interval
|
||||
use sph_database, only: npart, particle_id_ext, x, v
|
||||
use sph_database, only: npart, particle_id_ext, particle_phase, particle_status, &
|
||||
material_id, section_id, x, v, rho, pressure, temperature
|
||||
implicit none
|
||||
|
||||
integer, parameter :: SPH_OUTPUT_UNIT = 41
|
||||
@@ -50,12 +51,25 @@ contains
|
||||
return
|
||||
end if
|
||||
|
||||
write(SPH_OUTPUT_UNIT, '(A)') 'id,x,y,z,vx,vy,vz'
|
||||
write(SPH_OUTPUT_UNIT, '(A)') &
|
||||
'id,phase,status,material,section,x,y,z,vx,vy,vz,rho,pressure,temperature'
|
||||
do i = 1, npart
|
||||
write(SPH_OUTPUT_UNIT, '(I0,6(",",ES24.16))') particle_id_ext(i), &
|
||||
x(1,i), x(2,i), x(3,i), v(1,i), v(2,i), v(3,i)
|
||||
write(SPH_OUTPUT_UNIT, '(5(I0,","),6(ES24.16,","),3(ES24.16,:,","))') &
|
||||
particle_id_ext(i), particle_phase(i), particle_status(i), &
|
||||
material_id(i), section_id(i), x(1,i), x(2,i), x(3,i), &
|
||||
v(1,i), v(2,i), v(3,i), rho(i), pressure(i), temperature(i)
|
||||
end do
|
||||
close(unit=SPH_OUTPUT_UNIT)
|
||||
end subroutine sph_output_write_csv
|
||||
|
||||
subroutine sph_output_write_step(step, time, ierr)
|
||||
integer, intent(in) :: step
|
||||
real(rk), intent(in) :: time
|
||||
integer, intent(out) :: ierr
|
||||
character(len=1024) :: filename
|
||||
|
||||
write(filename, '(A,"/sphlite_",I8.8,".csv")') trim(output_directory), step
|
||||
call sph_output_write_csv(filename, ierr)
|
||||
end subroutine sph_output_write_step
|
||||
|
||||
end module sph_output_csv
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module sph_restart
|
||||
use sph_precision, only: rk
|
||||
use sph_precision, only: rk, SPH_VERSION_MAJOR, SPH_VERSION_MINOR, SPH_VERSION_PATCH
|
||||
use sph_error, only: SPH_SUCCESS, SPH_ERROR_IO, SPH_ERROR_INPUT, sph_error_set
|
||||
use sph_control, only: current_time, current_step
|
||||
use sph_control, only: current_time, current_step, output_interval, output_directory
|
||||
use sph_database, only: npart, sph_db_allocate, particle_id_ext, particle_phase, &
|
||||
particle_status, material_id, section_id, x0, x, v, a, vhalf, mass, rho, &
|
||||
volume, pressure, internal_energy, temperature, h
|
||||
@@ -26,8 +26,11 @@ contains
|
||||
return
|
||||
end if
|
||||
|
||||
write(SPH_RESTART_UNIT, '(A)') 'SPHLITE_RESTART 0.1.0'
|
||||
write(SPH_RESTART_UNIT, '(A,1X,I0,1X,I0,1X,I0,1X,A)') 'SPHLITE_RESTART', &
|
||||
SPH_VERSION_MAJOR, SPH_VERSION_MINOR, SPH_VERSION_PATCH, 'STATE_0_1'
|
||||
write(SPH_RESTART_UNIT, *) current_time, current_step, npart
|
||||
write(SPH_RESTART_UNIT, *) output_interval
|
||||
write(SPH_RESTART_UNIT, '(A)') trim(output_directory)
|
||||
do i = 1, npart
|
||||
write(SPH_RESTART_UNIT, *) particle_id_ext(i), particle_phase(i), &
|
||||
particle_status(i), material_id(i), section_id(i)
|
||||
@@ -42,7 +45,10 @@ contains
|
||||
character(len=*), intent(in) :: filename
|
||||
integer, intent(out) :: ierr
|
||||
character(len=64) :: tag
|
||||
character(len=32) :: version
|
||||
integer :: major
|
||||
integer :: minor
|
||||
integer :: patch
|
||||
character(len=32) :: state_version
|
||||
integer :: ios
|
||||
integer :: count
|
||||
integer :: i
|
||||
@@ -56,7 +62,7 @@ contains
|
||||
return
|
||||
end if
|
||||
|
||||
read(SPH_RESTART_UNIT, *, iostat=ios) tag, version
|
||||
read(SPH_RESTART_UNIT, *, iostat=ios) tag, major, minor, patch, state_version
|
||||
if (ios /= 0 .or. trim(tag) /= 'SPHLITE_RESTART') then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'invalid restart header')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
@@ -71,6 +77,20 @@ contains
|
||||
close(unit=SPH_RESTART_UNIT)
|
||||
return
|
||||
end if
|
||||
read(SPH_RESTART_UNIT, *, iostat=ios) output_interval
|
||||
if (ios /= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'invalid restart output interval')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
close(unit=SPH_RESTART_UNIT)
|
||||
return
|
||||
end if
|
||||
read(SPH_RESTART_UNIT, '(A)', iostat=ios) output_directory
|
||||
if (ios /= 0) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'invalid restart output directory')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
close(unit=SPH_RESTART_UNIT)
|
||||
return
|
||||
end if
|
||||
call sph_db_allocate(count, ierr)
|
||||
if (ierr /= SPH_SUCCESS) then
|
||||
close(unit=SPH_RESTART_UNIT)
|
||||
|
||||
Reference in New Issue
Block a user