Unit test routine for the vector_module.
subroutine vector_test() implicit none integer :: i real(wp) :: theta real(wp),dimension(3) :: v,k,v2,v3 real(wp),dimension(3,3) :: rotmat write(*,*) '' write(*,*) '---------------' write(*,*) ' vector_test' write(*,*) '---------------' write(*,*) '' v = [1.2_wp, 3.0_wp, -5.0_wp] k = [-0.1_wp, 16.2_wp, 2.1_wp] theta = 0.123_wp call axis_angle_rotation(v,k,theta,v2) call axis_angle_rotation_to_rotation_matrix(k,theta,rotmat) v3 = matmul(rotmat,v) write(*,*) 'Single test:' write(*,*) '' write(*,*) ' v1 :', v write(*,*) ' v2 :', v2 write(*,*) ' v3 :', v3 write(*,*) ' Error:', v3-v2 write(*,*) '' write(*,*) '0-360 test:' write(*,*) '' do i=0,360,10 theta = i * 180.0_wp/pi call axis_angle_rotation(v,k,theta,v2) call axis_angle_rotation_to_rotation_matrix(k,theta,rotmat) v3 = matmul(rotmat,v) write(*,*) 'Error:', norm2(v3-v2) end do !z-axis rotation test: theta = pi / 4.0_wp v = [one/cos(theta), 0.0_wp, 0.0_wp] rotmat = rotation_matrix(z_axis,theta) v2 = matmul(rotmat,v) write(*,*) v2 !should be [1, -1, 0] end subroutine vector_test