| 21 |  | #include  <string.h> | 
| 22 |  | #include  <math.h> | 
| 23 |  | #include  <stdlib.h> | 
| 24 | + | #include  <ctype.h> | 
| 25 |  |  | 
| 26 |  | #include  "rtio.h" | 
| 27 |  | #include  "fvect.h" | 
| 43 |  | /* Perez sky parametrization : epsilon and delta calculations from the direct and diffuse irradiances */ | 
| 44 |  | double sky_brightness(); | 
| 45 |  | double sky_clearness(); | 
| 46 | + | void computesky(); | 
| 47 |  |  | 
| 48 |  | /* calculation of the direct and diffuse components from the Perez parametrization */ | 
| 49 |  | double  diffus_irradiance_from_sky_brightness(); | 
| 73 |  | double  integ_lv(float *lv,float *theta); | 
| 74 |  | float   *theta_ordered(char *filename); | 
| 75 |  | float   *phi_ordered(char *filename); | 
| 76 | + | void    skip_comments(FILE *fp); | 
| 77 |  |  | 
| 78 |  |  | 
| 79 |  |  | 
| 274 |  | } | 
| 275 |  |  | 
| 276 |  |  | 
| 277 | + | void | 
| 278 |  | computesky()                    /* compute sky parameters */ | 
| 279 |  | { | 
| 280 |  |  | 
| 281 |  | /* new variables */ | 
| 282 | < | int     j, i; | 
| 282 | > | int     j; | 
| 283 |  | float   *lv_mod;  /* 145 luminance values*/ | 
| 284 |  | /* 145 directions for the calculation of the normalization coefficient, coefficient Perez model */ | 
| 285 |  | float   *theta_o, *phi_o, *coeff_perez; | 
| 286 |  | double  dzeta, gamma; | 
| 283 | – | double  diffusion; | 
| 287 |  | double  normfactor; | 
| 288 |  |  | 
| 289 |  |  | 
| 473 |  | /* Compute the ground radiance */ | 
| 474 |  | zenithbr=calc_rel_lum_perez(0.0,radians(sunzenith),radians(sunzenith),skyclearness,skybrightness,coeff_perez); | 
| 475 |  | zenithbr*=diffnormalization; | 
| 476 | + | /* | 
| 477 |  | fprintf(stderr, "gendaylit : the actual zenith radiance(W/m^2/sr) or luminance(cd/m^2) is : %.0lf\n", zenithbr); | 
| 478 | < |  | 
| 478 | > | */ | 
| 479 | > |  | 
| 480 |  | if (skyclearness==1) | 
| 481 |  | normfactor = 0.777778; | 
| 482 |  |  | 
| 613 |  |  | 
| 614 |  |  | 
| 615 |  |  | 
| 616 | + | void | 
| 617 | + | skip_comments(FILE *fp)         /* skip comments in file */ | 
| 618 | + | { | 
| 619 | + | int     c; | 
| 620 | + |  | 
| 621 | + | while ((c = getc(fp)) != EOF) | 
| 622 | + | if (c == '#') { | 
| 623 | + | while ((c = getc(fp)) != EOF) | 
| 624 | + | if (c == '\n') | 
| 625 | + | break; | 
| 626 | + | } else if (!isspace(c)) { | 
| 627 | + | ungetc(c, fp); | 
| 628 | + | break; | 
| 629 | + | } | 
| 630 | + | } | 
| 631 |  |  | 
| 632 |  |  | 
| 633 |  |  | 
| 614 | – |  | 
| 615 | – |  | 
| 616 | – |  | 
| 617 | – |  | 
| 618 | – |  | 
| 634 |  | /* Perez models */ | 
| 635 |  |  | 
| 636 |  | /* Perez global horizontal luminous efficacy model */ | 
| 1013 |  | { | 
| 1014 |  | /*printf("file %s  open\n", filename);*/ | 
| 1015 |  | } | 
| 1016 | + |  | 
| 1017 | + | skip_comments(fcoeff_perez); | 
| 1018 |  |  | 
| 1002 | – | rewind(fcoeff_perez); /* on se place en debut de fichier */ | 
| 1003 | – |  | 
| 1019 |  | for (i=0;i<8;i++) | 
| 1020 |  | for (j=0;j<20;j++) | 
| 1021 |  | { | 
| 1198 |  | fprintf(stderr,"Cannot open file %s in function theta_ordered\n",filename); | 
| 1199 |  | exit(1); | 
| 1200 |  | } | 
| 1201 | + |  | 
| 1202 | + | skip_comments(file_in); | 
| 1203 |  |  | 
| 1187 | – | rewind(file_in); | 
| 1188 | – |  | 
| 1204 |  | if ( (ptr = malloc(145*sizeof(float))) == NULL ) | 
| 1205 |  | { | 
| 1206 |  | fprintf(stderr,"Out of memory in function theta_ordered\n"); | 
| 1244 |  | fprintf(stderr,"Cannot open file %s in function phi_ordered\n",filename); | 
| 1245 |  | exit(1); | 
| 1246 |  | } | 
| 1247 | < |  | 
| 1248 | < | rewind(file_in); | 
| 1247 | > |  | 
| 1248 | > | skip_comments(file_in); | 
| 1249 |  |  | 
| 1250 |  | if ( (ptr = malloc(145*sizeof(float))) == NULL ) | 
| 1251 |  | { |