diff --git a/src/basic_mod.F90 b/src/basic_mod.F90 index b523405726ab203af7e0ee06efe26cf9609c6409..ecda6e4adabe730c948c1eddae48e7409762b69d 100644 --- a/src/basic_mod.F90 +++ b/src/basic_mod.F90 @@ -58,7 +58,6 @@ MODULE basic END INTERFACE allocate_array CONTAINS - !================================================================================ SUBROUTINE basic_data ! Read basic data for input file @@ -66,6 +65,8 @@ CONTAINS use prec_const IMPLICIT NONE + CALL find_input_file + NAMELIST /BASIC/ nrun, dt, tmax, maxruntime READ(lu_in,basic) @@ -76,6 +77,28 @@ CONTAINS END SUBROUTINE basic_data !================================================================================ + SUBROUTINE find_input_file + IMPLICIT NONE + CHARACTER(len=32) :: str, input_file + INTEGER :: nargs, fileid, l + LOGICAL :: mlexist + nargs = COMMAND_ARGUMENT_COUNT() + IF((nargs .EQ. 1) .OR. (nargs .EQ. 3)) THEN + CALL GET_COMMAND_ARGUMENT(nargs, str, l, ierr) + READ(str(1:l),'(i3)') fileid + WRITE(input_file,'(a,a1,i2.2,a3)') 'fort','_',fileid,'.90' + + INQUIRE(file=input_file, exist=mlexist) + IF( mlexist ) THEN + IF(my_id.EQ.0) write(*,*) 'Reading input ', input_file,'...' + OPEN(lu_in, file=input_file) + ELSE + IF(my_id.EQ.0) write(*,*) 'Reading input fort.90...' + OPEN(lu_in, file='fort.90') + ENDIF + ENDIF + END SUBROUTINE find_input_file + !================================================================================ SUBROUTINE daytim(str) ! Print date and time diff --git a/src/ppinit.F90 b/src/ppinit.F90 index 9b8382b6d135919e48d8cb61f175b6b977b57eff..c94183109c058d755625eac9576f3ca82efa6005 100644 --- a/src/ppinit.F90 +++ b/src/ppinit.F90 @@ -19,13 +19,9 @@ SUBROUTINE ppinit CALL MPI_COMM_SIZE (MPI_COMM_WORLD, num_procs, ierr) nargs = COMMAND_ARGUMENT_COUNT() - IF( nargs .NE. 0 .AND. nargs .NE. ndims ) THEN - IF(my_id .EQ. 0) WRITE(*, '(a,i4,a)') 'Number of arguments not equal to NDIMS =', ndims, '!' - CALL MPI_ABORT(MPI_COMM_WORLD, -1, ierr) - END IF ! - IF( nargs .NE. 0 ) THEN - DO i=1,nargs + IF( nargs .GT. 1 ) THEN + DO i=1,ndims CALL GET_COMMAND_ARGUMENT(i, str, l, ierr) READ(str(1:l),'(i3)') dims(i) END DO