module sub_check implicit none contains SUBROUTINE check ( ckind , fkind , vartype ) implicit none INTEGER, INTENT(IN) :: ckind , fkind CHARACTER (LEN=*) , INTENT(IN) :: vartype IF ( ckind == fkind ) THEN WRITE(*,100) vartype 100 format(' Default fortran & C variables of type ' , a , & 'are interoperable ' ) ELSE IF ( ckind < 0) THEN WRITE(*,200) vartype 200 format('A compatible fortran kind value is not available for type ',a) ELSE WRITE(*,300) vartype 300 format(' default fortran & C variables of type ' , a , & 'are NOT interoperable ' ) END IF END SUBROUTINE check end module sub_check PROGRAM CandF ! Program to test cooperation between C and Fortran USE, INTRINSIC :: iso_c_binding use sub_check implicit none CALL check ( c_int , KIND( 1 ) , ' integer / int ' ) CALL check ( c_float , KIND( 1.0e0 ) , ' real / float ' ) CALL check ( c_double , KIND( 1.0d0 ) , 'double precision/double ' ) CALL check ( c_bool , KIND( .TRUE. ) , ' logical / boolean ' ) CALL check ( c_char , KIND( 'A' ) , ' character/ char ' ) CALL check ( c_float_complex , KIND( ( 1.0e0 , 1.0e0 ) ) , & 'complex/ float_complex ' ) END Program CandF