oasis-cpp-interface.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #include "oasis-cpp-interface.h"
  2. #include "config.h"
  3. #include "shell.h"
  4. #ifdef WIN32
  5. // For windows testing
  6. int OASISMCT::init_comp(int * compid, std::string model_name)
  7. {
  8. return 0;
  9. };
  10. int OASISMCT::create_couplcomm(int myrank, int lcomm, int * ccomm)
  11. {
  12. return 0;
  13. };
  14. int OASISMCT::get_localcomm(int &localcompid)
  15. {
  16. return 0;
  17. };
  18. int OASISMCT::terminate(void)
  19. {
  20. return 0;
  21. };
  22. int OASISMCT::abort(int compid, std::string routine_name, std::string abort_message, int return_code)
  23. {
  24. return 0;
  25. };
  26. int OASISMCT::def_partition(int * il_part_id, int * ig_paral, int ig_paral_len)
  27. {
  28. return 0;
  29. };
  30. int OASISMCT::def_var(int * var_id,std::string name, int il_part_id, int * var_nodims, int kinout, int * var_actual_shape, int var_type)
  31. {
  32. return 0;
  33. };
  34. int OASISMCT::enddef(void)
  35. {
  36. return 0;
  37. };
  38. int OASISMCT::put_1d(int var_id, int date, double * field_array, int field_array_len)
  39. {
  40. return 0;
  41. };
  42. int OASISMCT::put_2d(int var_id, int date, double * field_array, int field_array_len_x, int field_array_len_y)
  43. {
  44. return 0; // I.e. OK
  45. };
  46. int OASISMCT::get_1d(int var_id, int date, double * field_array, int field_array_len)
  47. {
  48. return 0;
  49. };
  50. int OASISMCT::get_2d(int var_id, int date, double * field_array, int field_array_len_x, int field_array_len_y)
  51. {
  52. // For testing:
  53. // printf(" OASISMCT::get_2d -- for date %i\n",date);
  54. return 0;
  55. };
  56. #else
  57. // Non-Windows platforms
  58. extern "C"
  59. {
  60. int fortfunc_(void);
  61. int oasismct_init_comp_(int *, const char *);
  62. int oasismct_terminate_(void);
  63. int oasismct_abort_(int , std::string, std::string ,int );
  64. // ecev3
  65. int oasismct_create_couplcomm_(int *, int *, int *);
  66. int oasismct_get_localcomm_(int *);
  67. int oasismct_def_partition_(int *, int *, int *);
  68. int oasismct_def_var_(int *, const char *, int *, int *, int *, int *, int *);
  69. int oasismct_enddef_(void);
  70. int oasismct_put_1d_(int *, int *, double *, int *);
  71. int oasismct_put_2d_(int *, int *, double *, int *, int *);
  72. int oasismct_get_1d_(int *, int *, double *, int *);
  73. int oasismct_get_2d_(int *, int *, double *, int *, int *);
  74. };
  75. int OASISMCT::init_comp(int * compid, std::string model_name)
  76. {
  77. return oasismct_init_comp_(compid, model_name.c_str());
  78. };
  79. int OASISMCT::create_couplcomm(int myrank, int lcomm, int * ccomm)
  80. {
  81. return oasismct_create_couplcomm_(&myrank, &lcomm, ccomm);
  82. };
  83. int OASISMCT::get_localcomm(int &localcompid)
  84. {
  85. int lcid = 0;
  86. int isok = oasismct_get_localcomm_(&lcid);
  87. dprintf("oasismct_get_localcomm returned isok %i, and lcid %ii \n",isok,lcid);
  88. localcompid = lcid;
  89. return isok;
  90. };
  91. int OASISMCT::terminate(void)
  92. {
  93. return oasismct_terminate_();
  94. };
  95. int OASISMCT::abort(int compid,std::string routine_name,std::string abort_message,int return_code)
  96. {
  97. return oasismct_abort_(compid, routine_name, abort_message, return_code);
  98. };
  99. int OASISMCT::def_partition(int * il_part_id, int * ig_paral, int ig_paral_len)
  100. {
  101. return oasismct_def_partition_(il_part_id,ig_paral,&ig_paral_len);
  102. };
  103. int OASISMCT::def_var(int * var_id,std::string name, int il_part_id, int * var_nodims, int kinout, int * var_actual_shape, int var_type)
  104. {
  105. return oasismct_def_var_(var_id,name.c_str(),&il_part_id,var_nodims,&kinout,var_actual_shape,&var_type);
  106. };
  107. int OASISMCT::enddef(void)
  108. {
  109. dprintf("calling oasismct_enddef \n");
  110. int isok = oasismct_enddef_();
  111. dprintf("oasismct_enddef_ returned isok %i \n",isok);
  112. return isok;
  113. };
  114. int OASISMCT::put_1d(int var_id, int date, double * field_array, int field_array_len)
  115. {
  116. return oasismct_put_1d_(&var_id,&date,field_array,&field_array_len);
  117. };
  118. int OASISMCT::put_2d(int var_id, int date, double * field_array, int field_array_len_x, int field_array_len_y)
  119. {
  120. return oasismct_put_2d_(&var_id,&date,field_array,&field_array_len_x,&field_array_len_y);
  121. };
  122. int OASISMCT::get_1d(int var_id, int date, double * field_array, int field_array_len)
  123. {
  124. return oasismct_get_1d_(&var_id,&date,field_array,&field_array_len);
  125. };
  126. int OASISMCT::get_2d(int var_id, int date, double * field_array, int field_array_len_x, int field_array_len_y)
  127. {
  128. // For testing:
  129. // printf(" OASISMCT::get_2d -- for date %i\n",date);
  130. return oasismct_get_2d_(&var_id,&date,field_array,&field_array_len_x,&field_array_len_y);
  131. };
  132. #endif