diff --git a/examples/grid/material.yaml b/examples/grid/material.yaml index ef35f9281..a89068e1b 100644 --- a/examples/grid/material.yaml +++ b/examples/grid/material.yaml @@ -6,29 +6,29 @@ homogenization: phase: Aluminum: - "lattice": 'cF' + lattice: cF mechanical: output: [F, P, F_e, F_p, L_p, O] - elastic: {type: "Hooke", C_11: 106.75e+9, C_12: 60.41e+9, C_44: 28.34e+9} + elastic: {type: Hooke, C_11: 106.75e+9, C_12: 60.41e+9, C_44: 28.34e+9} plastic: - 'type': "phenopowerlaw" - "N_sl": [12] + type: phenopowerlaw + N_sl: [12] a_sl: 2.25 atol_xi: 1.0 dot_gamma_0_sl: 0.001 h_0_sl-sl: 75.e+6 h_sl-sl: [1, 1, 1.4, 1.4, 1.4, 1.4, 1.4] n_sl: 20 - 'output': ['xi_sl'] + output: [xi_sl] xi_0_sl: [31.e+6] xi_inf_sl: [63.e+6] material: - homogenization: SX constituents: - - 'phase': "Aluminum" - 'v': 1.0 - "O": [1.0, 0.0, 0.0, 0.0] + - phase: Aluminum + v: 1.0 + O: [1.0, 0.0, 0.0, 0.0] - homogenization: SX constituents: - phase: Aluminum diff --git a/src/IO.f90 b/src/IO.f90 index 399e2e6df..16d385106 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -494,6 +494,8 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg) msg = '--- expected after YAML file header' case (709) msg = 'Length mismatch' + case (710) + msg = 'Quotation missing in string' !------------------------------------------------------------------------------------------------- ! errors related to the grid solver diff --git a/src/YAML_parse.f90 b/src/YAML_parse.f90 index f876fd71f..4043fb6eb 100644 --- a/src/YAML_parse.f90 +++ b/src/YAML_parse.f90 @@ -72,7 +72,7 @@ recursive function parse_flow(YAML_flow) result(node) d = s + scan(flow_string(s+1:),':') e = d + find_end(flow_string(d+1:),'}') key = trim(adjustl(flow_string(s+1:d-1))) - if (key(1:1) == '"' .or. key(1:1) == "'" ) key = key(2:len(key)-1) + if(quotedString(key)) key = key(2:len(key)-1) myVal => parse_flow(flow_string(d+1:e-1)) ! parse items (recursively) select type (node) @@ -97,7 +97,7 @@ recursive function parse_flow(YAML_flow) result(node) allocate(tScalar::node) select type (node) class is (tScalar) - if (flow_string(1:1) == '"' .or. flow_string(1:1) == "'") then + if(quotedString(flow_string)) then node = trim(adjustl(flow_string(2:len(flow_string)-1))) else node = trim(adjustl(flow_string)) @@ -138,6 +138,23 @@ integer function find_end(str,e_char) end function find_end +!-------------------------------------------------------------------------------------------------- +! @brief check whether a string is enclosed with single or double quotes +!-------------------------------------------------------------------------------------------------- +logical function quotedString(line) + + character(len=*), intent(in) :: line + + quotedString = .false. + + if (line(1:1) == '"' .or. line(1:1) == "'") then + quotedString = .true. + if(line(len(line):len(line)) /= line(1:1)) call IO_error(710,ext_msg=line) + endif + +end function quotedString + + !-------------------------------------------------------------------------------------------------- ! @brief Returns Indentation. ! @details It determines the indentation level for a given block/line. @@ -760,6 +777,8 @@ subroutine selfTest if (indentDepth('a') /= 0) error stop 'indentDepth' if (indentDepth('x ') /= 0) error stop 'indentDepth' + if (.not. quotedString("'a'")) error stop 'quotedString' + if ( isFlow(' a')) error stop 'isFLow' if (.not. isFlow('{')) error stop 'isFlow' if (.not. isFlow(' [')) error stop 'isFlow'