Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/doc
/mod
*.txt
test/*.txt
example/*.txt
75 changes: 75 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
4 changes: 2 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
47 changes: 47 additions & 0 deletions scripts/sync_versions_and_years.py
Original file line number Diff line number Diff line change
@@ -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)
Loading