Create a gist now

Instantly share code, notes, and snippets.

@certik /README.md
Last active Aug 29, 2015

What would you like to do?
Fortran / C interoperability for logical

Compile using either of:

./compile_gnu

and you should get the result:

           3 T F
true -> false
           3 F T
false -> true
Done.

Now compile using Intel:

./compile_intel

and you get the result:

           3 T F
true -> true
           3 F T
false -> true
Done.

Which is incorrect. Enable -fpscomp logical in compile_intel, recompile, then you get:

           3 T F
true -> false
           3 F T
false -> true
Done.
module a
use iso_c_binding, only: c_int, c_bool
implicit none
private
public foo
contains
subroutine foo(n, relat, relat_out) bind(c, name="foo")
integer(c_int), intent(in), value :: n
logical(c_bool), intent(in), value :: relat
logical(c_bool), intent(out) :: relat_out
relat_out = .not. relat
print *, n, relat, relat_out
end subroutine
end module
gcc -o m.o -c m.c
gfortran -o a.o -c a.f90
gcc m.o a.o -lgfortran
icc -o m.o -c m.c
#ifort -fpscomp nologicals -o a.o -c a.f90
ifort -o a.o -c a.f90
icc m.o a.o -lifcore
pgcc -o m.o -c m.c
pgf90 -o a.o -c a.f90
pgcc m.o a.o -pgf90libs
#include <stdio.h>
#include <stdbool.h>
void foo(int n, bool relat, bool *relat_out);
int main()
{
bool relat_out;
foo(3, true, &relat_out);
printf("true -> %s\n", relat_out ? "true" : "false");
foo(3, false, &relat_out);
printf("false -> %s\n", relat_out ? "true" : "false");
printf("Done.\n");
return 0;
}

Hello
I need some help in fortran programming. As i am new in fortran so i am not getting how to merge two file or all i can say how to compile 2 file. As i am student of atmospheric science stream so i need to merge some satellite data. I have 10 files (Lat Lon Vales in each files). I want to make it one and also want to do average of each lat , lon values.

Hope you got my problem

Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment