Skip to content

Commit

Permalink
Merge pull request #125 from mabruzzo/fortran_example_flag
Browse files Browse the repository at this point in the history
Document optimization issues in Fortran example with gfortran 9.2.1 & 9.4.0
  • Loading branch information
brittonsmith committed Dec 5, 2022
2 parents f9a3866 + cbd68bc commit 8da5252
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ fortran_example: $(MODULES) fortran_example.o
exit 1; \
fi)

# the following target uses -O1 optimization because problems can arise with
# higher levels of optimization. A comment in fortran_example.F provides more
# details about the problems
.F.o:
@rm -f $@
@echo "Compiling $<"
Expand Down
11 changes: 11 additions & 0 deletions src/example/fortran_example.F
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
c Problems relating to grackle_data%grackle_data_file arise when
c this program is compiled using certain versions of gfortran
c (including versions 9.2.1 & 9.4.0) with an optimization level of
c -O2 or higher.
c
c In these cases, the compiler appears to make an aggressive
c optimization in which the program deallocates the `filename`
c variable before calls to certain grackle routines. This is
c problematic because grackle_data%grackle_data_file points to the
c address of the data held in `filename`

program fortran_example

USE ISO_C_BINDING
Expand Down

0 comments on commit 8da5252

Please sign in to comment.