code: def _add_resources(data, runtime):
      
      if "config" not in data:
          data["config"] = {}
      # Convert input resources, which may be a JSON string
      resources = data.get("resources", {}) or {}
      if isinstance(resources, six.string_types) and resources.startswith(("{", "[")):
          resources = json.loads(resources)
          data["resources"] = resources
      assert isinstance(resources, dict), (resources, data)
      data["config"]["resources"] = resources
      # Add in memory and core usage from CWL
      memory = int(float(runtime["ram"]) / float(runtime["cores"]))
      data["config"]["resources"].update({"default": {"cores": int(runtime["cores"]),
                                                      "memory": "%sM" % memory,
                                                      "jvm_opts": ["-Xms%sm" % min(1000, memory // 2),
                                                                      "-Xmx%sm" % memory]}})
      data["config"]["algorithm"]["num_cores"] = int(runtime["cores"])
      return data
docs: Merge input resources with current CWL runtime parameters.