From cd395efc3b97a91e4f91fda73a4147b4da1b7f9c Mon Sep 17 00:00:00 2001 From: slowy07 Date: Wed, 9 Oct 2024 05:49:38 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20update=20repositori=20bellshade=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: slowy07 --- .gitattributes | 1 + .github/CODEOWNERS | 1 + .github/ISSUE_TEMPLATE/lain-lain.md | 19 +++++ .github/pull_request_template.md | 27 ++++++ .github/workflows/fortran_ci.yml | 37 ++++++++ CMakeLists.txt | 57 +++++++++++++ CODE_OF_CONDUCT.md | 128 ++++++++++++++++++++++++++++ CONTRIBUTING.md | 89 +++++++++++++++++++ SECURITY.md | 19 +++++ module/sorting/bubble_sort.f90 | 48 +++++++++++ 10 files changed, 426 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/lain-lain.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/fortran_ci.yml create mode 100644 CMakeLists.txt create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 SECURITY.md create mode 100644 module/sorting/bubble_sort.f90 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..5efa040 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @slowy07 diff --git a/.github/ISSUE_TEMPLATE/lain-lain.md b/.github/ISSUE_TEMPLATE/lain-lain.md new file mode 100644 index 0000000..d26c712 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/lain-lain.md @@ -0,0 +1,19 @@ +--- +name: Lain Lain +about: buat report deskripsi untuk pull request +title: Penambahan algoritma +labels: enhancement +assignees: '' + +--- + +## Description + + +## Saya Menggunakan + +OS : ``Linux / Windows / MacOS`` +Fortran: ``gfortran --version`` + +## tambahan lainnya + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..38c6498 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,27 @@ +## Deskripsi (Description) + + +## Checklist: +### Umum: + +- [ ] Saya menambah algoritma terbaru. +- [ ] Saya memperbaiki algoritma yang sudah ada. +- [ ] Saya memperbaiki dokumentasi. +- [ ] Saya menambah dokumentasi. + +### Contributor Requirements (Syarat Kontributor) dan Lain-Lain: + + - [ ] Saya sudah membaca (I have read) [CONTRIBUTING](https://github.com/bellshade/fortran/blob/main/CONTRIBUTING.md) dan sudah menyetujui semua syarat. + - [ ] Saya telah menambahkan docstring yang memberikan penjelasan maksud dari kode yang saya buat. + - [ ] Saya menggunakan bahasa Indonesia untuk memberikan penjelasan dari kode yang saya buat. + +## Environment + +Saya menggunakan (I'm using): + +- ``os`` = ``linux / windows / macOS`` +- ``gfortran`` = ``gfortran --version`` + + + +linked issue #NOMOR_ISSUE diff --git a/.github/workflows/fortran_ci.yml b/.github/workflows/fortran_ci.yml new file mode 100644 index 0000000..1f3a66d --- /dev/null +++ b/.github/workflows/fortran_ci.yml @@ -0,0 +1,37 @@ +name: fortranci + +on: [push, pull_request] + +env: + build_path: ${{github.workspace}}/build + +jobs: + build_and_testing: + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, ubuntu-24.04] + + steps: + - name: checkout kode + uses: actions/checkout@v4 + + - name: buat direktori build + run: cmake -E make_directory ${{env.build_path}} + + - name: konfigurasi cmake + working-directory: ${{env.build_path}} + run: cmake ../ + + - name: build path + working-directory: ${{env.build_path}} + run: cmake --build . + + - name: testing + working-directory: ${{env.build_path}} + run: ctest + + - name: jalankan testing contoh + working-directory: ${{env.build_path}} + run: make jalankan_semua_contoh diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..11b7f27 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minum_required(VERSION 3.16) +project(bellshadeFortran LANGUAGES Fortran) + +add_compile_option( + -Wall + -Wextra + -Wpedantic + -Waliasing + -Wconversion-extra + -Wimplicit-interface + -Wimplcit-procedure + -Wsuprising + -Werror +) + +function(source_fortran DIR SOURCES) + file(GLOB_RECURSE NEW_SOURCES "${DIR}/*.f90") + list(APPEND ${SOURCES} ${NEW_SOURCES}) + set(${SOURCES} ${${SOURCES}} PARENT_SCOPE) +endfunction() + +set(MODULE_SOURCES) +source_fortran(${CMAKE_SOURCE_DIR}/modules MODULE_SOURCES) +add_library(modules STATIC ${MODULE_SOURCES}) + +function(buat_nama_file_unik FILE_NAME OUTPUT_NAME) + file(RELATIVE_PATH REL_PATH "${CMAKE_SOURCE_DIR}" "${FILE_NAME}") + get_filename_component(CUR_EXT "${REL_PATH}" LAST_EXT) + string(REPLACE "/" "_" UNIQUE_NAME "${REL_PATH}") + string(REPLACE "${CUR_EXT}" "" UNIQUE_NAME "${UNIQUE_NAME}") + set(${OUTPUT_NAME} ${UNIQUE_NAME} PARENT_SCOPE) +endfunction() + +file(GLOB_RECURSE TEST_FILES "${CMAKE_SOURCE_DIR}/test/*.f90") + +foreach(TEST_FILE ${TEST_FILES}) + buat_nama_file_unik(${TEST_FILE} TEST_NAME) + add_executable(${TEST_NAME} ${TEST_FILE}) + target_link_libraries(${TEST_NAME} modules) + add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) +endforeach() + +file(GLOB_RECURSE EXAMPLE_FILES "${CMAKE_SOURCE_DIR}/contoh/*.f90") + +foreach(EXAMPLE_FILE ${EXAMPLE_FILES}) + buat_nama_file_unik(${EXAMPLE_FILE} EXAMPLE_NAME) + add_executable(${EXAMPLE_NAME} ${EXAMPLE_FILE}) + target_link_libraries(${EXAMPLE_NAME} modules) + list(APPEND EXAMPLE_NAME_LIST run_${EXAMPLE_NAME}) + add_custom_target(run_${EXAMPLE_NAME} + COMMAND ${EXAMPLE_NAME} + DEPENDS ${EXAMPLE_NAME} + COMMENT "Jalankan contoh: ${EXAMPLE_NAME}") +endforeach() + +enable_testing() +add_custom_target(jalankan_semua_contoh DEPENDS ${EXAMPLE_NAME_LIST}) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..e6c2831 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[Discord Channel WPU](http://discord.gg/S4rrXQU). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..06c7099 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,89 @@ +# *Contributing* + +***Contributor*** + +Kami sangat senang anda telah ikut berkontribusi dalam implementasi algortima, struktur data, atau memperbaiki *error*. +Semua boleh ikut berkontribusi sekecil apapun dengan pengecualian sebagai berikut: + +- Hasil pekerjaan kamu adalah buatan kamu sendiri dan tidak ada hak cipta dari orang lain. Jika kami menemukan kesamaan, maka tidak kami *merge*. +- Hasil kerja kamu akan berlisensi [MIT](LICENSE) ketika *pull request* kamu sudah di-*merge*. +- Hasil kerja kamu wajib mengikuti standar dan *style* koding dari kami. +- Hanya menerima *file* dengan ekstensi ``*.f90``, selain itu dibuat pengecualian dengan menjelaskan secara detail. + +**Apa itu algoritma?** + +Algoritma adalah satu atau lebih fungsi dan/atau kelas yang: + +- memiliki satu atau lebih *input*; +- melakukan beberapa internal kalkulasi atau manipulasi data; +- mengembalikan satu atau lebih nilai hasil; +- memiliki kekurangan minimal (contoh: `print`, `read`) terkecuali jika memperbaiki materi tutorial. + +**Coding Style bahasa Fotrtran** + +Kami ingin hasil perkerjaan anda mudah dibaca oleh orang lain; oleh karena itu, kami menyarankan kamu untuk mengikuti _fortran coding style_ resmi. + +- Menggunakan `index` atau `idx` daripada `i` dalam sebuah variabel di looping. +- Menggunakan `src` atau `dst` daripada variabel bernama `a` atau `b`. +- Menggunakan `remainder` daripada nama variabel `r`. + +Gunakan juga konsep akronim, contohnya: +```f90 +!! contoh disarankan +faktor_persekutuan_terbesar() +!! contoh tidak disarankan +fpb() +``` +> ![NOTE] +> Jika variable tersebut berasal dari konteks matematika atau tidak membingungkan dengan variabel lain, penggunaan variabel satu huruf diperbolehkan. + +> [!CAUTION] +> Hindari dari penggunaan library diluar dari standar fortran (pihak ketiga). + + +***Pull request* yang baik** + +Informasi: gunakan [*issue*](https://github.com/bellshade/fortran/issues) apabila ingin menambahkan kode atau implementasi algoritma, dll (*basic*) agar tidak ada konflik dengan *pull request* lainnya. Kamu juga bisa menggunakan issue jika kamu ada +kendala atau masalah ketika melakukan pull request. Kamu juga bisa bertanya pada forum discord **WPU** dan **Kelas Terbuka** perihal bellshade. + +- Lakukan penjelasan deskripsi perubahan yang anda lakukan pada repositori kami dengan membuat penjelasan di [*issue*](https://github.com/bellshade/fortran/issues). +- Setelah menjelaskan perubahan anda di [*issue*](https://github.com/bellshade/fortran/issues) kemudian lakukan *fork* pada repositori kami. +- Setelah melakukan *fork*, anda dibebaskan untuk mengubah atau menambah algoritma. + - Untuk *pull request* merubah atau memperbaiki, diusahakan kamu menerapkan algoritma yang lebih baik dan lebih mudah serta memeberikan penjelasan lebih detail alasan dari perubahaan tersebut lebih baik dari sebelumnya. +- Setelah merubah-rubah atau menambahkan algoritma serta melakukan tes lokal kode kamu, usahakan kamu membuat *local branch* baru: + ```bash + git checkout -b + git add . # atau git add nama_perubahan_kamu.f90 + git commit -m "feat: menambahkan algoritma terbaru" + ``` +- Lakukan *push* ke *branch* kamu dan kemudian *open pull request*. + + +**Saran pesan commit** + +- `feat:` untuk menambah algoritma atau tambahan lainnya; +- `fix:` untuk mengubah algoritma yang sudah ada atau memperbaiki; +- `docs:` untuk mengubah atau membuat dokumentasi; +- `add:` untuk menambah algoritma atau tambahan lainnya (opsional); + +Catatan: pesan commit harus menjelaskan perubahan secara singkat. + +Contoh yang benar: +- ☒ feat: test_x.f90 +- ☑ feat: tambah unittest untuk algoritma x + +Lebih lengkapnya bisa dilihat di: +- [EN](https://www.conventionalcommits.org/en/v1.0.0/) +- [ID](https://www.conventionalcommits.org/id/v1.0.0/) + +Pull request akan di-*merge* jika: + +- mengikuti standar dan arahan dari `CONTRIBUTING.md`; +- lulus tes dan cek dari beberapa tes yang sudah kami siapkan. + +**Tambahan**: + +- Jika ada kendala atau masalah dalam *pull request*, kamu bisa laporkan masalahnya dalam [issue](https://github.com/bellshade/fortran/issues). +- Jika ada tes yang tidak lewat atau gagal, kami akan cek kembali perubahan anda. + +Untuk *pull request*, disarankan untuk menjelaskan secara detail yang kamu ubah atau tambahkan, dan bersikap sopan serta selalu berterima kasih. Itu salah satu bentuk tata krama yang baik terhadap sesama *contributor* dan *programmer* lainnya. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..2cae293 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 14.2.x | :white_check_mark: | +| 13.2.x | :white_check_mark: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. diff --git a/module/sorting/bubble_sort.f90 b/module/sorting/bubble_sort.f90 new file mode 100644 index 0000000..29f6555 --- /dev/null +++ b/module/sorting/bubble_sort.f90 @@ -0,0 +1,48 @@ +!> Algoritma bubble sorting +!! implementasi bubble sorting + +module bubble_sort_module + !! mengatur agar semua dari variable dideklarasian secara eksplisit + !! akan dianggap sebagai error + implicit none + +contains + !! subrutin untuk mengurutkan koleksi menggunakan algoritma + !! bubble sorting + subroutine bubble_sort(collection) + !! deklarasi parameter dari `collection` sabagi array 1 dimensi + !! yang dimana nilainya bilangan real + real, dimension(:), intent(inout) :: collection + !! variabel integer untuk iterasi + integer :: i, j collection_size + !! variabel sementara untuk save yang nantinya + !! nilai yang akan ditukarkan + real :: temp + !! variabel logic untuk cek apakah ada swap pada iterasi + logical :: swapped + + !! menentukan ukuran array listnya + collection_size = size(collection) + + !! lakukan sorting + do j = collection_size - 1, 1, -1 + !! looping pertama: iterasi dari akhir koleksi ke awal + swapped = .false. + !! looping untuk ngebandingkan elemen berdekatan pada array indeks 1 sampai j + do i = 1, j + !! cek apakah elemen di posisi nilai i lebih besar dari elemen posisi i + 1 + if (collection(i) .gt. collection(i + 1)) then + !! simpan nilai elemen ke dalam variabel sementara + temp = collection(i) + !! mengganti elemen i dengan elemen di posisi `i + 1` + collection(i) = collection(i + 1) + !! memindahkan nilai dari `temp` ke posisi `i + 1` + collection(i + 1) = temp + + swapped = .true. + end if + end do + if (.not. swapped) exit + end do + end subroutine bubble_sort +end module bubble_sort_module