Skip to content

Commit

Permalink
Merge pull request #13126 from ericvmueller/master
Browse files Browse the repository at this point in the history
Change CATF behavior to insert OTHER_FILES lines at exact location of CATF line. This is done to give control of precedence of overlapping features.
  • Loading branch information
ericvmueller committed Jul 5, 2024
2 parents 3787ea0 + cc58902 commit 5d3fe2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Manuals/FDS_User_Guide/FDS_User_Guide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ \section{Concatenating Input Files}
\begin{lstlisting}
&CATF OTHER_FILES='file_1.txt','file_2.txt' /
\end{lstlisting}
adds the contents of the two listed files into the current input file. Up to 20 files can be listed on one {\ct CATF} line, and multiple {\ct CATF} lines can be included in the input file. After reading the input file, FDS creates a new input file, {\ct CHID\_cat.fds}, and then runs the case.
adds the contents of the two listed files into the current input file. The contents of the other files will be inserted at the location of each respective {\ct CATF} line in the input file. Up to 20 files can be listed on one {\ct CATF} line, and multiple {\ct CATF} lines can be included in the input file. After reading the input file, FDS creates a new input file, {\ct CHID\_cat.fds}, and then runs the case.

When using this feature, limit the number of characters per line in both the original and added input files to 400.

Expand Down
22 changes: 9 additions & 13 deletions Source/read.f90
Original file line number Diff line number Diff line change
Expand Up @@ -330,39 +330,33 @@ SUBROUTINE READ_CATF
ENDIF
ENDIF

! Load CHID file into LU_CATF:

CALL COPY_FILE_TO_CAT(LU_INPUT,LU_CATF,0)

IF (N_MPI_PROCESSES > 1) CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)

! One &CATF line by one add the corresponding OTHER_FILES into LU_CATF:

REWIND(LU_INPUT) ; INPUT_FILE_LINE_NUMBER = 0
TFI=0
COPY_OFILES_LOOP: DO
CALL CHECKREAD('CATF',LU_INPUT,IOS) ; IF (STOP_STATUS==SETUP_STOP) RETURN
IF (IOS==1) EXIT COPY_OFILES_LOOP
COPY_OFILES_LOOP: DO TFI=1,N_CATF_LINES
CALL COPY_FILE_TO_CAT(LU_INPUT,LU_CATF,0)
OTHER_FILES(:) = 'null'
READ(LU_INPUT,NML=CATF,END=13,ERR=14,IOSTAT=IOS)
14 IF (IOS>0) THEN ; CALL SHUTDOWN('ERROR(101): Problem with CATF line.') ; RETURN ; ENDIF
! OPEN and copy other files into LU_CATF:
OFI=0
CPY_LOOP: DO
TFI = TFI + 1
OFI = OFI + 1
IF(TRIM(OTHER_FILES(OFI))=='null') EXIT CPY_LOOP
! If it exists open it and copy its contents without the &HEAD line (if any) up to the first &TAIL /
! appearance or the EOF.
OPEN(LU_CATF2,FILE=TRIM(OTHER_FILES(OFI)),ACTION='READ')
IF (MY_RANK==0) THEN
IF (TFI>1) WRITE(LU_CATF,'(A)')
IF (OFI>1) WRITE(LU_CATF,'(A)')
WRITE(LU_CATF,'(A)')'# Start of file '//TRIM(OTHER_FILES(OFI))//' :'
ENDIF
CALL COPY_FILE_TO_CAT(LU_CATF2,LU_CATF,OFI)
CLOSE(LU_CATF2)
ENDDO CPY_LOOP
ENDDO COPY_OFILES_LOOP
CALL COPY_FILE_TO_CAT(LU_INPUT,LU_CATF,0)
13 REWIND(LU_INPUT) ; INPUT_FILE_LINE_NUMBER = 0

IF (N_MPI_PROCESSES > 1) CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)
Expand Down Expand Up @@ -422,9 +416,11 @@ SUBROUTINE COPY_FILE_TO_CAT(LU_INFILE,LU_OUTFILE,FILENUM)
! Advancing READ:
11 CONTINUE
BACKSPACE(LU_INFILE); READ(LU_INFILE,'(A)') BUFFER2
IF (BUFFER2(1:5)=='&HEAD') CYCLE COPY_IFILE_LOOP
IF (BUFFER2(1:5)=='&CATF') CYCLE COPY_IFILE_LOOP
IF (BUFFER2(1:5)=='&TAIL') EXIT COPY_IFILE_LOOP ! Do not copy the tail line to LU_CATF
IF (BUFFER2(1:6)=='&HEAD ') CYCLE COPY_IFILE_LOOP
IF (BUFFER2(1:6)=='&CATF ') THEN
BACKSPACE(LU_INFILE); EXIT COPY_IFILE_LOOP
ENDIF
IF (BUFFER2(1:6)=='&TAIL ') EXIT COPY_IFILE_LOOP ! Do not copy the tail line to LU_CATF
IF(MY_RANK==0) WRITE(LU_OUTFILE,'(A)') TRIM(BUFFER2)
ENDDO COPY_IFILE_LOOP
10 RETURN
Expand Down

0 comments on commit 5d3fe2b

Please sign in to comment.