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

Annotation of /trunk/misc/writefield.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 111 - (hide annotations)
Wed Sep 17 11:57:10 2014 UTC (9 years, 8 months ago) by guez
Original Path: trunk/bibio/writefield.f
File size: 2168 byte(s)


1 guez 108 module WriteField_m
2    
3 guez 110 use CreateNewField_m, only: CreateNewField, ncid, nbfield, MaxWriteField
4 guez 109 use GetFieldIndex_m, only: GetFieldIndex
5     USE netcdf95, ONLY: nf95_put_var
6 guez 108
7     implicit none
8    
9 guez 110 integer, save:: Record(MaxWriteField)
10    
11 guez 108 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 guez 109 character(len=*), intent(in):: name
23     real, intent(in):: Field(:)
24 guez 108
25 guez 109 ! 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 guez 110 Record(Index) = 1
36 guez 109 else
37     Record(Index)=Record(Index)+1
38     endif
39    
40 guez 110 call NF95_PUT_VAR(Ncid(Index), Varid = 1, values = Field, &
41 guez 109 start = (/1, Record(Index)/))
42    
43 guez 108 end subroutine WriteField1d
44    
45     !****************************************************************
46    
47     subroutine WriteField2d(name,Field)
48    
49 guez 109 character(len=*), intent(in):: name
50     real, intent(in):: Field(:, :)
51 guez 108
52 guez 109 ! 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 guez 110 Record(Index) = 1
63 guez 109 else
64     Record(Index)=Record(Index)+1
65     endif
66    
67 guez 110 call NF95_PUT_VAR(Ncid(Index), Varid = 1, values = Field, &
68 guez 109 start = (/1, 1, Record(Index)/))
69    
70 guez 108 end subroutine WriteField2d
71    
72     !****************************************************************
73    
74     subroutine WriteField3d(name,Field)
75    
76 guez 109 character(len=*), intent(in):: name
77     real, intent(in):: Field(:, :, :)
78 guez 108
79 guez 109 ! 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 guez 110 Record(Index) = 1
90 guez 109 else
91     Record(Index)=Record(Index)+1
92     endif
93    
94 guez 110 call NF95_PUT_VAR(Ncid(Index), Varid = 1, values = Field, &
95 guez 109 start = (/1, 1, 1, Record(Index)/))
96    
97 guez 108 end subroutine WriteField3d
98    
99     end module WriteField_m

  ViewVC Help
Powered by ViewVC 1.1.21