Skip to content

Commit

Permalink
delete makefile; edit CMake to add system check
Browse files Browse the repository at this point in the history
  • Loading branch information
han190 committed Mar 12, 2024
1 parent b64d8ee commit 4e9e166
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 153 deletions.
64 changes: 32 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ project(PE-Fortran VERSION 0.0.4
HOMEPAGE_URL https://github.com/han190/PE-Fortran
LANGUAGES Fortran)

if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0)
message(FATAL_ERROR gfortran >= ${CMAKE_Fortran_COMPILER_VERSION})
endif()
message(STATUS "Using gfortran ${CMAKE_Fortran_COMPILER_VERSION}.")

if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0)
message(FATAL_ERROR gfortran >= ${CMAKE_Fortran_COMPILER_VERSION})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Compiling in debug mode.")
set(CMAKE_Fortran_FLAGS "-g -O0 -Wall -Wextra -pedantic -fbounds-check \
-fimplicit-none -fPIC -Wno-uninitialized -fcheck=all -fbacktrace \
-ffree-form -fcheck=array-temps -Werror=implicit-interface \
-std=f2018 -march=native")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Compiling in release mode.")
set(CMAKE_Fortran_FLAGS "-O3 -march=native -std=f2018 -march=native")
endif()
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 2021.11)
message(FATAL_ERROR ifx >= ${CMAKE_Fortran_COMPILER_VERSION})
endif()
message(STATUS "Using ifx ${CMAKE_Fortran_COMPILER_VERSION}.")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Compiling in debug mode.")
set(CMAKE_Fortran_FLAGS "-O0 -warn all -check all,nouninit \
-g -traceback -no-simd -stand f18 -mtune=native")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Compiling in release mode.")
set(CMAKE_Fortran_FLAGS "-O1 -ipo -xHost -stand f18 -mtune=native")
endif()
endif()
message(STATUS "Using gfortran ${CMAKE_Fortran_COMPILER_VERSION}.")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Compiling in debug mode.")
set(CMAKE_Fortran_FLAGS "-g -O0 -Wall -Wextra -pedantic -fbounds-check \
-fimplicit-none -fPIC -Wno-uninitialized -fcheck=all -fbacktrace \
-ffree-form -fcheck=array-temps -Werror=implicit-interface \
-std=f2018 -march=native")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Compiling in release mode.")
set(CMAKE_Fortran_FLAGS "-O3 -march=native -std=f2018 -march=native")
endif()

elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")

if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 2021.11)
message(FATAL_ERROR ifx >= ${CMAKE_Fortran_COMPILER_VERSION})
endif()
message(STATUS "Using ifx ${CMAKE_Fortran_COMPILER_VERSION}.")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Compiling in debug mode.")
set(CMAKE_Fortran_FLAGS "-O0 -warn all -check all,nouninit \
-g -traceback -no-simd -stand f18 -mtune=native")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Compiling in release mode.")
set(CMAKE_Fortran_FLAGS "-O1 -ipo -xHost -stand f18 -mtune=native")
endif()

else()
message(FATAL_ERROR "Unsupported OS.")
endif()

# Build static library
Expand Down
112 changes: 0 additions & 112 deletions Makefile

This file was deleted.

20 changes: 11 additions & 9 deletions src/module_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ end function problem_found

!> Get arugment
subroutine get_arguments()
character(len=:), allocatable :: answer_sheet, data_directory, output_format
character(len=:), allocatable :: arguments(:), keywords(:)
character(len=:), allocatable :: argument, next_argument, messages(:)
character(len=:), allocatable :: answer_directory, data_directory
character(len=:), allocatable :: keywords(:), messages(:)
character(len=:), allocatable :: arguments(:), argument, next_argument
character(len=:), allocatable :: output_format
integer(int64) :: num_trails, selected
integer :: argument_counts, i
type(problem_type), allocatable :: problems(:)
Expand All @@ -112,8 +113,8 @@ subroutine get_arguments()

!> Default values
data_directory = default_data_directory
allocate (character(len=500) :: answer_sheet)
answer_sheet = "answer.log"
allocate (character(len=500) :: answer_directory)
answer_directory = "."
num_trails = 2
selected = 0
list_solved = .false.
Expand Down Expand Up @@ -146,9 +147,9 @@ subroutine get_arguments()
output_format = "('Data directory:', 1x, a)"
write (output_unit, output_format) trim(data_directory)
case ("-a", "--answer")
answer_sheet = next_argument
output_format = "('Answer sheet:', 1x, a)"
write (output_unit, output_format) trim(answer_sheet)
answer_directory = next_argument
output_format = "('Answer directory:', 1x, a)"
write (output_unit, output_format) trim(answer_directory)
case ("-l", "--list")
list_solved = .true.
case ("-v", "--version")
Expand Down Expand Up @@ -177,7 +178,8 @@ subroutine get_arguments()
return
end if
call solve_problems(problems, num_trails, selected)
if (selected == 0) call print_answers(problems, trim(answer_sheet))
if (selected == 0) call print_answers( &
& problems, trim(answer_directory)//"/answer.log")
end subroutine get_arguments

end module module_driver

0 comments on commit 4e9e166

Please sign in to comment.