cc_check.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. int fcw = 4;
  4. int isz = 4;
  5. int rsz = 4;
  6. int ben = 0;
  7. FILE *wp;
  8. void check_fortran_integer(void)
  9. {
  10. int b;
  11. int l;
  12. FILE *fp;
  13. fp = fopen("F90_INTEGER","r");
  14. fseek(fp,0,SEEK_END);
  15. l = ftell(fp);
  16. if (l == 16) isz = 8;
  17. else if (l == 20) fcw = 8;
  18. else if (l == 24)
  19. {
  20. isz = 8;
  21. fcw = 8;
  22. }
  23. rewind(fp);
  24. b = fgetc(fp);
  25. if (b == 0) ben = 1;
  26. fclose(fp);
  27. }
  28. void check_fortran_real(void)
  29. {
  30. int b;
  31. int l;
  32. FILE *fp;
  33. fp = fopen("F90_REAL","r");
  34. fseek(fp,0,SEEK_END);
  35. l = ftell(fp);
  36. rsz = l - 2 * fcw;
  37. fclose(fp);
  38. }
  39. void print_info(void)
  40. {
  41. wp = fopen("most_info.txt","w");
  42. fprintf(wp,"\nSystem info for <%s>\n",getenv("HOSTNAME"));
  43. fprintf(wp,"Architecture: %s\n",getenv("MOSTARCH"));
  44. if (ben) fprintf(wp,"Endian format : big endian\n");
  45. else fprintf(wp,"Endian format : little endian\n");
  46. fprintf(wp,"FORTRAN control word size : %d bytes\n",fcw);
  47. fprintf(wp,"FORTRAN integer size : %d bytes\n",isz);
  48. fprintf(wp,"FORTRAN real size : %d bytes\n",rsz);
  49. fprintf(wp,"C int size : %ld bytes\n",sizeof(int));
  50. fprintf(wp,"C float size : %ld bytes\n",sizeof(float));
  51. fprintf(wp,"C long size : %ld bytes\n",sizeof(long));
  52. fprintf(wp,"C long long size : %ld bytes\n",sizeof(long long));
  53. fclose(wp);
  54. }
  55. int main(int argc, char *argv[])
  56. {
  57. check_fortran_integer();
  58. check_fortran_real();
  59. print_info();
  60. return 0;
  61. }