@@ -969,6 +969,8 @@ program ESMF_HConfigEx
969
969
call ESMF_HConfigFileLoad(hconfig, filename= " exampleWithTags.yaml" , rc= rc)
970
970
! EOC
971
971
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
972
+ call ESMF_HConfigLog(hconfig, prefix= " WithTagsStart: " , rc= rc)
973
+ if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
972
974
! BOE
973
975
! The file contains the following YAML:
974
976
! \begin{verbatim}
@@ -1132,9 +1134,11 @@ program ESMF_HConfigEx
1132
1134
! TRUE | FALSE
1133
1135
! \end{verbatim}
1134
1136
!
1135
- ! \paragraph{More Boolean values and the "Norway problem"}
1136
- ! The YAMLCPP backend used by {\tt ESMF\_HConfig} interprets several
1137
- ! additional values as boolean for convenience:
1137
+ ! \paragraph{Additional Boolean values and the "Norway problem"}
1138
+ ! The YAMLCPP backend used by {\tt ESMF\_HConfig} interprets all of the values
1139
+ ! recognized as such under \htmladdnormallink{YAML 1.1}
1140
+ ! {https://yaml.org/type/bool.html} as boolean. This extends the above list with
1141
+ ! additional options:
1138
1142
! \begin{verbatim}
1139
1143
! yes | no
1140
1144
! Yes | No
@@ -1145,43 +1149,39 @@ program ESMF_HConfigEx
1145
1149
! On | Off
1146
1150
! ON | OFF
1147
1151
! \end{verbatim}
1148
- ! The interpretation of value {\tt ON } as a boolean, instead of a literal
1149
- ! string, leads to the so-called {\em "Norway problem"}, where the same string
1150
- ! is often used as country code instead. The more general problem referred to
1151
- ! here is the misinterpretation of a value by YAML.
1152
+ ! The interpretation of value {\tt NO } as a boolean, instead of a literal
1153
+ ! string, can be problematic. It leads to the so-called {\em "Norway problem"},
1154
+ ! because the same string is often used as country code instead. The underlying
1155
+ ! problem is the misinterpretation of values by YAML.
1152
1156
! EOE
1153
- #if 1
1154
1157
tag = ESMF_HConfigGetTag(hconfig, keyString= " value_thirteen" , rc= rc)
1155
1158
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1156
1159
write (msgString, ' ("value_thirteen HConfig tag: ", A30)' ) tag
1157
1160
call ESMF_LogWrite(trim (msgString), ESMF_LOGMSG_INFO, rc= rc)
1158
1161
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1159
- #endif
1160
1162
! BOE
1161
1163
! Strictly speaking this is not a YAML problem, but instead a schema specific
1162
1164
! issue. Fortunately there are two simple solutions to ensure the correct and
1163
- ! intended interpretation of values by the YAML schema used by
1164
- ! {\tt ESMF\_HConfig}:
1165
+ ! intended interpretation of values by {\tt ESMF\_HConfig}:
1165
1166
!
1166
1167
! \begin{enumerate}
1167
- ! \item Explicit quotation of strings. See for instance the {\em map value}
1168
- ! for {\tt value\_fourteen}, which is {\tt "NO"}, and is consequently
1169
- ! interpreted as a literal string, identified as {\tt tag:yaml.org,2002:str}.
1170
- !
1171
- ! \item Explicit standard tags. This option allows explicit specificaitonof any
1172
- ! tag and is discussed below.
1168
+ ! \item Explicit quotation of strings: See for instance the {\em map value}
1169
+ ! for {\tt value\_fourteen} in the current example. Using explicit quotes for
1170
+ ! {\tt "NO"}, the entry is safely interpreted as a literal string, and if
1171
+ ! queried for its tag, will return {\tt tag:yaml.org,2002:str}.
1172
+ !
1173
+ ! \item Explicit standard tags: This option allows explicit specificaiton of any
1174
+ ! tag, e.g. the standard short-hand tag {\tt !str} for literal strings. This
1175
+ ! approach is discussed in more detal below.
1173
1176
! \end{enumerate}
1174
1177
! EOE
1175
- #if 0
1176
1178
tag = ESMF_HConfigGetTag(hconfig, keyString= " value_fourteen" , rc= rc)
1177
1179
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1178
1180
write (msgString, ' ("value_fourteen HConfig tag: ", A30)' ) tag
1179
1181
call ESMF_LogWrite(trim (msgString), ESMF_LOGMSG_INFO, rc= rc)
1180
1182
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1181
- #endif
1182
1183
1183
- call ESMF_HConfigAdd(hconfig, addKeyString= " value_added" , content= " 'NO'" , &
1184
- rc= rc)
1184
+ call ESMF_HConfigAdd(hconfig, addKeyString= " value_added" ,content= " 'NO'" ,rc= rc)
1185
1185
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1186
1186
1187
1187
tag = ESMF_HConfigGetTag(hconfig, keyString= " value_added" , rc= rc)
@@ -1190,17 +1190,8 @@ program ESMF_HConfigEx
1190
1190
call ESMF_LogWrite(trim (msgString), ESMF_LOGMSG_INFO, rc= rc)
1191
1191
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1192
1192
1193
- call ESMF_HConfigLog(hconfig, prefix= " WithTags: " , rc= rc)
1194
- if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1195
-
1196
- #if 1
1197
- tag = ESMF_HConfigGetTag(hconfig, keyString= " value_fourteen" , rc= rc)
1193
+ call ESMF_HConfigLog(hconfig, prefix= " WithTagsFinish: " , rc= rc)
1198
1194
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1199
- write (msgString, ' ("value_fourteen HConfig tag: ", A30)' ) tag
1200
- call ESMF_LogWrite(trim (msgString), ESMF_LOGMSG_INFO, rc= rc)
1201
- if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag= ESMF_END_ABORT)
1202
- #endif
1203
-
1204
1195
! BOE
1205
1196
! \paragraph{Explicit standard tags}
1206
1197
! Standard short-hand tags can be specified to change the default resolution.
0 commit comments