Changes between Version 1 and Version 2 of Fortran API

Show
Ignore:
Timestamp:
10/08/12 17:04:23 (12 years ago)
Author:
jorisborgdorff
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Fortran API

    v1 v2  
    1212MUSCLE_Will_Stop(logical result) 
    1313 
    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) 
     14MUSCLE_Receive(character*255 exit_name, [your_datatype]*65536 result, integer size, muscle_datatype_t type) 
     15MUSCLE_Send(character*255 entrance_name, [your_datatype]*(*) data, integer size, muscle_datatype_t type) 
    1616}}} 
    1717 
    18 The length of the result from {{{MUSCLE_Kernel_Name}}} and {{{MUSCLE_Get_Property}}} can be found by calling {{{LenCstr}}} 
     18The length of the result from {{{MUSCLE_Kernel_Name}}} and {{{MUSCLE_Get_Property}}} can be found by calling {{{len_trim}}}. In each case, if a character array is expected, it should be NUL-terminated, achieved by concatenating with a char(0): 
     19{{{ 
     20call MUSCLE_Receive("portIn"//char(0), data, len, MUSCLE_DOUBLE) 
     21}}} 
    1922 
    20 For compatibility with Fortran 
     23To use the enumeration containing the MUSCLE types, include the following statement in blocks where it is used: 
     24{{{ 
     25enum, bind(c) 
     26        enumerator :: MUSCLE_DOUBLE, MUSCLE_FLOAT, MUSCLE_RAW, MUSCLE_INT32, MUSCLE_INT64, MUSCLE_BOOLEAN, MUSCLE_STRING 
     27endenum 
     28}}} 
     29This 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{{{ 
     32subroutine 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)) 
     49end subroutine muscle_fortran_init 
     50}}}