no need to use two loops

This commit is contained in:
Martin Diehl 2018-08-31 09:11:09 +02:00
parent 732022d4f0
commit c0ac05aa88
1 changed files with 13 additions and 13 deletions

View File

@ -133,6 +133,7 @@ program DAMASK_spectral
incInfo, & !< string parsed to solution with information about current load case incInfo, & !< string parsed to solution with information about current load case
workingDir workingDir
type(tLoadCase), allocatable, dimension(:) :: loadCases !< array of all load cases type(tLoadCase), allocatable, dimension(:) :: loadCases !< array of all load cases
type(tLoadCase) :: newLoadCase
type(tSolutionState), allocatable, dimension(:) :: solres type(tSolutionState), allocatable, dimension(:) :: solres
integer(MPI_OFFSET_KIND) :: fileOffset integer(MPI_OFFSET_KIND) :: fileOffset
integer(MPI_OFFSET_KIND), dimension(:), allocatable :: outputSize integer(MPI_OFFSET_KIND), dimension(:), allocatable :: outputSize
@ -188,6 +189,7 @@ program DAMASK_spectral
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! reading basic information from load case file and allocate data structure containing load cases ! reading basic information from load case file and allocate data structure containing load cases
allocate (loadCases(0)) ! array of load cases
open(newunit=fileunit,iostat=myStat,file=trim(loadCaseFile),action='read') open(newunit=fileunit,iostat=myStat,file=trim(loadCaseFile),action='read')
if (myStat /= 0_pInt) call IO_error(100_pInt,el=myStat,ext_msg=trim(loadCaseFile)) if (myStat /= 0_pInt) call IO_error(100_pInt,el=myStat,ext_msg=trim(loadCaseFile))
do do
@ -205,29 +207,27 @@ program DAMASK_spectral
N_n = N_n + 1_pInt N_n = N_n + 1_pInt
end select end select
enddo ! count all identifiers to allocate memory and do sanity check enddo ! count all identifiers to allocate memory and do sanity check
enddo
if ((N_def /= N_n) .or. (N_n /= N_t) .or. N_n < 1_pInt) & ! sanity check if ((N_def /= N_n) .or. (N_n /= N_t) .or. N_n < 1_pInt) & ! sanity check
call IO_error(error_ID=837_pInt,ext_msg = trim(loadCaseFile)) ! error message for incomplete loadcase call IO_error(error_ID=837_pInt,ext_msg = trim(loadCaseFile)) ! error message for incomplete loadcase
allocate (loadCases(N_n)) ! array of load cases loadCases = [loadCases,newLoadCase]
loadCases%stress%myType='stress' currentLoadCase = currentLoadCase + 1_pInt
loadCases(currentLoadCase)%stress%myType='stress'
do i = 1, size(loadCases) allocate(loadCases(currentLoadCase)%ID(nActiveFields))
allocate(loadCases(i)%ID(nActiveFields))
field = 1 field = 1
loadCases(i)%ID(field) = FIELD_MECH_ID ! mechanical active by default loadCases(currentLoadCase)%ID(field) = FIELD_MECH_ID ! mechanical active by default
thermalActive: if (any(thermal_type == THERMAL_conduction_ID)) then thermalActive: if (any(thermal_type == THERMAL_conduction_ID)) then
field = field + 1 field = field + 1
loadCases(i)%ID(field) = FIELD_THERMAL_ID loadCases(currentLoadCase)%ID(field) = FIELD_THERMAL_ID
endif thermalActive endif thermalActive
damageActive: if (any(damage_type == DAMAGE_nonlocal_ID)) then damageActive: if (any(damage_type == DAMAGE_nonlocal_ID)) then
field = field + 1 field = field + 1
loadCases(i)%ID(field) = FIELD_DAMAGE_ID loadCases(currentLoadCase)%ID(field) = FIELD_DAMAGE_ID
endif damageActive endif damageActive
enddo enddo
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! reading the load case and assign values to the allocated data structure ! reading the load case and assign values to the allocated data structure
currentLoadCase = 0_pInt
rewind(FILEUNIT) rewind(FILEUNIT)
do do
read(fileUnit, '(A)', iostat=myStat) line read(fileUnit, '(A)', iostat=myStat) line