RUN = sfx.exe
COMPILER ?= gnu
FC_KEYS ?= -cpp -Wuninitialized

# set compiler
ifeq ($(COMPILER),intel)
  FC = ifort
endif
ifeq ($(COMPILER),gnu)
  FC = gfortran
endif 

OBJ_F90 = sfx_phys_const.o sfx_common.o  sfx_io.o sfx_data.o sfx_z0t_all_surface.o sfx_z0m_all_surface.o sfx_z0m_all.o sfx_z0t_all.o sfx_surface.o sfx_config.o sfx_log_param.o sfx_log.o sfx_most_param.o sfx_most.o sfx_most_snow_param.o sfx_most_snow.o sfx_sheba_param.o sfx_sheba.o sfx_esm_param.o sfx_esm.o  sfx_sheba_noit_param.o sfx_sheba_noniterative.o sfx_run.o sfx_main.o
OBJ_F =
OBJ = $(OBJ_F90) $(OBJ_F)

$(RUN): $(OBJ)
	$(FC) $(FC_KEYS) $(OBJ) -o $(RUN)

$(OBJ_F90): %.o: srcF/%.f90
	$(FC) $(FC_KEYS) -cpp -o $@ -c $<

$(OBJ_F): %.o: srcF/%.F
	$(FC) $(FC_KEYS) -cpp -o $@ -c $<

clean: 
	rm -f $(OBJ) $(RUN) *.mod