Skip to content

Commit

Permalink
fix issue 59 | samples_from_md should only be used for MDs (#60)
Browse files Browse the repository at this point in the history
* require infile.sim.hdf5 with velocities
* fail when number of requested samples is larger than number of samples
  • Loading branch information
flokno authored Apr 24, 2024
1 parent 5fa195a commit b78bbd2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libolle/gottochblandat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,8 @@ subroutine lo_stop_gracefully(msg,exitcode,filename,line)
write(*,*) 'exit code 7: MPI error'
case(8)
write(*,*) 'exit code 8: Feature removed'
case(9)
write(*,*) 'exit code 9: Bad inputs.'
end select
write(*,*) ''
do i=1,size(msg)
Expand Down
12 changes: 11 additions & 1 deletion src/samples_from_md/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ program samples_from_md
! Seed random numbers
call tw%init(iseed=0, rseed=walltime())
! Get simulation
call sim%read_from_file(verbosity=1)
call sim%read_from_hdf5('infile.sim.hdf5', verbosity=1)

! Stop when velocities are not present
if (.not. allocated(sim%v)) then
call lo_stop_gracefully(['No velocities present in the simulation. Is this an MD?'], 9)
end if

! Check if the number of samples is not too large
if (opts%n .gt. sim%nt) then
call lo_stop_gracefully(['Number of samples is larger than the number of timesteps in the simulation.'], 9)
end if

! List of all the samples
allocate (indices(sim%nt))
Expand Down
Binary file modified tests/infiles/infile.sim.hdf5
Binary file not shown.

0 comments on commit b78bbd2

Please sign in to comment.