Read in the run-time parameters from a file. The name of the file is read from the first command line option. If no command line options are given, use 'input.par'.
The parameters are read in one go using the namelist mechanism.
subroutine read_parameters ()
!! Read in the run-time parameters from a file. The name of the file
!! is read from the first command line option. If no command line options
!! are given, use 'input.par'.
!!
!! The parameters are read in one go using the namelist mechanism.
implicit none
integer :: argc, arglen, errno
character(len=256) :: inputpar
argc = command_argument_count()
if (argc == 0) then
inputpar = 'input.par'
else
call get_command_argument(1, inputpar, arglen, errno)
if (errno .ne. 0) then
write(*,*) "Error retrieving command line argument"
stop
endif
endif
open(1, file = inputpar, status='old', form = 'formatted', &
action = 'read' )
read(1, nml=params)
close(1)
end subroutine read_parameters