source: trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/Venus/readmeteo.F90

Last change on this file was 2021, checked in by mlefevre, 6 years ago

Photochemistry architecture for Venus mesoscale and LES model

File size: 78.0 KB
Line 
1program readmeteo
2
3implicit none
4include "netcdf.inc"
5
6!------------------------------------------------------------------------!
7! Readmeteo prepares an initial state for the WPS pre-processor of WRF   !
8!                                                                        !
9! Input is a diagfi.nc NETCDF file from a LMD/GCM simulation             !
10!                                                                        !
11! Outputs are WRFSI intermediate format files ready for metgrid.exe      !
12!       http://www.mmm.ucar.edu/wrf/OnLineTutorial/WPS/IM_si.htm         !
13!                                                                        !
14! **** Please create a WPSFEED folder (or a symbolic link) ****          !       
15!                                                                        !
16! A. Spiga - 16/04/2007                                                  !
17!            22/05/2007 : need to run zrecast as a preliminary           !
18!            07/06/2007 : external parameter file 'readmeteo.def         !
19!            30/07/2007 : manage additional variables (tsoil, emiss,...) !     
20!            19/10/2007 : no need to run zrecast at all (eta levels)     !   
21!               12/2007 : include co2ice and emissivity                  !
22!               02/2008 : include water vapor and ice                    !
23!               01/2010 : possible use of diagsoil for new physics       !
24!               02/2011 : add dust tracers, correct surface              !
25!                                                                        !
26! spiga@lmd.jussieu.fr                                                   !     
27!------------------------------------------------------------------------!
28
29
30
31!***************************************************************************
32!***************************************************************************
33REAL, PARAMETER :: emiss_prescribed=0.95
34REAL, PARAMETER :: co2ice_prescribed=0.
35CHARACTER (LEN=3), PARAMETER :: ident='LMD'
36
37
38
39!***************************************************************************
40!***************************************************************************
41
42REAL :: ptop
43REAL, PARAMETER :: grav=8.89
44LOGICAL, PARAMETER :: blank=.false.
45
46
47
48!! Variables to be written in the output file
49!! *** NB: conformity with metgrid/src/read_met_module.F90
50CHARACTER (LEN=33) :: output
51INTEGER :: IFV
52CHARACTER (LEN=24) :: HDATE
53REAL :: XFCST
54CHARACTER (LEN=32) :: SOURCE
55CHARACTER (LEN=9) :: FIELD
56CHARACTER (LEN=25) :: UNITS
57CHARACTER (LEN=46) :: DESC
58REAL :: XLVL
59INTEGER :: NX,NY,IPROJ
60CHARACTER (LEN=8) :: STARTLOC
61REAL :: STARTLAT,STARTLON,DELTALAT,DELTALON
62REAL, POINTER, DIMENSION(:,:) :: SLAB
63
64!! Variables related to NETCDF format
65integer :: nid,nid2,nid3,nvarid,ierr,ierr2
66integer :: timedim,londim,latdim,altdim,altdim2
67integer :: rlatvdim,rlonudim
68integer :: timelen,lonlen,latlen,altlen,altlen2
69integer :: rlatvlen,rlonulen
70integer :: soillen,soildim
71integer :: nphys
72integer, dimension(4) :: corner,edges
73
74!! Intermediate data arrays
75integer :: k,l,m,n,p,i,j
76real, dimension(:), allocatable :: lat,lon,time,alt,aps,bps,levels,vertdsoil
77real, dimension(:,:), allocatable :: vide,ones,ghtsfile
78real, dimension(:,:), allocatable :: interm
79real, dimension(:,:,:), allocatable :: gwparam
80real, dimension(:,:,:), allocatable :: psfile,tsfile
81real, dimension(:,:,:), allocatable :: emissfile,co2icefile
82real, dimension(:,:,:), allocatable :: tnsfile,unsfile,vnsfile
83real, dimension(:,:,:,:), allocatable :: tfile,ufile,vfile,rfile,hfile,ghfile
84real, dimension(:,:,:,:), allocatable :: pfile
85real, dimension(:,:,:,:), allocatable :: eta_gcm
86!real, dimension(:,:,:,:), allocatable :: tfileorig,ufileorig,vfileorig
87real, dimension(:,:,:,:), allocatable :: tsoilfile, dsoilfile, isoilfile
88real, dimension(:,:,:,:), allocatable :: waterfile, watericefile
89real, dimension(:,:,:), allocatable :: swatericefile!, swaterfile
90real, dimension(:,:,:,:), allocatable :: dustfile,dustnfile
91real, dimension(:,:,:,:), allocatable :: co2file
92real, dimension(:,:,:,:), allocatable :: ccnfile,ccnnfile
93
94!! Reading the parameter file
95integer :: tmp,increment,FILES
96integer :: tmp2,tmp3,tmp4
97character*1 :: answer
98character*4 :: str
99character*2 :: str2, str3, str4
100integer, dimension(:), allocatable :: time_out
101character*13, dimension(:), allocatable :: date_out
102character*19, dimension(:), allocatable :: date_out2
103
104#ifdef PHOTOCHEM
105real, dimension(:,:,:,:,:), allocatable :: chemtrac
106integer :: nchemtrac,i
107CHARACTER*20,DIMENSION(:),ALLOCATABLE :: wtnom
108#endif
109
110
111!***************************************************************************
112!***************************************************************************
113
114
115!!---------------------
116!! Open the datafile
117!!---------------------
118ierr=NF_OPEN ("input_diagfi.nc",NF_NOWRITE,nid)
119IF (ierr.NE.NF_NOERR) THEN
120   write(*,*)'**** Please create a symbolic link called input_diagfi.nc'
121   CALL ABORT
122ENDIF
123
124
125!!--------------------------
126!! Ask for data references
127!!--------------------------
128!write(*,*) "Create n files. What is n ?"
129read(*,*) FILES
130allocate(time_out(FILES))
131allocate(date_out(FILES))
132allocate(date_out2(FILES))
133
134!write(*,*) ""
135!write(*,*) "INPUT: Diagfi time"
136!write(*,*) "list of n subscripts, separated by <Return>s"
137increment=1
138do while (increment.ne.FILES+1)
139    read(*,*) tmp
140    time_out(increment)=tmp
141    increment=increment+1
142enddo
143
144!write(*,*) ""
145!write(*,*) "OUTPUT: WRF time"
146!write(*,*) "fill 4 lines indicating"
147!write(*,*) "-year (4 digits)"
148!write(*,*) "-month (2 digits)"
149!write(*,*) "-day (2 digits)"
150!write(*,*) "-hour (2 digits)"
151increment=1
152do while (increment.ne.FILES+1)
153    read(*,*) str
154    read(*,*) str2
155    read(*,*) str3
156    read(*,*) str4
157    date_out(increment)=str//'-'//str2//'-'//str3//'_'//str4
158    date_out2(increment)=str//'-'//str2//'-'//str3//'_'//str4//':00:00'
159    !print *,date_out(increment)
160    !write(*,*) "ok? (y/n)"
161    read(*,*) answer
162    if (answer.eq.'n') then
163        !write(*,*) "please write again"
164    else
165        !write(*,*) "next one, please"   
166        increment=increment+1
167    endif
168enddo
169
170
171!!-------------------
172!! Get array sizes
173!!-------------------
174SELECT CASE(ident)
175CASE('LMD')
176ierr=NF_INQ_DIMID(nid,"time_counter",timedim)
177CASE('OXF')
178ierr=NF_INQ_DIMID(nid,"time",timedim)
179END SELECT
180ierr=NF_INQ_DIMLEN(nid,timedim,timelen)
181  write(*,*) "timelen: ",timelen
182
183SELECT CASE(ident)
184CASE('LMD')
185ierr=NF_INQ_DIMID(nid,"lat",latdim)
186CASE('OXF')
187ierr=NF_INQ_DIMID(nid,"lat",latdim)
188END SELECT
189ierr=NF_INQ_DIMLEN(nid,latdim,latlen)
190  write(*,*) "latlen: ",latlen
191
192SELECT CASE(ident)
193CASE('LMD')
194ierr=NF_INQ_DIMID(nid,"lon",londim)
195CASE('OXF')
196ierr=NF_INQ_DIMID(nid,"lon",londim)
197END SELECT
198ierr=NF_INQ_DIMLEN(nid,londim,lonlen)
199  write(*,*) "lonlen: ",lonlen
200
201SELECT CASE(ident)
202CASE('LMD')
203ierr=NF_INQ_DIMID(nid,"presnivs",altdim)
204CASE('OXF')
205ierr=NF_INQ_DIMID(nid,"sigma",altdim)
206END SELECT
207ierr=NF_INQ_DIMLEN(nid,altdim,altlen)
208  write(*,*) "altlen: ",altlen
209
210
211
212!!-------------------------
213!! Allocate local arrays
214!!-------------------------
215allocate(eta_gcm(lonlen,latlen,altlen,timelen))
216allocate(tfile(lonlen,latlen,altlen,timelen))
217allocate(pfile(lonlen,latlen,altlen,timelen))
218allocate(tsoilfile(lonlen,latlen,altlen,timelen))
219allocate(dsoilfile(lonlen,latlen,altlen,timelen))
220allocate(isoilfile(lonlen,latlen,altlen,timelen))
221allocate(vertdsoil(altlen))
222!allocate(tfileorig(lonlen,latlen,altlen,timelen))
223allocate(ufile(lonlen,latlen,altlen,timelen))
224!allocate(ufileorig(lonlen,latlen,altlen,timelen))
225allocate(vfile(lonlen,latlen,altlen,timelen))
226!allocate(vfileorig(lonlen,latlen,altlen,timelen))
227allocate(rfile(lonlen,latlen,altlen,timelen))
228allocate(hfile(lonlen,latlen,altlen,timelen)) 
229allocate(waterfile(lonlen,latlen,altlen,timelen))
230allocate(watericefile(lonlen,latlen,altlen,timelen))
231!allocate(swaterfile(lonlen,latlen,timelen))
232allocate(swatericefile(lonlen,latlen,timelen))
233allocate(dustfile(lonlen,latlen,altlen,timelen))
234allocate(dustnfile(lonlen,latlen,altlen,timelen))
235allocate(co2file(lonlen,latlen,altlen,timelen))
236allocate(ccnfile(lonlen,latlen,altlen,timelen))
237allocate(ccnnfile(lonlen,latlen,altlen,timelen))
238allocate(psfile(lonlen,latlen,timelen))
239allocate(tsfile(lonlen,latlen,timelen))
240allocate(tnsfile(lonlen,latlen,timelen))
241allocate(unsfile(lonlen,latlen,timelen))
242allocate(vnsfile(lonlen,latlen,timelen))
243allocate(emissfile(lonlen,latlen,timelen))
244allocate(co2icefile(lonlen,latlen,timelen))
245allocate(interm(lonlen,latlen))
246allocate(gwparam(lonlen,latlen,5))
247allocate(ghtsfile(lonlen,latlen))    !! no scan axis
248allocate(ghfile(lonlen,latlen,altlen,timelen))
249allocate(vide(lonlen,latlen))
250allocate(ones(lonlen,latlen))
251allocate(lat(latlen), lon(lonlen), alt(altlen), time(timelen))
252allocate(aps(altlen),bps(altlen),levels(altlen))
253#ifdef PHOTOCHEM
254nchemtrac = 34
255allocate(wtnom(nchemtrac))
256print*,'PHOTOCHEM2.1'
257wtnom(1)  = "co2"
258wtnom(2)  = "co"
259wtnom(3)  = "h2"
260wtnom(4) = "h2o"
261wtnom(5)  = "o1d"
262wtnom(6)  = "o"
263wtnom(7)  = "o2"
264wtnom(8)  = "o2dg"
265wtnom(9)  = "o3"
266wtnom(10)  = "h"
267wtnom(11)  = "oh"
268wtnom(12)  = "ho2"
269wtnom(13) = "h2o2"
270wtnom(14)  = "cl"
271wtnom(15)  = "clo"
272wtnom(16)  = "cl2"
273wtnom(17)  = "hcl"
274wtnom(18)  = "hocl"
275wtnom(19)  = "clco"
276wtnom(20)  = "clco3"
277wtnom(21)  = "cocl2"
278wtnom(22)  = "s"
279wtnom(23)  = "so"
280wtnom(24)  = "so2"
281wtnom(25)  = "so3"
282wtnom(26)  = "s2o2"
283wtnom(27)  = "ocs"
284wtnom(28)  = "hso3"
285wtnom(29)  = "h2so4"
286wtnom(30)  = "s2"
287wtnom(31)  = "clso2"
288wtnom(32)  = "oscl"
289wtnom(33)  = "h2oliq"
290wtnom(34)  = "h2so4liq"
291allocate(chemtrac(lonlen,latlen,altlen,timelen,nchemtrac))
292chemtrac(:,:,:,:,:)=0
293#endif
294
295tfile(:,:,:,:)=0
296pfile(:,:,:,:)=0
297tsoilfile(:,:,:,:)=0
298isoilfile(:,:,:,:)=0
299dsoilfile(:,:,:,:)=0
300vertdsoil(:)=0.
301!tfileorig(:,:,:,:)=0
302!ufileorig(:,:,:,:)=0
303!vfileorig(:,:,:,:)=0
304ufile(:,:,:,:)=0
305vfile(:,:,:,:)=0
306rfile(:,:,:,:)=0
307hfile(:,:,:,:)=0
308waterfile(:,:,:,:)=0
309watericefile(:,:,:,:)=0
310!swaterfile(:,:,:)=0
311swatericefile(:,:,:)=0
312dustfile(:,:,:,:)=0
313dustnfile(:,:,:,:)=0
314co2file(:,:,:,:)=0
315ccnfile(:,:,:,:)=0
316ccnnfile(:,:,:,:)=0
317psfile(:,:,:)=0
318tsfile(:,:,:)=0
319emissfile(:,:,:)=0
320co2icefile(:,:,:)=0
321tnsfile(:,:,:)=0
322unsfile(:,:,:)=0
323vnsfile(:,:,:)=0
324interm(:,:)=0
325gwparam(:,:,:)=0
326ghtsfile(:,:)=0
327ghfile(:,:,:,:)=0
328vide(:,:)=0
329ones(:,:)=0
330
331
332!!-------------------
333!! Read dimensions
334!!-------------------
335
336print *,'>>> Read dimensions !'
337
338print *,'Time'
339SELECT CASE(ident)
340CASE('LMD')
341   ierr = NF_INQ_VARID (nid, "time_counter",nvarid)
342CASE('OXF')
343   ierr = NF_INQ_VARID (nid, "time",nvarid)
344END SELECT
345   IF (ierr .NE. NF_NOERR) THEN
346      PRINT *, "Error: Readmeteo <Time> not found"
347      stop
348   ENDIF
349#ifdef NC_DOUBLE
350   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, time)
351#else
352   ierr = NF_GET_VAR_REAL(nid, nvarid, time)
353#endif
354   print *,time(1),' ... to ... ',time(timelen)
355
356print *,'Latitude'
357SELECT CASE(ident)
358CASE('LMD')
359   ierr = NF_INQ_VARID (nid, "lat",nvarid)
360CASE('OXF')
361   ierr = NF_INQ_VARID (nid, "lat",nvarid)
362END SELECT
363   IF (ierr .NE. NF_NOERR) THEN
364      PRINT *, "Error: Readmeteo <latitude> not found"
365      stop
366   ENDIF
367#ifdef NC_DOUBLE
368   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, lat)
369#else
370   ierr = NF_GET_VAR_REAL(nid, nvarid, lat)
371#endif
372   print *,lat(1),' ... to ... ',lat(latlen),' ... step: ',lat(latlen)-lat(latlen-1)
373
374print *,'Longitude'
375SELECT CASE(ident)
376CASE('LMD')
377   ierr = NF_INQ_VARID (nid, "lon",nvarid)
378CASE('OXF')
379   ierr = NF_INQ_VARID (nid, "lon",nvarid)
380END SELECT
381   IF (ierr .NE. NF_NOERR) THEN
382      PRINT *, "Error: Readmeteo <longitude> not found"
383      stop
384   ENDIF
385#ifdef NC_DOUBLE
386   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, lon)
387#else
388   ierr = NF_GET_VAR_REAL(nid, nvarid, lon)
389#endif
390   print *,lon(1),' ... to ... ',lon(lonlen),' ... step: ',lon(lonlen)-lon(lonlen-1)
391
392!SELECT CASE(ident)
393!CASE('LMD')
394!print *, 'Hybrid coordinates'
395!   ierr = NF_INQ_VARID (nid, "aps", nvarid)
396!   IF (ierr .NE. NF_NOERR) THEN
397!      PRINT *, "Error: Readmeteo <aps> not found"
398!      stop
399!   ENDIF
400!#ifdef NC_DOUBLE
401!   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, aps)
402!#else
403!   ierr = NF_GET_VAR_REAL(nid, nvarid, aps)
404!#endif
405!   ierr = NF_INQ_VARID (nid, "bps", nvarid)
406!   IF (ierr .NE. NF_NOERR) THEN
407!      PRINT *, "Error: Readmeteo <bps> not found"
408!      stop
409!   ENDIF
410!#ifdef NC_DOUBLE
411!   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, bps)
412!#else
413!   ierr = NF_GET_VAR_REAL(nid, nvarid, bps)
414!#endif
415!   print *,aps(1),' ... to ... ',aps(altlen)
416!   print *,bps(1),' ... to ... ',bps(altlen)
417!CASE('OXF')
418!   ierr = NF_INQ_VARID (nid, "sigma", nvarid)
419!  IF (ierr .NE. NF_NOERR) THEN
420!      PRINT *, "Error: Readmeteo <sigma> not found"
421!      stop
422!   ENDIF
423!#ifdef NC_DOUBLE
424!   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, bps)
425!#else
426!   ierr = NF_GET_VAR_REAL(nid, nvarid, bps)
427!#endif
428!   print *,bps(1),' ... to ... ',bps(altlen)
429!END SELECT
430
431
432!!-------------------------------------------
433!! Reading 2D and 3D meteorological fields
434!!-------------------------------------------
435
436IF (blank .EQV. .false.) THEN
437
438print *,'>>> Read 2D optional fields !'
439
440print *,'Emissivity'
441   ierr = NF_INQ_VARID (nid,"emis",nvarid)
442IF (ierr .NE. NF_NOERR) THEN
443        PRINT *, '...warning: not found in diagfi !'
444        PRINT *, '...will be filled with a prescribed value', emiss_prescribed
445  emissfile(:,:,:)=emiss_prescribed
446ELSE
447#ifdef NC_DOUBLE
448  ierr = NF_GET_VAR_DOUBLE(nid, nvarid, emissfile)
449#else
450  ierr = NF_GET_VAR_REAL(nid, nvarid, emissfile)
451#endif
452ENDIF   
453
454print *,'CO2 ice'
455   ierr = NF_INQ_VARID (nid,"co2ice",nvarid)
456IF (ierr .NE. NF_NOERR) THEN
457  PRINT *, '...warning: not found in diagfi !'
458  PRINT *, '...will be filled with a prescribed value', co2ice_prescribed
459  co2icefile(:,:,:)=co2ice_prescribed
460ELSE
461#ifdef NC_DOUBLE
462  ierr = NF_GET_VAR_DOUBLE(nid, nvarid, co2icefile)
463#else
464  ierr = NF_GET_VAR_REAL(nid, nvarid, co2icefile)
465#endif
466ENDIF
467
468print *,'>>> Read 2D surface fields !'
469
470print *,'Surface Pressure'
471   ierr = NF_INQ_VARID (nid,"psol",nvarid)
472   IF (ierr .NE. NF_NOERR) THEN
473      PRINT *, "Error: Readmeteo <ps> not found"
474      stop
475   ENDIF
476#ifdef NC_DOUBLE
477   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, psfile)
478#else
479   ierr = NF_GET_VAR_REAL(nid, nvarid, psfile)
480#endif
481
482print *,'Ground Temperature'
483   ierr = NF_INQ_VARID (nid,"tsol",nvarid)
484   IF (ierr .NE. NF_NOERR) THEN
485      PRINT *, "Error: Readmeteo <tsurf> not found"
486      stop
487   ENDIF
488#ifdef NC_DOUBLE
489   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsfile)
490#else
491   ierr = NF_GET_VAR_REAL(nid, nvarid, tsfile)
492#endif
493
494
495!!!"atmospheric" surface temperature is taken
496!!!from original diagfi.nc first level
497!!!... level is ~3-5 meters
498!print *,'Near-Surface Temperature'
499!   ierr = NF_INQ_VARID (nid,"temp",nvarid)
500!   IF (ierr .NE. NF_NOERR) THEN
501!      ierr = NF_INQ_VARID (nid,"t",nvarid)
502!       IF (ierr .NE. NF_NOERR) THEN
503!           PRINT *, "Error: Readmeteo <temp> not found"
504!           stop
505!       ENDIF
506!   ENDIF
507!#ifdef NC_DOUBLE
508!   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tfileorig)
509!#else
510!   ierr = NF_GET_VAR_REAL(nid, nvarid, tfileorig)
511!#endif
512!   tnsfile=tfileorig(:,:,1,:)
513
514!!!"atmospheric" surface u is taken
515!!!from original diagfi.nc first level
516!!!... level is ~3-5 meters
517!print *,'Near-Surface Zonal Wind'
518!   ierr = NF_INQ_VARID (nid,"u",nvarid)
519!   IF (ierr .NE. NF_NOERR) THEN
520!     PRINT *, "Error: Readmeteo <u> not found"
521!     stop
522!   ENDIF
523!#ifdef NC_DOUBLE
524!   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ufileorig)
525!#else
526!   ierr = NF_GET_VAR_REAL(nid, nvarid, ufileorig)
527!#endif
528!   unsfile=ufileorig(:,:,1,:)
529
530!!!"atmospheric" surface v is taken
531!!!from original diagfi.nc first level
532!!!... level is ~3-5 meters
533!print *,'Near-Surface Meridional Wind'
534!   ierr = NF_INQ_VARID (nid,"v",nvarid)
535!   IF (ierr .NE. NF_NOERR) THEN
536!     PRINT *, "Error: Readmeteo <v> not found"
537!     stop
538!   ENDIF
539!#ifdef NC_DOUBLE
540!   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, vfileorig)
541!#else
542!   ierr = NF_GET_VAR_REAL(nid, nvarid, vfileorig)
543!#endif
544!   vnsfile=vfileorig(:,:,1,:)
545
546print *,'>>> Read 3D meteorological fields ! - This may take some time ...'
547
548print *,'Geopotential height'
549   ierr = NF_INQ_VARID (nid,"geop",nvarid)
550   IF (ierr .NE. NF_NOERR) THEN
551      PRINT *, "Error: Readmeteo <geop> not found"
552      stop
553   ENDIF
554#ifdef NC_DOUBLE
555   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ghfile)
556#else
557   ierr = NF_GET_VAR_REAL(nid, nvarid, ghfile)
558#endif
559ghtsfile=ghfile(:,:,1,1)/grav !surface geop
560
561print *,'Pressure'
562   ierr = NF_INQ_VARID (nid,"pres",nvarid)
563   IF (ierr .NE. NF_NOERR) THEN
564      ierr = NF_INQ_VARID (nid,"p",nvarid)
565        IF (ierr .NE. NF_NOERR) THEN
566          PRINT *, "Error: Readmeteo <p> not found"
567          stop
568        ENDIF
569   ENDIF
570#ifdef NC_DOUBLE
571   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, pfile)
572#else
573   ierr = NF_GET_VAR_REAL(nid, nvarid, pfile)
574#endif
575
576print *,'Temperature'
577   ierr = NF_INQ_VARID (nid,"temp",nvarid)
578   IF (ierr .NE. NF_NOERR) THEN
579      ierr = NF_INQ_VARID (nid,"t",nvarid)
580        IF (ierr .NE. NF_NOERR) THEN
581          PRINT *, "Error: Readmeteo <t> not found"
582          stop
583        ENDIF
584   ENDIF
585#ifdef NC_DOUBLE
586   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tfile)
587#else
588   ierr = NF_GET_VAR_REAL(nid, nvarid, tfile)
589#endif
590tnsfile=tfile(:,:,1,:)
591
592print *,'Zonal wind'   
593   ierr = NF_INQ_VARID (nid,"vitu",nvarid)
594   IF (ierr .NE. NF_NOERR) THEN
595      PRINT *, "Error: Readmeteo <u> not found"
596      stop
597   ENDIF
598#ifdef NC_DOUBLE
599   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ufile)
600#else
601   ierr = NF_GET_VAR_REAL(nid, nvarid, ufile)
602#endif
603unsfile=ufile(:,:,1,:)
604
605print *,'Meridional wind'
606   ierr = NF_INQ_VARID (nid,"vitv",nvarid)
607   IF (ierr .NE. NF_NOERR) THEN
608      PRINT *, "Error: Readmeteo <v> not found"
609      stop
610   ENDIF
611#ifdef NC_DOUBLE
612   ierr = NF_GET_VAR_DOUBLE(nid, nvarid, vfile)
613#else
614   ierr = NF_GET_VAR_REAL(nid, nvarid, vfile)
615#endif
616vnsfile=vfile(:,:,1,:)
617
618!!------------------------
619!! special water stuff
620!!------------------------
621    print *,'Water vapor'
622    ierr=NF_INQ_VARID(nid,"q02",nvarid)
623    if (ierr.ne.NF_NOERR) then
624      write(*,*) "...No q02 - Water vapor set to 0"
625      waterfile(:,:,:,:)=0. 
626    else
627      ierr=NF_GET_VAR_REAL(nid,nvarid,waterfile)
628    endif   
629
630    print *,'Water ice'
631    ierr=NF_INQ_VARID(nid,"q01",nvarid)
632    if (ierr.ne.NF_NOERR) then
633      write(*,*) "...No q01 - Water ice set to 0" 
634      watericefile(:,:,:,:)=0.
635    else
636      ierr=NF_GET_VAR_REAL(nid,nvarid,watericefile)
637    endif
638!    print *,'Surface Water vapor'
639!    ierr=NF_INQ_VARID(nid,"qsurf02",nvarid)
640!    if (ierr.ne.NF_NOERR) then
641!      write(*,*) "...No qsurf02 - surface Water vapor set to 0"
642!      swaterfile(:,:,:)=0.
643!    endif
644!    ierr=NF_GET_VAR_REAL(nid,nvarid,swaterfile)
645
646    print *,'Surface Water ice'
647!!!!!! ATTENTION ATTENTION
648!!!!!! water ice a la surface est qsurf(ig,nqmx)
649    ierr=NF_INQ_VARID(nid,"qsurf02",nvarid)
650    if (ierr.ne.NF_NOERR) then
651      write(*,*) "...No qsurf02 - surface Water ice set to 0"
652      swatericefile(:,:,:)=0.
653    else
654      ierr=NF_GET_VAR_REAL(nid,nvarid,swatericefile)
655    endif
656!!------------------------
657!! special water stuff
658!!------------------------
659
660    print *,'CO2 mass mixing ratio'
661    ierr=NF_INQ_VARID(nid,"co2",nvarid)
662    if (ierr.ne.NF_NOERR) then
663      write(*,*) "...No co2 - co2 mixing ratio set to 0.95"
664      co2file(:,:,:,:)=0.95
665    else
666      ierr=NF_GET_VAR_REAL(nid,nvarid,co2file)
667    endif
668
669!!------------------------
670!! special dust stuff
671!!------------------------
672    print *,'Dust mass'
673    ierr=NF_INQ_VARID(nid,"dustq",nvarid)
674    if (ierr.ne.NF_NOERR) then
675      write(*,*) "...No dustq - Dust mass set to 0"
676      dustfile(:,:,:,:)=0.
677    else
678      ierr=NF_GET_VAR_REAL(nid,nvarid,dustfile)
679    endif
680
681    print *,'Dust number'
682    ierr=NF_INQ_VARID(nid,"dustN",nvarid)
683    if (ierr.ne.NF_NOERR) then
684      write(*,*) "...No dustN - Dust number set to 0"
685      dustnfile(:,:,:,:)=0.
686    else
687      ierr=NF_GET_VAR_REAL(nid,nvarid,dustnfile)
688    endif
689
690    print *,'CCN mass'
691    ierr=NF_INQ_VARID(nid,"ccn",nvarid)
692    if (ierr.ne.NF_NOERR) then
693      write(*,*) "...No ccn - CCN mass set to 0"
694      ccnfile(:,:,:,:)=0.
695    else
696      ierr=NF_GET_VAR_REAL(nid,nvarid,ccnfile)
697    endif
698
699    print *,'CCN number'
700    ierr=NF_INQ_VARID(nid,"ccnN",nvarid)
701    if (ierr.ne.NF_NOERR) then
702      write(*,*) "...No ccnN - CCN number set to 0"
703      ccnnfile(:,:,:,:)=0.
704    else
705      ierr=NF_GET_VAR_REAL(nid,nvarid,ccnnfile)
706    endif
707!!------------------------
708!! special dust stuff
709!!------------------------
710
711!SELECT CASE(ident)
712!CASE('LMD')
713
714    print *,'Soil temperatures'
715    ierr=NF_INQ_VARID(nid,"tsoil",nvarid)
716    if (ierr.ne.NF_NOERR) then
717        write(*,*) "...No tsoil - Soil temperatures set isothermal with surface temperature"
718        DO l=1,altlen
719                tsoilfile(:,:,l,:)=tsfile(:,:,:)
720        ENDDO
721    else
722        ierr=NF_GET_VAR_REAL(nid,nvarid,tsoilfile)
723    endif
724
725!!!!!!!!
726!!!!!!!! new physics (but still compatible with old physics)
727    print *,'Soil depths'
728    ierr=NF_INQ_VARID(nid,"soildepth",nvarid)
729    if (ierr.ne.NF_NOERR) then
730        write(*,*) "...No soildepth - Set to -999"  !!! see soil_settings in LMD physics
731        DO l=1,altlen
732                vertdsoil(l)=-999.
733        ENDDO
734    else
735        ierr=NF_GET_VAR_REAL(nid,nvarid,vertdsoil)
736    endif
737    print *, 'wait a minute' !! AS: I know this could be better
738    DO m=1,lonlen
739     DO n=1,latlen
740      DO p=1,timelen
741       dsoilfile(m,n,:,p) = vertdsoil(:)
742      ENDDO
743     ENDDO
744    ENDDO
745    DEALLOCATE(vertdsoil)
746
747    print *,'Soil thermal inertia'
748    ierr=NF_INQ_VARID(nid,"inertiedat",nvarid)
749    if (ierr.ne.NF_NOERR) then
750        write(*,*) "...No soil therm. inert. - Set to -999"
751        DO l=1,altlen
752                isoilfile(:,:,l,:)=-999.
753        ENDDO
754    else
755        ierr=NF_GET_VAR_REAL(nid,nvarid,isoilfile)
756    endif
757!!!!!!!!
758!!!!!!!! new physics
759
760
761!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
762!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
763#ifdef PHOTOCHEM
764    print *,'photochem'
765    DO i=1,nchemtrac
766     print *,wtnom(i)
767     ierr=NF_INQ_VARID(nid,wtnom(i),nvarid)
768     if (ierr.ne.NF_NOERR) then
769       write(*,*) "...No ",wtnom(i), " - set to 0"
770       chemtrac(:,:,:,:,i)=0.
771     else
772       ierr=NF_GET_VAR_REAL(nid,nvarid,chemtrac(:,:,:,:,i))
773     endif
774    ENDDO
775#endif
776!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
777!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
778
779
780
781!END SELECT
782
783print*,'VENUS : rotation backward -> inversion of lat and long'
784DO i=1,latlen
785DO j=1,lonlen
786  psfile(j,i,:)=psfile(lonlen+1-j,latlen+1-i,:)
787  tsfile(i,j,:)=tsfile(lonlen+1-j,latlen+1-i,:)
788  ghtsfile(j,i)=ghtsfile(lonlen+1-j,latlen+1-i)
789  ghfile(j,i,:,:)=ghfile(lonlen+1-j,latlen+1-i,:,:)
790  pfile(j,i,:,:)=pfile(lonlen+1-j,latlen+1-i,:,:)
791  tfile(j,i,:,:)=tfile(lonlen+1-j,latlen+1-i,:,:)
792  ufile(j,i,:,:)=ufile(lonlen+1-j,latlen+1-i,:,:)
793  vfile(j,i,:,:)=vfile(lonlen+1-j,latlen+1-i,:,:)
794  tsoilfile(j,i,:,:)=tsoilfile(lonlen+1-j,latlen+1-i,:,:)
795#ifdef PHOTOCHEM
796 chemtrac(j,i,:,:,:)=chemtrac(lonlen+1-j,latlen+1-i,:,:,:)
797#endif
798ENDDO
799ENDDO 
800
801ierr=NF_CLOSE(nid)
802
803!!!!lott stuff
804!print *,'get lott'
805!ierr=NF_OPEN("init_lott.nc",NF_NOWRITE,nid3)
806!ierr=NF_INQ_VARID(nid3,"ZMEA",nvarid)
807!ierr=NF_GET_VAR_REAL(nid3,nvarid,interm)
808!gwparam(:,:,1)=interm(:,:)
809!ierr=NF_INQ_VARID(nid3,"ZSTD",nvarid)
810!ierr=NF_GET_VAR_REAL(nid3,nvarid,interm)
811!gwparam(:,:,2)=interm(:,:)
812!ierr=NF_INQ_VARID(nid3,"ZSIG",nvarid)
813!ierr=NF_GET_VAR_REAL(nid3,nvarid,interm)
814!gwparam(:,:,3)=interm(:,:)
815!ierr=NF_INQ_VARID(nid3,"ZGAM",nvarid)
816!ierr=NF_GET_VAR_REAL(nid3,nvarid,interm)
817!gwparam(:,:,4)=interm(:,:)
818!ierr=NF_INQ_VARID(nid3,"ZTHE",nvarid)
819!ierr=NF_GET_VAR_REAL(nid3,nvarid,interm)
820!gwparam(:,:,5)=interm(:,:)
821!ierr=NF_CLOSE(nid3)
822
823ENDIF
824
825!!-----------------------------
826!! Loop on the written files
827!! >>> what follows is pretty repetitive ...
828!!        gotta do something (one more loop?)
829!!-----------------------------
830
831!!! Equivalent eta levels for WRF interpolation in initialize_real
832!print *,'Computing equivalent eta levels'
833!       
834!       !ptop will be passed through RH(surface)
835!       ptop=MINVAL(aps(altlen)+bps(altlen)*psfile(:,:,:))
836!       print *, 'ptop', ptop
837!
838!print *, 'sample: equivalent eta levels at i=1,j=1'
839!DO k = 1,altlen
840!        levels(k)=-k
841!        eta_gcm(:,:,k,:)=(aps(k)+bps(k)*psfile(:,:,:)-ptop)/(psfile(:,:,:)-ptop)
842!        print *, eta_gcm(1,1,k,1)
843!END DO
844
845!!---better to pass pressure values
846!!---the eta treatment is done in module_initialize_real
847DO k = 1,altlen
848        levels(k)=-k
849        !!dummy decreasing levels
850END DO
851
852
853
854
855!! Dummy surface level is XLVL=200100.
856
857
858DO l=1,FILES
859
860
861!!---------------------------------------------
862!! Write file in intermediate format for WPS
863!! 1. Surface data
864!!---------------------------------------------
865!!
866!! a mettre pour tous sinon
867!!     WRF_DEBUG: Warning DIM             4 , NAME num_metgrid_levels REDIFINED  by
868!!            var DUSTN            26           25  in wrf_io.F90 line         2349
869!!
870
871!
872! These variables remain the same in the "loop"
873!
874HDATE=date_out(l)
875IFV=4
876XFCST=0.
877SOURCE=ident
878NX=lonlen
879NY=latlen
880ALLOCATE(SLAB(NX,NY))
881IPROJ=0
882STARTLOC='SWCORNER'
883STARTLAT=lat(1)
884STARTLON=lon(1)
885DELTALAT=lat(latlen)-lat(latlen-1)
886DELTALON=lon(lonlen)-lon(lonlen-1)
887!
888! Open the data destination file
889!
890output="./WPSFEED/"//ident//":"//date_out2(l)       
891open(UNIT=1,                    &
892        FILE=output,            &
893        STATUS='REPLACE',       &
894        FORM='UNFORMATTED',     &
895        ACCESS='SEQUENTIAL')
896
897!------------------------!   
898! >>> Write a variable   !
899!    ... Copy&Paste part !
900!------------------------!
901FIELD='T'
902UNITS='K'
903DESC='Atmospheric temperature'
904XLVL=200100.
905SLAB=tnsfile(:,:,time_out(l))
906        ! And now put everything in the destination file
907        ! ... Header
908        write(1) IFV
909        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
910        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
911        ! ... Data
912        write(1) SLAB
913!print *,'The field '//DESC//' was written to '//output
914!------------------------!   
915! >>> Write a variable   !
916!    ... Copy&Paste part !
917!------------------------!
918FIELD='U'
919UNITS='m s{-1}'
920DESC='Zonal wind'
921XLVL=200100.
922SLAB=unsfile(:,:,time_out(l))
923        ! And now put everything in the destination file
924        ! ... Header
925        write(1) IFV
926        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
927        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
928        ! ... Data
929        write(1) SLAB
930!print *,'The field '//DESC//' was written to '//output
931!------------------------!   
932! >>> Write a variable   !
933!    ... Copy&Paste part !
934!------------------------!
935FIELD='V'
936UNITS='m s{-1}'
937DESC='Meridional wind'
938XLVL=200100.
939SLAB=-1*vnsfile(:,:,time_out(l)) !VENUS ratoting backwards : v=-1*v
940        ! And now put everything in the destination file
941        ! ... Header
942        write(1) IFV
943        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
944        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
945        ! ... Data
946        write(1) SLAB
947!print *,'The field '//DESC//' was written to '//output
948!------------------------!   
949! >>> Write a variable   !
950!    ... Copy&Paste part !
951!------------------------!
952FIELD='RH'
953UNITS=''
954DESC='Customized 2D static field'
955XLVL=200100.
956SLAB=vide(:,:)
957        ! And now put everything in the destination file
958        ! ... Header
959        write(1) IFV
960        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
961        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
962        ! ... Data
963        write(1) SLAB
964!print *,'The field '//DESC//' was written to '//output
965
966!------------------------!   
967! >>> Write a variable   !
968!    ... Copy&Paste part !
969!------------------------!
970FIELD='SOILHGT'
971UNITS='m'
972DESC='Terrain field of source analysis'  !Ground geopotential height
973XLVL=200100.
974SLAB=ghtsfile(:,:)
975        ! And now put everything in the destination file
976        ! ... Header
977        write(1) IFV
978        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
979        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
980        ! ... Data
981        write(1) SLAB
982!print *,'The field '//DESC//' was written to '//output
983
984!------------------------!   
985! >>> Write a variable   !
986!    ... Copy&Paste part !
987!------------------------!
988FIELD='PSFC'
989UNITS='Pa'
990DESC='Surface Pressure'
991XLVL=200100.
992SLAB=psfile(:,:,time_out(l))
993        ! And now put everything in the destination file
994        ! ... Header
995        write(1) IFV
996        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
997        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
998        ! ... Data
999        write(1) SLAB
1000!print *,'The field '//DESC//' was written to '//output
1001
1002!------------------------!   
1003! >>> Write a variable   !
1004!    ... Copy&Paste part !
1005!------------------------!
1006FIELD='ST000010'
1007UNITS=''
1008DESC='Emissivity'
1009XLVL=200100.
1010SLAB=emissfile(:,:,time_out(l))
1011        ! And now put everything in the destination file
1012        ! ... Header
1013        write(1) IFV
1014        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1015        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1016        ! ... Data
1017        write(1) SLAB
1018!print *,'The field '//DESC//' was written to '//output
1019
1020!------------------------!   
1021! >>> Write a variable   !
1022!    ... Copy&Paste part !
1023!------------------------!
1024FIELD='ST010040'
1025UNITS=''
1026DESC='CO2 ice'
1027XLVL=200100.
1028SLAB=co2icefile(:,:,time_out(l))
1029        ! And now put everything in the destination file
1030        ! ... Header
1031        write(1) IFV
1032        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1033        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1034        ! ... Data
1035        write(1) SLAB
1036!print *,'The field '//DESC//' was written to '//output
1037
1038!------------------------!   
1039! >>> Write a variable   !
1040!    ... Copy&Paste part !
1041!------------------------!
1042FIELD='ST040100'
1043UNITS=''
1044DESC='ZMEA'
1045XLVL=200100.
1046SLAB=gwparam(:,:,1)
1047        ! And now put everything in the destination file
1048        ! ... Header
1049        write(1) IFV
1050        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1051        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1052        ! ... Data
1053        write(1) SLAB
1054!print *,'The field '//DESC//' was written to '//output
1055
1056!------------------------!   
1057! >>> Write a variable   !
1058!    ... Copy&Paste part !
1059!------------------------!
1060FIELD='ST100200'
1061UNITS=''
1062DESC='ZSTD'
1063XLVL=200100.
1064SLAB=gwparam(:,:,2)
1065        ! And now put everything in the destination file
1066        ! ... Header
1067        write(1) IFV
1068        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1069        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1070        ! ... Data
1071        write(1) SLAB
1072!print *,'The field '//DESC//' was written to '//output
1073
1074!------------------------!   
1075! >>> Write a variable   !
1076!    ... Copy&Paste part !
1077!------------------------!
1078FIELD='LANDSEA'
1079UNITS='0/1 Flag'
1080DESC='Land/Sea flag'
1081XLVL=200100.
1082SLAB=ones(:,:)
1083        ! And now put everything in the destination file
1084        ! ... Header
1085        write(1) IFV
1086        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1087        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1088        ! ... Data
1089        write(1) SLAB
1090!print *,'The field '//DESC//' was written to '//output
1091
1092!------------------------!   
1093! >>> Write a variable   !
1094!    ... Copy&Paste part !
1095!------------------------!
1096FIELD='SKINTEMP'
1097UNITS='K'
1098DESC='Ground temperature'
1099XLVL=200100.
1100SLAB=tsfile(:,:,time_out(l))
1101        ! And now put everything in the destination file
1102        ! ... Header
1103        write(1) IFV
1104        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1105        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1106        ! ... Data
1107        write(1) SLAB
1108!print *,'The field '//DESC//' was written to '//output
1109
1110!------------------------!   
1111! >>> Write a variable   !
1112!    ... Copy&Paste part !
1113!------------------------!
1114FIELD='SM000010'
1115UNITS=''
1116DESC='ZSIG'
1117XLVL=200100.
1118SLAB=gwparam(:,:,3)
1119        ! And now put everything in the destination file
1120        ! ... Header
1121        write(1) IFV
1122        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1123        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1124        ! ... Data
1125        write(1) SLAB
1126!print *,'The field '//DESC//' was written to '//output
1127
1128!------------------------!   
1129! >>> Write a variable   !
1130!    ... Copy&Paste part !
1131!------------------------!
1132FIELD='SM010040'
1133UNITS=''
1134DESC='ZGAM'
1135XLVL=200100.
1136SLAB=gwparam(:,:,4)
1137        ! And now put everything in the destination file
1138        ! ... Header
1139        write(1) IFV
1140        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1141        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1142        ! ... Data
1143        write(1) SLAB
1144!print *,'The field '//DESC//' was written to '//output
1145
1146!------------------------!   
1147! >>> Write a variable   !
1148!    ... Copy&Paste part !
1149!------------------------!
1150FIELD='SM040100'
1151UNITS=''
1152DESC='ZTHE'
1153XLVL=200100.
1154SLAB=gwparam(:,:,5)
1155        ! And now put everything in the destination file
1156        ! ... Header
1157        write(1) IFV
1158        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1159        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1160        ! ... Data
1161        write(1) SLAB
1162!print *,'The field '//DESC//' was written to '//output
1163
1164!------------------------!   
1165! >>> Write a variable   !
1166!    ... Copy&Paste part !
1167!------------------------!
1168FIELD='SM100200'
1169UNITS='kg/m2'
1170DESC='Surf water ice'
1171XLVL=200100.
1172SLAB=swatericefile(:,:,time_out(l))
1173        ! And now put everything in the destination file
1174        ! ... Header
1175        write(1) IFV
1176        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1177        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1178        ! ... Data
1179        write(1) SLAB
1180!print *,'The field '//DESC//' was written to '//output
1181
1182
1183!------------------------!
1184! >>> Write a variable   !
1185!    ... Copy&Paste part !
1186!------------------------!
1187FIELD='HV'
1188UNITS='kg/kg'
1189DESC='Water vapor'
1190XLVL=200100.
1191SLAB=waterfile(:,:,1,time_out(l))
1192        ! And now put everything in the destination file
1193        ! ... Header
1194        write(1) IFV
1195        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1196        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1197        ! ... Data
1198        write(1) SLAB
1199!print *,'The field '//DESC//' was written to '//output
1200
1201!------------------------!
1202! >>> Write a variable   !
1203!    ... Copy&Paste part !
1204!------------------------!
1205FIELD='HI'
1206UNITS='kg/kg'
1207DESC='Water ice'
1208XLVL=200100.
1209SLAB=watericefile(:,:,1,time_out(l))
1210        ! And now put everything in the destination file
1211        ! ... Header
1212        write(1) IFV
1213        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1214        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1215        ! ... Data
1216        write(1) SLAB
1217!print *,'The field '//DESC//' was written to '//output
1218
1219!------------------------!
1220! >>> Write a variable   !
1221!    ... Copy&Paste part !
1222!------------------------!
1223FIELD='TSOIL'
1224UNITS='K'
1225DESC='Soil temperature'
1226XLVL=200100.
1227SLAB=tsoilfile(:,:,1,time_out(l))
1228        ! And now put everything in the destination file
1229        ! ... Header
1230        write(1) IFV
1231        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1232        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1233        ! ... Data
1234        write(1) SLAB
1235!print *,'The field '//DESC//' was written to '//output
1236
1237!------------------------!
1238! >>> Write a variable   !
1239!    ... Copy&Paste part !
1240!------------------------!
1241FIELD='DSOIL'
1242UNITS='m'
1243DESC='Soil depths'
1244XLVL=200100.
1245SLAB=dsoilfile(:,:,1,time_out(l))
1246        ! And now put everything in the destination file
1247        ! ... Header
1248        write(1) IFV
1249        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1250        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1251        ! ... Data
1252        write(1) SLAB
1253!print *,'The field '//DESC//' was written to '//output
1254
1255!------------------------!
1256! >>> Write a variable   !
1257!    ... Copy&Paste part !
1258!------------------------!
1259FIELD='ISOIL'
1260UNITS='tiu'
1261DESC='Soil thermal inertia'
1262XLVL=200100.
1263SLAB=isoilfile(:,:,1,time_out(l))
1264        ! And now put everything in the destination file
1265        ! ... Header
1266        write(1) IFV
1267        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1268        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1269        ! ... Data
1270        write(1) SLAB
1271!print *,'The field '//DESC//' was written to '//output
1272
1273!------------------------!
1274! >>> Write a variable   !
1275!    ... Copy&Paste part !
1276!------------------------!
1277FIELD='CO2'
1278UNITS='kg/kg'
1279DESC='CO2 mixing ratio'
1280XLVL=200100.
1281SLAB=co2file(:,:,1,time_out(l))
1282        ! And now put everything in the destination file
1283        ! ... Header
1284        write(1) IFV
1285        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1286        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1287        ! ... Data
1288        write(1) SLAB
1289!print *,'The field '//DESC//' was written to '//output
1290
1291!------------------------!
1292! >>> Write a variable   !
1293!    ... Copy&Paste part !
1294!------------------------!
1295FIELD='DUSTQ'
1296UNITS='kg/kg'
1297DESC='Dust mixing ratio'
1298XLVL=200100.
1299SLAB=dustfile(:,:,1,time_out(l))
1300        ! And now put everything in the destination file
1301        ! ... Header
1302        write(1) IFV
1303        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1304        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1305        ! ... Data
1306        write(1) SLAB
1307!print *,'The field '//DESC//' was written to '//output
1308
1309!------------------------!
1310! >>> Write a variable   !
1311!    ... Copy&Paste part !
1312!------------------------!
1313FIELD='DUSTN'
1314UNITS='part/kg'
1315DESC='Dust number density'
1316XLVL=200100.
1317SLAB=dustnfile(:,:,1,time_out(l))
1318        ! And now put everything in the destination file
1319        ! ... Header
1320        write(1) IFV
1321        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1322        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1323        ! ... Data
1324        write(1) SLAB
1325!print *,'The field '//DESC//' was written to '//output
1326
1327!------------------------!
1328! >>> Write a variable   !
1329!    ... Copy&Paste part !
1330!------------------------!
1331FIELD='CCNQ'
1332UNITS='kg/kg'
1333DESC='CCN mixing ratio'
1334XLVL=200100.
1335SLAB=ccnfile(:,:,1,time_out(l))
1336        ! And now put everything in the destination file
1337        ! ... Header
1338        write(1) IFV
1339        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1340        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1341        ! ... Data
1342        write(1) SLAB
1343!print *,'The field '//DESC//' was written to '//output
1344
1345!------------------------!
1346! >>> Write a variable   !
1347!    ... Copy&Paste part !
1348!------------------------!
1349FIELD='CCNN'
1350UNITS='part/kg'
1351DESC='CCN number density'
1352XLVL=200100.
1353SLAB=ccnnfile(:,:,1,time_out(l))
1354        ! And now put everything in the destination file
1355        ! ... Header
1356        write(1) IFV
1357        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1358        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1359        ! ... Data
1360        write(1) SLAB
1361!print *,'The field '//DESC//' was written to '//output
1362
1363
1364!------------------------!
1365! >>> Write a variable   !
1366!     PHOTOCHEMISTRY     !
1367!------------------------!
1368#ifdef PHOTOCHEM
1369        FIELD='CO2'
1370        UNITS='kg/kg'
1371        DESC='CO2 mixing ratio'
1372        XLVL=levels(k)
1373        SLAB=chemtrac(:,:,1,time_out(l),1)
1374                ! And now put everything in the destination file
1375                ! ... Header
1376        write(1) IFV
1377        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1378        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1379                ! ... Data
1380        write(1) SLAB
1381
1382
1383        FIELD='CO'
1384        UNITS='kg/kg'
1385        DESC='CO mixing ratio'
1386        XLVL=levels(k)
1387        SLAB=chemtrac(:,:,1,time_out(l),2)
1388                ! And now put everything in the destination file
1389                ! ... Header
1390        write(1) IFV
1391        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1392        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1393                ! ... Data
1394        write(1) SLAB
1395
1396
1397        FIELD='H2'
1398        UNITS='kg/kg'
1399        DESC='H2 mixing ratio'
1400        XLVL=levels(k)
1401        SLAB=chemtrac(:,:,1,time_out(l),3)
1402                ! And now put everything in the destination file
1403                ! ... Header
1404        write(1) IFV
1405        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1406        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1407                ! ... Data
1408        write(1) SLAB
1409
1410
1411        FIELD='H2O'
1412        UNITS='kg/kg'
1413        DESC='H2O mixing ratio'
1414        XLVL=levels(k)
1415        SLAB=chemtrac(:,:,1,time_out(l),4)
1416                ! And now put everything in the destination file
1417                ! ... Header
1418        write(1) IFV
1419        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1420        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1421                ! ... Data
1422        write(1) SLAB
1423
1424
1425        FIELD='O1D'
1426        UNITS='kg/kg'
1427        DESC='O1D mixing ratio'
1428        XLVL=levels(k)
1429        SLAB=chemtrac(:,:,1,time_out(l),5)
1430                ! And now put everything in the destination file
1431                ! ... Header
1432        write(1) IFV
1433        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1434        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1435                ! ... Data
1436        write(1) SLAB
1437
1438
1439        FIELD='O'
1440        UNITS='kg/kg'
1441        DESC='O mixing ratio'
1442        XLVL=levels(k)
1443        SLAB=chemtrac(:,:,1,time_out(l),6)
1444                ! And now put everything in the destination file
1445                ! ... Header
1446        write(1) IFV
1447        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1448        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1449                ! ... Data
1450        write(1) SLAB
1451
1452
1453        FIELD='O2'
1454        UNITS='kg/kg'
1455        DESC='O2 mixing ratio'
1456        XLVL=levels(k)
1457        SLAB=chemtrac(:,:,1,time_out(l),7)
1458                ! And now put everything in the destination file
1459                ! ... Header
1460        write(1) IFV
1461        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1462        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1463                ! ... Data
1464        write(1) SLAB
1465
1466
1467        FIELD='O2DG'
1468        UNITS='kg/kg'
1469        DESC='O2DG mixing ratio'
1470        XLVL=levels(k)
1471        SLAB=chemtrac(:,:,1,time_out(l),8)
1472                ! And now put everything in the destination file
1473                ! ... Header
1474        write(1) IFV
1475        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1476        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1477                ! ... Data
1478        write(1) SLAB
1479
1480
1481        FIELD='O3'
1482        UNITS='kg/kg'
1483        DESC='O3 mixing ratio'
1484        XLVL=levels(k)
1485        SLAB=chemtrac(:,:,1,time_out(l),9)
1486                ! And now put everything in the destination file
1487                ! ... Header
1488        write(1) IFV
1489        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1490        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1491                ! ... Data
1492        write(1) SLAB
1493
1494
1495        FIELD='H'
1496        UNITS='kg/kg'
1497        DESC='H mixing ratio'
1498        XLVL=levels(k)
1499        SLAB=chemtrac(:,:,1,time_out(l),10)
1500                ! And now put everything in the destination file
1501                ! ... Header
1502        write(1) IFV
1503        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1504        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1505                ! ... Data
1506        write(1) SLAB
1507
1508
1509        FIELD='OH'
1510        UNITS='kg/kg'
1511        DESC='OH mixing ratio'
1512        XLVL=levels(k)
1513        SLAB=chemtrac(:,:,1,time_out(l),11)
1514                ! And now put everything in the destination file
1515                ! ... Header
1516        write(1) IFV
1517        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1518        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1519                ! ... Data
1520        write(1) SLAB
1521
1522
1523        FIELD='HO2'
1524        UNITS='kg/kg'
1525        DESC='hO2 mixing ratio'
1526        XLVL=levels(k)
1527        SLAB=chemtrac(:,:,1,time_out(l),12)
1528                ! And now put everything in the destination file
1529                ! ... Header
1530        write(1) IFV
1531        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1532        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1533                ! ... Data
1534        write(1) SLAB
1535
1536
1537        FIELD='H2O2'
1538        UNITS='kg/kg'
1539        DESC='H2O2 mixing ratio'
1540        XLVL=levels(k)
1541        SLAB=chemtrac(:,:,1,time_out(l),13)
1542                ! And now put everything in the destination file
1543                ! ... Header
1544        write(1) IFV
1545        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1546        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1547                ! ... Data
1548        write(1) SLAB
1549
1550
1551        FIELD='Cl'
1552        UNITS='kg/kg'
1553        DESC='Cl mixing ratio'
1554        XLVL=levels(k)
1555        SLAB=chemtrac(:,:,1,time_out(l),14)
1556                ! And now put everything in the destination file
1557                ! ... Header
1558        write(1) IFV
1559        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1560        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1561                ! ... Data
1562        write(1) SLAB
1563
1564
1565        FIELD='ClO'
1566        UNITS='kg/kg'
1567        DESC='ClO mixing ratio'
1568        XLVL=levels(k)
1569        SLAB=chemtrac(:,:,1,time_out(l),15)
1570                ! And now put everything in the destination file
1571                ! ... Header
1572        write(1) IFV
1573        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1574        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1575                ! ... Data
1576        write(1) SLAB
1577
1578
1579        FIELD='Cl2'
1580        UNITS='kg/kg'
1581        DESC='Cl2 mixing ratio'
1582        XLVL=levels(k)
1583        SLAB=chemtrac(:,:,1,time_out(l),16)
1584                ! And now put everything in the destination file
1585                ! ... Header
1586        write(1) IFV
1587        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1588        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1589                ! ... Data
1590        write(1) SLAB
1591
1592
1593        FIELD='HCl'
1594        UNITS='kg/kg'
1595        DESC='HCl mixing ratio'
1596        XLVL=levels(k)
1597        SLAB=chemtrac(:,:,1,time_out(l),17)
1598                ! And now put everything in the destination file
1599                ! ... Header
1600        write(1) IFV
1601        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1602        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1603                ! ... Data
1604        write(1) SLAB
1605
1606
1607        FIELD='HOCl'
1608        UNITS='kg/kg'
1609        DESC='HOCl mixing ratio'
1610        XLVL=levels(k)
1611        SLAB=chemtrac(:,:,1,time_out(l),18)
1612                ! And now put everything in the destination file
1613                ! ... Header
1614        write(1) IFV
1615        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1616        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1617                ! ... Data
1618        write(1) SLAB
1619
1620
1621        FIELD='ClCO'
1622        UNITS='kg/kg'
1623        DESC='ClCO mixing ratio'
1624        XLVL=levels(k)
1625        SLAB=chemtrac(:,:,1,time_out(l),19)
1626                ! And now put everything in the destination file
1627                ! ... Header
1628        write(1) IFV
1629        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1630        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1631                ! ... Data
1632        write(1) SLAB
1633
1634
1635        FIELD='ClCO3'
1636        UNITS='kg/kg'
1637        DESC='ClCO3 mixing ratio'
1638        XLVL=levels(k)
1639        SLAB=chemtrac(:,:,1,time_out(l),20)
1640                ! And now put everything in the destination file
1641                ! ... Header
1642        write(1) IFV
1643        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1644        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1645                ! ... Data
1646        write(1) SLAB
1647
1648
1649        FIELD='COCl2'
1650        UNITS='kg/kg'
1651        DESC='COClC2 mixing ratio'
1652        XLVL=levels(k)
1653        SLAB=chemtrac(:,:,1,time_out(l),21)
1654                ! And now put everything in the destination file
1655                ! ... Header
1656        write(1) IFV
1657        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1658        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1659                ! ... Data
1660        write(1) SLAB
1661
1662
1663        FIELD='S'
1664        UNITS='kg/kg'
1665        DESC='S mixing ratio'
1666        XLVL=levels(k)
1667        SLAB=chemtrac(:,:,1,time_out(l),22)
1668                ! And now put everything in the destination file
1669                ! ... Header
1670        write(1) IFV
1671        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1672        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1673                ! ... Data
1674        write(1) SLAB
1675
1676
1677        FIELD='SO'
1678        UNITS='kg/kg'
1679        DESC='SO mixing ratio'
1680        XLVL=levels(k)
1681        SLAB=chemtrac(:,:,1,time_out(l),23)
1682                ! And now put everything in the destination file
1683                ! ... Header
1684        write(1) IFV
1685        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1686        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1687                ! ... Data
1688        write(1) SLAB
1689
1690
1691        FIELD='SO2'
1692        UNITS='kg/kg'
1693        DESC='SO2 mixing ratio'
1694        XLVL=levels(k)
1695        SLAB=chemtrac(:,:,1,time_out(l),24)
1696                ! And now put everything in the destination file
1697                ! ... Header
1698        write(1) IFV
1699        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1700        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1701                ! ... Data
1702        write(1) SLAB
1703
1704
1705        FIELD='SO3'
1706        UNITS='kg/kg'
1707        DESC='SO3 mixing ratio'
1708        XLVL=levels(k)
1709        SLAB=chemtrac(:,:,1,time_out(l),25)
1710                ! And now put everything in the destination file
1711                ! ... Header
1712        write(1) IFV
1713        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1714        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1715                ! ... Data
1716        write(1) SLAB
1717
1718
1719        FIELD='S2O2'
1720        UNITS='kg/kg'
1721        DESC='S2O2 mixing ratio'
1722        XLVL=levels(k)
1723        SLAB=chemtrac(:,:,1,time_out(l),26)
1724                ! And now put everything in the destination file
1725                ! ... Header
1726        write(1) IFV
1727        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1728        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1729                ! ... Data
1730        write(1) SLAB
1731
1732
1733        FIELD='OCS'
1734        UNITS='kg/kg'
1735        DESC='OCS mixing ratio'
1736        XLVL=levels(k)
1737        SLAB=chemtrac(:,:,1,time_out(l),27)
1738                ! And now put everything in the destination file
1739                ! ... Header
1740        write(1) IFV
1741        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1742        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1743                ! ... Data
1744        write(1) SLAB
1745
1746
1747        FIELD='HSO3'
1748        UNITS='kg/kg'
1749        DESC='HSO3 mixing ratio'
1750        XLVL=levels(k)
1751        SLAB=chemtrac(:,:,1,time_out(l),28)
1752                ! And now put everything in the destination file
1753                ! ... Header
1754        write(1) IFV
1755        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1756        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1757                ! ... Data
1758        write(1) SLAB
1759
1760
1761        FIELD='H2SO4'
1762        UNITS='kg/kg'
1763        DESC='H2SO4 mixing ratio'
1764        XLVL=levels(k)
1765        SLAB=chemtrac(:,:,1,time_out(l),29)
1766                ! And now put everything in the destination file
1767                ! ... Header
1768        write(1) IFV
1769        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1770        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1771                ! ... Data
1772        write(1) SLAB
1773
1774
1775        FIELD='S2'
1776        UNITS='kg/kg'
1777        DESC='S2 mixing ratio'
1778        XLVL=levels(k)
1779        SLAB=chemtrac(:,:,1,time_out(l),30)
1780                ! And now put everything in the destination file
1781                ! ... Header
1782        write(1) IFV
1783        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1784        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1785                ! ... Data
1786        write(1) SLAB
1787
1788
1789        FIELD='ClSO2'
1790        UNITS='kg/kg'
1791        DESC='ClSO2 mixing ratio'
1792        XLVL=levels(k)
1793        SLAB=chemtrac(:,:,1,time_out(l),31)
1794                ! And now put everything in the destination file
1795                ! ... Header
1796        write(1) IFV
1797        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1798        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1799                ! ... Data
1800        write(1) SLAB
1801
1802
1803        FIELD='OSCl'
1804        UNITS='kg/kg'
1805        DESC='OSCl mixing ratio'
1806        XLVL=levels(k)
1807        SLAB=chemtrac(:,:,1,time_out(l),32)
1808                ! And now put everything in the destination file
1809                ! ... Header
1810        write(1) IFV
1811        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1812        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1813                ! ... Data
1814        write(1) SLAB
1815
1816
1817        FIELD='H2Oliq'
1818        UNITS='kg/kg'
1819        DESC='H2Oliq mixing ratio'
1820        XLVL=levels(k)
1821        SLAB=chemtrac(:,:,1,time_out(l),33)
1822                ! And now put everything in the destination file
1823                ! ... Header
1824        write(1) IFV
1825        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1826        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1827                ! ... Data
1828        write(1) SLAB
1829
1830
1831        FIELD='H2SO4liq'
1832        UNITS='kg/kg'
1833        DESC='H2SO4liq mixing ratio'
1834        XLVL=levels(k)
1835        SLAB=chemtrac(:,:,1,time_out(l),34)
1836                ! And now put everything in the destination file
1837                ! ... Header
1838        write(1) IFV
1839        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1840        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1841                ! ... Data
1842        write(1) SLAB
1843#endif
1844
1845!!----------------------------------------------------
1846!! Write file in intermediate format for WPS
1847!! 2. 3D meteorological data
1848!! >>> same stuff, but handle vertical profile
1849!! >>> !! XLVL must be decreasing (pressure levels)
1850!!----------------------------------------------------
1851
1852!------------------------!   
1853! >>> Write a variable   !
1854!    ... Copy&Paste part !
1855!------------------------!
1856FIELD='T'
1857UNITS='K'
1858DESC='Atmospheric temperature'
1859DO k = 1,altlen
1860        XLVL=levels(k)
1861        SLAB=tfile(:,:,k,time_out(l))
1862                ! And now put everything in the destination file
1863                ! ... Header
1864        write(1) IFV
1865        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1866        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1867                ! ... Data
1868                write(1) SLAB
1869END DO
1870!print *,'The field '//DESC//' was written to '//output
1871
1872!------------------------!   
1873! >>> Write a variable   !
1874!    ... Copy&Paste part !
1875!------------------------!
1876FIELD='U'
1877UNITS='m s{-1}'
1878DESC='Zonal wind'
1879DO k = 1,altlen
1880        XLVL=levels(k)
1881        SLAB=ufile(:,:,k,time_out(l))
1882                ! And now put everything in the destination file
1883                ! ... Header
1884        write(1) IFV
1885        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1886        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1887                ! ... Data
1888                write(1) SLAB
1889                !write(1) ufile(:,:,k,time_out(l))
1890END DO
1891!print *,'The field '//DESC//' was written to '//output
1892
1893!------------------------!   
1894! >>> Write a variable   !
1895!    ... Copy&Paste part !
1896!------------------------!
1897FIELD='V'
1898UNITS='m s{-1}'
1899DESC='Meridional wind'
1900DO k = 1,altlen
1901        XLVL=levels(k)
1902        SLAB=-1*vfile(:,:,k,time_out(l)) ! VENUS rotation backward : v=-1*v
1903                ! And now put everything in the destination file
1904                ! ... Header
1905        write(1) IFV
1906        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1907        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1908                ! ... Data
1909                write(1) SLAB
1910END DO
1911!print *,'The field '//DESC//' was written to '//output
1912
1913!------------------------!   
1914! >>> Write a variable   !
1915!    ... Copy&Paste part !
1916!------------------------!
1917FIELD='RH'
1918UNITS=''
1919DESC='Customized 2D static field'
1920DESC='Eta-levels from the GCM'
1921DESC='Pressure values from the GCM'
1922DO k = 1,altlen
1923        XLVL=levels(k)
1924SELECT CASE(ident)
1925CASE('LMD')
1926        SLAB=pfile(:,:,k,time_out(l))
1927CASE('OXF')
1928        !SLAB=bps(k)*psfile(:,:,time_out(l))
1929END SELECT
1930                ! And now put everything in the destination file
1931                ! ... Header
1932        write(1) IFV
1933        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1934        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1935                ! ... Data
1936                write(1) SLAB
1937END DO
1938!print *,'The field '//DESC//' was written to '//output
1939
1940!------------------------!   
1941! >>> Write a variable   !
1942!    ... Copy&Paste part !
1943!------------------------!
1944FIELD='HGT'
1945UNITS='m'
1946DESC='Height'
1947DO k = 1,altlen
1948        XLVL=levels(k)
1949SELECT CASE(ident)
1950CASE('LMD')
1951        SLAB=(ghfile(:,:,k,time_out(l)))/grav
1952CASE('OXF')
1953        !SLAB=10000.*alog(610./(bps(k)*psfile(:,:,time_out(l))))
1954END SELECT
1955                ! And now put everything in the destination file
1956                ! ... Header
1957        write(1) IFV
1958        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1959        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON 
1960                ! ... Data
1961                write(1) SLAB
1962END DO
1963!print *,'The field '//DESC//' was written to '//output
1964
1965!------------------------!
1966! >>> Write a variable   !
1967!    ... Copy&Paste part !
1968!------------------------!
1969FIELD='HV'
1970UNITS='kg/kg'
1971DESC='Water vapor'
1972DO k = 1,altlen
1973        XLVL=levels(k)
1974        SLAB=waterfile(:,:,k,time_out(l))
1975                ! And now put everything in the destination file
1976                ! ... Header
1977        write(1) IFV
1978        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1979        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
1980                ! ... Data
1981                write(1) SLAB
1982END DO
1983!print *,'The field '//DESC//' was written to '//output
1984
1985!------------------------!
1986! >>> Write a variable   !
1987!    ... Copy&Paste part !
1988!------------------------!
1989FIELD='HI'
1990UNITS='kg/kg'
1991DESC='Water ice'
1992DO k = 1,altlen
1993        XLVL=levels(k)
1994        SLAB=watericefile(:,:,k,time_out(l))
1995                ! And now put everything in the destination file
1996                ! ... Header
1997        write(1) IFV
1998        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
1999        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2000                ! ... Data
2001                write(1) SLAB
2002END DO
2003!print *,'The field '//DESC//' was written to '//output
2004
2005!------------------------!
2006! >>> Write a variable   !
2007!    ... Copy&Paste part !
2008!------------------------!
2009FIELD='TSOIL'
2010UNITS='K'
2011DESC='Soil temperature'
2012DO k = 1,altlen
2013        XLVL=levels(k)
2014        SLAB=tsoilfile(:,:,k,time_out(l))
2015                ! And now put everything in the destination file
2016                ! ... Header
2017        write(1) IFV
2018        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2019        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2020                ! ... Data
2021                write(1) SLAB
2022END DO
2023!print *,'The field '//DESC//' was written to '//output
2024
2025!------------------------!
2026! >>> Write a variable   !
2027!    ... Copy&Paste part !
2028!------------------------!
2029FIELD='DSOIL'
2030UNITS='m'
2031DESC='Soil depths'
2032DO k = 1,altlen
2033        XLVL=levels(k)
2034        SLAB=dsoilfile(:,:,k,time_out(l))
2035                ! And now put everything in the destination file
2036                ! ... Header
2037        write(1) IFV
2038        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2039        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2040                ! ... Data
2041                write(1) SLAB
2042END DO
2043!print *,'The field '//DESC//' was written to '//output
2044
2045!------------------------!
2046! >>> Write a variable   !
2047!    ... Copy&Paste part !
2048!------------------------!
2049FIELD='ISOIL'
2050UNITS='tiu'
2051DESC='Soil thermal inertia'
2052DO k = 1,altlen
2053        XLVL=levels(k)
2054        SLAB=isoilfile(:,:,k,time_out(l))
2055       
2056                ! And now put everything in the destination file
2057                ! ... Header
2058        write(1) IFV
2059        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2060        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2061                ! ... Data
2062                write(1) SLAB
2063END DO
2064!print *,'The field '//DESC//' was written to '//output
2065
2066!------------------------!
2067! >>> Write a variable   !
2068!    ... Copy&Paste part !
2069!------------------------!
2070FIELD='CO2'
2071UNITS='kg/kg'
2072DESC='CO2 mixing ratio'
2073DO k = 1,altlen
2074        XLVL=levels(k)
2075        SLAB=co2file(:,:,k,time_out(l))
2076                ! And now put everything in the destination file
2077                ! ... Header
2078        write(1) IFV
2079        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2080        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2081                ! ... Data
2082                write(1) SLAB
2083END DO
2084!print *,'The field '//DESC//' was written to '//output
2085
2086!------------------------!
2087! >>> Write a variable   !
2088!    ... Copy&Paste part !
2089!------------------------!
2090FIELD='DUSTQ'
2091UNITS='kg/kg'
2092DESC='Dust mixing ratio'
2093DO k = 1,altlen
2094        XLVL=levels(k)
2095        SLAB=dustfile(:,:,k,time_out(l))
2096                ! And now put everything in the destination file
2097                ! ... Header
2098        write(1) IFV
2099        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2100        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2101                ! ... Data
2102                write(1) SLAB
2103END DO
2104!print *,'The field '//DESC//' was written to '//output
2105
2106!------------------------!
2107! >>> Write a variable   !
2108!    ... Copy&Paste part !
2109!------------------------!
2110FIELD='DUSTN'
2111UNITS='part/kg'
2112DESC='Dust number density'
2113DO k = 1,altlen
2114        XLVL=levels(k)
2115        SLAB=dustnfile(:,:,k,time_out(l))
2116                ! And now put everything in the destination file
2117                ! ... Header
2118        write(1) IFV
2119        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2120        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2121                ! ... Data
2122                write(1) SLAB
2123END DO
2124!print *,'The field '//DESC//' was written to '//output
2125
2126!------------------------!
2127! >>> Write a variable   !
2128!    ... Copy&Paste part !
2129!------------------------!
2130FIELD='CCNQ'
2131UNITS='kg/kg'
2132DESC='CCN mixing ratio'
2133DO k = 1,altlen
2134        XLVL=levels(k)
2135        SLAB=ccnfile(:,:,k,time_out(l))
2136                ! And now put everything in the destination file
2137                ! ... Header
2138        write(1) IFV
2139        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2140        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2141                ! ... Data
2142                write(1) SLAB
2143END DO
2144!print *,'The field '//DESC//' was written to '//output
2145
2146!------------------------!
2147! >>> Write a variable   !
2148!    ... Copy&Paste part !
2149!------------------------!
2150FIELD='CCNN'
2151UNITS='part/kg'
2152DESC='CCN number density'
2153DO k = 1,altlen
2154        XLVL=levels(k)
2155        SLAB=ccnnfile(:,:,k,time_out(l))
2156                ! And now put everything in the destination file
2157                ! ... Header
2158        write(1) IFV
2159        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2160        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2161                ! ... Data
2162                write(1) SLAB
2163END DO
2164!print *,'The field '//DESC//' was written to '//output
2165
2166
2167!------------------------!
2168! >>> Write a variable   !
2169!     PHOTOCHEMISTRY     !
2170!------------------------!
2171#ifdef PHOTOCHEM
2172FIELD='CO2'
2173UNITS='kg/kg'
2174DESC='CO2 mixing ratio'
2175DO k = 1,altlen
2176        XLVL=levels(k)
2177        SLAB=chemtrac(:,:,k,time_out(l),1)
2178                ! And now put everything in the destination file
2179                ! ... Header
2180        write(1) IFV
2181        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2182        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2183                ! ... Data
2184                write(1) SLAB
2185END DO
2186
2187FIELD='CO'
2188UNITS='kg/kg'
2189DESC='CO mixing ratio'
2190DO k = 1,altlen
2191        XLVL=levels(k)
2192        SLAB=chemtrac(:,:,k,time_out(l),2)
2193                ! And now put everything in the destination file
2194                ! ... Header
2195        write(1) IFV
2196        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2197        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2198                ! ... Data
2199                write(1) SLAB
2200END DO
2201
2202FIELD='H2'
2203UNITS='kg/kg'
2204DESC='H2 mixing ratio'
2205DO k = 1,altlen
2206        XLVL=levels(k)
2207        SLAB=chemtrac(:,:,k,time_out(l),3)
2208                ! And now put everything in the destination file
2209                ! ... Header
2210        write(1) IFV
2211        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2212        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2213                ! ... Data
2214                write(1) SLAB
2215END DO
2216
2217FIELD='H2O'
2218UNITS='kg/kg'
2219DESC='H2O mixing ratio'
2220DO k = 1,altlen
2221        XLVL=levels(k)
2222        SLAB=chemtrac(:,:,k,time_out(l),4)
2223                ! And now put everything in the destination file
2224                ! ... Header
2225        write(1) IFV
2226        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2227        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2228                ! ... Data
2229                write(1) SLAB
2230END DO
2231
2232FIELD='O1D'
2233UNITS='kg/kg'
2234DESC='O1D mixing ratio'
2235DO k = 1,altlen
2236        XLVL=levels(k)
2237        SLAB=chemtrac(:,:,k,time_out(l),5)
2238                ! And now put everything in the destination file
2239                ! ... Header
2240        write(1) IFV
2241        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2242        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2243                ! ... Data
2244                write(1) SLAB
2245END DO
2246
2247FIELD='O'
2248UNITS='kg/kg'
2249DESC='O mixing ratio'
2250DO k = 1,altlen
2251        XLVL=levels(k)
2252        SLAB=chemtrac(:,:,k,time_out(l),6)
2253                ! And now put everything in the destination file
2254                ! ... Header
2255        write(1) IFV
2256        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2257        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2258                ! ... Data
2259                write(1) SLAB
2260END DO
2261
2262FIELD='O2'
2263UNITS='kg/kg'
2264DESC='O2 mixing ratio'
2265DO k = 1,altlen
2266        XLVL=levels(k)
2267        SLAB=chemtrac(:,:,k,time_out(l),7)
2268                ! And now put everything in the destination file
2269                ! ... Header
2270        write(1) IFV
2271        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2272        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2273                ! ... Data
2274                write(1) SLAB
2275END DO
2276
2277FIELD='O2DG'
2278UNITS='kg/kg'
2279DESC='O2DG mixing ratio'
2280DO k = 1,altlen
2281        XLVL=levels(k)
2282        SLAB=chemtrac(:,:,k,time_out(l),8)
2283                ! And now put everything in the destination file
2284                ! ... Header
2285        write(1) IFV
2286        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2287        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2288                ! ... Data
2289                write(1) SLAB
2290END DO
2291
2292FIELD='O3'
2293UNITS='kg/kg'
2294DESC='O3 mixing ratio'
2295DO k = 1,altlen
2296        XLVL=levels(k)
2297        SLAB=chemtrac(:,:,k,time_out(l),9)
2298                ! And now put everything in the destination file
2299                ! ... Header
2300        write(1) IFV
2301        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2302        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2303                ! ... Data
2304                write(1) SLAB
2305END DO
2306
2307FIELD='H'
2308UNITS='kg/kg'
2309DESC='H mixing ratio'
2310DO k = 1,altlen
2311        XLVL=levels(k)
2312        SLAB=chemtrac(:,:,k,time_out(l),10)
2313                ! And now put everything in the destination file
2314                ! ... Header
2315        write(1) IFV
2316        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2317        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2318                ! ... Data
2319                write(1) SLAB
2320END DO
2321
2322FIELD='OH'
2323UNITS='kg/kg'
2324DESC='OH mixing ratio'
2325DO k = 1,altlen
2326        XLVL=levels(k)
2327        SLAB=chemtrac(:,:,k,time_out(l),11)
2328                ! And now put everything in the destination file
2329                ! ... Header
2330        write(1) IFV
2331        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2332        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2333                ! ... Data
2334                write(1) SLAB
2335END DO
2336
2337FIELD='HO2'
2338UNITS='kg/kg'
2339DESC='hO2 mixing ratio'
2340DO k = 1,altlen
2341        XLVL=levels(k)
2342        SLAB=chemtrac(:,:,k,time_out(l),12)
2343                ! And now put everything in the destination file
2344                ! ... Header
2345        write(1) IFV
2346        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2347        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2348                ! ... Data
2349                write(1) SLAB
2350END DO
2351
2352FIELD='H2O2'
2353UNITS='kg/kg'
2354DESC='H2O2 mixing ratio'
2355DO k = 1,altlen
2356        XLVL=levels(k)
2357        SLAB=chemtrac(:,:,k,time_out(l),13)
2358                ! And now put everything in the destination file
2359                ! ... Header
2360        write(1) IFV
2361        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2362        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2363                ! ... Data
2364                write(1) SLAB
2365END DO
2366
2367FIELD='Cl'
2368UNITS='kg/kg'
2369DESC='Cl mixing ratio'
2370DO k = 1,altlen
2371        XLVL=levels(k)
2372        SLAB=chemtrac(:,:,k,time_out(l),14)
2373                ! And now put everything in the destination file
2374                ! ... Header
2375        write(1) IFV
2376        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2377        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2378                ! ... Data
2379                write(1) SLAB
2380END DO
2381
2382FIELD='ClO'
2383UNITS='kg/kg'
2384DESC='ClO mixing ratio'
2385DO k = 1,altlen
2386        XLVL=levels(k)
2387        SLAB=chemtrac(:,:,k,time_out(l),15)
2388                ! And now put everything in the destination file
2389                ! ... Header
2390        write(1) IFV
2391        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2392        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2393                ! ... Data
2394                write(1) SLAB
2395END DO
2396
2397FIELD='Cl2'
2398UNITS='kg/kg'
2399DESC='Cl2 mixing ratio'
2400DO k = 1,altlen
2401        XLVL=levels(k)
2402        SLAB=chemtrac(:,:,k,time_out(l),16)
2403                ! And now put everything in the destination file
2404                ! ... Header
2405        write(1) IFV
2406        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2407        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2408                ! ... Data
2409                write(1) SLAB
2410END DO
2411
2412FIELD='HCl'
2413UNITS='kg/kg'
2414DESC='HCl mixing ratio'
2415DO k = 1,altlen
2416        XLVL=levels(k)
2417        SLAB=chemtrac(:,:,k,time_out(l),17)
2418                ! And now put everything in the destination file
2419                ! ... Header
2420        write(1) IFV
2421        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2422        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2423                ! ... Data
2424                write(1) SLAB
2425END DO
2426
2427FIELD='HOCl'
2428UNITS='kg/kg'
2429DESC='HOCl mixing ratio'
2430DO k = 1,altlen
2431        XLVL=levels(k)
2432        SLAB=chemtrac(:,:,k,time_out(l),18)
2433                ! And now put everything in the destination file
2434                ! ... Header
2435        write(1) IFV
2436        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2437        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2438                ! ... Data
2439                write(1) SLAB
2440END DO
2441
2442FIELD='ClCO'
2443UNITS='kg/kg'
2444DESC='ClCO mixing ratio'
2445DO k = 1,altlen
2446        XLVL=levels(k)
2447        SLAB=chemtrac(:,:,k,time_out(l),19)
2448                ! And now put everything in the destination file
2449                ! ... Header
2450        write(1) IFV
2451        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2452        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2453                ! ... Data
2454                write(1) SLAB
2455END DO
2456
2457FIELD='ClCO3'
2458UNITS='kg/kg'
2459DESC='ClCO3 mixing ratio'
2460DO k = 1,altlen
2461        XLVL=levels(k)
2462        SLAB=chemtrac(:,:,k,time_out(l),20)
2463                ! And now put everything in the destination file
2464                ! ... Header
2465        write(1) IFV
2466        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2467        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2468                ! ... Data
2469                write(1) SLAB
2470END DO
2471
2472FIELD='COCl2'
2473UNITS='kg/kg'
2474DESC='COClC2 mixing ratio'
2475DO k = 1,altlen
2476        XLVL=levels(k)
2477        SLAB=chemtrac(:,:,k,time_out(l),21)
2478                ! And now put everything in the destination file
2479                ! ... Header
2480        write(1) IFV
2481        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2482        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2483                ! ... Data
2484                write(1) SLAB
2485END DO
2486
2487FIELD='S'
2488UNITS='kg/kg'
2489DESC='S mixing ratio'
2490DO k = 1,altlen
2491        XLVL=levels(k)
2492        SLAB=chemtrac(:,:,k,time_out(l),22)
2493                ! And now put everything in the destination file
2494                ! ... Header
2495        write(1) IFV
2496        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2497        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2498                ! ... Data
2499                write(1) SLAB
2500END DO
2501
2502FIELD='SO'
2503UNITS='kg/kg'
2504DESC='SO mixing ratio'
2505DO k = 1,altlen
2506        XLVL=levels(k)
2507        SLAB=chemtrac(:,:,k,time_out(l),23)
2508                ! And now put everything in the destination file
2509                ! ... Header
2510        write(1) IFV
2511        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2512        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2513                ! ... Data
2514                write(1) SLAB
2515END DO
2516
2517FIELD='SO2'
2518UNITS='kg/kg'
2519DESC='SO2 mixing ratio'
2520DO k = 1,altlen
2521        XLVL=levels(k)
2522        SLAB=chemtrac(:,:,k,time_out(l),24)
2523                ! And now put everything in the destination file
2524                ! ... Header
2525        write(1) IFV
2526        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2527        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2528                ! ... Data
2529                write(1) SLAB
2530END DO
2531
2532FIELD='SO3'
2533UNITS='kg/kg'
2534DESC='SO3 mixing ratio'
2535DO k = 1,altlen
2536        XLVL=levels(k)
2537        SLAB=chemtrac(:,:,k,time_out(l),25)
2538                ! And now put everything in the destination file
2539                ! ... Header
2540        write(1) IFV
2541        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2542        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2543                ! ... Data
2544                write(1) SLAB
2545END DO
2546
2547FIELD='S2O2'
2548UNITS='kg/kg'
2549DESC='S2O2 mixing ratio'
2550DO k = 1,altlen
2551        XLVL=levels(k)
2552        SLAB=chemtrac(:,:,k,time_out(l),26)
2553                ! And now put everything in the destination file
2554                ! ... Header
2555        write(1) IFV
2556        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2557        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2558                ! ... Data
2559                write(1) SLAB
2560END DO
2561
2562FIELD='OCS'
2563UNITS='kg/kg'
2564DESC='OCS mixing ratio'
2565DO k = 1,altlen
2566        XLVL=levels(k)
2567        SLAB=chemtrac(:,:,k,time_out(l),27)
2568                ! And now put everything in the destination file
2569                ! ... Header
2570        write(1) IFV
2571        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2572        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2573                ! ... Data
2574                write(1) SLAB
2575END DO
2576
2577FIELD='HSO3'
2578UNITS='kg/kg'
2579DESC='HSO3 mixing ratio'
2580DO k = 1,altlen
2581        XLVL=levels(k)
2582        SLAB=chemtrac(:,:,k,time_out(l),28)
2583                ! And now put everything in the destination file
2584                ! ... Header
2585        write(1) IFV
2586        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2587        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2588                ! ... Data
2589                write(1) SLAB
2590END DO
2591
2592FIELD='H2SO4'
2593UNITS='kg/kg'
2594DESC='H2SO4 mixing ratio'
2595DO k = 1,altlen
2596        XLVL=levels(k)
2597        SLAB=chemtrac(:,:,k,time_out(l),29)
2598                ! And now put everything in the destination file
2599                ! ... Header
2600        write(1) IFV
2601        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2602        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2603                ! ... Data
2604                write(1) SLAB
2605END DO
2606
2607FIELD='S2'
2608UNITS='kg/kg'
2609DESC='S2 mixing ratio'
2610DO k = 1,altlen
2611        XLVL=levels(k)
2612        SLAB=chemtrac(:,:,k,time_out(l),30)
2613                ! And now put everything in the destination file
2614                ! ... Header
2615        write(1) IFV
2616        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2617        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2618                ! ... Data
2619                write(1) SLAB
2620END DO
2621
2622FIELD='ClSO2'
2623UNITS='kg/kg'
2624DESC='ClSO2 mixing ratio'
2625DO k = 1,altlen
2626        XLVL=levels(k)
2627        SLAB=chemtrac(:,:,k,time_out(l),31)
2628                ! And now put everything in the destination file
2629                ! ... Header
2630        write(1) IFV
2631        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2632        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2633                ! ... Data
2634                write(1) SLAB
2635END DO
2636
2637FIELD='OSCl'
2638UNITS='kg/kg'
2639DESC='OSCl mixing ratio'
2640DO k = 1,altlen
2641        XLVL=levels(k)
2642        SLAB=chemtrac(:,:,k,time_out(l),32)
2643                ! And now put everything in the destination file
2644                ! ... Header
2645        write(1) IFV
2646        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2647        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2648                ! ... Data
2649                write(1) SLAB
2650END DO
2651
2652FIELD='H2Oliq'
2653UNITS='kg/kg'
2654DESC='H2Oliq mixing ratio'
2655DO k = 1,altlen
2656        XLVL=levels(k)
2657        SLAB=chemtrac(:,:,k,time_out(l),33)
2658                ! And now put everything in the destination file
2659                ! ... Header
2660        write(1) IFV
2661        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2662        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2663                ! ... Data
2664                write(1) SLAB
2665END DO
2666
2667FIELD='H2SO4liq'
2668UNITS='kg/kg'
2669DESC='H2SO4liq mixing ratio'
2670DO k = 1,altlen
2671        XLVL=levels(k)
2672        SLAB=chemtrac(:,:,k,time_out(l),34)
2673                ! And now put everything in the destination file
2674                ! ... Header
2675        write(1) IFV
2676        write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
2677        write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
2678                ! ... Data
2679                write(1) SLAB
2680END DO
2681#endif
2682
2683print *,'****done file '//output, int(100.*float(l)/float(FILES)), ' % '
2684close(1)
2685
2686DEALLOCATE(SLAB)
2687
2688END DO !! end of the files loop
2689
2690
2691!!-------------------------
2692!! DeAllocate local arrays
2693!!-------------------------
2694deallocate(eta_gcm)
2695deallocate(tfile)
2696deallocate(pfile)
2697deallocate(tsoilfile)
2698deallocate(isoilfile)
2699deallocate(dsoilfile)
2700!deallocate(tfileorig)
2701deallocate(ufile)
2702!deallocate(ufileorig)
2703deallocate(vfile)
2704!deallocate(vfileorig)
2705deallocate(rfile)
2706deallocate(hfile) 
2707deallocate(waterfile)
2708deallocate(watericefile)
2709!deallocate(swaterfile)
2710deallocate(swatericefile)
2711deallocate(dustfile)
2712deallocate(dustnfile)
2713deallocate(co2file)
2714deallocate(ccnfile)
2715deallocate(ccnnfile)
2716deallocate(psfile)
2717deallocate(tsfile)
2718deallocate(tnsfile)
2719deallocate(unsfile)
2720deallocate(vnsfile)
2721deallocate(emissfile)
2722deallocate(co2icefile)
2723deallocate(ghtsfile)    !! no scan axis
2724deallocate(ghfile)
2725deallocate(vide)
2726deallocate(ones)
2727deallocate(lat, lon, alt, time)
2728deallocate(aps,bps,levels)
2729
2730#ifdef PHOTOCHEM
2731deallocate(chemtrac)
2732deallocate(wtnom)
2733#endif
2734
2735print *, '------------------------'
2736print *, 'End of pre-WPS process !'
2737print *, '------------------------'
2738print *, 'Here is what you should set in namelist.wps:'
2739print *, " start_date = '"//date_out2(1)//"'"
2740print *, " end_date = '"//date_out2(FILES)//"'"
2741print *, '------------------------'
2742print *, 'Any date between those is ok'
2743print *, 'for example, second available date is ... '//date_out2(2)
2744print *, '------------------------'
2745
2746end
Note: See TracBrowser for help on using the repository browser.