Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=LINE_SIZ), | intent(in) | :: | header | |||
character(len=LINE_SIZ), | intent(in) | :: | usage(:) | |||
character(len=*), | intent(in) | :: | choice | |||
character(len=CMD_SIZ), | intent(in) | :: | cmd(:) | |||
character(len=CMD_DESC_SIZ), | intent(in) | :: | cmd_desc(:) | |||
character(len=LINE_SIZ), | intent(in), | optional | :: | desc(:) |
subroutine generate_and_output(header, usage, choice, cmd, cmd_desc, desc) implicit none character(LINE_SIZ), intent(in) :: header character(LINE_SIZ), intent(in) :: usage(:) character(*), intent(in) :: choice character(CMD_SIZ), intent(in) :: cmd(:) ! command character(CMD_DESC_SIZ), intent(in) :: cmd_desc(:) ! description character(LINE_SIZ), intent(in), optional :: desc(:) character(LINE_SIZ), allocatable :: buff(:) integer :: num_line, i, offset if (present(desc)) then num_line = 3 + size(desc) + size(usage) + 2 + size(cmd) else num_line = 3 + size(usage) + 2 + size(cmd) end if ! header + blank + DESC + blank+ USAGE + size(usage) + blank + COMMANDS + size(cmd) allocate(buff(num_line)) buff(:) = "" buff(1) = header ! buff(2) blank offset = 2 if (present(desc)) then do i = 1, size(desc) buff(i+offset) = desc(i) end do offset = offset + size(desc) endif offset = offset + 1 buff(offset) = "USAGE:" do i = 1, size(usage) buff(i+offset) = " "//trim(usage(i)) end do offset = offset + size(usage) buff(offset+2) = trim(choice)//":" offset = offset + 2 do i = 1, size(cmd) buff(i+offset) = " "//cmd(i)//" "//cmd_desc(i) enddo do i = 1, num_line write(stderr, fmta) trim(buff(i)) end do stop end subroutine generate_and_output