Using fpm in HPC system

Dear all:

Sorry in advance if this is a naive question. I am now learning how to use slurm and fpm to execute my code on the HPC system at my university. I have an account set up and I can log in and execute fortran code if I directly compile them using fortran (makefile). I am wondering if there is any way that I can use fpm to compile the same fortran code and execute them under the resource allocation of slurm script?

Thank you!

HJ

1 Like

It is certainly possible; but without a lot more information this is too broad a question.

  1. have your administrator install fpm and possibly create a module for using it.

  2. assuming you have permanent file space of your own, create a directory such as $HOME/.local/bin and build fpm and place it there and make sure the directory is in your path

are two different starting points; but without knowing more about your environment and whether the machine is on the WWW or a closed system and many other details ( are you running in a virtual machine, a container, … who has admin privileges to your environment and are they open to installing fpm for you; do you retain permanent file space on the HPC system; how familiar are you with the OS (do you know how to create your own directory of commands, …), what local resources you have to help you, … this is not really answerable. I think I would start more locally and first ask your local HPC support how to proceed, as the answer can be very specific to your local system.

fpm(1) can be as simple as installing or building from a single file and generally requires almost no additional infrastructure other than a Fortran compiler and having git(1) installed to use external dependencies. Show your administrator or instructor

Installing fpm — Fortran Package Manager

3 Likes

@urbanjost Thank you for your detailed reply!

I don’t think that my administrator will install fpm and create module for using it, while indeed I have a permanent file space for myself, and I can put fpm binary at $HOME/.local/bin .

I try to fpm build, and somehow it reports the error /usr/bin/ld: cannot find -lnlopt. So I am wondering whether I need to build fortran code from a Makefile.

I am familiar with Linux system.

So if you are using the LLNL non-linear optimization package this does not sound like you are working with a simple program. There is nothing wrong with using a makefile. So it depends somewhat on what your reasons are for switching to fpm. But if you look in the Makefile it very likely has compilation and loader options you need to use when using fpm, such as a -L option that specifies where the NLopt library is installed that you need to add to your $LIBRARY_PATH variable, or use in a response file or with the -link-flag option when using fpm. If you have the fpm command installed properly you should be able to enter something like

  fpm new tryit
  cd tryit
  fpm run

and it will build and run a little “hello world” program that lets you know the basic compiler and loader environment are set up correctly. If that works OK and the Makefile is relatively simple if you post the Makefile it would go a long way towards letting everyone know how complicated switching to fpm might be.

Hi @urbanjost , I indeed tried using fpm to create a new project and compile it, and it works. Then the question might be why I need to load nlopt, which I didn’t notice that until now. I guess I might try to use nlopt sometime before and actually now I am not using it in my code. If I want to get rid of the nlopt dependency in fpm, may I ask how should I do?

Thank you!

We need to see some of the files like your fpm.toml file, or the commands you are typing, and perhaps some of the environment variables you have set; otherwise this is sort of the like game “bigger than a breadbox”. The most likely explanation if you are using an fpm.toml file that has the nlopt library specified in it that you want to remove from the sound of it. You are not indicating if these files are something you made or if they came with some code, and so on.

Thanks @urbanjost , the following is my fpm.toml:

name = "UsedKCollateral"
version = "0.1.0"
license = "license"
author = "huijunchen9260"
maintainer = "chen.9260@osu.edu"
copyright = "Copyright 2023, huijunchen9260"
[build]
auto-executables = true
auto-tests = true
auto-examples = true
[install]
library = false
[dependencies]
# nlopt-f.git = "https://github.com/grimme-lab/nlopt-f"
# finterp = { git="https://github.com/jacobwilliams/finterp.git" }
# pyplot-fortran = { git="https://github.com/jacobwilliams/pyplot-fortran.git" }

Now I was commenting on the three dependencies to remove their existence. Is this an efficiency way to remove the dependency on nlopt-f? Or what I should do?

You have the dependencies commented out with the ‘#’ prefix so it should not require them.
So if the remaining code is really not using those other projects then you are adding the library
on your load via the command lines. So what exactly are you entering to build the code? Is it simply “fpm build” or are you adding options like “–link-flag -lnlopt”? So if you add the --verbose mode and show the command being used to build the odds are we will see what is causing the error. Something like

  fpm build --verbose