calling C from fortran
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
calling C from fortran         


Author: rudra
Date: Jul 22, 2008 22:59

dear friend, i have a C++ routine(badly written):

main()
{
ofstream myfile;
/********* PART 1: Checking machine bit *********/

FILE *stream;
char sys[6],*sysptr;
int bit;
sysptr = &sys[0];
sys[6] = 0x0;
stream=popen("/bin/uname -m","r");
fread(sysptr,1,6,stream);
pclose(stream);
//printf("%%s\n",sysptr);
Show full article (0.83Kb)
8 Comments
Re: calling C from fortran         


Author: Jörgen Tegnér
Date: Jul 23, 2008 01:57

On Tue, 22 Jul 2008 22:59:49 -0700, rudra wrote:
> dear friend, i have a C++ routine(badly written):
>
>
> main()
> {
> ofstream myfile;
> /********* PART 1: Checking machine bit *********/
>
> FILE *stream;
> char sys[6],*sysptr;
> int bit;
> sysptr = &sys[0];
> sys[6] = 0x0;

should be sys[5]=0x0;
Show full article (2.10Kb)
no comments
Re: calling C from fortran         


Author: fj
Date: Jul 23, 2008 02:02

On 23 juil, 07:59, rudra gmail.com> wrote:
> dear friend, i have a C++ routine(badly written):
>
> main()
> {
> ofstream myfile;
> /********* PART 1: Checking machine bit *********/
>
> FILE *stream;
> char sys[6],*sysptr;
> int bit;
> sysptr = &sys[0];
> sys[6] = 0x0;
> stream=popen("/bin/uname -m","r");
> fread(sysptr,1,6,stream);
> pclose(stream);
> //printf("%%s\n",sysptr);
>
> if ((strncmp(sysptr, "i686",4)==0)||
> (strncmp(sysptr, "i386",4)==0)) ...
Show full article (2.14Kb)
no comments
Re: calling C from fortran         


Author: rudra
Date: Jul 23, 2008 07:06

dear fj, while i am running the code by c-p your code, i am getting
error promp:

$ gcc -c operating_system.c
$ gfortran test.f90 operating_system.o
test.f90:6.24:

USE iso_c_binding
1
test.f90:5.31:

BIND(C,name="operating_system")
2
Error: USE statement at (1) cannot follow attribute declaration
statement at (2)
test.f90:7.15:

INTEGER(C_INT) :: r
1
Error: Parameter 'c_int' at (1) has not been declared or is a
variable, which does not reduce to a constant expression
test.f90:13.6:
Show full article (0.84Kb)
no comments
Re: calling C from fortran         


Author: Dave Seaman
Date: Jul 23, 2008 07:25

On Wed, 23 Jul 2008 07:06:41 -0700 (PDT), rudra wrote:
> dear fj, while i am running the code by c-p your code, i am getting
> error promp:
> $ gcc -c operating_system.c
> $ gfortran test.f90 operating_system.o
> test.f90:6.24:
> USE iso_c_binding
> 1
> test.f90:5.31:
> BIND(C,name="operating_system")
> 2
> Error: USE statement at (1) cannot follow attribute declaration
> statement at (2)

The compiler is telling you that what's on line 6 cannot follow what's on
line 5. Did you try reversing the order of those two lines?

--
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
no comments
Re: calling C from fortran         


Author: James Van Buskirk
Date: Jul 23, 2008 08:40

"Dave Seaman" wrote in message
news:g67f1k$ri4$2@mailhub227.itcs.purdue.edu...
> The compiler is telling you that what's on line 6 cannot follow what's on
> line 5. Did you try reversing the order of those two lines?

No, the problem is that line 4 was wrapped into lines 4 and 5.
Reuniting the two lines into one would fix the problem.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
no comments
Re: calling C from fortran         


Author: fj
Date: Jul 23, 2008 09:03

On 23 juil, 16:06, rudra gmail.com> wrote:
> dear fj, while i am running the code by c-p your code, i am getting
> error promp:
>
> $ gcc -c operating_system.c
> $ gfortran test.f90 operating_system.o
> test.f90:6.24:
>
> USE iso_c_binding
> 1
> test.f90:5.31:
>
> BIND(C,name="operating_system")
> 2
> Error: USE statement at (1) cannot follow attribute declaration
> statement at (2)
> test.f90:7.15:
>
> INTEGER(C_INT) :: r
> 1 ...
Show full article (1.30Kb)
no comments
Re: calling C from fortran         


Author: Dave Seaman
Date: Jul 23, 2008 12:57

On Wed, 23 Jul 2008 09:40:52 -0600, James Van Buskirk wrote:
> "Dave Seaman" wrote in message
> news:g67f1k$ri4$2@mailhub227.itcs.purdue.edu...
>> The compiler is telling you that what's on line 6 cannot follow what's on
>> line 5. Did you try reversing the order of those two lines?
> No, the problem is that line 4 was wrapped into lines 4 and 5.
> Reuniting the two lines into one would fix the problem.

Ah, ok. Part of the context had been snipped by the time I saw it.

--
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
no comments
Re: calling C from fortran         


Author: Ron Ford
Date: Jul 25, 2008 00:34

On Tue, 22 Jul 2008 22:59:49 -0700 (PDT), rudra posted:
> dear friend, i have a C++ routine(badly written):
>
>
> main()
> {
> ofstream myfile;
> /********* PART 1: Checking machine bit *********/
>
> FILE *stream;
> char sys[6],*sysptr;
> int bit;
> sysptr...
Show full article (1.26Kb)
no comments