http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53175
Bug #: 53175 Summary: Fortran 4.8 undefined reference to a variable in a module Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: michael.a.richm...@nasa.gov Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu Build: i686-pc-linux-gnu This error occurs only in gnu Fortran 4.8 dated 04/08/2012 or later. If I type "gfortran main.f90 e.f90 s.f90" I get the following error message: /tmp/ccwf6p16.o: In function `default_settings.1813': s.f90:(.text+0x1b): undefined reference to `__energy_function_MOD_dim' /tmp/ccwf6p16.o: In function `set_simplex_options.1815': s.f90:(.text+0x1cd): undefined reference to `__energy_function_MOD_dim' collect2: error: ld returned 1 exit status If I concatenate e.f90 and s.f90 so that they are compiled as a single file, the error goes away. Listed below are the contents of these files: main.f90 PROGRAM main END PROGRAM main e.f90 MODULE ENERGY_FUNCTION IMPLICIT NONE TYPE PARAM PRIVATE INTEGER :: WHICH_VECTOR END TYPE PARAM INTEGER, PRIVATE :: DIM CONTAINS FUNCTION ENERGY_FUNCTION_CURRENT_ARGS() INTEGER, DIMENSION(DIM) :: ENERGY_FUNCTION_CURRENT_ARGS END FUNCTION ENERGY_FUNCTION_CURRENT_ARGS FUNCTION ENERGY_FUNCTION_GET_PARAMS() TYPE(PARAM), DIMENSION(DIM) :: ENERGY_FUNCTION_GET_PARAMS END FUNCTION ENERGY_FUNCTION_GET_PARAMS END MODULE ENERGY_FUNCTION s.f90 MODULE SEARCH_EMIN USE ENERGY_FUNCTION IMPLICIT NONE CONTAINS SUBROUTINE SEARCH_EMIN_START() TYPE(PARAM), DIMENSION(:), ALLOCATABLE :: EF_PARAMS DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: START_PARAMETERS CALL SET_SIMPLEX_OPTIONS CONTAINS SUBROUTINE SET_SIMPLEX_OPTIONS EF_PARAMS = ENERGY_FUNCTION_GET_PARAMS() CALL DEFAULT_SETTINGS END SUBROUTINE SET_SIMPLEX_OPTIONS SUBROUTINE DEFAULT_SETTINGS START_PARAMETERS = ENERGY_FUNCTION_CURRENT_ARGS() END SUBROUTINE DEFAULT_SETTINGS END SUBROUTINE SEARCH_EMIN_START END MODULE SEARCH_EMIN