src/gray_cli.f90: allow enabling or disabling all units
This commit is contained in:
parent
8425e5e286
commit
59dfcb7799
@ -54,6 +54,7 @@ contains
|
||||
print '(a)', ' (default: gray.ini)'
|
||||
print '(a)', ' -s, --sum FILE sum the output profiles from a list of files'
|
||||
print '(a)', ' -u, --units ID[,ID...] select which units to output (default: 4, 7);'
|
||||
print '(a)', ' use `all` to enable all, or `none` for no units.'
|
||||
print '(a)', ' see the manual for all unit IDs.'
|
||||
print '(a)', ' -g, --gray-param ID=VAL set a GRAY parameter, overriding the value'
|
||||
print '(a)', ' specified via --params-file/--config-file;'
|
||||
@ -102,7 +103,7 @@ contains
|
||||
subroutine parse_cli_options(opts)
|
||||
! Parse the CLI arguments and initialise the options
|
||||
|
||||
use units, only : ucenr, usumm
|
||||
use units, only : ucenr, usumm, all_enabled
|
||||
use logger, only : WARNING
|
||||
|
||||
implicit none
|
||||
@ -161,19 +162,29 @@ contains
|
||||
case ('-u', '--units')
|
||||
call get_next_command(i, temp)
|
||||
|
||||
! resize the array
|
||||
commas = count([(temp(i:i) == ',', i = 1, len(temp))])
|
||||
deallocate(opts%units)
|
||||
allocate(opts%units(commas + 1))
|
||||
if (temp == 'none') then
|
||||
! disable all output units
|
||||
deallocate(opts%units)
|
||||
allocate(opts%units(0))
|
||||
elseif (temp == 'all') then
|
||||
! enable all output units
|
||||
all_enabled = .true.
|
||||
else
|
||||
! resize the array
|
||||
commas = count([(temp(i:i) == ',', i = 1, len(temp))])
|
||||
deallocate(opts%units)
|
||||
allocate(opts%units(commas + 1))
|
||||
|
||||
! read the list of table IDs
|
||||
read (temp, *, iostat=error) opts%units
|
||||
if (error > 0) then
|
||||
print '(a,a)', 'invalid table IDs: ', temp
|
||||
deallocate(argument)
|
||||
deallocate(temp)
|
||||
call exit(1)
|
||||
! read the list of table IDs
|
||||
read (temp, *, iostat=error) opts%units
|
||||
if (error > 0) then
|
||||
print '(a,a)', 'invalid table IDs: ', temp
|
||||
deallocate(argument)
|
||||
deallocate(temp)
|
||||
call exit(1)
|
||||
end if
|
||||
end if
|
||||
|
||||
deallocate(temp)
|
||||
|
||||
case ('-g', '--gray-param')
|
||||
|
@ -20,6 +20,7 @@ module units
|
||||
#endif
|
||||
|
||||
! List of active units
|
||||
logical, save :: all_enabled = .false.
|
||||
integer, allocatable, save :: active_units(:)
|
||||
|
||||
contains
|
||||
@ -66,7 +67,7 @@ contains
|
||||
integer, intent(in) :: unit
|
||||
logical :: on
|
||||
|
||||
on = any(active_units == unit)
|
||||
on = all_enabled .or. any(active_units == unit)
|
||||
|
||||
end function unit_active
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user