- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am compiling the following file as part of a much larger project:
subroutine GetSoftwareLicense
! Checks out a license for this instance
use Globals
use Licensing
implicit none
LOGICAL :: CheckoutSuccessful
!**********************************************************************************************
!******************* CHECK OUT SOFTWARE LICENSE **********************
!**********************************************************************************************
CheckoutSuccessful = initialize_license(1, 50)
if (.not. CheckoutSuccessful) call NoLicenseExit(3)
write(szLogText,'("Success!")')
call GlobalWriter(0,.TRUE.,.FALSE.)
end subroutine GetSoftwareLicense
subroutine NoLicenseExit(iType)
! Exits based on there not being a valid license
use Globals
implicit none
INTEGER, INTENT(IN) :: iType
CHARACTER(100) :: StringLoader
INTEGER :: iret
StringLoader = "License Error"//CHAR(0)
if (iType == 1) iret = MessageBox(ghWindow,"License failed to be checked out."//CHAR(0),StringLoader,IOR(MB_OK,MB_ICONERROR))
! More such checks... Just display a relevant message based on iType
iret = SendMessage(ghWindow,WM_DESTROY,0,0)
end subroutine NoLicenseExit
integer function GetCostForThreads(threads)
implicit none
integer, intent(in) :: threads
integer, parameter :: baseline = 5
! Baseline
if (threads <= 4) then
GetCostForThreads = baseline
! Scaling
else
GetCostForThreads = INT((threads-4)*1) + baseline
endif
end function GetCostForThreads
logical function UpdateOMPThreadCount(threads)
use Licensing
use Globals
implicit none
integer, intent(in) :: threads
integer :: cost, actual_threads
logical :: success
! Obviously
if (threads <= 1) then
actual_threads = 1
else
actual_threads = threads
endif
! Get cost
cost = GetCostForThreads(actual_threads)
! Check with licensing
success = update_cost(cost)
if (success) then
call omp_set_num_threads(actual_threads)
else
call GlobalErrorHandler(14)
endif
UpdateOMPThreadCount = success
end function UpdateOMPThreadCount
Severity Code Description Project File Line Suppression State
Error error #6404: This name does not have a type, and must have an explicit type. [GETCOSTFORTHREADS] Licenses.f90
Severity Code Description Project File Line Suppression State
Error error #5508: Declaration of routine 'NOLICENSEEXIT' conflicts with a previous declaration Licenses.f90
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>I have clearly declared GetCostForThreads,
In UpdateOMPThreadCount you have implicit none
You are calling the function GetCostForThreads
Within the scope of UpdateOMPThreadCount, GetCostForThreads is undefined.
A suggestion is to place this code into a module then (elsewhere) use this module:
module YourModuleNameHere
! module data follows
! ...
contains
! module procedures follow
subroutine GetSoftwareLicense
...
end function UpdateOMPThreadCount
end module YourModuleNameHere
subroutine SomeCodeElsewhere
use YourModuleNameHere
implicit none
...
If (when) you cannot place that code inside a module, then create a module containing the interfaces and use that to declare your interfaces:
module YourInterfacesNameHere
interface
subroutine GetSoftwareLicense
end subroutine GetSoftwareLicense
subroutine NoLicenseExit(iType)
INTEGER, INTENT(IN) :: iType
end subroutine NoLicenseExit
integer function GetCostForThreads(threads)
integer, intent(in) :: threads
end function GetCostForThreads
logical function UpdateOMPThreadCount(threads)
integer, intent(in) :: threads
end function UpdateOMPThreadCount
end module YourInterfacesNameHere
...
! other file
subroutine something
use YourInterfacesNameHere
...
EDIT: Note, in the second case your subroutine GetCostForThreads will require the USE YourInterfacesNameHere.
Jim Dempsey
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@CoryG probably the error is elsewhere in your code / compilation. Any chance that we can get a full reproducer and the full compilation log?
Please also check with the latest release (2024.2).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>I have clearly declared GetCostForThreads,
In UpdateOMPThreadCount you have implicit none
You are calling the function GetCostForThreads
Within the scope of UpdateOMPThreadCount, GetCostForThreads is undefined.
A suggestion is to place this code into a module then (elsewhere) use this module:
module YourModuleNameHere
! module data follows
! ...
contains
! module procedures follow
subroutine GetSoftwareLicense
...
end function UpdateOMPThreadCount
end module YourModuleNameHere
subroutine SomeCodeElsewhere
use YourModuleNameHere
implicit none
...
If (when) you cannot place that code inside a module, then create a module containing the interfaces and use that to declare your interfaces:
module YourInterfacesNameHere
interface
subroutine GetSoftwareLicense
end subroutine GetSoftwareLicense
subroutine NoLicenseExit(iType)
INTEGER, INTENT(IN) :: iType
end subroutine NoLicenseExit
integer function GetCostForThreads(threads)
integer, intent(in) :: threads
end function GetCostForThreads
logical function UpdateOMPThreadCount(threads)
integer, intent(in) :: threads
end function UpdateOMPThreadCount
end module YourInterfacesNameHere
...
! other file
subroutine something
use YourInterfacesNameHere
...
EDIT: Note, in the second case your subroutine GetCostForThreads will require the USE YourInterfacesNameHere.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@jimdempseyatthecove good catch:)
For omp_set_num_threads it would also be better if you would add "use omp_lib". For the GETCOSTFORTHREADS function, you could also declare it as "integer, external :: GETCOSTFORTHREADS"
- 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