Currently, gfortran only has start up routines, cf. http://gcc.gnu.org/onlinedocs/gfortran/Non_002dFortran-Main-Program.html
I think it makes sense to also add shutdown routines. Currently, _gfortran_abort calls: close_units (); Additionally, one should call: flush_all_units (); For some reasons _gfortran_exit_i(4,8) does not. And, I think it would make sense to call the unit flushing (via the shutdown routine) also for "STOP" and when leaving the main program. And non-Fortran main programs should do the same (cf. link above). The (externally visible) shutdown routine shall return and leave the exiting of the program to the caller. -- Summary: Add _gfortran_finalize function to close down the library Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43849