--- ray/src/util/eplus_adduvf.c 2014/02/27 22:42:53 2.14 +++ ray/src/util/eplus_adduvf.c 2020/01/17 17:33:48 2.20 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: eplus_adduvf.c,v 2.14 2014/02/27 22:42:53 greg Exp $"; +static const char RCSid[] = "$Id: eplus_adduvf.c,v 2.20 2020/01/17 17:33:48 greg Exp $"; #endif /* * Add User View Factors to EnergyPlus Input Data File @@ -8,6 +8,7 @@ static const char RCSid[] = "$Id: eplus_adduvf.c,v 2.1 */ #include +#include "platform.h" #include "rtio.h" #include "rtmath.h" #include "random.h" @@ -176,7 +177,7 @@ add_subsurf(IDF_OBJECT *param) static IDF_FIELD * get_vlist(IDF_OBJECT *param, const char *zname) { - static const int itm_len = sizeof(IDF_FIELD)+6; +#define itm_len (sizeof(IDF_FIELD)+6) static char fld_buf[4*itm_len]; static char *next_fbp = fld_buf; int i; @@ -219,6 +220,7 @@ get_vlist(IDF_OBJECT *param, const char *zname) sprintf(res->val, "%d", i/3); } return(res); +#undef itm_len } /* Get/allocate surface polygon */ @@ -361,7 +363,7 @@ start_rcontrib(SUBPROC *pd, ZONE *zp) IDF_FIELD *fptr; int i, j, n; /* start oconv command */ - sprintf(cbuf, "oconv - > '%s'", temp_octree); + sprintf(cbuf, "oconv - > \"%s\"", temp_octree); if ((ofp = popen(cbuf, "w")) == NULL) { fputs(progname, stderr); fputs(": cannot open oconv process\n", stderr); @@ -391,8 +393,8 @@ start_rcontrib(SUBPROC *pd, ZONE *zp) /* now subsurfaces */ if (zp->ntotal > zp->nsurf) { if (zp->area_redu != NULL) - memset(zp->area_redu, 0, sizeof(float)*zp->nsurf); - else if ((zp->area_redu = (float *)calloc(zp->nsurf, + memset(zp->area_redu, 0, sizeof(float)*zp->ntotal); + else if ((zp->area_redu = (float *)calloc(zp->ntotal, sizeof(float))) == NULL) return(0); } @@ -707,6 +709,15 @@ main(int argc, char *argv[]) fputs("'\n", stderr); return(1); } + /* check version (warning) */ + if ((pptr = idf_getobject(our_idf, "Version")) != NULL && + pptr->flist != NULL && atoi(pptr->flist->val) != 7) { + fputs(progname, stderr); + fputs(": warning - written for IDF version 7.x, not ", + stderr); + fputs(pptr->flist->val, stderr); + fputc('\n', stderr); + } /* remove existing UVFs */ if ((pptr = idf_getobject(our_idf, UVF_PNAME)) != NULL) { IDF_OBJECT *pnext; @@ -715,7 +726,7 @@ main(int argc, char *argv[]) do { pnext = pptr->pnext; idf_delobject(our_idf, pptr); - } while (pnext != NULL); + } while ((pptr = pnext) != NULL); } /* add to header */ if (our_idf->hrem == NULL ||