commit
95060bc0d9
@ -0,0 +1,75 @@
|
||||
module box
|
||||
!This module contains information on the properties of the current box.
|
||||
use parameters
|
||||
|
||||
implicit none
|
||||
|
||||
real(kind=dp) :: box_bd(6) !Global box boundaries
|
||||
|
||||
!The subbox variables contain values for each subbox, being the boxes read in through some
|
||||
!command. Currently only mode_merge will require sub_boxes, for mode_create it will always
|
||||
!allocate to only 1 sub_box
|
||||
integer :: sub_box_num = 0
|
||||
integer, allocatable :: sub_box_array_bd(:,:,:)!Boundaries in the atom and element arrays for each sub_box
|
||||
real(kind=dp), allocatable :: sub_box_ori(:,:,:)!Orientations for each of the subboxes
|
||||
real(kind=dp), allocatable :: sub_box_bd(:,:)!Boundaries for each of the sub_boxes
|
||||
|
||||
public
|
||||
contains
|
||||
|
||||
subroutine box_init
|
||||
!Initialize some box functions
|
||||
box_bd(:) = 0.0_dp
|
||||
end subroutine box_init
|
||||
|
||||
subroutine alloc_sub_box(n)
|
||||
!Allocate the sub_box variables
|
||||
|
||||
integer, intent(in) :: n
|
||||
|
||||
allocate(sub_box_ori(3,3,n), sub_box_bd(6,n), sub_box_array_bd(2,2,n))
|
||||
|
||||
end subroutine alloc_sub_box
|
||||
|
||||
subroutine grow_sub_box(n)
|
||||
!Grows sub box arrays, this is only called when a new file is read in
|
||||
integer, intent(in) :: n
|
||||
|
||||
integer, allocatable :: temp_array_bd(:,:,:), temp_file(:)
|
||||
real(kind=dp), allocatable :: temp_ori(:,:,:), temp_bd(:,:)
|
||||
!Allocate temporary arrays
|
||||
allocate(temp_ori(3,3,sub_box_num+n),temp_bd(6,sub_box_num+n), &
|
||||
temp_array_bd(2,2,sub_box_num+n), temp_file(sub_box_num+n))
|
||||
|
||||
!Move allocation for all sub_box_arrays
|
||||
temp_ori(:,:,1:sub_box_num) = sub_box_ori
|
||||
temp_ori(:,:,sub_box_num+1:) = 0.0_dp
|
||||
call move_alloc(temp_ori, sub_box_ori)
|
||||
|
||||
temp_bd(:, 1:sub_box_num) = sub_box_bd
|
||||
temp_bd(:, sub_box_num+1:) = 0.0_dp
|
||||
call move_alloc(temp_bd, sub_box_bd)
|
||||
|
||||
temp_array_bd(:,:,1:sub_box_num) = sub_box_array_bd
|
||||
temp_array_bd(:,:,sub_box_num+1:) = 0.0_dp
|
||||
call move_alloc(temp_array_bd, sub_box_array_bd)
|
||||
|
||||
return
|
||||
end subroutine grow_sub_box
|
||||
|
||||
subroutine grow_box(temp_box_bd)
|
||||
!This function takes in a temporary box boundary and adjusts the overall box boundaries
|
||||
!to include it
|
||||
|
||||
real(kind=dp), dimension(6), intent(in) :: temp_box_bd
|
||||
|
||||
integer :: i
|
||||
|
||||
do i = 1, 3
|
||||
if(temp_box_bd(2*i-1) < box_bd(2*i-1)) box_bd(2*i-1) = temp_box_bd(2*i-1)
|
||||
if(temp_box_bd(2*i) > box_bd(2*i)) box_bd(2*i) = temp_box_bd(2*i)
|
||||
end do
|
||||
return
|
||||
end subroutine grow_box
|
||||
|
||||
end module box
|
@ -0,0 +1,28 @@
|
||||
module mode_convert
|
||||
|
||||
use parameters
|
||||
use box
|
||||
use elements
|
||||
use io
|
||||
|
||||
public
|
||||
contains
|
||||
|
||||
subroutine convert
|
||||
!This subroutine converts a single input file from one format to another
|
||||
character(len=100) :: infile, outfile
|
||||
real(kind = dp) :: temp_box_bd(6)
|
||||
!We have to allocate the element and atom arrays with a size of 1 for the read in code to work
|
||||
call alloc_ele_arrays(1,1)
|
||||
!First read in the file
|
||||
call get_command_argument(2, infile)
|
||||
call get_in_file(infile)
|
||||
call read_in(1, (/0.0_dp,0.0_dp,0.0_dp/), temp_box_bd)
|
||||
call grow_box(temp_box_bd)
|
||||
|
||||
!Now get the outfile, writing is done after all the codes complete
|
||||
call get_command_argument(3, outfile)
|
||||
call get_out_file(outfile)
|
||||
|
||||
end subroutine convert
|
||||
end module mode_convert
|
@ -0,0 +1,102 @@
|
||||
module mode_merge
|
||||
!This module contains the code needed for merging several .mb files together
|
||||
|
||||
use parameters
|
||||
use atoms
|
||||
use io
|
||||
use subroutines
|
||||
use elements
|
||||
|
||||
character(len=4) :: dim
|
||||
integer :: in_num
|
||||
|
||||
public
|
||||
contains
|
||||
subroutine merge
|
||||
|
||||
integer :: i
|
||||
real(kind=dp) :: displace(3), temp_box_bd(6)
|
||||
|
||||
!First we parse the merge command
|
||||
call parse_command
|
||||
|
||||
!Now loop over all files and stack them
|
||||
do i = 1, in_num
|
||||
displace(:) = 0.0_dp
|
||||
if ((i==1).or.(trim(adjustl(dim)) == 'none')) then
|
||||
call read_in(i, displace, temp_box_bd)
|
||||
call grow_box(temp_box_bd)
|
||||
else
|
||||
select case(trim(adjustl(dim)))
|
||||
case('x')
|
||||
displace(1) = box_bd(2)
|
||||
case('y')
|
||||
displace(2) = box_bd(4)
|
||||
case('z')
|
||||
displace(3) = box_bd(6)
|
||||
end select
|
||||
|
||||
call read_in(i, displace, temp_box_bd)
|
||||
call grow_box(temp_box_bd)
|
||||
end if
|
||||
end do
|
||||
|
||||
return
|
||||
end subroutine merge
|
||||
|
||||
subroutine parse_command
|
||||
|
||||
character(len=100) :: textholder
|
||||
integer :: i, stat, arglen, arg_pos
|
||||
|
||||
!Get dimension to concatenate along
|
||||
call get_command_argument(2, dim, arglen)
|
||||
if (arglen == 0) STOP "Missing dim in mode_merge command"
|
||||
select case(trim(adjustl(dim)))
|
||||
case('x','y','z','none')
|
||||
continue
|
||||
case default
|
||||
print *, dim, " not accepted as a dimension in mode_merge"
|
||||
stop 3
|
||||
end select
|
||||
!Get number of files to read in
|
||||
call get_command_argument(3, textholder, arglen)
|
||||
if (arglen == 0) STOP "Number of files to read missing in mode_merge command"
|
||||
read(textholder, *, iostat = stat) in_num
|
||||
if (stat > 0) STOP "Error reading number of files in, must be integer"
|
||||
|
||||
!Now loop and pull out all files
|
||||
do i = 1, in_num
|
||||
call get_command_argument(3+i, textholder, arglen)
|
||||
if (arglen == 0) STOP "Fewer files to read in then specified"
|
||||
!Make sure this file is readable
|
||||
call get_in_file(textholder)
|
||||
end do
|
||||
|
||||
!Set argpos accordingly
|
||||
arg_pos = 3+in_num+1
|
||||
!Now options loop
|
||||
!Check for optional keywords
|
||||
do while(.true.)
|
||||
if(arg_pos > command_argument_count()) exit
|
||||
!Pull out the next argument which should either be a keyword or an option
|
||||
call get_command_argument(arg_pos, textholder)
|
||||
textholder=adjustl(textholder)
|
||||
arg_pos=arg_pos+1
|
||||
|
||||
!Choose what to based on what the option string is
|
||||
select case(trim(textholder))
|
||||
|
||||
case default
|
||||
!Check to see if it is an option command, if so then mode_create must be finished
|
||||
if(textholder(1:1) == '-') then
|
||||
exit
|
||||
!Check to see if a filename was passed
|
||||
elseif(scan(textholder,'.',.true.) > 0) then
|
||||
call get_out_file(textholder)
|
||||
end if
|
||||
end select
|
||||
end do
|
||||
|
||||
end subroutine parse_command
|
||||
end module mode_merge
|
Loading…
Reference in new issue