original_docstring: 
      Parse the config_compiler.xml file into a Macros file for the
      given machine and compiler.
      
docstring: Parse the config_compiler.xml file into a Macros file for the
  given machine and compiler.
docstring_tokens: Parse the config_compiler . xml file into a Macros file for the given machine and compiler .
code: def write_macros_file_v1(macros, compiler, os_, machine, macros_file="Macros", output_format="make"):
      """
      Parse the config_compiler.xml file into a Macros file for the
      given machine and compiler.
      """
      # A few things can be used from environ if not in XML
      for item in ["MPI_PATH", "NETCDF_PATH"]:
          if not item in macros and item in os.environ:
              logger.warning("Setting {} from Environment".format(item))
              macros[item] = os.environ[item]
  
      with open(macros_file, "w") as fd:
          fd.write(
  """#
  # COMPILER={}
  # OS={}
  # MACH={}
  """.format(compiler, os_, machine)
  )
          if output_format == "make":
              fd.write("#\n# Makefile Macros \n")
  
              # print the settings out to the Macros file
              for key, value in sorted(macros.items()):
                  if key == "_COND_":
                      pass
                  elif key.startswith("ADD_"):
                      fd.write("{}+={}\n\n".format(key[4:], value))
                  else:
                      fd.write("{}:={}\n\n".format(key, value))
  
          elif output_format == "cmake":
              fd.write(
  '''#
  # cmake Macros generated from $compiler_file
  #
  set(CMAKE_MODULE_PATH %s)
  include(Compilers)
  set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "Flags used by c compiler." FORCE)
  set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Flags used by c compiler." FORCE)
  set(CMAKE_Fortran_FLAGS_RELEASE "" CACHE STRING "Flags used by Fortran compiler." FORCE)
  set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Flags used by Fortran compiler." FORCE)
  set(all_build_types "None Debug Release RelWithDebInfo MinSizeRel")
  set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${all_build_types}." FORCE)
  ''' % os.path.join(get_cime_root(), "src", "CMake"))
  
              # print the settings out to the Macros file, do it in
              # two passes so that path values appear first in the
              # file.
              for key, value in sorted(macros.items()):
                  if key == "_COND_":
                      pass
                  else:
                      value = value.replace("(", "{").replace(")", "}")
                      if key.endswith("_PATH"):
                          if value.startswith("$"):
                              value = "$ENV{}".format(value[1:])
  
  
                          cmake_var = key.replace("NETCDF_PATH", "NetCDF_PATH").replace("PNETCDF_PATH", "Pnetcdf_PATH")
                          fd.write("set({} {})\n".format(cmake_var, value))
                          fd.write("list(APPEND CMAKE_PREFIX_PATH {})\n\n".format(value))
  
              for key, value in sorted(macros.items()):
                  if key == "_COND_":
                      pass
                  else:
                      value = value.replace("(", "{").replace(")", "}")
                      if "CFLAGS" in key or "FFLAGS" in key or "CPPDEFS" in key or "SLIBS" in key or "LDFLAGS" in key:
                          if "shell " in value:
                              components = _get_components(value)
  
                              idx = 0
                              for is_shell, component in components:
                                  component = component.replace("NETCDF", "NetCDF").replace("PNETCDF_PATH", "Pnetcdf_PATH")
                                  if is_shell:
                                      fd.write('execute_process(COMMAND {} OUTPUT_VARIABLE TEMP{:d})\n'.format(component, idx))
                                      fd.write('string(REGEX REPLACE "\\n$" "" TEMP{:d} "${{TEMP{:d}}}")\n'.format(idx, idx))
                                  else:
                                      fd.write('set(TEMP{:d} "{}")\n'.format(idx, component))
  
                                  idx += 1
  
                              fd.write('set(TEMP "{}")\n'.format(" ".join(["${{TEMP{:d}}}".format(i) for i in range(idx)])))
                          else:
                              fd.write('set(TEMP "{}")\n'.format(value))
  
                          if "CFLAGS" in key:
                              fd.write("add_flags(CFLAGS ${TEMP})\n\n")
                          elif "FFLAGS" in key:
                              fd.write("add_flags(FFLAGS ${TEMP})\n\n")
                          elif "CPPDEFS" in key:
                              fd.write("list(APPEND CPPDEFS ${TEMP})\n\n")
                          elif "SLIBS" in key or "LDFLAGS" in key:
                              fd.write("add_flags(LDFLAGS ${TEMP})\n\n")
  
          # Recursively print the conditionals, combining tests to avoid repetition
          _parse_hash(macros["_COND_"], fd, 0, output_format)
