diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2020-10-30 09:44:17 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2020-10-30 09:44:17 -0400 |
commit | a1eb0b0e024f57d1a9ab3ac8dac982fd9dc366e2 (patch) | |
tree | 3e82e89669854e1208743971b12ee4ccc225f516 | |
parent | 2b934212019fc3156e6acfa0a559c8a4d6720090 (diff) | |
download | clp_fortran-a1eb0b0e024f57d1a9ab3ac8dac982fd9dc366e2.tar.gz clp_fortran-a1eb0b0e024f57d1a9ab3ac8dac982fd9dc366e2.zip |
Added documentation for using DLLs and a general overview.
-rw-r--r-- | README.md | 45 | ||||
-rw-r--r-- | clp-dll/README.md | 29 | ||||
-rw-r--r-- | src/examples/basic.f90 | 2 |
3 files changed, 75 insertions, 1 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..670a96a --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Clp-Fortran Interface Library + +The Clp-Fortran interface library provides a simple wrapper around the COIN Linear Programming Library's C interface in a Fortran compatible manner. This interface aims to simplify the calling, eliminating much of the need to deal with C-style strings and arrays, instead providing clean Fortran equivalents. + +Much of the instructions and infrastructure included in this distribution focus on configuration and use on Windows systems, though the library itself can be built on other operating systems. Several Simply Fortran projects to simplify building the library and example code are also included. + +## Library Overview + +The Clp-Fortran interface is comprised of five Fortran source files contained within the *src* directory: + + * *clp.f90* - Primary interface code for the library containing + * *clp_callback.f90* - Code for supporting the COIN model callbacks in a Fortran-esque style + * *clp_constants.F90* - Constants used by the interface library and the COIN Linear Programming Library itself + * *clp_interface_utilities.f90* - Code mostly directed at handling the conversion of C strings to Fortran strings and vice versa + * *clp_types.f90* - Module containing necessary derived type definitions (currently empty) + +The most notable feature of this interface library is that routines that would provide arrays and strings will do so using Fortran programming paradigms rather than only providing thin wrappers returning C pointers. Arrays that are either used as input or output are Fortran-native arrays, and procedures using strings can use normal Fortran strings without requiring C-style string termination. + +## Using Clp on Windows + +Two separate sets of intructions are provided for using Clp and this library on Windows. For users wishing to compile the COIN Linear Programming library from scratch can consult *[clp-bin/BUILD.md](clp-bin/BUILD.md)* for instructions on how to build static libraries from CoinUtils and Clp source code on Windows. This process is somewhat time-consuming and requires substantially more requirements to configure a Minimalist GNU For Windows 64-bit (MinGW64) UNIX-like environment. + +The instructions for working with prebuilt COIN Linear Programming libraries on Windows are contained in *[clp-dll/README.md](clp-dll/README.md)*, and the requirements are substantially simpler. These instructions include where to download prebuilt libraries and what files should be extracted to use this interface. + +## Included Projects + +Four Simply Fortran projects are included in this distribution. + +** For Compiling the Clp-Fortran interface library: ** + + * *libClpFortran.prj* - Produces a static library for use with the static build of the COIN Linear Programming library in *clp-bin* + * *libClpFortran.dll.prj* - Produces a DLL for use with the prebuilt COIN Linear Programming DLL library in *clp-dll* + +** Examples using the Clp-Fortran interface library: ** + + * *clp-example.prj* - Builds an example program using static libraries + * *clp-example-using-dlls.prj* - Builds an example program using shared libraries + +Users are encouraged to work with the example projects as a basis because they include the flags necessary to build an executable that calls the Clp-Fortran interface library. + +--- + +*by Jeff Armstrong (jeff@approximatrix.com)* + +*Initial Release: 2020-10-30* diff --git a/clp-dll/README.md b/clp-dll/README.md index 5e15171..6f67fa6 100644 --- a/clp-dll/README.md +++ b/clp-dll/README.md @@ -39,3 +39,32 @@ The above are the only files necessary for compiling and linking against the COI ## Compiling the Clp-Fortran Interface +When compiling the Fortran interface to a DLL, the linker must be provided with the static import libraries (ending in *.lib*) during the process. For simplicity, in the topmost directory, a Simply Fortran project, *libClpFortran.dll.prj* is included that is pre-configured to link with the two necessary import libraries that should reside in this directory. The resultant library DLL will be created in this directory as well. + +The project will also produce a static import library for the Fortran interface, nominally named *libClpFortran.dll.a*, in this directory that can be used for linking projects utilizing the Clp-Fortran interface as well. + +## Compiling Code that Uses the Clp-Fortran Interface + +To use the Clp-Fortran interface, code must link to the requisite DLL import libraries: + + * libClpFortran.dll.a + * Clp.dll.lib + * CoinUtils.dll.lib + +Additionally, the Fortran modules associated with the Clp-Fortran interface must be on the module search path for the compiler. The project mentioned above that is configured to build the Clp-Fortran interface DLL produces modules in the *modules* subdirectory of this directory. + +When running the executable, the following DLLs must be present in the same directory as the executable file: + + * libClpFortran.dll + * Clp-0.dll + * CoinUtils-0.dll + * coinasl-2.dll + * coinglpk-40.dll + +An example Simply Fortran project, *clp-example-using-dlls.prj*, is included in the parent directory that builds a converted version of the Clp example driver for the C interface. This example can be used as a starting point for additional projects as it has all compiler flags properly configured. + +--- + +*by Jeff Armstrong (jeff@approximatrix.com)* + +*Initial Release: 2020-10-30* diff --git a/src/examples/basic.f90 b/src/examples/basic.f90 index ee69d39..27e6811 100644 --- a/src/examples/basic.f90 +++ b/src/examples/basic.f90 @@ -24,7 +24,7 @@ program main write (*,*) Clp_numberRows(lp) write (*,*) Clp_numberColumns(lp) -! call Clp_printModel(lp,"name"//c_null_char) ! seems to be broken when model is not defined +! call Clp_printModel(lp,"name") ! seems to be broken when model is not defined call Clp_deleteModel(lp) end |