source: trunk/MESOSCALE_DEV/PLOT/RESERVE/obsolete/read_dat.pro @ 207

Last change on this file since 207 was 86, checked in by aslmd, 14 years ago

*
mars + LMD_MM_MARS
* Precompilation flag MESOSCALE for better transparency

* in shared phymars between GCM and mesoscale model

*

M 85 mars/libf/phymars/meso_physiq.F
M 85 mars/libf/phymars/meso_inifis.F
Added a pre-compilation flag MESOSCALE so that the LMDZ.MARS GCM
will compile without stating errors because of mesoscale routines.

M 85 mars/libf/phymars/newcondens.F
M 85 mars/libf/phymars/testphys1d.F
M 85 mars/libf/phymars/dustlift.F
D 85 mars/libf/phymars/meso_testphys1d.F
D 85 mars/libf/phymars/meso_dustlift.F
D 85 mars/libf/phymars/meso_newcondens.F
Now, this MESOSCALE precompilation flag can be used to lower
the number of meso_* routines when adaptations for mesoscale
applications are not very extended.
--> Three meso_* routines were deleted and changes are
now impacted under the MESOSCALE flag in the original GCM routines
--> Completely transparent for GCM compilation since it is devoid
of the -DMESOSCALE option
--> Very good for syncing because changes in dustlift, newcondens
will be directly available in the mesoscale model

M 84 mesoscale/LMD_MM_MARS/makemeso
Changed meso_testphys1d in testphys1d

M 84 mesoscale/LMD_MM_MARS/SRC/WRFV2/mars_lmd_new/makegcm_pgf
M 84 mesoscale/LMD_MM_MARS/SRC/WRFV2/mars_lmd_new/makegcm_mpifort
M 84 mesoscale/LMD_MM_MARS/SRC/WRFV2/mars_lmd_new/makegcm_ifort
M 84 mesoscale/LMD_MM_MARS/SRC/WRFV2/mars_lmd_new/makegcm_g95
M 84 mesoscale/LMD_MM_MARS/SRC/WRFV2/mars_lmd_new/makegcm_mpi
Added the option -DMESOSCALE in these scripts

*
LMD_MM_MARS
* Various minor changes related to water cycle and plotting routines

* Also included the GW test case

*

A 0 mesoscale/LMDZ.MARS.new/myGCM/DEFS_JB/callphys.def.orig
M 84 mesoscale/NOTES.txt
D 84 mesoscale/LMD_MM_MARS/SRC/ARWpost/idl
M 84 mesoscale/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM
M 84 mesoscale/LMD_MM_MARS/SIMU/gnome_launch.meso
M 85 mesoscale/PLOT/MINIMAL/map_latlon.pro
D 85 mesoscale/PLOT/SPEC/LES/getget.pro
M 85 mesoscale/PLOT/SPEC/MAP/map_uvt.pro
A + - mesoscale/PLOT/SPEC/getget.pro
A 0 mesoscale/PLOT/RESERVE/obsolete
A 0 mesoscale/TESTS/TESTGW.tar.gz
M 84 000-USERS

