Using LightKrylov in a project

I wonder if someone could help me with this problem.

I want to use the matrix exponential function from the LightKrylov library. Initially, I thought I could just add LightKrylov as a dependnecy in my project with

LightKrylov = { git="https://github.com/nekStab/LightKrylov.git" }

but this leads to error with not being able to find the testdrive for the Logger.f90 from LightKrylov.

So, I built the library following the instructions on the repository’s page by:

  1. cd’ing into the build directory of my fpm project
  2. cloning the LightKrylov repository and cd’ing into that.
  3. fpm build --profile release
  4. fpm install --profile release

All these went successfully.

Now, how do I use it in my fpm project. Just doing use LightKrylov' did not work.

Sorry I haven’t answered yet to your issue. Lot going on right now. I ll look into on Tuesday. Note that the Krylov matrix exponential is very experimental at the moment.

Edit : is it the Krylov expm or the regular expm for dense matrices you want to use ? I suddenly have a doubt.

It is the regular expm that I want to use, although at this stage of my explorations, anything that works is fine.

Without cloning it you can add it as a dependency in your project’s fpm.toml file and a copy will be pulled from the WWW when you build your project and the objects will be in your build path so a
USE statement should work.

If you want your own local copy and have placed a clone of it in your project area you can also just use it as a dependency in your fpm.toml file but you specify a pathname instead of an URL like in the first case.

If you clone and build the directory and do the install you do not even have to have it into your project space; but you then have to specify it is an external dependency and give fpm the information it needs to locate it. The location information can be provided by fpm command line options or environment variables, or by making the installation directory a default location that your compiler already searches.

SInce you already cloned it into your project I think the second alternative is the easiest. Therefore I would follow this guideline …

If I want to be able to build offline I generally create a directory
called GLINKS and clone all the dependencies into it. I then make a
soft link to that directory in my projects and specify the “path”
variable to point to the dependencies.

An example might look like

[dependencies]
# uncomment this to use www copies
   #M_strings      = { git = "https://github.com/urbanjost/M_strings.git" }
   #M_CLI2         = { git = "https://github.com/urbanjost/M_CLI2.git" }
   #M_list         = { git = "https://github.com/urbanjost/M_list.git" }
   #M_framework    = { git = "https://github.com/urbanjost/M_framework.git" }

# uncomment this to use clones in the GLINKS directory
   M_strings      = { path = "GLINKS/M_strings" }
   M_CLI2         = { path = "GLINKS/M_CLI2" }
   M_list         = { path = "GLINKS/M_list" }
   M_framework   =  { path = "GLINKS/M_framework" }

The fpm.toml manifest file is described in detail at

fpm/manifest-reference.md at main · fortran-lang/fpm · GitHub

and describes the other alternatives like using an external library built outside
of the project.

unfortunately fpm.toml does not currently support conditional selections
or includes so you have to maintain multiple fpm.toml files or
comment out the unused lines as duplicates are also not allowed in a
single file. You can also create a template file that you run through
a preprocessor like cpp to generate the appropriate fpm.toml file as
an alternative.

What you first tried should have worked under most circumstances. Not sure exactly what you tried when you did your build though.

The issue here is on us apaprently. One of our modules uses a couple of types from testdrive but the latter is only declared as a dev-dependency and not a regular one. I ll fix it on Monday and everything should work correctly. If you want the expm function only, you can also simply extract it from the sources, no pb with that.