program cclite_main use ccl_case_types, only: CCL_Case_Type, ccl_case_print_summary use ccl_controller, only: ccl_controller_run_empty_coupling use ccl_errors, only: CCL_SUCCESS, CCL_ERROR_INPUT_MISSING_ARGUMENT use ccl_inp_parser, only: ccl_case_read use ccl_log, only: ccl_log_info, ccl_log_error use ccl_version, only: ccl_print_version implicit none integer :: argc integer :: exit_code character(len=128) :: command argc = command_argument_count() exit_code = CCL_SUCCESS if (argc == 0) then call print_help() call exit(CCL_SUCCESS) end if call get_command_argument(1, command) command = adjustl(command) select case (trim(command)) case ("--help", "-h", "help") call print_help() case ("--version", "-v", "version") call ccl_print_version() case ("check") exit_code = handle_mode("check", argc) case ("dry-run") exit_code = handle_mode("dry-run", argc) case ("run") exit_code = handle_mode("run", argc) case default call ccl_log_error("app", "unknown command: " // trim(command)) call print_help() exit_code = CCL_ERROR_INPUT_MISSING_ARGUMENT end select call exit(exit_code) contains integer function handle_mode(mode, argc_value) result(ierr) character(len=*), intent(in) :: mode integer, intent(in) :: argc_value character(len=512) :: input_file character(len=512) :: errmsg type(CCL_Case_Type) :: ccl_case if (argc_value < 2) then call ccl_log_error("app", trim(mode) // " requires a CCLite .inp file") ierr = CCL_ERROR_INPUT_MISSING_ARGUMENT return end if call get_command_argument(2, input_file) call ccl_log_info("app", trim(mode) // " mode reading input: " // trim(input_file)) call ccl_case_read(trim(input_file), ccl_case, ierr, errmsg) if (ierr /= CCL_SUCCESS) then call ccl_log_error("case", trim(errmsg)) return end if call ccl_case_print_summary(ccl_case) if (trim(mode) == "check") then ierr = CCL_SUCCESS return end if ierr = ccl_controller_run_empty_coupling(ccl_case, trim(input_file)) end function handle_mode subroutine print_help() print '(a)', "CCLite 0.1.x" print '(a)', "Usage:" print '(a)', " cclite --help" print '(a)', " cclite --version" print '(a)', " cclite check " print '(a)', " cclite dry-run " print '(a)', " cclite run " end subroutine print_help end program cclite_main