Results 1 to 2 of 2
Hi
Possibly not doing the correct way ... but I have a system developed using Fortran and C code, linked together to produce a task. The Fortran code has a ...
- 07-25-2007 #1Just Joined!
- Join Date
- Jul 2007
- Location
- Sussex, UK
- Posts
- 3
Access Fortran Common Block in other task
Hi
Possibly not doing the correct way ... but I have a system developed using Fortran and C code, linked together to produce a task. The Fortran code has a COMMON block defined that I am accessing within the C module without problem (defined as extern in the C module with an underscore appended)
However, I want the Fortran Common block to be accessible via other stand alone tasks. I had decided to (try) to do this via Shared Memory. ie. Define a shared memory segment using 'shmat' within the C module, forcing the address to be the same as the address of the COMMON block (within the shmat call) and then using this same shared memory block in the stand alone task.
However, the shmat call is currently failing with the error: Invalid argument. If I replace the address (&CommonBlock) with NULL within the shmat call, then it works OK ... but obviously the address is not then where I want it to be!
Can anyone give me a mechanism to allow a COMON block in one task be accessible from another task without linking the 2 together. Or can someone suggest a better mechanism.
I hope someone can make sense of the above and can provide some help. Please be aware that my Fortran skills are not great!
I am currently developing the system under Cygwin, but will be moving onto SUSE 10.2
Thanks very much
- 07-25-2007 #2Just Joined!
- Join Date
- Jul 2007
- Location
- Sussex, UK
- Posts
- 3
Related info?
Bit more info in case it prompts any assistance:
Even without the Fortran component I'm having problems!
I can not force the shared memory segment at any address without the shmat call failing.
ie In the C module:
void* pShmMem;The shmat call fails.
cout << "Creating shared memory" << endl;
pShmMem = new unsigned char[1024];
mKey = 1234;
if ((miShmId = shmget(mKey, 1024, 0666 | IPC_CREAT)) == -1 )
{
perror("shmget");}
exit(1);
mpData = (char *)shmat(miShmId, pShmMem, 0);
Is this not allowed either?
Thanks


Reply With Quote