Skip to content

Instantly share code, notes, and snippets.

@paulbuis
Last active August 29, 2015 14:28
Show Gist options
  • Save paulbuis/f64a97013e63a4562128 to your computer and use it in GitHub Desktop.
Save paulbuis/f64a97013e63a4562128 to your computer and use it in GitHub Desktop.
void hello (int repeatCount) {
hello_ (& repeatCount);
}

Again, Fortran passes function arguments "by reference" rather than "by value," so the C code calling the Fortran code in adapt.c needs to take the address of the actual argument.

In the case of the GNU Fortran compiler, the Fortran hello() procedure has an underscore appended to its name when assembly code is generated.

subroutine hello(numRepeats)
do 10 i=1,3
print*, "hello from Fortran"
10 continue
end
#include "hello.h"
int main(int argc, char** argv) {
hello(3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment