From 04db45f5c09034444e874c30879fbb3838c39f40 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 25 Feb 2023 12:13:27 +0100 Subject: [PATCH 1/6] functionality to report references in material.yaml --- src/IO.f90 | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ src/material.f90 | 30 +++++++++++++++++++++-- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index 2529e096e..386e93581 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -11,6 +11,7 @@ module IO IO_STDERR => ERROR_UNIT use prec + use misc implicit none(type,external) private @@ -30,6 +31,7 @@ module IO IO_read, & IO_readlines, & IO_isBlank, & + IO_insertEOL, & IO_stringPos, & IO_stringValue, & IO_intValue, & @@ -158,6 +160,53 @@ logical pure function IO_isBlank(string) end function IO_isBlank +!-------------------------------------------------------------------------------------------------- +!> @brief Insert EOL at separator trying to keep line length below limit. +!-------------------------------------------------------------------------------------------------- +function IO_insertEOL(string,separator,length) + + character(len=*), intent(in) :: string !< string to split + character, optional, intent(in) :: separator !< possible splitting positions + integer, optional, intent(in) :: length !< (soft) line limit + character(len=:), allocatable :: IO_insertEOL + + integer, dimension(:), allocatable :: pos_sep, pos_split + integer :: i,s,e + character :: sep + + + sep = misc_optional(separator,',') + + i = index(string,sep) + if (i == 0) then + IO_insertEOL = string + else + pos_sep = [0] + s = i + do while (i /= 0 .and. s < len(string)) + pos_sep = [pos_sep,s] + i = index(string(s+1:),sep) + s = s + i + end do + pos_sep = [pos_sep,len(string)] + + pos_split = [integer::] + s = 1 + e = 2 + IO_insertEOL= '' + do while (e < size(pos_sep)) + if (pos_sep(e+1) - pos_sep(s) >= misc_optional(length,80)) then + IO_insertEOL = IO_insertEOL//string(pos_sep(s)+1:pos_sep(e))//IO_EOL + s = e + end if + e = e + 1 + end do + IO_insertEOL = IO_insertEOL//string(pos_sep(s)+1:) + end if + +end function IO_insertEOL + + !-------------------------------------------------------------------------------------------------- !> @brief Locate all whitespace-separated chunks in given string and returns array containing !! number them and the left/right position to be used by IO_xxxVal. @@ -748,6 +797,19 @@ subroutine selfTest() str=' ab #';out=IO_rmComment(str) if (out /= ' ab'.or. len(out) /= 3) error stop 'IO_rmComment/6' + if ('abc, def' /= IO_insertEOL('abc, def')) & + error stop 'IO_insertEOL/1' + if ('abc,'//IO_EOL//'def' /= IO_insertEOL('abc,def',length=3)) & + error stop 'IO_insertEOL/2' + if ('abc,'//IO_EOL//'def' /= IO_insertEOL('abc,def',length=5)) & + error stop 'IO_insertEOL/3' + if ('abc, def' /= IO_insertEOL('abc, def',length=3,separator='.')) & + error stop 'IO_insertEOL/4' + if ('abc.'//IO_EOL//' def' /= IO_insertEOL('abc. def',length=3,separator='.')) & + error stop 'IO_insertEOL/5' + if ('abc,'//IO_EOL//'defg,'//IO_EOL//'hij' /= IO_insertEOL('abc,defg,hij',length=4)) & + error stop 'IO_insertEOL/6' + end subroutine selfTest end module IO diff --git a/src/material.f90 b/src/material.f90 index 2f8efa3aa..9f3f1f6d0 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -49,7 +49,8 @@ module material material_v ! fraction public :: & - material_init + material_init, & + material_references contains @@ -79,7 +80,32 @@ end subroutine material_init !-------------------------------------------------------------------------------------------------- -!> @brief Parse material.yaml to get the global structure +!> @brief Return string with references from dict. +!-------------------------------------------------------------------------------------------------- +function material_references(config) result(references) + + type(tDict) :: config + character(len=:), allocatable :: references + + type(tList), pointer :: ref + integer :: r + + + ref => config%get_list('references',emptyList) + if (ref%length > 0) then + references = 'references:' + do r = 1, ref%length + references = references//IO_EOL//' '//IO_insertEOL(ref%get_asString(r)) + end do + else + references = '' + end if + +end function material_references + + +!-------------------------------------------------------------------------------------------------- +!> @brief Parse material.yaml to get the global structure. !-------------------------------------------------------------------------------------------------- subroutine parse() From 941866460475db251047b289ad748dc7d149e798 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 25 Feb 2023 12:43:10 +0100 Subject: [PATCH 2/6] report origin of configuration if given --- src/phase.f90 | 3 ++- src/phase_damage.f90 | 1 + src/phase_damage_anisobrittle.f90 | 2 ++ src/phase_damage_isobrittle.f90 | 2 ++ src/phase_mechanical_elastic.f90 | 1 + src/phase_mechanical_plastic_dislotungsten.f90 | 2 ++ src/phase_mechanical_plastic_dislotwin.f90 | 2 ++ src/phase_mechanical_plastic_isotropic.f90 | 2 ++ src/phase_mechanical_plastic_kinehardening.f90 | 3 +++ src/phase_mechanical_plastic_none.f90 | 1 + src/phase_mechanical_plastic_nonlocal.f90 | 4 +++- src/phase_mechanical_plastic_phenopowerlaw.f90 | 17 ++++++++--------- src/phase_thermal.f90 | 1 + src/phase_thermal_dissipation.f90 | 1 + src/phase_thermal_externalheat.f90 | 1 + 15 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/phase.f90 b/src/phase.f90 index 42e495483..c34455f2a 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -394,6 +394,7 @@ subroutine phase_init do ph = 1,phases%length phase => phases%get_dict(ph) + print'(a,i0,a)', ' phase ',ph,' '//material_references(phase) phase_lattice(ph) = phase%get_asString('lattice') if (all(phase_lattice(ph) /= ['cF','cI','hP','tI'])) & call IO_error(130,ext_msg='phase_init: '//phase%get_asString('lattice')) @@ -516,7 +517,7 @@ end subroutine phase_result !-------------------------------------------------------------------------------------------------- -!> @brief allocates and initialize per grain variables +!> @brief Allocate and initialize. !-------------------------------------------------------------------------------------------------- subroutine crystallite_init() diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index b21df97e9..7c5b31973 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -103,6 +103,7 @@ module subroutine damage_init() phase => phases%get_dict(ph) source => phase%get_dict('damage',defaultVal=emptyDict) if (source%length > 0) then + print'(a,i0,a)', ' phase ',ph,' '//material_references(source) damage_active = .true. param(ph)%mu = source%get_asFloat('mu') param(ph)%l_c = source%get_asFloat('l_c') diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 6988ac39a..7fe11a71e 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -62,6 +62,8 @@ module function anisobrittle_init() result(mySources) associate(prm => param(ph)) + print'(a,i0,a)', ' phase ',ph,' '//material_references(src) + N_cl = src%get_as1dInt('N_cl',defaultVal=emptyIntArray) prm%sum_N_cl = sum(abs(N_cl)) diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 562ffe6c2..0b1641d38 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -64,6 +64,8 @@ module function isobrittle_init() result(mySources) prm%W_crit = src%get_asFloat('G_crit')/src%get_asFloat('l_c') + print'(a,i0,a)', ' phase ',ph,' '//material_references(src) + #if defined (__GFORTRAN__) prm%output = output_as1dString(src) #else diff --git a/src/phase_mechanical_elastic.f90 b/src/phase_mechanical_elastic.f90 index d5ad9f916..91cb7319d 100644 --- a/src/phase_mechanical_elastic.f90 +++ b/src/phase_mechanical_elastic.f90 @@ -42,6 +42,7 @@ module subroutine elastic_init(phases) phase => phases%get_dict(ph) mech => phase%get_dict('mechanical') elastic => mech%get_dict('elastic') + print'(a,i0,a)', ' phase ',ph,' '//material_references(elastic) if (elastic%get_asString('type') /= 'Hooke') call IO_error(200,ext_msg=elastic%get_asString('type')) associate(prm => param(ph)) diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index 40c1743bb..dedd876e2 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -128,6 +128,8 @@ module function plastic_dislotungsten_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') + print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) #else diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 52864ddf6..b1c97a9e1 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -181,6 +181,8 @@ module function plastic_dislotwin_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') + print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) #else diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index 64e3060ab..ae3fa2e80 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -86,6 +86,8 @@ module function plastic_isotropic_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') + print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) #else diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 622de124a..8aa824a5f 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -84,6 +84,7 @@ module function plastic_kinehardening_init() result(myPlasticity) mech, & pl + myPlasticity = plastic_active('kinehardening') if (count(myPlasticity) == 0) return @@ -111,6 +112,8 @@ module function plastic_kinehardening_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') + print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) #else diff --git a/src/phase_mechanical_plastic_none.f90 b/src/phase_mechanical_plastic_none.f90 index 351d4244b..b79a61183 100644 --- a/src/phase_mechanical_plastic_none.f90 +++ b/src/phase_mechanical_plastic_none.f90 @@ -31,6 +31,7 @@ module function plastic_none_init() result(myPlasticity) phases => config_material%get_dict('phase') do ph = 1, phases%length if (.not. myPlasticity(ph)) cycle + print'(a,i0,a)', ' phase ',ph call phase_allocateState(plasticState(ph),count(material_ID_phase == ph),0,0,0) end do diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index baaecb7b9..f157b2339 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -234,13 +234,15 @@ module function plastic_nonlocal_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - plasticState(ph)%nonlocal = pl%get_asBool('flux',defaultVal=.True.) + print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) #else prm%output = pl%get_as1dString('output',defaultVal=emptyStringArray) #endif + plasticState(ph)%nonlocal = pl%get_asBool('flux',defaultVal=.True.) prm%isotropic_bound = pl%get_asString('isotropic_bound',defaultVal='isostrain') prm%atol_rho = pl%get_asFloat('atol_rho',defaultVal=1.0_pReal) diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index c60e58411..0f8b9a299 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -122,6 +122,14 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') + print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + +#if defined (__GFORTRAN__) + prm%output = output_as1dString(pl) +#else + prm%output = pl%get_as1dString('output',defaultVal=emptyStringArray) +#endif + !-------------------------------------------------------------------------------------------------- ! slip related parameters N_sl = pl%get_as1dInt('N_sl',defaultVal=emptyIntArray) @@ -217,15 +225,6 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) prm%h_0_tw_sl = 0.0_pReal end if slipAndTwinActive -!-------------------------------------------------------------------------------------------------- -! output pararameters - -#if defined (__GFORTRAN__) - prm%output = output_as1dString(pl) -#else - prm%output = pl%get_as1dString('output',defaultVal=emptyStringArray) -#endif - !-------------------------------------------------------------------------------------------------- ! allocate state arrays Nmembers = count(material_ID_phase == ph) diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 1e44258ef..dc80aa423 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -107,6 +107,7 @@ module subroutine thermal_init(phases) ! ToDo: temperature dependency of K and C_p if (thermal%length > 0) then + print'(a,i0,a)', ' phase ',ph,' '//material_references(thermal) param(ph)%C_p = thermal%get_asFloat('C_p') param(ph)%K(1,1) = thermal%get_asFloat('K_11') if (any(phase_lattice(ph) == ['hP','tI'])) param(ph)%K(3,3) = thermal%get_asFloat('K_33') diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index ba2a9aafc..ffb48f80c 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -56,6 +56,7 @@ module function dissipation_init(source_length) result(mySources) if (mySources(so,ph)) then associate(prm => param(ph)) src => sources%get_dict(so) + print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//material_references(src) prm%kappa = src%get_asFloat('kappa') Nmembers = count(material_ID_phase == ph) diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 0e1d11b62..421117f9e 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -60,6 +60,7 @@ module function externalheat_init(source_length) result(mySources) source_thermal_externalheat_offset(ph) = so associate(prm => param(ph)) src => sources%get_dict(so) + print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//material_references(src) prm%f = table(src,'t','f') From 949bc39173552ae035d26009a9904d725a1959a6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Feb 2023 07:34:11 +0100 Subject: [PATCH 3/6] polishing --- src/IO.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index 386e93581..e049f3619 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -166,8 +166,8 @@ end function IO_isBlank function IO_insertEOL(string,separator,length) character(len=*), intent(in) :: string !< string to split - character, optional, intent(in) :: separator !< possible splitting positions - integer, optional, intent(in) :: length !< (soft) line limit + character, optional, intent(in) :: separator !< line breaks are possible after this character, defaults to ',' + integer, optional, intent(in) :: length !< (soft) line limit, defaults to 80 character(len=:), allocatable :: IO_insertEOL integer, dimension(:), allocatable :: pos_sep, pos_split @@ -190,10 +190,10 @@ function IO_insertEOL(string,separator,length) end do pos_sep = [pos_sep,len(string)] - pos_split = [integer::] + pos_split = emptyIntArray s = 1 e = 2 - IO_insertEOL= '' + IO_insertEOL = '' do while (e < size(pos_sep)) if (pos_sep(e+1) - pos_sep(s) >= misc_optional(length,80)) then IO_insertEOL = IO_insertEOL//string(pos_sep(s)+1:pos_sep(e))//IO_EOL From 95a953d25b398be17cca639a913ec0b572649add Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Feb 2023 07:55:34 +0100 Subject: [PATCH 4/6] more reasonable name --- src/config.f90 | 76 +++++++++++++------ src/material.f90 | 28 +------ src/phase.f90 | 2 +- src/phase_damage.f90 | 2 +- src/phase_damage_anisobrittle.f90 | 2 +- src/phase_damage_isobrittle.f90 | 2 +- src/phase_mechanical_elastic.f90 | 2 +- ...phase_mechanical_plastic_dislotungsten.f90 | 2 +- src/phase_mechanical_plastic_dislotwin.f90 | 2 +- src/phase_mechanical_plastic_isotropic.f90 | 2 +- ...phase_mechanical_plastic_kinehardening.f90 | 2 +- src/phase_mechanical_plastic_nonlocal.f90 | 2 +- ...phase_mechanical_plastic_phenopowerlaw.f90 | 2 +- src/phase_thermal.f90 | 2 +- src/phase_thermal_dissipation.f90 | 2 +- src/phase_thermal_externalheat.f90 | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/config.f90 b/src/config.f90 index 9840001ed..207dedb7a 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -18,8 +18,9 @@ module config public :: & config_init, & - config_material_deallocate,& - config_numerics_deallocate + config_material_deallocate, & + config_numerics_deallocate, & + config_fetchReferences contains @@ -36,6 +37,54 @@ subroutine config_init() end subroutine config_init +!-------------------------------------------------------------------------------------------------- +!> @brief Deallocate config_material. +!-------------------------------------------------------------------------------------------------- +subroutine config_material_deallocate() + + print'(/,1x,a)', 'deallocating material configuration'; flush(IO_STDOUT) + deallocate(config_material) + +end subroutine config_material_deallocate + +!-------------------------------------------------------------------------------------------------- +!> @brief Deallocate config_numerics if present. +!-------------------------------------------------------------------------------------------------- +subroutine config_numerics_deallocate() + + if (.not. associated(config_numerics, emptyDict)) then + print'(/,1x,a)', 'deallocating numerics configuration'; flush(IO_STDOUT) + deallocate(config_numerics) + end if + +end subroutine config_numerics_deallocate + + +!-------------------------------------------------------------------------------------------------- +!> @brief Return string with references from dict. +!-------------------------------------------------------------------------------------------------- +function config_fetchReferences(config) result(references) + + type(tDict) :: config + character(len=:), allocatable :: references + + type(tList), pointer :: ref + integer :: r + + + ref => config%get_list('references',emptyList) + if (ref%length > 0) then + references = 'references:' + do r = 1, ref%length + references = references//IO_EOL//' '//IO_insertEOL(ref%get_asString(r)) + end do + else + references = '' + end if + +end function config_fetchReferences + + !-------------------------------------------------------------------------------------------------- !> @brief Read material.yaml. !-------------------------------------------------------------------------------------------------- @@ -93,27 +142,4 @@ subroutine parse_numerics() end subroutine parse_numerics - -!-------------------------------------------------------------------------------------------------- -!> @brief Deallocate config_material. -!-------------------------------------------------------------------------------------------------- -subroutine config_material_deallocate() - - print'(/,1x,a)', 'deallocating material configuration'; flush(IO_STDOUT) - deallocate(config_material) - -end subroutine config_material_deallocate - -!-------------------------------------------------------------------------------------------------- -!> @brief Deallocate config_numerics if present. -!-------------------------------------------------------------------------------------------------- -subroutine config_numerics_deallocate() - - if (.not. associated(config_numerics, emptyDict)) then - print'(/,1x,a)', 'deallocating numerics configuration'; flush(IO_STDOUT) - deallocate(config_numerics) - end if - -end subroutine config_numerics_deallocate - end module config diff --git a/src/material.f90 b/src/material.f90 index 9f3f1f6d0..2169c876a 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -49,8 +49,7 @@ module material material_v ! fraction public :: & - material_init, & - material_references + material_init contains @@ -79,31 +78,6 @@ subroutine material_init(restart) end subroutine material_init -!-------------------------------------------------------------------------------------------------- -!> @brief Return string with references from dict. -!-------------------------------------------------------------------------------------------------- -function material_references(config) result(references) - - type(tDict) :: config - character(len=:), allocatable :: references - - type(tList), pointer :: ref - integer :: r - - - ref => config%get_list('references',emptyList) - if (ref%length > 0) then - references = 'references:' - do r = 1, ref%length - references = references//IO_EOL//' '//IO_insertEOL(ref%get_asString(r)) - end do - else - references = '' - end if - -end function material_references - - !-------------------------------------------------------------------------------------------------- !> @brief Parse material.yaml to get the global structure. !-------------------------------------------------------------------------------------------------- diff --git a/src/phase.f90 b/src/phase.f90 index c34455f2a..98388fc74 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -394,7 +394,7 @@ subroutine phase_init do ph = 1,phases%length phase => phases%get_dict(ph) - print'(a,i0,a)', ' phase ',ph,' '//material_references(phase) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(phase) phase_lattice(ph) = phase%get_asString('lattice') if (all(phase_lattice(ph) /= ['cF','cI','hP','tI'])) & call IO_error(130,ext_msg='phase_init: '//phase%get_asString('lattice')) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 7c5b31973..d2a25dcb3 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -103,7 +103,7 @@ module subroutine damage_init() phase => phases%get_dict(ph) source => phase%get_dict('damage',defaultVal=emptyDict) if (source%length > 0) then - print'(a,i0,a)', ' phase ',ph,' '//material_references(source) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(source) damage_active = .true. param(ph)%mu = source%get_asFloat('mu') param(ph)%l_c = source%get_asFloat('l_c') diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 7fe11a71e..9f09e37ac 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -62,7 +62,7 @@ module function anisobrittle_init() result(mySources) associate(prm => param(ph)) - print'(a,i0,a)', ' phase ',ph,' '//material_references(src) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(src) N_cl = src%get_as1dInt('N_cl',defaultVal=emptyIntArray) prm%sum_N_cl = sum(abs(N_cl)) diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 0b1641d38..cb496a44e 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -64,7 +64,7 @@ module function isobrittle_init() result(mySources) prm%W_crit = src%get_asFloat('G_crit')/src%get_asFloat('l_c') - print'(a,i0,a)', ' phase ',ph,' '//material_references(src) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(src) #if defined (__GFORTRAN__) prm%output = output_as1dString(src) diff --git a/src/phase_mechanical_elastic.f90 b/src/phase_mechanical_elastic.f90 index 91cb7319d..3d54a9d7d 100644 --- a/src/phase_mechanical_elastic.f90 +++ b/src/phase_mechanical_elastic.f90 @@ -42,7 +42,7 @@ module subroutine elastic_init(phases) phase => phases%get_dict(ph) mech => phase%get_dict('mechanical') elastic => mech%get_dict('elastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(elastic) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(elastic) if (elastic%get_asString('type') /= 'Hooke') call IO_error(200,ext_msg=elastic%get_asString('type')) associate(prm => param(ph)) diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index dedd876e2..4b3741e37 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -128,7 +128,7 @@ module function plastic_dislotungsten_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index b1c97a9e1..7375a402c 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -181,7 +181,7 @@ module function plastic_dislotwin_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index ae3fa2e80..443c9c9aa 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -86,7 +86,7 @@ module function plastic_isotropic_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 8aa824a5f..16185130d 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -112,7 +112,7 @@ module function plastic_kinehardening_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index f157b2339..8bdf7daeb 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -234,7 +234,7 @@ module function plastic_nonlocal_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index 0f8b9a299..9d6f78213 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -122,7 +122,7 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//material_references(pl) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index dc80aa423..2dc32560e 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -107,7 +107,7 @@ module subroutine thermal_init(phases) ! ToDo: temperature dependency of K and C_p if (thermal%length > 0) then - print'(a,i0,a)', ' phase ',ph,' '//material_references(thermal) + print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(thermal) param(ph)%C_p = thermal%get_asFloat('C_p') param(ph)%K(1,1) = thermal%get_asFloat('K_11') if (any(phase_lattice(ph) == ['hP','tI'])) param(ph)%K(3,3) = thermal%get_asFloat('K_33') diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index ffb48f80c..9c9015922 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -56,7 +56,7 @@ module function dissipation_init(source_length) result(mySources) if (mySources(so,ph)) then associate(prm => param(ph)) src => sources%get_dict(so) - print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//material_references(src) + print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//config_fetchReferences(src) prm%kappa = src%get_asFloat('kappa') Nmembers = count(material_ID_phase == ph) diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 421117f9e..4dad5248e 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -60,7 +60,7 @@ module function externalheat_init(source_length) result(mySources) source_thermal_externalheat_offset(ph) = so associate(prm => param(ph)) src => sources%get_dict(so) - print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//material_references(src) + print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//config_fetchReferences(src) prm%f = table(src,'t','f') From a40524da02b8aeb9867c1dff6023ba09aad91ae0 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 28 Feb 2023 14:57:44 -0500 Subject: [PATCH 5/6] rename to wrapLines; additional formatting options; whitespace trimming --- src/IO.f90 | 45 ++++++++++--------- src/config.f90 | 19 +++++--- src/phase.f90 | 5 ++- src/phase_damage.f90 | 11 +++-- src/phase_damage_anisobrittle.f90 | 8 +++- src/phase_damage_isobrittle.f90 | 8 +++- src/phase_mechanical_elastic.f90 | 5 ++- ...phase_mechanical_plastic_dislotungsten.f90 | 8 +++- src/phase_mechanical_plastic_dislotwin.f90 | 8 +++- src/phase_mechanical_plastic_isotropic.f90 | 8 +++- ...phase_mechanical_plastic_kinehardening.f90 | 8 +++- src/phase_mechanical_plastic_nonlocal.f90 | 8 +++- ...phase_mechanical_plastic_phenopowerlaw.f90 | 8 +++- src/phase_thermal.f90 | 7 +-- src/phase_thermal_dissipation.f90 | 5 ++- src/phase_thermal_externalheat.f90 | 5 ++- 16 files changed, 112 insertions(+), 54 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index e049f3619..1957eb6ad 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -31,7 +31,7 @@ module IO IO_read, & IO_readlines, & IO_isBlank, & - IO_insertEOL, & + IO_wrapLines, & IO_stringPos, & IO_stringValue, & IO_intValue, & @@ -163,23 +163,26 @@ end function IO_isBlank !-------------------------------------------------------------------------------------------------- !> @brief Insert EOL at separator trying to keep line length below limit. !-------------------------------------------------------------------------------------------------- -function IO_insertEOL(string,separator,length) +function IO_wrapLines(string,separator,filler,length) character(len=*), intent(in) :: string !< string to split character, optional, intent(in) :: separator !< line breaks are possible after this character, defaults to ',' + character(len=*), optional, intent(in) :: filler !< character(s) to insert after line break, defaults to none integer, optional, intent(in) :: length !< (soft) line limit, defaults to 80 - character(len=:), allocatable :: IO_insertEOL + character(len=:), allocatable :: IO_wrapLines integer, dimension(:), allocatable :: pos_sep, pos_split integer :: i,s,e character :: sep + character(len=:), allocatable :: fill sep = misc_optional(separator,',') + fill = misc_optional(filler,'') i = index(string,sep) if (i == 0) then - IO_insertEOL = string + IO_wrapLines = string else pos_sep = [0] s = i @@ -193,18 +196,18 @@ function IO_insertEOL(string,separator,length) pos_split = emptyIntArray s = 1 e = 2 - IO_insertEOL = '' + IO_wrapLines = '' do while (e < size(pos_sep)) if (pos_sep(e+1) - pos_sep(s) >= misc_optional(length,80)) then - IO_insertEOL = IO_insertEOL//string(pos_sep(s)+1:pos_sep(e))//IO_EOL + IO_wrapLines = IO_wrapLines//adjustl(string(pos_sep(s)+1:pos_sep(e)))//IO_EOL//fill s = e end if e = e + 1 end do - IO_insertEOL = IO_insertEOL//string(pos_sep(s)+1:) + IO_wrapLines = IO_wrapLines//adjustl(string(pos_sep(s)+1:)) end if -end function IO_insertEOL +end function IO_wrapLines !-------------------------------------------------------------------------------------------------- @@ -797,18 +800,20 @@ subroutine selfTest() str=' ab #';out=IO_rmComment(str) if (out /= ' ab'.or. len(out) /= 3) error stop 'IO_rmComment/6' - if ('abc, def' /= IO_insertEOL('abc, def')) & - error stop 'IO_insertEOL/1' - if ('abc,'//IO_EOL//'def' /= IO_insertEOL('abc,def',length=3)) & - error stop 'IO_insertEOL/2' - if ('abc,'//IO_EOL//'def' /= IO_insertEOL('abc,def',length=5)) & - error stop 'IO_insertEOL/3' - if ('abc, def' /= IO_insertEOL('abc, def',length=3,separator='.')) & - error stop 'IO_insertEOL/4' - if ('abc.'//IO_EOL//' def' /= IO_insertEOL('abc. def',length=3,separator='.')) & - error stop 'IO_insertEOL/5' - if ('abc,'//IO_EOL//'defg,'//IO_EOL//'hij' /= IO_insertEOL('abc,defg,hij',length=4)) & - error stop 'IO_insertEOL/6' + if ('abc, def' /= IO_wrapLines('abc, def')) & + error stop 'IO_wrapLines/1' + if ('abc,'//IO_EOL//'def' /= IO_wrapLines('abc,def',length=3)) & + error stop 'IO_wrapLines/2' + if ('abc,'//IO_EOL//'def' /= IO_wrapLines('abc,def',length=5)) & + error stop 'IO_wrapLines/3' + if ('abc, def' /= IO_wrapLines('abc, def',length=3,separator='.')) & + error stop 'IO_wrapLines/4' + if ('abc.'//IO_EOL//'def' /= IO_wrapLines('abc. def',length=3,separator='.')) & + error stop 'IO_wrapLines/5' + if ('abc,'//IO_EOL//'defg,'//IO_EOL//'hij' /= IO_wrapLines('abc,defg,hij',length=4)) & + error stop 'IO_wrapLines/6' + if ('abc,'//IO_EOL//'xxdefg,'//IO_EOL//'xxhij' /= IO_wrapLines('abc,defg, hij',filler='xx',length=4)) & + error stop 'IO_wrapLines/7' end subroutine selfTest diff --git a/src/config.f90 b/src/config.f90 index 207dedb7a..e5f9011fb 100644 --- a/src/config.f90 +++ b/src/config.f90 @@ -4,6 +4,7 @@ !-------------------------------------------------------------------------------------------------- module config use IO + use misc use YAML_parse use YAML_types use result @@ -20,7 +21,7 @@ module config config_init, & config_material_deallocate, & config_numerics_deallocate, & - config_fetchReferences + config_listReferences contains @@ -63,26 +64,30 @@ end subroutine config_numerics_deallocate !-------------------------------------------------------------------------------------------------- !> @brief Return string with references from dict. !-------------------------------------------------------------------------------------------------- -function config_fetchReferences(config) result(references) +function config_listReferences(config,indent) result(references) type(tDict) :: config + integer, optional :: indent character(len=:), allocatable :: references + type(tList), pointer :: ref + character(len=:), allocatable :: filler integer :: r + filler = repeat(' ',misc_optional(indent,0)) ref => config%get_list('references',emptyList) - if (ref%length > 0) then + if (ref%length == 0) then + references = '' + else references = 'references:' do r = 1, ref%length - references = references//IO_EOL//' '//IO_insertEOL(ref%get_asString(r)) + references = references//IO_EOL//filler//'- '//IO_wrapLines(ref%get_asString(r),filler=filler//' ') end do - else - references = '' end if -end function config_fetchReferences +end function config_listReferences !-------------------------------------------------------------------------------------------------- diff --git a/src/phase.f90 b/src/phase.f90 index 98388fc74..08027ebe7 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -382,6 +382,7 @@ subroutine phase_init type(tDict), pointer :: & phases, & phase + character(len=:), allocatable :: refs print'(/,1x,a)', '<<<+- phase init -+>>>'; flush(IO_STDOUT) @@ -393,8 +394,10 @@ subroutine phase_init allocate(phase_O_0(phases%length)) do ph = 1,phases%length + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) phase => phases%get_dict(ph) - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(phase) + refs = config_listReferences(phase,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs phase_lattice(ph) = phase%get_asString('lattice') if (all(phase_lattice(ph) /= ['cF','cI','hP','tI'])) & call IO_error(130,ext_msg='phase_init: '//phase%get_asString('lattice')) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index d2a25dcb3..e5909cb22 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -79,9 +79,10 @@ module subroutine damage_init() ph, & Nmembers type(tDict), pointer :: & - phases, & - phase, & - source + phases, & + phase, & + source + character(len=:), allocatable :: refs logical:: damage_active @@ -103,7 +104,9 @@ module subroutine damage_init() phase => phases%get_dict(ph) source => phase%get_dict('damage',defaultVal=emptyDict) if (source%length > 0) then - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(source) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(source,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs damage_active = .true. param(ph)%mu = source%get_asFloat('mu') param(ph)%l_c = source%get_asFloat('l_c') diff --git a/src/phase_damage_anisobrittle.f90 b/src/phase_damage_anisobrittle.f90 index 9f09e37ac..237ca8698 100644 --- a/src/phase_damage_anisobrittle.f90 +++ b/src/phase_damage_anisobrittle.f90 @@ -41,7 +41,9 @@ module function anisobrittle_init() result(mySources) src integer :: Nmembers,ph integer, dimension(:), allocatable :: N_cl - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg mySources = source_active('anisobrittle') @@ -62,7 +64,9 @@ module function anisobrittle_init() result(mySources) associate(prm => param(ph)) - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(src) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(src,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs N_cl = src%get_as1dInt('N_cl',defaultVal=emptyIntArray) prm%sum_N_cl = sum(abs(N_cl)) diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index cb496a44e..7b09d4a56 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -39,7 +39,9 @@ module function isobrittle_init() result(mySources) phase, & src integer :: Nmembers,ph - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg mySources = source_active('isobrittle') @@ -64,7 +66,9 @@ module function isobrittle_init() result(mySources) prm%W_crit = src%get_asFloat('G_crit')/src%get_asFloat('l_c') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(src) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(src,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(src) diff --git a/src/phase_mechanical_elastic.f90 b/src/phase_mechanical_elastic.f90 index 3d54a9d7d..15a5d29c2 100644 --- a/src/phase_mechanical_elastic.f90 +++ b/src/phase_mechanical_elastic.f90 @@ -28,6 +28,7 @@ module subroutine elastic_init(phases) phase, & mech, & elastic + character(len=:), allocatable :: refs print'(/,1x,a)', '<<<+- phase:mechanical:elastic init -+>>>' @@ -42,7 +43,9 @@ module subroutine elastic_init(phases) phase => phases%get_dict(ph) mech => phase%get_dict('mechanical') elastic => mech%get_dict('elastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(elastic) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(elastic,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs if (elastic%get_asString('type') /= 'Hooke') call IO_error(200,ext_msg=elastic%get_asString('type')) associate(prm => param(ph)) diff --git a/src/phase_mechanical_plastic_dislotungsten.f90 b/src/phase_mechanical_plastic_dislotungsten.f90 index 4b3741e37..e37511967 100644 --- a/src/phase_mechanical_plastic_dislotungsten.f90 +++ b/src/phase_mechanical_plastic_dislotungsten.f90 @@ -93,7 +93,9 @@ module function plastic_dislotungsten_init() result(myPlasticity) rho_mob_0, & !< initial dislocation density rho_dip_0, & !< initial dipole density a !< non-Schmid coefficients - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg type(tDict), pointer :: & phases, & phase, & @@ -128,7 +130,9 @@ module function plastic_dislotungsten_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(pl,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_dislotwin.f90 b/src/phase_mechanical_plastic_dislotwin.f90 index 7375a402c..ee6ccb9d1 100644 --- a/src/phase_mechanical_plastic_dislotwin.f90 +++ b/src/phase_mechanical_plastic_dislotwin.f90 @@ -140,7 +140,9 @@ module function plastic_dislotwin_init() result(myPlasticity) real(pReal), allocatable, dimension(:) :: & rho_mob_0, & !< initial unipolar dislocation density per slip system rho_dip_0 !< initial dipole dislocation density per slip system - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg type(tDict), pointer :: & phases, & phase, & @@ -181,7 +183,9 @@ module function plastic_dislotwin_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(pl,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_isotropic.f90 b/src/phase_mechanical_plastic_isotropic.f90 index 443c9c9aa..7a94e6d8b 100644 --- a/src/phase_mechanical_plastic_isotropic.f90 +++ b/src/phase_mechanical_plastic_isotropic.f90 @@ -54,7 +54,9 @@ module function plastic_isotropic_init() result(myPlasticity) sizeState, sizeDotState real(pReal) :: & xi_0 !< initial critical stress - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg type(tDict), pointer :: & phases, & phase, & @@ -86,7 +88,9 @@ module function plastic_isotropic_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(pl,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_kinehardening.f90 b/src/phase_mechanical_plastic_kinehardening.f90 index 16185130d..209dbc40b 100644 --- a/src/phase_mechanical_plastic_kinehardening.f90 +++ b/src/phase_mechanical_plastic_kinehardening.f90 @@ -77,7 +77,9 @@ module function plastic_kinehardening_init() result(myPlasticity) real(pReal), dimension(:), allocatable :: & xi_0, & !< initial resistance against plastic flow a !< non-Schmid coefficients - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg type(tDict), pointer :: & phases, & phase, & @@ -112,7 +114,9 @@ module function plastic_kinehardening_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(pl,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_nonlocal.f90 b/src/phase_mechanical_plastic_nonlocal.f90 index 8bdf7daeb..aeb647eeb 100644 --- a/src/phase_mechanical_plastic_nonlocal.f90 +++ b/src/phase_mechanical_plastic_nonlocal.f90 @@ -188,7 +188,9 @@ module function plastic_nonlocal_init() result(myPlasticity) s, t, l real(pReal), dimension(:), allocatable :: & a - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg type(tInitialParameters) :: & ini type(tDict), pointer :: & @@ -234,7 +236,9 @@ module function plastic_nonlocal_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(pl,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_mechanical_plastic_phenopowerlaw.f90 b/src/phase_mechanical_plastic_phenopowerlaw.f90 index 9d6f78213..11556db78 100644 --- a/src/phase_mechanical_plastic_phenopowerlaw.f90 +++ b/src/phase_mechanical_plastic_phenopowerlaw.f90 @@ -91,7 +91,9 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) xi_0_sl, & !< initial critical shear stress for slip xi_0_tw, & !< initial critical shear stress for twin a !< non-Schmid coefficients - character(len=:), allocatable :: extmsg + character(len=:), allocatable :: & + refs, & + extmsg type(tDict), pointer :: & phases, & phase, & @@ -122,7 +124,9 @@ module function plastic_phenopowerlaw_init() result(myPlasticity) mech => phase%get_dict('mechanical') pl => mech%get_dict('plastic') - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(pl) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(pl,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs #if defined (__GFORTRAN__) prm%output = output_as1dString(pl) diff --git a/src/phase_thermal.f90 b/src/phase_thermal.f90 index 2dc32560e..1371f3b7f 100644 --- a/src/phase_thermal.f90 +++ b/src/phase_thermal.f90 @@ -84,7 +84,7 @@ module subroutine thermal_init(phases) thermal type(tList), pointer :: & sources - + character(len=:), allocatable :: refs integer :: & ph, so, & Nmembers @@ -92,7 +92,6 @@ module subroutine thermal_init(phases) print'(/,1x,a)', '<<<+- phase:thermal init -+>>>' - allocate(current(phases%length)) allocate(thermalState(phases%length)) allocate(thermal_Nsources(phases%length),source = 0) @@ -107,7 +106,9 @@ module subroutine thermal_init(phases) ! ToDo: temperature dependency of K and C_p if (thermal%length > 0) then - print'(a,i0,a)', ' phase ',ph,' '//config_fetchReferences(thermal) + print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph) + refs = config_listReferences(thermal,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs param(ph)%C_p = thermal%get_asFloat('C_p') param(ph)%K(1,1) = thermal%get_asFloat('K_11') if (any(phase_lattice(ph) == ['hP','tI'])) param(ph)%K(3,3) = thermal%get_asFloat('K_33') diff --git a/src/phase_thermal_dissipation.f90 b/src/phase_thermal_dissipation.f90 index 9c9015922..66bde6808 100644 --- a/src/phase_thermal_dissipation.f90 +++ b/src/phase_thermal_dissipation.f90 @@ -34,6 +34,7 @@ module function dissipation_init(source_length) result(mySources) src class(tList), pointer :: & sources + character(len=:), allocatable :: refs integer :: so,Nmembers,ph @@ -56,7 +57,9 @@ module function dissipation_init(source_length) result(mySources) if (mySources(so,ph)) then associate(prm => param(ph)) src => sources%get_dict(so) - print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//config_fetchReferences(src) + print'(1x,a,i0,a,i0)', 'phase ',ph,' source ',so + refs = config_listReferences(src,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs prm%kappa = src%get_asFloat('kappa') Nmembers = count(material_ID_phase == ph) diff --git a/src/phase_thermal_externalheat.f90 b/src/phase_thermal_externalheat.f90 index 4dad5248e..304171c10 100644 --- a/src/phase_thermal_externalheat.f90 +++ b/src/phase_thermal_externalheat.f90 @@ -36,6 +36,7 @@ module function externalheat_init(source_length) result(mySources) src type(tList), pointer :: & sources + character(len=:), allocatable :: refs integer :: so,Nmembers,ph @@ -60,7 +61,9 @@ module function externalheat_init(source_length) result(mySources) source_thermal_externalheat_offset(ph) = so associate(prm => param(ph)) src => sources%get_dict(so) - print'(a,i0,a,i0,a)', ' phase ',ph,' source ',so,' '//config_fetchReferences(src) + print'(1x,a,i0,a,i0)', 'phase ',ph,' source ',so + refs = config_listReferences(src,indent=3) + if (len(refs) > 0) print'(/,1x,a)', refs prm%f = table(src,'t','f') From f3da19a8e21efd0dedd8253cc74b70a3a593e354 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 28 Feb 2023 15:09:23 -0500 Subject: [PATCH 6/6] drop little-used variables --- src/IO.f90 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index 1957eb6ad..882b7faf6 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -173,14 +173,9 @@ function IO_wrapLines(string,separator,filler,length) integer, dimension(:), allocatable :: pos_sep, pos_split integer :: i,s,e - character :: sep - character(len=:), allocatable :: fill - sep = misc_optional(separator,',') - fill = misc_optional(filler,'') - - i = index(string,sep) + i = index(string,misc_optional(separator,',')) if (i == 0) then IO_wrapLines = string else @@ -188,7 +183,7 @@ function IO_wrapLines(string,separator,filler,length) s = i do while (i /= 0 .and. s < len(string)) pos_sep = [pos_sep,s] - i = index(string(s+1:),sep) + i = index(string(s+1:),misc_optional(separator,',')) s = s + i end do pos_sep = [pos_sep,len(string)] @@ -199,7 +194,7 @@ function IO_wrapLines(string,separator,filler,length) IO_wrapLines = '' do while (e < size(pos_sep)) if (pos_sep(e+1) - pos_sep(s) >= misc_optional(length,80)) then - IO_wrapLines = IO_wrapLines//adjustl(string(pos_sep(s)+1:pos_sep(e)))//IO_EOL//fill + IO_wrapLines = IO_wrapLines//adjustl(string(pos_sep(s)+1:pos_sep(e)))//IO_EOL//misc_optional(filler,'') s = e end if e = e + 1