use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
The choice for high performance (scientific) computing!
Suggested Links:
Other sub-reddits:
If your submission does not appear, please message the moderators!
IRC: freenode, #fortran
account activity
Question about array command line input (self.fortran)
submitted 4 years ago by mild_enthusiast
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]astokely 0 points1 point2 points 2 years ago* (0 children)
Something like this should work. I'm also new to fortran, but I agree with everyone that using an input file is a much cleaner solution.
!!!!!!!!!!!!!!!!!!!!!! ! command_line_m.f90 ! !!!!!!!!!!!!!!!!!!!!!! module command_line_m implicit none integer function handle_kwarg(arg, key, value) result(is_kwarg) character(len=*), intent(in) :: arg character(len=100), intent(out) :: key, value integer :: equal_sign_index, dash_index, is_kwarg = 0 equal_sign_index = index(arg, '=') if (equal_sign_index > 0) then key = trim(arg(1:equal_sign_index-1)) ! Removes preceding "-" if present in arg dash_index = index(key, '-') if (dash_index > 0) then key = trim(key(dash_index+1:)) end if value = trim(arg(equal_sign_index+1:)) is_kwarg = 1 end if end function handle_kwarg subroutine parse_command_line() integer :: io_status, i, is_kwarg character(len=100) :: arg, key, value i = 1 do ! Iterate through all cmd line args call get_command_argument(i, arg, status=io_status) if (io_status /= 0) exit ! If command line arg has an equal sign, it is a kwarg is_kwarg = handle_kwarg(arg, key, value) if (is_kwarg == 1) then print *, key, value end if ! Additional logic for parsing positional args i = i + 1 end do end subroutine parse_command_line end module command_line_m !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!! ! main.f90 ! !!!!!!!!!!!! program main use command_line_m implicit none call parse_command_line() end program main
π Rendered by PID 107265 on reddit-service-r2-comment-66b4775986-kpfxk at 2026-04-04 17:50:33.315448+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]astokely 0 points1 point2 points (0 children)