-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.f90
39 lines (33 loc) · 1.12 KB
/
example.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
program example
use ioparams, only: group1_t, control_t, &
read_nml, write_nml, command_argument_as_array, &
parse_command_args, print_help, join_array
implicit none
type(group1_t) :: par1
type(control_t) :: ctr
integer :: i, parsed
character(len=256) :: arg
character(len=256), allocatable :: args(:)
! read namelist
open(88, file="namelist.nml")
call read_nml(88, par1)
call read_nml(88, ctr)
close(88)
! parse command-line arguments
call command_argument_as_array(args)
call parse_command_args(par1, args=args, unmatched=args, stop_on_help=.false.)
call parse_command_args(ctr, args=args, unmatched=args)
if (size(args) > 0) then
write(*,*) "Some arguments were not matched: "
write(*,*) trim(join_array(args))
stop
endif
if (ctr%print_nml) then
write(*,*) "-------------------------------------"
write(*,*) "Print namelist : "
write(*,*) "-------------------------------------"
call write_nml(6, par1)
write(*,*) "-------------------------------------"
endif
write(*,*) "Example program. Call with -h flag to get help on existing parameters."
end program