From b6b95dcc9d6563666c1358e6800cc9ff064f657c Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Sun, 20 Jun 2021 12:14:18 +0200 Subject: Allow reading version number from file --- example_packages/version_file/app/main.f90 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 example_packages/version_file/app/main.f90 (limited to 'example_packages/version_file/app/main.f90') diff --git a/example_packages/version_file/app/main.f90 b/example_packages/version_file/app/main.f90 new file mode 100644 index 0000000..f2ae87b --- /dev/null +++ b/example_packages/version_file/app/main.f90 @@ -0,0 +1,13 @@ +program stub + implicit none + logical :: exist + integer :: unit + character(len=100) :: line + inquire(file="VERSION", exist=exist) + if (.not.exist) error stop + open(file="VERSION", newunit=unit) + read(unit, '(a)') line + close(unit) + + print '(*(a))', "File VERSION contains '", trim(line), "'" +end program stub -- cgit v1.2.3 From 63288a62ceeb20c53ba656b89c0f7c709ad9dbaa Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Wed, 23 Jun 2021 08:56:32 +0200 Subject: Add meaningful error message to example package Co-authored-by: Milan Curcic --- example_packages/version_file/app/main.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'example_packages/version_file/app/main.f90') diff --git a/example_packages/version_file/app/main.f90 b/example_packages/version_file/app/main.f90 index f2ae87b..fcf8d64 100644 --- a/example_packages/version_file/app/main.f90 +++ b/example_packages/version_file/app/main.f90 @@ -1,10 +1,10 @@ program stub implicit none - logical :: exist + logical :: exists integer :: unit character(len=100) :: line - inquire(file="VERSION", exist=exist) - if (.not.exist) error stop + inquire(file="VERSION", exist=exists) + if (.not.exists) error stop "File VERSION does not exist." open(file="VERSION", newunit=unit) read(unit, '(a)') line close(unit) -- cgit v1.2.3