--- ray/src/gen/gendaylit.c 2009/06/06 20:18:32 2.1 +++ ray/src/gen/gendaylit.c 2011/08/10 22:30:31 2.5 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: gendaylit.c,v 2.1 2009/06/06 20:18:32 greg Exp $"; +static const char RCSid[] = "$Id: gendaylit.c,v 2.5 2011/08/10 22:30:31 greg Exp $"; #endif /* Copyright (c) 1994 *Fraunhofer Institut for Solar Energy Systems * Oltmannstr 5, D-79100 Freiburg, Germany @@ -21,6 +21,7 @@ static const char RCSid[] = "$Id: gendaylit.c,v 2.1 20 #include #include #include +#include #include "rtio.h" #include "fvect.h" @@ -42,6 +43,7 @@ double normsc(); /* Perez sky parametrization : epsilon and delta calculations from the direct and diffuse irradiances */ double sky_brightness(); double sky_clearness(); +void computesky(); /* calculation of the direct and diffuse components from the Perez parametrization */ double diffus_irradiance_from_sky_brightness(); @@ -71,6 +73,7 @@ void theta_phi_to_dzeta_gamma(double theta,double phi, double integ_lv(float *lv,float *theta); float *theta_ordered(char *filename); float *phi_ordered(char *filename); +void skip_comments(FILE *fp); @@ -271,6 +274,7 @@ char *argv[]; } +void computesky() /* compute sky parameters */ { @@ -470,8 +474,10 @@ computesky() /* compute sky parameters */ /* Compute the ground radiance */ zenithbr=calc_rel_lum_perez(0.0,radians(sunzenith),radians(sunzenith),skyclearness,skybrightness,coeff_perez); zenithbr*=diffnormalization; +/* fprintf(stderr, "gendaylit : the actual zenith radiance(W/m^2/sr) or luminance(cd/m^2) is : %.0lf\n", zenithbr); - +*/ + if (skyclearness==1) normfactor = 0.777778; @@ -608,14 +614,24 @@ register char **av; +void +skip_comments(FILE *fp) /* skip comments in file */ +{ + int c; + + while ((c = getc(fp)) != EOF) + if (c == '#') { + while ((c = getc(fp)) != EOF) + if (c == '\n') + break; + } else if (!isspace(c)) { + ungetc(c, fp); + break; + } +} - - - - - /* Perez models */ /* Perez global horizontal luminous efficacy model */ @@ -998,9 +1014,9 @@ int lect_coeff_perez(char *filename,float **coeff_pere { /*printf("file %s open\n", filename);*/ } + + skip_comments(fcoeff_perez); - rewind(fcoeff_perez); /* on se place en debut de fichier */ - for (i=0;i<8;i++) for (j=0;j<20;j++) { @@ -1183,9 +1199,9 @@ float *theta_ordered(char *filename) fprintf(stderr,"Cannot open file %s in function theta_ordered\n",filename); exit(1); } + + skip_comments(file_in); - rewind(file_in); - if ( (ptr = malloc(145*sizeof(float))) == NULL ) { fprintf(stderr,"Out of memory in function theta_ordered\n"); @@ -1229,8 +1245,8 @@ float *phi_ordered(char *filename) fprintf(stderr,"Cannot open file %s in function phi_ordered\n",filename); exit(1); } - - rewind(file_in); + + skip_comments(file_in); if ( (ptr = malloc(145*sizeof(float))) == NULL ) {