Fortran90 High Level Architecture Library

(libF90HLA)

-

C. Stenzel, S. Pawletta

February 2008

Abstract

The F90HLA library is developed through the research group Computational Engineering and Automation at the University of Wismar. It provides HLA connectivity within Fortran90 under Linux and Windows. Besides the GNU Compiler Suite also the Intel Compiler is supported. The current toolbox supports the HLA standard 1.3. It is licensed under the LPGL, the additional demos are licensed under the GPL. The recommended Runtime Infrastructure (RTI) is ONERA CERTI. The development takes place on the ONERA CERTI development web site at Savannah.
Contents Introduction
The High Level Architecture (HLA) is a standard for distributed simulation. Invented and developed by the American Department of Defense HLA arised to the first IEEE standard for distributed simulation in september 2000. The middleware providing HLA services is called Runtime Infrastructure (RTI).

Today different commercial and non-commercial RTI implementations exist. All of these implementations provide an API to C++ and/or Java conform to the interface specification of the HLA standard. This absolutely fulfills the requirements of the military domain where most of the simulations are coded in object-oriented programming languages like C++ or Java.

In the civilian domain simulations are created with the help of so-called Commercial of the Shelf Simulation Packages (COTSSP). HLA integration is not widely provided by today's COTSSP.

Simulation model design and execution in the engineering and scientific domain are often characterized by the usage of Scientific and technical Computation Environments (SCE) like Matlab, a famous commercial SCE. Other free SCEs already exist like Octave or Scilab. These systems replaces more and more the traditional Fortran coding. But existing Fortran programs are daily used througout the scientific and engineering community. Especially for the supercomputing community Fortran is still today the primary programming language.

In respect of the increasing importance of HLA there is a need to provide engineers a native HLA interface in their "daily working environments". This approach promises to reduce the effort for applying HLA in the engineering community to a minimum.

The F90HLA library closes this gap for Fortran. The related software project MatlabHLA of the research group CEA provides an HLA interface within Matlab (MatlabHLA-Toolbox).

Features
To simplify the original RTI interface the library makes use of abbreviated RTI service designators, selectable exception handling, default federate services and use of vectorized operation whereever possible. The library currently supports the GNU compiler suite 3.x, 4.x and the Intel Compiler Suite 9.x and 10.x.
F90 RTI Linkage
Linkage between C++ and Fortran is not straightforward. C++ compilers use a non-standardized technique called name mangling or name decoration to generate unique object code symbols and to provide additional semantic information for the linker. Programming concepts like function overloading are realized through name mangling. Even linkage between different compiler versions is usally not successful. Also Fortran compilers make use of name mangling, especially the module concept in Fortran90 requires this technique. But as a rule C++ compilers can use C style naming conventions on demand (extern "C"). So the problem is reduced to link Fortran object code against C.

The incompatibilities between C and Fortran can be relieved at the source code level. The following code fragment illustrates the principle:

This short Fortran program calls the function rtisrv with one parameter. The implementation of rtisrv is provided within a C++ program. Obviously parameters are passed by reference. When passing arrays the memory management differs between C and Fortran. C stores multidimensional arrays in row-major order but Fortran in column-major order. Additionally the Fortran compiler extends the function name with an underline character. This behaviour is compiler dependent but can easily handled on C source code level. The problem gets more complex when calling Fortran module functions from C. For example generates the Intel Fortran Compiler ifort (9.x, 10.x) from a function with the name fcnname within a module named modulename the symbol modulename_mp_fcnname_. Instead generates the GNU compiler gfortran the symbol __modulename__fcnname. The F90HLA library uses conditional preprocessor constants to support different compilers. Functions for data type conversions are also provided.

When integrating the object oriented RTI interface within a procedural language environment four main challanges have to be overcome:

Typically, a federate is only member of one federation. Originating of that assumption a federate have to instantiate one object of the RTIambassador class. The methods of the RTIambassador object are so-called RTI services. Furthermore a derived class of the abstract FederateAmbassador class have to be instantiated. The methods of that object are the so-called federate services and are application specific. These methods allow libRTI to call into the application and can best compared as callbacks. Both objects typically stay in memory until the process terminates.

The F90HLA library provides the function rtiOn() to instantiate statically an RTI ambassador object and a federate ambassador object. Once instantiated a procedural interface towards libRTI as shown in the right figure can be built up.

The usage of methods with the same name but different signatures is common practise in the object orientation. Also the RTI-C++-interface makes extensive use of overloaded methods. However, Fortran90 do not support overloading natively. But Fortran90 knows the concept of optional function parameters. With the intrinsic function present the existence of a parameter declared as optional can be tested. These tests are performed on an additional Fortran90 module layer. After that the layer calls the corresponding method of the C++ wrapper. Finally this C++ routine converts Fortran types to C/C++ types and calls the appropriate RTI service.

A similar method is applied to realize a selectable exception handling. When an optional error parameter is passed potential exceptions generated on the C++ wrapper layer are returned to the Fortran federate. By default the application terminates when an error occurs.

A Fortran90 federate invokes RTI services by calling the appropriate rtiModSrv function. There the function signature is analysed and the appropriate C function in the C++-Wrapper called. At C++ level all necessary type conversion are done. After that the actual library function is called. All RTI services return after execution immediatly. RTI initiated calls are handled first on the C++ wrapper layer. LibRTI calls the implemented federate services. There a type conversion from C resp. C++ types into Fortran types takes place. Finally the appropriate Fortran90 federate service implementation is called.

Supported Services
Federation Management - RTI Services (4)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
4.2 createFederationExecution createFedExec 1
4.3 destroyFederationExecution destroyFedExec 1
4.4 joinFederationExecution joinFedExec 1
4.5 resignFederationExecution resignFedExec 1
4.6 registerFederationSynchronizationPoint registerFedSyncPoint 1
4.9 synchronizationPointAchieved syncPointAchieved 1
4.11 requestFederationSave requestFedSave 1
4.13 federateSaveBegun fedSaveBegun 1
4.14 federateSaveComplete fedSaveComplete 1
4.14 federateSaveNotComplete fedSaveNotComplete 1
4.16 requestFederationRestore requestFedRestore 1
4.20 federateRestoreComplete fedResComplete 1
4.20 federateRestoreNotComplete fedResNotComplete 1

Federation Management - Federate Services (4)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
4.7 synchronizationPointRegistrationSucceeded syncPointRegSucceeded 1
4.7 synchronizationPointRegistrationFailed syncPointRegFailed 1
4.8 announceSynchronizationPoint announceSyncPoint 1
4.10 federationSynchronized fedSync 1
4.12 initiateFederateSave initiateFedSave 1
4.15 federationSaved fedSaved 1
4.15 federationNotSaved fedNotSaved 1
4.17 requestFederationRestoreSucceeded requestFedResSucceeded 1
4.17 requestFederationRestoreFailed requestFedResFailed 1
4.18 federationRestoreBegun fedResBegun 1
4.19 initiateFederateRestore initiateFedRestore 1
4.21 federationRestored fedRestored 1
4.21 federationNotRestored fedNotRestored 1

Declaration Management - RTI Services (5)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
5.2 publishObjectClass publishObjClass 1
5.3 unpublishObjectClass unpublishObjClass 0
5.4 publishInteractionClass publishInteractClass 0
5.5 unpublishInteractionClass unpublishInteractClass 0
5.6 subscribeObjectClassAttributes subscribeObjClassAttr 1
5.7 unsubscribeObjectClass unsubscribeObjClass 0
5.8 subscribeInteractionClass subscribeInteractClass 0
5.9 unsubscribeInteractionClass unsubscribeInteractClass 0

Declaration Management - Federate Services (5)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
5.10 startRegistrationForObjectClass startRegForObjClass 0
5.11 stopRegistrationForObjectClass stopRegForObjClass 0
5.12 turnInteractionsOn turnInteractOn 0
5.13 turnInteractionsOff turnInteractOff 0

Object Management - RTI Services (6)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
6.2 registerObjectInstance registerObjInst 1
6.4 updateAttributeValues updateAttrVal 1
6.6 sendInteraction sendInteract 0
6.8 deleteObjectInstance deleteObjInst 0
6.10 localDeleteObjectInstance localDelObjInst 0
6.11 changeAttributeTransportType changeAttrTransType 0
6.12 changeInteractionTransportType changeInteractTransType 0
6.15 requestObjectAttributeValueUpdate requestObjAttrValUp 0

Object Management - Federate Services (6)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
6.3 discoverObjectInstance discoverObjInst 1
6.5 reflectAttributeValues reflectAttrVal 1
6.7 receiveInteraction receiveInteract 0
6.9 removeObjectInstance removeObjInst 0
6.13 attributesInScope attrInScope 0
6.14 attributesOutOfScope attrOutOfScope 0
6.16 provideAttributeValueUpdate provideAttrValUpdate 0
6.16 turnUpdatesOnForObjectInstance turnUpdatesOnForObjInst 0
6.18 turnUpdatesOffForObjectInstance turnUpdatesOffForObjInst 0

Ownership Management - RTI Services (7)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
7.2 unconditionalAttributeOwnershipDivestiture unconditionalAttrOsDivest 0
7.3 negotiatedAttributeOwnershipDivestiture negotiatedAttrOsDivest 0
7.7 attributeOwnershipAcquisition attrOsAcq 0
7.8 attributeOwnershipAcquisitionIfAvailable attrOsAcqIfAvail 0
7.11 attributeOwnershipReleaseResponse attrOsRelRes 0
7.12 cancelNegotiatedAttributeOwnershipDivestiture cancelNegAttrOsDivest 0
7.13 cancelAttributeOwnershipAcquisition cancelAttrOsAcq 0
7.15 queryAttributeOwnership queryAttrOs 0
7.17 isAttributeOwnedByFederate isAttrOwnedByFed 0

Ownership Management - Federate Services (7)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
7.4 requestAttributeOwnershipAssumption requestAttrOsAssump 0
7.5 attributeOwnershipDivestitureNotification attrOsDivestNot 0
7.6 attributeOwnershipAcquisitionNotification attrOsAcqNot 0
7.9 attributeOwnershipUnavailable attrOsUnavail 0
7.10 requestAttributeOwnershipRelease requestAttrOsRel 0
7.14 confirmAttributeOwnershipAcquisitionCancellation confirmAttrOsAcqCancel 0
7.16 informAttributeOwnership informAttrOs 0
7.16 attributeIsNotOwned attrIsNotOwned 0
7.16 attributeOwnedByRTI attrOwnedByRTI 0

Time Management - RTI Services (8)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
8.2 enableTimeRegulation enableTimeReg 1
8.4 disableTimeRegulation disableTimeReg 0
8.5 enableTimeConstrained enableTimeConstr 1
8.7 disableTimeConstrained disableTimeConstr 0
8.8 timeAdvanceRequest timeAdvReq 1
8.9 timeAdvanceRequestAvailable timeAdvReqAvail 0
8.10 nextEventRequest nextEventReq 0
8.11 nextEventRequestAvailable nextEventReqAvail 0
8.12 flushQueueRequest flushQueueReq 0
8.14 enableAsynchronousDelivery enableAsyncDeliv 1
8.15 disableAsynchronousDelivery disableAsyncDeliv 0
8.16 queryLBTS queryLBTS 0
8.17 queryFederateTime queryFedTime 0
8.18 queryMinNextEventTime queryMinNextEventTime 0
8.19 modifyLookahead modifyLookahead 0
8.20 queryLookahead queryLookahead 0
8.21 retract retract 0
8.23 changeAttributeOrderType changeAttrOrderType 0
8.24 changeInteractionOrderType changeInteractOrderType 0

Time Management - Federate Services (8)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
8.3 timeRegulationEnabled timeRegEnabled 0
8.6 timeConstrainedEnabled timeConstrEnabled 0
8.13 timeAdvanceGrant timeAdvGrant 1
8.22 requestRetraction requestRetract 0

Data Distribution Management - RTI Services (9)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
9.2 createRegion createRegion 0
9.3 notifyAboutRegionModification notifyAboutRegMod 0
9.4 deleteRegion deleteRegion 0
9.5 registerObjectInstanceWithRegion registerObjInstWR 0
9.6 associateRegionForUpdates associateRegForUpdates 0
9.7 unassociateRegionForUpdates unassociateRegForUpdates 0
9.8 subscribeObjectClassAttributesWithRegion subscribeObjClassAttrWR 0
9.9 unsubscribeObjectClassAttributesWithRegion unsubscribeObjClassAttrWR 0
9.10 subscribeInteractionClassWithRegion subscribeInteractClassWR 0
9.11 unsubscribeInteractionClassWithRegion unsubscribeInteractClassWR 0
9.12 sendInteractionWithRegion sendInteractionWR 0
9.13 requestClassAttributeValueUpdateWithRegion requestClassAttrValUpdateWR 0

