diff --git a/pages/tutorial/dependencies.md b/pages/tutorial/dependencies.md index e2440e052..9caf67cd5 100644 --- a/pages/tutorial/dependencies.md +++ b/pages/tutorial/dependencies.md @@ -32,10 +32,6 @@ The implementation is shown here :caption: src/demo.f90 ``` -:::{note} -To work with deferred length characters we added a small helper function to read a whole line. -::: - Finally, we need a command line driver to make use of our new function. ```{code-block} fortran diff --git a/src/tutorial/dependencies/src/demo.f90 b/src/tutorial/dependencies/src/demo.f90 index 020e8d176..71c4f9c40 100644 --- a/src/tutorial/dependencies/src/demo.f90 +++ b/src/tutorial/dependencies/src/demo.f90 @@ -1,10 +1,10 @@ module demo + use stdlib_io, only : getline use stdlib_strings, only : replace_all implicit none private public :: substitute - public :: getline contains @@ -29,34 +29,4 @@ subroutine substitute(input, output, pattern, replacement) end do end subroutine substitute - !> Read a whole line from a formatted unit into a deferred length character variable - subroutine getline(unit, line, iostat, iomsg) - !> Formatted IO unit - integer, intent(in) :: unit - !> Line to read - character(len=:), allocatable, intent(out) :: line - !> Status of operation - integer, intent(out) :: iostat - !> Error message - character(len=:), allocatable, optional :: iomsg - - integer, parameter :: bufsize = 512 - character(len=bufsize) :: buffer, msg - integer :: chunk, stat - - allocate(character(len=0) :: line) - do - read(unit, '(a)', advance='no', iostat=stat, iomsg=msg, size=chunk) buffer - if (stat > 0) exit - line = line // buffer(:chunk) - if (stat < 0) then - if (is_iostat_eor(stat)) stat = 0 - exit - end if - end do - - if (stat /= 0 .and. present(iomsg)) iomsg = trim(msg) - iostat = stat - end subroutine getline - end module demo diff --git a/src/tutorial/dependencies/test/main.f90 b/src/tutorial/dependencies/test/main.f90 index f0404ed57..d369c2d0b 100644 --- a/src/tutorial/dependencies/test/main.f90 +++ b/src/tutorial/dependencies/test/main.f90 @@ -1,5 +1,6 @@ module test_demo - use demo, only : substitute, getline + use demo, only : substitute + use stdlib_io, only : getline use testdrive, only : error_type, unittest_type, new_unittest, check implicit none private