public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* 16 bits char string from C to FORTRAN
       [not found] ` <b7e3a9c0904231558g25f215la8802b76bb0e0e41@mail.gmail.com>
@ 2009-04-24  4:07   ` Americo Barbosa da Cunha Junior
  2009-04-24  5:14     ` Steve Kargl
  0 siblings, 1 reply; 2+ messages in thread
From: Americo Barbosa da Cunha Junior @ 2009-04-24  4:07 UTC (permalink / raw)
  To: fortran, gcc-help

Hello there,

I'm  calling a FORTRAN subroutine in a ANSI C program. The subroutine
has the following prototype:

C:

void CKINIT_(int *LENICK,int *LENRCK,int *LENCCK,int *LINC,int *LOUT,
                    int *ICKWRK,double *RCKWRK,char *CCKWRK,int *IFLAG);

FORTRAN:

      SUBROUTINE CKINIT (LENIWK, LENRWK, LENCWK, LINC, LOUT, ICKWRK,
     1                   RCKWRK, CCKWRK, IFLAG)
C
C  START PROLOGUE
C
C  SUBROUTINE CKINIT (LENIWK, LENRWK, LENCWK, LINC, LOUT, ICKWRK,
C                     RCKWRK, CCKWRK, IFLAG)*
C     Reads the binary file and creates the internal work arrays
C     ICKWRK, CCKWRK, and RCKWORK.  CKINIT must be called before any
C     other CHEMKIN subroutine is called.  The work arrays must then
C     be made available as input to the other CHEMKIN subroutines.
C
C  INPUT
C     LENIWK - Length of the integer work array, ICKWRK.
C                   Data type - integer scalar
C     LENCWK - Length of the character work array, CCKWRK.
C              The minimum length of CCKWRK(*) is MM + KK.
C                   Data type - integer scalar
C     LENRWK - Length of the real work array, WORK.
C                   Data type - integer scalar
C     LINC  -  Logical file number for the binary file.
C                   Data type - integer scalar
C     LOUT  -  Output file for printed diagnostics.
C                   Data type - integer scalar
C
C  OUTPUT
C     ICKWRK - Array of integer workspace.
C                   Data type - integer array
C                   Dimension ICKWRK(*) at least LENIWK.
C     RCKWRK - Array of real work space.
C                   Data type - real array
C                   Dimension RCKWRK(*) at least LENRWK.
C     CCKWRK - Array of character work space.
C                   Data type - CHARACTER*16 array
C                   Dimension CCKWRK(*) at least LENCWK.
C     IFLAG  - IFLAG=0 indicates successful reading of
C              binary linking file; IFLAG>0 indicates
C              error type.
C                   Data type - integer
C  END PROLOGUE


The char* string passed to CKINIT must be at least 16 bits
(CHARACTER*16) or the program is finished with the error message:

          CHARACTER LENGTH OF CCKWRK MUST BE AT LEAST 16


I've tried to change the length of the char type in C redefining
CHAR_BIT constant:

#include <limits.h>
#define CHAR_BIT 16


The program compiles without errors but every time that it is executed
the error message above is returned.

I'll become extremely grateful if someone can help me.


Thank you in advance.

Americo Cunha Jr
http://web.me.com/americo

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: 16 bits char string from C to FORTRAN
  2009-04-24  4:07   ` 16 bits char string from C to FORTRAN Americo Barbosa da Cunha Junior
@ 2009-04-24  5:14     ` Steve Kargl
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Kargl @ 2009-04-24  5:14 UTC (permalink / raw)
  To: Americo Barbosa da Cunha Junior; +Cc: fortran, gcc-help

On Fri, Apr 24, 2009 at 01:07:19AM -0300, Americo Barbosa da Cunha Junior wrote:
> 
> 
> The char* string passed to CKINIT must be at least 16 bits
> (CHARACTER*16) or the program is finished with the error message:
> 
>           CHARACTER LENGTH OF CCKWRK MUST BE AT LEAST 16
> 

The declaration CHARACTER*16 does not mean 16 bits.  It means a
string with 16 characters.

-- 
Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-24  5:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <b7e3a9c0904231550x28217ab0v4a6abd0b02132696@mail.gmail.com>
     [not found] ` <b7e3a9c0904231558g25f215la8802b76bb0e0e41@mail.gmail.com>
2009-04-24  4:07   ` 16 bits char string from C to FORTRAN Americo Barbosa da Cunha Junior
2009-04-24  5:14     ` Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).