Skip to content

Commit aabb1f3

Browse files
committed
Fix fortitude issues
1 parent f73f46a commit aabb1f3

45 files changed

Lines changed: 146 additions & 92 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/main.f90

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ subroutine get_arguments(input, input_format, output, output_format, normalize,
173173
& template, template_format, read_dot_files, error)
174174

175175
!> Input file name
176-
character(len=:), allocatable :: input
176+
character(len=:), allocatable, intent(out) :: input
177177

178178
!> Input file format
179179
integer, allocatable, intent(out) :: input_format
180180

181181
!> Output file name
182-
character(len=:), allocatable :: output
182+
character(len=:), allocatable, intent(out) :: output
183183

184184
!> Output file format
185185
integer, allocatable, intent(out) :: output_format
186186

187187
!> Template file name
188-
character(len=:), allocatable :: template
188+
character(len=:), allocatable, intent(out) :: template
189189

190190
!> Template file format
191191
integer, allocatable, intent(out) :: template_format
@@ -340,6 +340,9 @@ subroutine read_file(filename, val, error)
340340
end if
341341

342342
close(io, iostat=stat)
343+
if (stat /= 0) then
344+
call fatal_error(error, "Error: Could not close file '"//filename//"'")
345+
end if
343346

344347
end subroutine read_file
345348

fpm.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ jonquil = "https://toml-f.github.io/jonquil/module/jonquil.html"
4444
ignore = [
4545
"C002", # interface without implicit none
4646
"C003", # implicit none(external)
47-
"C011", # no default in select case
48-
"C061", # missing intent attribute
49-
"C072", # assumed size character intent
50-
"C121", # use without explicit only
51-
"C122", # intrinsic missing for internal modules
52-
"C181", # iostat not checked
5347
]
48+
per-file-ignores."src/mctc/io/symbols.f90" = ["C072"]
49+
per-file-ignores."src/mctc/io/resize.f90" = ["C072"]
5450
line-length = 132

src/mctc/env/testing.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function select_test(tests, name) result(pos)
296296
character(len=*), intent(in) :: name
297297

298298
!> Available unit tests
299-
type(unittest_type) :: tests(:)
299+
type(unittest_type), intent(in) :: tests(:)
300300

301301
!> Selected test suite
302302
integer :: pos
@@ -321,7 +321,7 @@ function select_suite(suites, name) result(pos)
321321
character(len=*), intent(in) :: name
322322

323323
!> Available test suites
324-
type(testsuite_type) :: suites(:)
324+
type(testsuite_type), intent(in) :: suites(:)
325325

326326
!> Selected test suite
327327
integer :: pos

src/mctc/io/filetype.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ elemental function get_filetype(file) result(ftype)
140140
ftype = filetype%pymatgen
141141
case("json")
142142
ftype = filetype%json
143+
case default
144+
continue
143145
end select
144146
if (ftype /= filetype%unknown) return
145147
else
@@ -158,6 +160,8 @@ elemental function get_filetype(file) result(ftype)
158160
ftype = filetype%tmol
159161
case("poscar", "contcar")
160162
ftype = filetype%vasp
163+
case default
164+
continue
161165
end select
162166
end if
163167

src/mctc/io/read.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ subroutine get_structure_reader(reader, ftype)
185185
case(filetype%json)
186186
reader => read_json
187187

188+
case default
189+
nullify(reader)
188190
end select
189191

190192
end subroutine get_structure_reader

src/mctc/io/read/ctfile.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ subroutine read_molfile_v3k(self, unit, error)
431431
case("HCOUNT")
432432
token%first = equal + 1
433433
call read_token(line, token, sdf(iatom)%hydrogens, stat)
434+
case default
435+
continue
434436
end select
435437
end if
436438
if (stat /= 0) then
@@ -554,7 +556,7 @@ subroutine next_v30(unit, line, pos, lnum, iostat, iomsg)
554556
integer, intent(out) :: iostat
555557

556558
!> Error message
557-
character(len=:), allocatable, optional :: iomsg
559+
character(len=:), allocatable, intent(out), optional :: iomsg
558560

559561
call next_line(unit, line, pos, lnum, iostat, iomsg)
560562
if (iostat /= 0) return

src/mctc/io/read/turbomole.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ subroutine read_coord(mol, unit, error)
232232
call next_line(unit, cell_string, pos, lnum, stat)
233233
if (debug) print*, cell_string
234234

235+
case default
236+
continue
235237
end select
236238
end if
237239
token = token_type(0, 0)
@@ -311,6 +313,11 @@ subroutine read_coord(mol, unit, error)
311313

312314
if (has_cell) then
313315
read(cell_string, *, iostat=stat) latvec(:p_ncp(periodic))
316+
if (stat /= 0) then
317+
call io_error(error, "Cannot read cell parameters", line_cell, token, &
318+
& filename(unit), lcell, "expected real values")
319+
return
320+
end if
314321
if (debug) print*, latvec(:p_ncp(periodic))
315322
if (lattice_in_bohr) then
316323
conv = 1.0_wp
@@ -326,6 +333,8 @@ subroutine read_coord(mol, unit, error)
326333
& pi/2, pi/2, latvec(3)*pi/180.0_wp]
327334
case(3)
328335
cellpar = [latvec(1:3)*conv, latvec(4:6)*pi/180.0_wp]
336+
case default
337+
continue
329338
end select
330339
call cell_to_dlat(cellpar, lattice)
331340
end if
@@ -342,6 +351,11 @@ subroutine read_coord(mol, unit, error)
342351
return
343352
end if
344353
read(lattice_string, *, iostat=stat) latvec(:p_nlv(periodic))
354+
if (stat /= 0) then
355+
call io_error(error, "Cannot read lattice vectors", line_lattice, token, &
356+
& filename(unit), llattice, "expected real values")
357+
return
358+
end if
345359
if (lattice_in_bohr) then
346360
conv = 1.0_wp
347361
else

