Skip to content

Commit

Permalink
DOC: Add documentation of format command
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Sep 12, 2024
1 parent cd68f8f commit 12e0766
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/seacas/doc-source/aprepro/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ \section{Mathematical Functions}
exodus\_meta(filename) & Open the \exo{} file and create several variables based on the metadata in the \exo{} file. \\
extract(s, b, e) & Return substring \var{[b,e)}. \var{b} is included; \var{e} is not. If \var{b} not found, return empty; If \var{e} not found, return rest of string. If \var{b} empty, start at beginning; if \var{e} empty, return rest of string. \\
file\_to\_string(fn)& Opens the file specified by \var{fn} and returns the contents as a multi-line string. \\
format(var, format) & Returns a string representing the double value \var{var} printed using the format specified in \var{format}. \\
get\_date() & Returns a string representing the current date in the form YYYY/MM/DD. \\
get\_iso\_date() & Returns a string representing the current date in the form YYYYMMDD. \\
get\_time() & Returns a string representing the current time in the form HH:MM:SS. \\
Expand Down
27 changes: 17 additions & 10 deletions packages/seacas/doc-source/aprepro/predefined_variables.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,33 @@ \chapter{Predefined Variables}\label{ch:predefined}
TRUE & 1 & \\
FALSE & 0 & \\
\_VERSION\_ & Varies, string value & current version of \aprepro \\
\_FORMAT& \texttt{"}\%.10g\texttt{"} & default output format \\
\_C\_ & \texttt{"}\$\texttt{"} & default comment character \\
\_FORMAT& \texttt{"\%.10g"} & default output format \\
\_C\_ & \texttt{"\$"} & default comment character \\
\end{longtable}

Note that the output format is used to output both integers and
floating point numbers. Therefore, it should use the \%g format
descriptor which will use either the decimal (\%d), exponential (\%e),
or float (\%f) format, whichever is shorter, with insignificant zeros
suppressed. If the output format is set to the empty string, the the
output will use as many variables as needed to fully represent the
double precision value.
floating point numbers. Therefore, it should use the \texttt{\%g} format
descriptor which will use either the decimal (\texttt{\%d}), exponential (\texttt{\%e}),
or float (\texttt{\%f}) format, whichever is shorter, with insignificant zeros
suppressed.

If the output format is set to the empty string, the output will use
as many variables as needed to fully represent the double precision
value. This can be selected at startup time using the command-line
option \textbf{--full\_precision} or \textbf{-p}.

The table below illustrates the effect of different format
specifications on the output of the variable \textbf{PI} and the value
1.0 . See the documentation of your C compiler for more
information. For most cases, the default value is sufficient.

If you need to temporarily change the output format for a specific
case, you can use the \cmd{format(var, format)} command which will
return a string representing \var{var} printed using the format
specified in \var{format}.
\begin{longtable}{lll}
\caption{Effect of various output format specifications}\\
Format & PI Output & 1.0 Output \\
\var{\_FORMAT} & PI Output & 1.0 Output \\
\hline
\%.10g & 3.141592654 & 1 \\
\%.10e & 3.1415926536e+00 & 1.0000000000e+00 \\
Expand All @@ -56,7 +63,7 @@ \chapter{Predefined Variables}\label{ch:predefined}

The comment character should be set to the character that the program
which will read the processed file uses as a comment character. The
default value of \texttt{"}\$\texttt{"} is the comment character used
default value of \texttt{"\$"} is the comment character used
by the SEACAS codes at Sandia National Laboratories. The \textbf{-c}
command line option (described in Chapter~\ref{ch:execution}) changes
the value of the comment variable to match the character specified on
Expand Down

0 comments on commit 12e0766

Please sign in to comment.