- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a subroutine
SUBROUTINE ALLOCATE_ARRAY(PC_ID, PC_ID_SIZE, ISV)
IMPLICIT NONE
CHARACTER*100, ALLOCATABLE::PC_ID(:)
INTEGER PC_ID_SIZE,ISV
INTEGER IERN
CHARACTER CBUF
IF (ALLOCATED(PC_ID)) DEALLOCATE (PC_ID, STAT=ISV)
ALLOCATE (PC_ID(PC_ID_SIZE), STAT=ISV) ! ALLOCATE PC_ID to a size of 500
IF (ISV .NE. 0) THEN
C FATAL ERROR - RUN TERMINATED
IERN = 2
CALL ERROR (IERN, CBUF)
C MEMORY ALLOCATION ERROR
IERN = 73
CALL ERROR (IERN, CBUF)
ENDIF
RETURN
END
called from a main program ( this has been reduced for the forum)
USE COMMON_PARENTCHILD
IMPLICIT NONE
INTEGER ISV
PC_ID_SIZE = 500
CALL ALLOCATE_ARRAY(PC_ID,PC_ID_SIZE,ISV)
STOP
END
with the module
MODULE COMMON_PARENTCHILD
CHARACTER*100, ALLOCATABLE::PC_ID(:)
INTEGER PC_ID_SIZE
END MODULE COMMON_PARENTCHILD
and an error
Error 1 error LNK2001: unresolved external symbol _ALLOCATE_ARRAY@16 progdll_lib.lib progdll
is shown
steve
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
way is to put the subroutine in a module.
The error you quote seems to be caused bynot exporting the allocate_array subroutine.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. An allocatable array may be passed as an actual argument to
(a) a subroutine that expects an ordinary array argument in the corresponding position.
(b) a subroutine that expects an allocatable array argument in the corresponding position.
In case (a), the actual argument may be either a statically allocated array or a dynamically allocated array, and no explicit interface to the subroutine is needed in the caller.
In case (b), the actual argument must be ALLOCATABLE, and an explicit interface to the subroutine is needed in the caller. Without an explicit interface provided, the compiler will produce an incorrect subroutine linkage.
2. If the called subroutine is in a DLL and the caller is in a separate application, extra care is needed to provide the explicit interface when one is needed. You have not made it clear as to which subroutines are in the DLL, how the DLL is built and called.
3. You have used the STDCALL linkage in your DLL or EXE. There needs to be a good reason for its being used, and consistency in its being used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in Intel Fortran it is not the default. So someone has taken a deliberate action to turn it on (the
visible effect is the suffix "@16" to the subroutine name).
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are absolutely no restrictions on passing an allocatable array as an actual argument that don't apply to any other kind of array. The language does provide requirements for an explicit interface depending on how the dummy arguments of the called routine are declared, but this is independent of the form of the actual argument.
In particular, there is no requirement that the dummy corresponding to an allocatable array also be ALLOCATABLE - in most cases you don't need or want that. The only case where you would want ALLOCATABLE on the dummy is if you plan to change the allocation status in the called routine.
Now as to the STDCALL - this program is probably being compiled with /iface:cvf, especially if it was migrated from CVF. In most cases, you can turn off that option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page