Blame view

src/output/asciiout.F90 4.95 KB
33b83817   dumoda01   Depot du modele /...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
!$Id: asciiout.F90,v 1.5 2005-07-06 14:19:50 kbk Exp $
#include"cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !MODULE: asciiout --- saving the results in ASCII
!
! !INTERFACE:
   MODULE asciiout
!
! !DESCRIPTION:
!  This module contains three subroutines for writing model output in ASCII format.
!  The authors do not encourage using ASCII for output --- instead we recommend
!  NetCDF.
!
! !USES:
   IMPLICIT NONE
!
!  Default all is private.
   private
!
! !PUBLIC MEMBER FUNCTIONS:
   public init_ascii, do_ascii_out, close_ascii
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  $Log: asciiout.F90,v $
!  Revision 1.5  2005-07-06 14:19:50  kbk
!  added writing of obs. velocities
!
!  Revision 1.4  2003/03/28 09:20:35  kbk
!  added new copyright to files
!
!  Revision 1.3  2003/03/10 08:53:05  gotm
!  Improved documentation and cleaned up code
!
!  Revision 1.2  2001/11/18 11:51:16  gotm
!  Now format statements
!
!  Revision 1.1.1.1  2001/02/12 15:55:58  gotm
!  initial import into CVS
!
!EOP
!-----------------------------------------------------------------------

   contains

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Open the file unit for writing
!
! !INTERFACE:
   subroutine init_ascii(fn,title,unit)
   IMPLICIT NONE
!
! !DESCRIPTION:
!  Opens a file giving in the {\tt output} namelist and connects
!  it with a unit number.
!
! !INPUT PARAMETERS:
   character(len=*), intent(in)        :: fn,title
!
! !INPUT/OUTPUT PARAMETERS:
   integer, intent(in)                 :: unit
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  See asciiout module
!
!EOP
!-------------------------------------------------------------------------
!BOC
   open(unit,status='unknown',file=fn)
   write(unit,*) '# ',trim(title)
   return
   end subroutine init_ascii
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Save the model results to file
!
! !INTERFACE:
   subroutine do_ascii_out(nlev,timestr,unit)
!
! !DESCRIPTION:
!  Writes all calculated data to an ASCII file.
!
! !USES:
   use meanflow,     only: depth0,h,u,v,z,S,T,NN,buoy
   use turbulence,   only: num,nuh,tke,eps,L
   use turbulence,   only: kb,epsb
   use observations, only: tprof,sprof,uprof,vprof,epsprof
!#ifdef SEDIMENT
!   use sediment, only: ascii_sediment
!#endif
!#ifdef SEDIMENT
!   use seagrass, only: ascii_seagrass
!#endif

   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   integer, intent(in)                 :: nlev
   CHARACTER(len=*), intent(in)        :: timestr
   integer, intent(in)                 :: unit
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  See asciiout module
!
!EOP
!
! !LOCAL VARIABLES:
   integer                   :: i
   integer, save             :: set=0
   REALTYPE                  :: d
   REALTYPE                  :: zz(0:nlev)
!
!-------------------------------------------------------------------------
!BOC
   set = set + 1
   write(unit,*) timestr,'  Set# ',set
   write(unit,112) 'z','u','v','T','S','buoy'
   d=0.
   do i=nlev,1,-1
      if (abs(u(i)).lt.1.e-32) u(i)=0.
      if (abs(v(i)).lt.1.e-32) v(i)=0.
      d=d+0.5*h(i)
      write(unit,114) z(i),u(i),v(i),T(i),S(i),buoy(i)
   end do

   write(unit,113) 'z','num','nuh','k','eps','L','kb','epsb'
   zz(1)=-depth0+h(1)
   do i=2,nlev
      zz(i)=zz(i-1)+h(i)
   end do
   do i=nlev-1,1,-1
      write(unit,115) zz(i),num(i),nuh(i),tke(i),eps(i),L(i),kb(i),epsb(i)
   end do

   write(unit,113) 'z','Tobs','Sobs','Uobs','Vobs','epsobs'
   do i=nlev,1,-1
     write(unit,116) z(i),tprof(i),sprof(i),uprof(i),vprof(i),epsprof(i)
   end do

112 format(A9,6(1x,A10))
113 format(A9,8(1x,A10))
114 format(F10.4,2(1x,E10.4E2),2(1x,F10.6),2(1x,E10.4E2))
115 format(F10.4,7(1x,E10.4E2))
116 format(F10.4,2(1x,F10.6),3(2x,E10.4E2))
117 format(A9,4(1x,A10))

!#ifdef SEDIMENT
!    call ascii_sediment(nlev,timestr)
!#endif
!#ifdef SEAGRASS
!    call ascii_seagrass(timestr)
!#endif

   return
   end subroutine do_ascii_out
!EOC

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: Close files used for saving model results
!
! !INTERFACE:
   subroutine close_ascii(unit)
   IMPLICIT NONE
!
! !DESCRIPTION:
!  Close the open ASCII file.
!
! !INPUT PARAMETERS:
   integer, intent(in)                 :: unit
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  See asciiout module
!
!EOP
!-------------------------------------------------------------------------
!BOC
   LEVEL2 'Output has been written in ASCII'
   close(unit)

   return
   end subroutine close_ascii
!EOC

!-----------------------------------------------------------------------

   end module asciiout

!-----------------------------------------------------------------------
! Copyright by the GOTM-team under the GNU Public License - www.gnu.org
!-----------------------------------------------------------------------