How are the types in this COMMON statement specified?

孤者浪人 提交于 2019-12-25 11:01:36

问题


I have an old fortran code that I am attempting to decipher and understand what is going on so I can modify it. Unfortunately I am a bit of a neophyte in fortran so I am having trouble figuring out this statement.

C 15/04/97  IBM VERSION                                         ECIS96  CALC-000
      SUBROUTINE CALC(W,NW,DW,IDMX)                                     CALC-001
C MAIN SUBROUTINE OF THE PROGRAMME                                      CALC-002
C W,NW,DW ARE THE WORKING SPACE IN EQUIVALENCE BY CALL,STARTING AS      CALC-003
C REAL*8. THEY ARE RESPECTIVELY REAL, INTEGER AND DOUBLE PRECISION.     CALC-004
C IDMX IS THE LENGTH OF DW.                                             CALC-005
C                                                                       CALC-006
C ADDRESSES IN THE WORKING FIELD DEFINED HERE (FOR OTHERS, SEE CALX)    CALC-007
C IN COMMON /DECOU/                                                     CALC-008
C 34- NT       HERE, ALSO REDUCED NUCLEAR MATRIX ELEMENTS               CALC-009
C 35- NIVQ     TABLE OF MULTIPOLES                                      CALC-010
C 36- NIVY     TABLE OF FORM FACTOR IDENTIFICATION IVY (FOR COMPUTATION)CALC-011
C 37- NIVZ     TABLE OF FORM FACTOR IDENTIFICATION IVZ (FOR USE)        CALC-012
C 38- NCOI     ADDRESS OF THE TABLE FOR DISCRETISATION OF CONTINUUM     CALC-013
C 39- MIPI     SAME AS NIPI FOR THE DISCRETISATION OF CONTINUUM         CALC-014
C 40- NXD      ADDRESS OF WEIGHTS AND STEPS OF CONTINUUM                CALC-015
C 41- MWV      SAME AS NWV FOR THE DISCRETISATION OF CONTINUUM          CALC-016
C 42- NIXT     TRANSMISSION COEFFICIENTS OF UNCOUPLED STATES            CALC-017
C 43- NTY      TEMPORARY RESULTS OF COMPOUND NUCLEUS FOR INTERPOLATION  CALC-018
C 44- NTX      PARTIAL REACTION CROSS SECTIONS AND COMPOUND NUCLEUS     CALC-019
C 45- NRY      COMPOUND NUCLEUS COEFFICIENTS                            CALC-020
C 46- NRCO     STRENGTH OF COULOMB CENTRAL POTENTIALS FOR CORRECTIONS   CALC-021
C 47- NRDO     STRENGTH OF COULOMB TRANSITION POTENTIALS FOR CORRECTIONSCALC-022
C 48- NVC1     REAL POTENTIALS                                          CALC-023
C 49- NVC2     IMAGINARY POTENTIALS                                     CALC-024
C 50- NNC      FIRST FREE ADDRESS AFTER COMPUTATION OF POTENTIALS       CALC-025
C 51- NCX      FIRST FREE ADDRESS FOR COMPUTATION OF POTENTIALS         CALC-026
C OTHER INTEGER DATA OF COMMON /DECOU/                                  CALC-027
C 52- IDMT     TOTAL WORKING FIELD LENGTH AS SINGLE PRECISION           CALC-028
C 53-98          SEE CALX                                               CALC-029
C 99- KXT      NUMBER OF PENETRABILITIES FOR UNCOUPLED STATES           CALC-030
C100- NRZ      NUMBER OF RESULTS TO SAVE FOR MINIMUM CHI2               CALC-031
C101- NTZ      NUMBER OF MEMRIES TO INITIALISE TO ZERO FOR SCATTERING   CALC-032
C              MATRIX AND COMPOUND NUCLEUS RESULTS                      CALC-033
C102- LMAX3    EFFECTIVE NUMBER OF COULOMB FUNCTIONS                    CALC-034
C103- IPM      NUMBER PF J VALUES USED FOR SCATTERING MATRIX (IN CAL1)  CALC-035
C104- IPK      NUMBER PF J VALUES USED FOR COMPOUND NUCLEUS (IN CAL1)   CALC-036
C105-110         SEE CALX                                               CALC-037
C                                                                       CALC-038
C IN COMMON /DBLPR/  CHI2,CHI2M:    CHI-SQUARE AND MINIMUM CHI-SQUARE   CALC-039
C                    CM,CHB:        NUCLEAR MASS AND H BAR              CALC-040
C                    CK,CMB,CCZ:    DERIVED CONSTANTS                   CALC-041
C                    XE,XM,XN:      RELATIVISTIC ENERGY AND MASS (COLF) CALC-042
C                    XZ:            CONVERSION FACTOR TO MILLIBARNS     CALC-043
C FOR COMMONS /POTE1/ AND /POTE2/ SEE REDM                              CALC-044
C FOR COMMON /NCOMP/ SEE CALX, LECT AND COLF                            CALC-045
C                                                                       CALC-046
C*some information on logical variables that is unimportant to this*
      DOUBLE PRECISION CHI2,CHI2M,CM,CK,CHB,CMB,CZ,CCZ,XE,XM,XN,XZ,DW(1)CALC-095
      LOGICAL LO(250)                                                   CALC-096
      DIMENSION W(1),NW(1)                                              CALC-097
      COMMON /DECOU/ NJIT,NIPP,NIPI,NWV,NIPH,NSCN,NPAR,NNIV,NFIS,NGAM,NPCALC-098
     1OT,NBETA,NFM,NTGX,NDONN,NRC,NIW,NDE,NISE,NNVI,NNWI,NCC,MCC,NXA,NAMCALC-099
     21,NFAC,NFAM,NPAD,NFG,NXG,NSM,NRES,NXX,NT,NIVQ,NIVY,NIVZ,NCOI,MIPI,CALC-100
     3NXD,MWV,NIXT,NTY,NTX,NRY,NRCO,NRDO,NVC1,NVC2,NNC,NCX,IDMT,NCOLL,NJCALC-101
     4MAX,ITERM,NPP,JDM,JIT,NSEC,LMD,MCM(2),NCOLS,NCOLT,KMAX,KMIN,NVA,NBCALC-102
     5ET,NBT1,LMX,LMAX1,NLT,ISM,IQM,IQMAX,MS1,MS2,NCT(6),KBA,KAB,KBC,KCCCALC-103
     6,NJC,JTX,JTH,NCOLR,NREC,NTOT,NFA,LMAX2,KE,ITEMM,NPLACE,KXT,NRZ,NTZCALC-104
     7,LMAX3,IPM,IPK,H,BJM,EITER,ACONV,CONJ,ASPIN                       CALC-105
      COMMON /DBLPR/ CHI2,CHI2M,CM,CK,CHB,CMB,CCZ,XE,XM,XN,XZ           CALC-106
      COMMON /POTE1/ ITX(16),IMAX,INTC,INLS,INVC,INVD,ITXM              CALC-107
      COMMON /POTE2/ ITY(8),INVT,INTV,INSL,NPX                          CALC-108
      COMMON /NCOMP/ NSP(3),NFISS,NRD,NCONT,NCOJ,ACN1,ACN2,NCONS,NIE,NCOCALC-109
     1LX,NDP,NDQ,AZ(6),BZ1,BZ2,BZ3,TG0,BN,FNUG,EGD,GGD,TG1,SGSQ         CALC-110

