COSIMA / libaccessom2

ACCESS-OM2 library
3 stars 7 forks source link

Check for comment in perturbation definition earlier #67

Open aidanheerdegen opened 3 years ago

aidanheerdegen commented 3 years ago

There was confusion from someone defining a perturbation. They got this error:

assertion failed: forcing_parse_field: wrong number of fields in perturbation definition, should be 5.

even though the perturbation definition seemed fine:

    {
      "filename": "INPUT/RYF.rlds.1990_1991.nc",
      "fieldname": "rlds",
      "cname": "lwfld_ai",
      "perturbations": [
        {
          "type": "offset",
          "dimension": "temporal",
          "value": "INPUT/RYF.rlds.1990_1991_wcwc10.nc",
          "calendar": "experiment"
        }
      ]
    },

The issue was a missing comment field, which is now mandatory, but the check for the comment is after this section https://github.com/COSIMA/libaccessom2/blob/a227a616fac7a7d4795d2ebcca750292b6004683/libforcing/src/forcing_config.F90#L331-L333 so never gets flagged, and the user does not know why their perturbation definition is incorrect.

I believe moving the assert block which checks for a comment to the beginning of the loop (say line 194) makes sense, and the rest of the logic can remain as-is.