/*********************************************************************\ * Read in hybrid parameters from an input file or the command line. * \*********************************************************************/ #include #include #include #include #include "structs.h" #define STRLEN 1000 void upcase (char *com); void read_hybrid_pars (char *string, struct fitpars *fpar) { int ncomp; char tok[10], *com; char *p; /*************************************************************\ * Check to see if the link structure is already active. * * First, check the fitpar tree for higher order terms. * \*************************************************************/ com = strtok (string, " #\t"); upcase (com); /*******************************************************************\ * Now extract the component numbers and store them in fpar->inner * * and fpar->outer. The first element of each is the number of * * of components that are involved. * \*******************************************************************/ if (strncmp (com, "L1", 2) == 0) { ncomp = 0; fpar->outer = (int *) calloc (OFFSET, sizeof(fpar->outer)); while ((p = strtok (NULL, " \t")) != NULL && p[0] != '#' && p[0] != '0' ) { ncomp++; fpar->outer = (int *) realloc (fpar->outer, (size_t)(sizeof (int) * (ncomp + OFFSET))); fpar->outer[ncomp] = atoi (p); }; fpar->outer[0] = ncomp; }; if (strncmp (com, "L2", 2) == 0) { ncomp = 0; fpar->inner = (int *) calloc (OFFSET, sizeof(fpar->inner)); while ((p = strtok (NULL, " \t")) != NULL && p[0] != '#' && p[0] != '0') { ncomp++; fpar->inner = (int *) realloc (fpar->inner, (size_t)(sizeof (int) * (ncomp + OFFSET))); fpar->inner[ncomp] = atoi (p); }; fpar->inner[0] = ncomp; }; } /*===========================================================================*\ * Add the symbols "\" and/or "/" to the end of the object name to designate * * it as a hybrid profile. * \*===========================================================================*/ void checkhybrid (struct fitpars *fpar) { struct fitpars *hptr, *fptr; int i, j; hptr = fpar; while (hptr != NULL) { if (strncmp (hptr->objtype, "hybrid", 6) == 0) { for (i=1; i <= hptr->outer[0]; i++) { fptr = fpar; for (j=1; j < hptr->outer[i]; j++) fptr = fptr->next; sprintf (fptr->objtype, "%s\\", fptr->objtype); }; for (i=1; i <= hptr->inner[0]; i++) { fptr = fpar; for (j=1; j < hptr->inner[i]; j++) fptr = fptr->next; sprintf (fptr->objtype, "%s/", fptr->objtype); }; }; hptr = hptr->next; }; }