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