gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] Fortran and Cobol type systems


From: Brian Tiffin
Subject: Re: [open-cobol-list] Fortran and Cobol type systems
Date: Sat, 14 Jun 2014 01:06:37 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26

Patrick wrote:
Hi Everyone

There are some things I miss from Ada when I program in Cobol. Ada has
facilities to match Ada and Cobol types through their interfaces.cobol
package and I can use Ada but there are some things I don't like about
Ada too.

Now I am thinking that the strong typing and user defined types from
Fortran will be enough for me.

It looks like Fortran strings are padded right with spaces and that is
encouraging. Does anyone know if the numeric and non-numeric type
systems match well ?

Kinda. It's not perfect, but as both COBOL and Fortran can speak 'native' they can interoperate. Especially gfortran and cobc.

CHARACTER data and PIC X are pretty close, as is INTEGER and REAL. You'd have to write code to deal with COMPLEX and assume a LOGICAL is an integer. Specialty cases would be a pain. KIND support in Fortran 95 would be tricky, as would PACKED DECIMAL from the COBOL side (along with all the PICTURE variants).

One huge phrase of caution.  Row major and column major ordered arrays.

Fortran will lay down arr[0][0] then arr[1][0] then arr[2][0], row major
C and COBOL lay down arr[0][0], arr[0][1], arr[0][2], column major order.

That means an index swap or transform for tables that you may want to pass back and forth to Fortran. For example, a matrix of integers passed to a Fortran formula, COBOL would have val[3][4] and Fortran would pull element [4][3] in the indexed assembler instructions. Comes down to "times r, plus c", or "plus r times c".

Brian has a neat Fortran-Cobol example on his site but it does not use
an extensive set of types and I haven't been able to come up with much
otherwise.

I'll try and duff over that listing with more details. I'd like to highlight
the risks with the row-column major indexing.  And some ways of
handling the transforms and/or index swaps.

And some more datatype tests.

Cheers,
Brian


Thanks for reading-Patrick



------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list



reply via email to

[Prev in Thread] Current Thread [Next in Thread]