| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
I'm trying to compile and run a Fortran 77 code that uses Cray pointers.
I tested it on Solaris, Linux with Portland and Intel compilers, and
SGI3k. Compiling on my Mac OS X using IBM's xlf works, but I get a
segmentation fault:
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x000266d4 in ordinstep (space=541912) at ordinstep.f:18
18 stfu(i) = cstep0(rlcar(1,rlend(i-1)+1)) * rlins(i)
(gdb)
The arrays that are accessed here have their storrage assigned through
cray pointers. I'm ware of the fact that the xlf is doing byte pointer
arithmetic instead of word arithmetic, but the code does not rely any
specific type of pointer arithmetic.
Can you show us the storage assignment and/or memory allocation lines of
code?
One thing to be aware of with XLF is how you call certain functions. For
instance, if you use malloc, you need to call it as malloc(%val(n)) instead
of the usual malloc(n) many people are accustomed to. XLF passes malloc,
and many other functions, directly to C. Therefore, arguments need to be
passed as values, not address. Other FORTRAN compilers may have wrappers
that take care of this for you, but not XLF.
Here's what the XLF manual gives for an example:
MEMBLK = MALLOC(1024) ! Wrong, passes the address of the constant
MEMBLK = MALLOC(N) ! Wrong, passes the address of the variable
MEMBLK = MALLOC(%VAL(1024)) ! Right, passes the value 1024
MEMBLK = MALLOC(%VAL(N)) ! Right, passes the value of the variable
This is the most often cause of memory allocation and addressing problems I
see with people new to XLF. In fact, it stops some porting efforts dead in
their tracks! So be aware of this, and any other similarly-affected
functions. It should all be documented in the XLF manuals.
Another example is calling the time() function -- it needs to be called as
time(%val(0)) or else you will get bus errors. However, if you call time_()
it works fine -- this function has a wrapper that takes care of the
address/value issue.
Craig
| References: | |
| >Re: Subject: xlf and Cray pointers (From: Craig Hunter <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.