[38] | 1 | subroutine wstats(ngrid,nom,titre,unite,dim,px) |
---|
| 2 | |
---|
[1130] | 3 | use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin |
---|
| 4 | use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo |
---|
| 5 | |
---|
[38] | 6 | implicit none |
---|
| 7 | |
---|
| 8 | #include "dimensions.h" |
---|
[1130] | 9 | #include "comconst.h" |
---|
[38] | 10 | #include "statto.h" |
---|
| 11 | #include "netcdf.inc" |
---|
| 12 | |
---|
| 13 | integer,intent(in) :: ngrid |
---|
| 14 | character (len=*),intent(in) :: nom,titre,unite |
---|
| 15 | integer,intent(in) :: dim |
---|
| 16 | integer,parameter :: iip1=iim+1 |
---|
| 17 | integer,parameter :: jjp1=jjm+1 |
---|
[1130] | 18 | real,intent(in) :: px(ngrid,llm) |
---|
[38] | 19 | real, dimension(iip1,jjp1,llm) :: mean3d,sd3d,dx3 |
---|
| 20 | real, dimension(iip1,jjp1) :: mean2d,sd2d,dx2 |
---|
| 21 | character (len=50) :: namebis |
---|
| 22 | character (len=50), save :: firstvar |
---|
[1130] | 23 | integer :: ierr,varid,nbdim,nid |
---|
[38] | 24 | integer :: meanid,sdid |
---|
[1130] | 25 | integer, dimension(4) :: id,start,sizes |
---|
[38] | 26 | logical, save :: firstcall=.TRUE. |
---|
| 27 | integer :: l,i,j,ig0 |
---|
[1130] | 28 | integer,save :: indx |
---|
[38] | 29 | |
---|
| 30 | integer, save :: step=0 |
---|
| 31 | |
---|
[1130] | 32 | ! Added to work in parallel mode |
---|
| 33 | #ifdef CPP_PARA |
---|
| 34 | real px3_glop(klon_glo,llm) ! to store a 3D data set on global physics grid |
---|
| 35 | real px3_glo(iim,jjp1,llm) ! to store a global 3D data set on global lonxlat grid |
---|
| 36 | real px2_glop(klon_glo) ! to store a 2D data set on global physics grid |
---|
| 37 | real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid |
---|
| 38 | real px2(ngrid) |
---|
| 39 | real px3(ngrid,llm) |
---|
| 40 | #else |
---|
| 41 | ! When not running in parallel mode: |
---|
| 42 | real px3_glop(ngrid,llm) ! to store a 3D data set on global physics grid |
---|
| 43 | real px3_glo(iim,jjp1,llm) ! to store a global 3D data set on global lonxlat grid |
---|
| 44 | real px2_glop(ngrid) ! to store a 2D data set on global physics grid |
---|
| 45 | real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid |
---|
| 46 | #endif |
---|
| 47 | |
---|
| 48 | ! 1. Initialization (creation of stats.nc file) |
---|
[38] | 49 | if (firstcall) then |
---|
| 50 | firstcall=.false. |
---|
[1130] | 51 | firstvar=trim((nom)) |
---|
[38] | 52 | call inistats(ierr) |
---|
| 53 | endif |
---|
| 54 | |
---|
[1130] | 55 | if (firstvar==nom) then ! If we're back to the first variable, increment time counter |
---|
[38] | 56 | step = step + 1 |
---|
| 57 | endif |
---|
| 58 | |
---|
| 59 | if (mod(step,istats).ne.0) then |
---|
[1130] | 60 | ! if its not time to write to file, exit |
---|
[38] | 61 | RETURN |
---|
| 62 | endif |
---|
| 63 | |
---|
[1130] | 64 | ! collect fields on a global physics grid |
---|
| 65 | #ifdef CPP_PARA |
---|
| 66 | if (dim.eq.3) then |
---|
| 67 | px3(1:ngrid,1:llm)=px(1:ngrid,1:llm) |
---|
| 68 | ! Gather fieds on a "global" (without redundant longitude) array |
---|
| 69 | call Gather(px3,px3_glop) |
---|
| 70 | !$OMP MASTER |
---|
| 71 | if (is_mpi_root) then |
---|
| 72 | call Grid1Dto2D_glo(px3_glop,px3_glo) |
---|
| 73 | ! copy dx3_glo() to dx3(:) and add redundant longitude |
---|
| 74 | dx3(1:iim,:,:)=px3_glo(1:iim,:,:) |
---|
| 75 | dx3(iip1,:,:)=dx3(1,:,:) |
---|
| 76 | endif |
---|
| 77 | !$OMP END MASTER |
---|
| 78 | !$OMP BARRIER |
---|
| 79 | else ! dim.eq.2 |
---|
| 80 | ! Gather fieds on a "global" (without redundant longitude) array |
---|
| 81 | px2(:)=px(:,1) |
---|
| 82 | call Gather(px2,px2_glop) |
---|
| 83 | !$OMP MASTER |
---|
| 84 | if (is_mpi_root) then |
---|
| 85 | call Grid1Dto2D_glo(px2_glop,px2_glo) |
---|
| 86 | ! copy px2_glo() to dx2(:) and add redundant longitude |
---|
| 87 | dx2(1:iim,:)=px2_glo(1:iim,:) |
---|
| 88 | dx2(iip1,:)=dx2(1,:) |
---|
| 89 | endif |
---|
| 90 | !$OMP END MASTER |
---|
| 91 | !$OMP BARRIER |
---|
| 92 | endif |
---|
| 93 | #else |
---|
| 94 | if (dim.eq.3) then |
---|
| 95 | px3_glop(:,1:llm)=px(:,1:llm) |
---|
| 96 | ! Passage variable physique --> variable dynamique |
---|
| 97 | DO l=1,llm |
---|
| 98 | DO i=1,iim |
---|
| 99 | px3_glo(i,1,l)=px(1,l) |
---|
| 100 | px3_glo(i,jjp1,l)=px(ngrid,l) |
---|
| 101 | ENDDO |
---|
| 102 | DO j=2,jjm |
---|
| 103 | ig0= 1+(j-2)*iim |
---|
| 104 | DO i=1,iim |
---|
| 105 | px3_glo(i,j,l)=px(ig0+i,l) |
---|
| 106 | ENDDO |
---|
| 107 | ENDDO |
---|
| 108 | ENDDO |
---|
| 109 | else ! dim.eq.2 |
---|
| 110 | px2_glop(:)=px(:,1) |
---|
| 111 | ! Passage variable physique --> physique dynamique |
---|
| 112 | DO i=1,iim |
---|
| 113 | px2_glo(i,1)=px(1,1) |
---|
| 114 | px2_glo(i,jjp1)=px(ngrid,1) |
---|
| 115 | ENDDO |
---|
| 116 | DO j=2,jjm |
---|
| 117 | ig0= 1+(j-2)*iim |
---|
| 118 | DO i=1,iim |
---|
| 119 | px2_glo(i,j)=px(ig0+i,1) |
---|
| 120 | ENDDO |
---|
| 121 | ENDDO |
---|
| 122 | endif |
---|
| 123 | #endif |
---|
| 124 | |
---|
| 125 | ! 2. Write field to file |
---|
| 126 | |
---|
| 127 | if (is_master) then |
---|
| 128 | ! only master needs do this |
---|
| 129 | |
---|
[38] | 130 | ierr = NF_OPEN("stats.nc",NF_WRITE,nid) |
---|
| 131 | |
---|
| 132 | namebis=trim(nom) |
---|
[1130] | 133 | |
---|
| 134 | ! test: check if that variable already exists in file |
---|
[38] | 135 | ierr= NF_INQ_VARID(nid,namebis,meanid) |
---|
| 136 | |
---|
| 137 | if (ierr.ne.NF_NOERR) then |
---|
[1130] | 138 | ! variable not in file, create/define it |
---|
[38] | 139 | if (firstvar==nom) then |
---|
[1130] | 140 | indx=1 |
---|
| 141 | count(:)=0 |
---|
[38] | 142 | endif |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | !declaration de la variable |
---|
| 146 | |
---|
| 147 | ! choix du nom des coordonnees |
---|
| 148 | ierr= NF_INQ_DIMID(nid,"longitude",id(1)) |
---|
| 149 | ierr= NF_INQ_DIMID(nid,"latitude",id(2)) |
---|
| 150 | if (dim.eq.3) then |
---|
| 151 | ierr= NF_INQ_DIMID(nid,"altitude",id(3)) |
---|
| 152 | ierr= NF_INQ_DIMID(nid,"Time",id(4)) |
---|
| 153 | nbdim=4 |
---|
| 154 | else if (dim==2) then |
---|
| 155 | ierr= NF_INQ_DIMID(nid,"Time",id(3)) |
---|
| 156 | nbdim=3 |
---|
| 157 | endif |
---|
| 158 | |
---|
| 159 | write (*,*) "=====================" |
---|
| 160 | write (*,*) "STATS: creation de ",nom |
---|
| 161 | namebis=trim(nom) |
---|
[1130] | 162 | call def_var(nid,namebis,titre,unite,nbdim,id,meanid,ierr) |
---|
| 163 | if (dim.eq.3) then |
---|
| 164 | call inivar(nid,meanid,size(px3_glop,1),dim,indx,px3_glop,ierr) |
---|
| 165 | else ! dim.eq.2 |
---|
| 166 | call inivar(nid,meanid,size(px2_glop,1),dim,indx,px2_glop,ierr) |
---|
| 167 | endif |
---|
[38] | 168 | namebis=trim(nom)//"_sd" |
---|
[1130] | 169 | call def_var(nid,namebis,trim(titre)//" total standard deviation over the season",unite,nbdim,id,sdid,ierr) |
---|
| 170 | if (dim.eq.3) then |
---|
| 171 | call inivar(nid,sdid,size(px3_glop,1),dim,indx,px3_glop,ierr) |
---|
| 172 | else ! dim.eq.2 |
---|
| 173 | call inivar(nid,sdid,size(px2_glop,1),dim,indx,px2_glop,ierr) |
---|
| 174 | endif |
---|
[38] | 175 | |
---|
| 176 | ierr= NF_CLOSE(nid) |
---|
| 177 | return |
---|
| 178 | |
---|
| 179 | else |
---|
[1130] | 180 | ! variable found in file |
---|
[38] | 181 | namebis=trim(nom)//"_sd" |
---|
| 182 | ierr= NF_INQ_VARID(nid,namebis,sdid) |
---|
| 183 | |
---|
| 184 | endif |
---|
| 185 | |
---|
| 186 | if (firstvar==nom) then |
---|
[1130] | 187 | count(indx)=count(int(indx))+1 |
---|
| 188 | indx=indx+1 |
---|
| 189 | if (indx>istime) then |
---|
| 190 | indx=1 |
---|
[38] | 191 | endif |
---|
| 192 | endif |
---|
| 193 | |
---|
[1130] | 194 | if (count(indx)==0) then |
---|
| 195 | ! very first time we write the variable to file |
---|
[38] | 196 | if (dim.eq.3) then |
---|
[1130] | 197 | start=(/1,1,1,indx/) |
---|
| 198 | sizes=(/iip1,jjp1,llm,1/) |
---|
| 199 | mean3d(:,:,:)=0 |
---|
| 200 | sd3d(:,:,:)=0 |
---|
[38] | 201 | else if (dim.eq.2) then |
---|
[1130] | 202 | start=(/1,1,indx,0/) |
---|
| 203 | sizes=(/iip1,jjp1,1,0/) |
---|
| 204 | mean2d(:,:)=0 |
---|
| 205 | sd2d(:,:)=0 |
---|
[38] | 206 | endif |
---|
| 207 | else |
---|
[1130] | 208 | ! load values from file |
---|
[38] | 209 | if (dim.eq.3) then |
---|
[1130] | 210 | start=(/1,1,1,indx/) |
---|
| 211 | sizes=(/iip1,jjp1,llm,1/) |
---|
[38] | 212 | #ifdef NC_DOUBLE |
---|
[1130] | 213 | ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean3d) |
---|
| 214 | ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,sizes,sd3d) |
---|
[38] | 215 | #else |
---|
[1130] | 216 | ierr = NF_GET_VARA_REAL(nid,meanid,start,sizes,mean3d) |
---|
| 217 | ierr = NF_GET_VARA_REAL(nid,sdid,start,sizes,sd3d) |
---|
[38] | 218 | #endif |
---|
| 219 | if (ierr.ne.NF_NOERR) then |
---|
| 220 | write (*,*) NF_STRERROR(ierr) |
---|
| 221 | stop "" |
---|
| 222 | endif |
---|
| 223 | |
---|
| 224 | else if (dim.eq.2) then |
---|
[1130] | 225 | start=(/1,1,indx,0/) |
---|
| 226 | sizes=(/iip1,jjp1,1,0/) |
---|
[38] | 227 | #ifdef NC_DOUBLE |
---|
[1130] | 228 | ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean2d) |
---|
| 229 | ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,sizes,sd2d) |
---|
[38] | 230 | #else |
---|
[1130] | 231 | ierr = NF_GET_VARA_REAL(nid,meanid,start,sizes,mean2d) |
---|
| 232 | ierr = NF_GET_VARA_REAL(nid,sdid,start,sizes,sd2d) |
---|
[38] | 233 | #endif |
---|
| 234 | if (ierr.ne.NF_NOERR) then |
---|
| 235 | write (*,*) NF_STRERROR(ierr) |
---|
| 236 | stop "" |
---|
| 237 | endif |
---|
| 238 | endif |
---|
[1130] | 239 | endif ! of if (count(indx)==0) |
---|
[38] | 240 | |
---|
[1130] | 241 | |
---|
| 242 | ! 2.1. Build dx* (data on lon-lat grid, with redundant longitude) |
---|
| 243 | |
---|
[38] | 244 | if (dim.eq.3) then |
---|
[1130] | 245 | dx3(1:iim,:,:)=px3_glo(:,:,:) |
---|
| 246 | dx3(iip1,:,:)=dx3(1,:,:) |
---|
| 247 | else ! dim.eq.2 |
---|
| 248 | dx2(1:iim,:)=px2_glo(:,:) |
---|
| 249 | dx2(iip1,:)=dx2(1,:) |
---|
| 250 | endif |
---|
[38] | 251 | |
---|
| 252 | |
---|
[1130] | 253 | ! 2.2. Add current values to previously stored sums |
---|
[38] | 254 | |
---|
[1130] | 255 | if (dim.eq.3) then |
---|
[38] | 256 | |
---|
[1130] | 257 | mean3d(:,:,:)=mean3d(:,:,:)+dx3(:,:,:) |
---|
| 258 | sd3d(:,:,:)=sd3d(:,:,:)+dx3(:,:,:)**2 |
---|
| 259 | |
---|
[38] | 260 | #ifdef NC_DOUBLE |
---|
[1130] | 261 | ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,sizes,mean3d) |
---|
| 262 | ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,sizes,sd3d) |
---|
[38] | 263 | #else |
---|
[1130] | 264 | ierr = NF_PUT_VARA_REAL(nid,meanid,start,sizes,mean3d) |
---|
| 265 | ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd3d) |
---|
[38] | 266 | #endif |
---|
| 267 | |
---|
| 268 | else if (dim.eq.2) then |
---|
| 269 | |
---|
| 270 | mean2d(:,:)= mean2d(:,:)+dx2(:,:) |
---|
[1130] | 271 | sd2d(:,:)=sd2d(:,:)+dx2(:,:)**2 |
---|
[38] | 272 | |
---|
| 273 | #ifdef NC_DOUBLE |
---|
[1130] | 274 | ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,sizes,mean2d) |
---|
| 275 | ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,sizes,sd2d) |
---|
[38] | 276 | #else |
---|
[1130] | 277 | ierr = NF_PUT_VARA_REAL(nid,meanid,start,sizes,mean2d) |
---|
| 278 | ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd2d) |
---|
[38] | 279 | #endif |
---|
| 280 | |
---|
[1130] | 281 | endif ! of if (dim.eq.3) elseif (dim.eq.2) |
---|
[38] | 282 | |
---|
[1130] | 283 | ierr= NF_CLOSE(nid) |
---|
| 284 | endif ! of if (is_master) |
---|
[38] | 285 | |
---|
| 286 | end subroutine wstats |
---|
| 287 | |
---|
| 288 | !====================================================== |
---|
[1130] | 289 | subroutine inivar(nid,varid,ngrid,dim,indx,px,ierr) |
---|
[38] | 290 | |
---|
| 291 | implicit none |
---|
| 292 | |
---|
| 293 | include "dimensions.h" |
---|
| 294 | include "netcdf.inc" |
---|
| 295 | |
---|
[1130] | 296 | integer, intent(in) :: nid,varid,dim,indx,ngrid |
---|
[38] | 297 | real, dimension(ngrid,llm), intent(in) :: px |
---|
| 298 | integer, intent(out) :: ierr |
---|
| 299 | |
---|
| 300 | integer,parameter :: iip1=iim+1 |
---|
| 301 | integer,parameter :: jjp1=jjm+1 |
---|
| 302 | |
---|
| 303 | integer :: l,i,j,ig0 |
---|
[1130] | 304 | integer, dimension(4) :: start,sizes |
---|
[38] | 305 | real, dimension(iip1,jjp1,llm) :: dx3 |
---|
| 306 | real, dimension(iip1,jjp1) :: dx2 |
---|
| 307 | |
---|
| 308 | if (dim.eq.3) then |
---|
| 309 | |
---|
[1130] | 310 | start=(/1,1,1,indx/) |
---|
| 311 | sizes=(/iip1,jjp1,llm,1/) |
---|
[38] | 312 | |
---|
| 313 | ! Passage variable physique --> variable dynamique |
---|
| 314 | |
---|
| 315 | DO l=1,llm |
---|
| 316 | DO i=1,iip1 |
---|
| 317 | dx3(i,1,l)=px(1,l) |
---|
| 318 | dx3(i,jjp1,l)=px(ngrid,l) |
---|
| 319 | ENDDO |
---|
| 320 | DO j=2,jjm |
---|
| 321 | ig0= 1+(j-2)*iim |
---|
| 322 | DO i=1,iim |
---|
| 323 | dx3(i,j,l)=px(ig0+i,l) |
---|
| 324 | ENDDO |
---|
| 325 | dx3(iip1,j,l)=dx3(1,j,l) |
---|
| 326 | ENDDO |
---|
| 327 | ENDDO |
---|
| 328 | |
---|
| 329 | #ifdef NC_DOUBLE |
---|
[1130] | 330 | ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3) |
---|
[38] | 331 | #else |
---|
[1130] | 332 | ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3) |
---|
[38] | 333 | #endif |
---|
| 334 | |
---|
| 335 | else if (dim.eq.2) then |
---|
| 336 | |
---|
[1130] | 337 | start=(/1,1,indx,0/) |
---|
| 338 | sizes=(/iip1,jjp1,1,0/) |
---|
[38] | 339 | |
---|
| 340 | ! Passage variable physique --> physique dynamique |
---|
| 341 | |
---|
| 342 | DO i=1,iip1 |
---|
| 343 | dx2(i,1)=px(1,1) |
---|
| 344 | dx2(i,jjp1)=px(ngrid,1) |
---|
| 345 | ENDDO |
---|
| 346 | DO j=2,jjm |
---|
| 347 | ig0= 1+(j-2)*iim |
---|
| 348 | DO i=1,iim |
---|
| 349 | dx2(i,j)=px(ig0+i,1) |
---|
| 350 | ENDDO |
---|
| 351 | dx2(iip1,j)=dx2(1,j) |
---|
| 352 | ENDDO |
---|
| 353 | |
---|
| 354 | #ifdef NC_DOUBLE |
---|
[1130] | 355 | ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2) |
---|
[38] | 356 | #else |
---|
[1130] | 357 | ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2) |
---|
[38] | 358 | #endif |
---|
| 359 | |
---|
| 360 | endif |
---|
| 361 | |
---|
| 362 | end subroutine inivar |
---|
| 363 | |
---|
| 364 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 365 | |
---|
| 366 | subroutine def_var_stats(nid,name,title,units,nbdim,dimids,nvarid,ierr) |
---|
| 367 | |
---|
| 368 | ! This subroutine defines variable 'name' in a (pre-existing and opened) |
---|
| 369 | ! NetCDF file (known from its NetCDF ID 'nid'). |
---|
| 370 | ! The number of dimensions 'nbdim' of the variable, as well as the IDs of |
---|
| 371 | ! corresponding dimensions must be set (in array 'dimids'). |
---|
| 372 | ! Upon successfull definition of the variable, 'nvarid' contains the |
---|
| 373 | ! NetCDF ID of the variable. |
---|
| 374 | ! The variables' attributes 'title' (Note that 'long_name' would be more |
---|
| 375 | ! appropriate) and 'units' are also set. |
---|
| 376 | |
---|
| 377 | implicit none |
---|
| 378 | |
---|
| 379 | #include "netcdf.inc" |
---|
| 380 | |
---|
| 381 | integer,intent(in) :: nid ! NetCDF file ID |
---|
| 382 | character(len=*),intent(in) :: name ! the variable's name |
---|
| 383 | character(len=*),intent(in) :: title ! 'title' attribute of variable |
---|
| 384 | character(len=*),intent(in) :: units ! 'units' attribute of variable |
---|
| 385 | integer,intent(in) :: nbdim ! number of dimensions of the variable |
---|
| 386 | integer,dimension(nbdim),intent(in) :: dimids ! NetCDF IDs of the dimensions |
---|
| 387 | ! the variable is defined along |
---|
| 388 | integer,intent(out) :: nvarid ! NetCDF ID of the variable |
---|
| 389 | integer,intent(out) :: ierr ! returned NetCDF staus code |
---|
| 390 | |
---|
| 391 | ! 1. Switch to NetCDF define mode |
---|
| 392 | ierr=NF_REDEF(nid) |
---|
| 393 | |
---|
| 394 | ! 2. Define the variable |
---|
| 395 | #ifdef NC_DOUBLE |
---|
| 396 | ierr = NF_DEF_VAR (nid,adjustl(name),NF_DOUBLE,nbdim,dimids,nvarid) |
---|
| 397 | #else |
---|
| 398 | ierr = NF_DEF_VAR (nid,adjustl(name),NF_FLOAT,nbdim,dimids,nvarid) |
---|
| 399 | #endif |
---|
| 400 | if(ierr/=NF_NOERR) then |
---|
| 401 | write(*,*) "def_var_stats: Failed defining variable "//trim(name) |
---|
| 402 | write(*,*) NF_STRERROR(ierr) |
---|
| 403 | stop "" |
---|
| 404 | endif |
---|
| 405 | |
---|
| 406 | ! 3. Write attributes |
---|
| 407 | ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title",& |
---|
| 408 | len_trim(adjustl(title)),adjustl(title)) |
---|
| 409 | if(ierr/=NF_NOERR) then |
---|
| 410 | write(*,*) "def_var_stats: Failed writing title attribute for "//trim(name) |
---|
| 411 | write(*,*) NF_STRERROR(ierr) |
---|
| 412 | stop "" |
---|
| 413 | endif |
---|
| 414 | |
---|
| 415 | ierr=NF_PUT_ATT_TEXT(nid,nvarid,"units",& |
---|
| 416 | len_trim(adjustl(units)),adjustl(units)) |
---|
| 417 | if(ierr/=NF_NOERR) then |
---|
| 418 | write(*,*) "def_var_stats: Failed writing units attribute for "//trim(name) |
---|
| 419 | write(*,*) NF_STRERROR(ierr) |
---|
| 420 | stop "" |
---|
| 421 | endif |
---|
| 422 | |
---|
| 423 | ! 4. Switch out of NetCDF define mode |
---|
| 424 | ierr = NF_ENDDEF(nid) |
---|
| 425 | |
---|
| 426 | end subroutine def_var_stats |
---|
| 427 | |
---|