Elias Athanasopoulos | 12 Apr 2003 10:46
Picon

Calling fortran from C

Hello!

Does anyone know if I can call fortran code from C using the GCC toolchain?

Elias

--

-- 
University of Athens			I bet the human brain 
Physics Department				is a kludge --Marvin Minsky 

	
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Glynn Clements | 12 Apr 2003 12:15
Favicon

Re: Calling fortran from C


Elias Athanasopoulos wrote:

> Does anyone know if I can call fortran code from C using the GCC toolchain?

Yes.

Include g2c.h to get definitions for the fortran types, and link with
-lg2c to get the functions which fortran code requires.

You also need to write the prototypes for any fortran functions which
you wish to call from C.

--

-- 
Glynn Clements <glynn.clements <at> virgin.net>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Progga | 12 Apr 2003 16:44

Randomizing


 Is there any function for randomizing a string (like glibc's strfry() ) which 
can be used across different Unices ?

 Khoda Hafez
 Progga

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Glynn Clements | 12 Apr 2003 17:40
Favicon

Re: Randomizing


Progga wrote:

> Is there any function for randomizing a string (like glibc's
> strfry() ) which can be used across different Unices ?

No; but it's not hard to write one yourself:

	void randomize(char *str)
	{
		int len = strlen(str);
		int i;
		for (i = 0; i < len; i++)
		{
			int n = i + rand() % (len - i);
			char tmp = str[i];
			str[i] = str[n];
			str[n] = tmp;
		}
	}

--

-- 
Glynn Clements <glynn.clements <at> virgin.net>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Elias Athanasopoulos | 16 Apr 2003 18:53
Picon

Re: Calling fortran from C

Hi Glynn,

On Sat, Apr 12, 2003 at 11:15:15AM +0100, Glynn Clements wrote:
> > Does anyone know if I can call fortran code from C using the GCC toolchain?
> 
> Yes.
> 
> Include g2c.h to get definitions for the fortran types, and link with
> -lg2c to get the functions which fortran code requires.

Thank you for the reply and extremely sorry for my late response.

I have done all these, except from...

> You also need to write the prototypes for any fortran functions which
> you wish to call from C.

...this.

My problem is that my app crashes whenever it calls a simple fortran 
function.

I've tested the whole stuff with:

	PROGRAM FOO 

        END 

	FUNCTION DUMMY (I)
	INTEGER I
(Continue reading)

Glynn Clements | 16 Apr 2003 19:42
Favicon

Re: Calling fortran from C


Elias Athanasopoulos wrote:

> > > Does anyone know if I can call fortran code from C using the GCC toolchain?
> > 
> > Yes.
> > 
> > Include g2c.h to get definitions for the fortran types, and link with
> > -lg2c to get the functions which fortran code requires.
> 
> Thank you for the reply and extremely sorry for my late response.
> 
> I have done all these, except from...
> 
> > You also need to write the prototypes for any fortran functions which
> > you wish to call from C.
> 
> ...this.
> 
> My problem is that my app crashes whenever it calls a simple fortran 
> function.
> 
> I've tested the whole stuff with:
> 
> 	PROGRAM FOO 
> 
>         END 
> 
> 	FUNCTION DUMMY (I)
> 	INTEGER I
(Continue reading)

Holger Kiehl | 16 Apr 2003 22:13
Picon
Favicon

Sending commands via an ssh connection

Hello

I am trying to write an ssh client to send some commands to a remote
host via ssh. But for reasons unknown to me, this client does not
want to work correctly. It seems that the remote side does not
always get the commands, so I assume there must be something wrong
with my pty communication handling. The reason why I use a pty device
is because I want this client to be called by some daemon and ssh
needs one to enter the password.                                                
I have attached the source code of my client, maybe someone can tell
me what I am doing wrong.

Thanks,
Holger
--

-- 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <signal.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

(Continue reading)

Elias Athanasopoulos | 17 Apr 2003 17:23
Picon

Re: Calling fortran from C

Hi Glynn,

On Wed, Apr 16, 2003 at 06:42:57PM +0100, Glynn Clements wrote:
> Fortran functions are call-by-reference, so you have to pass a pointer
> to a C variable:

Thank you very much! :-) It worked and you really saved me a lot of time of
research, since I know almost null about fortran.

Regards,
Elias

--

-- 
University of Athens			I bet the human brain 
Physics Department				is a kludge --Marvin Minsky 

	
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

george anzinger | 18 Apr 2003 02:26

Re: linux-source debugging with kgdb-patch

Mathur, Shobhit wrote:
> 
> 
> Hello,
> 
> BACKGROUND:
> 
> I was keen to see kgdb running  for  purely academic reasons. Thus,
> I made a setup of 2 machines for source-level debugging of the
> linux-kernel. The procedure mentioned on the web-site
> [ kgdb.sourceforge.net] has  been adhered to.  I was able to
> successfully configure the setup. Also, I decided to use "ddd" front-end
> on gdb [local m/c]  for debugging  the kgdb-patched kernel on the remote
> machine, which is the usual setup for such debugging-efforts.
>     The m/c to be debugged stops with the message "Waiting for
> connection from remote gdb..." until the "target remote" command is run
> from the "gdb" prompt of "ddd", upon which the m/c to be debugged
> continues it's bootup till it shows the command-prompt.
> 
> PROBLEM:
> 
> I was interested in setting a break-point in start_kernel thru' "ddd"
> such that the boot-up  of the m/c to be debugged could be analysed
> step-by-step remotely. Though, I am able to set the breakpoint in
> start_kernel(),
> the commands "run" or "continue" on the "gdb" prompt, only throw up the
> following errors :
> 
> (gdb) info break
> Num Type           Disp Enb Address    What
(Continue reading)

ronkhu | 28 Apr 2003 10:37
Picon
Picon

(non-member) wait-notify mechanism in pthreads

Im not a member of this list but I've got a question:
How does one go about implementing a wait-notify mechanism in pthreads 
in lieu of the
busy-waiting approach( which tends to be a cpu-hog)?

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane