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