RTI Support Services (10)

Service Number HLA Interface Specification Method F90HLA Library Function Implementation Status
10.2 getObjectClassHandle getObjClassHdl 1
10.3 getObjectClassName getObjClassName 0
10.4 getAttributeHandle getAttrHdl 1
10.5 getAttributeName getAttrName 0
10.6 getInteractionClassHandle getInteractClassHdl 0
10.7 getInteractionClassName getInteractClassName 0
10.8 getParameterHandle getParamHdl 0
10.9 getParameterName getParamName 0
10.10 getObjectInstanceHandle getObjInstHdl 0
10.11 getObjectInstanceName getObjInstName 0
10.12 getRoutingSpaceHandle getRoutingSpaceHdl 0
10.13 getRoutingSpaceName getRoutingSpaceName 0
10.14 getDimensionHandle getDimHdl 0
10.15 getDimensionName getDimName 0
10.16 getAttributeRoutingSpaceHandle getAttrRoutingSpaceHdl 0
10.17 getObjectClass getObjClass 0
10.18 getInteractionRoutingSpaceHandle getInteractRoutingSpaceHdl 0
10.19 getTransportationHandle getTransHdl 0
10.20 getTransportationName getTransName 0
10.21 getOrderingHandle getOrderingHdl 0
10.22 getOrderingName getOrderingName 0
10.23 enableClassRelevanceAdvisorySwitch enableClassRelAdvisSwitch 0
10.24 disableClassRelevanceAdvisorySwitch disableClassRelAdvisSwitch 0
10.25 enableAttributeRelevanceAdvisorySwitch enableAttrRelAdvisSwitch 0
10.26 disableAttributeRelevanceAdvisorySwitch disableAttrRelAdvisSwitch 0
10.27 enableAttributeScopeAdvisorySwitch enableAttrScopeAdvisSwitch 0
10.28 disableAttributeScopeAdvisorySwitch disableAttrScopeAdvisSwitch 0
10.29 enableInteractionRelevanceAdvisorySwitch enableInteractRelAdvisSwitch 0
10.30 disableInteractionRelevanceAdvisorySwitch disableInteractRelAdvisSwitch 0
- tick tick 1
- getRegionToken getRegionToken 0
- getRegion getRegion 0

Major Development Steps
2008
Getting libF90HLA
There are three possibilities to obtain the F90HLA library:
  1. Download the latest release from the ONERA CERTI contrib folder as source tar ball. This is the recommended method for most users.
  2. If you want to improve the F90HLA library or if you are interested in the latest changes you can get the current development state from ONERA CERTI through anonymous CVS with the following instruction:

    cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/certi co -d F90HLA applications/F90HLA

  3. The third method is for registered ONERA CERTI users only. Visit http://savannah.nongnu.org/cvs/?group=certi for further details.
Installing F90HLA library
Note: The install instructions are based upon a former successful ONERA CERTI installation. A working cmake installation is required.

  1. mkdir F90HLA_lib_build
  2. cd F90HLA_lib_build
  3. Optional: To compile with Intel Compiler Suite type:
    export CXX=icpc
    export FC=ifort
  4. cmake F90HLA_Source_Dir/libF90HLA13
  5. make
  6. make install (requires root privileges)
  7. mkdir ../F90HLA_demo_build
  8. cd ../F90HLA_demo_build
  9. cmake F90HLA_Source_Dir/demoF90
  10. make
  11. make install (requires root privileges)
  12. Verify your installation with the demo application.
Sending Patches
To create patches please work via CVS as described above. Create patches against the current cvs repository with

cvs diff -uN . > /tmp/myChanges.patch

The command line option -u creates an unified diff, -N adds new files to the patch. Please send your patch to the project supervisor.

Bug Report
The recommended method is to report the bug at the ONERA CERTI bug tracker. Choose F90HLA in the category field. This method requires a vaild login at Savannah. Another but particularly not recommended method is to write directly an email to the project supervisor.
Belonging Publications
This section tries to list all publications dealing with the High Level Architecture (HLA) and Scientific Computational Environments (SCE) or Fortran. It would be very nice if you can help to complete the list below. If you have a literature hint please send an email to the project supervisor.

2007

2006 2001 2000
Feb. 2008, C. Stenzel