Compare commits
1 Commits
master
...
no-derived
Author | SHA1 | Date | |
---|---|---|---|
25edae468b |
@ -9,14 +9,15 @@ module gray_cli
|
|||||||
! 1. the print_help() subroutine
|
! 1. the print_help() subroutine
|
||||||
! 2. the print_cli_options() subroutine
|
! 2. the print_cli_options() subroutine
|
||||||
! 3. the man page
|
! 3. the man page
|
||||||
|
integer, parameter :: max_options_len=255
|
||||||
type cli_options
|
type cli_options
|
||||||
! Switches
|
! Switches
|
||||||
logical :: quiet
|
logical :: quiet
|
||||||
! Files
|
! Files
|
||||||
character(len=:), allocatable :: output_dir
|
character(len=max_options_len) :: output_dir = ''
|
||||||
character(len=:), allocatable :: params_file
|
character(len=max_options_len) :: params_file = ''
|
||||||
character(len=:), allocatable :: config_file
|
character(len=max_options_len) :: config_file = ''
|
||||||
character(len=:), allocatable :: sum_filelist
|
character(len=max_options_len) :: sum_filelist = ''
|
||||||
! others
|
! others
|
||||||
integer :: verbose
|
integer :: verbose
|
||||||
integer, allocatable :: units(:)
|
integer, allocatable :: units(:)
|
||||||
@ -90,9 +91,9 @@ contains
|
|||||||
print '(a)' , 'switches:'
|
print '(a)' , 'switches:'
|
||||||
print '(a,l)' , ' - quiet: ' , opts%quiet
|
print '(a,l)' , ' - quiet: ' , opts%quiet
|
||||||
print '(a)' , 'files:'
|
print '(a)' , 'files:'
|
||||||
print '(a,a)' , ' output-dir: ' , opts%output_dir
|
print '(a,a)' , ' output-dir: ' , trim(opts%output_dir)
|
||||||
print '(a,a)' , ' param-file: ' , opts%params_file
|
print '(a,a)' , ' param-file: ' , trim(opts%params_file)
|
||||||
print '(a,a)' , ' sum: ' , opts%sum_filelist
|
print '(a,a)' , ' sum: ' , trim(opts%sum_filelist)
|
||||||
print '(a)' , 'others:'
|
print '(a)' , 'others:'
|
||||||
print '(a,20i3)' , ' - units: ' , opts%units
|
print '(a,20i3)' , ' - units: ' , opts%units
|
||||||
print '(a,l)' , ' - verbose: ' , opts%verbose
|
print '(a,l)' , ' - verbose: ' , opts%verbose
|
||||||
@ -151,19 +152,27 @@ contains
|
|||||||
opts%quiet = .true.
|
opts%quiet = .true.
|
||||||
|
|
||||||
case ('-o', '--output-dir')
|
case ('-o', '--output-dir')
|
||||||
call get_command_string(i + 1, opts%output_dir)
|
call get_command_string(i + 1, temp)
|
||||||
|
opts%output_dir = temp
|
||||||
|
deallocate(temp)
|
||||||
skip_next = .true.
|
skip_next = .true.
|
||||||
|
|
||||||
case ('-p', '--params-file')
|
case ('-p', '--params-file')
|
||||||
call get_command_string(i + 1, opts%params_file)
|
call get_command_string(i + 1, temp)
|
||||||
|
opts%params_file = temp
|
||||||
|
deallocate(temp)
|
||||||
skip_next = .true.
|
skip_next = .true.
|
||||||
|
|
||||||
case ('-c', '--config-file')
|
case ('-c', '--config-file')
|
||||||
call get_command_string(i + 1, opts%config_file)
|
call get_command_string(i + 1, temp)
|
||||||
|
opts%config_file = temp
|
||||||
|
deallocate(temp)
|
||||||
skip_next = .true.
|
skip_next = .true.
|
||||||
|
|
||||||
case ('-s', '--sum')
|
case ('-s', '--sum')
|
||||||
call get_command_string(i + 1, opts%sum_filelist)
|
call get_command_string(i + 1, temp)
|
||||||
|
opts%sum_filelist = temp
|
||||||
|
deallocate(temp)
|
||||||
skip_next = .true.
|
skip_next = .true.
|
||||||
|
|
||||||
case ('-u', '--units')
|
case ('-u', '--units')
|
||||||
@ -303,10 +312,6 @@ contains
|
|||||||
! subroutine arguments
|
! subroutine arguments
|
||||||
type(cli_options), intent(inout) :: opts
|
type(cli_options), intent(inout) :: opts
|
||||||
|
|
||||||
if (allocated(opts%output_dir)) deallocate(opts%output_dir)
|
|
||||||
if (allocated(opts%params_file)) deallocate(opts%params_file)
|
|
||||||
if (allocated(opts%config_file)) deallocate(opts%config_file)
|
|
||||||
if (allocated(opts%sum_filelist)) deallocate(opts%sum_filelist)
|
|
||||||
if (allocated(opts%units)) deallocate(opts%units)
|
if (allocated(opts%units)) deallocate(opts%units)
|
||||||
end subroutine deinit_cli_options
|
end subroutine deinit_cli_options
|
||||||
|
|
||||||
|
23
src/main.f90
23
src/main.f90
@ -37,16 +37,16 @@ program main
|
|||||||
|
|
||||||
! Load the parameters from file and move to its directory
|
! Load the parameters from file and move to its directory
|
||||||
! (all other filepaths are assumed relative to it)
|
! (all other filepaths are assumed relative to it)
|
||||||
if (allocated(opts%config_file)) then
|
if (len_trim(opts%config_file)>0) then
|
||||||
! Use the newer gray.ini configuration file
|
! Use the newer gray.ini configuration file
|
||||||
call log_message(level=INFO, mod='main', msg='using GRAY INI config')
|
call log_message(level=INFO, mod='main', msg='using GRAY INI config')
|
||||||
call read_gray_config(opts%config_file, params)
|
call read_gray_config(trim(opts%config_file), params)
|
||||||
err = chdir(dirname(opts%config_file))
|
err = chdir(dirname(trim(opts%config_file)))
|
||||||
else
|
else
|
||||||
! Use the legacy gray_params.data file
|
! Use the legacy gray_params.data file
|
||||||
call log_message(level=INFO, mod='main', msg='using GRAY params file')
|
call log_message(level=INFO, mod='main', msg='using GRAY params file')
|
||||||
call read_gray_params(opts%params_file, params)
|
call read_gray_params(trim(opts%params_file), params)
|
||||||
err = chdir(dirname(opts%params_file))
|
err = chdir(dirname(trim(opts%params_file)))
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
@ -69,15 +69,15 @@ program main
|
|||||||
call init_misc(params, data)
|
call init_misc(params, data)
|
||||||
|
|
||||||
! Change the current directory to output files there
|
! Change the current directory to output files there
|
||||||
if (allocated(opts%output_dir)) then
|
if (len_trim(opts%output_dir)>0) then
|
||||||
if (chdir(trim(cwd) // '/' // opts%output_dir) /= 0) then
|
if (chdir(trim(cwd) // '/' // trim(opts%output_dir)) /= 0) then
|
||||||
call log_message(level=ERROR, mod='main', &
|
call log_message(level=ERROR, mod='main', &
|
||||||
msg='chdir to output_dir ('//opts%output_dir//') failed!')
|
msg='chdir to output_dir ('//trim(opts%output_dir)//') failed!')
|
||||||
call exit(1)
|
call exit(1)
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if (allocated(opts%sum_filelist)) then
|
if (len_trim(opts%sum_filelist)>0) then
|
||||||
call log_message(level=INFO, mod='main', msg='summing profiles')
|
call log_message(level=INFO, mod='main', msg='summing profiles')
|
||||||
|
|
||||||
sum: block
|
sum: block
|
||||||
@ -93,10 +93,10 @@ program main
|
|||||||
pins(params%output%nrho), rtin(params%output%nrho), &
|
pins(params%output%nrho), rtin(params%output%nrho), &
|
||||||
rpin(params%output%nrho))
|
rpin(params%output%nrho))
|
||||||
|
|
||||||
open(100, file=opts%sum_filelist, action='read', status='old', iostat=err)
|
open(100, file=trim(opts%sum_filelist), action='read', status='old', iostat=err)
|
||||||
if (err /= 0) then
|
if (err /= 0) then
|
||||||
call log_message(level=ERROR, mod='main', &
|
call log_message(level=ERROR, mod='main', &
|
||||||
msg='opening file list ('//opts%sum_filelist//') failed!')
|
msg='opening file list ('//trim(opts%sum_filelist)//') failed!')
|
||||||
call exit(1)
|
call exit(1)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@ -154,7 +154,6 @@ program main
|
|||||||
close(100 + i)
|
close(100 + i)
|
||||||
end do
|
end do
|
||||||
deallocate(dpdv, jcd, jphi, currins, pins, rtin, rpin)
|
deallocate(dpdv, jcd, jphi, currins, pins, rtin, rpin)
|
||||||
deallocate(opts%params_file)
|
|
||||||
end block sum
|
end block sum
|
||||||
else
|
else
|
||||||
call gray_main(params, data, results, err)
|
call gray_main(params, data, results, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user