/[lmdze]/trunk/bibio/Writefield/writefield.f
ViewVC logotype

Contents of /trunk/bibio/Writefield/writefield.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 110 - (show annotations)
Wed Sep 17 11:55:05 2014 UTC (9 years, 8 months ago) by guez
File size: 2168 byte(s)
Moved variables of module write_field to module
createnewfield_m. Deleted module variable varid because we know that
varid is always 1. Module variable record was modified in 2 procedures
so Moved assignment:

Record(NbField) = 1

to writefield.

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

  ViewVC Help
Powered by ViewVC 1.1.21