It would be useful if there were a defined constant with the maximum
kim model string length, so it can be created properly for these sorts
character(len=MAX_KIM_MODEL_STR_LEN) :: model_str
kim_error = kim_api_get_model_kim_str(trim(this%KIM_model_name), model_str)
I think KIM_KEY_STRING_LENGTH is what you want (which is 128 I think). See KIM_API_C.h:#define KIM_KEY_STRING_LENGTH 128.
Hi Noam and David.
KIM_KEY_STRING_LENGTH is a constant that is defined and is a valid max length for most strings that the KIM API deals with.
However, this is not the case for the string returned by the KIM_API_get_model_kim_str() routine. This string can be of arbitrary length (in principal). It is a verbatim copy of the Model's ".kim" file (including comments, blank lines, etc.)
In the future, this routine will be deprecated in favor of a more programatic interface to access the content of the Model's ".kim" file. Thus, KIM_API_get_model_kim_str() should be viewed as a stop-gap measure to provide some access to this information (albeit inconvenient access). This means that the use of KIM_API_get_model_kim_str() is discouraged. However, it does make sense that, while the function is in the KIM API, the KIM API provide access to the length of the string that will be returned by a call to KIM_API_get_model_kim_str().
I can easily add such a function. I've put it on my todo list and I'll expect to include this in the next release of the KIM API.