From 478c899c3f4154983630975890a82d2e138eb180 Mon Sep 17 00:00:00 2001 From: Jonathan Hodges Date: Sat, 20 Jan 2024 01:51:09 -0500 Subject: [PATCH] move when trailing slash is added to RESULT_DIR --- Source/dump.f90 | 44 +++++++++++++++++++++++++++++++++++++++----- Source/main.f90 | 33 --------------------------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/Source/dump.f90 b/Source/dump.f90 index dd0d7d5b96c..488885cd03c 100644 --- a/Source/dump.f90 +++ b/Source/dump.f90 @@ -19,6 +19,7 @@ MODULE DUMP CC_VGSC,CC_GASPHASE,MAKE_UNIQUE_VERT_ARRAY,AVERAGE_FACE_VALUES USE CC_SCALARS, ONLY : ADD_Q_DOT_CUTCELLS,GET_PRES_CFACE,GET_PRES_CFACE_TEST,GET_UVWGAS_CFACE,GET_MUDNS_CFACE +USE COMP_FUNCTIONS, ONLY : SHUTDOWN IMPLICIT NONE (TYPE,EXTERNAL) PRIVATE @@ -221,6 +222,39 @@ SUBROUTINE ASSIGN_FILE_NAMES ALLOCATE(FILE_COUNTER(0:N_MPI_PROCESSES)) FILE_COUNTER = 10 +! Check for custom directory for output +IF (RESULT_DIR/='') THEN + DO I=1,FILE_LENGTH + IF (RESULT_DIR(FILE_LENGTH-I:FILE_LENGTH-I)/='') THEN + IF (RESULT_DIR(FILE_LENGTH-I:FILE_LENGTH-I)=='/') THEN + EXIT + ELSE + RESULT_DIR(FILE_LENGTH-I+1:FILE_LENGTH-I+1)='/' + EXIT + ENDIF + ENDIF + ENDDO +! Try to make results directory on all ranks in case one that is not 0 +! This prevents subsequent failure of the software in writing to a non-existent +! directory later on if rank 0 is running too slow. +! As an alternative we could add an mpi wait here on other processes. +#ifdef _WIN32 + CALL EXECUTE_COMMAND_LINE('mkdir '//'"'//TRIM(RESULT_DIR)//'"') +#else + CALL EXECUTE_COMMAND_LINE('mkdir -p '//TRIM(RESULT_DIR)) +#endif + IF (MY_RANK==0) THEN + LU_RDIR=GET_FILE_NUMBER() + OPEN(LU_RDIR,FILE=TRIM(RESULT_DIR)//'/.ignore',FORM='FORMATTED',STATUS='REPLACE') + WRITE(LU_RDIR, '(A)') TRIM(RESULT_DIR) + CLOSE(LU_RDIR) + INQUIRE(FILE=TRIM(RESULT_DIR)//'/.ignore',EXIST=EX) + IF (.NOT.EX) THEN + CALL SHUTDOWN('FAILED TO CREATE DIRECTORY: '//TRIM(RESULT_DIR)) + ENDIF + ENDIF +ENDIF + ! GIT ID file FN_GIT = TRIM(CHID)//'_git.txt' @@ -410,11 +444,11 @@ SUBROUTINE ASSIGN_FILE_NAMES LU_SLCF_GEOM(N,NM) = GET_FILE_NUMBER() LU_SLCF(N+N_SLCF_MAX,NM) = GET_FILE_NUMBER() ! bounds for slice file LU_SLCF(N+2*N_SLCF_MAX,NM) = GET_FILE_NUMBER() ! run length encoded slice file - CFORM = '(A,A,I0,A,I0,A)' - WRITE(FN_SLCF(N,NM),CFORM) TRIM(RESULT_DIR)//TRIM(CHID),'_',NM,'_',N,'.sf' - WRITE(FN_SLCF_GEOM(N,NM),CFORM) TRIM(RESULT_DIR)//TRIM(CHID),'_',NM,'_',N,'.gsf' - WRITE(FN_SLCF(N+N_SLCF_MAX,NM),CFORM) TRIM(RESULT_DIR)//TRIM(CHID),'_',NM,'_',N,'.sf.bnd' - WRITE(FN_SLCF(N+2*N_SLCF_MAX,NM),CFORM) TRIM(RESULT_DIR)//TRIM(CHID),'_',NM,'_',N,'.sf.rle' + CFORM = '(A,A,A,I0,A,I0,A)' + WRITE(FN_SLCF(N,NM),CFORM) TRIM(RESULT_DIR),TRIM(CHID),'_',NM,'_',N,'.sf' + WRITE(FN_SLCF_GEOM(N,NM),CFORM) TRIM(RESULT_DIR),TRIM(CHID),'_',NM,'_',N,'.gsf' + WRITE(FN_SLCF(N+N_SLCF_MAX,NM),CFORM) TRIM(RESULT_DIR),TRIM(CHID),'_',NM,'_',N,'.sf.bnd' + WRITE(FN_SLCF(N+2*N_SLCF_MAX,NM),CFORM) TRIM(RESULT_DIR),TRIM(CHID),'_',NM,'_',N,'.sf.rle' ENDDO ! Radiation Files diff --git a/Source/main.f90 b/Source/main.f90 index 0805c1e2d8f..26807220404 100644 --- a/Source/main.f90 +++ b/Source/main.f90 @@ -417,39 +417,6 @@ PROGRAM FDS CALL INITIALIZE_OUTPUT_CLOCKS(T) -! Check for custom directory for output -IF (RESULT_DIR/='') THEN - DO I=1,FILE_LENGTH - IF (RESULT_DIR(FILE_LENGTH-I:FILE_LENGTH-I)/='') THEN - IF (RESULT_DIR(FILE_LENGTH-I:FILE_LENGTH-I)=='/') THEN - EXIT - ELSE - RESULT_DIR(FILE_LENGTH-I+1:FILE_LENGTH-I+1)='/' - EXIT - ENDIF - ENDIF - ENDDO -! Try to make results directory on all ranks in case one that is not 0 -! This prevents subsequent failure of the software in writing to a non-existent -! directory later on if rank 0 is running too slow. -! As an alternative we could add an mpi wait here on other processes. -#ifdef _WIN32 - CALL EXECUTE_COMMAND_LINE('mkdir '//'"'//TRIM(RESULT_DIR)//'"') -#else - CALL EXECUTE_COMMAND_LINE('mkdir -p '//TRIM(RESULT_DIR)) -#endif - IF (MY_RANK==0) THEN - LU_RDIR=GET_FILE_NUMBER() - OPEN(LU_RDIR,FILE=TRIM(RESULT_DIR)//'/.ignore',FORM='FORMATTED',STATUS='REPLACE') - WRITE(LU_RDIR, '(A)') TRIM(RESULT_DIR) - CLOSE(LU_RDIR) - INQUIRE(FILE=TRIM(RESULT_DIR)//'/.ignore',EXIST=EX) - IF (.NOT.EX) THEN - CALL SHUTDOWN('FAILED TO CREATE DIRECTORY: '//TRIM(RESULT_DIR)) - ENDIF - ENDIF -ENDIF - ! Initialize output files that are mesh-specific DO NM=LOWER_MESH_INDEX,UPPER_MESH_INDEX