dhermes / bezier

Helper for Bézier Curves, Triangles, and Higher Order Objects
Apache License 2.0
255 stars 35 forks source link

[QUESTION] Should we check status of `allocate()` in Fortran code #141

Open dhermes opened 5 years ago

dhermes commented 5 years ago

Inspired by a snippet from https://www.tacc.utexas.edu/documents/13601/162125/fortran_class.pdf:

allocate(x_1d(n), x_2d(n,m), stat=ierror) ! Check the
if (ierror /= 0) stop 'error'             ! error status!

(Or #133 instead)

dhermes commented 4 years ago

Currently, there are 50 uses of allocate().

$ git log -1 --pretty=%H
54a912919e013596b1ae79c34d323c0fb6d2cd78
$ git grep -n ' allocate(' -- 'src/*.f90' | wc -l
      50
$ git grep -n ' allocate(' -- 'src/*.f90'
src/fortran/curve.f90:390:       allocate(next_candidates(num_next_candidates - 1)%nodes(dimension_, num_nodes))
src/fortran/curve.f90:393:       allocate(next_candidates(num_next_candidates)%nodes(dimension_, num_nodes))
src/fortran/curve.f90:419:          allocate(next_candidates(2 * num_candidates))
src/fortran/curve.f90:422:       allocate(next_candidates(2 * num_candidates))
src/fortran/curve.f90:480:    allocate(candidates_odd(1))  ! First iteration is odd.
...