Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] fork in Fortran
From: Dmitry N. Mikushin (maemarcus_at_[hidden])
Date: 2012-08-30 12:01:21


Modern Fortran has a feature called ISO_C_BINDING. It essentially
allows to declare a binding of external function to be used from
Fortran program. You only need to provide a corresponding interface.
ISO_C_BINDING module contains C-like extensions in type system, but
you don't need them, as your function has no arguments :)


program fork_test


function fork() bind(C)
use iso_c_binding
integer(c_int) :: fork
end function fork

end interface

print *, 'My PID = ', fork()

end program fork_test

$ make
gfortran fork.f90 -o fork
$ ./fork
 My PID = 4033
 My PID = 0

For further info, please refer to language standard
If you have any questions - consider asking the gfortran community,
they are very friendly.

- D.

2012/8/30 sudhirs@ <sudhirchem87_at_[hidden]>:
> Dear users,
> How to use fork(), vfork() type functions in Fortran programming ??
> Thanking you in advance
> --
> Sudhir Kumar Sahoo
> Ph.D Scholar
> Dept. Of Chemistry
> IIT Kanpur-208016
> _______________________________________________
> users mailing list
> users_at_[hidden]