Hi, I am try to run the Fortran 77 popular ODEPACK files( written by Alan Hindmarsh) on a Intel Visual Fortran Compiler running on Visual Studio Professional 2012. I have fixed most of the errors except for one recurring one that seems to have an aliasing issue with the compiler.
When the overall source codes are run, this is the result:
Error 1 error #6633: The type of the actual argument differs from the type of the dummy argument. [RWORK] C:\Users\FortranCompiler\Desktop\Liu text files\opkdmain.f 3445
Error 2 Compilation Aborted (code 1) C:\Users\FortranCompiler\Desktop\Liu text files\opkdmain.f 1
Error 3 error #6633: The type of the actual argument differs from the type of the dummy argument. [RWORK] C:\Users\FortranCompiler\Desktop\Liu text files\opkda1.f 9499
Error 4 Compilation Aborted (code 1) C:\Users\FortranCompiler\Desktop\Liu text files\opkda1.f 1
List of files and areas of code error:
opkdmain.f
C-----------------------------------------------------------------------
C CALL DSTODE(NEQ,Y,YH,NYH,YH,EWT,SAVF,ACOR,WM,WM,F,JAC,DPRJS,DSOLSS)
C-----------------------------------------------------------------------
CALL DSTODE (NEQ, Y,RWORK(LYH), NYH,RWORK(LYH),RWORK(LEWT),
1 RWORK(LSAVF),RWORK(LACOR),RWORK(LWM),RWORK(LWM),
2 F, JAC, DPRJS, DSOLSS)
KGO = 1 - KFLAG
GO TO (300, 530, 540, 550), KGO
opkda1.f :
C Call DPREPI to do matrix preprocessing operations. -------------------
CALL DPREPI (NEQ, Y, S, RWORK(LYH), RWORK(LSAVF),
1 RWORK(LEWT),RWORK(LACOR),IA,JA,IC,JC,RWORK(LWM),
2 RWORK(LWM), IPFLAG,RES, JAC, ADDA)
LENWK = MAX(LREQ,LWMIN)
IF (IPFLAG .LT. 0) RETURN
C If DPREPI was successful, move YH to end of required space for WM. ---
LYHN = LWM + LENWK
IF (LYHN .GT. LYH) RETURN
LYHD = LYH - LYHN
IF (LYHD .EQ. 0) GO TO 20
IMAX = LYHN - 1 + LENYHM
DO 10 I=LYHN,IMAX
10 RWORK(I) = RWORK(I+LYHD)
LYH = LYHN
C Reset pointers for SAVR, EWT, and ACOR. ------------------------------
20 LSAVF = LYH + LENYH
LEWTN = LSAVF + N
LACOR = LEWTN + N
IF (ISTATC .EQ. 3) GO TO 40
C If ISTATE = 1, move EWT (left) to its new position. ------------------
IF (LEWTN .GT. LEWT) RETURN
DO 30 I=1,N
30 RWORK(I+LEWTN-1) = RWORK(I+LEWT-1)
40 LEWT = LEWTN
RETURN
C----------------------- End of Subroutine DIPREPI ---------------------
END
*DECK DPREPI
SUBROUTINE DPREPI (NEQ, Y, S,YH,SAVR,EWT,RTEM,IA,JA,IC,JC,
1 WK, IWK, IPPER, RES, JAC, ADDA)
EXTERNAL RES, JAC, ADDA
INTEGER NEQ, IA, JA, IC, JC, IWK, IPPER
DOUBLE PRECISION Y, S, YH, SAVR, EWT, RTEM, WK
DIMENSION NEQ(*), Y(*), S(*), YH(*), SAVR(*), EWT(*), RTEM(*),
1 IA(*), JA(*), IC(*), JC(*), WK(*), IWK(*)
INTEGER IOWND, IOWNS,
1 ICF, IERPJ, IERSL, JCUR, JSTART, KFLAG, L,
2 LYH, LEWT, LACOR, LSAVF, LWM, LIWM, METH, MITER,
3 MAXORD, MAXCOR, MSBP, MXNCF, N, NQ, NST, NFE, NJE, NQU
INTEGER IPLOST, IESP, ISTATC, IYS, IBA, IBIAN, IBJAN, IBJGP,
1 IPIAN, IPJAN, IPJGP, IPIGP, IPR, IPC, IPIC, IPISP, IPRSP, IPA,
2 LENYH, LENYHM, LENWK, LREQ, LRAT, LREST, LWMIN, MOSS, MSBJ,
3 NSLJ, NGP, NLU, NNZ, NSP, NZL, NZU
DOUBLE PRECISION ROWNS,
1 CCMAX, EL0, H, HMIN, HMXI, HU, RC, TN, UROUND
DOUBLE PRECISION RLSS
Analysis: Both files have same error with the way RWORK is classified. From the originally run program, RWORK is classified as follows:
EXTERNAL FEX, JAC
DOUBLE PRECISION ATOL, RTOL, RWORK, T, TOUT, Y
DIMENSION NEQ(12),Y(12), RWORK(500), IWORK(30), RTOL(12), ATOL(12)
DATA LRW/500/, LIW/30/
NEQ(1) = 12
DO 10 I = 1,NEQ(1)
10 Y(I) = 0.0D0
Y(1) = 1.0D0
T = 0.0D0
TOUT = 0.1D0
ITOL = 1
RTOL = 1.0D-4
ATOL = 1.0D-6
ITASK = 1
QISTATE = 1
IOPT = 0
MF = 121
DO 40 IOUT = 1,5
CALL DLSODES (FEX, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL,
1 ITASK, ISTATE, IOPT, RWORK, LRW, IWORK, LIW, JAC, MF)
As listed in the opkdmain.f file of odepack subroutines:
C RWORK = a work array used for a mixture of real (double precision)
C and integer work space.
C The length of RWORK (in real words) must be at least
C 20 + NYH*(MAXORD + 1) + 3*NEQ + LWM where
C NYH = the initial value of NEQ,
C MAXORD = 12 (if METH = 1) or 5 (if METH = 2) (unless a
C smaller value is given as an optional input),
C LWM = 0 if MITER = 0,
C LWM = 2*NNZ + 2*NEQ + (NNZ+9*NEQ)/LENRAT if MITER = 1,
C LWM = 2*NNZ + 2*NEQ + (NNZ+10*NEQ)/LENRAT if MITER = 2,
C LWM = NEQ + 2 if MITER = 3.
C In the above formulas,
C NNZ = number of nonzero elements in the Jacobian matrix.
C LENRAT = the real to integer wordlength ratio (usually 1 in
C single precision and 2 in double precision).
C (See the MF description for METH and MITER.)
C Thus if MAXORD has its default value and NEQ is constant,
C the minimum length of RWORK is:
C 20 + 16*NEQ for MF = 10,
C 20 + 16*NEQ + LWM for MF = 11, 111, 211, 12, 112, 212,
C 22 + 17*NEQ for MF = 13,
C 20 + 9*NEQ for MF = 20,
C 20 + 9*NEQ + LWM for MF = 21, 121, 221, 22, 122, 222,
C 22 + 10*NEQ for MF = 23.
C If MITER = 1 or 2, the above formula for LWM is only a
C crude lower bound. The required length of RWORK cannot
C be readily predicted in general, as it depends on the
C sparsity structure of the problem. Some experimentation
C may be necessary.
C
C The first 20 words of RWORK are reserved for conditional
C and optional inputs and optional outputs.
C
C The following word in RWORK is a conditional input:
C RWORK(1) = TCRIT = critical value of t which the solver
C is not to overshoot. Required if ITASK is
C 4 or 5, and ignored otherwise. (See ITASK.)
C
C LRW = the length of the array RWORK, as declared by the user.
C (This will be checked by the solver.)
C
C IWORK = an integer work array. The length of IWORK must be at least
C 31 + NEQ + NNZ if MOSS = 0 and MITER = 1 or 2, or
C 30 otherwise.
C (NNZ is the number of nonzero elements in df/dy.)
C
C In DLSODES, IWORK is used only for conditional and
C optional inputs and optional outputs.
C
C The following two blocks of words in IWORK are conditional
C inputs, required if MOSS = 0 and MITER = 1 or 2, but not
C otherwise (see the description of MF for MOSS).
C IWORK(30+j) = IA(j) (j=1,...,NEQ+1)
C IWORK(31+NEQ+k) = JA(k) (k=1,...,NNZ)
C The two arrays IA and JA describe the sparsity structure
C to be assumed for the Jacobian matrix. JA contains the row
C indices where nonzero elements occur, reading in columnwise
C order, and IA contains the starting locations in JA of the
C descriptions of columns 1,...,NEQ, in that order, with
C IA(1) = 1. Thus, for each column index j = 1,...,NEQ, the
C values of the row index i in column j where a nonzero
C element may occur are given by
C i = JA(k), where IA(j) .le. k .lt. IA(j+1).
C If NNZ is the total number of nonzero locations assumed,
C then the length of the JA array is NNZ, and IA(NEQ+1) must
C be NNZ + 1. Duplicate entries are not allowed.
It seems that the sections that RWORK is taken as an array of a mix of double precision and integer data types. Is it possible for the RWORK array to contain two different data types or must it only contain one based on Intel's aliasing rules for Fortran 77. Please let me know if the structure of the code right now is in error or if there is an alternative way of allowing RWORK to include both INTEGER and DOUBLE PRECISION data types. Thank you!