integer function cla_command_argument_count() ! Define these wrappers for these intrinsic functions because we want to implement ! a cla parser that can work with plain strings, read from stdin for example, ! not just from the command line. ! The purpose is to easily adapt a program that runs using command line inputs into ! a program that can run with string input it eats from a pipe. implicit none CHARACTER(len=CLALEN) :: outs INTEGER :: i, k, n if (cla_cla_len == 0) then cla_command_argument_count = command_argument_count() else ! Count number of spaces to get ! number of parameters minus 1: cla_command_argument_count = 0 ! Now count arguments: ! write(*,*) 'Counting arguments in :',trim(cla_cla) cla_cla_len = len_trim(cla_cla) if (cla_cla_len == 0) then return end if do i=1,cla_cla_len if (cla_cla(i:i) == ' ') then cla_command_argument_count = cla_command_argument_count + 1 end if end do cla_command_argument_count = cla_command_argument_count + 1 ! write(*,*) 'cla_command_argument_count found ',cla_command_argument_count end if end function cla_command_argument_count