<commit_before>## CMAKE Script for setting up the fortran compiling and linking flags for different operating systems and compilers

# Check if linux
if(UNIX AND NOT APPLE)
    set(LINUX TRUE)
endif()

# Make sure the build type is uppercase
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" BT)

IF(BT STREQUAL "RELEASE")
    SET(CMAKE_BUILD_TYPE RELEASE CACHE STRING
      "Choose the type of build, options are DEBUG, or RELEASE."
      FORCE)
ELSEIF(BT STREQUAL "DEBUG")
    SET (CMAKE_BUILD_TYPE DEBUG CACHE STRING
      "Choose the type of build, options are DEBUG, or RELEASE."
      FORCE)
ELSEIF(NOT BT)
    SET(CMAKE_BUILD_TYPE RELEASE CACHE STRING
      "Choose the type of build, options are DEBUG, or RELEASE."
      FORCE)
    MESSAGE(STATUS "CMAKE_BUILD_TYPE not given, defaulting to RELEASE.")
ELSE()
    MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE not valid, choices are DEBUG, or RELEASE.")
ENDIF(BT STREQUAL "RELEASE")

## Determine which fortran compiler we are using
# Get the Fortran Compiler used with cmake
get_filename_component (F90 ${CMAKE_Fortran_COMPILER} NAME)

# Get a tag corresponding to the compiler
string(REGEX MATCH "gfortran" F90tag ${F90})
if (NOT F90tag)
  string(REGEX MATCH "ifort" F90tag ${F90})
endif()


# Set gfortran compile flags
if (${F90tag} MATCHES "gfortran")
  MESSAGE(STATUS "Getting gfortran flags")
  
  set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -fopenmp -std=f2008ts -funroll-all-loops  -finline-functions -static-libgfortran -static-libgcc -ffree-line-length-none -fall-intrinsics")
  set (CMAKE_Fortran_FLAGS_DEBUG   "-O0 -fopenmp -std=f2008ts -fbacktrace -fbounds-check -Waliasing -Wampersand -Wconversion -Wsurprising -Wc-binding-type -Wintrinsics-std -Wtabs -Wintrinsic-shadow -Wline-truncation -Wtarget-lifetime -Wreal-q-constant -static-libgfortran -static-libgcc -ffree-line-length-none -fall-intrinsics")

elseif (${F90tag} MATCHES "ifort") 
  MESSAGE(STATUS "Getting ifort flags")

  if (WIN32)
    set (CMAKE_Fortran_FLAGS_RELEASE "-nologo -fpp -O3 -openmp -heap-arrays1024 -QaxCORE-AVX2,CORE-AVX-I,AVX,SSE4.2,SSSE3 -Qipo -fp:fast=2 -Qdiag-disable:remark -Qmkl")
    set (CMAKE_Fortran_FLAGS_DEBUG "-nologo -fpp -Od -openmp -heap-arrays1024 -traceback -CB -Qfp-stack-check -Qmkl -warn:all -warn:nounused")
  endif ()
  
  if (${LINIX})
  
  endif ()
  
  if (APPLE)
    set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -qopenmp -axCORE-AVX2,CORE-AVX-I,AVX,SSE4.2,SSSE3 -ipo -no-prec-div -fp-model fast=2 -mkl")
    set (CMAKE_Fortran_FLAGS_DEBUG "-Od -openmp -traceback -CB -fp-stack-check -gen-interfaces -warn interfaces -mkl")
  endif ()
endif()


##
## Display information to the user
##
MESSAGE(STATUS "Build type is ${CMAKE_BUILD_TYPE} use option -DCMAKE_BUILD_TYPE=[DEBUG RELEASE] to switch")

if(BT STREQUAL "RELEASE")
    MESSAGE(STATUS "Using the following compile flags ${CMAKE_Fortran_FLAGS_RELEASE}")
elseif(BT STREQUAL "DEBUG")
	MESSAGE(STATUS "Using the following compile flags ${CMAKE_Fortran_FLAGS_DEBUG}")
endif()


###
### Set the output directories for compiled libraries and module files.<commit_msg>Updated Mac compile flags<commit_after>## CMAKE Script for setting up the fortran compiling and linking flags for different operating systems and compilers

