Wiki
Clone wikipflotran / Developers / CodeDevelopment / KeywordLogging
Keyword Logging
Keyword logging tracks the "stack" of input deck keywords during simulation initialization.
Error Messaging
The keyword stack information is leveraged for more accurate error messaging. E.g.
------------------------------------------------------------------------------ Helpful information for debugging the input deck: Filename : regional_doublet.in Line Number : 339 Keyword : SUBSURFACE,FLOW_CONDITION,TYPE,RATE,SCALED_VOLUMETRIC_RATE,NEIGHBOR_PERMS ------------------------------------------------------------------------------ ERROR: Keyword "NEIGHBOR_PERMS" not recognized in flow condition "extraction" scaled_volumetric_rate.
Screen Output
When each keyword is read from the input deck, the current stack can be printed to the screen by appending -keyword_screen_output to the command line. E.g.
... pflotran card:: FLOW_CONDITION injection KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE,RATE KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE,RATE,SCALED_VOLUMETRIC_RATE KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE,RATE,SCALED_VOLUMETRIC_RATE,NEIGHBOR_PERM KEYWORD: SUBSURFACE,FLOW_CONDITION,RATE KEYWORD: SUBSURFACE,FLOW_CONDITION pflotran card:: FLOW_CONDITION extraction KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE,RATE KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE,RATE,SCALED_VOLUMETRIC_RATE KEYWORD: SUBSURFACE,FLOW_CONDITION,TYPE,RATE,SCALED_VOLUMETRIC_RATE,NEIGHBOR_PERMS
Implementation in the Source Code
Keyword logging is implemented through a combination of calls to InputPushBlock(), InputPopBlock(), InputReadCard() and InputPushCard() and keyword storage in two strings: keyword_log and keyword_buf.
- keyword_log stores a permanent comma-delimited stack
- keyword_buf is a buffer that stores a temporary comma-delimited stack
- InputPushBlock() appends the contents of keyword_buf to keyword_log, and keyword_buf is erased.
- InputPopBlock() removes the last entry from keyword_log and erases keyword_buf. The contents of keyword_log and keyword_buf are concatenated when the stack is printed to the screen.
- InputReadCard() reads a keyword from the input file and appends it to keyword_buf.
- InputCheckExit() erases keyword_buf, allowing for a clean buffer at the top of a do loop that reads cards.
Examples
Input File Block To Be Read
GRID TYPE STRUCTURED
Source Code
! keyword_log = '' call InputPushBlock(input,option) ! keyword_buf = '' do call InputReadPflotranString(input,option) ! input%buf = 'GRID' ... if (InputCheckExit(input,option)) exit ! keyword_buf = '' ... call InputReadCard(input,option,keyword) ! keyword_buf = 'GRID' ... ScreenPrintout: GRID ... select case(keyword) case('GRID') call InputPushBlock(input,option) ! keyword_log = 'GRID' do ! keyword_buf = '' call InputReadPflotranString(input,option) ! input%buf = 'TYPE STRUCTURED' ... if (InputCheckExit(input,option)) exit ! keyword_buf = '' ... call InputReadCard(input,option,keyword) ! keyword_buf = 'TYPE' ... ScreenPrintout: GRID,TYPE ... select case(keyword) ! input%buf = 'STRUCTURED' case('TYPE') call InputReadCard(input,option,keyword) ! keyword_buf = 'TYPE,STRUCTURED' ... end select ScreenPrintout: GRID,TYPE,STRUCTURED enddo call InputPopBlock(input,option) ! keyword_log = 'GRID' end select ! keyword_buf = '' ... enddo call InputPopBlock(input,option) ! keyword_log = '' ! keyword_buf = ''
There are places where a combination of InputReadWord() and InputPushCard() should be used instead of InputReadCard(). An example is when a keyword or number could be read at the same location in the input deck. E.g.
Input File Block To Be Read
FLOW_CONDITION ... PRESSURE DATASET
versus
FLOW_CONDITION ... PRESSURE 101325.
Source Code
call InputReadWord(input,option,keyword,PETSC_TRUE) ... if (StringStartsWithAlpha(keyword)) then call InputPushCard(input,keyword,option) ... else call InputReadDouble(keyword,option,value,ierr) endif
Updated