Skip to content

Add Python-like input() function to stdlib_io#1116

Open
utsav-pal wants to merge 1 commit intofortran-lang:masterfrom
utsav-pal:feature/add-input-function
Open

Add Python-like input() function to stdlib_io#1116
utsav-pal wants to merge 1 commit intofortran-lang:masterfrom
utsav-pal:feature/add-input-function

Conversation

@utsav-pal
Copy link

Implements a Python-like input() function as requested in #259.

Changes

  • Added input() function to stdlib_io module
  • Function provides convenient user input with optional prompt
  • Uses existing get_line() function internally

Example Usage

use stdlib_io, only: input
character(len=:), allocatable :: name

name = input('Enter your name: ')
print *, 'Hello, ', name

Testing

  • Full stdlib builds successfully (2049 files)
  • All existing tests pass (407/407)
  • Added unit test and example program

Files Changed

  • src/io/stdlib_io.fypp - Core implementation
  • doc/specs/stdlib_io.md - Documentation
  • example/io/example_input.f90 - Usage example
  • test/io/test_input.f90 - Unit test

Related Issue

Closes #259

@utsav-pal utsav-pal mentioned this pull request Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input() function

1 participant