AEM in FortranΒΆ

Similarly to C++ we think about splitting the codebase into two source files: main.f90 and exc.f90. The former will trivially contain the main program with a single function call to bbqFortranMain(<recipe-name>), to actually launched the runtime managed part of the application. Once again, the argument is name of the recipe file to install, as usual, in <BOSP_PREFIX>/etc/bbque/recipes/.

main.f90

program main
    print *, "FORTRAN: main: start"
    call bbqFortranMain("HelloFortran")
    print *, "FORTRAN: main: end"
end program main

The latter instead, will contain the wrapping of the BbqueEXC member functions.

Please include also the bbque_types.f90 file, for wrapping the RTLIB data types. The file is installed in <BOSP_PREFIX>/usr/lib/bbque/fortran/. You can link of directly copy it in your source folder.

exc.f90

include 'bbque_types.f90'

subroutine BBQonSetup(*)
    print *, 'FORTRAN: onSetup'
    return 0
end subroutine BBQonSetup

subroutine BBQonConfigure(*)
    use RTLIB_ResourceType
    integer proc_quota
    external BBQGetAssignedResources
    call BBQGetAssignedResources(PROC_ELEMENT, proc_quota)
    print *, 'FORTRAN: onConfigure: got CPU quota=', proc_quota
    return 0
end subroutine BBQonConfigure

subroutine BBQonRun(*)
    use RTLIB_ExitCode
    integer BBQCycles
    external BBQCycles
    print *, 'FORTRAN: onRun: cycle_num=', cycle_count
    ret = 0
    if (BBQCycles() >= 5) then
        return RTLIB_EXC_WORKLOAD_NONE
    end if
    return RTLIB_OK
end subroutine BBQonRun

subroutine BBQonMonitor(*)
    use RTLIB_ExitCode
    external BBQGetCPS
    real cps
    cps = BBQGetCPS()
    print *, "FORTRAN: onMonitor: CPS=", cps
    return RTLIB_OK
end subroutine BBQonMonitor

subroutine BBQonRelease(*)
    use RTLIB_ExitCode
    print *, 'FORTRAN: onRelease'
    return RTLIB_OK
end subroutine BBQonRelease

The executable must be then linked to the libbbque_fortran_bindings.so library, coming with the BOSP installation, in the <BOSP_PREFIX>/usr/lib/bbque/fortran/ directory.