From a18057ba4d192c26ecd2d631af514a3da79f192c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 21 Jan 2020 07:37:04 +0100 Subject: [PATCH] use central functionality for file IO --- src/grid/DAMASK_grid.f90 | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index b324a5afc..dbd558315 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -65,12 +65,11 @@ program DAMASK_spectral currentLoadcase = 0, & !< current load case inc, & !< current increment in current load case totalIncsCounter = 0, & !< total # of increments - fileUnit = 0, & !< file unit for reading load case and writing results - myStat, & statUnit = 0, & !< file unit for statistics output stagIter, & nActiveFields = 0 character(len=6) :: loadcase_string + character(len=pStringLen), dimension(:), allocatable :: fileContent character(len=1024) :: & incInfo type(tLoadCase), allocatable, dimension(:) :: loadCases !< array of all load cases @@ -142,16 +141,12 @@ program DAMASK_spectral !-------------------------------------------------------------------------------------------------- ! reading information from load case file and to sanity checks allocate (loadCases(0)) ! array of load cases - open(newunit=fileunit,iostat=myStat,file=trim(loadCaseFile),action='read') - if (myStat /= 0) call IO_error(100,el=myStat,ext_msg=trim(loadCaseFile)) - do - read(fileUnit, '(A)', iostat=myStat) line - if ( myStat /= 0) exit - if (IO_isBlank(line)) cycle ! skip empty lines - - currentLoadCase = currentLoadCase + 1 + fileContent = IO_read_ASCII(trim(loadCaseFile)) + do currentLoadCase = 1, size(fileContent) + line = fileContent(currentLoadCase) chunkPos = IO_stringPos(line) + do i = 1, chunkPos(1) ! reading compulsory parameters for loadcase select case (IO_lc(IO_stringValue(line,chunkPos,i))) case('l','fdot','dotf','f') @@ -300,7 +295,7 @@ program DAMASK_spectral endif reportAndCheck loadCases = [loadCases,newLoadCase] ! load case is ok, append it enddo - close(fileUnit) + !-------------------------------------------------------------------------------------------------- ! doing initialization depending on active solvers