#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# *                                                                 *
# * Copyright (C) 1998-2009 Timothy E. Dowling                      *
# *                                                                 *
# * This program is free software; you can redistribute it and/or   *
# * modify it under the terms of the GNU General Public License     *
# * as published by the Free Software Foundation; either version 2  *
# * of the License, or (at your option) any later version.          *
# * A copy of this License is in the file:                          *
# *   $EPIC4_PATH/License.txt                                        *
# *                                                                 *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of  *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.            *
# *                                                                 *
# * You should have received a copy of the GNU General Public       *
# * License along with this program; if not, write to the Free      *
# * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,     *
# * Boston, MA 02110-1301, USA.                                     *
# *                                                                 *
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#
#  This is the single-processor Makefile for the EPIC model.
#  It also compiles initial and change.
#
#  The object-code suffix _se.o denotes single-epic.
#

PROGS = initial \
        change \
        epic

INITSRCS = $(EPIC4_PATH)/src/shared/epic_globals.c \
           $(EPIC4_PATH)/src/shared/epic_initial.c \
           $(EPIC4_PATH)/src/shared/epic_init_eigen.c \
           $(EPIC4_PATH)/src/shared/epic_funcs_io.c \
           $(EPIC4_PATH)/src/shared/epic_funcs_util.c \
           $(EPIC4_PATH)/src/shared/epic_funcs_init.c \
           $(EPIC4_PATH)/src/shared/epic_funcs_astron.c \
           $(EPIC4_PATH)/src/shared/epic_funcs_diag.c \
           $(EPIC4_PATH)/src/single/s_epic_functions.c \
           $(EPIC4_PATH)/src/shared/epic_timestep.c \
           $(EPIC4_PATH)/src/shared/epic_sensible_heating.c \
           $(EPIC4_PATH)/src/shared/epic_flux.c \
           $(EPIC4_PATH)/src/shared/epic_adjust.c \
           $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics.c \
           $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_funcs.c \
           $(EPIC4_PATH)/src/shared/epic_subgrid.c \
           $(EPIC4_PATH)/src/shared/nmt_physics.c

INITOBJS = $(EPIC4_PATH)/src/shared/epic_globals_se.o \
           $(EPIC4_PATH)/src/shared/epic_initial_se.o \
           $(EPIC4_PATH)/src/shared/epic_init_eigen_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_io_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_util_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_init_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_astron_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_diag_se.o \
           $(EPIC4_PATH)/src/single/s_epic_functions_se.o \
           $(EPIC4_PATH)/src/shared/epic_timestep_se.o \
           $(EPIC4_PATH)/src/shared/epic_sensible_heating_se.o \
           $(EPIC4_PATH)/src/shared/epic_flux_se.o \
           $(EPIC4_PATH)/src/shared/epic_adjust_se.o \
           $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_se.o \
           $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_funcs_se.o \
           $(EPIC4_PATH)/src/shared/epic_subgrid_se.o \
           $(EPIC4_PATH)/src/shared/nmt_physics_se.o
     

CHANGESRCS = $(EPIC4_PATH)/src/shared/epic_globals.c \
             $(EPIC4_PATH)/src/shared/epic_change.c \
             $(EPIC4_PATH)/src/shared/epic_init_eigen.c \
             $(EPIC4_PATH)/src/shared/epic_funcs_io.c \
             $(EPIC4_PATH)/src/shared/epic_funcs_util.c \
             $(EPIC4_PATH)/src/shared/epic_funcs_init.c \
             $(EPIC4_PATH)/src/shared/epic_funcs_astron.c \
             $(EPIC4_PATH)/src/shared/epic_funcs_diag.c \
             $(EPIC4_PATH)/src/single/s_epic_functions.c \
             $(EPIC4_PATH)/src/shared/epic_timestep.c \
             $(EPIC4_PATH)/src/shared/epic_sensible_heating.c \
             $(EPIC4_PATH)/src/shared/epic_flux.c \
             $(EPIC4_PATH)/src/shared/epic_adjust.c \
             $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics.c \
             $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_funcs.c \
             $(EPIC4_PATH)/src/shared/epic_subgrid.c \
             $(EPIC4_PATH)/src/shared/nmt_physics.c

CHANGEOBJS = $(EPIC4_PATH)/src/shared/epic_globals_se.o \
             $(EPIC4_PATH)/src/shared/epic_change_se.o \
             $(EPIC4_PATH)/src/shared/epic_init_eigen_se.o \
             $(EPIC4_PATH)/src/shared/epic_funcs_io_se.o \
             $(EPIC4_PATH)/src/shared/epic_funcs_util_se.o \
             $(EPIC4_PATH)/src/shared/epic_funcs_init_se.o \
             $(EPIC4_PATH)/src/shared/epic_funcs_astron_se.o \
             $(EPIC4_PATH)/src/shared/epic_funcs_diag_se.o \
             $(EPIC4_PATH)/src/single/s_epic_functions_se.o \
             $(EPIC4_PATH)/src/shared/epic_timestep_se.o \
             $(EPIC4_PATH)/src/shared/epic_sensible_heating_se.o \
             $(EPIC4_PATH)/src/shared/epic_flux_se.o \
             $(EPIC4_PATH)/src/shared/epic_adjust_se.o \
             $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_se.o \
             $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_funcs_se.o \
             $(EPIC4_PATH)/src/shared/epic_subgrid_se.o \
             $(EPIC4_PATH)/src/shared/nmt_physics_se.o

