Re: problem with unhandled exception (acces violation) and undefined array/pointer
- From: *** Hendrickson <***.hendrickson@xxxxxxx>
- Date: Mon, 18 May 2009 20:32:35 GMT
The basic problem is that FORTRAN 77 didn't have any dynamic
memory capabilities and people worked around that. The easiest
way was to do what is apparently biting you. Declare a huge
array in the main program and divide it up into chunks; a
poor man's malloc. By passing the chunks (like A(KADD5))
to a subroutine you could lie to the subroutine and use
them within the subroutine "as if" they had the local
declared type, not the type from the main program.
Here's where I'm taking a guess. The problem is that for
most compilers character arguments require some extra
hidden magic arguments. If you pass a real array to a
character dummy the extra arguments won't be there.
Without seeing the declarations from the called routine,
particularly those for argument 22, it's hard to say
much more than "DON'T DO THAT". Not a constructive solution.
The most likely thing to do is in the calling routine declare
a character array that has the same size as A and the same
character length as the 22nd dummy argument. This isn't
trivial, especially with "limited knowledge". But, find the
character length from READ, most likely 1 or 4, call it MMM.
Find out the size in bytes of an element of A; this will almost
for sure be 4, call it NNN. Declare a character array
character (len = MMM) dummy_name(128000*NNN/MMM)
equivalence (A, dummy_name)
Then replace the 22 argument with dummy_name(KADD?*NNN/MMM)
I may have screwed that up a bit, it's off the top of my
head and untried.
Basically, you want to overlay the real array, A, with a character
array and be able to use the same index into that array, making
allowances for the fact that NNN characters fit into one element of
A.
Good luck
*** Hendrickson
kuco wrote:
Hi,.
Background: occasional fortran user with limited knowledge, especially
with compile and link options, based of f77.
Problem: I have to make modifications on the source code dated from
the early seventies, modified many times and compiled and linked with
different applications. The first step was an attempt to compile and
link the source I was given. The process ends with the exe but
compiler return numerous warning messages all in the form:
„I:\x\source.f(666) : Warning: In the call to READ, actual argument
#22 does not match the type and kind of the corresponding dummy
argument.
2 A(K17),A(KADD1),A(KADD2),A(KADD3),A(KADD4),A(KADD5) ,A
(KADD6))“
When I run the code it goes until the the point that the warning
message is indicating. It enters the subroutine but fails when the
problematic varsiable is used for the first time. The code stops
without any error message.
In debug mode it break with „unhandled exception“ and „undefined
pointer/array“ indications.
The array A in the main code is initialized by statement: „DIMENSION A
(128000)“. As far as I could figure it out the array holds variables
of different type (integer, character). In subroutines the
corresponding variables (arrays) are defined using dimension statemnt,
and some with specific integer or character statement following.
I was told that the source was successfully compiled and linked using
Compaq Visual Fortran 6.5. I am using the same environment. The
project is defined as fortran console application, and I am using the
default settings.
Any suggestions?
Thanks
Kuco
- Follow-Ups:
- References:
- Prev by Date: Re: Fix for intel v11.0 compiler bug available?
- Next by Date: Re: problem with unhandled exception (acces violation) and undefined array/pointer
- Previous by thread: problem with unhandled exception (acces violation) and undefined array/pointer
- Next by thread: Re: problem with unhandled exception (acces violation) and undefined array/pointer
- Index(es):