File size: 5.0 KB
Line 
1pro read_dat, output, x, y, z, t, desc_field, nodata=nodata
2
3
4;---------------------------------------------------------------------------
5;
6; Read the files generated by ARWpost
7;
8; Please create symbolic link 'input.ctl' and 'input.dat'
9; --- or rename files
10;
11; - output contains all fields
12; - x,y,z,t contains coordinates
13; - desc_field contains strings describing fields
14; - if nodata is not blank, do not read the fields
15;
16;---------------------------------------------------------------------------
17; A. Spiga, August 2007
18;---------------------------------------------------------------------------
19
20
21;
22; info for localtime
23;
24interv=0.
25openr, 99, 'timefil'
26readf,99,interv
27close, 99
28
29
30
31; get preliminar info on coordinates
32;
33wnx=1
34wny=1
35wnz=1
36wnt=1
37txt=''
38param=[0.,0.,0.,0.,0.,0.,0.,0.]
39openr, 1, 'input.ctl'
40while not eof(1) do begin
41    readf,1,txt
42    match=STRPOS(txt,'linear')
43        if (match ne -1) then begin
44                wnx=(STRPOS(txt,'xdef') eq -1)*wnx  ;0 if linear
45                wny=(STRPOS(txt,'ydef') eq -1)*wny  ;0 if linear
46                wnz=(STRPOS(txt,'zdef') eq -1)*wnz  ;0 if linear
47                wnt=(STRPOS(txt,'tdef') eq -1)*wnt  ;0 if linear
48                paramstart=STRSPLIT(txt, 'r', LENGTH=paramlength)
49                paramchar=STRMID(txt,paramstart(1),paramlength(1))
50                READS, paramchar, start, step
51                param=param+[start*(STRPOS(txt,'xdef') ne -1),$
52                        step*(STRPOS(txt,'xdef') ne -1),$
53                        start*(STRPOS(txt,'ydef') ne -1),$
54                        step*(STRPOS(txt,'ydef') ne -1),$
55                        start*(STRPOS(txt,'zdef') ne -1),$
56                        step*(STRPOS(txt,'zdef') ne -1),$
57                        start*(STRPOS(txt,'tdef') ne -1),$
58                        step*(STRPOS(txt,'tdef') ne -1)]
59        endif   
60endwhile
61close, 1
62timebegin=param(6)
63       
64;---------------------------------
65; READ .CTL FILE INFORMATIONS
66;---------------------------------
67
68info=read_ascii('input.ctl', missing_value=1e37)
69infodat=info.field1
70
71;
72; second column : dimensions
73;
74
75w=where((infodat(0,*) eq 1e37) and (infodat(1,*) lt 1e37))
76dimensions=reform(infodat(1,w))
77
78nx=round(dimensions(0))
79ny=round(dimensions(1))
80nz=round(dimensions(2))
81nt=round(dimensions(3))
82fields=round(dimensions(4))
83vertical=intarr(fields)
84for i=0,fields-1 do begin
85        vertical(i)=round(dimensions(5+i))
86endfor
87
88
89;
90; first column : coordinates
91;
92
93w=where((infodat(1,*) eq 1e37) and (infodat(0,*) lt 1e37))
94if (w(0) ne -1) then coordinates=reform(infodat(0,w))
95
96if (wnx ne 0) then begin
97        wnx=nx
98        x=coordinates(0:nx-1)
99endif else begin
100        xmin=param(0)
101        xmax=param(0)+param(1)*(nx-1) MOD 360
102        ;inc=param(0)+param(1)*(nx-1)   ;cas mercator
103        ;x=start+inc*findgen(nx)
104        x=xmin+(xmax-xmin)*findgen(nx)/(nx-1)
105        ;print, x
106        ;stop
107endelse
108if (wny ne 0) then begin
109        wny=ny
110        y=coordinates(wnx:wnx+wny-1)
111endif else begin
112        start=param(2)
113        step=param(3)
114        y=start+step*findgen(ny)
115endelse
116if (wnz ne 0) then begin
117        wnz=nz
118        z=coordinates(wnx+wny:wnx+wny+wnz-1)
119endif else begin
120        start=param(4)
121        step=param(5)
122        z=start+step*findgen(nz)
123endelse
124t=interv*findgen(nt)/3700. + timebegin + mean(x)/15.
125       
126
127;
128; get info on fields
129;
130openr, 1, 'input.ctl'
131toto=5+wnx+1+wny+1+wnz+2+fields
132infofields=strarr(toto)
133readf, 1, infofields
134close, 1
135
136;
137desc_field=transpose(infofields(toto-fields:toto-1))
138
139
140if (n_elements(nodata) eq 0) then begin
141;---------------------------------
142; READ .DAT FILE DATA
143;---------------------------------
144; GrADS views gridded data sets as 5-dimensional arrays
145; varying in longitude, latitude, vertical level, variable, and time.
146;---------------------------------
147
148print, '----------------'
149print, 'reading data ...'
150print, '----------------'
151print, 'longitudes: ', min(x), max(x), nx, ' points'
152print, 'latitudes: ', min(y), max(y), ny, ' points'
153print, 'altitudes: ', min(z), max(z), nz, ' points'
154print, 'local times: ', min(t), max(t), nt, ' points'
155print, fields, ' recorded fields :'
156print, desc_field
157print, '----------------'
158
159        ;;very slow method
160        ;;----------------     
161        ;data=read_ascii('input.dat', missing_value=1e37)
162        ;datadat=data.field1
163
164; see http://www.dfanning.com/tips/ascii_column_data.html       
165OPENR, lun, 'input.dat', /GET_LUN
166
167;count=0L
168output=fltarr(fields,nx,ny,nz,nt)
169dummy=0.
170
171for l=0,nt-1 do begin                                           ;time loop
172print, 'time loop ...', l+1, ' / ', string(nt,'(I0)')   
173        for f=0, fields-1 do begin ;fields (whether 2D or 3D)   ;variable loop
174        nzf=vertical(f)
175        print, 'reading field ...', f+1, ' / ', string(fields,'(I0)')
176                for k=0,nzf-1 do begin                          ;vertical loop
177                        for j=0,ny-1 do begin                   ;latitude loop
178                        for i=0,nx-1 do begin                   ;longitude loop
179
180                                ;;very slow method
181                                ;output(f,i,j,k,l)=datadat(count)
182                                ;count=count+1
183
184                                READF, lun, dummy
185                                output(f,i,j,k,l)=dummy
186
187                        endfor
188                        endfor
189                endfor
190        endfor
191endfor
192
193; missing values
194w=where(output eq 1e20)
195if (w(0) ne -1) then begin
196        print, 'change missing values ...'
197        output[w]=1e37
198endif
199
200
201CLOSE, lun
202;SPAWN, '\rm input.dat_tmp'
203print, '...done !'
204help, /memory
205print, '---------'
206
207;if (count ne n_elements(datadat)) then begin
208;       print, 'some data were not read !'
209;       stop
210;endif
211
212;;
213;; Manage missing data so as IDL recognize them
214;;
215;w=where(output eq 1e37)
216;if (w(0) ne -1) then output[w]=!Values.F_NAN
217
218endif
219
220end
Note: See TracBrowser for help on using the repository browser.