HΦ  3.2.0
Add new parameter into modpara

You can set a value of parameters with a new keyword in modpara file by following way.

  • Define a new variable corresponding to the above parameter in struct.h file.
  • The value with the keyword are read by ReadDefFileNInt function in readdef.c.

    In the following, we describe the detail of the flow of reading the parameter.

    To read the parameter, the switch statement where iKWidx matches KWModPara is used. The detail of the reading flow in this function are described as follows.

  1. The first eight lines are header (not touch!).
    fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp); //1
    fgetsMPI(ctmp2, 256, fp);
    sscanf(ctmp2, "%s %d\n", ctmp, &itmp); //2
    fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp); //3
    fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp); //4
    fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp); //5
    fgetsMPI(ctmp2, 256, fp);
    sscanf(ctmp2, "%s %s\n", ctmp, X->CDataFileHead); //6
    fgetsMPI(ctmp2, 256, fp);
    sscanf(ctmp2, "%s %s\n", ctmp, X->CParaFileHead); //7
    fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp); //8
  2. Each line is read by fgetsMPI(ctmp2, 256, fp) function.
  3. The line is divided into keyword and number by using CheckWords function.

    For example, when you add new key word "NTest", you can get the value as follows:

    if (CheckWords(ctmp, "NTest") == 0) {
    X->NTest = (int) dtmp;
    }
See also
ReadDefFileNInt, CheckWords