Skip to content

Commit 1676233

Browse files
committed
add example program
1 parent 522f35e commit 1676233

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

example/system/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ADD_EXAMPLE(get_runtime_os)
2+
ADD_EXAMPLE(null_device)
23
ADD_EXAMPLE(os_type)
34
ADD_EXAMPLE(process_1)
45
ADD_EXAMPLE(process_2)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
! Showcase usage of the null device
2+
program example_null_device
3+
use stdlib_system, only: null_device
4+
use iso_fortran_env, only: output_unit
5+
implicit none
6+
integer :: unit
7+
logical :: screen_output = .false.
8+
9+
if (screen_output) then
10+
unit = output_unit
11+
else
12+
! Write to the null device if no screen output is wanted
13+
open(newunit=unit,file=null_device())
14+
endif
15+
16+
write(unit,*) "Hello, world!"
17+
18+
if (.not.screen_output) close(unit)
19+
20+
end program example_null_device

0 commit comments

Comments
 (0)