Skip to content

Commit e0ed1bd

Browse files
committed
Add hypothetical page for fortran with failing checks
1 parent 3f63019 commit e0ed1bd

File tree

3 files changed

+185
-0
lines changed

3 files changed

+185
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
program clickhouse_example
2+
use clickhouse_driver
3+
implicit none
4+
5+
type(ClickHouseClient) :: client
6+
type(QueryResult) :: result
7+
integer :: status, i
8+
9+
! Initialize and connect to ClickHouse
10+
call client%init('localhost', port=9000, database='default', &
11+
user='default', password='')
12+
13+
status = client%connect()
14+
if (status /= CH_SUCCESS) then
15+
print *, 'Connection failed!'
16+
stop
17+
end if
18+
19+
print *, 'Connected to ClickHouse successfully'
20+
21+
! Execute a simple query
22+
call client%execute('SELECT version()', result)
23+
call result%print()
24+
25+
! Cleanup
26+
call result%free()
27+
call client%disconnect()
28+
29+
end program clickhouse_example
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
sidebar_label: 'Fortran'
3+
keywords: ['Fortran', 'driver', 'language client']
4+
slug: /integrations/language-client/fortran
5+
description: 'The official Fortran client for connecting to ClickHouse.'
6+
title: 'ClickHouse Fortran driver'
7+
doc_type: 'guide'
8+
integration:
9+
- support_level: 'core'
10+
- category: 'language_client'
11+
- website: 'https://github.com/ClickHouse/fortran'
12+
---
13+
14+
import Tabs from '@theme/Tabs';
15+
import TabItem from '@theme/TabItem';
16+
17+
# ClickHouse Fortran driver
18+
19+
Key Features:
20+
21+
- Native TCP protocol support for optimal performance
22+
- Column-oriented data transfer compatible with Fortran arrays
23+
- Support for modern Fortran standards (Fortran 90/95/2003/2008)
24+
- Efficient handling of [numerical data types](/sql-reference/data-types/int-int) commonly used in scientific computing
25+
- TLS/SSL connection support
26+
- Parameterized query execution
27+
- Batch insert operations optimized for large datasets
28+
29+
## Installation
30+
31+
```bash
32+
fpm install clickhouse-fortran
33+
```
34+
35+
## Fortran-facts
36+
37+
<Tabs>
38+
39+
<TabItem value="Fact 1" label="Fact 1" default>
40+
From its creation in 1954 and its commercial release in 1957 as the progenitor of software, Fortran (short for formula translation) became the first computer language standard.
41+
<br/>
42+
</TabItem>
43+
44+
<TabItem value="Fact 2" label="Fact 2" default>
45+
Originally developed for performing high computation mathematical calculations, NASA is currently deploying Fortran in climate model, aerodynamics applications and orbital mechanism projects.
46+
<br/>
47+
</TabItem>
48+
49+
</Tabs>
50+
51+
<details>
52+
<summary>Did you know?</summary>
53+
54+
People use Fortran for many important tasks.
55+
These include predicting the weather, designing airplanes, and understanding how liquids flow.
56+
It's also used in computational physics and chemistry.
57+
Fortran is a top choice for high-performance computing.
58+
This means it runs programs on the world's fastest supercomputers.
59+
</details>
60+
61+
## Usage
62+
63+
<VerticalStepper headerLevel="h3">
64+
65+
### Ordinary codeblock
66+
67+
Create a connection using a connection string with the imaginary code below:
68+
69+
```fortran
70+
use clickhouse_driver
71+
type(ClickHouseClient) :: client
72+
call client%connect('localhost', 9000)
73+
call client%execute('SELECT * FROM measurements')
74+
```
75+
76+
### Codeblock from a file in docs repo
77+
78+
Here is some basic connect and query code from a file in this repository:
79+
80+
```fortran file=code_snippets/integrations/language_clients/example.f90
81+
program clickhouse_example
82+
use clickhouse_driver
83+
implicit none
84+
85+
type(ClickHouseClient) :: client
86+
type(QueryResult) :: result
87+
integer :: status, i
88+
89+
! Initialize and connect to ClickHouse
90+
call client%init('localhost', port=9000, database='default', &
91+
user='default', password='')
92+
93+
status = client%connect()
94+
if (status /= CH_SUCCESS) then
95+
print *, 'Connection failed!'
96+
stop
97+
end if
98+
99+
print *, 'Connected to ClickHouse successfully'
100+
101+
! Execute a simple query
102+
call client%execute('SELECT version()', result)
103+
call result%print()
104+
105+
! Cleanup
106+
call result%free()
107+
call client%disconnect()
108+
109+
end program clickhouse_example
110+
```
111+
112+
### Code block from an external URL
113+
114+
Here is some code from a file in GitHub:
115+
116+
```fortran url=https://raw.githubusercontent.com/scivision/fortran2018-examples/refs/heads/main/src/system/play_sound.f90
117+
program play_sound
118+
!! recommend using all lower case filenames and no spaces.
119+
!! plays sound in Fortran 2003+
120+
121+
implicit none
122+
123+
! configure ffplay -- could make if/else to allow other players
124+
character(*),parameter :: playexe='ffplay'
125+
! -autoexit clips off the end of the sound slightly, but otherwise thread hangs open even after Fortran program ends.
126+
character(*),parameter :: cmdopts='-autoexit -loglevel warning -nodisp'
127+
128+
character(:), allocatable :: pcmd, buf
129+
logical :: fexist
130+
integer :: ierr, istat, L
131+
132+
valgrind : block
133+
134+
call get_command_argument(1, length=L, status=ierr)
135+
if (ierr /= 0) error stop "please specify sound file"
136+
allocate(character(L) :: buf)
137+
call get_command_argument(1, value=buf)
138+
139+
inquire(file=buf, exist=fexist)
140+
141+
if (.not. fexist) error stop 'did not find FILE ' // buf
142+
143+
pcmd = playexe//' '//cmdopts//' '//trim(buf)
144+
145+
call execute_command_line(pcmd, cmdstat=ierr, exitstat=istat)
146+
if(ierr /= 0) error stop 'could not open player'
147+
if(istat /= 0) error stop 'problem playing file'
148+
149+
end block valgrind
150+
151+
end program
152+
153+
```
154+
155+
</VerticalStepper>

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ const sidebars = {
550550
"interfaces/third-party/client-libraries",
551551
],
552552
},
553+
"integrations/language-clients/fortran"
553554
],
554555
},
555556
{

0 commit comments

Comments
 (0)