fortran 在学习基本的I/O概念中遇到的问题a

代码执行不了

    IMPLICIT NONE
    REAL,PARAMETER :: ELECTRONS_PER_COULOMB = 6.241461E18
    REAL :: c
    REAL :: charge
    REAL :: electrons 
    REAL :: energy
    REAL :: type   !为计算提供输入的数据的类型1:c和v,2:v和charge
    REAL :: v
    WRITE(*,100)
100 FORMAT('This program calculates information about a capacitor.',/,
    'Please specify the type of information available from the following list :',/,
    '1 --capacitance and voltage',/,
    '2 --charge and voltage',//,
    'Select options 1 or 2:')
    DO
        READ(*,*)type
        If((type == 1 ).OR.(type == 2))EXIT
        WRITE(*,110)type
110 FORMAT('Invalid response:',I6,'. Please enter 1 or 2 :')
    END DO
    input:IF(type == 1)THEN
        WRITE(*,'Enter capacitance in farads:')
        READ(*,*)c
        WRITE(*,'Enter voltage in volts:')
        READ(*,*)v
    ELSE
        WRITE(*,'Enter charge in coulombs:')
        READ(*,*)charge
        WRITE(*,'Enter voltage in voltes:')
        READ(*,*)v
    END IF input
    calculate:IF(type == 1)THEN
        charge = c * v
    ELSE
        c = charge / v
    END IF calculate
    electrons = charge * ELECTRONS_PER_COULOMB
    energy = 0.5 * c * v**2
    WRITE(*,120)v,c,charge,electrons,energy
120 FORMAT('For this capacitor:',/,
    'voltage = ',F10.2,'V',/,
    'capacitance = ',ES10.3,'F',/,
    'Total charge = ',ES10.3,'C',/,
   'Number of electrons = ',ES10.3,/,
   'Total energy = ',F10.4,'joules')
   END PROGRAM main



img


  program main
  IMPLICIT NONE
  REAL,PARAMETER :: ELECTRONS_PER_COULOMB = 6.241461E18
  REAL :: c
  REAL :: charge
  REAL :: electrons
  REAL :: energy
  REAL :: type   !为计算提供输入的数据的类型1:c和v,2:v和charge
  REAL :: v
  WRITE(*,100)
100 FORMAT('This program calculates information about a capacitor.',/, &
    'Please specify the type of information available from the following list :',/, &
    '1 --capacitance and voltage',/, &
    '2 --charge and voltage',//, &
    'Select options 1 or 2:')
  DO
    READ(*,*)type
    If((type == 1 ).OR.(type == 2))EXIT
    WRITE(*,110)type
110 FORMAT('Invalid response:',I6,'. Please enter 1 or 2 :')
  END DO
  input:IF(type == 1)THEN
    WRITE(*,'("Enter capacitance in farads:")')
    READ(*,*)c
    WRITE(*,'("Enter voltage in volts:")')
    READ(*,*)v
  ELSE
    WRITE(*,'("Enter charge in coulombs:")')
    READ(*,*)charge
    WRITE(*,'("Enter voltage in voltes:")')
    READ(*,*)v
  END IF input
  calculate:IF(type == 1)THEN
    charge = c * v
  ELSE
    c = charge / v
  END IF calculate
  electrons = charge * ELECTRONS_PER_COULOMB
  energy = 0.5 * c * v**2
  WRITE(*,120)v,c,charge,electrons,energy
120 FORMAT('For this capacitor:',/, &
    'voltage = ',F10.2,'V',/, &
    'capacitance = ',ES10.3,'F',/, &
    'Total charge = ',ES10.3,'C',/, &
    'Number of electrons = ',ES10.3,/, &
    'Total energy = ',F10.4,'joules')
  END PROGRAM main

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^