If it helps this is how the function is called.

C 18/12/87  IBM VERSION CONVEX                                  ECIS88  ECIS-000
      REAL*8 W(600000)                                                  ECIS-001
      COMMON W                                                          ECIS-002
      CALL CALC(W,W,W,600000)                                           ECIS-003
      STOP                                                              ECIS-004
      END                                                               ECIS-005

I already understand the line continuations and that for lines CALC-099 through CALC-105 the first non-whitespace numbers are just counting the continuations since the compiler is jumping to column 7 for the continuation.

What I do not understand is how the types are decided. Is it something automatically determined on first assignment, my understanding of how common blocks work makes this seem unlikely. Is it something in the naming, is the first character somehow determining it?

Also, what are the dimension statements doing here? If the array is 600,000 long why is the dimension statement "setting" its length to 1, or is it doing something I am not seeing?


回答1:


Both parts of your question are something that horrifies modern people.

First, implicit typing. Variables, unless they have an explicit type, take an implicit type. Variables beginning I-Nare INTEGER and others are REAL. The IMPLICIT statement overrides this, however, so look out for that (never underestimate what evils programmers can do). Also, note that IMPLICIT NONE is a later addition to the standard.

Second, in subroutines DIMENSION(1) (or equivalent) was an alternative to DIMENSION(*).




回答2:


The default typing in FORTRAN77 is

IMPLICIT REAL(A-H, O-Z), INTEGER(I-N)

Which means variables that start with letters i,j,..,n are INTEGER and the rest are REAL.

Reference URL



来源:https://stackoverflow.com/questions/21174355/how-are-the-types-in-this-common-statement-specified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!