-->

OpenSees Cloud

OpenSees AMI

PSA: OpenSees Commands Are Case Sensitive

11 Nov 2020 - Michael H. Scott


I recently had a conversation with an experienced OpenSees user who asked why distributed loads were not working on their elastic beam-column model. I initially thought something must have changed in GitHub, but was relieved when I looked at their input file and saw the following:

pattern Plain 2 Linear {
   eleLoad -ele 10020001 -type -BeamUniform -30.0
}

Do you see the error?

The eleLoad command recognizes '-beamUniform' and 'beamUniform', but not '-BeamUniform'. The capital 'B' throws off the strcmp inside the parsing function, which, to make matters worse, doesn’t return an error that the element load type is not recognized.

   const char* type = OPS_GetString();
   if (strcmp(type,"-beamUniform") == 0 ||
       strcmp(type,"beamUniform") == 0) {

       if (ndm == 2) {

There’s no built-in case insensitive string compare function in the C++ string library, or at least there wasn’t when we started writing the parsing functions. So strcmp got copied throughout OpenSees.

Changing all the calls to strcmp to a case insensitive version would be a major effort, so probably not one I will undertake. Shouting at your script is common, but do you want your script shouting things like '-BEAMUNIFORM' back at you?