Strip comments. Note: line lengths limited to 127 characters
Close files and exit
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | fileold | |||
character(len=*), | intent(in) | :: | filenew |
SUBROUTINE rmcoment(fileold,filenew)
CHARACTER(*), INTENT(IN) :: fileold,filenew
CHARACTER(128) :: line
INTEGER, PARAMETER :: nold=55,nnew=56
INTEGER cmax, ios
LOGICAL :: file_exist
!!-----------------------------------------------------------------------
!! Open files, but make sure the old one exists first.
!!-----------------------------------------------------------------------
INQUIRE(FILE=fileold,EXIST=file_exist)
IF(.NOT. file_exist) THEN
PRINT *,'The file "',fileold,'" could not be found.'
STOP
ENDIF
OPEN(UNIT=default_unit_open,FILE=fileold,status="OLD",form='formatted')
OPEN(UNIT=default_unit_write,FILE=filenew,status='REPLACE')
!!-----------------------------------------------------------------------
!! Strip comments. Note: line lengths limited to 127 characters
!!-----------------------------------------------------------------------
DO
READ(UNIT=default_unit_open,FMT='(a)',IOSTAT=ios) line
IF (ios /= 0) EXIT
cmax=1
DO WHILE(line(cmax:cmax).NE.'!' .AND. cmax .LE. 127)
cmax=cmax+1
ENDDO
IF(cmax .GT. 1) WRITE(default_unit_write,'(a)') line(1:cmax-1)
ENDDO
!!-----------------------------------------------------------------------
!! Close files and exit
!!-----------------------------------------------------------------------
CLOSE(default_unit_open)
CLOSE(default_unit_write)
END SUBROUTINE rmcoment