source: trunk/LMDZ.GENERIC/libf/aeronostd/iniwrite_spec.F @ 3469

Last change on this file since 3469 was 3309, checked in by yjaziri, 8 months ago

GENERIC PCM:

  • Cosmetic + clarifying some variables and comments in chemistry
  • add controle variable for actinique UV flux in photochemistry and output surface UV flux in diagspecUV.nc

YJ

File size: 7.8 KB
RevLine 
[3309]1      SUBROUTINE iniwrite_spec(nid,idayref,area,nbplon,nbplat)
2
3      use photolysis_mod, only : nw, wl, wc, wu
4      use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
5      use time_phylmdz_mod, only: daysec, dtphys
6!      USE logic_mod, ONLY: fxyhypb,ysinus
7!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
8!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
9      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
10      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
11
12      implicit none
13
14c=======================================================================
15c
16c   Auteur:  L. Fairhead  ,  P. Le Van, Y. Wanherdrick, F. Forget
17c   -------
18c
19c   Objet:
20c   ------
21c
22c   'Initialize' the diagfi_spec.nc file: write down dimensions as well
23c   as time-independent fields (e.g: geopotential, mesh area, ...)
24c
25c=======================================================================
26c-----------------------------------------------------------------------
27c   Declarations:
28c   -------------
29
30      include "netcdf.inc"
31
32c   Arguments:
33c   ----------
34
35      integer,intent(in) :: nid        ! NetCDF file ID
36      INTEGER*4,INTENT(IN) :: idayref  ! date (initial date for this run)
37      real,intent(in) :: area(nbplon,nbplat) ! mesh area (m2)
38      integer,intent(in) :: nbplon,nbplat ! sizes of area
39
40c   Local:
41c   ------
42      INTEGER length,l
43      parameter (length = 100)
44      REAL tab_cntrl(length) ! run parameters are stored in this array
45      INTEGER ierr
46      REAl,ALLOCATABLE :: lon_reg_ext(:) ! extended longitudes
47
48      integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
49      integer :: idim_rlatu,idim_rlatv,idim_llmp1,idim_llm
50 !     integer :: idim_nsoilmx ! "subsurface_layers" dimension ID #
51      integer :: idim_wl ! "Wavelength" dimension ID #
52      integer, dimension(2) :: id 
53
54c-----------------------------------------------------------------------
55
56      IF (nbp_lon*nbp_lat==1) THEN
57        ! 1D model
58        ALLOCATE(lon_reg_ext(1))
59      ELSE
60        ! 3D model
61        ALLOCATE(lon_reg_ext(nbp_lon+1))
62      ENDIF
63
64      DO l=1,length
65         tab_cntrl(l)=0.
66      ENDDO
67      tab_cntrl(1)  = FLOAT(nbp_lon)
68      tab_cntrl(2)  = FLOAT(nbp_lat-1)
69      tab_cntrl(3)  = FLOAT(nbp_lev)
70      tab_cntrl(4)  = FLOAT(idayref)
71      tab_cntrl(5)  = rad
72      tab_cntrl(6)  = omeg
73      tab_cntrl(7)  = g
74      tab_cntrl(8)  = mugaz
75      tab_cntrl(9)  = rcp
76      tab_cntrl(10) = daysec
77      tab_cntrl(11) = dtphys
78!      tab_cntrl(12) = etot0
79!      tab_cntrl(13) = ptot0
80!      tab_cntrl(14) = ztot0
81!      tab_cntrl(15) = stot0
82!      tab_cntrl(16) = ang0
83c
84c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
85c         .....        parametres  pour le zoom          ......   
86!      tab_cntrl(17)  = clon
87!      tab_cntrl(18)  = clat
88!      tab_cntrl(19)  = grossismx
89!      tab_cntrl(20)  = grossismy
90c
91c     .....   ajout  le 6/05/97 et le 15/10/97  .......
92c
93!      IF ( fxyhypb )   THEN
94!        tab_cntrl(21) = 1.
95!        tab_cntrl(22) = dzoomx
96!        tab_cntrl(23) = dzoomy
97!      ELSE
98!        tab_cntrl(21) = 0.
99!        tab_cntrl(22) = dzoomx
100!        tab_cntrl(23) = dzoomy
101!        tab_cntrl(24) = 0.
102!        IF( ysinus )  tab_cntrl(24) = 1.
103!      ENDIF
104
105c    .........................................................
106
107! Define dimensions
108   
109      ierr = NF_REDEF (nid)
110
111      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
112      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
113      IF (nbp_lon*nbp_lat==1) THEN
114        ierr = NF_DEF_DIM (nid, "longitude", 1, idim_rlonv)
115      ELSE
116        ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
117      ENDIF
118      ierr = NF_DEF_DIM (nid, "Wavelength",nw,idim_wl)
119
120      ierr = NF_ENDDEF(nid)
121
122c  Contol parameters for this run
123      ierr = NF_REDEF (nid)
124#ifdef NC_DOUBLE
125      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1,
126     .       idim_index,nvarid)
127#else
128      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1,
129     .       idim_index,nvarid)
130#endif
131      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
132     .                       "Control parameters")
133      ierr = NF_ENDDEF(nid)
134#ifdef NC_DOUBLE
135      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
136#else
137      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
138#endif
139
140c --------------------------
141c  longitudes and latitudes
142
143      ierr = NF_REDEF (nid)
144#ifdef NC_DOUBLE
145      ierr =NF_DEF_VAR(nid, "latitude", NF_DOUBLE, 1, idim_rlatu,nvarid)
146#else
147      ierr =NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim_rlatu,nvarid)
148#endif
149      ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north")
150      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
151     .      "North latitude")
152      ierr = NF_ENDDEF(nid)
153#ifdef NC_DOUBLE
154      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
155#else
156      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
157#endif
158c
159c --------------------------
160      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
161      !add extra redundant point (180 degrees, since lon_reg starts at -180
162      IF (nbp_lon*nbp_lat/=1) THEN
163        ! In 3D, add extra redundant point (180 degrees,
164        ! since lon_reg starts at -180)
165        lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
166      ENDIF
167
168      ierr = NF_REDEF (nid)
169#ifdef NC_DOUBLE
170      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
171#else
172      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
173#endif
174      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
175     .      "East longitude")
176      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
177      ierr = NF_ENDDEF(nid)
178#ifdef NC_DOUBLE
179      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
180#else
181      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
182#endif
183c
184
185!-------------------------------
186! Number of bands in the IR
187!-------------------------------
188
189      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
190      ! define variable
191#ifdef NC_DOUBLE
192      ierr=NF_DEF_VAR(nid,"Wavelength",NF_DOUBLE,1,
193     .                                idim_wl,nvarid)
194#else
195      ierr=NF_DEF_VAR(nid,"Wavelength",NF_FLOAT,1,
196     .                                idim_wl,nvarid)
197#endif
198      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 37,
199     .                        "Band mid Wavelength in the UV-visible")
200      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",2,"nm")
201      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
202      ! write variable
203#ifdef NC_DOUBLE
204      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,dble(wc))
205#else
206      ierr=NF_PUT_VAR_REAL (nid,nvarid,real(wc))
207#endif
208
209c
210!-------------------------------
211! Width of bands in the Visible
212!-------------------------------
213
214      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
215      ! define variable
216#ifdef NC_DOUBLE
217      ierr=NF_DEF_VAR(nid,"Wavelength_width",NF_DOUBLE,1,
218     .                                idim_wl,nvarid)
219#else
220      ierr=NF_DEF_VAR(nid,"Wavelength_width",NF_FLOAT,1,
221     .                                idim_wl,nvarid)
222#endif
223      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 27,
224     .                        "Bandwidth in the UV-visible")
225      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",2,"nm")
226      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
227      ! write variable
228#ifdef NC_DOUBLE
229      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,dble(wu-wl))
230#else
231      ierr=NF_PUT_VAR_REAL (nid,nvarid,real(wu-wl))
232#endif
233c
234c --------------------------
235c   Mesh area
236c --------------------------
237
238      id(1)=idim_rlonv
239      id(2)=idim_rlatu
240
241
242      ierr = NF_REDEF (nid)
243#ifdef NC_DOUBLE
244      ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid)
245#else
246      ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid)
247#endif
248      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
249     .                       "Mesh area")
250      ierr = NF_ENDDEF(nid)
251#ifdef NC_DOUBLE
252      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
253#else
254      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
255#endif
256
257
258
259      END
Note: See TracBrowser for help on using the repository browser.