dtep2txt.c 805 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #define NLEV 5
  4. int DimX;
  5. int DimY;
  6. int DimT;
  7. int head[10];
  8. float *F;
  9. int main(int argc, char *argv[])
  10. {
  11. int i,j,jlev;
  12. FILE *ifp;
  13. FILE *ofp;
  14. ifp = fopen(argv[1],"r");
  15. ofp = fopen(argv[2],"w");
  16. for (jlev = 0 ; jlev < NLEV ; ++jlev)
  17. {
  18. fread(head,sizeof(int),10,ifp);
  19. DimX = head[4];
  20. DimY = head[5];
  21. DimT = DimX * DimY;
  22. F = (float *)malloc((DimT+2) * sizeof(float));
  23. fread(F,sizeof(float),DimT+2,ifp);
  24. for (i = 1 ; i < 9 ; ++i)
  25. fprintf(ofp,"%9d",head[i]);
  26. fprintf(ofp,"\n");
  27. for (j = 1 ; j <= DimT ; j += 8)
  28. {
  29. for (i = j ; i < j + 8 && i <= DimT ; ++i)
  30. fprintf(ofp,"%9.2f",F[i]);
  31. fprintf(ofp,"\n");
  32. }
  33. }
  34. return 0;
  35. }