diff --git a/.gitignore b/.gitignore index 047d6f2f..b3422d8f 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,7 @@ test-driver *.sql *.sqlite .gdb_history +.tag* # OS generated files # ###################### diff --git a/applications/scuff-analyze/Makefile.am b/applications/scuff-analyze/Makefile.am index 940005d7..37fbb6ac 100644 --- a/applications/scuff-analyze/Makefile.am +++ b/applications/scuff-analyze/Makefile.am @@ -11,4 +11,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libSGJC \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-analyze/scuff-analyze.cc b/applications/scuff-analyze/scuff-analyze.cc index 22196e03..c55d3853 100644 --- a/applications/scuff-analyze/scuff-analyze.cc +++ b/applications/scuff-analyze/scuff-analyze.cc @@ -33,6 +33,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include "libscuff.h" #include "EquivalentEdgePairs.h" @@ -451,7 +455,7 @@ int main(int argc, char *argv[]) /***************************************************************/ /***************************************************************/ if (GeoFile==0 && MeshFile==0) - OSUsage(argv[0],OSArray,"either --geometry or --meshfile option must be specified"); + OSUsage(argv[0], VERSION, OSArray,"either --geometry or --meshfile option must be specified"); if (GeoFile!=0 && MeshFile!=0) ErrExit("--geometry and --meshfile options are mutually exclusive"); if (PhysicalRegion!=-1 && MeshFile==0) diff --git a/applications/scuff-cas2D/Makefile.am b/applications/scuff-cas2D/Makefile.am index b29ec0a7..a5097606 100644 --- a/applications/scuff-cas2D/Makefile.am +++ b/applications/scuff-cas2D/Makefile.am @@ -27,4 +27,5 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/libs/libSGJC \ -I$(top_srcdir)/libs/libMDInterp \ -I$(top_srcdir)/libs/libMatProp \ - -I$(top_srcdir)/libs/libhmat + -I$(top_srcdir)/libs/libhmat \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-cas3D/CreateSC3Data.cc b/applications/scuff-cas3D/CreateSC3Data.cc index b41bec97..25e9b606 100644 --- a/applications/scuff-cas3D/CreateSC3Data.cc +++ b/applications/scuff-cas3D/CreateSC3Data.cc @@ -224,7 +224,7 @@ void WriteFilePreamble(SC3Data *SC3D, int PreambleType) time_t MyTime = time(0); struct tm *MyTm=localtime(&MyTime); strftime(DateStr,30,"%D::%T",MyTm); - fprintf(f,"# scuff-cas3D run on %s at %s\n",GetHostName(),DateStr); + fprintf(f,"# scuff-cas3D " VERSIONSTRING " run on %s at %s\n",GetHostName(),DateStr); fprintf(f,"# data file columns: \n"); fprintf(f,"#1: transform tag\n"); diff --git a/applications/scuff-cas3D/Makefile.am b/applications/scuff-cas3D/Makefile.am index f51f2dd6..8cd54537 100644 --- a/applications/scuff-cas3D/Makefile.am +++ b/applications/scuff-cas3D/Makefile.am @@ -17,4 +17,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libSGJC \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-cas3D/scuff-cas3D.cc b/applications/scuff-cas3D/scuff-cas3D.cc index 399f151a..aefc6d26 100644 --- a/applications/scuff-cas3D/scuff-cas3D.cc +++ b/applications/scuff-cas3D/scuff-cas3D.cc @@ -29,6 +29,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include "scuff-cas3D.h" /***************************************************************/ @@ -145,7 +149,7 @@ int main(int argc, char *argv[]) /*******************************************************************/ /*******************************************************************/ if (GeoFile==0) - OSUsage(argv[0], OSArray, "--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray, "--geometry option is mandatory"); if (!FileBase) FileBase=vstrdup(GetFileBase(GeoFile)); diff --git a/applications/scuff-caspol/Makefile.am b/applications/scuff-caspol/Makefile.am index b5d9f5e8..4ebb8699 100644 --- a/applications/scuff-caspol/Makefile.am +++ b/applications/scuff-caspol/Makefile.am @@ -18,4 +18,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ -I$(top_srcdir)/libs/libMDInterp \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-caspol/PolModel.cc b/applications/scuff-caspol/PolModel.cc index f96c181a..374bba11 100644 --- a/applications/scuff-caspol/PolModel.cc +++ b/applications/scuff-caspol/PolModel.cc @@ -266,6 +266,8 @@ void PolModel::InitPolModel_BI(char *Atom) return; }; + // initialize MP, otherwise will be used in PolModel::GetPolarizability w/o assignment + MP = 0; // initialize the interpolator PolInterp = new Interp1D(XiPoints, PolPoints, NumPoints, 1); diff --git a/applications/scuff-caspol/scuff-caspol.cc b/applications/scuff-caspol/scuff-caspol.cc index 3f67dfc1..7736b60a 100644 --- a/applications/scuff-caspol/scuff-caspol.cc +++ b/applications/scuff-caspol/scuff-caspol.cc @@ -54,7 +54,7 @@ void WriteFilePreamble(SCPData *SCPD, const char *FileName, char TimeString[200]; strftime(TimeString,30,"%D::%T",MyTm); - fprintf(f,"# scuff-caspol running on %s (%s)\n",getenv("HOST"),TimeString); + fprintf(f,"# scuff-caspol " VERSIONSTRING " run on %s (%s)\n",getenv("HOST"),TimeString); fprintf(f,"#\n"); fprintf(f,"# command line:\n"); fprintf(f,"#\n"); diff --git a/applications/scuff-ldos/AnalyticalDGFs.cc b/applications/scuff-ldos/AnalyticalDGFs.cc index f864d77b..1844f50d 100644 --- a/applications/scuff-ldos/AnalyticalDGFs.cc +++ b/applications/scuff-ldos/AnalyticalDGFs.cc @@ -152,7 +152,7 @@ void HalfSpaceDGFIntegrand(const double *q, HalfSpaceData *Data, if (TwoPointDGF) XMatrix->GetEntriesD(nx,"3:5",XSource); - if ( abs(imag(qz*(XSource[2] + XDest[2])) > 40.0 ) ) + if ( abs(imag(qz*(XSource[2] + XDest[2]))) > 40.0 ) continue; double R[3]; diff --git a/applications/scuff-ldos/CreateSLDData.cc b/applications/scuff-ldos/CreateSLDData.cc index ff381573..6de8161e 100644 --- a/applications/scuff-ldos/CreateSLDData.cc +++ b/applications/scuff-ldos/CreateSLDData.cc @@ -37,7 +37,7 @@ void WriteFilePreamble(char *FileName, int FileType, int LDim, { FILE *f=fopen(FileName,"a"); - fprintf(f,"# scuff-ldos run on %s ",GetHostName()); + fprintf(f,"# scuff-ldos " VERSIONSTRING " run on %s ",GetHostName()); fprintf(f,"%s\n",GetTimeString()); fprintf(f,"# columns: \n"); diff --git a/applications/scuff-ldos/Makefile.am b/applications/scuff-ldos/Makefile.am index b5609f8c..e762e5a6 100644 --- a/applications/scuff-ldos/Makefile.am +++ b/applications/scuff-ldos/Makefile.am @@ -18,4 +18,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libSpherical \ -I$(top_srcdir)/libs/libTriInt \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-ldos/scuff-ldos.cc b/applications/scuff-ldos/scuff-ldos.cc index 6f6539a7..e794e3a3 100644 --- a/applications/scuff-ldos/scuff-ldos.cc +++ b/applications/scuff-ldos/scuff-ldos.cc @@ -24,6 +24,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -106,9 +110,9 @@ int main(int argc, char *argv[]) }; ProcessOptions(argc, argv, OSArray); if (GeoFile==0 && (SkipBZIntegration==false) ) - OSUsage(argv[0], OSArray,"--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray,"--geometry option is mandatory"); if (nEPFiles==0) - OSUsage(argv[0], OSArray,"you must specify at least one --EPFile"); + OSUsage(argv[0], VERSION, OSArray,"you must specify at least one --EPFile"); if (!FileBase) FileBase = vstrdup(GetFileBase(GeoFile)); if (HalfSpace) @@ -172,7 +176,8 @@ int main(int argc, char *argv[]) int LDim = Data->G->LDim; if (HalfSpace && LDim!=2) - OSUsage(argv[0],OSArray,"--HalfSpace requires a 2D-periodic geometry unless you also say --SkipBZIntegration"); + OSUsage(argv[0], VERSION, OSArray, + "--HalfSpace requires a 2D-periodic geometry unless you also say --SkipBZIntegration"); int NX = Data->TotalEvalPoints; int NFun = Data->LDOSOnly ? 2 : 38; // # outputs per eval pt diff --git a/applications/scuff-microstrip/scuff-microstrip.cc b/applications/scuff-microstrip/scuff-microstrip.cc index d67d96c1..9698cf80 100644 --- a/applications/scuff-microstrip/scuff-microstrip.cc +++ b/applications/scuff-microstrip/scuff-microstrip.cc @@ -30,6 +30,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -166,9 +170,9 @@ int main(int argc, char *argv[]) }; ProcessOptions(argc, argv, OSArray); if (GeoFile==0) - OSUsage(argv[0],OSArray,"--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray,"--geometry option is mandatory"); if (PortFile==0) - OSUsage(argv[0],OSArray,"--PortFileName option is mandatory"); + OSUsage(argv[0], VERSION, OSArray,"--PortFileName option is mandatory"); if (!FileBase) FileBase=strdup(GetFileBase(GeoFile)); @@ -228,13 +232,13 @@ int main(int argc, char *argv[]) /* sanity check input arguments ********************************/ /***************************************************************/ if (PCFile==0 && FreqList->N!=0 && (ZParms==0 && SParms==0) ) - OSUsage(argv[0],OSArray,"--ZParameters and/or --SParameters must be specified if a frequency specification is present"); + OSUsage(argv[0], VERSION, OSArray,"--ZParameters and/or --SParameters must be specified if a frequency specification is present"); if (PCFile!=0 && (ZParms!=0 || SParms!=0) ) - OSUsage(argv[0],OSArray,"--ZParameters and --SParameters may not be used with --PortCurrentFile"); + OSUsage(argv[0], VERSION, OSArray,"--ZParameters and --SParameters may not be used with --PortCurrentFile"); //if (PCFile!=0 && nEPFiles==0 && nFVMeshes==0) - //OSUsage(argv[0],OSArray,"--EPFile or --FVMesh must be specified if --PortCurrentFile is specified"); + //OSUsage(argv[0], VERSION, OSArray,"--EPFile or --FVMesh must be specified if --PortCurrentFile is specified"); if (PCFile==0 && (nEPFiles!=0 || nFVMeshes!=0) ) - OSUsage(argv[0],OSArray,"--EPFile and --FVMesh require --PortCurrentFile"); + OSUsage(argv[0], VERSION, OSArray,"--EPFile and --FVMesh require --PortCurrentFile"); /***************************************************************/ /* process list of geometric transformations, if any */ diff --git a/applications/scuff-microstrip/tests/tInterpolation.cc b/applications/scuff-microstrip/tests/tInterpolation.cc index 47ee546c..c6e4a7c6 100644 --- a/applications/scuff-microstrip/tests/tInterpolation.cc +++ b/applications/scuff-microstrip/tests/tInterpolation.cc @@ -26,6 +26,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include "libhrutil.h" #include "libSGJC.h" #include "libSubstrate.h" @@ -98,9 +102,9 @@ int main(int argc, char *argv[]) }; ProcessOptions(argc, argv, OSArray); if (GeoFile==0) - OSUsage(argv[0],OSArray,"--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray,"--geometry option is mandatory"); if (EPFile==0) - OSUsage(argv[0],OSArray,"--epfile option is mandatory"); + OSUsage(argv[0], VERSION, OSArray,"--epfile option is mandatory"); RWGGeometry *G = new RWGGeometry(GeoFile); diff --git a/applications/scuff-neq/CreateSNEQData.cc b/applications/scuff-neq/CreateSNEQData.cc index b1a6186a..fbc6489a 100644 --- a/applications/scuff-neq/CreateSNEQData.cc +++ b/applications/scuff-neq/CreateSNEQData.cc @@ -46,7 +46,7 @@ void WriteSIFluxFilePreamble(SNEQData *SNEQD, char *FileName, bool ByRegion=fals { FILE *f = ByRegion ? vfopen("%s.byRegion","a",FileName) : fopen(FileName,"a"); fprintf(f,"\n"); - fprintf(f,"# scuff-neq run on "); + fprintf(f,"# scuff-neq " VERSIONSTRING " run on "); fprintf(f,"%s (%s)\n",GetHostName(),GetTimeString()); fprintf(f,"# data file columns: \n"); fprintf(f,"# 1 transform tag\n"); @@ -217,7 +217,7 @@ SNEQData *CreateSNEQData(char *GeoFile, char *TransFile, if (SNEQD->NumSRQs>0) { FILE *f=vfopen("%s.SRFlux","a",SNEQD->FileBase); fprintf(f,"\n"); - fprintf(f,"# scuff-neq run on %s (%s)\n",GetHostName(),GetTimeString()); + fprintf(f,"# scuff-neq " VERSIONSTRING " run on %s (%s)\n",GetHostName(),GetTimeString()); fprintf(f,"# data file columns: \n"); fprintf(f,"# 1 transform tag\n"); fprintf(f,"# 2 omega \n"); diff --git a/applications/scuff-neq/Makefile.am b/applications/scuff-neq/Makefile.am index 1d786fda..685d213d 100644 --- a/applications/scuff-neq/Makefile.am +++ b/applications/scuff-neq/Makefile.am @@ -20,4 +20,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libSGJC \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-neq/scuff-integrate.cc b/applications/scuff-neq/scuff-integrate.cc index 6f43ebee..fe893aed 100644 --- a/applications/scuff-neq/scuff-integrate.cc +++ b/applications/scuff-neq/scuff-integrate.cc @@ -36,6 +36,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include @@ -225,7 +229,7 @@ int main(int argc, char *argv[]) ProcessOptions(argc, argv, OSArray); if (DataFileName==0) - OSUsage(argv[0],OSArray,"--DataFile option is mandatory"); + OSUsage(argv[0], VERSION,OSArray,"--DataFile option is mandatory"); /***************************************************************/ /* auto-detect special known file types and autoset values of */ @@ -290,11 +294,11 @@ int main(int argc, char *argv[]) /* sanity checks ***********************************************/ /***************************************************************/ if (NumData==0) - OSUsage(argv[0],OSArray,"you must specify at least one --DataColumn"); + OSUsage(argv[0], VERSION, OSArray,"you must specify at least one --DataColumn"); if (nDataNames!=0 && nDataNames!=NumData) - OSUsage(argv[0],OSArray,"numbers of --DataNames and --DataColumns do not agree"); + OSUsage(argv[0], VERSION, OSArray,"numbers of --DataNames and --DataColumns do not agree"); if (nParmNames!=0 && nParmNames!=NumParms) - OSUsage(argv[0],OSArray,"numbers of --ParmNames and --ParmColumns do not agree"); + OSUsage(argv[0], VERSION, OSArray,"numbers of --ParmNames and --ParmColumns do not agree"); if (nDataNames==0) for(int nd=0; nd #include #include + +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include "scuff-neq.h" #include @@ -139,7 +144,7 @@ int main(int argc, char *argv[]) /*******************************************************************/ /*******************************************************************/ if (GeoFile==0) - OSUsage(argv[0], OSArray, "--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray, "--geometry option is mandatory"); if (!FileBase) FileBase=vstrdup(GetFileBase(GeoFile)); diff --git a/applications/scuff-rf/Makefile.am b/applications/scuff-rf/Makefile.am index cf1d681b..4263952d 100644 --- a/applications/scuff-rf/Makefile.am +++ b/applications/scuff-rf/Makefile.am @@ -21,4 +21,5 @@ AM_CPPFLAGS = -DSCUFF \ -I$(top_srcdir)/libs/libhmat \ -I$(top_srcdir)/libs/libSGJC \ -I$(top_srcdir)/libs/libSubstrate \ - -I$(top_srcdir)/libs/libTriInt + -I$(top_srcdir)/libs/libTriInt \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-rf/scuff-rf.cc b/applications/scuff-rf/scuff-rf.cc index 90dd4bb1..e07c67b6 100644 --- a/applications/scuff-rf/scuff-rf.cc +++ b/applications/scuff-rf/scuff-rf.cc @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) }; ProcessOptions(argc, argv, OSArray); if (GeoFile==0) - OSUsage(argv[0],OSArray,"--geometry option is mandatory"); + OSUsage(argv[0],VERSIONSTRING,OSArray,"--geometry option is mandatory"); if (!FileBase) FileBase=strdup(GetFileBase(GeoFile)); @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) /***************************************************************/ SetLogFileName("scuff-rf.log"); int narg; - Log("%s running on %s with arguments ",argv[0],getenv("HOST")); + Log("%s " VERSIONSTRING " running on %s with arguments ",argv[0],getenv("HOST")); Log("%s ",argv[0]); for(narg=1; narg #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include "scuff-scatter.h" /***************************************************************/ @@ -179,7 +183,7 @@ int main(int argc, char *argv[]) ProcessOptions(argc, argv, OSArray); if (GeoFile==0) - OSUsage(argv[0], OSArray, "--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray, "--geometry option is mandatory"); if (FileBase==0) FileBase=vstrdup(GetFileBase(GeoFile)); @@ -190,7 +194,7 @@ int main(int argc, char *argv[]) HVector *OmegaList=GetOmegaList(OmegaFile, OmegaVals, nOmegaVals, LambdaFile, LambdaVals, nLambdaVals); if (OmegaList==0) - OSUsage(argv[0], OSArray, "you must specify at least one frequency"); + OSUsage(argv[0], VERSION, OSArray, "you must specify at least one frequency"); /*******************************************************************/ /* process incident-field-related options to construct the data */ diff --git a/applications/scuff-spectrum/Makefile.am b/applications/scuff-spectrum/Makefile.am index 32666f89..f1183da7 100644 --- a/applications/scuff-spectrum/Makefile.am +++ b/applications/scuff-spectrum/Makefile.am @@ -14,6 +14,7 @@ tBeyn411_LDADD = libBeyn.la \ $(top_builddir)/libs/libhrutil/libhrutil.la AM_CPPFLAGS = -DSCUFF \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\"\ -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libIncField \ -I$(top_srcdir)/libs/libMatProp \ @@ -23,4 +24,4 @@ AM_CPPFLAGS = -DSCUFF \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ -I$(top_srcdir)/libs/libhrutil \ - -I$(top_builddir) # for config.h + -I$(top_builddir) # for config.h diff --git a/applications/scuff-spectrum/OutputModules.cc b/applications/scuff-spectrum/OutputModules.cc index 5ec2fb84..bf41807e 100644 --- a/applications/scuff-spectrum/OutputModules.cc +++ b/applications/scuff-spectrum/OutputModules.cc @@ -66,7 +66,7 @@ void ProcessEPFile(RWGGeometry *G, HVector *KN, cdouble Omega, double *kBloch, /*--------------------------------------------------------------*/ SetDefaultCD2SFormat("%+.8e %+.8e "); FILE *f=vfopen("%s.%s.ModeFields","w",OutFileBase,GetFileBase(EPFileName)); - fprintf(f,"# scuff-spectrum run on %s (%s)\n",GetHostName(),GetTimeString()); + fprintf(f,"# scuff-spectrum " VERSIONSTRING " run on %s (%s)\n",GetHostName(),GetTimeString()); fprintf(f,"# columns: \n"); fprintf(f,"# 1,2,3 x,y,z (evaluation point coordinates)\n"); fprintf(f,"# 4 5 re,im omega (angular frequency)\n"); diff --git a/applications/scuff-spectrum/scuff-spectrum.cc b/applications/scuff-spectrum/scuff-spectrum.cc index 9e1fe1f0..5057137d 100644 --- a/applications/scuff-spectrum/scuff-spectrum.cc +++ b/applications/scuff-spectrum/scuff-spectrum.cc @@ -7,6 +7,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -155,7 +159,7 @@ int main(int argc, char *argv[]) }; ProcessOptions(argc, argv, OSArray); if (GeoFile==0) - OSUsage(argv[0],OSArray,"--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray,"--geometry option is mandatory"); if (FileBase==0) FileBase=strdup(GetFileBase(GeoFile)); @@ -188,7 +192,7 @@ int main(int argc, char *argv[]) /* open eigenfrequency output file and write file header */ /***************************************************************/ FILE *f=vfopen("%s.ModeFrequencies","a",FileBase); - fprintf(f,"#%s running on %s (%s)\n",argv[0], GetHostName(), GetTimeString()); + fprintf(f,"#%s " VERSION " run on %s (%s)\n",argv[0], GetHostName(), GetTimeString()); fclose(f); /***************************************************************/ diff --git a/applications/scuff-static/Makefile.am b/applications/scuff-static/Makefile.am index d5bf1191..8f5c0620 100644 --- a/applications/scuff-static/Makefile.am +++ b/applications/scuff-static/Makefile.am @@ -20,4 +20,5 @@ AM_CPPFLAGS = -I$(top_srcdir)/libs/libscuff \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ -I$(top_srcdir)/libs/libStaticSolver \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe always --dirty)\" diff --git a/applications/scuff-static/OutputModules.cc b/applications/scuff-static/OutputModules.cc index 6f83f5bc..b607b052 100644 --- a/applications/scuff-static/OutputModules.cc +++ b/applications/scuff-static/OutputModules.cc @@ -67,7 +67,7 @@ void WriteFields(StaticSolver *SS, HVector *Sigma, StaticExcitation *SE, else snprintf(FileName, MAXSTR, "%s.%s.out",OutFileBase,GetFileBase(EPFiles[nepf])); FILE *f=fopen(FileName,Separate ? "w" : "a"); - fprintf(f,"# scuff-static run on %s (%s)",GetHostName(),GetTimeString()); + fprintf(f,"# scuff-static " VERSIONSTRING " run on %s (%s)",GetHostName(),GetTimeString()); fprintf(f,"# data file columns: \n"); int nc=1; if (!Separate && TransformLabel) @@ -138,7 +138,7 @@ void WritePolarizabilities(StaticSolver *SS, HMatrix *M, HVector *Sigma, char *P FILE *f=fopen(PolFile,"a"); if (!WroteHeader) { WroteHeader=true; - fprintf(f,"# scuff-static run on %s (%s)",GetHostName(),GetTimeString()); + fprintf(f,"# scuff-static " VERSIONSTRING " run on %s (%s)",GetHostName(),GetTimeString()); fprintf(f,"# data file columns: \n"); int nc=1; if (SS->TransformLabel) @@ -196,7 +196,7 @@ void WriteCapacitanceMatrix(StaticSolver *SS, HMatrix *M, RWGGeometry *G=SS->G; if (WroteHeader==false) { WroteHeader=true; - fprintf(f,"# scuff-static run on %s (%s)",GetHostName(),GetTimeString()); + fprintf(f,"# scuff-static " VERSIONSTRING " run on %s (%s)",GetHostName(),GetTimeString()); fprintf(f,"# indices of conducting surfaces: "); fprintf(f,"# data file columns: \n"); int NCS=0; diff --git a/applications/scuff-static/scuff-static.cc b/applications/scuff-static/scuff-static.cc index 492b7981..dab295d7 100644 --- a/applications/scuff-static/scuff-static.cc +++ b/applications/scuff-static/scuff-static.cc @@ -29,6 +29,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include "scuff-static.h" using namespace scuff; @@ -155,7 +159,7 @@ int main(int argc, char *argv[]) ProcessOptions(argc, argv, OSArray); if (GeoFile==0) - OSUsage(argv[0], OSArray, "--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray, "--geometry option is mandatory"); if (nlMax && (CMatrixFile==0 || CMatrixHDF5File) ) ErrExit("--lMax option can only be used with --CMatrixFile or --CMatrixHDF5File"); @@ -174,7 +178,7 @@ int main(int argc, char *argv[]) ); if ( (!HaveType1Outputs) && (!HaveType2Outputs) ) - OSUsage(argv[0], OSArray, "you have not selected any type of calculation"); + OSUsage(argv[0], VERSION, OSArray, "you have not selected any type of calculation"); if (HaveType1Outputs && HaveType2Outputs) ErrExit("{--EPFile,--FVMesh{ may not be used with {--polfilebase, --capfilebase}"); if (HaveType1Outputs && HaveType2Inputs) diff --git a/applications/scuff-tmatrix/Makefile.am b/applications/scuff-tmatrix/Makefile.am index aff4fbd4..eb9f00fa 100644 --- a/applications/scuff-tmatrix/Makefile.am +++ b/applications/scuff-tmatrix/Makefile.am @@ -15,4 +15,5 @@ AM_CPPFLAGS = -DSCUFF \ -I$(top_srcdir)/libs/libSpherical \ -I$(top_srcdir)/libs/libSubstrate \ -I$(top_srcdir)/libs/libTriInt \ - -I$(top_srcdir)/libs/libhrutil + -I$(top_srcdir)/libs/libhrutil \ + -DVERSIONSTRING=\"$(shell git describe --always --dirty)\" diff --git a/applications/scuff-tmatrix/scuff-tmatrix.cc b/applications/scuff-tmatrix/scuff-tmatrix.cc index bf7a373e..9da15aa7 100644 --- a/applications/scuff-tmatrix/scuff-tmatrix.cc +++ b/applications/scuff-tmatrix/scuff-tmatrix.cc @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) }; ProcessOptions(argc, argv, OSArray); if (GeoFileName==0) - OSUsage(argv[0],OSArray,"--geometry option is mandatory"); + OSUsage(argv[0],VERSIONSTRING,OSArray,"--geometry option is mandatory"); /*--------------------------------------------------------------*/ /*- process frequency options ----------------------------------*/ @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) OmegaVector->SetEntry(0,Omega); } else - OSUsage(argv[0],OSArray,"either --omega or --omegafile must be specified"); + OSUsage(argv[0],VERSIONSTRING,OSArray,"either --omega or --omegafile must be specified"); /*--------------------------------------------------------------*/ /* create the RWGGeometry from the .scuffgeo file */ @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) if (!FileBase) FileBase = vstrdup(GetFileBase(GeoFileName)); FILE *f=vfopen("%s.TMatrix","a",FileBase); - fprintf(f,"# scuff-tmatrix run on %s (%s)\n",GetHostName(),GetTimeString()); + fprintf(f,"# scuff-tmatrix " VERSIONSTRING " run on %s (%s)\n",GetHostName(),GetTimeString()); fprintf(f,"# columns:\n"); fprintf(f,"# 1 omega\n"); fprintf(f,"# 2,3,4,5 (alpha, {L,M,P}_alpha) (T-matrix row index)\n"); @@ -147,10 +147,34 @@ int main(int argc, char *argv[]) { Log("Computing T matrix at frequency %s...",z2s(Omega)); + Omega=OmegaVector->GetEntry(nOmega); + + /*----------------------------------------------*/ + /* Early check of material properties validity */ + /*----------------------------------------------*/ + G->UpdateCachedEpsMuValues(Omega); + { + int material_invalid = 0; + + for (int regi = 0; regi < G->NumRegions; ++regi) + if ( isnan(real(G->EpsTF[regi])) + || isnan(imag(G->EpsTF[regi])) + || isnan(real(G->MuTF[regi])) + || isnan(imag(G->MuTF[regi])) ) + ++material_invalid; + + if (material_invalid) { + Log("Some of the regions contain invalid material properties at frequency %s; giving up.", z2s(Omega)); + Log(" (Check the frequency ranges in the material data files.)"); + fprintf(f, "# %s\tnot computed due to invalid material properties;" + " check the frequency ranges in the material data files.\n", z2s(Omega)); + continue; + } + } + /*--------------------------------------------------------------*/ /* assemble and factorize the BEM matrix at this frequency */ /*--------------------------------------------------------------*/ - Omega=OmegaVector->GetEntry(nOmega); G->AssembleBEMMatrix(Omega, M); M->LUFactorize(); diff --git a/applications/scuff-transmission/scuff-transmission.cc b/applications/scuff-transmission/scuff-transmission.cc index 17fc3fa2..596cf6e4 100644 --- a/applications/scuff-transmission/scuff-transmission.cc +++ b/applications/scuff-transmission/scuff-transmission.cc @@ -26,6 +26,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include "scuff-transmission.h" @@ -85,7 +89,7 @@ bool GetSourceDestRegions(RWGGeometry *G, bool FromAbove, /***************************************************************/ void WriteFilePreamble(FILE *f) { - fprintf(f,"# scuff-transmission run on %s (%s)\n", + fprintf(f,"# scuff-transmission " VERSION " run on %s (%s)\n", GetHostName(),GetTimeString()); fprintf(f,"# data file columns: \n"); fprintf(f,"# 1: omega \n"); @@ -232,11 +236,11 @@ int main(int argc, char *argv[]) /*******************************************************************/ /*******************************************************************/ if (GeoFileName==0) - OSUsage(argv[0], OSArray, "--geometry option is mandatory"); + OSUsage(argv[0], VERSION, OSArray, "--geometry option is mandatory"); if (!FileBase) FileBase=vstrdup(GetFileBase(GeoFileName)); SetLogFileName("%s.log",FileBase); - Log("scuff-transmission running on %s",GetHostName()); + Log("scuff-transmission" VERSION " running on %s",GetHostName()); /*******************************************************************/ /*- create the RWGGeometry -*/ @@ -265,7 +269,7 @@ int main(int argc, char *argv[]) /*******************************************************************/ HVector *OmegaVector=GetOmegaList(OmegaFile, OmegaVals, nOmegaVals, LambdaFile, LambdaVals, nLambdaVals); if ( !OmegaVector || OmegaVector->N==0) - OSUsage(argv[0], OSArray, "you must specify at least one frequency"); + OSUsage(argv[0], VERSION, OSArray, "you must specify at least one frequency"); /*******************************************************************/ /* process incident-angle-related options to construct a list of */ @@ -278,7 +282,7 @@ int main(int argc, char *argv[]) HVector *ThetaVector; if ( ThetaMax!=0.0 ) { if ( ThetaMax #include #include #include #include -#define II cdouble(0.0,1.0) - /**********************************************************************/ /* constructor and field-setting routines *****************************/ /**********************************************************************/ @@ -57,10 +54,8 @@ void SphericalWave::GetFields(const double X[3], cdouble EHC[6]) cdouble Z=ZVAC*sqrt(Mu/Eps); // convert the evaluation point to spherical coordinates - double XX[3]; - memcpy(XX, X, 3*sizeof(double)); double r, Theta, Phi; - CoordinateC2S(XX, &r, &Theta, &Phi); + CoordinateC2S(X, &r, &Theta, &Phi); // get the M and N vector spherical harmonics cdouble MVec[3], NVec[3]; diff --git a/libs/libMatProp/libMatProp.cc b/libs/libMatProp/libMatProp.cc index 6507a86f..3af4c937 100644 --- a/libs/libMatProp/libMatProp.cc +++ b/libs/libMatProp/libMatProp.cc @@ -528,17 +528,25 @@ void MatProp::GetEpsMu(cdouble Omega, cdouble *pEps, cdouble *pMu) { if (InterpReal==0) ErrExit("no real-frequency data given in material data file %s",Name+5); - InterpReal->Evaluate(real(Omega)*FreqUnit, Data); - EpsRV=cdouble(Data[0], Data[1]); - MuRV=cdouble(Data[2], Data[3]); + if(InterpReal->Evaluate(real(Omega)*FreqUnit, Data)) { + EpsRV=cdouble(Data[0], Data[1]); + MuRV=cdouble(Data[2], Data[3]); + } else { + EpsRV = MuRV = cdouble(NAN, NAN); + Warn("Setting Eps, Mu to NaN: frequency %s outside the interpolation range in data file %s.", z2s(Omega), Name+5); + } } else if (real(Omega)==0.0) { if (InterpImag==0) - ErrExit("no imaginary-frequency data given in material data file %s",Name+5); - InterpImag->Evaluate(imag(Omega)*FreqUnit, Data); - EpsRV=cdouble(Data[0], 0.0); - MuRV=cdouble(Data[2], 0.0); + ErrExit("no imaginary-frequency data given in material data file %s); setting Eps, Mu to NaN.",Name+5); + if(InterpImag->Evaluate(imag(Omega)*FreqUnit, Data)) { + EpsRV=cdouble(Data[0], 0.0); + MuRV=cdouble(Data[2], 0.0); + } else { + EpsRV = MuRV = cdouble(NAN, NAN); + Warn("Setting Eps, Mu to NaN: frequency %s outside the interpolation range in data file %s.", z2s(Omega), Name+5); + } } else ErrExit("interpolated frequencies must lie on the real or imaginary axis"); @@ -546,7 +554,9 @@ void MatProp::GetEpsMu(cdouble Omega, cdouble *pEps, cdouble *pMu) else if ( Type==MP_PARSED ) { GetEpsMu_Parsed(Omega, &EpsRV, &MuRV); - }; // if (Type==... ) + } // if (Type==... ) + else + ErrExit("Invalid material property type"); if (pEps) *pEps=EpsRV; if (pMu) *pMu=MuRV; diff --git a/libs/libSGJC/libSGJC.h b/libs/libSGJC/libSGJC.h index 50199d01..6ddbee1a 100644 --- a/libs/libSGJC/libSGJC.h +++ b/libs/libSGJC/libSGJC.h @@ -106,7 +106,7 @@ int pcubature_v_buf(unsigned fdim, integrand_v f, void *fdata, error_norm norm, unsigned *m, double **buf, size_t *nbuf, size_t max_nbuf, - double *val, double *err, char *LogFileName); + double *val, double *err, const char *LogFileName); int pcubature_v(unsigned fdim, integrand_v f, void *fdata, unsigned dim, const double *xmin, const double *xmax, diff --git a/libs/libSGJC/pcubature.c b/libs/libSGJC/pcubature.c index 1f383d7c..d0c3548d 100644 --- a/libs/libSGJC/pcubature.c +++ b/libs/libSGJC/pcubature.c @@ -284,7 +284,7 @@ static int converged(unsigned fdim, const double *vals, const double *errs, /***************************************************************/ /* HR 201308 status logging ************************************/ /***************************************************************/ -void SGJCLog(char *LogFileName, int numEvals, +void SGJCLog(const char *LogFileName, int numEvals, unsigned fdim, const double *vals, const double *errs) { int nf; @@ -314,7 +314,7 @@ int pcubature_v_buf(unsigned fdim, integrand_v f, void *fdata, error_norm norm, unsigned *m, double **buf, size_t *nbuf, size_t max_nbuf, - double *val, double *err, char *LogFileName) + double *val, double *err, const char *LogFileName) { int ret = FAILURE; double V = 1; diff --git a/libs/libSpherical/VectorSphericalWaves.cc b/libs/libSpherical/VectorSphericalWaves.cc index b079591f..84b139b0 100644 --- a/libs/libSpherical/VectorSphericalWaves.cc +++ b/libs/libSpherical/VectorSphericalWaves.cc @@ -246,7 +246,7 @@ HMatrix *GetWaveMatrix(double r, double Theta, double Phi, cdouble *RFArray = dYdThetaArray + NAlpha; cdouble *dWorkspace = RFArray + 3*(LMax+1); - GetVSWRadialFunctions(LMax, k, r, WaveType, RFArray, (double *)dWorkspace, RConjugate); + GetVSWRadialFunctions(LMax, k, r, WaveType, RFArray, (double *)dWorkspace, /* TimesrFactor */ false, RConjugate); /***************************************************************/ /* fetch angular functions */ @@ -273,6 +273,12 @@ HMatrix *GetWaveMatrix(double r, double Theta, double Phi, AA[1][2] = +1.0*II*AA[0][1]; AA[2][0] = YArray[Alpha]; + // This is quite obscure; it seems that it gives the right result + // for transversal waves only (MaxwellWaves = true), but I (MMN) + // believe that it gives some nonsense otherwise. Therefore: + if(!MaxwellWaves) ErrExit("Before trying to compute the full set of " + "VSWFs, you should fix the code after line %d in file %s.", + __LINE__, __FILE__); for(int P=0; P<3; P++) { int Index = MaxwellWaves ? GetMWIndex(L, M, (P==0) ? 0 : 1) diff --git a/libs/libSpherical/libSpherical.cc b/libs/libSpherical/libSpherical.cc index d6eb610c..ae60499b 100644 --- a/libs/libSpherical/libSpherical.cc +++ b/libs/libSpherical/libSpherical.cc @@ -52,10 +52,10 @@ void CoordinateC2S(double X, double Y, double Z, double *r, double *Theta, doubl *Phi=atan2(Y,X); } -void CoordinateC2S(double X[3], double *r, double *Theta, double *Phi) +void CoordinateC2S(const double X[3], double *r, double *Theta, double *Phi) { CoordinateC2S(X[0], X[1], X[2], r, Theta, Phi); } -void CoordinateC2S(double X[3], double R[3]) +void CoordinateC2S(const double X[3], double R[3]) { CoordinateC2S(X[0], X[1], X[2], R+0, R+1, R+2); } void CoordinateC2S(double X[3]) @@ -82,7 +82,7 @@ void CoordinateS2C(double r, double Theta, double Phi, double *X, double *Y, dou void CoordinateS2C(double r, double Theta, double Phi, double X[3]) { CoordinateS2C(r, Theta, Phi, X+0, X+1, X+2); } -void CoordinateS2C(double R[3], double X[3]) +void CoordinateS2C(const double R[3], double X[3]) { CoordinateS2C(R[0], R[1], R[2], X+0, X+1, X+2); } void CoordinateS2C(double R[3]) @@ -97,7 +97,7 @@ void CoordinateS2C(double R[3]) /* given the cartesian components of a vector, return its */ /* spherical components. */ /***************************************************************/ -void VectorC2S(double Theta, double Phi, cdouble VC[3], cdouble VS[3]) +void VectorC2S(double Theta, double Phi, const cdouble VC[3], cdouble VS[3]) { double CT=cos(Theta), ST=sin(Theta); double CP=cos(Phi), SP=sin(Phi); @@ -126,7 +126,7 @@ void VectorC2S(double Theta, double Phi, double V[3]) V[0]=VS[0]; V[1]=VS[1]; V[2]=VS[2]; } -void VectorC2S(double Theta, double Phi, double VC[3], double VS[3]) +void VectorC2S(double Theta, double Phi, const double VC[3], double VS[3]) { double CT=cos(Theta), ST=sin(Theta); double CP=cos(Phi), SP=sin(Phi); @@ -160,7 +160,7 @@ void VectorS2C(double Theta, double Phi, double V[3]) /* given the spherical components of a vector, return its */ /* cartesian components. */ /***************************************************************/ -void VectorS2C(double Theta, double Phi, cdouble VS[3], cdouble VC[3]) +void VectorS2C(double Theta, double Phi, const cdouble VS[3], cdouble VC[3]) { double CT=cos(Theta), ST=sin(Theta); double CP=cos(Phi), SP=sin(Phi); @@ -178,7 +178,7 @@ void VectorS2C(double Theta, double Phi, cdouble VS[3], cdouble VC[3]) } -void VectorS2C(double Theta, double Phi, double VS[3], double VC[3]) +void VectorS2C(double Theta, double Phi, const double VS[3], double VC[3]) { double CT=cos(Theta), ST=sin(Theta); double CP=cos(Phi), SP=sin(Phi); @@ -279,7 +279,7 @@ cdouble GetYlm(int l, int m, double Theta, double Phi) GetPlm(l, abs(m), cos(Theta), Plm, PlmPrime); if (m<0) - RetVal = ((m%1) ? -1.0 : 1.0) * Plm[l-abs(m)] * exp(-1.0*II*mPhi); + RetVal = ((m%1) ? -1.0 : 1.0) * Plm[l-abs(m)] * exp(II*mPhi); else RetVal = Plm[l-m]*exp(II*mPhi); @@ -760,7 +760,7 @@ void GetMNlmArray(int lMax, cdouble k, { int NAlpha=(lMax+1)*(lMax+1); int Alpha, l, m; - double SinTheta, dl, dm; + double SinTheta; cdouble nik, PreFac; cdouble ROverR; cdouble *R = new cdouble[lMax+2]; @@ -798,13 +798,10 @@ void GetMNlmArray(int lMax, cdouble k, for (Alpha=l=1; l<=lMax; l++) for (m=-l; m<=l; m++, Alpha++) { - dl=((double)l); - dm=((double)m); - - PreFac=1.0/sqrt( dl*(dl+1.0) ); + PreFac=1.0/sqrt( l*(l+1.0) ); M[3*Alpha + 0]= 0.0; - M[3*Alpha + 1]= -dm*PreFac*R[l]*Ylm[Alpha]/SinTheta; + M[3*Alpha + 1]= -(double)m*PreFac*R[l]*Ylm[Alpha]/SinTheta; M[3*Alpha + 2]= -II*PreFac*R[l]*dYlmdTheta[Alpha]; #if 0 @@ -815,9 +812,9 @@ void GetMNlmArray(int lMax, cdouble k, ROverR = (l==1) ? k/3.0 : 0.0; else ROverR=R[l]/r; - N[3*Alpha + 0]= -sqrt(dl*(dl+1.0))*ROverR*Ylm[Alpha]/k; + N[3*Alpha + 0]= -sqrt(l*(l+1.0))*ROverR*Ylm[Alpha]/k; N[3*Alpha + 1]= II*PreFac*(ROverR + dRdr[l])*dYlmdTheta[Alpha]; - N[3*Alpha + 2]= -dm*PreFac*(ROverR + dRdr[l])*Ylm[Alpha]/SinTheta; + N[3*Alpha + 2]= -(double)m*PreFac*(ROverR + dRdr[l])*Ylm[Alpha]/SinTheta; #endif PreFac/=k; @@ -825,14 +822,14 @@ void GetMNlmArray(int lMax, cdouble k, ROverR = (l==1) ? k/3.0 : 0.0; else ROverR=R[l]/r; - N[3*Alpha + 0]= -sqrt(dl*(dl+1.0))*ROverR*Ylm[Alpha]/k; + N[3*Alpha + 0]= -sqrt(l*(l+1.0))*ROverR*Ylm[Alpha]/k; N[3*Alpha + 1]= -PreFac*(ROverR + dRdr[l])*dYlmdTheta[Alpha]; - N[3*Alpha + 2]= -II*dm*PreFac*(ROverR + dRdr[l])*Ylm[Alpha]/SinTheta; + N[3*Alpha + 2]= -II*(double)m*PreFac*(ROverR + dRdr[l])*Ylm[Alpha]/SinTheta; if (LL) { LL[3*Alpha + 0] = PreFac*dRdr[l] * Ylm[Alpha]; LL[3*Alpha + 1] = PreFac*ROverR*dYlmdTheta[Alpha]; - LL[3*Alpha + 2] = PreFac*II*dm*ROverR * Ylm[Alpha] / SinTheta; + LL[3*Alpha + 2] = PreFac*II*(double)m*ROverR * Ylm[Alpha] / SinTheta; }; if (DivLL) diff --git a/libs/libSpherical/libSpherical.h b/libs/libSpherical/libSpherical.h index c9b8cd33..d79b41f6 100644 --- a/libs/libSpherical/libSpherical.h +++ b/libs/libSpherical/libSpherical.h @@ -67,19 +67,19 @@ /* conversion routines */ /***************************************************************/ void CoordinateC2S(double X, double Y, double Z, double *r, double *Theta, double *Phi); -void CoordinateC2S(double X[3], double *r, double *Theta, double *Phi); -void CoordinateC2S(double X[3], double R[3]); -void CoordinateC2S(double X[3]); +void CoordinateC2S(const double X[3], double *r, double *Theta, double *Phi); +void CoordinateC2S(const double X[3], double R[3]); +void CoordinateC2S(const double X[3]); void CoordinateS2C(double r, double Theta, double Phi, double X[3]); void CoordinateS2C(double r, double Theta, double Phi, double *X, double *Y, double *Z); -void CoordinateS2C(double R[3], double X[3]); +void CoordinateS2C(const double R[3], double X[3]); void CoordinateS2C(double R[3]); -void VectorC2S(double Theta, double Phi, cdouble VC[3], cdouble VS[3]); -void VectorC2S(double Theta, double Phi, double VC[3], double VS[3]); +void VectorC2S(double Theta, double Phi, const cdouble VC[3], cdouble VS[3]); +void VectorC2S(double Theta, double Phi, const double VC[3], double VS[3]); void VectorC2S(double Theta, double Phi, double V[3]); void VectorC2S(double Theta, double Phi, cdouble V[3]); -void VectorS2C(double Theta, double Phi, cdouble VS[3], cdouble VC[3]); -void VectorS2C(double Theta, double Phi, double VS[3], double VC[3]); +void VectorS2C(double Theta, double Phi, const cdouble VS[3], cdouble VC[3]); +void VectorS2C(double Theta, double Phi, const double VS[3], double VC[3]); void VectorS2C(double Theta, double Phi, double V[3]); void VectorS2C(double Theta, double Phi, cdouble V[3]); diff --git a/libs/libTriInt/libTriInt.cc b/libs/libTriInt/libTriInt.cc index 4731238f..69351b1b 100644 --- a/libs/libTriInt/libTriInt.cc +++ b/libs/libTriInt/libTriInt.cc @@ -215,8 +215,8 @@ static void DeleteFirstTriangle(TIWorkspace *TIW) /***************************************************************/ static int tcmp(const void *pT1, const void *pT2) { - Triangle *T1=(Triangle *)(*(Triangle **)pT1); - Triangle *T2=(Triangle *)(*(Triangle **)pT2); + const Triangle *T1=(*(const Triangle * const *)pT1); + const Triangle *T2=(*(const Triangle * const *)pT2); if (T1->MaxError > T2->MaxError) return -1; diff --git a/libs/libhmat/LBWrappers.cc b/libs/libhmat/LBWrappers.cc index 7ece699c..7887876d 100644 --- a/libs/libhmat/LBWrappers.cc +++ b/libs/libhmat/LBWrappers.cc @@ -69,8 +69,9 @@ void HMatrix::Multiply(HMatrix *B, HMatrix *C, const char *Options) if (Options) { int MaxTokens=4, NumTokens; char *Tokens[4]; - char Line[100]; + char Line[101]; strncpy(Line, Options, 100); + Line[100] = '\0'; NumTokens=Tokenize(Line, Tokens, MaxTokens); for (int nt=0; ntZV, &NR, &info); else if ( RealComplex==LHM_COMPLEX && StorageType==LHM_SYMMETRIC ) zsptrs_("U", &NR, &iOne, ZM, ipiv, X->ZV, &NR, &info); + else ErrExit("Invalid matrix properties"); return info; } @@ -229,6 +232,7 @@ if ( RealComplex==LHM_REAL && StorageType==LHM_NORMAL ) zhptrs_("U", &NR, &nrhs, ZM, ipiv, X->ZM, &NR, &info); else if ( RealComplex==LHM_COMPLEX && StorageType==LHM_SYMMETRIC ) zsptrs_("U", &NR, &nrhs, ZM, ipiv, X->ZM, &NR, &info); + else ErrExit("Invalid matrix properties"); return info; } @@ -352,7 +356,8 @@ int HMatrix::CholFactorize() else if ( RealComplex==LHM_COMPLEX && StorageType==LHM_SYMMETRIC ) { fprintf(stderr,"\n*\n* ERROR: cannot cholesky-factorize a complex symmetric matrix \n*\n"); return -1; - }; + } + else ErrExit("Invalid matrix properties"); return info; } @@ -379,7 +384,8 @@ int HMatrix::CholSolve(HVector *X) else if ( RealComplex==LHM_COMPLEX && StorageType==LHM_SYMMETRIC ) { fprintf(stderr,"\n*\n* ERROR: cannot cholesky-factorize a complex symmetric matrix \n*\n"); return -1; - }; + } + else ErrExit("Invalid matrix properties"); return info; } @@ -407,7 +413,8 @@ int HMatrix::CholSolve(HMatrix *X, int nrhs) else if ( RealComplex==LHM_COMPLEX && StorageType==LHM_SYMMETRIC ) { fprintf(stderr,"\n*\n* ERROR: cannot cholesky-factorize a complex symmetric matrix \n*\n"); return -1; - }; + } + else ErrExit("Invalid matrix properties"); return info; } @@ -958,7 +965,7 @@ double HMatrix::GetRCond(double ANorm, bool UseInfinityNorm) /***************************************************************/ cdouble DoDot(HVector *A, HVector *B, bool Hermitian=true) { - if ( (A->N != A->N) || (A->RealComplex != B->RealComplex) ) + if ( (A->N != B->N) || (A->RealComplex != B->RealComplex) ) { Warn("attempt to dot-product incompatible vectors (returning 0)"); return 0.0; }; diff --git a/libs/libhrutil/ProcessOptions.cc b/libs/libhrutil/ProcessOptions.cc index a52e48b1..970587d0 100644 --- a/libs/libhrutil/ProcessOptions.cc +++ b/libs/libhrutil/ProcessOptions.cc @@ -55,16 +55,18 @@ void AppendOSUsageMessage(const char *Message) /***************************************************************/ /***************************************************************/ /***************************************************************/ -void OSUsage(char *ProgName, OptStruct *OSArray, const char *format, ...) +void printOSUsage(const char *ProgName, const char *version, OptStruct *OSArray, const char *format, va_list ap) { - va_list ap; + //va_list ap; char buffer[MAXSTR]; + if (version) + fprintf(stderr, "%s %s\n", ProgName, version); + if (format) - { va_start(ap,format); + { vsnprintfEC(buffer,MAXSTR,format,ap); fprintf(stderr,"\nerror: %s (aborting)\n\n",buffer); - va_end(ap); }; fprintf(stderr,"usage: %s [options]\n\n",ProgName); @@ -110,8 +112,29 @@ void OSUsage(char *ProgName, OptStruct *OSArray, const char *format, ...) if (ExtraOSUsageMessage) fprintf(stderr,"%s\n",ExtraOSUsageMessage); + +} + +void OSUsage(const char *ProgName, const char *version, OptStruct *OSArray, const char *format, ...) +{ + va_list ap; + if(format) + va_start(ap, format); + printOSUsage(ProgName, version, OSArray, format, ap); + if(format) + va_end(ap); exit(1); +} +void OSUsage(const char *ProgName, OptStruct *OSArray, const char *format, ...) +{ + va_list ap; + if(format) + va_start(ap, format); + printOSUsage(ProgName, NULL, OSArray, format, ap); + if(format) + va_end(ap); + exit(1); } /***************************************************************/ diff --git a/libs/libhrutil/libhrutil.h b/libs/libhrutil/libhrutil.h index 5bba237e..e208df4e 100644 --- a/libs/libhrutil/libhrutil.h +++ b/libs/libhrutil/libhrutil.h @@ -337,7 +337,8 @@ typedef struct OptStruct } OptStruct; void AppendOSUsageMessage(const char *Message); -void OSUsage(char *ProgName, OptStruct *OSArray, const char *format, ...); +void OSUsage(const char *ProgName, OptStruct *OSArray, const char *format, ...); +void OSUsage(const char *ProgName, const char *version, OptStruct *OSArray, const char *format, ...); void ProcessOptions(int argc, char *argv[], OptStruct *OSArray, bool AbortOnUnknown=true, bool ZeroArgs=false); void ProcessOptions(const char *ArgString, OptStruct *OSArray); diff --git a/libs/libscuff/FIBBICache.cc b/libs/libscuff/FIBBICache.cc index 15a2f5e9..a78cc9ca 100644 --- a/libs/libscuff/FIBBICache.cc +++ b/libs/libscuff/FIBBICache.cc @@ -69,9 +69,8 @@ void ComputeFIBBIData(RWGSurface *Sa, int nea, /*--------------------------------------------------------------*/ long JenkinsHash(const char *key, size_t len) { - long hash; - unsigned int i; - for(hash = i = 0; i < len; ++i) + long hash = 0; + for(size_t i = 0; i < len; ++i) { hash += key[i]; hash += (hash << 10); @@ -95,7 +94,7 @@ typedef struct { double Data[DATALEN]; } DataStruct; typedef std::pair KDPair; -struct KeyHash +struct FIBBIKeyHash { long operator() (const KeyStruct &K) const { return HashFunction(K.Key); } @@ -111,18 +110,18 @@ typedef struct ); }; - } KeyCmp; + } FIBBIKeyCmp; #ifdef HAVE_CXX11 typedef std::unordered_map< KeyStruct, DataStruct, - KeyHash, - KeyCmp> KDMap; + FIBBIKeyHash, + FIBBIKeyCmp> KDMap; #elif defined(HAVE_TR1) typedef std::tr1::unordered_map< KeyStruct, DataStruct, - KeyHash, - KeyCmp> KDMap; + FIBBIKeyHash, + FIBBIKeyCmp> KDMap; #endif /*--------------------------------------------------------------*/ diff --git a/libs/libscuff/FIPPICache.cc b/libs/libscuff/FIPPICache.cc index 47eac1ad..4f754cab 100644 --- a/libs/libscuff/FIPPICache.cc +++ b/libs/libscuff/FIPPICache.cc @@ -66,7 +66,7 @@ typedef struct typedef std::pair KeyValuePair; -struct KeyHash +struct FIPPIKeyHash { long operator() (const KeyStruct &K) const { return HashFunction(K.Key); } }; @@ -80,18 +80,18 @@ typedef struct return true; }; - } KeyCmp; + } FIPPIKeyCmp; #ifdef HAVE_CXX11 typedef std::unordered_map< KeyStruct, QIFIPPIData *, - KeyHash, - KeyCmp> KeyValueMap; + FIPPIKeyHash, + FIPPIKeyCmp> KeyValueMap; #elif defined(HAVE_TR1) typedef std::tr1::unordered_map< KeyStruct, QIFIPPIData *, - KeyHash, - KeyCmp> KeyValueMap; + FIPPIKeyHash, + FIPPIKeyCmp> KeyValueMap; #endif /*--------------------------------------------------------------*/ diff --git a/libs/libscuff/GBarVDEwald.cc b/libs/libscuff/GBarVDEwald.cc index cca24d42..d861924a 100644 --- a/libs/libscuff/GBarVDEwald.cc +++ b/libs/libscuff/GBarVDEwald.cc @@ -338,7 +338,7 @@ cdouble GFullTwiddle1D(double kx, double Rho, cdouble k, { cdouble kt2 = kx*kx - k*k; cdouble kt = sqrt(kt2); - cdouble K[2]; + cdouble K[3]; AmosBessel('K',kt*Rho,0.0,3,false,K,0); double Denom = 4.0*M_PI*M_PI; diff --git a/libs/libscuff/ParseMeshFiles.cc b/libs/libscuff/ParseMeshFiles.cc index 09e44b08..c62d5ed7 100644 --- a/libs/libscuff/ParseMeshFiles.cc +++ b/libs/libscuff/ParseMeshFiles.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include "libscuff.h" @@ -38,20 +39,24 @@ namespace scuff { #define TYPE_TRIANGLE 2 #define TYPE_POINT 15 -#define NODE_START_KEYWORD1 "$NOD" -#define NODE_START_KEYWORD2 "$Nodes" +#define MESH_FORMAT_START_KEYWORD_GMSH24 "$MeshFormat" +#define MESH_FORMAT_END_KEYWORD_GMSH24 "$EndMeshFormat" -#define NODE_END_KEYWORD1 "$ENDNOD" -#define NODE_END_KEYWORD2 "$EndNodes" +#define NODE_START_KEYWORD_GMSH1 "$NOD" +#define NODE_START_KEYWORD_GMSH24 "$Nodes" -#define ELM_START_KEYWORD1 "$ELM" -#define ELM_START_KEYWORD2 "$Elements" +#define NODE_END_KEYWORD_GMSH1 "$ENDNOD" +#define NODE_END_KEYWORD_GMSH24 "$EndNodes" -#define ELM_END_KEYWORD1 "$ENDELM" -#define ELM_END_KEYWORD2 "$EndElements" +#define ELM_START_KEYWORD_GMSH1 "$ELM" +#define ELM_START_KEYWORD_GMSH24 "$Elements" -#define FORMAT_LEGACY 0 -#define FORMAT_NEW 1 +#define ELM_END_KEYWORD_GMSH1 "$ENDELM" +#define ELM_END_KEYWORD_GMSH24 "$EndElements" + +#define FORMAT_GMSH1 1 +#define FORMAT_GMSH2 2 +#define FORMAT_GMSH4 4 #define MAXREFPTS 100 @@ -75,16 +80,56 @@ char *ParseGMSHFile(FILE *MeshFile, char *FileName, int MeshTag, /*------------------------------------------------------------*/ int LineNum=0; char Line[100]; - bool KeywordFound=false; - int WhichMeshFormat; - while(!KeywordFound) + bool NodesKeywordFound=false; + int WhichMeshFormat = 0; + + { // Read MSH preambule and determine version. The format checking is not bullet-proof + // (some malformed files can pass through), but it should parse are correct files + // correctly. + double MeshFormatVersion = 0; int file_type, data_size;// for MSH version 2 and higher + int VersionInfoPhase = 0; + while(VersionInfoPhase < 5) { + if (!fgets(Line,100,MeshFile)) + return vstrdup("%s:%i: failed to find valid MSH file version specification", FileName, LineNum); + LineNum++; + if (VersionInfoPhase == 0) { + if( !strncmp(Line,NODE_START_KEYWORD_GMSH1,strlen(NODE_START_KEYWORD_GMSH1))) { + WhichMeshFormat=FORMAT_GMSH1; + NodesKeywordFound=true; + VersionInfoPhase = 5; + break; + } else if (!strncmp(Line,MESH_FORMAT_START_KEYWORD_GMSH24,strlen(MESH_FORMAT_START_KEYWORD_GMSH24))) + ++VersionInfoPhase; + else return vstrdup("%s:%i: expected $MeshFormat or $NOD keyword", FileName, LineNum); + } + if (VersionInfoPhase == 1) { + if (1 == fscanf(MeshFile, "%lf", &MeshFormatVersion)) { + WhichMeshFormat = (int) MeshFormatVersion; + if (WhichMeshFormat != FORMAT_GMSH2) + return vstrdup("%s:%i: only MSH v1 and v2 formats currently supported (input file claims to be v%g)", FileName, LineNum, MeshFormatVersion); + ++VersionInfoPhase; + } + } + if (VersionInfoPhase == 2) { + if (1 == fscanf(MeshFile, "%d", &file_type)) ++VersionInfoPhase; + } + if (VersionInfoPhase == 3) { + if (1 == fscanf(MeshFile, "%d", &data_size)) ++VersionInfoPhase; + } + if (VersionInfoPhase == 4) { + if (!strncmp(Line,MESH_FORMAT_END_KEYWORD_GMSH24,strlen(MESH_FORMAT_END_KEYWORD_GMSH24))) + ++VersionInfoPhase; + } + } + } + assert(WhichMeshFormat != 0); + + while(!NodesKeywordFound) { if (!fgets(Line,100,MeshFile)) - return vstrdup("%s: failed to find node start keyword"); + return vstrdup("%s:%i: failed to find node start keyword", FileName, LineNum); LineNum++; - if( !strncmp(Line,NODE_START_KEYWORD1,strlen(NODE_START_KEYWORD1))) - { WhichMeshFormat=FORMAT_LEGACY; KeywordFound=true; } - else if( !strncmp(Line,NODE_START_KEYWORD2,strlen(NODE_START_KEYWORD2))) - { WhichMeshFormat=FORMAT_NEW; KeywordFound=true; } + if( !strncmp(Line,NODE_START_KEYWORD_GMSH24,strlen(NODE_START_KEYWORD_GMSH24))) + NodesKeywordFound=true; } int NumNodes; if ( !fgets(Line,100,MeshFile) || !(NumNodes=atoi(Line)) ) @@ -106,7 +151,7 @@ char *ParseGMSHFile(FILE *MeshFile, char *FileName, int MeshTag, GMSH2HR[i]=-1; for (int nn=0; nnMeshFileName); + fclose(f); } /***************************************************************/