14 | | MUSCLE_Receive(character*(*) exit_name, [your_datatype]*65536 result, integer size, muscle_datatype_t type) |
15 | | MUSCLE_Send(character*(*) entrance_name, [your_datatype]*(*) data, integer size, muscle_datatype_t type) |
| 14 | MUSCLE_Receive(character*255 exit_name, [your_datatype]*65536 result, integer size, muscle_datatype_t type) |
| 15 | MUSCLE_Send(character*255 entrance_name, [your_datatype]*(*) data, integer size, muscle_datatype_t type) |
20 | | For compatibility with Fortran |
| 23 | To use the enumeration containing the MUSCLE types, include the following statement in blocks where it is used: |
| 24 | {{{ |
| 25 | enum, bind(c) |
| 26 | enumerator :: MUSCLE_DOUBLE, MUSCLE_FLOAT, MUSCLE_RAW, MUSCLE_INT32, MUSCLE_INT64, MUSCLE_BOOLEAN, MUSCLE_STRING |
| 27 | endenum |
| 28 | }}} |
| 29 | This ensures that the datatypes are the same as used in the C/C++ code. Due to the difficulty of converting arrays of character arrays to C, instead of the standard MUSCLE_Init, add the following subroutine to your code, that will convert the string to C-compatible strings. |
| 30 | |
| 31 | {{{ |
| 32 | subroutine muscle_fortran_init() |
| 33 | implicit none |
| 34 | integer :: argc, i, prevlen, newlen |
| 35 | character(len=25600) :: argv |
| 36 | character(len=255) :: arg |
| 37 | |
| 38 | prevlen = 0 |
| 39 | argc = command_argument_count() |
| 40 | |
| 41 | do i = 0, argc |
| 42 | call get_command_argument(i, arg) |
| 43 | newlen = len_trim(arg) |
| 44 | argv = argv(1:prevlen) // arg(1:newlen) // char(0) |
| 45 | prevlen = prevlen + newlen + 1 |
| 46 | end do |
| 47 | |
| 48 | call MUSCLE_Init(argc, argv(1:prevlen)) |
| 49 | end subroutine muscle_fortran_init |
| 50 | }}} |