linux - Csh script call C program,arguments issue -
this line csh script
./model2grd $model -d$nx/$ny/$nz -o$x0/$y0 -i$dx/$dy -l$layer -c$coverage -avel.dat -gvel.grd
this part of model2grd.c
for (i = 2; < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'g': grdfile = &argv[i][2]; lgrd = true; break; case 'c': cov = &argv[i][2]; lcov = true; break; case 'a': xyzfile = &argv[i][2]; lxyz = true; break; case 'd': sscanf(&argv[i][2],"%d/%d/%d",&nx,&ny,&nz); break; case 'i': sscanf(&argv[i][2], "%lf/%lf", &dx, &dy); break; case 'o': sscanf(&argv[i][2], "%lf/%lf", &xmin, &ymin); break; case 'l': layer = atoi(&argv[i][2]); break; case 'n': nan = (float)atof(&argv[i][2]); break; case 'z': cvalue = (float)atof(&argv[i][2]); break; case 'v': verbose = true; break; default: break; } } }
does mean takes d(nx,ny,nz),with o(xmin , ymin),with l layer , c coverage?are avel.dat , gvel.grd input files or not?
avel.dat
, gvel.grd
not input files. @ argument parsing again.
switch (argv[i][1]) { case 'g': grdfile = &argv[i][2]; lgrd = true; break;
consider argument:
-gvel.grd
in plain english, switch
examines second character of each argument. in case -gvel.grd
argument, looks @ g
. passing test, case statement derives address of character comes immediately after g
within character string. in other words, v
.
therefore, file name vel.grd
. should able apply same logic rest of arguments follow same pattern.
Comments
Post a Comment