# Check if linux
if(UNIX AND NOT APPLE)
    set(LINUX TRUE)
endif()

# Make sure the build type is uppercase
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" BT)

IF(BT STREQUAL "RELEASE")
    SET(CMAKE_BUILD_TYPE RELEASE CACHE STRING
      "Choose the type of build, options are DEBUG, or RELEASE."
      FORCE)
ELSEIF(BT STREQUAL "DEBUG")
    SET (CMAKE_BUILD_TYPE DEBUG CACHE STRING
      "Choose the type of build, options are DEBUG, or RELEASE."
      FORCE)
ELSEIF(NOT BT)
    SET(CMAKE_BUILD_TYPE RELEASE CACHE STRING
      "Choose the type of build, options are DEBUG, or RELEASE."
      FORCE)
    MESSAGE(STATUS "CMAKE_BUILD_TYPE not given, defaulting to RELEASE.")
ELSE()
    MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE not valid, choices are DEBUG, or RELEASE.")
ENDIF(BT STREQUAL "RELEASE")

## Determine which fortran compiler we are using
# Get the Fortran Compiler used with cmake
get_filename_component (F90 ${CMAKE_Fortran_COMPILER} NAME)

# Get a tag corresponding to the compiler
string(REGEX MATCH "gfortran" F90tag ${F90})
if (NOT F90tag)
  string(REGEX MATCH "ifort" F90tag ${F90})
endif()


# Set gfortran compile flags
if (${F90tag} MATCHES "gfortran")
  MESSAGE(STATUS "Getting gfortran flags")
  
  set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -fopenmp -std=f2008ts -funroll-all-loops  -finline-functions -static-libgfortran -static-libgcc -ffree-line-length-none -fall-intrinsics")
  set (CMAKE_Fortran_FLAGS_DEBUG   "-O0 -fopenmp -std=f2008ts -fbacktrace -fbounds-check -Waliasing -Wampersand -Wconversion -Wsurprising -Wc-binding-type -Wintrinsics-std -Wtabs -Wintrinsic-shadow -Wline-truncation -Wtarget-lifetime -Wreal-q-constant -static-libgfortran -static-libgcc -ffree-line-length-none -fall-intrinsics")

elseif (${F90tag} MATCHES "ifort") 
  MESSAGE(STATUS "Getting ifort flags")

  if (WIN32)
    set (CMAKE_Fortran_FLAGS_RELEASE "-nologo -fpp -O3 -openmp -heap-arrays1024 -QaxCORE-AVX2,CORE-AVX-I,AVX,SSE4.2,SSSE3 -Qipo -fp:fast=2 -Qdiag-disable:remark -Qmkl")
    set (CMAKE_Fortran_FLAGS_DEBUG "-nologo -fpp -Od -openmp -heap-arrays1024 -traceback -CB -Qfp-stack-check -Qmkl -warn:all -warn:nounused")
  endif ()
  
  if (${LINIX})
  
  endif ()
  
  if (APPLE)
    set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -qopenmp -axCORE-AVX2,CORE-AVX-I,AVX,SSE4.2,SSSE3 -no-prec-div -fp-model fast=2")
    set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -qopenmp -traceback -CB -fp-stack-check -gen-interfaces -warn interfaces")
  endif ()
endif()


##
## Display information to the user
##
MESSAGE(STATUS "Build type is ${CMAKE_BUILD_TYPE} use option -DCMAKE_BUILD_TYPE=[DEBUG RELEASE] to switch")

if(BT STREQUAL "RELEASE")
    MESSAGE(STATUS "Using the following compile flags ${CMAKE_Fortran_FLAGS_RELEASE}")
elseif(BT STREQUAL "DEBUG")
	MESSAGE(STATUS "Using the following compile flags ${CMAKE_Fortran_FLAGS_DEBUG}")
endif()


###
### Set the output directories for compiled libraries and module files.
{'fraction_non_alphanumeric': 0.10854616895874264, 'fraction_numerical': 0.015880812049770793, 'mean_word_length': 4.387125220458554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4316581', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2145, 'n_words': 613}