Commit 23fba7a91cfb588dd54a337a86d5c55b16de911f
1 parent
0cb6a7aa
Exists in
master
and in
109 other branches
no temp file for CdfSampling
Showing
3 changed files
with
18 additions
and
12 deletions
Show diff stats
php/classes/FilesMgr.php
... | ... | @@ -120,19 +120,13 @@ class FilesMgr extends AmdaObjectMgr |
120 | 120 | return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs, 'units' => $units, 'fillvalue' => $fillval); |
121 | 121 | } |
122 | 122 | |
123 | - public function getCdfSampling() { | |
124 | - copy($this->fileName, "temp.cdf"); | |
125 | - exec('cdfsamplingfromdata ', $results); | |
126 | - unlink("temp.cdf"); | |
127 | - | |
123 | + public function getCdfSampling() { | |
124 | + exec('cdfsamplingfromdata '.$this->fileName, $results); | |
128 | 125 | return $results; |
129 | 126 | } |
130 | 127 | |
131 | - public function getCdfSamplings() { | |
132 | - copy($this->fileName, "temp.cdf"); | |
133 | - exec('cdfsamplingsfromdata ', $results); | |
134 | - unlink("temp.cdf"); | |
135 | - | |
128 | + public function getCdfSamplings() { | |
129 | + exec('cdfsamplingsfromdata '.$this->fileName, $results); | |
136 | 130 | return $results; |
137 | 131 | } |
138 | 132 | /* |
... | ... |
php/src/cdfsamplingfromdata.c
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | #include <time.h> |
8 | 8 | #include <math.h> |
9 | 9 | |
10 | -#define fileName "temp.cdf" | |
10 | +#define MAX_FILE_NAME_LEN 120 | |
11 | 11 | #define badFile -100 |
12 | 12 | |
13 | 13 | /************************************* |
... | ... | @@ -45,6 +45,7 @@ void cdf_handle_error(CDFstatus status) |
45 | 45 | |
46 | 46 | int main(int argc, char *argv[]) |
47 | 47 | { |
48 | + char fileName[MAX_FILE_NAME_LEN]; | |
48 | 49 | long RecStart = 0, RecCount = 2, RecInt = 1; |
49 | 50 | long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1}; |
50 | 51 | long varN = -1; |
... | ... | @@ -58,6 +59,11 @@ int main(int argc, char *argv[]) |
58 | 59 | double epoch16[2], dbl_value, dbl_value_; |
59 | 60 | long year, month, day, hour, minute, sec, msec, mksec, nsec, psec; |
60 | 61 | long long *int_value; |
62 | + | |
63 | + if (argc <= 1) | |
64 | + exit(0); /* CDF input file name not specified */ | |
65 | + else | |
66 | + strcpy(fileName, argv[argc-1]); /* Get the input file name */ | |
61 | 67 | |
62 | 68 | /*********************** Open CDF file *****************************/ |
63 | 69 | if ((cstatus = CDFopen(fileName, &id)) != CDF_OK) |
... | ... |
php/src/cdfsamplingsfromdata.c
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | #include <time.h> |
11 | 11 | #include <math.h> |
12 | 12 | |
13 | -#define fileName "temp.cdf" | |
13 | +#define MAX_FILE_NAME_LEN 120 | |
14 | 14 | #define badFile -100 |
15 | 15 | |
16 | 16 | /************************************* |
... | ... | @@ -76,6 +76,7 @@ void find_min(int* delta, int nRecs, int minFalse, int* minVal) |
76 | 76 | |
77 | 77 | int main(int argc, char *argv[]) |
78 | 78 | { |
79 | + char fileName[MAX_FILE_NAME_LEN]; | |
79 | 80 | long RecStart = 0, RecCount, RecInt = 1; |
80 | 81 | long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1}; |
81 | 82 | long varN = -1; |
... | ... | @@ -91,6 +92,11 @@ int main(int argc, char *argv[]) |
91 | 92 | double epoch16[2], dbl_value, dbl_value_; |
92 | 93 | long year, month, day, hour, minute, sec, msec, mksec, nsec, psec; |
93 | 94 | long long *int_value; |
95 | + | |
96 | + if (argc <= 1) | |
97 | + exit(0); /* CDF input file name not specified */ | |
98 | + else | |
99 | + strcpy(fileName, argv[argc-1]); /* Get the input file name */ | |
94 | 100 | |
95 | 101 | /*********************** Open CDF file *****************************/ |
96 | 102 | if ((cstatus = CDFopen(fileName, &id)) != CDF_OK) |
... | ... |