Question:
FORTRAN syntax issues?
mnafk
2012-01-05 11:34:29 UTC
FORTRAN syntax issues?
What does this FORTRAN syntax mean:

A CALL is being made to a subroutine BEGIN. Some of the arguments being passed on are integers and real arrays. The index or dimension of these arrays are also being passed on, but I don't know what this really means.

CALL BEGIN (NSYS, II, KK, LENI, LENR, LENC,
1 LINKCK, LIN, LOUT, LSAVE, LIGN,
2 I(NIDAS), R(NRDAS), R(NSDAS),
3 R(NRPAR), I(NIPAR), R(NZ), R(NZP), R(NRTOL),
4 R(NATOL), R(NXMOL), C(NKSYM), C(IPCCK))

These indices or dimensions, if you will, are defined earlier in the code as following:
! APPORTION REAL WORK SPACE

NRPAR = 1
NRDAS = NRPAR + IPTOT
NSDAS = NRDAS + LRDAS
NATOL = NSDAS + LSDAS
NRTOL = NATOL + NEQ
NXMOL = NRTOL + NEQ
NZ = NXMOL + KK
NZP = NZ + NEQ
LRTOT = NZP + NEQ

! APPORTION INTEGER WORK SPACE

NIPAR = 1
NIDAS = NIPAR + LENI + IPICK
LITOT = NIDAS + LIDAS

! APPORTION CHARACTER WORK SPACE

IPCCK = 1
NKSYM = IPCCK + LENC
LCTOT = NKSYM + KK
______________________________________…
The actual subroutine header is like this:
SUBROUTINE BEGIN (NSYS, II, KK, LENICK, LENRCK, LENCCK,
1 LINKCK, LIN, LOUT, LSAVE, LIGN,
2 IDWORK, DWORK, SDWORK,
3 RPAR, IPAR, Z, ZP, RTOL,
4 ATOL, XMOL, KSYM, CCKWRK)
______________________________________…
Three answers:
Jared
2012-01-05 11:51:09 UTC
This is slightly old syntax style for Fortran. I'm going to infer that the code looks something like this:





! Definitions Here



! End Definitions



! APPORTION REAL WORK SPACE



NRPAR = 1

NRDAS = NRPAR + IPTOT

NSDAS = NRDAS + LRDAS

NATOL = NSDAS + LSDAS

NRTOL = NATOL + NEQ

NXMOL = NRTOL + NEQ

NZ = NXMOL + KK

NZP = NZ + NEQ

LRTOT = NZP + NEQ



! APPORTION INTEGER WORK SPACE



NIPAR = 1

NIDAS = NIPAR + LENI + IPICK

LITOT = NIDAS + LIDAS



! APPORTION CHARACTER WORK SPACE



IPCCK = 1

NKSYM = IPCCK + LENC

LCTOT = NKSYM + KK



CALL BEGIN (NSYS, II, KK, LENI, LENR, LENC,

1 LINKCK, LIN, LOUT, LSAVE, LIGN,

2 I(NIDAS), R(NRDAS), R(NSDAS),

3 R(NRPAR), I(NIPAR), R(NZ), R(NZP), R(NRTOL),

4 R(NATOL), R(NXMOL), C(NKSYM), C(IPCCK))



! End Begin.



This is ancient continuation syntax. Also, there must be functions I(), R(), C() or they must be arrays. Since you said it passes arrays, I'll assume that's what they are instead of functions. In this case, it passes only certain portions of an array that are referenced by indices defined above the call statement. This is all I can say really about this. I'm going to say that NSYS,II,KK,LENI,LENR,LENC,LINKCK,LIN,LOUT,LSAVE,LIGN are probably all output values of the subroutine.



That's all that I can really say about this without the entire code. With Fortran, usually you pass the dimensions of the array to make the code as dynamic as possible. But it looks like you might only be passing individual values unless those I,R,C are functions that return arrays. You really need to post the declarations of the code, it would be huge help.
Vincent G
2012-01-05 19:01:39 UTC
Fortran passes arguments by reference, not by value. The last argument in the call statement,

C(IPCCK) corresponds to CCKWRK in the subroutine, I have a hunch that CCKWRK is defined as a scalar value, as opposed to an array. So what happens here is that the C(1) (since IPPCK is set to 1) is being acted on, that is the rest of the array is untouched.

There is value in this form, as it allows a routine expecting a scalar to act on a value currently housed in an array without having to needlessly duplicate it.



You have to remember that a computer memory is just a long string of allocated and usually contiguous memory slots, after compilation, all that remains where all the fancy variable names were encoded are a bunch of memory addresses. Thus, C(IPCCK) will be decoded as the address that is IPCCK-1 offset from where the array C is defined to start. At run time, this will translate to the first entry in array C, owing to the value of IPCCK being set to 1 (but later in the program, it could be set to some other value).



As for the person who questions the pertinence of Fortran in this day and age, perhaps he should get out more often. Fortran is used as much as it ever was, and probably ever will. It is the overall usage of *other* languages that went up, in applications that differ from the traditional realm of Fortran.
2012-01-05 12:44:24 UTC
FORTRAN?? Really?? Who uses that anymore?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...