code_tokens: def write_macros_file_v1 ( macros , compiler , os_ , machine , macros_file = "Macros" , output_format = "make" ) : for item in [ "MPI_PATH" , "NETCDF_PATH" ] : if not item in macros and item in os . environ : logger . warning ( "Setting {} from Environment" . format ( item ) ) macros [ item ] = os . environ [ item ] with open ( macros_file , "w" ) as fd : fd . write ( """#
  # COMPILER={}
  # OS={}
  # MACH={}
  """ . format ( compiler , os_ , machine ) ) if output_format == "make" : fd . write ( "#\n# Makefile Macros \n" ) for key , value in sorted ( macros . items ( ) ) : if key == "_COND_" : pass elif key . startswith ( "ADD_" ) : fd . write ( "{}+={}\n\n" . format ( key [ 4 : ] , value ) ) else : fd . write ( "{}:={}\n\n" . format ( key , value ) ) elif output_format == "cmake" : fd . write ( '''#
  # cmake Macros generated from $compiler_file
  #
  set(CMAKE_MODULE_PATH %s)
  include(Compilers)
  set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "Flags used by c compiler." FORCE)
  set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Flags used by c compiler." FORCE)
  set(CMAKE_Fortran_FLAGS_RELEASE "" CACHE STRING "Flags used by Fortran compiler." FORCE)
  set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Flags used by Fortran compiler." FORCE)
  set(all_build_types "None Debug Release RelWithDebInfo MinSizeRel")
  set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${all_build_types}." FORCE)
  ''' % os . path . join ( get_cime_root ( ) , "src" , "CMake" ) ) for key , value in sorted ( macros . items ( ) ) : if key == "_COND_" : pass else : value = value . replace ( "(" , "{" ) . replace ( ")" , "}" ) if key . endswith ( "_PATH" ) : if value . startswith ( "$" ) : value = "$ENV{}" . format ( value [ 1 : ] ) cmake_var = key . replace ( "NETCDF_PATH" , "NetCDF_PATH" ) . replace ( "PNETCDF_PATH" , "Pnetcdf_PATH" ) fd . write ( "set({} {})\n" . format ( cmake_var , value ) ) fd . write ( "list(APPEND CMAKE_PREFIX_PATH {})\n\n" . format ( value ) ) for key , value in sorted ( macros . items ( ) ) : if key == "_COND_" : pass else : value = value . replace ( "(" , "{" ) . replace ( ")" , "}" ) if "CFLAGS" in key or "FFLAGS" in key or "CPPDEFS" in key or "SLIBS" in key or "LDFLAGS" in key : if "shell " in value : components = _get_components ( value ) idx = 0 for is_shell , component in components : component = component . replace ( "NETCDF" , "NetCDF" ) . replace ( "PNETCDF_PATH" , "Pnetcdf_PATH" ) if is_shell : fd . write ( 'execute_process(COMMAND {} OUTPUT_VARIABLE TEMP{:d})\n' . format ( component , idx ) ) fd . write ( 'string(REGEX REPLACE "\\n$" "" TEMP{:d} "${{TEMP{:d}}}")\n' . format ( idx , idx ) ) else : fd . write ( 'set(TEMP{:d} "{}")\n' . format ( idx , component ) ) idx += 1 fd . write ( 'set(TEMP "{}")\n' . format ( " " . join ( [ "${{TEMP{:d}}}" . format ( i ) for i in range ( idx ) ] ) ) ) else : fd . write ( 'set(TEMP "{}")\n' . format ( value ) ) if "CFLAGS" in key : fd . write ( "add_flags(CFLAGS ${TEMP})\n\n" ) elif "FFLAGS" in key : fd . write ( "add_flags(FFLAGS ${TEMP})\n\n" ) elif "CPPDEFS" in key : fd . write ( "list(APPEND CPPDEFS ${TEMP})\n\n" ) elif "SLIBS" in key or "LDFLAGS" in key : fd . write ( "add_flags(LDFLAGS ${TEMP})\n\n" ) _parse_hash ( macros [ "_COND_" ] , fd , 0 , output_format )
short_docstring: Parse the config_compiler.xml file into a Macros file for the
  given machine and compiler.
short_docstring_tokens: Parse the config_compiler . xml file into a Macros file for the given machine and compiler .
comment: """
      Parse the config_compiler.xml file into a Macros file for the
      given machine and compiler.
      """$SEP$# A few things can be used from environ if not in XML$SEP$# print the settings out to the Macros file$SEP$# print the settings out to the Macros file, do it in$SEP$# two passes so that path values appear first in the$SEP$# file.$SEP$# Recursively print the conditionals, combining tests to avoid repetition