#!/bin/sh
# script to generate SP and DP codes
# EH, Dec 2004 -- Jan 2005

SetDef(){
template_file=alm_map_template.F90
outfile_s=alm_map_ss_inc.F90
outfile_d=alm_map_dd_inc.F90
}

#--------

IncludeWarning(){
    echo '!*******************************************************************' >  $outfile
    echo '!                     DO NOT EDIT THIS FILE'                          >> $outfile
    echo "!Edit $template_file and run $script (or local Makefile) instead"     >> $outfile
    echo '!******************************************************************'  >> $outfile
}

#--------

Substitute(){

echo "-------------------------------------------"
echo "generating SP and DP routines for alm_tools"
echo "-------------------------------------------"

kind=SP
suffix=s
outfile=$outfile_s
IncludeWarning $outfile
cat $template_file |\
	sed "s|KMAP|$kind|" |\
	sed "s|KALM|$kind|" |\
	sed "s|KLOAD|$suffix|" >> $outfile
	
kind=DP
suffix=d
outfile=$outfile_d
IncludeWarning $outfile
cat $template_file |\
	sed "s|KMAP|$kind|" |\
	sed "s|KALM|$kind|" |\
	sed "s|KLOAD|$suffix|" >> $outfile
}	

#--------

script=$0
SetDef
Substitute

exit

