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)', ' (default: gray.ini)'
|
||||||
print '(a)', ' -s, --sum FILE sum the output profiles from a list of files'
|
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)', ' -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)', ' see the manual for all unit IDs.'
|
||||||
print '(a)', ' -g, --gray-param ID=VAL set a GRAY parameter, overriding the value'
|
print '(a)', ' -g, --gray-param ID=VAL set a GRAY parameter, overriding the value'
|
||||||
print '(a)', ' specified via --params-file/--config-file;'
|
print '(a)', ' specified via --params-file/--config-file;'
|
||||||
@ -102,7 +103,7 @@ contains
|
|||||||
subroutine parse_cli_options(opts)
|
subroutine parse_cli_options(opts)
|
||||||
! Parse the CLI arguments and initialise the options
|
! Parse the CLI arguments and initialise the options
|
||||||
|
|
||||||
use units, only : ucenr, usumm
|
use units, only : ucenr, usumm, all_enabled
|
||||||
use logger, only : WARNING
|
use logger, only : WARNING
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
@ -161,6 +162,14 @@ contains
|
|||||||
case ('-u', '--units')
|
case ('-u', '--units')
|
||||||
call get_next_command(i, temp)
|
call get_next_command(i, temp)
|
||||||
|
|
||||||
|
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
|
! resize the array
|
||||||
commas = count([(temp(i:i) == ',', i = 1, len(temp))])
|
commas = count([(temp(i:i) == ',', i = 1, len(temp))])
|
||||||
deallocate(opts%units)
|
deallocate(opts%units)
|
||||||
@ -174,6 +183,8 @@ contains
|
|||||||
deallocate(temp)
|
deallocate(temp)
|
||||||
call exit(1)
|
call exit(1)
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
deallocate(temp)
|
deallocate(temp)
|
||||||
|
|
||||||
case ('-g', '--gray-param')
|
case ('-g', '--gray-param')
|
||||||
|
@ -20,6 +20,7 @@ module units
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
! List of active units
|
! List of active units
|
||||||
|
logical, save :: all_enabled = .false.
|
||||||
integer, allocatable, save :: active_units(:)
|
integer, allocatable, save :: active_units(:)
|
||||||
|
|
||||||
contains
|
contains
|
||||||
@ -66,7 +67,7 @@ contains
|
|||||||
integer, intent(in) :: unit
|
integer, intent(in) :: unit
|
||||||
logical :: on
|
logical :: on
|
||||||
|
|
||||||
on = any(active_units == unit)
|
on = all_enabled .or. any(active_units == unit)
|
||||||
|
|
||||||
end function unit_active
|
end function unit_active
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user