GRASS 8 Programmer's Manual
8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
write2d.c
Go to the documentation of this file.
1
/*!
2
* \file secpar2d.c
3
*
4
* \author H. Mitasova, I. Kosinovsky, D. Gerdes Fall 1993 (original authors)
5
* \author modified by McCauley in August 1995
6
* \author modified by Mitasova in August 1995
7
* \author H. Mitasova (University of Illinois)
8
* \author I. Kosinovsky, (USA-CERL)
9
* \author D.Gerdes (USA-CERL)
10
*
11
* SPDX-FileCopyrightText: 1993-1995 Helena Mitasova
12
* SPDX-FileCopyrightText: GRASS Development Team
13
* SPDX-License-Identifier: GPL-2.0-or-later
14
*/
15
16
#include <
grass/config.h
>
17
#include <
stdio.h
>
18
#include <math.h>
19
#include <
unistd.h
>
20
21
#include <
grass/gis.h
>
22
#include <
grass/glocale.h
>
23
#include <grass/interpf.h>
24
25
/* parameter descriptions takes from a strange comment */
26
/*!
27
* Writes az,adx,...,adxy into appropriate place (depending on ngstc, nszc
28
* and offset) in corresponding temp file
29
*/
30
int
IL_write_temp_2d
(
struct
interp_params
*params,
31
int
ngstc
,
/*!< begin. column */
32
int
nszc
,
/*!< end. column */
33
off_t
offset2
/*!< offset */
34
)
35
{
36
int
j
;
37
static
FCELL
*
array_cell
=
NULL
;
38
39
if
(!
array_cell
)
40
array_cell
=
G_malloc
(
sizeof
(
FCELL
) * params->
nsizc
+ 1);
41
if
(params->
Tmp_fd_z
!=
NULL
) {
42
for
(
j
=
ngstc
;
j
<=
nszc
;
j
++)
43
array_cell
[
j
- 1] = (
FCELL
)params->
az
[
j
];
44
G_fseek
(params->
Tmp_fd_z
,
offset2
,
SEEK_SET
);
45
if
(!
fwrite
(
array_cell
+
ngstc
- 1,
sizeof
(
FCELL
),
nszc
-
ngstc
+ 1,
46
params->
Tmp_fd_z
))
47
G_fatal_error
(
_
(
"Cannot write files"
));
48
}
49
if
(params->
Tmp_fd_dx
!=
NULL
) {
50
for
(
j
=
ngstc
;
j
<=
nszc
;
j
++)
51
if
(!params->
deriv
)
52
array_cell
[
j
- 1] = (
FCELL
)params->
adx
[
j
];
53
else
54
array_cell
[
j
- 1] = (
FCELL
)(params->
adx
[
j
] * params->
scik1
);
55
G_fseek
(params->
Tmp_fd_dx
,
offset2
,
SEEK_SET
);
56
if
(!
fwrite
(
array_cell
+
ngstc
- 1,
sizeof
(
FCELL
),
nszc
-
ngstc
+ 1,
57
params->
Tmp_fd_dx
))
58
G_fatal_error
(
_
(
"Cannot write files"
));
59
}
60
if
(params->
Tmp_fd_dy
!=
NULL
) {
61
for
(
j
=
ngstc
;
j
<=
nszc
;
j
++) {
62
if
(!params->
deriv
) {
63
if
(params->
ady
[
j
] > 0. && params->
ady
[
j
] < 0.5)
64
params->
ady
[
j
] = 360.;
65
array_cell
[
j
- 1] = (
FCELL
)params->
ady
[
j
];
66
}
67
else
68
array_cell
[
j
- 1] = (
FCELL
)(params->
ady
[
j
] * params->
scik1
);
69
}
70
G_fseek
(params->
Tmp_fd_dy
,
offset2
,
SEEK_SET
);
71
if
(!
fwrite
(
array_cell
+
ngstc
- 1,
sizeof
(
FCELL
),
nszc
-
ngstc
+ 1,
72
params->
Tmp_fd_dy
))
73
G_fatal_error
(
_
(
"Cannot write files"
));
74
}
75
if
(params->
Tmp_fd_xx
!=
NULL
) {
76
for
(
j
=
ngstc
;
j
<=
nszc
;
j
++) {
77
array_cell
[
j
- 1] = (
FCELL
)(params->
adxx
[
j
] * params->
scik1
);
78
}
79
G_fseek
(params->
Tmp_fd_xx
,
offset2
,
SEEK_SET
);
80
if
(!
fwrite
(
array_cell
+
ngstc
- 1,
sizeof
(
FCELL
),
nszc
-
ngstc
+ 1,
81
params->
Tmp_fd_xx
))
82
G_fatal_error
(
_
(
"Cannot write files"
));
83
}
84
if
(params->
Tmp_fd_yy
!=
NULL
) {
85
for
(
j
=
ngstc
;
j
<=
nszc
;
j
++)
86
array_cell
[
j
- 1] = (
FCELL
)(params->
adyy
[
j
] * params->
scik2
);
87
G_fseek
(params->
Tmp_fd_yy
,
offset2
,
SEEK_SET
);
88
if
(!
fwrite
(
array_cell
+
ngstc
- 1,
sizeof
(
FCELL
),
nszc
-
ngstc
+ 1,
89
params->
Tmp_fd_yy
))
90
G_fatal_error
(
_
(
"Cannot write files"
));
91
}
92
if
(params->
Tmp_fd_xy
!=
NULL
) {
93
for
(
j
=
ngstc
;
j
<=
nszc
;
j
++)
94
array_cell
[
j
- 1] = (
FCELL
)(params->
adxy
[
j
] * params->
scik3
);
95
G_fseek
(params->
Tmp_fd_xy
,
offset2
,
SEEK_SET
);
96
if
(!
fwrite
(
array_cell
+
ngstc
- 1,
sizeof
(
FCELL
),
nszc
-
ngstc
+ 1,
97
params->
Tmp_fd_xy
))
98
G_fatal_error
(
_
(
"Cannot write files"
));
99
}
100
return
1;
101
}
NULL
#define NULL
Definition
ccmath.h:32
AMI_STREAM
Definition
ami_stream.h:153
config.h
G_fatal_error
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
G_malloc
#define G_malloc(n)
Definition
defs/gis.h:136
G_fseek
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
Definition
gis/seek.c:48
gis.h
FCELL
float FCELL
Definition
gis.h:633
glocale.h
_
#define _(str)
Definition
glocale.h:10
stdio.h
interp_params
Definition
interpf.h:70
interp_params::Tmp_fd_xx
FILE * Tmp_fd_xx
Definition
interpf.h:123
interp_params::Tmp_fd_xy
FILE * Tmp_fd_xy
Definition
interpf.h:123
interp_params::scik2
int scik2
Definition
interpf.h:102
interp_params::az
DCELL * az
Definition
interpf.h:94
interp_params::deriv
int deriv
Definition
interpf.h:114
interp_params::Tmp_fd_yy
FILE * Tmp_fd_yy
Definition
interpf.h:123
interp_params::adxy
DCELL * adxy
Definition
interpf.h:94
interp_params::scik3
int scik3
Definition
interpf.h:102
interp_params::Tmp_fd_dx
FILE * Tmp_fd_dx
Definition
interpf.h:123
interp_params::adyy
DCELL * adyy
Definition
interpf.h:94
interp_params::adx
DCELL * adx
Definition
interpf.h:94
interp_params::Tmp_fd_z
FILE * Tmp_fd_z
Definition
interpf.h:123
interp_params::ady
DCELL * ady
Definition
interpf.h:94
interp_params::nsizc
int nsizc
Definition
interpf.h:92
interp_params::Tmp_fd_dy
FILE * Tmp_fd_dy
Definition
interpf.h:123
interp_params::adxx
DCELL * adxx
Definition
interpf.h:94
interp_params::scik1
int scik1
Definition
interpf.h:102
unistd.h
IL_write_temp_2d
int IL_write_temp_2d(struct interp_params *params, int ngstc, int nszc, off_t offset2)
Definition
write2d.c:30
lib
rst
interp_float
write2d.c
Generated on Sun Sep 13 2026 06:57:51 for GRASS 8 Programmer's Manual by
1.9.8