
/*
	file:	init.c
	reads input parameters and user's data
*/

#include "area.h" 

// to make independent module from vadar.parms for shiftx+
#define PROBE_RADIUS    1.4
#define RAD_TYPE        SHRAKE_RAD        // Shrake : 3

#define MODULE_AREA   "AREA"

float 	probeRadius;
void 	read_parms_file();
int  	radType, allChains;
FILE 	*get_out_file(), *atomfp, *resfp, *parmsfp;
char 	atomFname[MAX_FNAME_LEN];
extern	FILE *get_parms_file();


/*************************************************************/
/* read parameters/data for this program 
*/
void init_parms(parmsFname, result)
char *parmsFname;
char *result;
{
        /* set unused becasue it just read two parameter (probeRadius, radiusType) 
   
                find_lib();

                parmsfp = get_parms_file(parmsFname);
                if (parmsfp == NULL)
                        exit(1);

                read_parms_file(parmsfp);
        */

        // set params insteady of read params from vadar.parms
        probeRadius = PROBE_RADIUS;
        radType = RAD_TYPE; 

	resfp = (FILE *)get_out_file(result);
	if (resfp == NULL)
		exit(1);


	strcpy(atomFname, result);       // result == -o outfile.name
	strcat(atomFname, ".asa");      // atomFname == outfile.name.atom
	atomfp = (FILE *)get_out_file(atomFname);
	if (atomfp == NULL)
		exit(1);

	
} /* init_parms */


/*************************************************************/
/* Read each parameter.
*/
FILE *get_out_file(result)
char *result;
{
	FILE	*fp;

	fp = fopen(result, "w");

	if (fp == NULL)
		fp = stdout;

	return(fp);

}	/* get_out_file */


/*************************************************************/
/* Read each parameter.
*/
void read_parms_file(parmfp)
FILE *parmfp;
{
int		i;
char    idStr[MAX_LINE_LEN];


	/* find allChains flag */
	for (i=0; i<ALLCHAINS_POS; i++)
		if (read_prompt(parmfp) == FALSE)
			show_err(TRUE, MODULE_AREA, "Parameter expected but not found.");
	fscanf(parmfp, "%d", &allChains);

	/* find AREA module name */
	do {
		if (read_prompt(parmfp) == FALSE) {
			show_err(TRUE, MODULE_AREA, "Could not find parameter ID code."); 
		}
		fscanf(parmfp, "%s", idStr);
	} while (0 != strcmp(idStr, MODULE_AREA));

	/* find probe radius */
	if (read_prompt(parmfp) == FALSE)
		show_err(TRUE, MODULE_AREA, "Parameter expected but not found.");
	fscanf(parmfp, "%f", &probeRadius);

	/* get vanderwalls radius */
	if (read_prompt(parmfp) == FALSE)
		show_err(TRUE, MODULE_AREA, "Parameter expected but not found.");
	fscanf(parmfp, "%d", &radType);

}   /* read_parms_file */