EPIC_SRCS = $(EPIC4_PATH)/src/shared/epic_globals.c \
            $(EPIC4_PATH)/src/single/s_epic_functions.c \
	    $(EPIC4_PATH)/src/shared/epic_main.c \
            $(EPIC4_PATH)/src/shared/epic_timestep.c \
            $(EPIC4_PATH)/src/shared/epic_sensible_heating.c \
            $(EPIC4_PATH)/src/shared/epic_flux.c \
            $(EPIC4_PATH)/src/shared/epic_funcs_io.c \
            $(EPIC4_PATH)/src/shared/epic_funcs_util.c \
            $(EPIC4_PATH)/src/shared/epic_funcs_astron.c \
            $(EPIC4_PATH)/src/shared/epic_funcs_diag.c \
            $(EPIC4_PATH)/src/shared/epic_adjust.c \
            $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics.c \
            $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_funcs.c \
            $(EPIC4_PATH)/src/shared/epic_subgrid.c \
            $(EPIC4_PATH)/src/shared/nmt_physics.c

EPICOBJS = $(EPIC4_PATH)/src/shared/epic_globals_se.o \
           $(EPIC4_PATH)/src/single/s_epic_functions_se.o \
	   $(EPIC4_PATH)/src/shared/epic_main_se.o \
           $(EPIC4_PATH)/src/shared/epic_timestep_se.o \
           $(EPIC4_PATH)/src/shared/epic_sensible_heating_se.o \
           $(EPIC4_PATH)/src/shared/epic_flux_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_io_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_util_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_astron_se.o \
           $(EPIC4_PATH)/src/shared/epic_funcs_diag_se.o \
           $(EPIC4_PATH)/src/shared/epic_adjust_se.o \
           $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_se.o \
           $(EPIC4_PATH)/src/shared/microphysics/epic_microphysics_funcs_se.o \
           $(EPIC4_PATH)/src/shared/epic_subgrid_se.o \
           $(EPIC4_PATH)/src/shared/nmt_physics_se.o

HFILES = $(EPIC4_PATH)/include/epic.h \
         $(EPIC4_PATH)/include/epic_funcs_util.h \
         $(EPIC4_PATH)/include/epic_microphysics.h \
         $(EPIC4_PATH)/include/epic_subgrid.h \
         $(EPIC4_PATH)/include/nmt_physics.h

SRCS = $(INITSRCS) $(CHANGESRCS) $(EPIC_SRCS) 

# EPIC_SINGLE indicates that the computer is a single processor:

DEFINES = -DEPIC_SINGLE \
          -DEPIC4_PATH=\"$(EPIC4_PATH)\" \
          -D$(MACHINE_TYPE) \
          -DEPIC_PRECISION=$(EPIC_PRECISION) \
          -DEPIC_CHECK=$(EPIC_CHECK)

INCL = -I. \
       -I/usr/include \
       -I$(EPIC4_PATH)/netcdf/include \
       -I$(EPIC4_PATH)/include

C_FLAGS = $(CFLAGS) $(INCL) $(DEFINES) 

CC     = $(EPIC_CC)
LINKER = $(EPIC_CC)

LD_FLAGS = $(LDFLAGS) $(XLDFLAGS)

LIB_PATH = -L$(EPIC4_PATH)/netcdf/lib

LIB_LIST = -lnetcdf \
           -lm

LIBS     = $(LIB_PATH) $(LIB_LIST)

.SUFFIXES:
.SUFFIXES: _se.o .c .f 
.c_se.o: $(HFILES)
	${CC} $(C_FLAGS) -c $*.c -o $*_se.o ; 

all: $(PROGS)

initial: $(INITOBJS) $(HFILES)
	$(LINKER) $(LD_FLAGS) $(INITOBJS) $(LIBS) -o $@

change: $(CHANGEOBJS) $(HFILES)
	$(LINKER) $(LD_FLAGS) $(CHANGEOBJS) $(LIBS) -o $@

epic: $(EPICOBJS) $(HFILES)
	$(LINKER) $(LD_FLAGS) $(EPICOBJS) $(LIBS) -o $@

clean:
	@rm -f core *o *BAK *bak *~ *% *.log

clear:
	@rm -f core *o *BAK *bak *~ *% *.log

install: all
	@for name in $(PROGS); do \
	  mv $$name $(EPIC4_PATH)/bin ; \
	done

depend:
	makedepend -- $(C_FLAGS) -- $(SRCS)

# DO NOT DELETE THIS LINE -- make depend depends on it.
