diff --git a/Source/cons.f90 b/Source/cons.f90 index de61b6d5902..4fa8f09010e 100644 --- a/Source/cons.f90 +++ b/Source/cons.f90 @@ -773,7 +773,8 @@ MODULE OUTPUT_CLOCKS INTEGER :: RAMP_SL3D_INDEX=0 !< Ramp index for 3D slice file time series INTEGER :: RAMP_SM3D_INDEX=0 !< Ramp index for smoke3d file time series INTEGER :: RAMP_SPEC_INDEX=0 !< Ramp index for species file time series -INTEGER :: RAMP_TIME_INDEX=0 !< Ramp index for specied simulation time steps +INTEGER :: RAMP_TIME_INDEX=0 !< Ramp index for specified simulation time steps +INTEGER :: RAMP_DT_INDEX=0 !< Ramp index for specified minimum simulation time step INTEGER :: RAMP_TMP_INDEX =0 !< Ramp index for temperature file time series INTEGER :: RAMP_UVW_INDEX =0 !< Ramp index for velocity file time series REAL(EB), ALLOCATABLE, DIMENSION(:) :: BNDF_CLOCK, CPU_CLOCK,CTRL_CLOCK,DEVC_CLOCK,FLSH_CLOCK,GEOM_CLOCK, HRR_CLOCK,HVAC_CLOCK,& diff --git a/Source/dump.f90 b/Source/dump.f90 index f3159c2db81..9c9ed1e32a4 100644 --- a/Source/dump.f90 +++ b/Source/dump.f90 @@ -793,7 +793,7 @@ SUBROUTINE INITIALIZE_GLOBAL_DUMPS(T,DT) ENDDO ENDIF -IF (APPEND) THEN +IF (.NOT. APPEND) THEN OPEN(LU_HRR,FILE=FN_HRR,FORM='FORMATTED',STATUS='OLD') CALL APPEND_FILE(LU_HRR,2,T_BEGIN+(T-T_BEGIN)*TIME_SHRINK_FACTOR) ELSE @@ -1023,12 +1023,7 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) DO N=1,N_ISOF IS => ISOSURFACE_FILE(N) - IF (APPEND) THEN - OPEN(ABS(LU_ISOF(N,NM)),FILE=FN_ISOF(N,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') - IF(IS%INDEX2 /= -1 ) THEN - OPEN(ABS(LU_ISOF2(N,NM)),FILE=FN_ISOF2(N,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') - ENDIF - ELSE + IF (.NOT. APPEND) THEN OPEN(ABS(LU_ISOF(N,NM)),FILE=FN_ISOF(N,NM),FORM='UNFORMATTED',STATUS='REPLACE') IF (IS%INDEX2 /= -1 ) THEN OPEN(ABS(LU_ISOF2(N,NM)),FILE=FN_ISOF2(N,NM),FORM='UNFORMATTED',STATUS='REPLACE') @@ -1069,24 +1064,19 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) DO N=1,N_SMOKE3D IF (SMOKE3D_FILE(N)%QUANTITY_INDEX==0) CYCLE - IF (APPEND) THEN - OPEN(LU_SMOKE3D(N,NM), FILE=FN_SMOKE3D(N,NM), FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') - OPEN(LU_SMOKE3D(N+N_SMOKE3D,NM), FILE=FN_SMOKE3D(N+N_SMOKE3D,NM), FORM='FORMATTED', STATUS='OLD',POSITION='APPEND') - IF (SMOKE3D_16) THEN - OPEN(LU_SMOKE3D(N+2*N_SMOKE3D,NM),FILE=FN_SMOKE3D(N+2*N_SMOKE3D,NM),FORM='UNFORMATTED', STATUS='OLD',POSITION='APPEND') - ENDIF - ELSE + IF (.NOT. APPEND) THEN OPEN(LU_SMOKE3D(N,NM), FILE=FN_SMOKE3D(N,NM), FORM='UNFORMATTED',STATUS='REPLACE') WRITE(LU_SMOKE3D(N,NM)) INTEGER_ONE,INTEGER_ZERO,0,M%IBAR,0,M%JBAR,0,M%KBAR - + CLOSE(LU_SMOKE3D(N,NM)) OPEN(LU_SMOKE3D(N+N_SMOKE3D,NM),FILE=FN_SMOKE3D(N+N_SMOKE3D,NM),FORM='FORMATTED',STATUS='REPLACE') WRITE(LU_SMOKE3D(N+N_SMOKE3D,NM),*) INTEGER_ZERO - + CLOSE(LU_SMOKE3D(N+N_SMOKE3D,NM)) IF (SMOKE3D_16) THEN SMOKE3D_16_COMPRESS = 0 SMOKE3D_16_VERSION = 1 OPEN(LU_SMOKE3D(N+2*N_SMOKE3D,NM), FILE=FN_SMOKE3D(N+2*N_SMOKE3D,NM),FORM='UNFORMATTED',STATUS='REPLACE') WRITE(LU_SMOKE3D(N+2*N_SMOKE3D,NM)) INTEGER_ONE,SMOKE3D_16_VERSION,SMOKE3D_16_COMPRESS,M%IBP1,M%JBP1,M%KBP1 + CLOSE(LU_SMOKE3D(N+2*N_SMOKE3D,NM)) ENDIF IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM) M%N_STRINGS = M%N_STRINGS + 1 @@ -1314,9 +1304,7 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) BF => BOUNDARY_FILE(NF) - RESTART: IF (APPEND) THEN - OPEN(LU_BNDF(NF,NM),FILE=FN_BNDF(NF,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') - ELSE RESTART + IF (.NOT. APPEND) THEN IF (M%N_STRINGS+5>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM) M%N_STRINGS = M%N_STRINGS + 1 IF (BF%CELL_CENTERED) THEN @@ -1341,7 +1329,8 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) PA=>M%PATCH(IP) WRITE(LU_BNDF(NF,NM)) PA%I1,PA%I2,PA%J1,PA%J2,PA%K1,PA%K2,PA%IOR,PA%OBST_INDEX,NM ENDDO - ENDIF RESTART + CLOSE(LU_BNDF(NF,NM)) + ENDIF ENDDO BOUNDARY_FILES @@ -1349,12 +1338,7 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) PARTICLE_IF: IF (PARTICLE_FILE) THEN - APPEND_PARTICLE_FILE: IF (APPEND) THEN - - OPEN(LU_PART(NM),FILE=FN_PART(NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') - OPEN(LU_PART(NM+NMESHES),FILE=FN_PART(NM+NMESHES),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND') - - ELSE APPEND_PARTICLE_FILE + IF (.NOT. APPEND) THEN IF (M%N_STRINGS+10*N_LAGRANGIAN_CLASSES>M%N_STRINGS_MAX) CALL RE_ALLOCATE_STRINGS(NM) N = M%N_STRINGS_MAX/MAX(1,N_LAGRANGIAN_CLASSES) @@ -1384,8 +1368,10 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) WRITE(LU_PART(NM)) OUTPUT_QUANTITY(LPC%QUANTITIES_INDEX(NN))%UNITS(1:30) ENDDO ENDDO + CLOSE(LU_PART(NM)) + CLOSE(LU_PART(NM+NMESHES)) - ENDIF APPEND_PARTICLE_FILE + ENDIF ENDIF PARTICLE_IF ! Initialize radiation file (RADF) @@ -1418,8 +1404,7 @@ SUBROUTINE INITIALIZE_MESH_DUMPS(NM) NRM = NORM2([DLX(NN),DLY(NN),DLZ(NN)]) WRITE(LU_RADF(N,NM),'(3F7.3)') DLX(NN)/NRM,DLY(NN)/NRM,DLZ(NN)/NRM ENDDO - ELSE - OPEN(LU_RADF(N,NM),FILE=FN_RADF(N,NM),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND') + CLOSE(LU_RADF(N,NM)) ENDIF ENDDO @@ -3871,6 +3856,9 @@ SUBROUTINE DUMP_PART(T,NM) STIME = T_BEGIN + (T-T_BEGIN)*TIME_SHRINK_FACTOR +OPEN(LU_PART(NM),FILE=FN_PART(NM),FORM='UNFORMATTED',STATUS='REPLACE') +OPEN(LU_PART(NM+NMESHES),FILE=FN_PART(NM+NMESHES),FORM='FORMATTED',STATUS='REPLACE') + WRITE(LU_PART(NM)) REAL(STIME,FB) WRITE(LU_PART(NM+NMESHES),'(ES13.6,1X,I4,1X,I4)')STIME, N_LAGRANGIAN_CLASSES, PART_BOUNDFILE_VERSION @@ -3958,6 +3946,9 @@ SUBROUTINE DUMP_PART(T,NM) ENDDO LAGRANGIAN_PARTICLE_CLASS_LOOP +CLOSE(LU_PART(NM)) +CLOSE(LU_PART(NM+NMESHES)) + END SUBROUTINE DUMP_PART @@ -10244,6 +10235,7 @@ SUBROUTINE DUMP_BNDF(T,DT,NM) PY => PROPERTY(BF%PROP_INDEX) BOUND_MAX = -1.0E+33_FB BOUND_MIN = -BOUND_MAX + OPEN(LU_BNDF(NF,NM),FILE=FN_BNDF(NF,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') WRITE(LU_BNDF(NF,NM)) STIME IND = ABS(BF%INDEX) NC = 0 @@ -10352,6 +10344,9 @@ SUBROUTINE DUMP_BNDF(T,DT,NM) ENDIF ENDDO PATCH_LOOP + + CLOSE(LU_BNDF(NF,NM)) + CHANGE_BOUND = 0 IF (REAL(T-T_BEGIN,FB) RAD_FILE(N) + OPEN(LU_RADF(N,NM),FILE=FN_RADF(N,NM),FORM='FORMATTED',STATUS='OLD',POSITION='APPEND') WRITE(LU_RADF(N,NM),'(/A)') 'TIME' WRITE(LU_RADF(N,NM),'(F8.2)') T WRITE(LU_RADF(N,NM),'(/A)') 'INTENSITIES' @@ -4605,6 +4606,7 @@ SUBROUTINE RADIATION_FVM ENDDO ENDDO ENDDO + CLOSE(LU_RADF(N,NM)) ENDDO RADF_COUNTER(NM) = RADF_COUNTER(NM) + 1 diff --git a/Source/read.f90 b/Source/read.f90 index 588a982ccfc..4e2044dab63 100644 --- a/Source/read.f90 +++ b/Source/read.f90 @@ -1474,11 +1474,11 @@ END SUBROUTINE READ_TRAN SUBROUTINE READ_TIME(DT) USE MATH_FUNCTIONS, ONLY: GET_RAMP_INDEX -USE OUTPUT_CLOCKS, ONLY: RAMP_TIME_INDEX +USE OUTPUT_CLOCKS, ONLY: RAMP_TIME_INDEX,RAMP_DT_INDEX REAL(EB), INTENT(OUT) :: DT -CHARACTER(LABEL_LENGTH) :: RAMP_TIME +CHARACTER(LABEL_LENGTH) :: RAMP_TIME,RAMP_DT NAMELIST /TIME/ DT,DT_END_FILL,DT_END_MINIMUM,DT_EXTERNAL,DT_EXTERNAL_HEARTBEAT,EXTERNAL_HEARTBEAT_FILENAME,HEARTBEAT_FAIL,& - FYI,LIMITING_DT_RATIO,LOCK_TIME_STEP,& + FYI,LIMITING_DT_RATIO,LOCK_TIME_STEP,RAMP_DT,& RAMP_TIME,RESTRICT_TIME_STEP,T_BEGIN,T_END,TIME_SHRINK_FACTOR,WALL_INCREMENT DT = -1._EB @@ -1486,6 +1486,7 @@ SUBROUTINE READ_TIME(DT) T_BEGIN = 0._EB T_END = 1._EB RAMP_TIME = 'null' +RAMP_DT = 'null' REWIND(LU_INPUT) ; INPUT_FILE_LINE_NUMBER = 0 READ_TIME_LOOP: DO @@ -1505,7 +1506,14 @@ SUBROUTINE READ_TIME(DT) ! Set up time ramp if specified +IF (RAMP_TIME /='null' .AND. RAMP_DT /='null') THEN + WRITE(MESSAGE,'(A)') & + 'ERROR(XXX): On TIME, do not set both RAMP_TIME and RAMP_DT.' + CALL SHUTDOWN(MESSAGE) ; RETURN +ENDIF + IF (RAMP_TIME /='null') CALL GET_RAMP_INDEX(RAMP_TIME,'TIME',RAMP_TIME_INDEX) +IF (RAMP_DT /='null') CALL GET_RAMP_INDEX(RAMP_DT,'TIME',RAMP_DT_INDEX) IF (DT_EXTERNAL_HEARTBEAT <= TWO_EPSILON_EB .NEQV. EXTERNAL_HEARTBEAT_FILENAME=='null') THEN WRITE(MESSAGE,'(A)') & diff --git a/Source/smvv.f90 b/Source/smvv.f90 index a096965e9a2..36fcd1393fe 100644 --- a/Source/smvv.f90 +++ b/Source/smvv.f90 @@ -924,7 +924,7 @@ END SUBROUTINE SLICE_TO_RLEFILE SUBROUTINE SMOKE3D_TO_FILE(NM,TIME,DX,SMOKE3D_INDEX,VALS,NX,NY,NZ,SMOKE3D_16_FLAG) USE OUTPUT_DATA, ONLY: SMOKE3D_TYPE,SMOKE3D_FILE,N_SMOKE3D -USE GLOBAL_CONSTANTS, ONLY: TMPA,TMPM,LU_SMOKE3D,TEMP_MAX_SMV,HRRPUV_MAX_SMV +USE GLOBAL_CONSTANTS, ONLY: TMPA,TMPM,LU_SMOKE3D,FN_SMOKE3D,TEMP_MAX_SMV,HRRPUV_MAX_SMV INTEGER, INTENT(IN) :: NX,NY,NZ,NM,SMOKE3D_INDEX LOGICAL, INTENT(IN) :: SMOKE3D_16_FLAG REAL(FB), INTENT(IN) :: TIME, DX @@ -989,15 +989,19 @@ SUBROUTINE SMOKE3D_TO_FILE(NM,TIME,DX,SMOKE3D_INDEX,VALS,NX,NY,NZ,SMOKE3D_16_FLA ! Write size information to a text file IF (.NOT.SMOKE3D_16_FLAG) THEN ! write out an extra column below if SMOKE3D_16_FLAG is true + OPEN(LU_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM),FILE=FN_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM),& + FORM='FORMATTED',STATUS='OLD',POSITION='APPEND') WRITE(LU_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM),*) TIME,NCHARS_IN,NCHARS_OUT,MAX_VAL + CLOSE(LU_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM)) ENDIF ! Write data +OPEN(LU_SMOKE3D(SMOKE3D_INDEX,NM),FILE=FN_SMOKE3D(SMOKE3D_INDEX,NM),FORM='UNFORMATTED',STATUS='OLD',POSITION='APPEND') WRITE(LU_SMOKE3D(SMOKE3D_INDEX,NM)) TIME WRITE(LU_SMOKE3D(SMOKE3D_INDEX,NM)) NCHARS_IN,NCHARS_OUT WRITE(LU_SMOKE3D(SMOKE3D_INDEX,NM)) (BUFFER_OUT(I),I=1,NCHARS_OUT) - +CLOSE(LU_SMOKE3D(SMOKE3D_INDEX,NM)) ! write out data as 2 byte integers IF (SMOKE3D_16_FLAG) THEN @@ -1022,12 +1026,18 @@ SUBROUTINE SMOKE3D_TO_FILE(NM,TIME,DX,SMOKE3D_INDEX,VALS,NX,NY,NZ,SMOKE3D_16_FLA BUFFER16_IN(2*i) = CHAR(VAL_LOW) ENDDO + OPEN(LU_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM),FILE=FN_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM),& + FORM='FORMATTED',STATUS='OLD',POSITION='APPEND') WRITE(LU_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM),*) TIME,NCHARS_IN,NCHARS_OUT,MAX_VAL,NVALS16_OUT + CLOSE(LU_SMOKE3D(SMOKE3D_INDEX+N_SMOKE3D,NM)) + OPEN(LU_SMOKE3D(SMOKE3D_INDEX+2*N_SMOKE3D,NM),FILE=FN_SMOKE3D(SMOKE3D_INDEX+2*N_SMOKE3D,NM),FORM='UNFORMATTED',& + STATUS='OLD',POSITION='APPEND') WRITE(LU_SMOKE3D(SMOKE3D_INDEX + 2*N_SMOKE3D,NM)) TIME WRITE(LU_SMOKE3D(SMOKE3D_INDEX + 2*N_SMOKE3D,NM)) NVALS,NVALS16_OUT,SMOKE3D_16_VALMIN,SMOKE3D_16_VALMAX ! output (2**16 - 1)(val-valmin)/(valmax-valmin) WRITE(LU_SMOKE3D(SMOKE3D_INDEX + 2*N_SMOKE3D,NM)) (BUFFER16_IN(I),I=1,2*NVALS) + CLOSE(LU_SMOKE3D(SMOKE3D_INDEX + 2*N_SMOKE3D,NM)) DEALLOCATE(BUFFER16_IN) ENDIF diff --git a/Source/velo.f90 b/Source/velo.f90 index 82a45bf129f..503d0d1961e 100644 --- a/Source/velo.f90 +++ b/Source/velo.f90 @@ -1619,7 +1619,7 @@ SUBROUTINE VELOCITY_PREDICTOR(T,DT,DT_NEW,NM) IF (SOLID_PHASE_ONLY) RETURN IF (PERIODIC_TEST==4) THEN CALL COMPRESSION_WAVE(NM,T,4) - CALL CHECK_STABILITY(DT,DT_NEW,NM) + CALL CHECK_STABILITY(DT,DT_NEW,T,NM) RETURN ENDIF @@ -1712,7 +1712,7 @@ SUBROUTINE VELOCITY_PREDICTOR(T,DT,DT_NEW,NM) ! Check the stability criteria, and if the time step is too small, send back a signal to kill the job -CALL CHECK_STABILITY(DT,DT_NEW,NM) +CALL CHECK_STABILITY(DT,DT_NEW,T,NM) IF (DT_NEW(NM) \brief Check the Courant and Von Neumann stability criteria, and if necessary, reduce or increase the time step !> \param DT Time step (s) !> \param DT_NEW New time step (s) +!> \param T Current time (s) !> \param NM Mesh number -SUBROUTINE CHECK_STABILITY(DT,DT_NEW,NM) +SUBROUTINE CHECK_STABILITY(DT,DT_NEW,T,NM) USE CC_SCALARS, ONLY : CHECK_CFLVN_LINKED_CELLS -USE OUTPUT_CLOCKS, ONLY: RAMP_TIME_INDEX +USE OUTPUT_CLOCKS, ONLY: RAMP_TIME_INDEX,RAMP_DT_INDEX +USE MATH_FUNCTIONS, ONLY: EVALUATE_RAMP INTEGER, INTENT(IN) :: NM -REAL(EB), INTENT(IN) :: DT +REAL(EB), INTENT(IN) :: DT,T REAL(EB) :: UODX,VODY,WODZ,UVW,UVWMAX,R_DX2,MU_MAX,MUTRM,PART_CFL,MU_TMP, UVWMAX_TMP, DT_CLIP, T_NOW REAL(EB) :: DT_NEW(NMESHES) INTEGER :: I,J,K,IW,IIG,JJG,KKG, ICFL_TMP, JCFL_TMP, KCFL_TMP @@ -3153,6 +3155,8 @@ SUBROUTINE CHECK_STABILITY(DT,DT_NEW,NM) DT_CLIP) CHANGE_TIME_STEP_INDEX(NM) = -1 ENDIF + + IF (RAMP_DT_INDEX > 0) DT_NEW(NM) = MIN(DT_NEW(NM),EVALUATE_RAMP(T,RAMP_DT_INDEX)) ENDIF RAMP_TIME_IF