diff --git a/.gitignore b/.gitignore index 7dd235c..904640e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /build /doc /mod -*.txt \ No newline at end of file +test/*.txt +example/*.txt \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..de501f3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.18) +project(fortime LANGUAGES Fortran) + +# Metadata +set(PROJECT_VERSION "0.6.1") +set(PROJECT_LICENSE "BSD 3-Clause License") +set(PROJECT_AUTHOR "Seyed Ali Ghasemi") + +# Fortran settings +enable_language(Fortran) +set(CMAKE_Fortran_STANDARD 2008) +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod) + +# Dependencies +include(FetchContent) + +# FACE dependency +FetchContent_Declare( + FACE + GIT_REPOSITORY https://github.com/szaghi/FACE.git +) +FetchContent_MakeAvailable(FACE) + +# forunittest (only for testing) +FetchContent_Declare( + forunittest + GIT_REPOSITORY https://github.com/gha3mi/forunittest.git + GIT_TAG main +) +FetchContent_MakeAvailable(forunittest) + +# Source files +file(GLOB_RECURSE SOURCES src/*.f90) +set_source_files_properties(${SOURCES} PROPERTIES Fortran_PREPROCESS ON) + +add_library(fortime ${SOURCES}) +target_include_directories(fortime PUBLIC ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_link_libraries(fortime PUBLIC FACE) + +# Optional: Enable OpenMP support +find_package(OpenMP) +if(OpenMP_Fortran_FOUND) + target_link_libraries(fortime PUBLIC OpenMP::OpenMP_Fortran) + target_compile_definitions(fortime PUBLIC USE_OMP) +endif() + +# Optional: Enable MPI support +find_package(MPI) +if(MPI_Fortran_FOUND) + target_link_libraries(fortime PUBLIC MPI::MPI_Fortran) + target_compile_definitions(fortime PUBLIC USE_MPI) +endif() + +# Examples +file(GLOB EXAMPLES example/example*.f90) +foreach(example_file ${EXAMPLES}) + get_filename_component(example_name ${example_file} NAME_WE) + add_executable(${example_name} ${example_file}) + target_link_libraries(${example_name} PRIVATE fortime) +endforeach() + +# Tests (if any) +enable_testing() +file(GLOB TEST_SOURCES test/test*.f90) +foreach(test_file ${TEST_SOURCES}) + get_filename_component(test_name ${test_file} NAME_WE) + set_source_files_properties(${test_file} PROPERTIES Fortran_PREPROCESS ON) + add_executable(${test_name} ${test_file}) + target_link_libraries(${test_name} PRIVATE fortime forunittest) + set_target_properties(${test_name} PROPERTIES + Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod/test + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test + ) + add_test(NAME ${test_name} COMMAND ${CMAKE_BINARY_DIR}/test/${test_name}) +endforeach() diff --git a/VERSION b/VERSION index 09a3acf..7ceb040 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.0 \ No newline at end of file +0.6.1 \ No newline at end of file diff --git a/fpm.toml b/fpm.toml index 2bbe080..50e93ff 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,5 +1,5 @@ name = "fortime" -version = "0.6.0" +version = "0.6.1" license = "BSD 3-Clause License" author = "Seyed Ali Ghasemi" maintainer = "info@gha3mi.com" @@ -63,7 +63,7 @@ main = "example6.f90" [extra.ford] project = "ForTime" -version = "0.6.0" +version = "0.6.1" year = "2023-2025" project_github = "https://github.com/gha3mi/fortime" author = "Seyed Ali Ghasemi" diff --git a/scripts/sync_versions_and_years.py b/scripts/sync_versions_and_years.py new file mode 100644 index 0000000..686476c --- /dev/null +++ b/scripts/sync_versions_and_years.py @@ -0,0 +1,47 @@ +import re +from datetime import datetime + +with open('VERSION', 'r') as f: + new_version = f.read().strip() + +current_year = datetime.now().year + +# --- Update fpm.toml --- +with open('fpm.toml', 'r') as f: + content = f.read() + +# Update version fields +content = re.sub( + r'(version\s*=\s*)"[0-9]+\.[0-9]+\.[0-9]+"', + rf'\1"{new_version}"', + content +) +content = re.sub( + r'(\[extra\.ford\].*?version\s*=\s*)"[0-9]+\.[0-9]+(\.[0-9]+)?"', + rf'\1"{new_version}"', + content, + flags=re.DOTALL +) + +# Update year ranges only +content = re.sub( + r'(\d{4})-(\d{1,4})', + lambda m: f'{m.group(1)}-{current_year}' if len(m.group(2)) != 4 or int(m.group(2)) != current_year else m.group(0), + content +) + +with open('fpm.toml', 'w') as f: + f.write(content) + +# --- Update CMakeLists.txt --- +with open('CMakeLists.txt', 'r') as f: + cmake_content = f.read() + +cmake_content = re.sub( + r'(set\(PROJECT_VERSION\s+")\d+\.\d+\.\d+("\))', + rf'\g<1>{new_version}\2', + cmake_content +) + +with open('CMakeLists.txt', 'w') as f: + f.write(cmake_content)