diff --git a/src/call_mode.f90 b/src/call_mode.f90 index f571520..fb187c1 100644 --- a/src/call_mode.f90 +++ b/src/call_mode.f90 @@ -1,4 +1,4 @@ -subroutine call_mode(arg_num,mode) +subroutine call_mode(arg_pos,mode) !This code is used to parse the command line argument for the mode information and calls the required !mode module. @@ -9,16 +9,16 @@ subroutine call_mode(arg_num,mode) implicit none - integer, intent(in) :: arg_num + integer, intent(out) :: arg_pos character(len=100), intent(in) :: mode select case(mode) case('--create') - call create + call create(arg_pos) case('--convert') - call convert + call convert(arg_pos) case('--merge') - call merge + call merge(arg_pos) case default print *, "Mode ", trim(adjustl(mode)), " currently not accepted. Please check documentation for ", & "accepted modes and rerun." diff --git a/src/main.f90 b/src/main.f90 index c7ac008..a681d33 100644 --- a/src/main.f90 +++ b/src/main.f90 @@ -17,8 +17,8 @@ program main use io - integer :: arg_num - character(len=100) :: mode + integer :: i, end_mode_arg, arg_num + character(len=100) :: argument !Call initialization functions call lattice_init @@ -29,13 +29,29 @@ program main !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 - call get_command_argument(1, mode) + call get_command_argument(1, argument) - mode = trim(adjustl(mode)) - if (mode(1:2) == '--') then - call call_mode(arg_num, mode) + argument = trim(adjustl(argument)) + if (argument(1:2) == '--') then + call call_mode(end_mode_arg, argument) end if - !Finish by writing the files + !Now we loop through all of the arguments and check for passed options or for a filename to be written out + do i = end_mode_arg-1, arg_num + call get_command_argument(i, argument) + + !Check to see if a filename was passed + if(scan(argument,'.',.true.) > 0) then + call get_out_file(argument) + end if + end do + + !Check to make sure a file was passed to be written out and then write out + ! Before building do a check on the file + if (outfilenum == 0) then + argument = 'none' + call get_out_file(argument) + end if call write_out + end program main \ No newline at end of file diff --git a/src/mode_convert.f90 b/src/mode_convert.f90 index d6e1d9b..1f8a6bd 100644 --- a/src/mode_convert.f90 +++ b/src/mode_convert.f90 @@ -8,8 +8,9 @@ module mode_convert public contains - subroutine convert + subroutine convert(arg_pos) !This subroutine converts a single input file from one format to another + integer, intent(out) :: arg_pos 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 @@ -19,10 +20,7 @@ module mode_convert 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) + arg_pos = 3 end subroutine convert end module mode_convert \ No newline at end of file diff --git a/src/mode_create.f90 b/src/mode_create.f90 index 08e201a..23b9100 100644 --- a/src/mode_create.f90 +++ b/src/mode_create.f90 @@ -21,11 +21,12 @@ module mode_create public contains - subroutine create() + subroutine create(arg_pos) ! Main subroutine which controls execution character(len=100) :: textholder - + integer, intent(out) :: arg_pos + integer :: i, ibasis, inod real(kind=dp), allocatable :: r_node_temp(:,:,:) @@ -45,14 +46,8 @@ module mode_create lat_atom_num = 0 !First we parse the command - call parse_command() + call parse_command(arg_pos) - ! Before building do a check on the file - if (outfilenum == 0) then - textholder = 'none' - call get_out_file(textholder) - end if - !Now we setup the unit element and call other init subroutines call def_ng_node(1, element_type) @@ -161,10 +156,10 @@ module mode_create sub_box_array_bd(2,2,1) = ele_num end subroutine create !This subroutine parses the command and pulls out information needed for mode_create - subroutine parse_command() + subroutine parse_command(arg_pos) - - integer :: arg_pos, ori_pos, i, j, arglen, stat + integer, intent(out) :: arg_pos + integer :: ori_pos, i, j, arglen, stat character(len=100) :: textholder character(len=8) :: orient_string @@ -245,20 +240,10 @@ module mode_create read(textholder, *) origin(i) arg_pos = arg_pos + 1 end do - !If a filetype is passed then we add name.ext to the outfiles list - case('xyz') - textholder = trim(adjustl(name)) //'.xyz' - call get_out_file(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 + !If it isn't an option then you have to exit + exit end select end do diff --git a/src/mode_merge.f90 b/src/mode_merge.f90 index 0919b70..ca9d068 100644 --- a/src/mode_merge.f90 +++ b/src/mode_merge.f90 @@ -12,13 +12,14 @@ module mode_merge public contains - subroutine merge + subroutine merge(arg_pos) + integer, intent(out) :: arg_pos integer :: i real(kind=dp) :: displace(3), temp_box_bd(6) !First we parse the merge command - call parse_command + call parse_command(arg_pos) !Now loop over all files and stack them do i = 1, in_num @@ -44,10 +45,12 @@ module mode_merge return end subroutine merge - subroutine parse_command + subroutine parse_command(arg_pos) + + integer, intent(out) :: arg_pos character(len=100) :: textholder - integer :: i, stat, arglen, arg_pos + integer :: i, stat, arglen !Get dimension to concatenate along call get_command_argument(2, dim, arglen) @@ -88,13 +91,8 @@ module mode_merge 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 + !If it isn't an available option to mode merge then we just exit + exit end select end do