- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have 4 fortran projects and right now theyall are statically linked.
A function in one of the fortran project is called by a C++ COM,out ofwhich i want one of the function argument (string) to be made available for all theremaining 3 fortran projects. I dont want to pass it as a function argument to all the functions and subroutines across all the projects. Instead I want to declare it as a global variable that can be consumed across all thethree projects. I dont have any clue about usingglobal variables in Fortran.
Please explain with a small arithmetic example (calculator), wherein one project does addition, second one does multiplication and third one does division. Fouth project calls the other three projects. The variables for arithmetic calculation should be decalred as global in fourth project and i want to consume those variables in the other three projects.
Please help me with your valuable suggestion and more valuable time.
Regards,
Jayaraj
I have 4 fortran projects and right now theyall are statically linked.
A function in one of the fortran project is called by a C++ COM,out ofwhich i want one of the function argument (string) to be made available for all theremaining 3 fortran projects. I dont want to pass it as a function argument to all the functions and subroutines across all the projects. Instead I want to declare it as a global variable that can be consumed across all thethree projects. I dont have any clue about usingglobal variables in Fortran.
Please explain with a small arithmetic example (calculator), wherein one project does addition, second one does multiplication and third one does division. Fouth project calls the other three projects. The variables for arithmetic calculation should be decalred as global in fourth project and i want to consume those variables in the other three projects.
Please help me with your valuable suggestion and more valuable time.
Regards,
Jayaraj
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use FileMapping to share memory between processes in windows.
Look at example http://support.microsoft.com/kb/188535
It is written in VisualFoxPro but it is easily rewritable to fortran because all API functions interfaces are already defined. Look at help to used functions.
Jakub
Look at example http://support.microsoft.com/kb/188535
It is written in VisualFoxPro but it is easily rewritable to fortran because all API functions interfaces are already defined. Look at help to used functions.
Jakub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create a common module file used by all programs
! yourGlobalData.f90
module yourGlobalData
real :: sharedReal
end module yourGlobalData
------
! yourProgram.f90
program yourProgram
use yourGlobalData
sharedReal = 1234.5678
call fileInOtherProject
end program yourProgram
------
! fileInOtherProject.f90
subroutine fileInOtherProject
use yourGlobalData
write(*,*) sharedReal
end subroutine fileInOtherProject
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page