Loading, saving, printing
load
fortran
call fini%load([filename=] [, source=] [, separator=] [, error=])| Argument | Type | |
|---|---|---|
filename | character(*), in | the file to read; it is stored in fini%filename |
source | character(*), in | a string holding the whole file, lines separated by new_line('a') |
separator | character(1), in | the separator of names and values, = by default |
error | integer(I4P), out | 0, the I/O status of a failed read, or ERR_SOURCE_MISSING |
filenametakes precedence oversource. With neither,loadreadsfini%filenameif it is set (by an earlierload,saveorinitialize, or by hand).- The new sections replace all the sections of
fini. If the file cannot be read,finikeeps its sections anderrorholds the I/O status (not zero). errorisERR_SOURCE_MISSINGwhen there is nothing to read: no source, or a source with no option and no section.- The separator is remembered by
finifor the followingloadcalls that do not pass one.
save
fortran
call fini%save([filename=] [, retain_comments=] [, iostat=] [, iomsg=])| Argument | Type | |
|---|---|---|
filename | character(*), in | the file to write (created or replaced); it is stored in fini%filename |
retain_comments | logical, in | write the inline comments back, .false. by default |
iostat | integer(I4P), out | 0, or the status of the first operation that failed |
iomsg | character(*), out | the message of that failure |
- Without
filename,savewritesfini%filename. With neither, nothing is written andiostatisERR_SOURCE_MISSING. - A
finiwithout sections writes nothing: the file is neither created nor truncated, andiostatis0. iostatis the status of the firstopen,writeorclosethat failed: a file that cannot be opened (a missing directory, no permission) is reported, and nothing is written after it.- What
savewrites: options asname = value, comment lines dropped, continuations joined.
print
fortran
call fini%print(unit= [, pref=] [, retain_comments=] [, iostat=] [, iomsg=])| Argument | Type | |
|---|---|---|
unit | integer(I4P), in | an open unit, 6 (or output_unit) for the standard output |
pref | character(*), in | a prefix written at the start of every line |
retain_comments | logical, in | print the inline comments, .false. by default |
iostat, iomsg | out | as for save: 0 when nothing failed (also when there is nothing to print) |
print writes what save writes, each option indented by two blanks, each line after pref.
The file name, initialize and free
fini%filenameis a publiccharacter(len=:), allocatablemember:load(filename=)andsave(filename=)set it, and you can set it by hand.initialize([filename=])emptiesfini(asfree) and setsfilename.free()deletes every section and option, the file name, and the separator (back to=).
Copying
b = a makes b an independent copy of a: its file name, separator, sections and options. Changing one does not change the other.