process_readall(3f) - [M_process] read all lines from process into single string (LICENSE:PD)
Synopsis
Options
Results
Examples
See Also
Author
License
syntax:
function process_readall(cmd,delim,ierr) result(string)character(len=*),intent(in) :: cmd character(len=*),intent(in),optional :: delim integer,intent(out),optional :: ierr character(len=:),allocatable :: string
cmd command to pass to system delim delimiter to place between output lines when they are concatenated. Defaults to a space ierr check status of call.
process_readall Assuming sufficient memory is available all the output of the system command are concatenated into a string with spaces added between the output lines of the command.
Read all output of a command to a single string
program demo_process_readall use M_process, only: process_readall implicit none integer :: ierr character(len=:),allocatable :: string string=process_readall(ls,ierr=ierr) write(*,*)ierr,string end program demo_process_readallResults:
app build docs example fpm.toml LICENSE man README.md src testRead all output of a command to an array using split(3f)
program test_process_readall use M_process ,only: process_readall use M_strings ,only: split implicit none integer :: ierr integer :: i character(len=:),allocatable :: string character(len=:),allocatable :: array(:) string=process_readall(ls,delim=NEW_LINE("A"),ierr=ierr) call split(string,array,delimiters=NEW_LINE("A")) do i=1,size(array) write(*,(i0,t10,"[",a,"]"))i,trim(array(i)) enddo write(*,*)string=process_readall(& & ls,delim=NEW_LINE("A"),ierr=ierr) write(*,*)string end program test_process_readallResults:
> 1 [Articles] > 2 [LIBRARY] > 3 [PC] > 4 [SHIP] > 5 [SPEC] > 6 [crib.dat] > 7 [doc] > 8 [html] > 9 [index.html] > 10 [plan.txt] > 11 [questions] > 12 [scripts] > 13 [tmp]
M_process(3fm)
John S. Urban
Public Domain
Nemo Release 3.1 | process_readall (3) | February 23, 2025 |