Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc698b56

Browse files
committed
snippets: state type
1 parent0e48862 commitc698b56

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

‎snippets/create_state_snippets.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Create code snippet images for the state type:
4+
"""
5+
6+
fromgenerate_code_imageimportcreate_snippet_from_file
7+
8+
# Modern Fortran version
9+
print("Creating snippet from state_type_wrapper.f90...")
10+
output=create_snippet_from_file(
11+
"state_type_example.f90",
12+
style="monokai",
13+
font_size=18
14+
)
15+
print(f"✅ Created:{output}\n")
16+
17+
print("Creating snippet from state_type_wrapper.f90...")
18+
output=create_snippet_from_file(
19+
"state_type_wrapper.f90",
20+
style="monokai",
21+
font_size=18
22+
)
23+
print(f"✅ Created:{output}\n")
24+
25+
print("🎉 Both dlargv snippets created successfully!")
26+
print(" - state_type_example.png")
27+
print(" - state_type_wrapper.png")

‎snippets/state_type_example.f90‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
elementalsubroutinehandle_gesv_info(this,info,lda,n,nrhs,err)
2+
character(len=*),intent(in):: this
3+
integer(ilp),intent(in):: info,lda,n,nrhs
4+
type(linalg_state_type),intent(out):: err
5+
6+
! Process output
7+
select case (info)
8+
case (0)
9+
! Success
10+
case (-1)
11+
err= linalg_state_type(this,LINALG_VALUE_ERROR,'invalid problem size n=',n)
12+
case (-2)
13+
err= linalg_state_type(this,LINALG_VALUE_ERROR,'invalid rhs size n=',nrhs)
14+
case (-4)
15+
err= linalg_state_type(this,LINALG_VALUE_ERROR,'invalid matrix size a=',[lda,n])
16+
case (-7)
17+
err= linalg_state_type(this,LINALG_ERROR,'invalid matrix size a=',[lda,n])
18+
case (1:)
19+
err= linalg_state_type(this,LINALG_ERROR,'singular matrix')
20+
case default
21+
err= linalg_state_type(this,LINALG_INTERNAL_ERROR,'catastrophic error')
22+
end select
23+
24+
endsubroutine handle_gesv_info

‎snippets/state_type_wrapper.f90‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
!> `state_type` defines a general state return type for a
2+
!> stdlib routine. State contains a status flag, a comment, and a
3+
!> procedure specifier that can be used to mark where the error happened
4+
type:: state_type
5+
6+
!> The current exit state
7+
integer(ilp):: state= STDLIB_SUCCESS
8+
9+
!> Message associated to the current state
10+
character(len=MSG_LENGTH):: message=repeat('',MSG_LENGTH)
11+
12+
!> Location of the state change
13+
character(len=NAME_LENGTH):: where_at=repeat('',NAME_LENGTH)
14+
15+
end type state_type
16+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp