ralna / libHSL

Dummy repository for libHSL
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Add some symbols of ma57 in the dummy library libhsl #7

Open amontoison opened 3 months ago

amontoison commented 3 months ago

Charlie Varanet recently released Uno, an optimization solver that can use MA57 as a linear solver. However, just like GALAHAD, Uno needs the symbols of MA57 at compilation time (https://github.com/JuliaPackaging/Yggdrasil/pull/8937). We should add dummy subroutines for the following symbols so that users can rely on HSL_jll.jl as we do with Ipopt.jl and, in the near future, GALAHAD.jl:

ma57id_
ma57ad_
ma57bd_
ma57cd_
ma57dd_

I think the following code should be enough:

SUBROUTINE MA57ID()
END SUBROUTINE MA57ID

SUBROUTINE MA57AD()
END SUBROUTINE MA57AD

SUBROUTINE MA57BD()
END SUBROUTINE MA57BD

SUBROUTINE MA57CD()
END SUBROUTINE MA57CD

SUBROUTINE MA57DD()
END SUBROUTINE MA57DD

or do we need to provide dummy subroutines with all arguments?

cc @cvanaret @jfowkes @nimgould

nimgould commented 3 months ago

My temptation would be to provide all dummy arguments so that compilers can check that the calls are correct. I didn't do this in the past for the HSL interfaces for GALAHAD as MA57 isn't called directly; hsl_ma57 is used instead. But, I have now changed this. Also, MA57 supports an additional call to MA57ED, so that should be added as well for completeness. Note that the GALAHAD dummy interface is generic, so you will need to remove the USE HSL_KINDSreal, ONLY: ip, rp statements, and replace the calls to the preprocessor so that MA57IR -> MA57ID (etc) and INTEGER ( KIND = ip ) -> INTEGER and REAL ( KIND = rp_ ) -> DOUBLE PRECISION (yes, a step back in time!)

amontoison commented 3 months ago

Thanks Nick!

I propose the following code:

SUBROUTINE MA57ID(CNTL, ICNTL)
    DOUBLE PRECISION CNTL(5)
    INTEGER ICNTL(20)
    RETURN
END SUBROUTINE MA57ID

SUBROUTINE MA57AD(N, NE, IRN, JCN, LKEEP, KEEP, IWORK, ICNTL, INFO, RINFO)
    INTEGER N, NE, IRN(NE), JCN(NE), IWORK(5*N), LKEEP, KEEP(LKEEP),
 &          ICNTL(20), INFO(40)
    DOUBLE PRECISION RINFO(20)
    RETURN
END SUBROUTINE MA57AD

SUBROUTINE MA57BD(N, NE, A, FACT, LFACT, IFACT, LIFACT,
 & LKEEP, KEEP, PPOS, ICNTL, CNTL, INFO, RINFO)
    INTEGER N, NE, LFACT, LIFACT, LKEEP
    DOUBLE PRECISION A(NE), FACT(LFACT), CNTL(5), RINFO(20)
    INTEGER IFACT(LIFACT), INFO(40), KEEP(LKEEP), PPOS(N), ICNTL(20)
    RETURN
END SUBROUTINE MA57BD

SUBROUTINE MA57CD(JOB, N, FACT, LFACT, IFACT, LIFACT, NRHS, RHS, LRHS, W,
 &                LW, IW1, ICNTL, INFO)
    INTEGER JOB, N, LFACT, LIFACT, NRHS, LRHS, LW
    DOUBLE PRECISION FACT(LFACT), RHS(LRHS, NRHS), W(LW)
    INTEGER IFACT(LIFACT), IW1(N), ICNTL(20), INFO(40)
    RETURN
END SUBROUTINE MA57CD

SUBROUTINE MA57DD(JOB, N, NE, A, IRN, JCN, FACT, LFACT, IFACT, LIFACT,
 &                RHS, X, RESID, W, IW, ICNTL, CNTL, INFO, RINFO)
    INTEGER JOB, N, NE, LFACT, LIFACT
    DOUBLE PRECISION A(NE), FACT(LFACT), RHS(N), X(N), RESID(N), CNTL(5)
    INTEGER IRN(NE), JCN(NE), IFACT(LIFACT), IW(N), ICNTL(20), INFO(40)
    DOUBLE PRECISION RINFO(20)
    DOUBLE PRECISION W(N, *)
    RETURN
END SUBROUTINE MA57DD

@cvanaret Do you need another modification such you can check if you have a dummy HSL routine or not in Uno?

nimgould commented 3 months ago

Alexis, as this is a fortran 77 code, everything has to start in column 7 (or beyond) except for the continuation (&) which must be in column 6. Also check the 72 column limit

jfowkes commented 3 months ago

I would strongly encourage people to migrate to using the F90 HSL_MA57 wrapper, especially now that it has a C interface.