program main !**************************** CACmb ******************************* !* CAC model building toolkit * ! ____________ * ! / / * ! / / * ! /___________/ * ! _|_ _|_ _|____________ * ! / / * ! / / * ! /___________/ * ! * !******************************************************************* use parameters use elements use io integer :: i, end_mode_arg, arg_num, arg_pos character(len=100) :: argument !Call initialization functions call lattice_init call box_init end_mode_arg = 0 ! Command line parsing arg_num = command_argument_count() !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, argument) argument = trim(adjustl(argument)) if (argument(1:2) == '--') then call call_mode(end_mode_arg, argument) end if !Check to make sure a mode was called if (end_mode_arg==0) then stop "Nothing to do, please run cacmb using an available mode" end if !Now we loop through all of the arguments and check for passed options or for a filename to be written out arg_pos = end_mode_arg do while(.true.) !Exit the loop if we are done reading if(arg_pos > arg_num) exit call get_command_argument(arg_pos, argument) !Check to see if a filename was passed if(scan(argument,'.',.true.) > 0) then call get_out_file(argument) arg_pos = arg_pos + 1 !Check to see if an option has been passed else if(argument(1:1) == '-') then call call_option(argument, arg_pos) !Otherwise print that the argument is not accepted and move on else print *, trim(adjustl(argument)), " is not accepted. Skipping to next argument" arg_pos = arg_pos + 1 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