Am 29.09.2021 um 23:00 schrieb Michael Potter:
Hi All,
I am porting COBOL/CICS code on iSeries to GnuCOBOL/OpenKicks on Linux.
What I am finding is that COBOL on iSeries is initializing working
storage differently than GnuCOBOL on Linux.
I have not pinned down exactly what is happening but before I try to
write some test programs I would like to come up with the list of
compile options that control how memory is initialized in GnuCOBOL.
One of the members tipped me off to -fdefault-byte=0; that looks promising.
here are my questions/requests.
1.
What exactly is defaultbyte setting and when does it set it?
here is my guess...
Default byte will set each variable in working storage that does not
have a VALUE clause. VALUE clauses will continue to be set to the
stated value. The default byte will be set each time the program is
called even if it is called multiple times.
When there is a conflict caused by redefines the first definition will
take precedence.
There's no need to guess:
cobc --help | grep "byte\|osvs"
-Warithmetic-osvs warn if arithmetic expression precision has changed
-fdefaultbyte=<value> initialize fields without VALUE to value
-fbinary-size=<value> binary byte size - defines the allocated bytes
according to PIC
-fbinary-byteorder=<value> binary byte order
-fmove-ibm MOVE operates as on IBM (left to right, byte
by byte)
-fperform-osvs exit point of any currently executing perform
is recognized if reached
-farithmetic-osvs limit precision in intermediate results to
precision of final result (less accurate)
All of those are likely interesting to you.
Note: -std=ibm / -std=mvs (or the -strict variants) set most of those.
It sounds like your porting likely benefit of setting the appropriate
dialect (but this also depends on the question "Do you want to use
features not available on the original system" or possibly _don't_ use
features from the old one [like storage initialization ;-)] )
If you don't want to use a complete dialect "as is" it is most
reasonable to look out for the "best matching", then create a
"your.conf" whcih includes that dialect file, then override whatever you
(don't) want and use this on the command line with
--conf=/path/to/your.conf or place your.conf in the directory noted in
cobc --info | grep CONFIG and just use -std=your
Additional note: defaultbyte is currently no dialect option so needs to
be set on the command line. This is likely to change with the next
release...
2.
What other options can help me initialize the memory?
No compile/dialect options other than defaultbyte.
3.
What does "IS INITIAL PROGRAM" do in GnuCOBOL? When I turned it on to
see what it did the program core dumped and I just turned it off.
It should do what the standard says, see either this or the Programmer's
Guide, for example at
https://gnucobol.sourceforge.io/HTML/gnucobpg.html#IDENTIFICATION-DIVISION
"The INITIAL, COMMON and RECURSIVE words are used only within
subprograms serving as subroutines. [...]
The INITIAL clause, if specified, guarantees the subprogram will be in
its initial (i.e. compiled) state each and every time it is executed,
not just the first time."
It should NEVER core dump because of this, maybe you use an outdated
version of GnuCOBOL and hit this bug?
fixed with 2.2 (no one should use an older version if sources are
available to recompile):
https://sourceforge.net/p/gnucobol/bugs/52/
fixed with 3.1:
https://sourceforge.net/p/gnucobol/bugs/431/
Please recheck and if your dump occurs in a newer version and if yes
report a bug with a reproducer (ideally minimal program + command line
for compile + run)
4.
Because OpenKicks has a preprocessor I could add in INITIALIZE statement
to the code before GnuCOBOL compiles it.
would this work:
INITIALIZE SOME-01-LEVEL ALL to LOW-VALUES THEN TO DEFAULT.
This would not work as you want to keep the VALUEs, but
INITIALIZE SOME-01-LEVEL WITH FILLER
ALL TO VALUE
THEN REPLACING ALPHABETIC BY LOW-VALUES
THEN REPLACING ALPHANUMERIC BY LOW-VALUES
THEN REPLACING ALPHANUMERIC-EDITED BY LOW-VALUES
THEN REPLACING NATIONAL BY LOW-VALUES
THEN REPLACING NATIONAL-EDITED BY LOW-VALUES
THEN REPLACING NUMERIC BY LOW-VALUES
THEN REPLACING NUMERIC-EDITED BY LOW-VALUES
THEN TO DEFAULT
likely would do what you want, but.. -fdefaultbyte is much easier.
Simon