Reputation: 51
I am getting these kind of errors.
colsys.f:1367.51:
1 NOLD, ALDIF, K, NCOMP, M, MSTAR, 3,DUMM,0)
1
Warning: Rank mismatch in argument 'dmval' at (1) (rank-1 and scalar)
colsys.f:814.33:
1 EALPHA, A, IPIV, INTEGS, RNORM, 0, FSUB,
1
Warning: Actual argument contains too few elements for dummy argument 'integs' (1/3) at (1)
Here I an giving the program link. More errors are there in the link provided below. Some of the errors I fixed. But I don't know how to attach the updated program since it is too long to copy and paste.
https://mtchu.math.ncsu.edu/Teaching/Lectures/MA581/colsys.f
Upvotes: 5
Views: 22642
Reputation: 43762
If this is legacy FORTRAN code that has "worked for decades", you may choose to tell gfortran to ignore these statements with -fallow-argument-mismatch
or sent as a Fortran flag via:
FFLAGS="-fallow-argument-mismatch"
but be warned that for maintained or new code, the gfortran manual states:
Using this option is strongly discouraged. It is possible to provide standard-conforming code which allows different types of arguments by using an explicit interface and
TYPE(*)
.
Upvotes: 3
Reputation: 7395
The linked code is an old code written in 1981 (more than 35 years ago!), and it seems that all the warning messages come from the now obsolete way of using one-element arrays as assumed-size arrays, e.g.,
DIMENSION M(1), ZETA(1), IPAR(1), LTOL(1), TOL(1),
So, I guess it will probably be OK to just ignore all the warning messages as long as it compiles successfully. If desired, the warnings may be suppressed by some compiler options, or by modifying such arrays to assumed-size ones, e.g.
DIMENSION M(*), ZETA(*), IPAR(*), LTOL(*), TOL(*),
Another problem is that the author passes a scalar variable named DUMM
etc to a dummy array argument that is not used in the subroutine. So, to avoid warnings, we also need to declare those variables explicitly as DUMM(1)
in the caller side.
To actually modify the code, replace dummy arguments with (1)
and ,1)
in the DIMENSION
statement by (*)
and ,*)
(which could be done by hand or by sed/awk). Then the difference between the original and modified codes becomes as follows. Although it is still not clear whether the code works correctly, this at least eliminates all the warnings by gfortran and ifort.
457,458c457,461
< DIMENSION M(1), ZETA(1), IPAR(1), LTOL(1), TOL(1),
< 1 FIXPNT(1), ISPACE(1), FSPACE(1)
---
> DIMENSION M(*), ZETA(*), IPAR(*), LTOL(*), TOL(*),
> 1 FIXPNT(*), ISPACE(*), FSPACE(*)
>
> dimension dum1(1), dum2(1), dum3(1), dum4(1)
>
769,771c772,774
< DIMENSION XI(1), XIOLD(1), XIJ(1), ALPHA(1), ALDIF(1), RHS(1)
< DIMENSION A(1), VALSTR(1), SLOPE(1), ACCUM(1), IPIV(1), INTEGS(1)
< DIMENSION DALPHA(1), EALPHA(1) , FIXPNT(1)
---
> DIMENSION XI(*), XIOLD(*), XIJ(*), ALPHA(*), ALDIF(*), RHS(*)
> DIMENSION A(*), VALSTR(*), SLOPE(*), ACCUM(*), IPIV(*), INTEGS(*)
> DIMENSION DALPHA(*), EALPHA(*) , FIXPNT(*)
1260,1261c1263,1266
< DIMENSION D1(40), D2(40), ZV(40), SLOPE(1), ACCUM(1), VALSTR(1)
< DIMENSION XI(1), XIOLD(1), XIJ(1), ALDIF(1), FIXPNT(1)
---
> DIMENSION D1(40), D2(40), ZV(40), SLOPE(*), ACCUM(*), VALSTR(*)
> DIMENSION XI(*), XIOLD(*), XIJ(*), ALDIF(*), FIXPNT(*)
>
> dimension dumm(1)
1755c1760,1762
< DIMENSION XIOLD(1), ALDIF(1), VALSTR(1), WORK(MSTAR,1)
---
> DIMENSION XIOLD(*), ALDIF(*), VALSTR(*), WORK(MSTAR,*)
>
> dimension dumm(1)
1899,1900c1906,1907
< DIMENSION ALPHO(1), XI(1), XIOLD(1), XIJ(1), ALPHA(1)
< DIMENSION ALDIF(1), RHS(1), A(1), IPIV(1), INTEGS(3,1)
---
> DIMENSION ALPHO(*), XI(*), XIOLD(*), XIJ(*), ALPHA(*)
> DIMENSION ALDIF(*), RHS(*), A(*), IPIV(*), INTEGS(3,*)
1901a1909,1910
>
> dimension dummy(1)
2163,2164c2172,2173
< DIMENSION Q(NROW,1), Z(1), DF(NCOMP,1)
< DIMENSION XI(1), BASEF(620), ALPHO(1), DG(40)
---
> DIMENSION Q(NROW,*), Z(*), DF(NCOMP,*)
> DIMENSION XI(*), BASEF(620), ALPHO(*), DG(40)
2329c2338,2341
< DIMENSION Z(1), FSPACE(1), ISPACE(1)
---
> DIMENSION Z(*), FSPACE(*), ISPACE(*)
>
> dimension dumm(1)
>
2332c2344,2345
< CALL APPROX (ISPACE(5), X, Z, FSPACE(IS6), FSPACE, ISPACE,
---
> CALL APPROX (ISPACE(5), X, Z, FSPACE(IS6), FSPACE, ISPACE(1),
> c CALL APPROX (ISPACE(5), X, Z, FSPACE(IS6), FSPACE, ISPACE,
2374c2387
< DIMENSION Z(1), VN(1), XI(1), ALDIF(1), M(1), DMVAL(1)
---
> DIMENSION Z(*), VN(*), XI(*), ALDIF(*), M(*), DMVAL(*)
2482c2495
< DIMENSION VN(1), M(1)
---
> DIMENSION VN(*), M(*)
2532c2545
< DIMENSION VN(1), XI(1), M(1)
---
> DIMENSION VN(*), XI(*), M(*)
2612c2625
< DIMENSION BASEF(1), VN(1), XMESH(1)
---
> DIMENSION BASEF(*), VN(*), XMESH(*)
2889c2902
< DIMENSION ALDIF(1), ALPHA(1), XI(1), M(1)
---
> DIMENSION ALDIF(*), ALPHA(*), XI(*), M(*)
3004,3005c3017,3018
< DIMENSION UHIGH(1) , AR(20), ARM1(20)
< DIMENSION ALDIF(1), XIOLD(1)
---
> DIMENSION UHIGH(*) , AR(20), ARM1(20)
> DIMENSION ALDIF(*), XIOLD(*)
Upvotes: 3
Reputation: 78374
Either
a) in the declaration of a procedure (either a function
or a subroutine
) argument dumm
is defined to be a rank-1 array (an array with 1 dimension if you prefer but 'rank-1' is the Fortran terminology that your compiler uses) and when your code calls the procedure it is given a scalar value. Note in particular that a scalar value is not the same (for argument matching) as a rank-1 array with only one element.
or
b) vice-versa.
Either way, there is a mismatch between the argument in the procedure definition and the argument passed when the procedure is called.
The second error you report is similar, it seems that when the procedure is called it expects a 3-element array but gets only a 1-element array. Or something like that.
Personally I'm not inclined to follow links off-site in search of more errors to fix.
Upvotes: 5