# -----------------------------------------------------------------
# Programmer(s): David J. Gardner @ LLNL
# -----------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2024, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# -----------------------------------------------------------------
# Makefile for ARKODE Fortran 2003 interface parallel examples
#
# This file is generated from a template using various variables
# set at configuration time. It can be used as a template for
# other user Makefiles.
# -----------------------------------------------------------------

F90      = /usr/bin/mpif90
F90FLAGS = -O3 -DSUNDIALS_INT32_T -cpp
F90LIBS  =  -lm

SUNDIALS_PREFIX      = /usr
SUNDIALS_INCLUDE_DIR = ${SUNDIALS_PREFIX}/fortran
SUNDIALS_LIBRARY_DIR = ${SUNDIALS_PREFIX}/lib/riscv64-linux-gnu

# ------------------------------------------------------------------------------

INCLUDE_DIRS = $(addprefix -I, ${SUNDIALS_INCLUDE_DIR})
LIBRARY_DIRS = $(addprefix -L, ${SUNDIALS_LIBRARY_DIR})
LIBRARIES = $(addprefix -l,  sundials_farkode_mod sundials_nvecparallel sundials_fnvecparallel_mod sundials_arkode sundials_fnvecmpiplusx_mod sundials_nvecmpiplusx sundials_fnvecmpimanyvector_mod sundials_nvecmpimanyvector sundials_fcore_mod sundials_core) ${F90LIBS}
LINKFLAGS = -Wl,-rpath,${SUNDIALS_LIBRARY_DIR}

# ------------------------------------------------------------------------------

EXAMPLES =  ark_brusselator1D_task_local_nls_f2003
EXAMPLES_DEPENDENCIES = 

OBJECTS = ${EXAMPLES:=.o}
OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}

# ------------------------------------------------------------------------------

.SUFFIXES : .o .f90

.f90.o :
	${F90} ${F90FLAGS} ${INCLUDE_DIRS} -c $<

# ------------------------------------------------------------------------------

all: examples

examples: ${OBJECTS_DEPENDENCIES} ${OBJECTS}
	@for i in ${EXAMPLES} ; do \
	  echo "${F90} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${F90FLAGS} ${INCLUDES} ${LIBRARY_DIRS} ${LIBRARIES} ${LINKFLAGS}" ; \
	  ${F90} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${F90FLAGS} ${INCLUDES} ${LIBRARY_DIRS} ${LIBRARIES} ${LINKFLAGS} ; \
	done

clean:
	rm -f *.o *.mod
	rm -f ${OBJECTS}

realclean: clean
	rm -f ${EXAMPLES}

# ------------------------------------------------------------------------------
