PARAMS: Unify formatting of INQUIRE, READ, and WRITE statements.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2023-12-19 15:33:29 -03:00
parent b10e8d8db4
commit f31cb12545

View File

@ -123,7 +123,7 @@ module parameters
parameter_file = trim(arg) parameter_file = trim(arg)
else else
if (verbose) & if (verbose) &
write(error_unit,*) & write (error_unit,*) &
"The option '--input' or '-i' requires an argument. Exiting..." "The option '--input' or '-i' requires an argument. Exiting..."
status = 112 status = 112
return return
@ -132,12 +132,12 @@ module parameters
end if end if
end do end do
inquire(file=parameter_file, exist=info) inquire (file=parameter_file, exist=info)
if (info) then if (info) then
call parse_parameters(status) call parse_parameters(status)
else else
write(error_unit,*) "The parameter file '" // parameter_file // & write (error_unit,*) "The parameter file '" // parameter_file // &
"' does not exist. Exiting..." "' does not exist. Exiting..."
status = 111 status = 111
end if end if
@ -228,20 +228,20 @@ module parameters
n = 0 n = 0
j = 1024 j = 1024
inquire(file=parameter_file, size=j) inquire (file=parameter_file, size=j)
allocate(character(len=j) :: line) allocate(character(len=j) :: line)
open (newunit=io, file=parameter_file, action='read', err=30) open (newunit=io, file=parameter_file, action='read', err=30)
10 read(io, fmt="(a)", end=20) line 10 read (io, fmt="(a)", end=20) line
n = n + 1 n = n + 1
! remove comments ! remove comments
! !
i = index(line, '#') i = index(line, '#')
if (i > 0) write(line,"(a)") trim(adjustl(line(:i-1))) if (i > 0) write (line,"(a)") trim(adjustl(line(:i-1)))
! skip empty lines ! skip empty lines
! !
@ -278,7 +278,7 @@ module parameters
end if end if
if (status > 0) then if (status > 0) then
write(error_unit,"('[',a,']: ',a)") loc, & write (error_unit,"('[',a,']: ',a)") loc, &
"Wrong parameter format in '" // parameter_file // "'." "Wrong parameter format in '" // parameter_file // "'."
write (error_unit,"('[',a,']: ',a,i0,':')") loc, "Verify line ", n write (error_unit,"('[',a,']: ',a,i0,':')") loc, "Verify line ", n
write (error_unit,"('[',a,']: ',a)") loc, trim(adjustl(line)) write (error_unit,"('[',a,']: ',a)") loc, trim(adjustl(line))
@ -298,7 +298,7 @@ module parameters
item_ptr => item_ptr%next item_ptr => item_ptr%next
end do end do
if (exists) then if (exists) then
write(error_unit,"('[',a,']: ',a)") loc, "Parameter '" // key // & write (error_unit,"('[',a,']: ',a)") loc, "Parameter '" // key // &
"' appears multiple times. " // & "' appears multiple times. " // &
"Only the value of the first occurrence is considered." "Only the value of the first occurrence is considered."
else else
@ -317,7 +317,7 @@ module parameters
return return
30 write(error_unit,"('[',a,']: ',a)") loc, & 30 write (error_unit,"('[',a,']: ',a)") loc, &
"Unable to open the parameter file '" // & "Unable to open the parameter file '" // &
parameter_file // "'!" parameter_file // "'!"
@ -418,7 +418,7 @@ module parameters
item_ptr => parameter_list item_ptr => parameter_list
do while(associated(item_ptr)) do while(associated(item_ptr))
if (item_ptr%key == key) then if (item_ptr%key == key) then
read(item_ptr%val, err=10, fmt=*) val read (item_ptr%val, err=10, fmt=*) val
exit exit
end if end if
item_ptr => item_ptr%next item_ptr => item_ptr%next
@ -426,7 +426,7 @@ module parameters
return return
10 write(error_unit,"('[',a,']: ',a)") loc, & 10 write (error_unit,"('[',a,']: ',a)") loc, &
"Incorrect format for the integer parameter '" // key // & "Incorrect format for the integer parameter '" // key // &
"', or its value is either too small or too large!" "', or its value is either too small or too large!"
@ -468,7 +468,7 @@ module parameters
item_ptr => parameter_list item_ptr => parameter_list
do while(associated(item_ptr)) do while(associated(item_ptr))
if (item_ptr%key == key) then if (item_ptr%key == key) then
read(item_ptr%val, err=10, fmt=*) val read (item_ptr%val, err=10, fmt=*) val
exit exit
end if end if
item_ptr => item_ptr%next item_ptr => item_ptr%next
@ -476,7 +476,7 @@ module parameters
return return
10 write(error_unit,"('[',a,']: ',a)") loc, & 10 write (error_unit,"('[',a,']: ',a)") loc, &
"Incorrect format for the float parameter '" // key // & "Incorrect format for the float parameter '" // key // &
"', or its value is either too small or too large!" "', or its value is either too small or too large!"
@ -585,7 +585,7 @@ module parameters
if (master) then if (master) then
item_ptr => parameter_list item_ptr => parameter_list
do while(associated(item_ptr)) do while(associated(item_ptr))
write(str,"(a)") item_ptr%key // '|' // item_ptr%val write (str,"(a)") item_ptr%key // '|' // item_ptr%val
call broadcast(str) call broadcast(str)