#!/bin/csh
# $argv[1]: name of dynamical system class
# $argv[2]: class index
# $argv[3-]: codenames of dynamical systems belonging to the class
#

set outdir = $KAOSHOME/modellib
set outfile = $outdir/${argv[1]}_kaos_init.h

set argum = 
echo "Write a file $outfile from a set of dynamical systems"

cat > $outfile <<END
/*
----------------------------------------------------------------
	This file is automatically generated by kwrite_init.
-----------------------------------------------------------------
*/
/*
	dynamical system class index
*/
int ds_class = ${argv[2]};
/*
	vector field and function routine pointers
*/
int (*f_p)();
int (*func_p)();
/*
	declaration of dynamical system subroutines
*/
struct init_struct { int (*init_p)();};
END

foreach argum ($argv[3-])
	cat >> $outfile <<END
int ${argum}_init(),${argum}_f(),${argum}_func();
END
end

cat >> $outfile <<END
/*
	list of dynamical systems in the same order as one in panel cycle items
*/
struct init_struct init_tbl[MODEL_DIM] = {
END

foreach argum ($argv[3-])
	cat >> $outfile <<END
	${argum}_init,
END
end

cat >> $outfile <<END
};
END
echo Done!
