/[lmdze]/trunk/misc/writefield.f90
ViewVC logotype

Contents of /trunk/misc/writefield.f90

Parent Directory Parent Directory | Revision Log Revision Log


Revision 328 - (show annotations)
Thu Jun 13 14:40:06 2019 UTC (4 years, 11 months ago) by guez
File size: 2275 byte(s)
Change all `.f` suffixes to `.f90`. (The opposite was done in revision
82.)  Because of change of philosopy in GNUmakefile: we already had a
rewritten rule for `.f`, so it does not make the makefile longer to
replace it by a rule for `.f90`. And it spares us options of
makedepf90 and of the compiler. Also we prepare the way for a simpler
`CMakeLists.txt`.

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, nf95_sync
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 call nf95_sync(Ncid(Index))
43
44 end subroutine WriteField1d
45
46 !****************************************************************
47
48 subroutine WriteField2d(name,Field)
49
50 character(len=*), intent(in):: name
51 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
73
74 !****************************************************************
75
76 subroutine WriteField3d(name,Field)
77
78 character(len=*), intent(in):: name
79 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
101
102 end module WriteField_m

  ViewVC Help
Powered by ViewVC 1.1.21