Editing
Library Reference
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Functions from the C library== Functions from the C library for which an interface has been defined at the end of <tt>RSFSRC/api/f90/fortran.c</tt> can be called directly from Madagascar F90 programs. The programmer must know, however, that '''an argument type mismatch will result in a silent failure, with no informative errors.''' There may be other sources of problems as well. Caution therefore must be advised when calling these functions. The reason for these issues is that [http://people.scs.fsu.edu/~burkardt/f_src/mixed/mixed.html if a FORTRAN90 routine needs to pass a scalar parameter to a C routine, there is no standard way to ensure that a value is passed rather than an address]. The success rate of calling C from Fortran [http://w3.pppl.gov/~dmccune/papers-reports/linux_f90.txt is compiler-dependent] and [http://www.cs.sandia.gov/Zoltan/ug_html/ug_fortran.html special types may have to be defined for portability]. If you do have to call a C function from F90, follow the examples of the functions below. Use the C library reference to find argument and output types. A C-to-F90 data type dictionary follows: {| class="wikitable" align="center" cellspacing="0" border="1" ! style="background:#ffdead;" | C ||! style="background:#ffdead;" | F90 |- | RSFFILE || type(file) |- | INT || integer |- | OFFSETT || integer(kind=OFFKIND) |} ===Void-output functions callable as subroutines=== These can be treated as subroutines, and accessed with a <tt>call</tt> statement. Follow * <tt>sf_error</tt> ('''G''') * <tt>sf_init</tt> ('''G''') ('''''Can it also be called in subroutines if we want to isolate I/O operations there?''''') * <tt>sf_seek</tt> ===Non-void-output functions=== It is a good idea to declare in your program the function output type and use the keyword <tt>external</tt>, i.e.: <pre>real, external :: sf_dosomething</pre> Alternately, you may define a F90 <tt>interface</tt> block for the procedure(s). Several examples can be found in <tt>RSFSRC/filt/lib/rsf.f90</tt>, but they are not enumerated here because F90 wrappers exist for them and they should be used instead of the direct calls to the C library functions.
Summary:
Please note that all contributions to Madagascar are considered to be released under the GNU Free Documentation License 1.3 or later (see
My wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Getting Madagascar
download
Installation
GitHub repository
SEGTeX
Introduction
Package overview
Tutorial
Hands-on tour
Reproducible documents
Hall of Fame
User Documentation
List of programs
Common programs
Popular programs
The RSF file format
Reproducibility with SCons
Developer documentation
Adding programs
Contributing programs
API demo: clipping data
API demo: explicit finite differences
Community
Conferences
User mailing list
Developer mailing list
GitHub organization
LinkedIn group
Development blog
Twitter
Slack
Tools
What links here
Related changes
Special pages
Page information