I am trying to make the arguments of a subroutine be part of the module so other subroutines can use it. Is there anyway to make this work without having to assign local variables (testDLL's a and b) to global variables (TestMod's a and b)? I am trying to avoid assignments as much as I can.
module TestMod real :: a real :: b real :: c contains !================================ subroutine testDLL ( a , b ) implicit none !DEC$ ATTRIBUTES DLLEXPORT::TestDLL call otherSub1 () end subroutine testDLL !================================ subroutine otherSub1 () implicit none c = ( a + b ) * 5.0 end subroutine otherSub1 end TestMod
Thanks.
No. Module variables are globals (and static), But you could do this:
module TestMod contains !================================ subroutine testDLL ( a , b ) implicit none !DEC$ ATTRIBUTES DLLEXPORT::TestDLL call otherSub1 () contains !================================ subroutine otherSub1 () implicit none c = ( a + b ) * 5.0 end subroutine otherSub1 end subroutine testDLL end TestMod
(I note that you don't declare c here, but you'll get the idea,) When testDLL calls otherSub1, any local variables in testDLL are visible in the contained subroutine otherSub1. Yes, you can have a contained procedure within a module procedure.
链接已复制
No. Module variables are globals (and static), But you could do this:
module TestMod contains !================================ subroutine testDLL ( a , b ) implicit none !DEC$ ATTRIBUTES DLLEXPORT::TestDLL call otherSub1 () contains !================================ subroutine otherSub1 () implicit none c = ( a + b ) * 5.0 end subroutine otherSub1 end subroutine testDLL end TestMod
(I note that you don't declare c here, but you'll get the idea,) When testDLL calls otherSub1, any local variables in testDLL are visible in the contained subroutine otherSub1. Yes, you can have a contained procedure within a module procedure.
