Skip to content

Commit

Permalink
- spelling and formatting corrections throughout the code
Browse files Browse the repository at this point in the history
- replaces a few UTF-8 symbols
  • Loading branch information
myurkin committed Nov 25, 2024
1 parent 5398e9a commit d8721ba
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/calculator.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,13 @@ static void CoupleConstant(doublecomplex *mrel,const enum incpol which,doublecom
for (l=0; l < 3; l++)
draineSum+=prop[l]*prop[l]*draine_precalc_data_array[draine_precalc_data_index].R3[R3_INDEX(i,l)];

// L is obtaned in Eq.(62)
// L is obtained in Eq.(62)
L=c1+mrel[0]*mrel[0]*c2*(1-3*prop[i]*prop[i])-mrel[0]*mrel[0]*c3*prop[i]*prop[i]-FOUR_PI*PI*I*nu/3-
draine_precalc_data_array[draine_precalc_data_index].R1-
(mrel[0]*mrel[0]-1)*draine_precalc_data_array[draine_precalc_data_index].R2[i]-
8*mrel[0]*mrel[0]*prop[i]*prop[i]*
draine_precalc_data_array[draine_precalc_data_index].R3[R3_INDEX(i,i)]+4*mrel[0]*mrel[0]*draineSum;
// K is obtaned in Eq.(63)
// K is obtained in Eq.(63)
K=c3+draine_precalc_data_array[draine_precalc_data_index].R1-
4*draine_precalc_data_array[draine_precalc_data_index].R2[i]+
8*draine_precalc_data_array[draine_precalc_data_index].R3[R3_INDEX(i,i)];
Expand Down Expand Up @@ -541,8 +541,8 @@ static void CoupleConstant(doublecomplex *mrel,const enum incpol which,doublecom
case POL_NLOC: // !!! additionally dynamic part should be added (if needed)
/* Here the polarizability is derived from the condition that V_d*sum(G_h(ri))=-4pi/3, where sum is
* taken over the whole lattice. Then M=4pi/3+V_d*Gh(0)=V_d*sum(G_h(ri),i!=0)
* Moreover, the regular part (in limit Rp->0) of Green's tensor automatically sums to zero, so only the
* irregular part need to be considered -h(r)*4pi/3, where h(r) is a normalized Gaussian
* Moreover, the regular part (in limit Rp->0) of Green's tensor automatically sums to zero, so only
* the irregular part need to be considered -h(r)*4pi/3, where h(r) is a normalized Gaussian
*/
if (polNlocRp==0) res[i]=polCM(mrel[i]);
else res[i]=polM(FOUR_PI_OVER_THREE*ellTheta(SQRT1_2PI*gridspace/polNlocRp),mrel[i]);
Expand Down
6 changes: 3 additions & 3 deletions src/chebyshev.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static double Zmax(double e)
tmp=e*(n2+1);
if (tmp>=-1) res=1+e;
/* two special cases for small n are based on direct solution of f'(x)=0; the formulae are self-derived but agree
* (for n=2) with A. Mugnai and W.J. Wiscombe, Scattering of radiation by moderately nonspherical particles,
* (for n=2) with A. Mugnai and W.J. Wiscombe, "Scattering of radiation by moderately nonspherical particles,"
* J. Atmos. Sci. 37, 1291-1307 (1980).
*/
else if (n==1) res=-1/(4*e);
Expand Down Expand Up @@ -169,8 +169,8 @@ void ChebyshevParams(double eps_in,int n_in,double *dx,double *dz,double *sz,dou
*dz=zmax-zmin;
*sz=(zmax+zmin)/2;
*dx=2*xmax;
/* determine volume fraction; the formula is self-derived but agrees with A. Mugnai and W.J. Wiscombe, Scattering
* of radiation by moderately nonspherical particles, J. Atmos. Sci. 37, 1291-1307 (1980).
/* determine volume fraction; the formula is self-derived but agrees with A. Mugnai and W.J. Wiscombe, "Scattering
* of radiation by moderately nonspherical particles," J. Atmos. Sci. 37, 1291-1307 (1980).
*/
tmp1=eps*eps/4;
tmp2=1+6*tmp1*(4*n2-2)/(4*n2-1);
Expand Down
2 changes: 1 addition & 1 deletion src/crosssec.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static inline void ScanString(FILE * restrict file,const char * restrict fname,c
*/
{
ReadLineStart(file,fname,buf,buf_size,start);
if (sscanf(buf+strlen(start),"%s",res)!=1)
if (sscanf(buf+strlen(start),"%s",res)!=1) // @suppress("Format String Vulnerability")
LogError(ONE_POS,"Error reading value after '%s' in file '%s'",start,fname);
/* More secure would be to put field width in format string above (like "%.Ns"), however this field width is
* defined by the variable buf_size. The latter can only be implemented by a preliminary printf to get a format
Expand Down
2 changes: 1 addition & 1 deletion src/fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void TransposeYZ(const int direction)
size_t enqtglobalzy[3]={gridZ,gridY,3*local_gridX};
size_t enqtglobalyz[3]={gridY,gridZ,3*local_gridX};

//if the grid is not dividable by blocksize, extend it. Kernel takes care of borders
// if the grid is not divisible by blocksize, extend it. Kernel takes care of borders
size_t tgridZ = (gridZ%blocksize==0) ? gridZ : (gridZ/blocksize+1)*blocksize;
size_t tgridY = (gridY%blocksize==0) ? gridY : (gridY/blocksize+1)*blocksize;
enqtglobalzy[0]=tgridZ;
Expand Down
2 changes: 1 addition & 1 deletion src/igt_so.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static inline void InitIGTvars(const double rvec[static restrict 3],double qmunu
doublecomplex_t result[static restrict 6],const double wave_num,const double ds_x,const double ds_y,
const double ds_z,double *rr,double *invr3,double *kr,double *kr2,double *D,double *u,double *invvol,double *ds_x2,
double *ds_y2,double *ds_z2,double *halfk2,double *invr,doublecomplex_t *expval,doublecomplex_t *ksi)
// initialize common variables, inluding point value of G
// initialize common variables, including point value of G
{
double qvec[3]; // scaled unit directional vector {rx,ry,rz}/r
*invvol=1.0/ds_x/ds_y/ds_z;
Expand Down
2 changes: 1 addition & 1 deletion src/interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void (*ReflTerm_real)(const double qvec[static restrict 3],doublecomplex result[
extern const double ZsumShift;
// defined and initialized in param.c
extern const double igt_lim,igt_eps,nloc_Rp;
extern const bool InteractionRealArgs;
// extern const bool InteractionRealArgs;

// used in fft.c
int local_Nz_Rm; // number of local layers in Rmatrix, not greater than 2*boxZ-1 (also used in SPARSE)
Expand Down
2 changes: 1 addition & 1 deletion src/iterative.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static const char *Print_clBLAS_Errstring(clblasStatus err)

static void Check_clBLAS_Err(const clblasStatus err,ERR_LOC_DECL)
/* Checks error code for clBLAS calls and prints error if necessary. First searches among clBLAS specific errors. If not
* found, uses general error processing for CL calls (since clBLAS error codes can take standard cl values as well).
* found, uses general error processing for CL calls (since clBLAS error codes can take standard CL values as well).
*/
{
if (err != clblasSuccess) {
Expand Down
6 changes: 3 additions & 3 deletions src/make_particle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,8 +1622,8 @@ void InitShape(void)
/* determined by equation: (a/r)^2=1+nu*cos(theta)-(1-eps)cos^2(theta) or equivalently:
* a^2=r^2+nu*r*z-(1-eps)z^2. Parameters must be 0<eps<=1, 0<=nu<eps. This shape is proposed in:
* Hahn D.V., Limsui D., Joseph R.I., Baldwin K.C., Boggs N.T., Carr A.K., Carter C.C., Han T.S., and
* Thomas M.E. "Shape characteristics of biological spores", paper 6954-31 to be presented at
* "SPIE Defence + Security", March 2008
* Thomas M.E. "Shape characteristics of biological spores", paper 6954-31, presented at
* "SPIE Defense + Security", March 2008
*/
double ad;
double ct,ct2; // cos(theta0) and its square
Expand Down Expand Up @@ -1879,7 +1879,7 @@ void InitShape(void)
Nmat_need=1;
/* Volume is given analytically by Eq.(4) in T. Wriedt, "Using the T-matrix method for light scattering
* computations by non-axisymmetric particles: Superellipsoids and realistically shaped particles," Part.
* Part. Sys. Charact. 19, 256-268 (2002).
* Part. Syst. Charact. 19, 256-268 (2002).
* Since the relevant box volume is 8a^3, the volume ratio (1/4)(b/a)(c/a)*n*B(n/2 +1,n)*e*B(e/2,e/2).
* Both n*B(n/2 +1,n) and e*B(e/2,e/2) are continuous to zero, and can be reliably computed using lgamma.
* Still we need to explicitly handle edge cases when n or e are 0.
Expand Down
2 changes: 1 addition & 1 deletion src/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,8 @@ static int TimeField(const char c)
case 'M': return 60;
case 's':
case 'S': return 1;
default: PrintErrorHelp("Illegal time format specifier (%c)",c);
}
PrintErrorHelp("Illegal time format specifier (%c)",c);
}

//======================================================================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/sinint.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Function for calculating sine and cosine integrals
*
* It was originaly based on routine given in "Numerical Recipes in C" 2nd ed. and then was slightly corrected according
* to the 3rd ed. of the same book.
* It was originally based on routine given in "Numerical Recipes in C" 2nd ed. and then was slightly corrected
* according to the 3rd ed. of the same book.
*
* Copyright (C) ADDA contributors
* This file is part of ADDA.
Expand Down
35 changes: 11 additions & 24 deletions src/somnec.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Two functions are copied from calculation.c and misc.c of the same package
* Further bug fixes and improvements were made by ADDA contributors (see git logs).
*
* Copyright (C) ADDA contributors (for changes over the original code)
* This file is part of ADDA, but can also be used separately.
*
* ADDA is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -82,7 +83,6 @@ static void lambda(double t,complex double *xlam,complex double *dxlam);
static void rom1(int n,complex double *sum,int nx);
static void saoa(double t,complex double *ans);
static void test(double f1r,double f2r,double *tr,double f1i,double f2i,double *ti,double dmin);
static void abort_on_error(int why);

// TODO: specify which function arguments are const, and try to make the whole routine thread-safe
// common /evlcom/
Expand Down Expand Up @@ -113,7 +113,7 @@ void som_init(complex double epscf)

ck2=TP;
ck2sq=ck2*ck2;
// sommerfeld integral evaluation uses exp(-iwt)
// Sommerfeld integral evaluation uses exp(-iwt)
ck1sq=ck2sq*epscf;
ck1=csqrt(ck1sq);
ck1r=creal(ck1);
Expand Down Expand Up @@ -363,7 +363,7 @@ void evlua(double zphIn,double rhoIn,complex double *erv,complex double *ezv,com
* figure) or (2) from c to infinity and then back to d along two vertical lines near the corresponding
* branch cuts. The choice of one over another depends on the |arg(a)| in asymptotic expression exp(-a*|xl|)
* for the integrand. We want to minimize this argument.
* In these cases, |tg[arg(a)]| is approximately tg[arg((Z-i*rho)*(d-c))] and Z/rho, respectively. Inverse
* In these cases, |tan[arg(a)]| is approximately tan[arg((Z-i*rho)*(d-c))] and Z/rho, respectively. Inverse
* of these quantities are compared in the following.
* Factor 4 seems to be an empirical one to balance the two options (either one finite integral or two
* infinite ones). However, this specific values is not discussed in any docs, moreover, based on the
Expand Down Expand Up @@ -407,7 +407,7 @@ void evlua(double zphIn,double rhoIn,complex double *erv,complex double *ezv,com
cp4=1.01*creal(ck1)+0.99*cimag(ck1)*I;
d34=cp4-cp3;
/* test if a direct line from cp3 will hit the branch cut from k1; if yes, integrate from from c to d and
* then to infinity, otherwise - directly from ñ to infinity
* then to infinity, otherwise - directly from c to infinity
*/
if (cimag(d34)<slope*creal(d34)) gshank(cp3,del*d34/cabs(d34),ans,6,sum,1,cp4,delta2);
else gshank(cp3,delta2,ans,6,sum,0,0,0);
Expand All @@ -434,7 +434,7 @@ void evlua(double zphIn,double rhoIn,complex double *erv,complex double *ezv,com
}
else gshank(cp3,del*conj(rot)*dP3/cabs(dP3),ans,6,sum,1,cp3+dP3*conj(rot),delta2);
}
else gshank(cp3,delta2,ans,6,sum,0,0,0); // from ñ directly to infinity on the figure
else gshank(cp3,delta2,ans,6,sum,0,0,0); // from c directly to infinity on the figure
}
}
ans[5]*=ck1;
Expand Down Expand Up @@ -559,7 +559,8 @@ static void gshank(complex double start,complex double dela,complex double *sum,
}
// No convergence
printf("z=%g, rho=%g\n",zph,rho);
abort_on_error(-6);
fprintf(stderr,"No convergence in gshank() - aborting. Try to increase MAXH in somnec.c and recompile\n");
exit(-6);
}

//======================================================================================================================
Expand Down Expand Up @@ -598,7 +599,10 @@ static void hankel(complex double z,complex double *h0,complex double *h0p)
}

zms=cAbs2(z);
if (zms==0) abort_on_error(-7);
if (zms==0) {
fprintf(stderr,"somnec.c: hankel not valid for z=0 - aborting\n");
exit(-7);
}
ib=0;
if (zms<=16.81) {
if (zms>16) ib=1;
Expand Down Expand Up @@ -902,20 +906,3 @@ static void test(double f1r,double f2r,double *tr,double f1i,double f2i,double *

return;
}

//======================================================================================================================

static void abort_on_error(int why)
// print error and abort
// TODO: remove this function and move the code to the callers
{
switch (why) {
case -6:
fprintf(stderr,"No convergence in gshank() - aborting. Try to increase MAXH in somnec.c and recompile\n");
break;
case -7:
fprintf(stderr,"somnec.c: hankel not valid for z=0 - aborting\n");
break;
}
exit(why);
}

0 comments on commit d8721ba

Please sign in to comment.