Skip to content

Commit 393c42c

Browse files
committed
makefile cleanup
1 parent 785515f commit 393c42c

6 files changed

+31
-14
lines changed

c/makefile

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ perc: percolation_driver.o $(objects)
1515
$(CC) -o perc percolation_driver.o $(objects) $(CFLAGS)
1616

1717
vc: verg_and_count.o nodal_domain_driver_no_main.o ../vergini/verg_no_main.o $(objects) $(dependencies)
18+
./update_no_main.sh
19+
cd ../vergini; ./update_no_main.sh; cd ../c
1820
$(CC) $(CFLAGS) -o vc verg_and_count.o nodal_domain_driver_no_main.o ../vergini/verg_no_main.o $(objects) $(VERG) $(MATHLIBS)
1921

2022
nodal_domain_driver.o: nodal_domain_driver.c

c/nodal_domain_driver_no_main.c

+23-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Kyle Konrad
1919

2020
// vergini code dependencies
2121
#include "../vergini/billiard.h"
22-
;
22+
extern int verb;
2323

2424
// options specified by command line arguments
2525
int showTime = 0; // flag: print time it takes for countNodalDomains to run
@@ -29,6 +29,7 @@ int mode = -1; // 0 - generate random_percolation grid; 1 - read grid from sta_b
2929
int maskFlag = 0; // flag: use a mask file
3030
char *maskFile; // use mask from this file
3131
int oneFlag = 0; // flag: only count one eigenfunction
32+
int sizeFlag = 0; // flag: write domain sizes to file
3233

3334
Billiard bil; // Billiard shape we are using - defined in vergini code
3435
double dx = -1; // grid spacing
@@ -42,11 +43,13 @@ int interp = 1; // boolean whether or not to interpolate
4243
print a usage statement
4344
*/
4445
void usage() {
45-
fprintf(stderr, "USAGE: count -f file [-m maskFile | {-l billiardType -d dx [-k k_0] -M besselOrder -u upsample}] [-t] [-o] [-1] [-n]\n");
46+
fprintf(stderr, "USAGE: count -f file [-m maskFile | {-l billiardType -d dx [-k k_0] -M besselOrder -u upsample}] [-t] [-o] [-1] [-n] [-q] [-s]\n");
4647
fprintf(stderr, "-t: show timing info\n");
4748
fprintf(stderr, "-o: output grid to file\n");
4849
fprintf(stderr, "-1: only count first eigenfunction\n");
4950
fprintf(stderr, "-n: do not use interpolation\n");
51+
fprintf(stderr, "-q: quiet\n");
52+
fprintf(stderr, "-s: output nodal domain sizes to file\n");
5053
}
5154

5255
/*
@@ -63,16 +66,14 @@ void count_processArgs(int argc, char **argv) {
6366
exit(CMD_LINE_ARG_ERR);
6467
}
6568

66-
while ((c = getopt(argc, argv, "f:m:l:d:k:M:u:to1n")) != -1) {
69+
while ((c = getopt(argc, argv, "f:m:l:d:k:M:u:to1nqs")) != -1) {
6770
switch (c) {
6871
case 'f':
69-
file = (char *)malloc(strlen(optarg)*sizeof(char));
70-
strcpy(file, optarg);
72+
SET(file, optarg);
7173
mode = 1;
7274
break;
7375
case 'm':
74-
maskFile = (char *)malloc(strlen(optarg)*sizeof(char));
75-
strcpy(maskFile, optarg);
76+
SET(maskFile, optarg);
7677
maskFlag = 1;
7778
break;
7879
case 'l':
@@ -107,6 +108,12 @@ void count_processArgs(int argc, char **argv) {
107108
case 'n':
108109
interp = 0;
109110
break;
111+
case 'q':
112+
verb = 0;
113+
break;
114+
case 's':
115+
sizeFlag = 1;
116+
break;
110117
case '?':
111118
switch (optopt) {
112119
case 'f':
@@ -162,16 +169,21 @@ void count_processArgs(int argc, char **argv) {
162169
*/
163170
int runTest(double **grid, char **mask, int ny, int nx, double k, double dx, int besselOrder, int upsample, interp_stats *stats) {
164171
char sizefilename[50];
165-
sprintf(sizefilename, "sizes_%f_%f.dat", k, dx);
166-
FILE *sizefile = fopen(sizefilename, "w");
172+
FILE *sizefile = NULL;
173+
if (sizeFlag) {
174+
sprintf(sizefilename, "sizes_%f_%f.dat", k, dx);
175+
sizefile = fopen(sizefilename, "w");
176+
}
167177
int nd;
168178
if (interp) {
169179
nd = countNodalDomainsInterp(grid, mask, ny, nx, k, dx, besselOrder, upsample, stats, sizefile);
170180
}
171181
else {
172182
nd = countNodalDomainsNoInterp(grid, mask, ny, nx, sizefile);
173183
}
174-
fclose(sizefile);
184+
if (sizeFlag) {
185+
fclose(sizefile);
186+
}
175187
return nd;
176188
}
177189

@@ -215,8 +227,7 @@ int count_main(int argc, char **argv) {
215227
free(maskFile);
216228
}
217229

218-
printf("%s\t%s\t%s\t%s\t%s\n", "k", "count", "small domains", "interp count", "boundary trouble count", "edge trouble count");
219-
printf("%f\t%d\t%d\t%d\t%d\n", k_0, count, stats.small_domain_count, stats.interp_count, stats.boundary_trouble_count, stats.edge_trouble_count);
230+
printf("%f,%f,%d,%d,%d,%d\n", k_0, dx, count, stats.small_domain_count, stats.interp_count, stats.boundary_trouble_count, stats.edge_trouble_count);
220231

221232
}
222233

c/percolation_driver.c

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Kyle Konrad
1616
#include <string.h>
1717
#include <unistd.h> // for command line parsing with getopt
1818

19+
// global verbosity variable
20+
int verb = 1;
21+
1922
// options specified by command line arguments
2023
int showTime = 0; // flag: print time it takes for countNodalDomains to run
2124
int gridSize = -1; // size of grid in x and y dimensions

c/update_no_main.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ sed -i -e 's/int main(/int count_main(/' nodal_domain_driver_no_main.c
66
sed -i -e 's/processArgs/count_processArgs/' nodal_domain_driver_no_main.c
77
sed -i -e '/void count_processArgs(/ a\
88
optind = 0;' nodal_domain_driver_no_main.c
9-
sed -i -e 's/int verb//' nodal_domain_driver_no_main.c
9+
sed -i -e 's/int verb.*/extern int verb;/' nodal_domain_driver_no_main.c

vergini/update_no_main.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ cp verg.cc verg_no_main.cc
55
sed -i -e 's/int main(/int verg_main(/' verg_no_main.cc
66
sed -i -e '/bas.set_type = NBASES;/ a\
77
optind = 0;' verg_no_main.cc
8+
sed -i -e 's/int verb.*/extern int verb;/' verg_no_main.cc

vergini/verg_no_main.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
flags: 0x02 - generally more
3131
0x80 - cmd line parsing
3232
*/
33-
int verb = 1;
33+
extern int verb;
3434

3535
// tasks...
3636
#define NO_TASK -1

0 commit comments

Comments
 (0)