Added -ow option which allows for automatic overwriting

master
Alex Selimov 5 years ago
parent 9ebdfff0a1
commit a942b8e2a1

@ -218,3 +218,11 @@ remesh esize
``` ```
This command remeshes the atoms/elements within the group to the new element size `esize`. Currently only accepts an `esize` of 2 which refines it to full atomistics. This command remeshes the atoms/elements within the group to the new element size `esize`. Currently only accepts an `esize` of 2 which refines it to full atomistics.
### Option overwrite
```
-ow
```
If this option is passed then all files are automatically overwritten without asking the user.

@ -12,7 +12,11 @@ subroutine call_option(option, arg_pos)
call dislocation(option, arg_pos) call dislocation(option, arg_pos)
case('-group') case('-group')
call group(arg_pos) call group(arg_pos)
case('-ow')
arg_pos = arg_pos + 1
continue
case default case default
print *, 'Option ', trim(adjustl(option)), ' is not currently accepted.' print *, 'Option ', trim(adjustl(option)), ' is not currently accepted. Skipping to next argument'
arg_pos = arg_pos + 1
end select end select
end subroutine call_option end subroutine call_option

@ -9,7 +9,7 @@ module io
integer :: outfilenum = 0, infilenum = 0 integer :: outfilenum = 0, infilenum = 0
character(len=100) :: outfiles(10), infiles(10) character(len=100) :: outfiles(10), infiles(10)
logical :: force_overwrite
public public
contains contains
@ -38,7 +38,7 @@ module io
!Check to see if file exists, if it does then ask user if they would like to overwrite the file !Check to see if file exists, if it does then ask user if they would like to overwrite the file
inquire(file=trim(temp_outfile), exist=file_exists) inquire(file=trim(temp_outfile), exist=file_exists)
if (file_exists) then if (file_exists.and.(.not.(force_overwrite))) then
if (overwrite == 'r') print *, "File ", trim(temp_outfile), " already exists. Would you like to overwrite? (Y/N)" if (overwrite == 'r') print *, "File ", trim(temp_outfile), " already exists. Would you like to overwrite? (Y/N)"
read(*,*) overwrite read(*,*) overwrite
if((scan(overwrite, "n") > 0).or.(scan(overwrite, "N") > 0)) then if((scan(overwrite, "n") > 0).or.(scan(overwrite, "N") > 0)) then

@ -37,11 +37,23 @@ program main
!Call initialization functions !Call initialization functions
call lattice_init call lattice_init
call box_init call box_init
force_overwrite=.false.
end_mode_arg = 0 end_mode_arg = 0
! Command line parsing ! Command line parsing
arg_num = command_argument_count() arg_num = command_argument_count()
!Check to see if overwrite flag is passed
do i = 1, arg_num
call get_command_argument(i,argument)
select case(trim(adjustl(argument)))
case('-ow')
force_overwrite = .true.
print *, "Overwrite flag passed, output files will be overwritten"
end select
end do
!Determine if a mode is being used and what it is. The first argument has to be the mode !Determine if a mode is being used and what it is. The first argument has to be the mode
!if a mode is being used !if a mode is being used
call get_command_argument(1, argument) call get_command_argument(1, argument)

Loading…
Cancel
Save