Пример #1
0
int main( int argc, char **argv )
{
    if ( argc < 4 )
    {
        fputs("usage: obj2unr <obj> <outname> <polytype>\n",stderr);
        return 1;
    }
    if ( !loadobj(argv[1]) )
    {
        perror("loadobj");
        return 1;
    }
    if ( (numverts >= 16383) || (numfaces >= 65535) )
    {
        fprintf(stderr,
                "obj2unr: too many verts/faces (%u,%u),"
                " max 16383/65535\n",numverts,numfaces);
        clearobj();
        return 2;
    }
    if ( !unrout(argv[2],argv[3][0]) )
    {
        perror("unrout");
        clearobj();
        return 4;
    }
    clearobj();
    return 0;
}
Пример #2
0
int DEPMOD_MAIN(int argc, char *argv[], int all, const char *system_map, const char *base_dir, const char *module_dir, const char *file_syms)
{
	int ret;

	if (all)
	{
		if ((ret = addksyms(file_syms)) != -1) {
			recursive_action(module_dir, TRUE, FALSE, FALSE, add_module, 0, NULL);
			resolve();
			ret = prtdepend(base_dir, module_dir, flag_dry) || ret;
		}
	}
	else
	{
		/* not stdmode */
		if ((ret = addksyms(file_syms)) != -1) {
			for (; argc > 0 && ret != -1; ++argv, --argc)
				loadobj(*argv, file_syms != NULL);
			resolve();
			ret = prtdepend(base_dir, module_dir, flag_dry) || ret;
		}
	}

	return ret;
}
Пример #3
0
static int add_module(const char *filename, struct stat *statbuf,
		void *userdata)
{
	if (!strncmp (&filename[strlen(filename)-2], ".o", 2))
		loadobj(filename, 0);
	return (FALSE);
}
Пример #4
0
/*-----------------------------------------------------------------------------
 *  load_potential -- load the potential from an object file
 *       This routine depends heavily on the object-loader (loadobj(3NEMO))
 *	BUG: if dataname is NULL, the routines dies when trying f_c interface 
 *		since it can't take strlen(NULL)
 *-----------------------------------------------------------------------------
 */
local proc load_potential(string fname, string parameters, string dataname, char type)
{
    char  name[256], cmd[256], path[256], pname[32];
    char  *fullname, *nemopath, *potpath;
    proc  pot, ini_pot;
    int never=0;

    if (parameters!=NULL && *parameters!=0) {              /* get parameters */
	local_npar = nemoinpd(parameters,local_par,MAXPAR);
        if (local_npar>MAXPAR)
            error ("get_potential: potential has too many parameters (%d)",
                            local_npar);
        if (local_npar<0)
            warning("get_potential: parsing error in: %s",parameters);
    } else
        local_npar=0;
    if (local_npar > 0 && local_par[0] != 0.0) { /* aid multiple potentials */
        local_omega = local_par[0];
        dprintf(1,"get_potential: setting local_omega = %g\n",local_omega);
    }

    if (first) {
        mysymbols(getparam("argv0"));      /* get symbols for this program */
        first = FALSE;			   /* and tell it we've initialized */
    }
    potpath = getenv("POTPATH");	     /* is there customized path ? */
    if (potpath==NULL) {			/* use default path */
       potpath = path;
       strcpy (path,".");
       nemopath = getenv("NEMO");
       if (nemopath==NULL) {
	 strcat(path,":");
	 strcat (path,nemopath);
	 strcat (path,"/obj/potential");		/* ".:$NEMO/obj/potential" */
       }
    }
    strcpy (name,fname);
    strcat (name,".so");
    fullname = pathfind (potpath, name);
    if (fullname!=NULL) {			/* .o found !! */
        dprintf (2,"Attempt to load potential from %s\n",name);
    	loadobj(fullname);
    } else {					/* no .o found */
	strcpy (path,".");	/* just look in current directory */
	strcpy (name,fname);
	strcat (name,".c");
	if (pathfind(".",name)==NULL)
	    error("get_potential: no potential %s found",name);
	dprintf (0,"[Compiling potential %s]\n",name);	
	sprintf (cmd,"make -f $NEMOLIB/Makefile.lib %s.so",name);
	dprintf (1,"%s\n",cmd);
	if (system(cmd)!=0)
	    error ("Error in compiling potential file");
	strcpy (name,fname);
	strcat (name,".so");
	fullname = name;	/* or use: findpath ? */
	loadobj (name);
    }

    /*
     * changed code 17/05/02 WD
     * debugged     18/09/08 WD
     *
     * after finding the .so file, we still need to find the proper 
     * routine to link with. This is controlled by the type.
     * if type = 'r',  behaviour depends on the macro SINGLEPREC:
     *                 If defined, we behave as for type='f', otherwise
     *                 as for type='d'.
     * if type = 'd',  we first look for "potential_double" and
     *                 restore to "potential" if no "potential_double" found
     * if type = 'f',  we only look for "potential_float"
     *
     * macro FIND(POTENTIAL) tries to find routine POTENTIAL          WD
     */
#define FIND(POTENTIAL) {							\
  strcpy(pname,POTENTIAL);                 /*   try potential           */	\
  mapsys(pname);								\
  pot = (proc) findfn (pname);             /*   try C-routine           */ 	\
  if (pot==NULL) {                         /*   IF not found          > */ 	\
    strcat(pname,"_");								\
    pot = (proc) findfn (pname);           /*     try F77-routine       */	\
    if (pot)                               /*     found!                */ 	\
      Qfortran = TRUE;	 	     /*       must be F77 then    */ 		\
  }                                        /*   <                       */ 	\
  if(pot) dprintf(1,"\"%s\" loaded from file \"%s\"\n",POTENTIAL,fullname);	\
}

    char search_type = type=='r'?
