1 |
module WriteField_m |
2 |
|
3 |
USE write_field, ONLY: ncid, record, varid, nbfield |
4 |
use CreateNewField_m, only: CreateNewField |
5 |
use GetFieldIndex_m, only: GetFieldIndex |
6 |
USE netcdf95, ONLY: nf95_put_var |
7 |
|
8 |
implicit none |
9 |
|
10 |
interface WriteField |
11 |
module procedure WriteField3d,WriteField2d,WriteField1d |
12 |
end interface WriteField |
13 |
|
14 |
private |
15 |
public WriteField |
16 |
|
17 |
contains |
18 |
|
19 |
subroutine WriteField1d(name,Field) |
20 |
|
21 |
character(len=*), intent(in):: name |
22 |
real, intent(in):: Field(:) |
23 |
|
24 |
! Local: |
25 |
integer index |
26 |
|
27 |
!------------------------------------------- |
28 |
|
29 |
Index=GetFieldIndex(name) |
30 |
|
31 |
if (Index==-1) then |
32 |
call CreateNewField(name, shape(field)) |
33 |
Index=nbfield |
34 |
else |
35 |
Record(Index)=Record(Index)+1 |
36 |
endif |
37 |
|
38 |
call NF95_PUT_VAR(Ncid(Index), Varid(Index), Field, & |
39 |
start = (/1, Record(Index)/)) |
40 |
|
41 |
end subroutine WriteField1d |
42 |
|
43 |
!**************************************************************** |
44 |
|
45 |
subroutine WriteField2d(name,Field) |
46 |
|
47 |
character(len=*), intent(in):: name |
48 |
real, intent(in):: Field(:, :) |
49 |
|
50 |
! Local: |
51 |
integer index |
52 |
|
53 |
!------------------------------------------- |
54 |
|
55 |
Index=GetFieldIndex(name) |
56 |
|
57 |
if (Index==-1) then |
58 |
call CreateNewField(name, shape(field)) |
59 |
Index=nbfield |
60 |
else |
61 |
Record(Index)=Record(Index)+1 |
62 |
endif |
63 |
|
64 |
call NF95_PUT_VAR(Ncid(Index), Varid(Index), Field, & |
65 |
start = (/1, 1, Record(Index)/)) |
66 |
|
67 |
end subroutine WriteField2d |
68 |
|
69 |
!**************************************************************** |
70 |
|
71 |
subroutine WriteField3d(name,Field) |
72 |
|
73 |
character(len=*), intent(in):: name |
74 |
real, intent(in):: Field(:, :, :) |
75 |
|
76 |
! Local: |
77 |
integer index |
78 |
|
79 |
!------------------------------------------- |
80 |
|
81 |
Index=GetFieldIndex(name) |
82 |
|
83 |
if (Index==-1) then |
84 |
call CreateNewField(name, shape(field)) |
85 |
Index=nbfield |
86 |
else |
87 |
Record(Index)=Record(Index)+1 |
88 |
endif |
89 |
|
90 |
call NF95_PUT_VAR(Ncid(Index), Varid(Index), Field, & |
91 |
start = (/1, 1, 1, Record(Index)/)) |
92 |
|
93 |
end subroutine WriteField3d |
94 |
|
95 |
end module WriteField_m |