#!/bin/bash

# This routine compiles the requested file locally taking advantage of makefiles
# First it creates a makefile using fmkmf with a path (-p) that includes the library
# Then it executes the make file locally
# Note that up to date files are not remade, but the makefile itself is

# Edit this line to provide the address of your TEOS library directory
libdir=/home/dwright/IAPWS/TEOS10_FTN_V1.1/SIA_library

if [ ! -f "$1" ]
then
echo " "
echo "You may have forgotten to provide the file name to be compiled"
echo "Just enter its name (including .F90) after TEOSf90.sh"
echo " "
fi 

${libdir}/fmkmf.sh -tag F90 -p .:${libdir} $1 > Makefile
make

# If you want to have Makefiles for more than one routine in this directory, you can use
# ${libdir}/fmkmf.sh -tag F90 -p .:${libdir} $1 > Makefile_$(basename $1 .F90)
# to append the filename to the Makefile name. In this case, you would use 
# make -f Makefile_$(basename $1 .F90)
# to compile and link your routine to the library routines.
