如何指定此COMMON语句中的类型?

时间:2014-01-16 22:36:42

标签: fortran gfortran fortran77

我有一个旧的fortran代码,我试图破译并了解发生了什么,所以我可以修改它。不幸的是,我在fortran中有点新手,所以我很难搞清楚这句话。

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

如果这有助于调用该函数的方式。

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

我已经理解了行继续,对于行CALC-099到CALC-105,第一个非空白数字只是计算延续,因为编译器跳转到第7列继续。

我不明白的是如何决定类型。它是在第一次分配时自动确定的,我对常见块的工作方式的理解使这看起来不太可能。它是命名中的东西,是第一个以某种方式决定它的角色吗?

此外,维度声明在这里做什么?如果数组长度为600,000,为什么维度语句将其长度“设置”为1,或者它是否正在执行我未看到的内容?

2 个答案:

答案 0 :(得分:2)

你问题的两个部分都让现代人感到恐惧。

首先,隐式输入。变量,除非它们具有显式类型,否则采用隐式类型。以I开头的变量 - NINTEGER,其他为REAL。然而,IMPLICIT语句会覆盖这一点,所以要注意这一点(永远不要低估程序员可以做些什么)。另请注意,IMPLICIT NONE是标准的后续添加内容。

其次,在子程序中DIMENSION(1)(或等效物)是DIMENSION(*)的替代品。

答案 1 :(得分:2)

FORTRAN77中的默认输入是

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

这意味着以字母ij,...,n开头的变量为INTEGER,其余为REAL

Reference URL