-
Notifications
You must be signed in to change notification settings - Fork 18
Add additional unit tests #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sam Clarke-Green (t00sa)
merged 30 commits into
MetOffice:main
from
r-sharp:add-additional-unit-tests
Apr 30, 2026
Merged
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
09510e0
Some initial drafts
r-sharp 7784b5f
some working, but very messy examples
r-sharp e626a32
Some tidying, and some questions for tomorrow.
r-sharp f71e30d
Twiddling things, it works, but is "useless"
r-sharp 7134e81
Adding copyright checker.
r-sharp 4ba0e8d
improve error messages
r-sharp 89db21a
Minor fixes for missing config owner (#218)
james-bruten-mo 7bbecff
Aaaarrrrrrrrgle!!!!!!!
r-sharp f16a1fa
Merge branch 'MetOffice:main' into add-additional-unit-tests
r-sharp de71e6c
testing built in helper functions and trying to concattenate lines
r-sharp 1c7c589
Adding line length check
r-sharp cd2b864
Adding re-worked tests to checker so they get run.
r-sharp 5e01490
converting dictionaries of callable tests to lists
r-sharp d2de828
Bit of a TODO and redundant code tidy
r-sharp 1713ac1
missed a bit...
r-sharp 2a33be3
Stop ruff from trying to correct the demo Fortran file
r-sharp e8f9b5c
Adding single programming module tests and adjusting TODOs a bit more.
r-sharp ae4e58a
Quick Tidy of an output failure message.
r-sharp 5f1d9c0
Updating the Fortran file editing routine to add or replace with mult…
r-sharp 02c663b
skinning the Latte.
r-sharp 6c543ea
Tidying up redundant tests
r-sharp db52136
Merge branch 'MetOffice:main' into add-additional-unit-tests
r-sharp f323196
A mild tidy, and a deliberate test for l_some_logical = .FALSE. as hi…
r-sharp 5afa827
It is well documented that I hate ruff, but when I find out who keeps…
r-sharp 6a708aa
Linter loonacy.
r-sharp ed1a09d
to requote : "I hate ruff"
r-sharp 35f68e9
Merge branch 'main' into add-additional-unit-tests
r-sharp 3e69e15
Apply suggestions from code review
r-sharp 89719c1
Trying to pass the unit tests....
r-sharp deff956
Fungle Worzle Aardvark Frakkin' Apostorphes
r-sharp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from pathlib import Path | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def example_fortran_lines() -> list[str]: | ||
| """Return the example Fortran source as a list of lines for tests.""" | ||
| test_dir = Path(__file__).resolve().parent | ||
| return (test_dir / "example_fortran_code.F90").read_text().splitlines() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| ! fortls: ignore file | ||
| ! fortitude: ignore file | ||
| ! *****************************COPYRIGHT******************************* | ||
| ! (C) Crown copyright Met Office. All rights reserved. | ||
| ! For further details please refer to the file COPYRIGHT.txt | ||
| ! which you should have received as part of this distribution. | ||
| ! *****************************COPYRIGHT******************************* | ||
| ! | ||
| ! An example routine depicting how one should construct new code | ||
| ! to meet the UMDP3 coding standards. | ||
| ! | ||
| MODULE example_mod | ||
| IMPLICIT NONE | ||
| ! Description: | ||
| ! A noddy routine that illustrates the way to apply the UMDP3 | ||
| ! coding standards to new code to help code developers | ||
| ! pass code reviews. | ||
| ! | ||
| ! Method: | ||
| ! In this routine we apply many of the UMDP3 features | ||
| ! to construct a simple routine. The references on the RHS take the reader | ||
| ! to the appropriate section of the UMDP3 guide with further details. | ||
| ! | ||
| ! Code Owner: Please refer to the UM file CodeOwners.txt | ||
| ! This file belongs in section: Control | ||
| ! | ||
| ! Code description: | ||
| ! Language: Fortran 2003. | ||
| ! This code is written to UMDP3 standards. | ||
| CHARACTER(LEN=*), PARAMETER, PRIVATE :: ModuleName="EXAMPLE_MOD" | ||
| CONTAINS | ||
| ! Subroutine Interface: | ||
| SUBROUTINE example (xlen,ylen,l_unscale,input1,input2, & | ||
| output, l_loud_opt) | ||
| ! Description: | ||
| ! Nothing further to add to module description. | ||
| USE atmos_constants_mod, ONLY: r | ||
| USE ereport_mod, ONLY: ereport | ||
| USE parkind1, ONLY: jpim, jprb | ||
| USE umprintMgr, ONLY: umprint,ummessage,PrNorm | ||
| USE errormessagelength_mod, ONLY: errormessagelength | ||
| USE yomhook, ONLY: lhook, dr_hook | ||
| IMPLICIT NONE | ||
| ! Subroutine arguments | ||
| INTEGER, INTENT(IN) :: xlen !Length of first dimension of the arrays. | ||
| INTEGER, INTENT(IN) :: ylen !Length of second dimension of the arrays. | ||
| LOGICAL, INTENT(IN) :: l_unscale ! switch scaling off. | ||
| REAL, INTENT(IN) :: input1(xlen, ylen) !First input array | ||
| REAL, INTENT(IN OUT) :: input2(xlen, ylen) !Second input array | ||
| REAL, INTENT(OUT) :: output(xlen, ylen) !Contains the result | ||
| LOGICAL, INTENT(IN), OPTIONAL :: l_loud_opt !optional debug flag | ||
| ! Local variables | ||
| INTEGER(KIND=jpim), PARAMETER :: zhook_in = 0 ! DrHook tracing entry | ||
| INTEGER(KIND=jpim), PARAMETER :: zhook_out = 1 ! DrHook tracing exit | ||
| INTEGER :: i ! Loop counter | ||
| INTEGER :: j ! Loop counter | ||
| INTEGER :: icode ! error code for EReport | ||
| LOGICAL :: l_loud ! debug flag (default false unless l_loud_opt is used) | ||
| REAL, ALLOCATABLE :: field(:,:) ! Scaling array to fill. | ||
| REAL, ALLOCATABLE :: field2(:,:) ! Scaling array to fill. | ||
| REAL(KIND=jprb) :: zhook_handle ! DrHook tracing | ||
| CHARACTER(LEN=*), PARAMETER :: RoutineName="EXAMPLE" | ||
| CHARACTER(LEN=errormessagelength) :: Cmessage ! used for EReport | ||
| CHARACTER(LEN=256) :: my_char ! string for output | ||
| ! End of header | ||
| IF (lhook) CALL dr_hook(ModuleName//":"//RoutineName,zhook_in,zhook_handle) | ||
| ! Set debug flag if argument is present | ||
| l_loud = .FALSE. | ||
| IF (PRESENT(l_loud_opt)) THEN | ||
| l_loud = l_loud_opt | ||
| END IF | ||
| my_char & | ||
| = "This is a very very very very very very very " & | ||
| // "long character assignment" ! A pointless long character example. | ||
| icode=0 | ||
| ! verbosity choice, output some numbers to aid with debugging | ||
| ! protected by printstatus>=PrNorm and pe=0 | ||
| WRITE(ummessage,"(A,I0)")"xlen=",xlen | ||
| CALL umprint(ummessage,level=PrNorm,pe=0,src="example_mod") | ||
| WRITE(ummessage,"(A,I0)")"ylen=",ylen | ||
| CALL umprint(ummessage,level=PrNorm,pe=0,src="example_mod") | ||
| IF (l_loud) CALL umprint(my_char,level=PrNormal,src="example_mod") | ||
| ! Allocate and initialise scaling array | ||
| ! Noddy code warns user when scalling is not employed. | ||
| IF ( l_unscale ) THEN | ||
| icode = -100 ! set up WARNING message | ||
| ALLOCATE(field( 1,1 ) ) | ||
| ALLOCATE(field2( 1,1 ) ) | ||
| cmessage="Scaling is switched off in run!" | ||
| CALL ereport(RoutineName,icode,cmessage) | ||
| ELSE | ||
| ALLOCATE(field( xlen, ylen ) ) | ||
| ALLOCATE(field2( xlen, ylen ) ) | ||
| DO j=1,ylen | ||
| DO i=1,xlen | ||
| field(i, j) = (1.0*i) + (2.0*j) | ||
| input2(i, j) = input2(i, j) * field(i, j) | ||
| field2(i, j) = (1.0*i) - (2.0*j) & | ||
| + (3.0*i*j) + (4.0*i**2) + field(i, j)*2 | ||
| END DO | ||
| END DO | ||
| END IF | ||
| ! The main calculation of the routine, using OpenMP. | ||
| !$OMP PARALLEL DEFAULT(NONE) & | ||
| !$OMP SHARED(xlen,ylen,input1,input2,field,output) & | ||
| !$OMP PRIVATE(i, j ) | ||
| !$OMP DO SCHEDULE(STATIC) | ||
| DO j = 1, ylen | ||
| i_loop: DO i = 1, xlen | ||
| ! Calculate the Output value: | ||
| output(i, j) = (input1(i, j) * input2(i, j)) | ||
| END DO i_loop | ||
| END DO ! j loop | ||
| !$OMP END DO | ||
| !$OMP END PARALLEL | ||
| DEALLOCATE (field) | ||
| IF (lhook) CALL dr_hook(ModuleName//":"//RoutineName,zhook_out,zhook_handle) | ||
| RETURN | ||
| END SUBROUTINE example | ||
| END MODULE example_mod |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.