我正在尝试比较月份数组以检查每个数字是奇数月还是偶数月,以便我可以将文件标记为月//日期//year.txt 并将与其他文件中的日期匹配的行上传到相应的 .txt 文件。
我的输出应该是 90 个 .txt 文件,每个文件都包含与 APM_FORMATTED.txt 中的特定日期匹配的行。
PROGRAM APM_TEST
IMPLICIT NONE
INTEGER :: READSTATUS, YEAR_MIN, MONTH_MIN, DAY_MIN, YEAR_MAX, MONTH_MAX, DAY_MAX, I, IND, IND1, D, D1, D2
CHARACTER(13) :: DATE_INPUT
CHARACTER(2) :: FILE_DAY, FILE_MONTH, FILE_YEAR, CURRENT_DAY, CURRENT_MONTH
CHARACTER(632) :: ROW1
INTEGER, DIMENSION(1,6) :: M
INTEGER, DIMENSION(1,6) :: N
INTEGER, DIMENSION(1,3) :: MON
WRITE(*,'(" ENTER DATE RANGE OF FILE (E.G. 010413-010713):")', ADVANCE = "NO")
READINT : DO
READ (*,*,IOSTAT=READSTATUS) DATE_INPUT
IF (READSTATUS==0) THEN
EXIT READINT
ELSE
WRITE(*,'(/"READ ERROR. PLEASE RE-INPUT:")')
ENDIF
ENDDO READINT
READ(DATE_INPUT(5:6), '(I2)') YEAR_MIN
READ(DATE_INPUT(3:4), '(I2)') MONTH_MIN
READ(DATE_INPUT(1:2), '(I2)') DAY_MIN
READ(DATE_INPUT(12:13), '(I2)') YEAR_MAX
READ(DATE_INPUT(10:11), '(I2)') MONTH_MAX
READ(DATE_INPUT(8:9), '(I2)') DAY_MAX
IND=1
IND1=1
M=(/1,3,5,7,9,11/)
N=(/4,6,8,10,12/)
36 DO MON=MONTH_MIN, MONTH_MAX
IF (ANY(M.EQ.MON(IND))) THEN
DO D=DAY_MIN,31
FILE_DAY=DATE_INPUT(1:2)
FILE_MONTH=DATE_INPUT(3:4)
FILE_YEAR=DATE_INPUT(5:6)
OPEN(UNIT=201, FILE="APM_FORMATTED.TXT")
OPEN(IND1, FILE=(FILE_MONTH//FILE_DAY//FILE_YEAR//".TXT"), ACTION="WRITE", STATUS="NEW")
45 DO I=1,200000
READ(201,'(A632)') ROW1
IF (ROW1(1:3).EQ.'APM') THEN
READ(ROW1(41:42), '(I2)') CURRENT_DAY
READ(ROW1(43:44), '(I2)') CURRENT_MONTH
IF (CURRENT_MONTH.EQ.MON .AND. CURRENT_DAY.EQ.D) THEN
WRITE(IND1,*) ROW1
ELSE
GOTO 45
ENDIF
ELSE
ENDIF
ENDDO
IND1=IND1+1
CLOSE(IND1)
CLOSE(201)
ENDDO
ELSEIF (ANY(N.EQ.MON)) THEN
DO D1=DAY_MIN,30
FILE_DAY=DATE_INPUT(1:2)
FILE_MONTH=DATE_INPUT(3:4)
FILE_YEAR=DATE_INPUT(5:6)
OPEN(UNIT=201, FILE="APM_FORMATTED.TXT")
OPEN(IND1, FILE=(FILE_MONTH//FILE_DAY//FILE_YEAR//".TXT"), ACTION="WRITE", STATUS="NEW")
73 DO I=1,200000
READ(201,'(A632)') ROW1
IF (ROW1(1:3).EQ.'APM') THEN
READ(ROW1(41:42), '(I2)') CURRENT_DAY
READ(ROW1(43:44), '(I2)') CURRENT_MONTH
IF (CURRENT_MONTH.EQ.MON .AND. CURRENT_DAY.EQ.D1) THEN
WRITE(IND1,*) ROW1
ELSE
GOTO 73
ENDIF
ELSE
ENDIF
ENDDO
IND1=IND1+1
CLOSE(IND1)
CLOSE(201)
ENDDO
ELSEIF (ANY(M.EQ.4)) THEN
DO D2=DAY_MIN,28
FILE_DAY=DATE_INPUT(1:2)
FILE_MONTH=DATE_INPUT(3:4)
FILE_YEAR=DATE_INPUT(5:6)
OPEN(UNIT=201, FILE="APM_FORMATTED.TXT")
OPEN(IND1, FILE=(FILE_MONTH//FILE_DAY//FILE_YEAR//".TXT"), ACTION="WRITE", STATUS="NEW")
101 DO I=1,200000
READ(201,'(A632)') ROW1
IF (ROW1(1:3).EQ.'APM') THEN
READ(ROW1(41:42), '(I2)') CURRENT_DAY
READ(ROW1(43:44), '(I2)') CURRENT_MONTH
IF (CURRENT_MONTH.EQ.MON .AND. CURRENT_DAY.EQ.D2) THEN
WRITE(IND1,*) ROW1
ELSE
GOTO 101
ENDIF
ELSE
ENDIF
ENDDO
IND1=IND1+1
CLOSE(IND1)
CLOSE(201)
ENDDO
ELSE
GOTO 36
ENDIF
IND=IND+1
DAY_MIN=1
ENDDO
END PROGRAM APM_TEST
Errors:
error FOR2614: assignment between arrays of differing rank
error FOR2614: assignment between arrays of differing rank
error FOR2799: DO control variable MON is not scalar
error FOR2979: expected 2 subscripts but found 1 for array MON
error FOR3041: operands to relational operator .EQ. are of incompatible data type
error FOR3041: operands to relational operator .EQ. are of incompatible data type
error FOR3048: illegal data type to binary logical operator .AND.
error FOR3156: array shapes differ in dimension 2 (extent 6 and 3)
error FOR3041: operands to relational operator .EQ. are of incompatible data type
error FOR3041: operands to relational operator .EQ. are of incompatible data type
error FOR3048: illegal data type to binary logical operator .AND.
error FOR3041: operands to relational operator .EQ. are of incompatible data type
error FOR3041: operands to relational operator .EQ. are of incompatible data type
error FOR3048: illegal data type to binary logical operator .AND.