src/mctc/io/symbols.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ elemental subroutine symbol_to_number(number, symbol)
124124
select case(lcsymbol)
125125
case("d ", "t ")
126126
number = 1
127+
case default
128+
continue
127129
end select
128130
end if
129131

src/mctc/io/utils.f90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ subroutine getline(unit, line, iostat, iomsg)
6060
integer, intent(out) :: iostat
6161

6262
!> Error message
63-
character(len=:), allocatable, optional :: iomsg
63+
character(len=:), allocatable, intent(out), optional :: iomsg
6464

6565
integer, parameter :: bufsize = 512
6666
character(len=bufsize) :: buffer
@@ -109,7 +109,7 @@ subroutine next_line(unit, line, pos, lnum, iostat, iomsg)
109109
integer, intent(out) :: iostat
110110

111111
!> Error message
112-
character(len=:), allocatable, optional :: iomsg
112+
character(len=:), allocatable, intent(out), optional :: iomsg
113113

114114
pos = 0
115115
call getline(unit, line, iostat, iomsg)
@@ -405,7 +405,9 @@ subroutine read_token_int(line, token, val, iostat, iomsg)
405405
character(len=512) :: msg
406406

407407
if (token%first > 0 .and. token%last <= len(line)) then
408+
val = 0
408409
read(line(token%first:token%last), *, iostat=iostat, iomsg=msg) val
410+
if (iostat /= 0) val = 0
409411
else
410412
iostat = 1
411413
msg = "No input found"
@@ -437,7 +439,9 @@ subroutine read_token_real(line, token, val, iostat, iomsg)
437439
character(len=512) :: msg
438440

439441
if (token%first > 0 .and. token%last <= len(line)) then
442+
val = 0.0_wp
440443
read(line(token%first:token%last), *, iostat=iostat, iomsg=msg) val
444+
if (iostat /= 0) val = 0.0_wp
441445
else
442446
iostat = 1
443447
msg = "No input found"

src/mctc/ncoord/erf.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ subroutine new_erf_ncoord(self, mol, kcn, cutoff, rcov, cut, norm_exp)
5353
!> Molecular structure data
5454
type(structure_type), intent(in) :: mol
5555
!> Steepness of counting function
56-
real(wp), optional :: kcn
56+
real(wp), intent(in), optional :: kcn
5757
!> Real space cutoff
5858
real(wp), intent(in), optional :: cutoff
5959
!> Covalent radii

0 commit comments

Comments
 (0)