Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Location
    Sussex, UK
    Posts
    3

    Unhappy 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

  2. #2
    Just 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;
    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);
    The shmat call fails.
    Is this not allowed either?
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...