Hello guys,
I would like to check if a file exists, if it is the right calculation case. If it does not exist, it is created und results are stored in there. This didnt work correctly, at least not when the file already exists. Here is the code, I hope someone can help me:
fexist = .FALSE.
fright = .FALSE.
fscat = .TRUE.
IF (fscat) THEN
INQUIRE (FILE = 'mie_scat_int.asc', EXIST=fexist)
IF (fexist) THEN
WRITE(*,*) 'mie_scat_int.asc already exists'
OPEN(20, FILE = 'mie_scat_int.asc', STATUS = 'UNKNOWN')
READ (20,*) dummy1
READ (20,*) dummy2
READ (20,*) dummy3
CLOSE (UNIT=20)
IF ((dummy1==alfamax).AND.(dummy2==alfares).AND.(dummy3==nn)) THEN
fright = .TRUE.
WRITE(*,*) 'mie file fits the present analysis'
ELSE
fright = .FALSE.
END IF
ENDIF
IF (fexist.AND.fright) THEN
WRITE (*,*) 'mie_scat_int.asc is read'
OPEN(20, FILE = 'mie_scat_int.asc', STATUS = 'UNKNOWN')
READ (20,*) dummy1
READ (20,*) dummy2
READ (20,*) dummy3
DO jj = 1,alfares
DO ii = 1,nn
READ (20,*) alfa(ii,jj), theta(ii), i1(ii,jj)
END DO
END DO
CLOSE (UNIT=20)
ELSE
WRITE (*,*) 'mie_scat_int.asc is created'
OPEN(20, FILE = 'mie_scat_int.asc', STATUS = 'UNKNOWN')
WRITE (20,*) alfamax
WRITE (20,*) alfares
WRITE (20,*) nn
DO ii = 1, nn
theta(ii) = (ii-1)*dang
END DO