def METHOD_NAME(self, model, action):
    spec = self.spec
    satisfies = spec.satisfies
    fflags = [self.compiler.openmp_flag]
    cppflags = ["-D_MPI"]
    if satisfies("%gcc"):
        fflags.extend(
            [
                "-ffree-line-length-none",
                "-fconvert=big-endian",
                "-ffree-form",
                "-fdefault-real-8",
                "-fdefault-double-8",
            ]
        )
        cppflags.append("-DUNDERSCORE")
    elif satisfies("%fj"):
        fflags.extend(["-Free", "-Fwide", "-CcdRR8"])
    elif satisfies("%intel"):
        fflags.extend(["-convert big_endian", "-FR"])
        if satisfies("precision=double"):
            fflags.extend(["-r8"])
        cppflags.append("-DUNDERSCORE")
    targets = [
        "FC_PARALLEL={0}".format(spec["mpi"].mpifc),
        "CC_PARALLEL={0}".format(spec["mpi"].mpicc),
        "CXX_PARALLEL={0}".format(spec["mpi"].mpicxx),
        "FC_SERIAL={0}".format(spack_fc),
        "CC_SERIAL={0}".format(spack_cc),
        "CXX_SERIAL={0}".format(spack_cxx),
        "CFLAGS_OMP={0}".format(self.compiler.openmp_flag),
        "FFLAGS_OMP={0}".format(" ".join(fflags)),
        "CPPFLAGS={0}".format(" ".join(cppflags)),
        "PIO={0}".format(spec["parallelio"].prefix),
        "NETCDF={0}".format(spec["netcdf-c"].prefix),
        "NETCDFF={0}".format(spec["netcdf-fortran"].prefix),
    ]
    if satisfies("^parallelio+pnetcdf"):
        targets.append("PNETCDF={0}".format(spec["parallel-netcdf"].prefix))
    if self.spec.variants["precision"]:
        targets.extend(["PRECISION={0}".format(self.spec.variants["precision"].value)])
    if action == "all":
        # First try to guess by compiler name
        if os.path.basename(spack_fc) in self.make_target:
            action = os.path.basename(spack_fc)
        # Then overwrite with the optional variant if set
        if self.spec.variants["make_target"].value != "none":
            action = self.spec.variants["make_target"].value
    targets.extend(
        ["USE_PIO2=true", "CPP_FLAGS=-D_MPI", "OPENMP=true", "CORE={0}".format(model), action]
    )
    self.patch_makefile(action, targets)
    return targets