Print

Print


On Thu, 2012-06-07 at 00:21 +0800, Zhigang Wu wrote:
> 
> Dear all,
> 
>  
> 
> I would like to know if it is possible to write hybrid codes combining
> both Fortran and JAVA. I know that modern Fortran can communicate with
> C, is JAVA also suitable to work with Fortran?

Subclause 15.1 of the Fortran 2008 standard says

        Fortran provides a means of referencing procedures that are
        defined by means of the C programming language or procedures
        that can be described by C prototypes as defined in 6.7.5.3 of
        ISO/IEC 9899:1999, even if they are not actually defined by
        means of C.  Conversely, there is a means of specifying that a
        procedure defined by a Fortran subprogram can be referenced from
        a function defined by means of C.  In addition, there is a means
        of declaring global variables that are associated with C
        variables whose names have external linkage as defined in 6.2.2
        of ISO/IEC 9899:1999.

When a Fortran procedure is referenced by C, there is an expectation
that the Fortran runtime library has been appropriately initialized.
This might not happen if the Fortran procedure is referenced from, say,
Java or Ruby or IDL or Maple, so Fortran I/O might not work.  This
depends upon the relationship of the Fortran processor to a "companion"
processor, which need not be a C processor.  Some Fortran processors
notice that the runtime library hasn't been initialized, and do the
initialization if needed, say, during a WRITE statement.  Others
generate code to do it before the main program begins execution, and
don't later check whether it's been done.  The latter are becoming more
rare.

> It will be extremely appreciated if some related internet resources
> can be introduced.
> 
>  
> 
> Many thanks!
> 
>  
> 
> Regards
> 
>  
> 
> Zhigang Wu