#ifdef SINGLEPREC
      'f'
#else
      'd'
#endif
      : type;

    if(search_type=='f') {                   /* IF type=f                 */
      FIND("potential_float");               /*   try "potential_float"   */
    } else if(search_type=='d') {            /* ELIF type=d               */
      FIND("potential_double");              /*   try "potential_double"  */
      if( pot==NULL) {                       /*   IF not found            */
	FIND("potential");                   /*     try "potential"       */
      }
    } else
      error("unknown data type '%c'\n",type);
#undef FIND
    /* it is perhaps possible that some fortran compilers will add __ for */
    /* routines that have embedded _ in their name.... we're not catching */
    /* those here yet !!!                                                 */
    /* e.g.  g77 options:  -fno-underscoring and -fno-second-underscore   */
    /* will fix this problem                                              */
    if (pot==NULL) {
      error("Couldn't find a suitable potential for type %c in %s",type,fname);
      return NULL;
    }

    strcpy(pname,"inipotential");
    mapsys(pname);
    ini_pot = (proc) findfn (pname);              		/* C */
    if (ini_pot==NULL) {
        strcpy(pname,"ini_potential");
        mapsys(pname);
        ini_pot = (proc) findfn (pname);	        	/* C */
        if (ini_pot==NULL) {
            strcpy(pname,"inipotential_");
            mapsys(pname);
            ini_pot = (proc) findfn (pname);		        /* F77 */
            if (ini_pot==NULL) {
                strcpy(pname,"ini_potential_");
                mapsys(pname);
                ini_pot = (proc) findfn (pname);        	/* F77 */
            }
        }
    }
    if (ini_pot)
        if (!Qfortran)
            (*ini_pot)(&local_npar,local_par,dataname); 	/* C */
        else {
            if (dataname==NULL)
                (*ini_pot)(&local_npar,local_par,dataname,0);   /* F77 */
            else
                (*ini_pot)(&local_npar,local_par,dataname,strlen(dataname)); /* F77 */

        }
    else {
        printf ("Warning: inipotential(_) not present in %s", fname);
        printf (",default taken\n");
    }
    l_potential = pot;            /* save these two for later references */
    l_inipotential = ini_pot;
    if (local_npar > 0 && local_par[0] != local_omega) {
    	local_omega = local_par[0];
    	dprintf(1,"get_potential: modified omega=%g\n",local_omega);
    }
    if (pot==NULL) potential_dummy_for_c();    /* should never be called */
    return pot;
}