[38] | 1 | SUBROUTINE iniwrite(nid,idayref,phis) |
---|
| 2 | IMPLICIT NONE |
---|
| 3 | |
---|
| 4 | c======================================================================= |
---|
| 5 | c |
---|
| 6 | c Auteur: L. Fairhead , P. Le Van, Y. Wanherdrick, F. Forget |
---|
| 7 | c ------- |
---|
| 8 | c |
---|
| 9 | c Objet: |
---|
| 10 | c ------ |
---|
| 11 | c |
---|
| 12 | c 'Initialize' the diagfi.nc file: write down dimensions as well |
---|
| 13 | c as time-independent fields (e.g: geopotential, mesh area, ...) |
---|
| 14 | c |
---|
| 15 | c======================================================================= |
---|
| 16 | c----------------------------------------------------------------------- |
---|
| 17 | c Declarations: |
---|
| 18 | c ------------- |
---|
| 19 | |
---|
| 20 | #include "dimensions.h" |
---|
| 21 | #include "paramet.h" |
---|
| 22 | !include "comconst.h" |
---|
| 23 | #include "comcstfi.h" |
---|
| 24 | #include "comvert.h" |
---|
| 25 | #include "comgeom.h" |
---|
| 26 | #include "temps.h" |
---|
| 27 | #include "ener.h" |
---|
| 28 | #include "logic.h" |
---|
| 29 | #include "netcdf.inc" |
---|
| 30 | #include "description.h" |
---|
| 31 | #include "serre.h" |
---|
| 32 | #include"dimphys.h" |
---|
| 33 | #include"comsoil.h" |
---|
| 34 | |
---|
| 35 | c Arguments: |
---|
| 36 | c ---------- |
---|
| 37 | |
---|
[164] | 38 | integer,intent(in) :: nid ! NetCDF file ID |
---|
| 39 | INTEGER*4,intent(in) :: idayref ! date (initial date for this run) |
---|
| 40 | real,intent(in) :: phis(ip1jmp1) ! surface geopotential |
---|
[38] | 41 | |
---|
| 42 | c Local: |
---|
| 43 | c ------ |
---|
| 44 | INTEGER length,l |
---|
| 45 | parameter (length = 100) |
---|
| 46 | REAL tab_cntrl(length) ! run parameters are stored in this array |
---|
| 47 | INTEGER ierr |
---|
| 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 # |
---|
| 52 | integer, dimension(2) :: id |
---|
| 53 | c----------------------------------------------------------------------- |
---|
| 54 | |
---|
| 55 | DO l=1,length |
---|
| 56 | tab_cntrl(l)=0. |
---|
| 57 | ENDDO |
---|
| 58 | tab_cntrl(1) = real(iim) |
---|
| 59 | tab_cntrl(2) = real(jjm) |
---|
| 60 | tab_cntrl(3) = real(llm) |
---|
| 61 | tab_cntrl(4) = real(idayref) |
---|
| 62 | tab_cntrl(5) = rad |
---|
| 63 | tab_cntrl(6) = omeg |
---|
| 64 | tab_cntrl(7) = g |
---|
| 65 | tab_cntrl(8) = mugaz |
---|
| 66 | tab_cntrl(9) = rcp |
---|
| 67 | tab_cntrl(10) = daysec |
---|
| 68 | tab_cntrl(11) = dtphys |
---|
| 69 | tab_cntrl(12) = etot0 |
---|
| 70 | tab_cntrl(13) = ptot0 |
---|
| 71 | tab_cntrl(14) = ztot0 |
---|
| 72 | tab_cntrl(15) = stot0 |
---|
| 73 | tab_cntrl(16) = ang0 |
---|
[999] | 74 | |
---|
| 75 | tab_cntrl(27) = hour_ini |
---|
[38] | 76 | c |
---|
| 77 | c .......... P.Le Van ( ajout le 8/04/96 ) ......... |
---|
| 78 | c ..... parametres pour le zoom ...... |
---|
| 79 | tab_cntrl(17) = clon |
---|
| 80 | tab_cntrl(18) = clat |
---|
| 81 | tab_cntrl(19) = grossismx |
---|
| 82 | tab_cntrl(20) = grossismy |
---|
| 83 | c |
---|
| 84 | c ..... ajout le 6/05/97 et le 15/10/97 ....... |
---|
| 85 | c |
---|
| 86 | IF ( fxyhypb ) THEN |
---|
| 87 | tab_cntrl(21) = 1. |
---|
| 88 | tab_cntrl(22) = dzoomx |
---|
| 89 | tab_cntrl(23) = dzoomy |
---|
| 90 | ELSE |
---|
| 91 | tab_cntrl(21) = 0. |
---|
| 92 | tab_cntrl(22) = dzoomx |
---|
| 93 | tab_cntrl(23) = dzoomy |
---|
| 94 | tab_cntrl(24) = 0. |
---|
| 95 | IF( ysinus ) tab_cntrl(24) = 1. |
---|
| 96 | ENDIF |
---|
| 97 | |
---|
| 98 | c ......................................................... |
---|
| 99 | |
---|
| 100 | ! Define dimensions |
---|
| 101 | |
---|
| 102 | ierr = NF_REDEF (nid) |
---|
| 103 | |
---|
| 104 | ierr = NF_DEF_DIM (nid, "index", length, idim_index) |
---|
| 105 | ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu) |
---|
| 106 | ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu) |
---|
| 107 | ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv) |
---|
| 108 | ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv) |
---|
| 109 | ierr = NF_DEF_DIM (nid, "interlayer", (llm+1), idim_llmp1) |
---|
| 110 | ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm) |
---|
| 111 | ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoilmx,idim_nsoilmx) |
---|
| 112 | c |
---|
| 113 | ierr = NF_ENDDEF(nid) |
---|
| 114 | |
---|
| 115 | c Contol parameters for this run |
---|
| 116 | ierr = NF_REDEF (nid) |
---|
| 117 | #ifdef NC_DOUBLE |
---|
| 118 | ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, |
---|
| 119 | . idim_index,nvarid) |
---|
| 120 | #else |
---|
| 121 | ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, |
---|
| 122 | . idim_index,nvarid) |
---|
| 123 | #endif |
---|
| 124 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18, |
---|
| 125 | . "Control parameters") |
---|
| 126 | ierr = NF_ENDDEF(nid) |
---|
| 127 | #ifdef NC_DOUBLE |
---|
| 128 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl) |
---|
| 129 | #else |
---|
| 130 | ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl) |
---|
| 131 | #endif |
---|
| 132 | |
---|
| 133 | c -------------------------- |
---|
| 134 | c longitudes and latitudes |
---|
| 135 | ierr = NF_REDEF (nid) |
---|
| 136 | #ifdef NC_DOUBLE |
---|
| 137 | ierr = NF_DEF_VAR (nid, "rlonu", NF_DOUBLE, 1, idim_rlonu,nvarid) |
---|
| 138 | #else |
---|
| 139 | ierr = NF_DEF_VAR (nid, "rlonu", NF_FLOAT, 1, idim_rlonu,nvarid) |
---|
| 140 | #endif |
---|
| 141 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 21, |
---|
| 142 | . "Longitudes at u nodes") |
---|
| 143 | ierr = NF_ENDDEF(nid) |
---|
| 144 | #ifdef NC_DOUBLE |
---|
| 145 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu/pi*180) |
---|
| 146 | #else |
---|
| 147 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu/pi*180) |
---|
| 148 | #endif |
---|
| 149 | c |
---|
| 150 | c -------------------------- |
---|
| 151 | ierr = NF_REDEF (nid) |
---|
| 152 | #ifdef NC_DOUBLE |
---|
| 153 | ierr =NF_DEF_VAR(nid, "latitude", NF_DOUBLE, 1, idim_rlatu,nvarid) |
---|
| 154 | #else |
---|
| 155 | ierr =NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim_rlatu,nvarid) |
---|
| 156 | #endif |
---|
| 157 | ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north") |
---|
| 158 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14, |
---|
| 159 | . "North latitude") |
---|
| 160 | ierr = NF_ENDDEF(nid) |
---|
| 161 | #ifdef NC_DOUBLE |
---|
| 162 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180) |
---|
| 163 | #else |
---|
| 164 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180) |
---|
| 165 | #endif |
---|
| 166 | c |
---|
| 167 | c -------------------------- |
---|
| 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,rlonv/pi*180) |
---|
| 180 | #else |
---|
| 181 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180) |
---|
| 182 | #endif |
---|
| 183 | c |
---|
| 184 | c -------------------------- |
---|
| 185 | ierr = NF_REDEF (nid) |
---|
| 186 | #ifdef NC_DOUBLE |
---|
| 187 | ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1, |
---|
| 188 | . idim_llm,nvarid) |
---|
| 189 | #else |
---|
| 190 | ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1, |
---|
| 191 | . idim_llm,nvarid) |
---|
| 192 | #endif |
---|
| 193 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",10,"pseudo-alt") |
---|
| 194 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km") |
---|
| 195 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up") |
---|
| 196 | |
---|
| 197 | ierr = NF_ENDDEF(nid) |
---|
| 198 | #ifdef NC_DOUBLE |
---|
| 199 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt) |
---|
| 200 | #else |
---|
| 201 | ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt) |
---|
| 202 | #endif |
---|
| 203 | c |
---|
| 204 | c -------------------------- |
---|
| 205 | ierr = NF_REDEF (nid) |
---|
| 206 | #ifdef NC_DOUBLE |
---|
| 207 | ierr = NF_DEF_VAR (nid, "rlatv", NF_DOUBLE, 1, idim_rlatv,nvarid) |
---|
| 208 | #else |
---|
| 209 | ierr = NF_DEF_VAR (nid, "rlatv", NF_FLOAT, 1, idim_rlatv,nvarid) |
---|
| 210 | #endif |
---|
| 211 | ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20, |
---|
| 212 | . "Latitudes at v nodes") |
---|
| 213 | ierr = NF_ENDDEF(nid) |
---|
| 214 | #ifdef NC_DOUBLE |
---|
| 215 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv/pi*180) |
---|
| 216 | #else |
---|
| 217 | ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv/pi*180) |
---|
| 218 | #endif |
---|
| 219 | c |
---|
| 220 | c -------------------------- |
---|
| 221 | c Vertical levels |
---|
| 222 | call def_var(nid,"aps","hybrid pressure at midlayers ","Pa", |
---|
| 223 | . 1,idim_llm,nvarid,ierr) |
---|
| 224 | #ifdef NC_DOUBLE |
---|
| 225 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps) |
---|
| 226 | #else |
---|
| 227 | ierr = NF_PUT_VAR_REAL (nid,nvarid,aps) |
---|
| 228 | #endif |
---|
| 229 | |
---|
| 230 | call def_var(nid,"bps","hybrid sigma at midlayers"," ", |
---|
| 231 | . 1,idim_llm,nvarid,ierr) |
---|
| 232 | #ifdef NC_DOUBLE |
---|
| 233 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps) |
---|
| 234 | #else |
---|
| 235 | ierr = NF_PUT_VAR_REAL (nid,nvarid,bps) |
---|
| 236 | #endif |
---|
| 237 | |
---|
| 238 | call def_var(nid,"ap","hybrid pressure at interlayers","Pa", |
---|
| 239 | . 1,idim_llmp1,nvarid,ierr) |
---|
| 240 | #ifdef NC_DOUBLE |
---|
| 241 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap) |
---|
| 242 | #else |
---|
| 243 | ierr = NF_PUT_VAR_REAL (nid,nvarid,ap) |
---|
| 244 | #endif |
---|
| 245 | |
---|
| 246 | call def_var(nid,"bp","hybrid sigma at interlayers"," ", |
---|
| 247 | . 1,idim_llmp1,nvarid,ierr) |
---|
| 248 | #ifdef NC_DOUBLE |
---|
| 249 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp) |
---|
| 250 | #else |
---|
| 251 | ierr = NF_PUT_VAR_REAL (nid,nvarid,bp) |
---|
| 252 | #endif |
---|
| 253 | |
---|
| 254 | !------------------------------- |
---|
| 255 | ! (soil) depth variable mlayer() (known from comsoil.h) |
---|
| 256 | !------------------------------- |
---|
| 257 | ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode |
---|
| 258 | ! define variable |
---|
| 259 | #ifdef NC_DOUBLE |
---|
| 260 | ierr=NF_DEF_VAR(nid,"soildepth",NF_DOUBLE,1,idim_nsoilmx,nvarid) |
---|
| 261 | #else |
---|
| 262 | ierr=NF_DEF_VAR(nid,"soildepth",NF_FLOAT,1,idim_nsoilmx,nvarid) |
---|
| 263 | #endif |
---|
| 264 | ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 20, |
---|
| 265 | . "Soil mid-layer depth") |
---|
| 266 | ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",1,"m") |
---|
| 267 | ierr=NF_PUT_ATT_TEXT (nid,nvarid,"positive",4,"down") |
---|
| 268 | ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode |
---|
| 269 | ! write variable |
---|
| 270 | #ifdef NC_DOUBLE |
---|
| 271 | ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer) |
---|
| 272 | #else |
---|
| 273 | ierr=NF_PUT_VAR_REAL (nid,nvarid,mlayer) |
---|
| 274 | #endif |
---|
| 275 | |
---|
| 276 | c |
---|
| 277 | c -------------------------- |
---|
| 278 | c Mesh area and conversion coefficients cov. <-> contra. <--> natural |
---|
| 279 | |
---|
| 280 | id(1)=idim_rlonu |
---|
| 281 | id(2)=idim_rlatu |
---|
| 282 | c |
---|
| 283 | ierr = NF_REDEF (nid) |
---|
| 284 | #ifdef NC_DOUBLE |
---|
| 285 | ierr = NF_DEF_VAR (nid, "cu", NF_DOUBLE, 2, id,nvarid) |
---|
| 286 | #else |
---|
| 287 | ierr = NF_DEF_VAR (nid, "cu", NF_FLOAT, 2, id,nvarid) |
---|
| 288 | #endif |
---|
| 289 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40, |
---|
| 290 | . "Conversion coefficients cov <--> natural") |
---|
| 291 | ierr = NF_ENDDEF(nid) |
---|
| 292 | #ifdef NC_DOUBLE |
---|
| 293 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu) |
---|
| 294 | #else |
---|
| 295 | ierr = NF_PUT_VAR_REAL (nid,nvarid,cu) |
---|
| 296 | #endif |
---|
| 297 | c |
---|
| 298 | id(1)=idim_rlonv |
---|
| 299 | id(2)=idim_rlatv |
---|
| 300 | c |
---|
| 301 | c -------------------------- |
---|
| 302 | ierr = NF_REDEF (nid) |
---|
| 303 | #ifdef NC_DOUBLE |
---|
| 304 | ierr = NF_DEF_VAR (nid, "cv", NF_DOUBLE, 2, id,nvarid) |
---|
| 305 | #else |
---|
| 306 | ierr = NF_DEF_VAR (nid, "cv", NF_FLOAT, 2, id,nvarid) |
---|
| 307 | #endif |
---|
| 308 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40, |
---|
| 309 | . "Conversion coefficients cov <--> natural") |
---|
| 310 | ierr = NF_ENDDEF(nid) |
---|
| 311 | #ifdef NC_DOUBLE |
---|
| 312 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv) |
---|
| 313 | #else |
---|
| 314 | ierr = NF_PUT_VAR_REAL (nid,nvarid,cv) |
---|
| 315 | #endif |
---|
| 316 | c |
---|
| 317 | id(1)=idim_rlonv |
---|
| 318 | id(2)=idim_rlatu |
---|
| 319 | c |
---|
| 320 | c -------------------------- |
---|
| 321 | ierr = NF_REDEF (nid) |
---|
| 322 | #ifdef NC_DOUBLE |
---|
| 323 | ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid) |
---|
| 324 | #else |
---|
| 325 | ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid) |
---|
| 326 | #endif |
---|
| 327 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9, |
---|
| 328 | . "Mesh area") |
---|
| 329 | ierr = NF_ENDDEF(nid) |
---|
| 330 | #ifdef NC_DOUBLE |
---|
| 331 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire) |
---|
| 332 | #else |
---|
| 333 | ierr = NF_PUT_VAR_REAL (nid,nvarid,aire) |
---|
| 334 | #endif |
---|
| 335 | c |
---|
| 336 | c Surface geopotential |
---|
| 337 | id(1)=idim_rlonv |
---|
| 338 | id(2)=idim_rlatu |
---|
| 339 | c |
---|
| 340 | ierr = NF_REDEF (nid) |
---|
| 341 | #ifdef NC_DOUBLE |
---|
| 342 | ierr = NF_DEF_VAR (nid, "phisinit", NF_DOUBLE, 2, id,nvarid) |
---|
| 343 | #else |
---|
| 344 | ierr = NF_DEF_VAR (nid, "phisinit", NF_FLOAT, 2, id,nvarid) |
---|
| 345 | #endif |
---|
| 346 | ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27, |
---|
| 347 | . "Geopotential at the surface") |
---|
| 348 | ierr = NF_ENDDEF(nid) |
---|
| 349 | #ifdef NC_DOUBLE |
---|
| 350 | ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis) |
---|
| 351 | #else |
---|
| 352 | ierr = NF_PUT_VAR_REAL (nid,nvarid,phis) |
---|
| 353 | #endif |
---|
| 354 | c |
---|
| 355 | |
---|
| 356 | write(*,*)'iniwrite: iim,jjm,llm,idayref',iim,jjm,llm,idayref |
---|
| 357 | write(*,*)'iniwrite: rad,omeg,g,mugaz,rcp', |
---|
| 358 | s rad,omeg,g,mugaz,rcp |
---|
| 359 | write(*,*)'iniwrite: daysec,dtphys',daysec,dtphys |
---|
| 360 | |
---|
| 361 | END |
---|