Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Shared Common between programs

kurrajong
Beginner
1,271 Views

I need to share a common area between individual executables . Ive seen various posts which refer to a sample called SAMPLESDLLDLLEXP2 which seems to be exactly what I need but have been unable to locate a copy anywhere. Can someone please point me to a link or provide the code.

A copy of a project solution would be great to avoid the issues I'm sure I'll have in understanding and converting the command line switches.

I already have DLL's sharing the common data.

Thanks in anticipation

GB

0 Kudos
9 Replies
Steven_L_Intel1
Employee
1,271 Views

The DLLEXP2 sample is not something I'd recommend, as it uses a rather confusing method (and didn't provide a project).

Tomorrow I'll attach a sample project that shows sharing information among executables. It uses module variables but the concept is the same with COMMON.

0 Kudos
Steven_L_Intel1
Employee
1,271 Views
Here's the example - sorry for the delay.
0 Kudos
kurrajong
Beginner
1,271 Views

Thanks.

I tried loading it but I get a message on linking

Error1 error LNK2019: unresolved external symbol __imp__SHARED_GLOBALS_mp_SHARED_VARIABLE referenced in function _MAIN__C:FIntelinSharedDllDLL_Shared_Datamain.f901
Error2 error LNK2019: unresolved external symbol __imp__SHARED_GLOBALS_mp_NOT_DEAD_YET referenced in function _MAIN__C:FIntelinSharedDllDLL_Shared_Datamain.f901
Error3 fatal error LNK1120: 2 unresolved externalsC:FIntelinSharedDllDLL_Shared_Datamain.f901

The library is created but for some reason it isnt found. Ive tried all sorts of things to make it available with no success. I can't run the batch file because of some path issue. I want to avoid the batch thing anyway and run completely from the IDE. How can I force the load of the lib file in the IDE

Ive added the /section stuff to the link command line of the project properties

COMMON

What do I need to do to use common with this. Do all elements of common have to be non-zeroed, the common areas are quite large.

Here is a common area example I use with the DLL. The proper labels are defined in other includes

! modcom.f90

!

! FUNCTIONS/SUBROUTINES exported from modcom.dll:

! modcom - subroutine

!

BLOCK DATA

!DEC$ ATTRIBUTES DLLEXPORT:: /COMFLG/

!DEC$ ATTRIBUTES DLLEXPORT:: /RTCFG/

!DEC$ ATTRIBUTES DLLEXPORT:: /PMCFG/

!DEC$ ATTRIBUTES DLLEXPORT:: /RTAPP/

!DEC$ ATTRIBUTES DLLEXPORT:: /PMAPP/

!DEC$ ATTRIBUTES DLLEXPORT:: /RTSET/

!DEC$ ATTRIBUTES DLLEXPORT:: /PMSET/

BYTE DUMDLL1,DUMDLL2,DUMDLL3,DUMDLL4,DUMDLL5,DUMDLL6,DUMDLL7 !

COMMON /COMFLG/ DUMDLL1(4000)

COMMON /RTCFG/ DUMDLL2(4000)

COMMON /RTSET/ DUMDLL3(4000)

COMMON /PMCFG/ DUMDLL4(4000)

COMMON /PMSET/ DUMDLL5(4000)

COMMON /RTAPP/ DUMDLL6(4000)

COMMON /PMAPP/ DUMDLL7(4000)

END

Thanks

GrahamB

0 Kudos
kurrajong
Beginner
1,271 Views

Further to the above, I created a new solution from scratch using the f90 files and now have it working (although I need to copy all of the DLL files into the the main debug directory). Ineed the share to run in quickwin and get an error now using windows instead of console indicating.

possible internal inconsistency file src/quickwin/qwkinit.c line 131

which seems to stop the second instance from starting.

Any ideas.

regards GB

0 Kudos
Steven_L_Intel1
Employee
1,271 Views
QuickWin and DLLs don't mix, unless the DLLs do no I/O or try to do anything with the user interface.
0 Kudos
kurrajong
Beginner
1,271 Views

Thanks,

In that case how can I share common between QUICKWIN applications.

Regards Graham B

0 Kudos
Steven_L_Intel1
Employee
1,271 Views
A QuickWin application can link to a DLL, as long as that DLL doesn't use QuickWin. In this case, build a DLL that contains only a BLOCK DATA subprogram which defines and exports the COMMONs. You can then DLLIMPORT the COMMONs and link against the DLL's export library from a QuickWin executable.
0 Kudos
kurrajong
Beginner
1,271 Views

Thanks.

Current state of play is that I have used your example, modified the module to be a BLOCK DATA common and have it working (removing a lot of the loccking code) and have successfully sahed the common amongst many applications BUT only if they are Console Apps.

If I try exactly the same code (including your original) when it tries to start the second copy of the application, the Quickwin versions fail and so it never gets far enough to have 2 quickwin applications running.

As mentioned above, the error message is

"possible internal consistency file "src/quickwin/qckinit.c line 131"

Various other thing I have tried (without debug) simply crash with an exception violation.

If you can make your example run under quickwin as opposed to console , that will solve my problem I'm sure.

My BlockData code is

BLOCK DATA

! in order to be placed in .data section

!dec$ attributes dllexport :: /COMFLG/

!dec$ attributes dllexport :: /RTFLG/

COMMON

/COMFLG/ABC(10)

COMMON

/RTFLG/JKF(10)

real

:: ABC,JKF

data

ABC(5)/888.0/ ! only needs 1 element in the common to force to .data section

data

JKF(10)/888.0/ ! only needs 1 element in the common to force to .data section

end

Which is very similar to what I sent before but simpler.

My need is simply to share the memory locations, I will manage all of the data locking etc externally and only need what windows needs to physically share the memory locations and support the multiple applications

Thanks for your help

Graham B

/

0 Kudos
Pam_R_
Beginner
1,271 Views

i tried following this guideline to work with commons

i can not seem to share the data between dll and main program through common declare in include file

there are actually 2 common, 1 common is part of the include file and that include file is included in both dll and main program. the other common i declare in both dll and main program.

the common declared in both dll and main program works ok and shares common data

however, common declare in include file is not shared

any thoughts what might be wrong

0 Kudos
Reply