healpix: calling f90 from C
-
- Posts: 3
- Joined: October 27 2006
- Affiliation: USNO
healpix: calling f90 from C
I'm not very familiar with F90 (much more experiance with F77) but I wanted to know if were possible to call the healpix f90 modules from C code? If it is possible, is there documentation available anywhere, or does anyone have an example test program?
I have Healpix 2.01 and Fedora Core 5 on a 64 bit Opteron in case that makes a difference.
Thanks.
I have Healpix 2.01 and Fedora Core 5 on a 64 bit Opteron in case that makes a difference.
Thanks.
-
- Posts: 13
- Joined: July 26 2006
- Affiliation: Max-Planck-Institute for Astrophysics
healpix: calling f90 from C
Hi Greg,
calling Fortran90 routines from C is, at the very least, very nonportable. There are different problems:
These problems will become solvable in Fortran 2003, but compilers for that are still rare.
If you need Healpix functionality, I expect it would be much easier to use chealpix or the C++ port, unless of course you need some routines that are only available in the Fortran version.
Cheers,
Martin
calling Fortran90 routines from C is, at the very least, very nonportable. There are different problems:
- The routine names you have to call can be very different from the names appearing in the Fortran sources. They may be all caps, have one or two underscores at the end, maybe have the module name encoded somewhere etc. This strongly depends on the compiler manufacturer.
The Fortran routines may take some hidden parameters, like string lengths, array shapes etc. You would have to "fake" these additional parameters in your calls.
These problems will become solvable in Fortran 2003, but compilers for that are still rare.
If you need Healpix functionality, I expect it would be much easier to use chealpix or the C++ port, unless of course you need some routines that are only available in the Fortran version.
Cheers,
Martin
-
- Posts: 3
- Joined: October 27 2006
- Affiliation: USNO
Re: healpix: calling f90 from C
I note that the routine I'm interested in (query_disk) is available in the java version. I calling java from C easier than calling F90?
-
- Posts: 13
- Joined: July 26 2006
- Affiliation: Max-Planck-Institute for Astrophysics
healpix: calling f90 from C
Not really, although it is at least standardized.I note that the routine I'm interested in (query_disk) is available in the java version. I calling java from C easier than calling F90?
I think your best bet is to write a C-compatible wrapper function around Healpix_Base::query_disc() and call this from your code. Unless your application is absolutely time-critical, this should work nicely.
-
- Posts: 3
- Joined: October 27 2006
- Affiliation: USNO
Re: healpix: calling f90 from C
I'll give that a try. Thanks.Martin Reinecke wrote:I
I think your best bet is to write a C-compatible wrapper function around Healpix_Base::query_disc() and call this from your code. Unless your application is absolutely time-critical, this should work nicely.