Changeset 38506
- Timestamp:
- Jun 20, 2015, 1:30:59 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src
- Files:
-
- 2 edited
-
dvo_catalog.c (modified) (3 diffs)
-
dvo_catalog_split.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog.c
r38484 r38506 85 85 86 86 // we can return a static string here unless we run multiple outputs threads at once 87 static char compress_string[16];88 87 char *dvo_catalog_compress_string (DVOCatCompress catcompress) { 89 88 char *compress_string = NULL; 90 89 switch (catcompress) { 91 90 case DVO_COMPRESS_NONE: 92 strcpy (compress_string,"NONE");91 compress_string = strcreate("NONE"); 93 92 break; 94 93 case DVO_COMPRESS_AUTO: 95 strcpy (compress_string,"AUTO");94 compress_string = strcreate("AUTO"); 96 95 break; 97 96 case DVO_COMPRESS_GZIP_1: 98 strcpy (compress_string,"GZIP_1");97 compress_string = strcreate("GZIP_1"); 99 98 break; 100 99 case DVO_COMPRESS_GZIP_2: 101 strcpy (compress_string,"GZIP_2");100 compress_string = strcreate("GZIP_2"); 102 101 break; 103 102 case DVO_COMPRESS_NONE_1: 104 strcpy (compress_string,"NONE_1");103 compress_string = strcreate("NONE_1"); 105 104 break; 106 105 case DVO_COMPRESS_NONE_2: 107 strcpy (compress_string,"NONE_2");106 compress_string = strcreate("NONE_2"); 108 107 break; 109 108 case DVO_COMPRESS_RICE_1: 110 strcpy (compress_string,"RICE_1");109 compress_string = strcreate("RICE_1"); 111 110 break; 112 111 default: … … 1158 1157 return FALSE; 1159 1158 } 1160 1159 1160 int outStatus = TRUE; 1161 1161 status = unlink (tmpfilename); 1162 1162 if (status) { 1163 perror ("unlink: "); 1163 1164 fprintf (stderr, "failed to unlink catalog %s~\n", catalog->filename); 1164 returnFALSE;1165 outStatus = FALSE; 1165 1166 } 1166 1167 … … 1168 1169 if (catalog[0].measure_catalog != NULL) { 1169 1170 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) { 1170 returnFALSE;1171 outStatus = FALSE; 1171 1172 } 1172 1173 } 1173 1174 if (catalog[0].missing_catalog != NULL) { 1174 1175 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) { 1175 returnFALSE;1176 outStatus = FALSE; 1176 1177 } 1177 1178 } 1178 1179 if (catalog[0].secfilt_catalog != NULL) { 1179 1180 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) { 1180 returnFALSE;1181 outStatus = FALSE; 1181 1182 } 1182 1183 } 1183 1184 if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) { 1184 1185 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) { 1185 returnFALSE;1186 outStatus = FALSE; 1186 1187 } 1187 1188 } 1188 1189 if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) { 1189 1190 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) { 1190 returnFALSE;1191 outStatus = FALSE; 1191 1192 } 1192 1193 } 1193 1194 if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) { 1194 1195 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) { 1195 returnFALSE;1196 outStatus = FALSE; 1196 1197 } 1197 1198 } 1198 1199 if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) { 1199 1200 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) { 1200 returnFALSE;1201 } 1202 } 1203 } 1204 return TRUE;1205 } 1206 1207 1201 outStatus = FALSE; 1202 } 1203 } 1204 } 1205 return outStatus; 1206 } 1207 1208 -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog_split.c
r38494 r38506 1 1 # include <dvo.h> 2 # define OHANA_MEMCHECK 12 # define OHANA_MEMCHECK 0 3 3 4 4 // return options: … … 90 90 int dvo_catalog_save_subcat (Catalog *catalog, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) { 91 91 92 Matrix matrix; 93 94 // if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 92 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 95 93 96 94 /* rewind file pointers and truncate (file is still open) */ … … 108 106 off_t fullsize = catalog->header.datasize; 109 107 108 # if (1) 110 109 // write the PHU matrix; this is probably a NOP, do I have to keep it in? 110 Matrix matrix; 111 111 gfits_create_matrix (&catalog->header, &matrix); 112 112 if (!gfits_fwrite_matrix (catalog->f, &matrix)) { … … 117 117 fullsize += matrix.datasize; 118 118 gfits_free_matrix (&matrix); 119 # endif 119 120 120 121 FTable *outtable = ftable; … … 128 129 int isCompressed = output_is_compressed (start, Nrows, Ntotal, catalog->catcompress); 129 130 130 //if (OHANA_MEMCHECK) ohana_memcheck (TRUE);131 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 131 132 132 133 if (isCompressed) { … … 136 137 if (!gfits_compress_table (ftable, &cmptable, 1000, compressMode)) { 137 138 fprintf (stderr, "compression failure\n"); 139 free (compressMode); 138 140 return (FALSE); 139 141 } 140 142 if (!byteswap_varlength_ftable (&cmpheader, &cmptable)) { 141 143 fprintf (stderr, "failed to swap varlength column\n"); 144 free (compressMode); 142 145 return FALSE; 143 146 } 144 147 if (!gfits_modify (cmptable.header, "DVO_CMP", "%s", 1, compressMode)) { 145 148 fprintf (stderr, "can't save compression mode\n"); 146 return (FALSE); 147 } 149 free (compressMode); 150 return (FALSE); 151 } 152 free (compressMode); 148 153 outtable = &cmptable; 149 154 } 150 155 151 //if (OHANA_MEMCHECK) ohana_memcheck (TRUE);156 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 152 157 153 158 // write the table data … … 170 175 171 176 // XXX test of repeated failure 172 {177 if (0) { 173 178 Matrix myMatrix; 174 179 … … 195 200 } 196 201 197 //if (OHANA_MEMCHECK) ohana_memcheck (TRUE);202 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 198 203 199 204 // since we init'ed the structures above, these operations are safe whether or not we compressed the table … … 217 222 off_t Nskip; 218 223 int status; 219 char *path, string[ 80];224 char *path, string[256]; 220 225 Catalog *subcat; 221 226 … … 241 246 return (DVO_CAT_OPEN_FAIL); 242 247 } 243 ALLOCATE (subcat[0].filename, char, strlen(path) + strlen(string) + 2); 244 sprintf (subcat[0].filename, "%s/%s", path, string); 248 int Nchar = strlen(path) + strlen(string) + 10; 249 ALLOCATE (subcat[0].filename, char, Nchar); 250 snprintf (subcat[0].filename, Nchar, "%s/%s", path, string); 245 251 free (path); 246 252 … … 308 314 } 309 315 310 char compressMode[ 80];316 char compressMode[256]; 311 317 if (!gfits_scan (ftable->header, "DVO_CMP", "%s", 1, compressMode)) { 312 318 strcpy (compressMode, "AUTO"); … … 785 791 } 786 792 793 # if (0) 794 void compare_file_ptr (FILE *copy_ptr, FILE *real_ptr, char *name) { 795 return; 796 797 int i; 798 799 char *real = (char *) real_ptr; 800 char *copy = (char *) copy_ptr; 801 802 for (i = 0; i < sizeof(FILE); i++, real++, copy++) { 803 if (*real != *copy) { 804 fprintf (stderr, "file pointers %s differ @ %d\n", name, (int) ((char *) real - (char *) real_ptr)); 805 } 806 } 807 } 808 # endif 809 787 810 /* save_catalog_split writes all data currently in memory to disk */ 788 811 int dvo_catalog_save_split (Catalog *catalog, char VERBOSE) { … … 871 894 goto failure; 872 895 } 896 873 897 gfits_free_header (&header); 874 898 gfits_free_table (&ftable); … … 913 937 goto failure; 914 938 } 939 915 940 gfits_free_header (&header); 916 941 gfits_free_table (&ftable);
Note:
See TracChangeset
for help on using the changeset viewer.
