[3000] | 1 | #define __MYFILE__ 'ioncdf.F90' |
---|
| 2 | MODULE ioncdf |
---|
| 3 | !!====================================================================== |
---|
| 4 | !! *** MODULE ioncdf *** |
---|
| 5 | !! Input/Output: manage netcdf inputs/outputs |
---|
| 6 | !!===================================================================== |
---|
| 7 | |
---|
| 8 | !!---------------------------------------------------------------------- |
---|
| 9 | !! ioncdf : manage netcdf inputs/outputs |
---|
| 10 | !! put_map : write a 2d/3d map |
---|
| 11 | !! put_scalar : write a scalar |
---|
| 12 | !! test_var : test if variable exists |
---|
| 13 | !! get_nb_dim : get dimension number of a variable |
---|
| 14 | !! get_dim_val : get dimensions values of a variable |
---|
| 15 | !! get_var : read a 1d/2d/3d/4d array |
---|
| 16 | !! put_coord : write coordinates |
---|
| 17 | !! create_map : create map netcdf file |
---|
| 18 | !! put_att : write CF attributes |
---|
| 19 | !! get_var_info : get CF attributes |
---|
| 20 | !! Original : Nicolas Daget |
---|
| 21 | !! Modified : MAB (nf90) |
---|
| 22 | !!--------------------------------------------------------------------- |
---|
| 23 | !! * Modules used |
---|
| 24 | USE toolspar_kind |
---|
| 25 | USE netcdf |
---|
| 26 | USE nctools |
---|
| 27 | |
---|
| 28 | IMPLICIT NONE |
---|
| 29 | PRIVATE |
---|
| 30 | |
---|
| 31 | !! * Routine accessibility |
---|
| 32 | PUBLIC :: put_coord, put_map, get_var, test_var, put_scalar, get_nb_dim, & |
---|
| 33 | get_dim_val, get_scalar |
---|
| 34 | |
---|
| 35 | !! * Substitutions |
---|
| 36 | |
---|
| 37 | !! * Interface |
---|
| 38 | INTERFACE put_coord |
---|
| 39 | MODULE PROCEDURE put_coord_r, put_coord_d |
---|
| 40 | END INTERFACE |
---|
| 41 | |
---|
| 42 | INTERFACE put_map |
---|
| 43 | MODULE PROCEDURE put_map_2d_r, put_map_3d_r, put_map_2d_d, put_map_3d_d |
---|
| 44 | END INTERFACE |
---|
| 45 | |
---|
| 46 | INTERFACE put_scalar |
---|
| 47 | MODULE PROCEDURE put_scalar_i, put_scalar_r, put_scalar_d |
---|
| 48 | END INTERFACE |
---|
| 49 | |
---|
| 50 | INTERFACE get_var |
---|
| 51 | MODULE PROCEDURE get_var_1d_r, get_var_2d_r, get_var_3d_r, get_var_4d_r, & |
---|
| 52 | get_var_1d_d, get_var_2d_d, get_var_3d_d, get_var_4d_d, & |
---|
| 53 | get_var_1d_i, get_var_2d_i, get_var_3d_i, get_var_4d_i |
---|
| 54 | END INTERFACE |
---|
| 55 | |
---|
| 56 | INTERFACE get_scalar |
---|
| 57 | MODULE PROCEDURE get_scalar_i, get_scalar_r, get_scalar_d |
---|
| 58 | END INTERFACE |
---|
| 59 | |
---|
| 60 | CONTAINS |
---|
| 61 | |
---|
| 62 | SUBROUTINE test_var ( cd_filename, cd_var, k_test ) |
---|
| 63 | !!---------------------------------------------------------------------- |
---|
| 64 | !! *** ROUTINE test_var *** |
---|
| 65 | !! |
---|
| 66 | !! ** Purpose : test if cd_var exists |
---|
| 67 | !! |
---|
| 68 | !! ** Method : use netcdf fortran library |
---|
| 69 | !! |
---|
| 70 | !! ** Action : - get variable informations |
---|
| 71 | !! |
---|
| 72 | !! Reference : |
---|
| 73 | !! |
---|
| 74 | !! History : |
---|
| 75 | !! 06-05 (N. Daget) original code |
---|
| 76 | !!---------------------------------------------------------------------- |
---|
| 77 | !! * Modules used |
---|
| 78 | |
---|
| 79 | !! * Library used |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | !! * arguments |
---|
| 83 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 84 | cd_filename ! filename |
---|
| 85 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 86 | cd_var ! variable name |
---|
| 87 | INTEGER, INTENT(out) :: & |
---|
| 88 | k_test ! test if variable exists |
---|
| 89 | |
---|
| 90 | !! * local declarations |
---|
| 91 | INTEGER :: & |
---|
| 92 | i_file_id, i_var_id ! file and variable identifier |
---|
| 93 | !!---------------------------------------------------------------------- |
---|
| 94 | |
---|
| 95 | ! Open and test netcdf file |
---|
| 96 | ! ------------------------- |
---|
| 97 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ),& |
---|
| 98 | & __LINE__,__MYFILE__) |
---|
| 99 | k_test = nf90_inq_varid( i_file_id, cd_var, i_var_id ) |
---|
| 100 | CALL nchdlerr( nf90_close( i_file_id ),& |
---|
| 101 | & __LINE__,__MYFILE__) |
---|
| 102 | |
---|
| 103 | IF ( k_test .EQ. nf90_noerr ) THEN |
---|
| 104 | k_test = 1 |
---|
| 105 | ELSE |
---|
| 106 | k_test = 0 |
---|
| 107 | ENDIF |
---|
| 108 | |
---|
| 109 | END SUBROUTINE test_var |
---|
| 110 | SUBROUTINE get_nb_dim ( cd_filename, cd_var, k_nb_dim ) |
---|
| 111 | !!---------------------------------------------------------------------- |
---|
| 112 | !! *** ROUTINE get_nb_dim *** |
---|
| 113 | !! |
---|
| 114 | !! ** Purpose : Get dimension number of variable |
---|
| 115 | !! |
---|
| 116 | !! ** Method : use netcdf fortran library |
---|
| 117 | !! |
---|
| 118 | !! ** Action : - get dimension number of variables |
---|
| 119 | !! |
---|
| 120 | !! Reference : |
---|
| 121 | !! |
---|
| 122 | !! History : |
---|
| 123 | !! 06-06 (N. Daget) original code |
---|
| 124 | !!---------------------------------------------------------------------- |
---|
| 125 | !! * Modules used |
---|
| 126 | |
---|
| 127 | !! * Library used |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | !! * arguments |
---|
| 131 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 132 | cd_filename ! filename |
---|
| 133 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 134 | cd_var ! variable name |
---|
| 135 | INTEGER, INTENT(out) :: & |
---|
| 136 | k_nb_dim ! c$dimension number of variable |
---|
| 137 | |
---|
| 138 | !! * local declarations |
---|
| 139 | INTEGER :: & |
---|
| 140 | i_file_id, i_var_id ! file and variable identifier |
---|
| 141 | !!---------------------------------------------------------------------- |
---|
| 142 | |
---|
| 143 | ! Open and test netcdf file |
---|
| 144 | ! ------------------------- |
---|
| 145 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 146 | & __LINE__,__MYFILE__) |
---|
| 147 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 148 | & __LINE__,__MYFILE__) |
---|
| 149 | CALL nchdlerr(nf90_inquire_variable( i_file_id, i_var_id, ndims=k_nb_dim ),& |
---|
| 150 | & __LINE__,__MYFILE__) |
---|
| 151 | CALL nchdlerr( nf90_close( i_file_id ),& |
---|
| 152 | & __LINE__,__MYFILE__) |
---|
| 153 | END SUBROUTINE get_nb_dim |
---|
| 154 | |
---|
| 155 | SUBROUTINE get_dim_val ( cd_filename, cd_var, k_dim ) |
---|
| 156 | !!---------------------------------------------------------------------- |
---|
| 157 | !! *** ROUTINE get_dim_val *** |
---|
| 158 | !! |
---|
| 159 | !! ** Purpose : Get dimensions values of a variable |
---|
| 160 | !! |
---|
| 161 | !! ** Method : use netcdf fortran library |
---|
| 162 | !! |
---|
| 163 | !! ** Action : - get dimensions values of a variable |
---|
| 164 | !! |
---|
| 165 | !! Reference : |
---|
| 166 | !! |
---|
| 167 | !! History : |
---|
| 168 | !! 06-06 (N. Daget) original code |
---|
| 169 | !!---------------------------------------------------------------------- |
---|
| 170 | !! * Modules used |
---|
| 171 | |
---|
| 172 | !! * Library used |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | !! * arguments |
---|
| 176 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 177 | cd_filename ! filename |
---|
| 178 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 179 | cd_var ! variable name |
---|
| 180 | INTEGER, DIMENSION(:), INTENT(out) :: & |
---|
| 181 | k_dim ! dimensions values of a variable |
---|
| 182 | |
---|
| 183 | !! * local declarations |
---|
| 184 | INTEGER, DIMENSION(1) :: i_nbdim ! dimensions of the variable |
---|
| 185 | INTEGER :: & |
---|
| 186 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 187 | ii ! counter |
---|
| 188 | !!---------------------------------------------------------------------- |
---|
| 189 | |
---|
| 190 | ! Open and test netcdf file |
---|
| 191 | ! ------------------------- |
---|
| 192 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 193 | & __LINE__,__MYFILE__) |
---|
| 194 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 195 | & __LINE__,__MYFILE__) |
---|
| 196 | CALL nchdlerr(nf90_inquire_variable( i_file_id, i_var_id, dimids=k_dim ) ,& |
---|
| 197 | & __LINE__,__MYFILE__) |
---|
| 198 | i_nbdim = SHAPE( k_dim ) |
---|
| 199 | DO ii = 1, i_nbdim(1) |
---|
| 200 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, k_dim(ii), len=k_dim(ii) ),__LINE__,__MYFILE__ ) |
---|
| 201 | ENDDO |
---|
| 202 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 203 | & __LINE__,__MYFILE__) |
---|
| 204 | |
---|
| 205 | END SUBROUTINE get_dim_val |
---|
| 206 | |
---|
| 207 | !!====================================================================== |
---|
| 208 | |
---|
| 209 | SUBROUTINE get_scalar_i ( cd_filename, cd_var, k_var ) |
---|
| 210 | !!---------------------------------------------------------------------- |
---|
| 211 | !! *** ROUTINE get_scalar_i *** |
---|
| 212 | !! |
---|
| 213 | !! ** Purpose : read integer scalar in a netcdf file |
---|
| 214 | !! |
---|
| 215 | !! ** Method : use netcdf fortran library |
---|
| 216 | !! |
---|
| 217 | !! ** Action : - get variable informations |
---|
| 218 | !! - read variable |
---|
| 219 | !! |
---|
| 220 | !! Reference : |
---|
| 221 | !! |
---|
| 222 | !! History : |
---|
| 223 | !! 06-09 (N. Daget) original code |
---|
| 224 | !!---------------------------------------------------------------------- |
---|
| 225 | !! * Modules used |
---|
| 226 | |
---|
| 227 | !! * Library used |
---|
| 228 | |
---|
| 229 | !! * arguments |
---|
| 230 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 231 | cd_filename ! filename |
---|
| 232 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 233 | cd_var ! variable name |
---|
| 234 | INTEGER, INTENT(out) :: & |
---|
| 235 | k_var ! variable to read in netcdf file |
---|
| 236 | |
---|
| 237 | !! * local declarations |
---|
| 238 | INTEGER :: & |
---|
| 239 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 240 | i_ndims, & ! Number of dimensions for this variable |
---|
| 241 | i_type ! external data type for this variable |
---|
| 242 | !!---------------------------------------------------------------------- |
---|
| 243 | |
---|
| 244 | ! Open and test netcdf file |
---|
| 245 | ! ------------------------- |
---|
| 246 | CALL nchdlerr(nf90_open( cd_filename, nf90_nowrite, i_file_id ),& |
---|
| 247 | & __LINE__,__MYFILE__) |
---|
| 248 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 249 | & __LINE__,__MYFILE__) |
---|
| 250 | CALL nchdlerr(nf90_inquire_variable( i_file_id, i_var_id,xtype=i_type,ndims=i_ndims),& |
---|
| 251 | & __LINE__,__MYFILE__) |
---|
| 252 | IF ( i_type .NE. 4 ) THEN |
---|
| 253 | WRITE(*,*)'filename = ',cd_filename |
---|
| 254 | WRITE(*,*)'variable = ',cd_var |
---|
| 255 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 256 | WRITE(*,*)'The valid external data type is NF_INT : 4' |
---|
| 257 | WRITE(*,*)'CALL abort' |
---|
| 258 | CALL abort |
---|
| 259 | ENDIF |
---|
| 260 | |
---|
| 261 | IF ( i_ndims .NE. 1 ) THEN |
---|
| 262 | WRITE(*,*)'filename = ',cd_filename |
---|
| 263 | WRITE(*,*)'variable = ',cd_var |
---|
| 264 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 265 | WRITE(*,*)'The valid number of dimension is 1' |
---|
| 266 | WRITE(*,*)'CALL abort' |
---|
| 267 | CALL abort |
---|
| 268 | ENDIF |
---|
| 269 | |
---|
| 270 | ! Read variable |
---|
| 271 | ! ------------- |
---|
| 272 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, k_var ),& |
---|
| 273 | & __LINE__,__MYFILE__ ) |
---|
| 274 | |
---|
| 275 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 276 | & __LINE__,__MYFILE__) |
---|
| 277 | |
---|
| 278 | END SUBROUTINE get_scalar_i |
---|
| 279 | |
---|
| 280 | SUBROUTINE get_scalar_r ( cd_filename, cd_var, p_var ) |
---|
| 281 | !!---------------------------------------------------------------------- |
---|
| 282 | !! *** ROUTINE get_scalar_r *** |
---|
| 283 | !! |
---|
| 284 | !! ** Purpose : read real scalar in a netcdf file |
---|
| 285 | !! |
---|
| 286 | !! ** Method : use netcdf fortran library |
---|
| 287 | !! |
---|
| 288 | !! ** Action : - get variable informations |
---|
| 289 | !! - read variable |
---|
| 290 | !! |
---|
| 291 | !! Reference : |
---|
| 292 | !! |
---|
| 293 | !! History : |
---|
| 294 | !! 06-09 (N. Daget) original code |
---|
| 295 | !!---------------------------------------------------------------------- |
---|
| 296 | !! * Modules used |
---|
| 297 | |
---|
| 298 | !! * Library used |
---|
| 299 | |
---|
| 300 | !! * arguments |
---|
| 301 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 302 | cd_filename ! filename |
---|
| 303 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 304 | cd_var ! variable name |
---|
| 305 | REAL(KIND=sp), INTENT(out) :: & |
---|
| 306 | p_var ! variable to read in netcdf file |
---|
| 307 | |
---|
| 308 | !! * local declarations |
---|
| 309 | INTEGER :: & |
---|
| 310 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 311 | i_ndims, & ! Number of dimensions for this variable |
---|
| 312 | i_type ! external data type for this variable |
---|
| 313 | !!---------------------------------------------------------------------- |
---|
| 314 | |
---|
| 315 | ! Open and test netcdf file |
---|
| 316 | ! ------------------------- |
---|
| 317 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 318 | & __LINE__,__MYFILE__) |
---|
| 319 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 320 | & __LINE__,__MYFILE__) |
---|
| 321 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type,ndims=i_ndims ),& |
---|
| 322 | & __LINE__,__MYFILE__) |
---|
| 323 | IF ( i_type .NE. 5 ) THEN |
---|
| 324 | WRITE(*,*)'filename = ',cd_filename |
---|
| 325 | WRITE(*,*)'variable = ',cd_var |
---|
| 326 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 327 | WRITE(*,*)'The valid external data type is NF_FLOAT : 5' |
---|
| 328 | ! WRITE(*,*)'CALL abort' |
---|
| 329 | ! CALL abort |
---|
| 330 | ENDIF |
---|
| 331 | IF ( i_ndims .NE. 1 ) THEN |
---|
| 332 | WRITE(*,*)'filename = ',cd_filename |
---|
| 333 | WRITE(*,*)'variable = ',cd_var |
---|
| 334 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 335 | WRITE(*,*)'The valid number of dimension is 1' |
---|
| 336 | WRITE(*,*)'CALL abort' |
---|
| 337 | CALL abort |
---|
| 338 | ENDIF |
---|
| 339 | |
---|
| 340 | ! Read variable |
---|
| 341 | ! ------------- |
---|
| 342 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, p_var ) ,__LINE__,__MYFILE__ ) |
---|
| 343 | |
---|
| 344 | CALL nchdlerr( nf90_close( i_file_id ),__LINE__,__MYFILE__ ) |
---|
| 345 | |
---|
| 346 | END SUBROUTINE get_scalar_r |
---|
| 347 | |
---|
| 348 | SUBROUTINE get_scalar_d ( cd_filename, cd_var, dd_var ) |
---|
| 349 | !!---------------------------------------------------------------------- |
---|
| 350 | !! *** ROUTINE get_scalar_d *** |
---|
| 351 | !! |
---|
| 352 | !! ** Purpose : read double scalar in a netcdf file |
---|
| 353 | !! |
---|
| 354 | !! ** Method : use netcdf fortran library |
---|
| 355 | !! |
---|
| 356 | !! ** Action : - get variable informations |
---|
| 357 | !! - read variable |
---|
| 358 | !! |
---|
| 359 | !! Reference : |
---|
| 360 | !! |
---|
| 361 | !! History : |
---|
| 362 | !! 06-09 (N. Daget) original code |
---|
| 363 | !!---------------------------------------------------------------------- |
---|
| 364 | !! * Modules used |
---|
| 365 | |
---|
| 366 | !! * Library used |
---|
| 367 | |
---|
| 368 | !! * arguments |
---|
| 369 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 370 | cd_filename ! filename |
---|
| 371 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 372 | cd_var ! variable name |
---|
| 373 | REAL(KIND=dp), INTENT(out) :: & |
---|
| 374 | dd_var ! variable to read in netcdf file |
---|
| 375 | |
---|
| 376 | !! * local declarations |
---|
| 377 | INTEGER :: & |
---|
| 378 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 379 | i_ndims, & ! Number of dimensions for this variable |
---|
| 380 | i_type ! external data type for this variable |
---|
| 381 | !!---------------------------------------------------------------------- |
---|
| 382 | |
---|
| 383 | ! Open and test netcdf file |
---|
| 384 | ! ------------------------- |
---|
| 385 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 386 | & __LINE__,__MYFILE__) |
---|
| 387 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ),__LINE__,__MYFILE__ ) |
---|
| 388 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type,ndims=i_ndims),__LINE__,__MYFILE__ ) |
---|
| 389 | IF ( i_type .NE. 6 ) THEN |
---|
| 390 | WRITE(*,*)'filename = ',cd_filename |
---|
| 391 | WRITE(*,*)'variable = ',cd_var |
---|
| 392 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 393 | WRITE(*,*)'The valid external data type is NF_DOUBLE : 6' |
---|
| 394 | ! WRITE(*,*)'CALL abort' |
---|
| 395 | ! CALL abort |
---|
| 396 | ENDIF |
---|
| 397 | IF ( i_ndims .NE. 1 ) THEN |
---|
| 398 | WRITE(*,*)'filename = ',cd_filename |
---|
| 399 | WRITE(*,*)'variable = ',cd_var |
---|
| 400 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 401 | WRITE(*,*)'The valid number of dimension is 1' |
---|
| 402 | WRITE(*,*)'CALL abort' |
---|
| 403 | CALL abort |
---|
| 404 | ENDIF |
---|
| 405 | |
---|
| 406 | ! Read variable |
---|
| 407 | ! ------------- |
---|
| 408 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, dd_var ),__LINE__,__MYFILE__ ) |
---|
| 409 | |
---|
| 410 | CALL nchdlerr( nf90_close( i_file_id ),__LINE__,__MYFILE__ ) |
---|
| 411 | |
---|
| 412 | END SUBROUTINE get_scalar_d |
---|
| 413 | |
---|
| 414 | !!====================================================================== |
---|
| 415 | |
---|
| 416 | SUBROUTINE put_scalar_i ( cd_filename, k_var, cd_var, cd_longname ) |
---|
| 417 | !!---------------------------------------------------------------------- |
---|
| 418 | !! *** ROUTINE put_scalar_i *** |
---|
| 419 | !! |
---|
| 420 | !! ** Purpose : write an integer scalar in a netcdf file |
---|
| 421 | !! |
---|
| 422 | !! ** Method : use netcdf fortran library |
---|
| 423 | !! |
---|
| 424 | !! ** Action : - get variable informations |
---|
| 425 | !! - (re)define variable |
---|
| 426 | !! - put variable in netcdf file |
---|
| 427 | !! |
---|
| 428 | !! Reference : |
---|
| 429 | !! |
---|
| 430 | !! History : |
---|
| 431 | !! 06-05 (N. Daget) original code |
---|
| 432 | !!---------------------------------------------------------------------- |
---|
| 433 | !! * Modules used |
---|
| 434 | |
---|
| 435 | !! * Library used |
---|
| 436 | |
---|
| 437 | |
---|
| 438 | !! * arguments |
---|
| 439 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 440 | cd_filename, & ! filename |
---|
| 441 | cd_var ! variable name |
---|
| 442 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 443 | cd_longname ! variable longname |
---|
| 444 | INTEGER, INTENT(in) :: & |
---|
| 445 | k_var ! variable to write in netcdf file |
---|
| 446 | |
---|
| 447 | !! * local declarations |
---|
| 448 | LOGICAL :: llexist ! test |
---|
| 449 | INTEGER :: & |
---|
| 450 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 451 | i_dim_id, & ! dimension identifier |
---|
| 452 | i_var_exist, i_dim_exist ! tests |
---|
| 453 | INTEGER, DIMENSION(1) :: & |
---|
| 454 | i_dim ! netcdf information |
---|
| 455 | !!---------------------------------------------------------------------- |
---|
| 456 | |
---|
| 457 | ! |
---|
| 458 | ! Open or create file |
---|
| 459 | ! ------------------- |
---|
| 460 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 461 | IF ( .NOT. llexist ) THEN |
---|
| 462 | CALL nchdlerr( nf90_create( cd_filename, nf90_clobber, i_file_id ) ,& |
---|
| 463 | & __LINE__,__MYFILE__) |
---|
| 464 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 465 | & __LINE__,__MYFILE__) |
---|
| 466 | ELSE |
---|
| 467 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 468 | & __LINE__,__MYFILE__) |
---|
| 469 | ENDIF |
---|
| 470 | |
---|
| 471 | i_dim_exist = nf90_inq_dimid( i_file_id, 'scalar', i_dim_id ) |
---|
| 472 | IF ( i_dim_exist .NE. 0 ) THEN |
---|
| 473 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 474 | & __LINE__,__MYFILE__) |
---|
| 475 | CALL nchdlerr( nf90_def_dim( i_file_id, 'scalar', 1, i_dim_id ) ,& |
---|
| 476 | & __LINE__,__MYFILE__) |
---|
| 477 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 478 | & __LINE__,__MYFILE__) |
---|
| 479 | ENDIF |
---|
| 480 | |
---|
| 481 | i_dim(1) = i_dim_id |
---|
| 482 | |
---|
| 483 | ! |
---|
| 484 | ! Define variable or find it |
---|
| 485 | ! -------------------------- |
---|
| 486 | i_var_exist = nf90_inq_varid( i_file_id, cd_var, i_var_id ) |
---|
| 487 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 488 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 489 | & __LINE__,__MYFILE__) |
---|
| 490 | CALL nchdlerr( nf90_def_var( i_file_id, cd_var, nf90_int, i_dim, i_var_id ) ,& |
---|
| 491 | & __LINE__,__MYFILE__) |
---|
| 492 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', TRIM(cd_var) ) ,& |
---|
| 493 | & __LINE__,__MYFILE__) |
---|
| 494 | IF ( PRESENT(cd_longname) ) THEN |
---|
| 495 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', TRIM(cd_longname) ) ,& |
---|
| 496 | & __LINE__,__MYFILE__) |
---|
| 497 | ENDIF |
---|
| 498 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 499 | & __LINE__,__MYFILE__) |
---|
| 500 | ENDIF |
---|
| 501 | |
---|
| 502 | ! Put variable(s) |
---|
| 503 | ! -------------- |
---|
| 504 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, k_var ) ,& |
---|
| 505 | & __LINE__,__MYFILE__) |
---|
| 506 | |
---|
| 507 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 508 | & __LINE__,__MYFILE__) |
---|
| 509 | |
---|
| 510 | END SUBROUTINE put_scalar_i |
---|
| 511 | |
---|
| 512 | SUBROUTINE put_scalar_r ( cd_filename, p_var, cd_var, cd_longname ) |
---|
| 513 | !!---------------------------------------------------------------------- |
---|
| 514 | !! *** ROUTINE put_scalar_r *** |
---|
| 515 | !! |
---|
| 516 | !! ** Purpose : write an real scalar in a netcdf file |
---|
| 517 | !! |
---|
| 518 | !! ** Method : use netcdf fortran library |
---|
| 519 | !! |
---|
| 520 | !! ** Action : - get variable informations |
---|
| 521 | !! - (re)define variable |
---|
| 522 | !! - put variable in netcdf file |
---|
| 523 | !! |
---|
| 524 | !! Reference : |
---|
| 525 | !! |
---|
| 526 | !! History : |
---|
| 527 | !! 06-05 (N. Daget) original code |
---|
| 528 | !!---------------------------------------------------------------------- |
---|
| 529 | !! * Modules used |
---|
| 530 | |
---|
| 531 | !! * Library used |
---|
| 532 | |
---|
| 533 | !! * arguments |
---|
| 534 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 535 | cd_filename, & ! filename |
---|
| 536 | cd_var ! variable name |
---|
| 537 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 538 | cd_longname ! variable longname |
---|
| 539 | REAL(KIND=sp), INTENT(in) :: & |
---|
| 540 | p_var ! variable to write in netcdf file |
---|
| 541 | |
---|
| 542 | !! * local declarations |
---|
| 543 | LOGICAL :: llexist ! test |
---|
| 544 | INTEGER :: & |
---|
| 545 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 546 | i_dim_id, & ! dimension identifier |
---|
| 547 | i_var_exist, i_dim_exist ! tests |
---|
| 548 | INTEGER, DIMENSION(1) :: & |
---|
| 549 | i_dim ! netcdf information |
---|
| 550 | !!---------------------------------------------------------------------- |
---|
| 551 | |
---|
| 552 | ! |
---|
| 553 | ! Open or create file |
---|
| 554 | ! ------------------- |
---|
| 555 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 556 | IF ( .NOT. llexist ) THEN |
---|
| 557 | CALL nchdlerr( nf90_create( cd_filename, nf90_clobber, i_file_id ) ,& |
---|
| 558 | & __LINE__,__MYFILE__) |
---|
| 559 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 560 | & __LINE__,__MYFILE__) |
---|
| 561 | ELSE |
---|
| 562 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 563 | & __LINE__,__MYFILE__) |
---|
| 564 | ENDIF |
---|
| 565 | |
---|
| 566 | i_dim_exist = nf90_inq_dimid( i_file_id, 'scalar', i_dim_id ) |
---|
| 567 | IF ( i_dim_exist .NE. 0 ) THEN |
---|
| 568 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 569 | & __LINE__,__MYFILE__) |
---|
| 570 | CALL nchdlerr( nf90_def_dim( i_file_id, 'scalar', 1, i_dim_id ) ,& |
---|
| 571 | & __LINE__,__MYFILE__) |
---|
| 572 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 573 | & __LINE__,__MYFILE__) |
---|
| 574 | ENDIF |
---|
| 575 | |
---|
| 576 | i_dim(1) = i_dim_id |
---|
| 577 | |
---|
| 578 | ! |
---|
| 579 | ! Define variable or find it |
---|
| 580 | ! -------------------------- |
---|
| 581 | i_var_exist = nf90_inq_varid( i_file_id, cd_var, i_var_id ) |
---|
| 582 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 583 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 584 | & __LINE__,__MYFILE__) |
---|
| 585 | CALL nchdlerr( nf90_def_var( i_file_id, cd_var, nf90_real, i_dim, i_var_id ) ,& |
---|
| 586 | & __LINE__,__MYFILE__) |
---|
| 587 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', TRIM(cd_var) ) ,& |
---|
| 588 | & __LINE__,__MYFILE__) |
---|
| 589 | IF ( PRESENT(cd_longname) ) THEN |
---|
| 590 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', TRIM(cd_longname) ) ,& |
---|
| 591 | & __LINE__,__MYFILE__) |
---|
| 592 | ENDIF |
---|
| 593 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 594 | & __LINE__,__MYFILE__) |
---|
| 595 | ENDIF |
---|
| 596 | |
---|
| 597 | ! Put variable(s) |
---|
| 598 | ! -------------- |
---|
| 599 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, p_var ) ,& |
---|
| 600 | & __LINE__,__MYFILE__) |
---|
| 601 | |
---|
| 602 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 603 | & __LINE__,__MYFILE__) |
---|
| 604 | |
---|
| 605 | END SUBROUTINE put_scalar_r |
---|
| 606 | |
---|
| 607 | SUBROUTINE put_scalar_d ( cd_filename, dd_var, cd_var, cd_longname ) |
---|
| 608 | !!---------------------------------------------------------------------- |
---|
| 609 | !! *** ROUTINE put_scalar_d *** |
---|
| 610 | !! |
---|
| 611 | !! ** Purpose : write an integer scalar in a netcdf file |
---|
| 612 | !! |
---|
| 613 | !! ** Method : use netcdf fortran library |
---|
| 614 | !! |
---|
| 615 | !! ** Action : - get variable informations |
---|
| 616 | !! - (re)define variable |
---|
| 617 | !! - put variable in netcdf file |
---|
| 618 | !! |
---|
| 619 | !! Reference : |
---|
| 620 | !! |
---|
| 621 | !! History : |
---|
| 622 | !! 06-05 (N. Daget) original code |
---|
| 623 | !!---------------------------------------------------------------------- |
---|
| 624 | !! * Modules used |
---|
| 625 | |
---|
| 626 | !! * Library used |
---|
| 627 | |
---|
| 628 | |
---|
| 629 | !! * arguments |
---|
| 630 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 631 | cd_filename, & ! filename |
---|
| 632 | cd_var ! variable name |
---|
| 633 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 634 | cd_longname ! variable longname |
---|
| 635 | REAL(KIND=dp), INTENT(in) :: & |
---|
| 636 | dd_var ! variable to write in netcdf file |
---|
| 637 | |
---|
| 638 | !! * local declarations |
---|
| 639 | LOGICAL :: llexist ! test |
---|
| 640 | INTEGER :: & |
---|
| 641 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 642 | i_dim_id, & ! dimension identifier |
---|
| 643 | i_var_exist, i_dim_exist ! tests |
---|
| 644 | INTEGER, DIMENSION(1) :: & |
---|
| 645 | i_dim ! netcdf information |
---|
| 646 | !!---------------------------------------------------------------------- |
---|
| 647 | |
---|
| 648 | ! |
---|
| 649 | ! Open or create file |
---|
| 650 | ! ------------------- |
---|
| 651 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 652 | IF ( .NOT. llexist ) THEN |
---|
| 653 | CALL nchdlerr( nf90_create( cd_filename, nf90_clobber, i_file_id ) ,& |
---|
| 654 | & __LINE__,__MYFILE__) |
---|
| 655 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 656 | & __LINE__,__MYFILE__) |
---|
| 657 | ELSE |
---|
| 658 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 659 | & __LINE__,__MYFILE__) |
---|
| 660 | ENDIF |
---|
| 661 | |
---|
| 662 | i_dim_exist = nf90_inq_dimid( i_file_id, 'scalar', i_dim_id ) |
---|
| 663 | IF ( i_dim_exist .NE. 0 ) THEN |
---|
| 664 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 665 | & __LINE__,__MYFILE__) |
---|
| 666 | CALL nchdlerr( nf90_def_dim( i_file_id, 'double', 1, i_dim_id ) ,& |
---|
| 667 | & __LINE__,__MYFILE__) |
---|
| 668 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 669 | & __LINE__,__MYFILE__) |
---|
| 670 | ENDIF |
---|
| 671 | |
---|
| 672 | i_dim(1) = i_dim_id |
---|
| 673 | |
---|
| 674 | ! |
---|
| 675 | ! Define variable or find it |
---|
| 676 | ! -------------------------- |
---|
| 677 | i_var_exist = nf90_inq_varid( i_file_id, cd_var, i_var_id ) |
---|
| 678 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 679 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 680 | & __LINE__,__MYFILE__) |
---|
| 681 | CALL nchdlerr( nf90_def_var( i_file_id, cd_var, nf90_double, i_dim, i_var_id ) ,& |
---|
| 682 | & __LINE__,__MYFILE__) |
---|
| 683 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', TRIM(cd_var) ) ,& |
---|
| 684 | & __LINE__,__MYFILE__) |
---|
| 685 | IF ( PRESENT(cd_longname) ) THEN |
---|
| 686 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', TRIM(cd_longname) ) ,& |
---|
| 687 | & __LINE__,__MYFILE__) |
---|
| 688 | ENDIF |
---|
| 689 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 690 | & __LINE__,__MYFILE__) |
---|
| 691 | ENDIF |
---|
| 692 | |
---|
| 693 | ! Put variable(s) |
---|
| 694 | ! -------------- |
---|
| 695 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, dd_var ) ,& |
---|
| 696 | & __LINE__,__MYFILE__) |
---|
| 697 | |
---|
| 698 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 699 | & __LINE__,__MYFILE__) |
---|
| 700 | |
---|
| 701 | END SUBROUTINE put_scalar_d |
---|
| 702 | |
---|
| 703 | !!====================================================================== |
---|
| 704 | |
---|
| 705 | SUBROUTINE put_map_2d_r ( cd_filename, p_var, p_missing, cd_var, k_code, k_time, reftime, leadtime, time_bnd, cd_descr ) |
---|
| 706 | !!---------------------------------------------------------------------- |
---|
| 707 | !! *** ROUTINE put_map_2d_r *** |
---|
| 708 | !! |
---|
| 709 | !! ** Purpose : write 2d map of reals in a netcdf file |
---|
| 710 | !! |
---|
| 711 | !! ** Method : use netcdf fortran library |
---|
| 712 | !! |
---|
| 713 | !! ** Action : - get variable informations |
---|
| 714 | !! - (re)define variable |
---|
| 715 | !! - put variable in netcdf file |
---|
| 716 | !! |
---|
| 717 | !! Reference : |
---|
| 718 | !! |
---|
| 719 | !! History : |
---|
| 720 | !! 06-05 (N. Daget) original code |
---|
| 721 | !!---------------------------------------------------------------------- |
---|
| 722 | !! * Modules used |
---|
| 723 | |
---|
| 724 | !! * Library used |
---|
| 725 | |
---|
| 726 | !! * arguments |
---|
| 727 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 728 | cd_filename ! filename |
---|
| 729 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 730 | cd_var ! variable name |
---|
| 731 | INTEGER, OPTIONAL, INTENT(in) :: & |
---|
| 732 | k_code, & ! CF code |
---|
| 733 | k_time, & ! time of the variable |
---|
| 734 | leadtime ! leadtime of the variable |
---|
| 735 | INTEGER, DIMENSION(:), OPTIONAL, INTENT(in) :: & |
---|
| 736 | time_bnd ! time_bnd |
---|
| 737 | REAL(KIND=sp), OPTIONAL, INTENT(in) :: & |
---|
| 738 | p_missing, & ! missing value of the variable |
---|
| 739 | reftime ! reftime of the variable |
---|
| 740 | REAL(KIND=sp), DIMENSION(:,:), INTENT(in) :: & |
---|
| 741 | p_var ! variable to write in netcdf file |
---|
| 742 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 743 | cd_descr ! description of file contents |
---|
| 744 | |
---|
| 745 | !! * local declarations |
---|
| 746 | LOGICAL :: llexist ! test |
---|
| 747 | CHARACTER(len=80) :: cl_var ! new variable name |
---|
| 748 | INTEGER :: & |
---|
| 749 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 750 | i_dim_x_id, i_dim_y_id, i_time_id, & ! dimension identifier |
---|
| 751 | i_reftime_id, i_leadtime_id, & ! dimension identifier |
---|
| 752 | i_time_bnd_id, i_dim_id, & ! dimension identifier |
---|
| 753 | i_var_exist, i_pos, ii ! test and temporary variable |
---|
| 754 | INTEGER, DIMENSION(1) :: i_time_bnd ! dimensions of the variable |
---|
| 755 | INTEGER, DIMENSION(2) :: i_dimxy, i_len ! dimensions of the variable |
---|
| 756 | INTEGER, DIMENSION(3) :: & |
---|
| 757 | i_tab_start, i_tab_count, i_dim ! netcdf information |
---|
| 758 | INTEGER, DIMENSION(:), ALLOCATABLE :: & |
---|
| 759 | i_time ! time |
---|
| 760 | REAL :: & |
---|
| 761 | z_min, z_max, z_min_old, z_max_old ! Minima and maxima of variable |
---|
| 762 | !!---------------------------------------------------------------------- |
---|
| 763 | |
---|
| 764 | ! Read dimensions and compute min and max |
---|
| 765 | ! --------------------------------------- |
---|
| 766 | i_dimxy = SHAPE( p_var) |
---|
| 767 | i_tab_start(1) = 1 |
---|
| 768 | i_tab_count(1) = i_dimxy(1) |
---|
| 769 | i_tab_start(2) = 1 |
---|
| 770 | i_tab_count(2) = i_dimxy(2) |
---|
| 771 | i_tab_count(3) = 1 |
---|
| 772 | |
---|
| 773 | IF ( PRESENT(p_missing) ) THEN |
---|
| 774 | z_min = MINVAL(p_var, mask = p_var .NE. p_missing ) |
---|
| 775 | z_max = MAXVAL(p_var, mask = p_var .NE. p_missing ) |
---|
| 776 | ELSE |
---|
| 777 | z_min = MINVAL(p_var ) |
---|
| 778 | z_max = MAXVAL(p_var ) |
---|
| 779 | ENDIF |
---|
| 780 | |
---|
| 781 | ! Define the name of the variable |
---|
| 782 | ! ------------------------------- |
---|
| 783 | cl_var = "var" |
---|
| 784 | IF ( PRESENT(cd_var) ) cl_var = cd_var |
---|
| 785 | IF ( PRESENT(k_code) ) CALL get_var_info( k_code, cl_var ) |
---|
| 786 | |
---|
| 787 | ! |
---|
| 788 | ! Open or create file |
---|
| 789 | ! ------------------- |
---|
| 790 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 791 | IF ( .NOT. llexist ) THEN |
---|
| 792 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 793 | CALL create_map ( cd_filename, i_dimxy, cd_descr=cd_descr ) |
---|
| 794 | ELSE |
---|
| 795 | CALL create_map ( cd_filename, i_dimxy ) |
---|
| 796 | ENDIF |
---|
| 797 | ENDIF |
---|
| 798 | |
---|
| 799 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 800 | & __LINE__,__MYFILE__) |
---|
| 801 | |
---|
| 802 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'time', i_time_id ) ,& |
---|
| 803 | & __LINE__,__MYFILE__) |
---|
| 804 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'x', i_dim_x_id ) ,& |
---|
| 805 | & __LINE__,__MYFILE__) |
---|
| 806 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'y', i_dim_y_id ) ,& |
---|
| 807 | & __LINE__,__MYFILE__) |
---|
| 808 | i_dim(1) = i_dim_x_id |
---|
| 809 | i_dim(2) = i_dim_y_id |
---|
| 810 | i_dim(3) = i_time_id |
---|
| 811 | |
---|
| 812 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(1), len=i_len(1) ),__LINE__,__MYFILE__ ) |
---|
| 813 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(2), len=i_len(2) ) ,& |
---|
| 814 | & __LINE__,__MYFILE__) |
---|
| 815 | |
---|
| 816 | IF ( (i_len(1) .NE. i_dimxy(1)) .OR. (i_len(2) .NE. i_dimxy(2)) ) THEN |
---|
| 817 | WRITE(*,*)'filename = ',cd_filename |
---|
| 818 | WRITE(*,*)'variable = ',cl_var |
---|
| 819 | WRITE(*,*)'shape of array = ',i_dimxy |
---|
| 820 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 821 | WRITE(*,*)'Dimensions are different' |
---|
| 822 | WRITE(*,*)'CALL abort' |
---|
| 823 | CALL abort |
---|
| 824 | ENDIF |
---|
| 825 | |
---|
| 826 | ! Define variable or find it |
---|
| 827 | ! -------------------------- |
---|
| 828 | i_var_exist = nf90_inq_varid( i_file_id, cl_var, i_var_id ) |
---|
| 829 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 830 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 831 | & __LINE__,__MYFILE__) |
---|
| 832 | CALL nchdlerr( nf90_def_var( i_file_id, cl_var, nf90_real, i_dim, i_var_id ) ,& |
---|
| 833 | & __LINE__,__MYFILE__) |
---|
| 834 | IF ( PRESENT(k_code) ) CALL put_att( i_file_id, i_var_id, k_code ) |
---|
| 835 | IF ( PRESENT(p_missing) ) & |
---|
| 836 | & CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', p_missing ) ,& |
---|
| 837 | & __LINE__,__MYFILE__) |
---|
| 838 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_min ) ,& |
---|
| 839 | & __LINE__,__MYFILE__) |
---|
| 840 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_max ) ,& |
---|
| 841 | & __LINE__,__MYFILE__) |
---|
| 842 | i_var_exist = nf90_inq_varid( i_file_id, 'time', i_time_id ) |
---|
| 843 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 844 | CALL nchdlerr( nf90_def_var( i_file_id, 'time', nf90_int, i_dim(3), i_time_id ) ,& |
---|
| 845 | & __LINE__,__MYFILE__) |
---|
| 846 | ENDIF |
---|
| 847 | IF ( PRESENT(reftime) ) THEN |
---|
| 848 | i_var_exist = nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) |
---|
| 849 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 850 | CALL nchdlerr( nf90_def_var( i_file_id, 'reftime', nf90_real, i_dim(3), i_reftime_id ) ,& |
---|
| 851 | & __LINE__,__MYFILE__) |
---|
| 852 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'units', 'days since 1950-01-01 00:00:00' ) ,& |
---|
| 853 | & __LINE__,__MYFILE__) |
---|
| 854 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'standard_name', 'forecast_reference_time' ) ,& |
---|
| 855 | & __LINE__,__MYFILE__) |
---|
| 856 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'long_name', 'forecast reference time' ) ,& |
---|
| 857 | & __LINE__,__MYFILE__) |
---|
| 858 | ENDIF |
---|
| 859 | ENDIF |
---|
| 860 | IF ( PRESENT(leadtime) ) THEN |
---|
| 861 | i_var_exist = nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) |
---|
| 862 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 863 | CALL nchdlerr( nf90_def_var( i_file_id, 'leadtime', nf90_int, i_dim(3), i_leadtime_id ) ,& |
---|
| 864 | & __LINE__,__MYFILE__) |
---|
| 865 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'units', 'days' ) ,& |
---|
| 866 | & __LINE__,__MYFILE__) |
---|
| 867 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'standard_name', 'forecast_period' ) ,& |
---|
| 868 | & __LINE__,__MYFILE__) |
---|
| 869 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'long_name', & |
---|
| 870 | & 'Time elapsed since the start of the forecast' ) ,& |
---|
| 871 | & __LINE__,__MYFILE__) |
---|
| 872 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'bounds', 'time_bnd' ) ,& |
---|
| 873 | & __LINE__,__MYFILE__) |
---|
| 874 | ENDIF |
---|
| 875 | ENDIF |
---|
| 876 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 877 | i_var_exist = nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) |
---|
| 878 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 879 | i_time_bnd=SHAPE(time_bnd) |
---|
| 880 | CALL nchdlerr( nf90_def_dim( i_file_id, 'time_bnd', i_time_bnd(1) , i_dim_id ) ,& |
---|
| 881 | & __LINE__,__MYFILE__) |
---|
| 882 | CALL nchdlerr( nf90_def_var( i_file_id, 'time_bnd', nf90_int, (/i_dim_id, i_dim(3)/), i_time_bnd_id ) ,& |
---|
| 883 | & __LINE__,__MYFILE__) |
---|
| 884 | CALL nchdlerr( nf90_put_att( i_file_id, i_time_bnd_id, 'units', 'days' ) ,& |
---|
| 885 | & __LINE__,__MYFILE__) |
---|
| 886 | ENDIF |
---|
| 887 | ENDIF |
---|
| 888 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 889 | & __LINE__,__MYFILE__) |
---|
| 890 | i_tab_start(3) = 1 |
---|
| 891 | i_pos = 1 |
---|
| 892 | ELSE |
---|
| 893 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_min', z_min_old ) ,& |
---|
| 894 | & __LINE__,__MYFILE__) |
---|
| 895 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_max', z_max_old ) ,& |
---|
| 896 | & __LINE__,__MYFILE__) |
---|
| 897 | z_min = MIN( z_min, z_min_old ) |
---|
| 898 | z_max = MAX( z_max, z_max_old ) |
---|
| 899 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 900 | & __LINE__,__MYFILE__) |
---|
| 901 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_min ) ,& |
---|
| 902 | & __LINE__,__MYFILE__) |
---|
| 903 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_max ) ,& |
---|
| 904 | & __LINE__,__MYFILE__) |
---|
| 905 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 906 | & __LINE__,__MYFILE__) |
---|
| 907 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_time_id, len=i_pos ) ,& |
---|
| 908 | & __LINE__,__MYFILE__) |
---|
| 909 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time', i_time_id ) ,& |
---|
| 910 | & __LINE__,__MYFILE__) |
---|
| 911 | IF ( PRESENT(reftime) ) THEN |
---|
| 912 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) ,& |
---|
| 913 | & __LINE__,__MYFILE__) |
---|
| 914 | ENDIF |
---|
| 915 | IF ( PRESENT(leadtime) ) THEN |
---|
| 916 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) ,& |
---|
| 917 | & __LINE__,__MYFILE__) |
---|
| 918 | ENDIF |
---|
| 919 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 920 | i_time_bnd=SHAPE(time_bnd) |
---|
| 921 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) ,& |
---|
| 922 | & __LINE__,__MYFILE__) |
---|
| 923 | ENDIF |
---|
| 924 | ALLOCATE( i_time(i_pos) ) |
---|
| 925 | CALL nchdlerr( nf90_get_var( i_file_id, i_time_id, i_time ) ,& |
---|
| 926 | & __LINE__,__MYFILE__) |
---|
| 927 | IF ( PRESENT(k_time) ) THEN |
---|
| 928 | DO ii = 1, i_pos |
---|
| 929 | IF ( k_time .EQ. i_time(ii) ) THEN |
---|
| 930 | i_pos = ii - 1 |
---|
| 931 | EXIT |
---|
| 932 | ENDIF |
---|
| 933 | ENDDO |
---|
| 934 | ENDIF |
---|
| 935 | DEALLOCATE( i_time ) |
---|
| 936 | i_pos = i_pos + 1 |
---|
| 937 | i_tab_start(3) = i_pos |
---|
| 938 | ENDIF |
---|
| 939 | |
---|
| 940 | ! Put variable(s) |
---|
| 941 | ! -------------- |
---|
| 942 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, p_var, & |
---|
| 943 | & start=i_tab_start, count=i_tab_count ) ,& |
---|
| 944 | & __LINE__,__MYFILE__) |
---|
| 945 | IF ( PRESENT(k_time) ) THEN |
---|
| 946 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/k_time/), & |
---|
| 947 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 948 | & __LINE__,__MYFILE__) |
---|
| 949 | ELSE |
---|
| 950 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/i_pos/), & |
---|
| 951 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 952 | & __LINE__,__MYFILE__) |
---|
| 953 | ENDIF |
---|
| 954 | IF ( PRESENT(reftime) ) THEN |
---|
| 955 | CALL nchdlerr( nf90_put_var( i_file_id, i_reftime_id, (/reftime/), & |
---|
| 956 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 957 | & __LINE__,__MYFILE__) |
---|
| 958 | ENDIF |
---|
| 959 | IF ( PRESENT(leadtime) ) THEN |
---|
| 960 | CALL nchdlerr( nf90_put_var( i_file_id, i_leadtime_id, (/leadtime/), & |
---|
| 961 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 962 | & __LINE__,__MYFILE__) |
---|
| 963 | ENDIF |
---|
| 964 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 965 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_bnd_id, time_bnd, & |
---|
| 966 | start=(/1,i_tab_start(3)/), count=(/i_time_bnd(1),i_tab_count(3)/) ) ,& |
---|
| 967 | & __LINE__,__MYFILE__) |
---|
| 968 | ENDIF |
---|
| 969 | |
---|
| 970 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 971 | & __LINE__,__MYFILE__) |
---|
| 972 | |
---|
| 973 | END SUBROUTINE put_map_2d_r |
---|
| 974 | |
---|
| 975 | SUBROUTINE put_map_2d_d ( cd_filename, dd_var, dd_missing, cd_var, k_code, k_time, reftime, leadtime, time_bnd, cd_descr ) |
---|
| 976 | !!---------------------------------------------------------------------- |
---|
| 977 | !! *** ROUTINE put_map_2d_d *** |
---|
| 978 | !! |
---|
| 979 | !! ** Purpose : write 2d map of reals in a netcdf file |
---|
| 980 | !! |
---|
| 981 | !! ** Method : use netcdf fortran library |
---|
| 982 | !! |
---|
| 983 | !! ** Action : - get variable informations |
---|
| 984 | !! - (re)define variable |
---|
| 985 | !! - put variable in netcdf file |
---|
| 986 | !! |
---|
| 987 | !! Reference : |
---|
| 988 | !! |
---|
| 989 | !! History : |
---|
| 990 | !! 06-05 (N. Daget) original code |
---|
| 991 | !!---------------------------------------------------------------------- |
---|
| 992 | !! * Modules used |
---|
| 993 | |
---|
| 994 | !! * Library used |
---|
| 995 | |
---|
| 996 | |
---|
| 997 | !! * arguments |
---|
| 998 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 999 | cd_filename ! filename |
---|
| 1000 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 1001 | cd_var ! variable name |
---|
| 1002 | INTEGER, OPTIONAL, INTENT(in) :: & |
---|
| 1003 | k_code, & ! CF code |
---|
| 1004 | k_time, & ! time of the variable |
---|
| 1005 | leadtime ! leadtime of the variable |
---|
| 1006 | INTEGER, DIMENSION(:), OPTIONAL, INTENT(in) :: & |
---|
| 1007 | time_bnd ! time_bnd |
---|
| 1008 | REAL(KIND=dp), OPTIONAL, INTENT(in) :: & |
---|
| 1009 | dd_missing, & ! missing value of the variable |
---|
| 1010 | reftime ! reftime of the variable |
---|
| 1011 | REAL(KIND=dp), DIMENSION(:,:), INTENT(in) :: & |
---|
| 1012 | dd_var ! variable to write in netcdf file |
---|
| 1013 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 1014 | cd_descr ! description of file contents |
---|
| 1015 | |
---|
| 1016 | !! * local declarations |
---|
| 1017 | LOGICAL :: llexist ! test |
---|
| 1018 | CHARACTER(len=80) :: cl_var ! new variable name |
---|
| 1019 | INTEGER :: & |
---|
| 1020 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 1021 | i_dim_x_id, i_dim_y_id, i_time_id, & ! dimension identifier |
---|
| 1022 | i_reftime_id, i_leadtime_id, & ! dimension identifier |
---|
| 1023 | i_time_bnd_id, i_dim_id, & ! dimension identifier |
---|
| 1024 | i_var_exist, i_pos, ii ! test and temporary variable |
---|
| 1025 | INTEGER, DIMENSION(1) :: i_time_bnd ! dimensions of the variable |
---|
| 1026 | INTEGER, DIMENSION(2) :: i_dimxy, i_len ! dimensions of the variable |
---|
| 1027 | INTEGER, DIMENSION(3) :: & |
---|
| 1028 | i_tab_start, i_tab_count, i_dim ! netcdf information |
---|
| 1029 | INTEGER, DIMENSION(:), ALLOCATABLE :: & |
---|
| 1030 | i_time ! time |
---|
| 1031 | REAL(KIND=dp) :: & |
---|
| 1032 | dl_min, dl_max, dl_min_old, dl_max_old ! Minima and maxima of variable |
---|
| 1033 | !!---------------------------------------------------------------------- |
---|
| 1034 | |
---|
| 1035 | ! Read dimensions and compute min and max |
---|
| 1036 | ! --------------------------------------- |
---|
| 1037 | i_dimxy = SHAPE( dd_var) |
---|
| 1038 | i_tab_start(1) = 1 |
---|
| 1039 | i_tab_count(1) = i_dimxy(1) |
---|
| 1040 | i_tab_start(2) = 1 |
---|
| 1041 | i_tab_count(2) = i_dimxy(2) |
---|
| 1042 | i_tab_count(3) = 1 |
---|
| 1043 | |
---|
| 1044 | IF ( PRESENT(dd_missing) ) THEN |
---|
| 1045 | dl_min = MINVAL( dd_var, mask = dd_var .NE. dd_missing ) |
---|
| 1046 | dl_max = MAXVAL( dd_var, mask = dd_var .NE. dd_missing ) |
---|
| 1047 | ELSE |
---|
| 1048 | dl_min = MINVAL( dd_var ) |
---|
| 1049 | dl_max = MAXVAL( dd_var ) |
---|
| 1050 | ENDIF |
---|
| 1051 | |
---|
| 1052 | ! Define the name of the variable |
---|
| 1053 | ! ------------------------------- |
---|
| 1054 | cl_var = "var" |
---|
| 1055 | IF ( PRESENT(cd_var) ) cl_var = cd_var |
---|
| 1056 | IF ( PRESENT(k_code) ) CALL get_var_info( k_code, cl_var ) |
---|
| 1057 | |
---|
| 1058 | ! |
---|
| 1059 | ! Open or create file |
---|
| 1060 | ! ------------------- |
---|
| 1061 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 1062 | IF ( .NOT. llexist ) THEN |
---|
| 1063 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 1064 | CALL create_map ( cd_filename, i_dimxy, cd_descr=cd_descr ) |
---|
| 1065 | ELSE |
---|
| 1066 | CALL create_map ( cd_filename, i_dimxy ) |
---|
| 1067 | ENDIF |
---|
| 1068 | ENDIF |
---|
| 1069 | |
---|
| 1070 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 1071 | & __LINE__,__MYFILE__) |
---|
| 1072 | |
---|
| 1073 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'time', i_time_id ) ,& |
---|
| 1074 | & __LINE__,__MYFILE__) |
---|
| 1075 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'x', i_dim_x_id ) ,& |
---|
| 1076 | & __LINE__,__MYFILE__) |
---|
| 1077 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'y', i_dim_y_id ) ,& |
---|
| 1078 | & __LINE__,__MYFILE__) |
---|
| 1079 | i_dim(1) = i_dim_x_id |
---|
| 1080 | i_dim(2) = i_dim_y_id |
---|
| 1081 | i_dim(3) = i_time_id |
---|
| 1082 | |
---|
| 1083 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(1), len=i_len(1) ) ,& |
---|
| 1084 | & __LINE__,__MYFILE__) |
---|
| 1085 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(2), len=i_len(2) ) ,& |
---|
| 1086 | & __LINE__,__MYFILE__) |
---|
| 1087 | |
---|
| 1088 | IF ( (i_len(1) .NE. i_dimxy(1)) .OR. (i_len(2) .NE. i_dimxy(2)) ) THEN |
---|
| 1089 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1090 | WRITE(*,*)'variable = ',cl_var |
---|
| 1091 | WRITE(*,*)'shape of array = ',i_dimxy |
---|
| 1092 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 1093 | WRITE(*,*)'Dimensions are different' |
---|
| 1094 | WRITE(*,*)'CALL abort' |
---|
| 1095 | CALL abort |
---|
| 1096 | ENDIF |
---|
| 1097 | |
---|
| 1098 | ! Define variable or find it |
---|
| 1099 | ! -------------------------- |
---|
| 1100 | i_var_exist = nf90_inq_varid( i_file_id, cl_var, i_var_id ) |
---|
| 1101 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1102 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 1103 | & __LINE__,__MYFILE__) |
---|
| 1104 | CALL nchdlerr( nf90_def_var( i_file_id, cl_var, nf90_double, i_dim, i_var_id ) ,& |
---|
| 1105 | & __LINE__,__MYFILE__) |
---|
| 1106 | IF ( PRESENT(k_code) ) CALL put_att( i_file_id, i_var_id, k_code ) |
---|
| 1107 | IF ( PRESENT(dd_missing) ) & |
---|
| 1108 | & CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', dd_missing ),__LINE__,__MYFILE__ ) |
---|
| 1109 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_min ) ,& |
---|
| 1110 | & __LINE__,__MYFILE__) |
---|
| 1111 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_max ) ,& |
---|
| 1112 | & __LINE__,__MYFILE__) |
---|
| 1113 | i_var_exist = nf90_inq_varid( i_file_id, 'time', i_time_id ) |
---|
| 1114 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1115 | CALL nchdlerr( nf90_def_var( i_file_id, 'time', nf90_int, i_dim(3), i_time_id ) ,& |
---|
| 1116 | & __LINE__,__MYFILE__) |
---|
| 1117 | ENDIF |
---|
| 1118 | IF ( PRESENT(reftime) ) THEN |
---|
| 1119 | i_var_exist = nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) |
---|
| 1120 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1121 | CALL nchdlerr( nf90_def_var( i_file_id, 'reftime', nf90_double, i_dim(3), i_reftime_id ) ,& |
---|
| 1122 | & __LINE__,__MYFILE__) |
---|
| 1123 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'units', 'days since 1950-01-01 00:00:00' ) ,& |
---|
| 1124 | & __LINE__,__MYFILE__) |
---|
| 1125 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'standard_name', 'forecast_reference_time' ) ,& |
---|
| 1126 | & __LINE__,__MYFILE__) |
---|
| 1127 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'long_name', 'forecast reference time' ) ,& |
---|
| 1128 | & __LINE__,__MYFILE__) |
---|
| 1129 | ENDIF |
---|
| 1130 | ENDIF |
---|
| 1131 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1132 | i_var_exist = nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) |
---|
| 1133 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1134 | CALL nchdlerr( nf90_def_var( i_file_id, 'leadtime', nf90_int, i_dim(3), i_leadtime_id ),__LINE__,__MYFILE__ ) |
---|
| 1135 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'units', 'days' ) ,& |
---|
| 1136 | & __LINE__,__MYFILE__) |
---|
| 1137 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'standard_name', 'forecast_period' ) ,& |
---|
| 1138 | & __LINE__,__MYFILE__) |
---|
| 1139 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'long_name', & |
---|
| 1140 | & 'Time elapsed since the start of the forecast' ) ,& |
---|
| 1141 | & __LINE__,__MYFILE__) |
---|
| 1142 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'bounds', 'time_bnd' ) ,& |
---|
| 1143 | & __LINE__,__MYFILE__) |
---|
| 1144 | ENDIF |
---|
| 1145 | ENDIF |
---|
| 1146 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1147 | i_var_exist = nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) |
---|
| 1148 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1149 | i_time_bnd=SHAPE(time_bnd) |
---|
| 1150 | CALL nchdlerr( nf90_def_dim( i_file_id, 'time_bnd', i_time_bnd(1) , i_dim_id ) ,& |
---|
| 1151 | & __LINE__,__MYFILE__) |
---|
| 1152 | CALL nchdlerr( nf90_def_var( i_file_id, 'time_bnd', nf90_int, (/i_dim_id, i_dim(3)/), i_time_bnd_id ) ,& |
---|
| 1153 | & __LINE__,__MYFILE__) |
---|
| 1154 | CALL nchdlerr( nf90_put_att( i_file_id, i_time_bnd_id, 'units', 'days' ) ,& |
---|
| 1155 | & __LINE__,__MYFILE__) |
---|
| 1156 | ENDIF |
---|
| 1157 | ENDIF |
---|
| 1158 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 1159 | & __LINE__,__MYFILE__) |
---|
| 1160 | i_tab_start(3) = 1 |
---|
| 1161 | i_pos = 1 |
---|
| 1162 | ELSE |
---|
| 1163 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_min', dl_min_old ) ,& |
---|
| 1164 | & __LINE__,__MYFILE__) |
---|
| 1165 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_max', dl_max_old ) ,& |
---|
| 1166 | & __LINE__,__MYFILE__) |
---|
| 1167 | dl_min = MIN( dl_min, dl_min_old ) |
---|
| 1168 | dl_max = MAX( dl_max, dl_max_old ) |
---|
| 1169 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 1170 | & __LINE__,__MYFILE__) |
---|
| 1171 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_min ) ,& |
---|
| 1172 | & __LINE__,__MYFILE__) |
---|
| 1173 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_max ) ,& |
---|
| 1174 | & __LINE__,__MYFILE__) |
---|
| 1175 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 1176 | & __LINE__,__MYFILE__) |
---|
| 1177 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_time_id, len=i_pos ) ,& |
---|
| 1178 | & __LINE__,__MYFILE__) |
---|
| 1179 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time', i_time_id ) ,& |
---|
| 1180 | & __LINE__,__MYFILE__) |
---|
| 1181 | IF ( PRESENT(reftime) ) THEN |
---|
| 1182 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) ,& |
---|
| 1183 | & __LINE__,__MYFILE__) |
---|
| 1184 | ENDIF |
---|
| 1185 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1186 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) ,& |
---|
| 1187 | & __LINE__,__MYFILE__) |
---|
| 1188 | ENDIF |
---|
| 1189 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1190 | i_time_bnd=SHAPE(time_bnd) |
---|
| 1191 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) ,& |
---|
| 1192 | & __LINE__,__MYFILE__) |
---|
| 1193 | ENDIF |
---|
| 1194 | ALLOCATE( i_time(i_pos) ) |
---|
| 1195 | CALL nchdlerr( nf90_get_var( i_file_id, i_time_id, i_time ) ,& |
---|
| 1196 | & __LINE__,__MYFILE__) |
---|
| 1197 | DO ii = 1, i_pos |
---|
| 1198 | IF ( k_time .EQ. i_time(ii) ) THEN |
---|
| 1199 | i_pos = ii - 1 |
---|
| 1200 | EXIT |
---|
| 1201 | ENDIF |
---|
| 1202 | ENDDO |
---|
| 1203 | DEALLOCATE( i_time ) |
---|
| 1204 | i_pos = i_pos + 1 |
---|
| 1205 | i_tab_start(3) = i_pos |
---|
| 1206 | ENDIF |
---|
| 1207 | |
---|
| 1208 | ! Put variable(s) |
---|
| 1209 | ! -------------- |
---|
| 1210 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, dd_var, & |
---|
| 1211 | & start=i_tab_start, count=i_tab_count ) ,& |
---|
| 1212 | & __LINE__,__MYFILE__) |
---|
| 1213 | IF ( PRESENT(k_time) ) THEN |
---|
| 1214 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/k_time/), & |
---|
| 1215 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 1216 | & __LINE__,__MYFILE__) |
---|
| 1217 | ELSE |
---|
| 1218 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/i_pos/), & |
---|
| 1219 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 1220 | & __LINE__,__MYFILE__) |
---|
| 1221 | ENDIF |
---|
| 1222 | IF ( PRESENT(reftime) ) THEN |
---|
| 1223 | CALL nchdlerr( nf90_put_var( i_file_id, i_reftime_id, (/reftime/), & |
---|
| 1224 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 1225 | & __LINE__,__MYFILE__) |
---|
| 1226 | ENDIF |
---|
| 1227 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1228 | CALL nchdlerr( nf90_put_var( i_file_id, i_leadtime_id, (/leadtime/), & |
---|
| 1229 | & start=(/i_tab_start(3)/), count=(/i_tab_count(3)/) ) ,& |
---|
| 1230 | & __LINE__,__MYFILE__) |
---|
| 1231 | ENDIF |
---|
| 1232 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1233 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_bnd_id, time_bnd, & |
---|
| 1234 | & start=(/1,i_tab_start(3)/), count=(/i_time_bnd(1),i_tab_count(3)/) ) ,& |
---|
| 1235 | & __LINE__,__MYFILE__) |
---|
| 1236 | ENDIF |
---|
| 1237 | |
---|
| 1238 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 1239 | & __LINE__,__MYFILE__) |
---|
| 1240 | |
---|
| 1241 | END SUBROUTINE put_map_2d_d |
---|
| 1242 | |
---|
| 1243 | SUBROUTINE put_map_3d_r ( cd_filename, p_var, p_missing, cd_var, k_code, k_time, reftime, leadtime, time_bnd, cd_descr ) |
---|
| 1244 | !!---------------------------------------------------------------------- |
---|
| 1245 | !! *** ROUTINE put_map_3d_r *** |
---|
| 1246 | !! |
---|
| 1247 | !! ** Purpose : write 3d map of reals in a netcdf file |
---|
| 1248 | !! |
---|
| 1249 | !! ** Method : use netcdf fortran library |
---|
| 1250 | !! |
---|
| 1251 | !! ** Action : - get variable informations |
---|
| 1252 | !! - (re)define variable |
---|
| 1253 | !! - put variable in netcdf file |
---|
| 1254 | !! |
---|
| 1255 | !! Reference : |
---|
| 1256 | !! |
---|
| 1257 | !! History : |
---|
| 1258 | !! 06-05 (N. Daget) original code |
---|
| 1259 | !!---------------------------------------------------------------------- |
---|
| 1260 | !! * Modules used |
---|
| 1261 | |
---|
| 1262 | !! * Library used |
---|
| 1263 | |
---|
| 1264 | !! * arguments |
---|
| 1265 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 1266 | cd_filename ! filename |
---|
| 1267 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 1268 | cd_var ! variable name |
---|
| 1269 | INTEGER, OPTIONAL, INTENT(in) :: & |
---|
| 1270 | k_code, & ! CF code |
---|
| 1271 | k_time, & ! time of the variable |
---|
| 1272 | leadtime ! leadtime of the variable |
---|
| 1273 | INTEGER, DIMENSION(:), OPTIONAL, INTENT(in) :: & |
---|
| 1274 | time_bnd ! time_bnd |
---|
| 1275 | REAL(KIND=sp), OPTIONAL, INTENT(in) :: & |
---|
| 1276 | p_missing, & ! missing value of the variable |
---|
| 1277 | reftime ! reftime of the variable |
---|
| 1278 | REAL(KIND=sp), DIMENSION(:,:,:), INTENT(in) :: & |
---|
| 1279 | p_var ! variable to write in netcdf file |
---|
| 1280 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 1281 | cd_descr ! description of file contents |
---|
| 1282 | |
---|
| 1283 | !! * local declarations |
---|
| 1284 | LOGICAL :: llexist ! test |
---|
| 1285 | CHARACTER(len=80) :: cl_var ! new variable name |
---|
| 1286 | INTEGER :: & |
---|
| 1287 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 1288 | i_dim_x_id, i_dim_y_id, & ! dimension identifiers |
---|
| 1289 | i_dim_z_id, i_time_id, & ! dimension identifiers |
---|
| 1290 | i_reftime_id, i_leadtime_id, & ! dimension identifier |
---|
| 1291 | i_time_bnd_id, i_dim_id, & ! dimension identifier |
---|
| 1292 | i_var_exist, i_pos, ii ! test and temporary variable |
---|
| 1293 | INTEGER, DIMENSION(1) :: i_time_bnd ! dimensions of the variable |
---|
| 1294 | INTEGER, DIMENSION(3) :: i_dimxy, i_len ! dimensions of the variable |
---|
| 1295 | INTEGER, DIMENSION(4) :: & |
---|
| 1296 | i_tab_start, i_tab_count, i_dim ! netcdf information |
---|
| 1297 | INTEGER, DIMENSION(:), ALLOCATABLE :: & |
---|
| 1298 | i_time ! time |
---|
| 1299 | REAL :: & |
---|
| 1300 | z_min, z_max, z_min_old, z_max_old ! Minima and maxima of variable |
---|
| 1301 | !!---------------------------------------------------------------------- |
---|
| 1302 | |
---|
| 1303 | ! Read dimensions and compute min and max |
---|
| 1304 | ! --------------------------------------- |
---|
| 1305 | i_dimxy = SHAPE( p_var) |
---|
| 1306 | i_tab_start(1) = 1 |
---|
| 1307 | i_tab_count(1) = i_dimxy(1) |
---|
| 1308 | i_tab_start(2) = 1 |
---|
| 1309 | i_tab_count(2) = i_dimxy(2) |
---|
| 1310 | i_tab_start(3) = 1 |
---|
| 1311 | i_tab_count(3) = i_dimxy(3) |
---|
| 1312 | i_tab_count(4) = 1 |
---|
| 1313 | |
---|
| 1314 | IF ( PRESENT(p_missing) ) THEN |
---|
| 1315 | z_min = MINVAL(p_var, mask = p_var .NE. p_missing ) |
---|
| 1316 | z_max = MAXVAL(p_var, mask = p_var .NE. p_missing ) |
---|
| 1317 | ELSE |
---|
| 1318 | z_min = MINVAL(p_var ) |
---|
| 1319 | z_max = MAXVAL(p_var ) |
---|
| 1320 | ENDIF |
---|
| 1321 | |
---|
| 1322 | ! Define the name of the variable |
---|
| 1323 | ! ------------------------------- |
---|
| 1324 | cl_var = "var" |
---|
| 1325 | IF ( PRESENT(cd_var) ) cl_var = cd_var |
---|
| 1326 | IF ( PRESENT(k_code) ) CALL get_var_info( k_code, cl_var ) |
---|
| 1327 | |
---|
| 1328 | ! |
---|
| 1329 | ! Open or create file |
---|
| 1330 | ! ------------------- |
---|
| 1331 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 1332 | IF ( .NOT. llexist ) THEN |
---|
| 1333 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 1334 | CALL create_map ( cd_filename, i_dimxy, cd_descr=cd_descr ) |
---|
| 1335 | ELSE |
---|
| 1336 | CALL create_map ( cd_filename, i_dimxy ) |
---|
| 1337 | ENDIF |
---|
| 1338 | ENDIF |
---|
| 1339 | |
---|
| 1340 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 1341 | & __LINE__,__MYFILE__) |
---|
| 1342 | |
---|
| 1343 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'time', i_time_id ) ,& |
---|
| 1344 | & __LINE__,__MYFILE__) |
---|
| 1345 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'x', i_dim_x_id ) ,& |
---|
| 1346 | & __LINE__,__MYFILE__) |
---|
| 1347 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'y', i_dim_y_id ) ,& |
---|
| 1348 | & __LINE__,__MYFILE__) |
---|
| 1349 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'z', i_dim_z_id ) ,& |
---|
| 1350 | & __LINE__,__MYFILE__) |
---|
| 1351 | i_dim(1) = i_dim_x_id |
---|
| 1352 | i_dim(2) = i_dim_y_id |
---|
| 1353 | i_dim(3) = i_dim_z_id |
---|
| 1354 | i_dim(4) = i_time_id |
---|
| 1355 | |
---|
| 1356 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(1), len=i_len(1) ) ,& |
---|
| 1357 | & __LINE__,__MYFILE__) |
---|
| 1358 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(2), len=i_len(2) ) ,& |
---|
| 1359 | & __LINE__,__MYFILE__) |
---|
| 1360 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(3), len=i_len(3) ) ,& |
---|
| 1361 | & __LINE__,__MYFILE__) |
---|
| 1362 | |
---|
| 1363 | IF ( (i_len(1) .NE. i_dimxy(1)) .OR. (i_len(2) .NE. i_dimxy(2)) .OR. & |
---|
| 1364 | (i_len(3) .NE. i_dimxy(3)) ) THEN |
---|
| 1365 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1366 | WRITE(*,*)'variable = ',cl_var |
---|
| 1367 | WRITE(*,*)'shape of array = ',i_dimxy |
---|
| 1368 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 1369 | WRITE(*,*)'Dimensions are different' |
---|
| 1370 | WRITE(*,*)'CALL abort' |
---|
| 1371 | CALL abort |
---|
| 1372 | ENDIF |
---|
| 1373 | |
---|
| 1374 | ! Define variable or find it |
---|
| 1375 | ! -------------------------- |
---|
| 1376 | i_var_exist = nf90_inq_varid( i_file_id, cl_var, i_var_id ) |
---|
| 1377 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1378 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 1379 | & __LINE__,__MYFILE__) |
---|
| 1380 | CALL nchdlerr( nf90_def_var( i_file_id, cl_var, nf90_real, i_dim, i_var_id ) ,& |
---|
| 1381 | & __LINE__,__MYFILE__) |
---|
| 1382 | IF ( PRESENT(k_code) ) CALL put_att( i_file_id, i_var_id, k_code ) |
---|
| 1383 | IF ( PRESENT(p_missing) ) & |
---|
| 1384 | & CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', p_missing ) ,& |
---|
| 1385 | & __LINE__,__MYFILE__) |
---|
| 1386 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_min ) ,& |
---|
| 1387 | & __LINE__,__MYFILE__) |
---|
| 1388 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_max ) ,& |
---|
| 1389 | & __LINE__,__MYFILE__) |
---|
| 1390 | i_var_exist = nf90_inq_varid( i_file_id, 'time', i_time_id ) |
---|
| 1391 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1392 | CALL nchdlerr( nf90_def_var( i_file_id, 'time', nf90_int, i_dim(4), i_time_id ) ,& |
---|
| 1393 | & __LINE__,__MYFILE__) |
---|
| 1394 | ENDIF |
---|
| 1395 | IF ( PRESENT(reftime) ) THEN |
---|
| 1396 | i_var_exist = nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) |
---|
| 1397 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1398 | CALL nchdlerr( nf90_def_var( i_file_id, 'reftime', nf90_real, i_dim(4), i_reftime_id ) ,& |
---|
| 1399 | & __LINE__,__MYFILE__) |
---|
| 1400 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'units', 'days since 1950-01-01 00:00:00' ) ,& |
---|
| 1401 | & __LINE__,__MYFILE__) |
---|
| 1402 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'standard_name', 'forecast_reference_time' ) ,& |
---|
| 1403 | & __LINE__,__MYFILE__) |
---|
| 1404 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'long_name', 'forecast reference time' ) ,& |
---|
| 1405 | & __LINE__,__MYFILE__) |
---|
| 1406 | ENDIF |
---|
| 1407 | ENDIF |
---|
| 1408 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1409 | i_var_exist = nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) |
---|
| 1410 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1411 | CALL nchdlerr( nf90_def_var( i_file_id, 'leadtime', nf90_int, i_dim(4), i_leadtime_id ),__LINE__,__MYFILE__ ) |
---|
| 1412 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'units', 'days' ) ,& |
---|
| 1413 | & __LINE__,__MYFILE__) |
---|
| 1414 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'standard_name', 'forecast_period' ) ,& |
---|
| 1415 | & __LINE__,__MYFILE__) |
---|
| 1416 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'long_name', & |
---|
| 1417 | & 'Time elapsed since the start of the forecast' ) ,& |
---|
| 1418 | & __LINE__,__MYFILE__) |
---|
| 1419 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'bounds', 'time_bnd' ) ,& |
---|
| 1420 | & __LINE__,__MYFILE__) |
---|
| 1421 | ENDIF |
---|
| 1422 | ENDIF |
---|
| 1423 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1424 | i_var_exist = nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) |
---|
| 1425 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1426 | i_time_bnd=SHAPE(time_bnd) |
---|
| 1427 | CALL nchdlerr( nf90_def_dim( i_file_id, 'time_bnd', i_time_bnd(1) , i_dim_id ) ,& |
---|
| 1428 | & __LINE__,__MYFILE__) |
---|
| 1429 | CALL nchdlerr( nf90_def_var( i_file_id, 'time_bnd', nf90_int, (/i_dim_id, i_dim(4)/), i_time_bnd_id ) ,& |
---|
| 1430 | & __LINE__,__MYFILE__) |
---|
| 1431 | CALL nchdlerr( nf90_put_att( i_file_id, i_time_bnd_id, 'units', 'days' ) ,& |
---|
| 1432 | & __LINE__,__MYFILE__) |
---|
| 1433 | ENDIF |
---|
| 1434 | ENDIF |
---|
| 1435 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 1436 | & __LINE__,__MYFILE__) |
---|
| 1437 | i_tab_start(4) = 1 |
---|
| 1438 | i_pos = 1 |
---|
| 1439 | ELSE |
---|
| 1440 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_min', z_min_old ) ,& |
---|
| 1441 | & __LINE__,__MYFILE__) |
---|
| 1442 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_max', z_max_old ) ,& |
---|
| 1443 | & __LINE__,__MYFILE__) |
---|
| 1444 | z_min = MIN( z_min, z_min_old ) |
---|
| 1445 | z_max = MAX( z_max, z_max_old ) |
---|
| 1446 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 1447 | & __LINE__,__MYFILE__) |
---|
| 1448 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_min ) ,& |
---|
| 1449 | & __LINE__,__MYFILE__) |
---|
| 1450 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_max ) ,& |
---|
| 1451 | & __LINE__,__MYFILE__) |
---|
| 1452 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 1453 | & __LINE__,__MYFILE__) |
---|
| 1454 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_time_id, len=i_pos ),__LINE__,__MYFILE__ ) |
---|
| 1455 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time', i_time_id ) ,& |
---|
| 1456 | & __LINE__,__MYFILE__) |
---|
| 1457 | IF ( PRESENT(reftime) ) THEN |
---|
| 1458 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) ,& |
---|
| 1459 | & __LINE__,__MYFILE__) |
---|
| 1460 | ENDIF |
---|
| 1461 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1462 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) ,& |
---|
| 1463 | & __LINE__,__MYFILE__) |
---|
| 1464 | ENDIF |
---|
| 1465 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1466 | i_time_bnd=SHAPE(time_bnd) |
---|
| 1467 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) ,& |
---|
| 1468 | & __LINE__,__MYFILE__) |
---|
| 1469 | ENDIF |
---|
| 1470 | ALLOCATE( i_time(i_pos) ) |
---|
| 1471 | CALL nchdlerr( nf90_get_var( i_file_id, i_time_id, i_time ) ,& |
---|
| 1472 | & __LINE__,__MYFILE__) |
---|
| 1473 | DO ii = 1, i_pos |
---|
| 1474 | IF ( k_time .EQ. i_time(ii) ) THEN |
---|
| 1475 | i_pos = ii - 1 |
---|
| 1476 | EXIT |
---|
| 1477 | ENDIF |
---|
| 1478 | ENDDO |
---|
| 1479 | DEALLOCATE( i_time ) |
---|
| 1480 | i_pos = i_pos + 1 |
---|
| 1481 | i_tab_start(4) = i_pos |
---|
| 1482 | ENDIF |
---|
| 1483 | |
---|
| 1484 | ! Put variable(s) |
---|
| 1485 | ! -------------- |
---|
| 1486 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, p_var, & |
---|
| 1487 | & start=i_tab_start, count=i_tab_count ) ,& |
---|
| 1488 | & __LINE__,__MYFILE__) |
---|
| 1489 | IF ( PRESENT(k_time) ) THEN |
---|
| 1490 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/k_time/), & |
---|
| 1491 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1492 | & __LINE__,__MYFILE__) |
---|
| 1493 | ELSE |
---|
| 1494 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/i_pos/), & |
---|
| 1495 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1496 | & __LINE__,__MYFILE__) |
---|
| 1497 | ENDIF |
---|
| 1498 | IF ( PRESENT(reftime) ) THEN |
---|
| 1499 | CALL nchdlerr( nf90_put_var( i_file_id, i_reftime_id, (/reftime/), & |
---|
| 1500 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1501 | & __LINE__,__MYFILE__) |
---|
| 1502 | ENDIF |
---|
| 1503 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1504 | CALL nchdlerr( nf90_put_var( i_file_id, i_leadtime_id, (/leadtime/), & |
---|
| 1505 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1506 | & __LINE__,__MYFILE__) |
---|
| 1507 | ENDIF |
---|
| 1508 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1509 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_bnd_id, time_bnd, & |
---|
| 1510 | start=(/1,i_tab_start(4)/), count=(/i_time_bnd(1),i_tab_count(4)/) ),__LINE__,__MYFILE__ ) |
---|
| 1511 | ENDIF |
---|
| 1512 | |
---|
| 1513 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 1514 | & __LINE__,__MYFILE__) |
---|
| 1515 | |
---|
| 1516 | END SUBROUTINE put_map_3d_r |
---|
| 1517 | |
---|
| 1518 | SUBROUTINE put_map_3d_d ( cd_filename, dd_var, dd_missing, cd_var, k_code, k_time, reftime, leadtime, time_bnd, cd_descr ) |
---|
| 1519 | !!---------------------------------------------------------------------- |
---|
| 1520 | !! *** ROUTINE put_map_3d_d *** |
---|
| 1521 | !! |
---|
| 1522 | !! ** Purpose : write 3d map of reals in a netcdf file |
---|
| 1523 | !! |
---|
| 1524 | !! ** Method : use netcdf fortran library |
---|
| 1525 | !! |
---|
| 1526 | !! ** Action : - get variable informations |
---|
| 1527 | !! - (re)define variable |
---|
| 1528 | !! - put variable in netcdf file |
---|
| 1529 | !! |
---|
| 1530 | !! Reference : |
---|
| 1531 | !! |
---|
| 1532 | !! History : |
---|
| 1533 | !! 06-05 (N. Daget) original code |
---|
| 1534 | !!---------------------------------------------------------------------- |
---|
| 1535 | !! * Modules used |
---|
| 1536 | |
---|
| 1537 | !! * Library used |
---|
| 1538 | |
---|
| 1539 | !! * arguments |
---|
| 1540 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 1541 | cd_filename ! filename |
---|
| 1542 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 1543 | cd_var ! variable name |
---|
| 1544 | INTEGER, OPTIONAL, INTENT(in) :: & |
---|
| 1545 | k_code, & ! CF code |
---|
| 1546 | k_time, & ! time of the variable |
---|
| 1547 | leadtime ! leadtime of the variable |
---|
| 1548 | INTEGER, DIMENSION(:), OPTIONAL, INTENT(in) :: & |
---|
| 1549 | time_bnd ! time_bnd |
---|
| 1550 | REAL(KIND=dp), OPTIONAL, INTENT(in) :: & |
---|
| 1551 | dd_missing, & ! missing value of the variable |
---|
| 1552 | reftime ! reftime of the variable |
---|
| 1553 | REAL(KIND=dp), DIMENSION(:,:,:), INTENT(in) :: & |
---|
| 1554 | dd_var ! variable to write in netcdf file |
---|
| 1555 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 1556 | cd_descr ! description of file contents |
---|
| 1557 | |
---|
| 1558 | !! * local declarations |
---|
| 1559 | LOGICAL :: llexist ! test |
---|
| 1560 | CHARACTER(len=80) :: cl_var ! new variable name |
---|
| 1561 | INTEGER :: & |
---|
| 1562 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 1563 | i_dim_x_id, i_dim_y_id, & ! dimension identifiers |
---|
| 1564 | i_dim_z_id, i_time_id, & ! dimension identifiers |
---|
| 1565 | i_reftime_id, i_leadtime_id, & ! dimension identifier |
---|
| 1566 | i_time_bnd_id, i_dim_id, & ! dimension identifier |
---|
| 1567 | i_var_exist, i_pos, ii ! test and temporary variable |
---|
| 1568 | INTEGER, DIMENSION(1) :: i_time_bnd ! dimensions of the variable |
---|
| 1569 | INTEGER, DIMENSION(3) :: i_dimxy, i_len ! dimensions of the variable |
---|
| 1570 | INTEGER, DIMENSION(4) :: & |
---|
| 1571 | i_tab_start, i_tab_count, i_dim ! netcdf information |
---|
| 1572 | INTEGER, DIMENSION(:), ALLOCATABLE :: & |
---|
| 1573 | i_time ! time |
---|
| 1574 | REAL(KIND=dp) :: & |
---|
| 1575 | dl_min, dl_max, dl_min_old, dl_max_old ! Minima and maxima of variable |
---|
| 1576 | !!---------------------------------------------------------------------- |
---|
| 1577 | |
---|
| 1578 | ! Read dimensions and compute min and max |
---|
| 1579 | ! --------------------------------------- |
---|
| 1580 | i_dimxy = SHAPE( dd_var) |
---|
| 1581 | i_tab_start(1) = 1 |
---|
| 1582 | i_tab_count(1) = i_dimxy(1) |
---|
| 1583 | i_tab_start(2) = 1 |
---|
| 1584 | i_tab_count(2) = i_dimxy(2) |
---|
| 1585 | i_tab_start(3) = 1 |
---|
| 1586 | i_tab_count(3) = i_dimxy(3) |
---|
| 1587 | i_tab_count(4) = 1 |
---|
| 1588 | |
---|
| 1589 | IF ( PRESENT(dd_missing) ) THEN |
---|
| 1590 | dl_min = MINVAL(dd_var, mask = dd_var .NE. dd_missing ) |
---|
| 1591 | dl_max = MAXVAL(dd_var, mask = dd_var .NE. dd_missing ) |
---|
| 1592 | ELSE |
---|
| 1593 | dl_min = MINVAL(dd_var ) |
---|
| 1594 | dl_max = MAXVAL(dd_var ) |
---|
| 1595 | ENDIF |
---|
| 1596 | |
---|
| 1597 | ! Define the name of the variable |
---|
| 1598 | ! ------------------------------- |
---|
| 1599 | cl_var = "var" |
---|
| 1600 | IF ( PRESENT(cd_var) ) cl_var = cd_var |
---|
| 1601 | IF ( PRESENT(k_code) ) CALL get_var_info( k_code, cl_var ) |
---|
| 1602 | |
---|
| 1603 | ! |
---|
| 1604 | ! Open or create file |
---|
| 1605 | ! ------------------- |
---|
| 1606 | INQUIRE( FILE=cd_filename, EXIST=llexist ) |
---|
| 1607 | IF ( .NOT. llexist ) THEN |
---|
| 1608 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 1609 | CALL create_map ( cd_filename, i_dimxy, cd_descr=cd_descr ) |
---|
| 1610 | ELSE |
---|
| 1611 | CALL create_map ( cd_filename, i_dimxy ) |
---|
| 1612 | ENDIF |
---|
| 1613 | ENDIF |
---|
| 1614 | |
---|
| 1615 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 1616 | & __LINE__,__MYFILE__) |
---|
| 1617 | |
---|
| 1618 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'time', i_time_id ) ,& |
---|
| 1619 | & __LINE__,__MYFILE__) |
---|
| 1620 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'x', i_dim_x_id ) ,& |
---|
| 1621 | & __LINE__,__MYFILE__) |
---|
| 1622 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'y', i_dim_y_id ) ,& |
---|
| 1623 | & __LINE__,__MYFILE__) |
---|
| 1624 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'z', i_dim_z_id ) ,& |
---|
| 1625 | & __LINE__,__MYFILE__) |
---|
| 1626 | i_dim(1) = i_dim_x_id |
---|
| 1627 | i_dim(2) = i_dim_y_id |
---|
| 1628 | i_dim(3) = i_dim_z_id |
---|
| 1629 | i_dim(4) = i_time_id |
---|
| 1630 | |
---|
| 1631 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(1), len=i_len(1) ) ,& |
---|
| 1632 | & __LINE__,__MYFILE__) |
---|
| 1633 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(2), len=i_len(2) ) ,& |
---|
| 1634 | & __LINE__,__MYFILE__) |
---|
| 1635 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dim(3), len=i_len(3) ) ,& |
---|
| 1636 | & __LINE__,__MYFILE__) |
---|
| 1637 | |
---|
| 1638 | IF ( (i_len(1) .NE. i_dimxy(1)) .OR. (i_len(2) .NE. i_dimxy(2)) .OR. & |
---|
| 1639 | (i_len(3) .NE. i_dimxy(3)) ) THEN |
---|
| 1640 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1641 | WRITE(*,*)'variable = ',cl_var |
---|
| 1642 | WRITE(*,*)'shape of array = ',i_dimxy |
---|
| 1643 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 1644 | WRITE(*,*)'Dimensions are different' |
---|
| 1645 | WRITE(*,*)'CALL abort' |
---|
| 1646 | CALL abort |
---|
| 1647 | ENDIF |
---|
| 1648 | ! Define variable or find it |
---|
| 1649 | ! -------------------------- |
---|
| 1650 | i_var_exist = nf90_inq_varid( i_file_id, cl_var, i_var_id ) |
---|
| 1651 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1652 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 1653 | & __LINE__,__MYFILE__) |
---|
| 1654 | CALL nchdlerr( nf90_def_var( i_file_id, cl_var, nf90_double, i_dim, i_var_id ) ,& |
---|
| 1655 | & __LINE__,__MYFILE__) |
---|
| 1656 | IF ( PRESENT(k_code) ) CALL put_att( i_file_id, i_var_id, k_code ) |
---|
| 1657 | IF ( PRESENT(dd_missing) ) & |
---|
| 1658 | & CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', dd_missing ) ,& |
---|
| 1659 | & __LINE__,__MYFILE__) |
---|
| 1660 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_min ) ,& |
---|
| 1661 | & __LINE__,__MYFILE__) |
---|
| 1662 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_max ) ,& |
---|
| 1663 | & __LINE__,__MYFILE__) |
---|
| 1664 | i_var_exist = nf90_inq_varid( i_file_id, 'time', i_time_id ) |
---|
| 1665 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1666 | CALL nchdlerr( nf90_def_var( i_file_id, 'time', nf90_int, i_dim(4), i_time_id ) ,& |
---|
| 1667 | & __LINE__,__MYFILE__) |
---|
| 1668 | ENDIF |
---|
| 1669 | IF ( PRESENT(reftime) ) THEN |
---|
| 1670 | i_var_exist = nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) |
---|
| 1671 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1672 | CALL nchdlerr( nf90_def_var( i_file_id, 'reftime', nf90_double, i_dim(4), i_reftime_id ) ,& |
---|
| 1673 | & __LINE__,__MYFILE__) |
---|
| 1674 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'units', 'days since 1950-01-01 00:00:00' ) ,& |
---|
| 1675 | & __LINE__,__MYFILE__) |
---|
| 1676 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'standard_name', 'forecast_reference_time' ) ,& |
---|
| 1677 | & __LINE__,__MYFILE__) |
---|
| 1678 | CALL nchdlerr( nf90_put_att( i_file_id, i_reftime_id, 'long_name', 'forecast reference time' ) ,& |
---|
| 1679 | & __LINE__,__MYFILE__) |
---|
| 1680 | ENDIF |
---|
| 1681 | ENDIF |
---|
| 1682 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1683 | i_var_exist = nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) |
---|
| 1684 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1685 | CALL nchdlerr( nf90_def_var( i_file_id, 'leadtime', nf90_int, i_dim(4), i_leadtime_id ),__LINE__,__MYFILE__ ) |
---|
| 1686 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'units', 'days' ) ,& |
---|
| 1687 | & __LINE__,__MYFILE__) |
---|
| 1688 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'standard_name', 'forecast_period' ) ,& |
---|
| 1689 | & __LINE__,__MYFILE__) |
---|
| 1690 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'long_name', & |
---|
| 1691 | & 'Time elapsed since the start of the forecast' ) ,& |
---|
| 1692 | & __LINE__,__MYFILE__) |
---|
| 1693 | CALL nchdlerr( nf90_put_att( i_file_id, i_leadtime_id, 'bounds', 'time_bnd' ) ,& |
---|
| 1694 | & __LINE__,__MYFILE__) |
---|
| 1695 | ENDIF |
---|
| 1696 | ENDIF |
---|
| 1697 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1698 | i_var_exist = nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) |
---|
| 1699 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 1700 | i_time_bnd=SHAPE(time_bnd) |
---|
| 1701 | CALL nchdlerr( nf90_def_dim( i_file_id, 'time_bnd', i_time_bnd(1) , i_dim_id ) ,& |
---|
| 1702 | & __LINE__,__MYFILE__) |
---|
| 1703 | CALL nchdlerr( nf90_def_var( i_file_id, 'time_bnd', nf90_int, (/i_dim_id, i_dim(4)/), i_time_bnd_id ) ,& |
---|
| 1704 | & __LINE__,__MYFILE__) |
---|
| 1705 | CALL nchdlerr( nf90_put_att( i_file_id, i_time_bnd_id, 'units', 'days' ) ,& |
---|
| 1706 | & __LINE__,__MYFILE__) |
---|
| 1707 | ENDIF |
---|
| 1708 | ENDIF |
---|
| 1709 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 1710 | & __LINE__,__MYFILE__) |
---|
| 1711 | i_tab_start(4) = 1 |
---|
| 1712 | i_pos = 1 |
---|
| 1713 | ELSE |
---|
| 1714 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_min', dl_min_old ) ,& |
---|
| 1715 | & __LINE__,__MYFILE__) |
---|
| 1716 | CALL nchdlerr( nf90_get_att( i_file_id, i_var_id, 'valid_max', dl_max_old ) ,& |
---|
| 1717 | & __LINE__,__MYFILE__) |
---|
| 1718 | dl_min = MIN( dl_min, dl_min_old ) |
---|
| 1719 | dl_max = MAX( dl_max, dl_max_old ) |
---|
| 1720 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 1721 | & __LINE__,__MYFILE__) |
---|
| 1722 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_min ) ,& |
---|
| 1723 | & __LINE__,__MYFILE__) |
---|
| 1724 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_max ) ,& |
---|
| 1725 | & __LINE__,__MYFILE__) |
---|
| 1726 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 1727 | & __LINE__,__MYFILE__) |
---|
| 1728 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_time_id, len=i_pos ),__LINE__,__MYFILE__ ) |
---|
| 1729 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time', i_time_id ) ,& |
---|
| 1730 | & __LINE__,__MYFILE__) |
---|
| 1731 | IF ( PRESENT(reftime) ) THEN |
---|
| 1732 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'reftime', i_reftime_id ) ,& |
---|
| 1733 | & __LINE__,__MYFILE__) |
---|
| 1734 | ENDIF |
---|
| 1735 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1736 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'leadtime', i_leadtime_id ) ,& |
---|
| 1737 | & __LINE__,__MYFILE__) |
---|
| 1738 | ENDIF |
---|
| 1739 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1740 | i_time_bnd=SHAPE(time_bnd) |
---|
| 1741 | CALL nchdlerr( nf90_inq_varid( i_file_id, 'time_bnd', i_time_bnd_id ) ,& |
---|
| 1742 | & __LINE__,__MYFILE__) |
---|
| 1743 | ENDIF |
---|
| 1744 | ALLOCATE( i_time(i_pos) ) |
---|
| 1745 | CALL nchdlerr( nf90_get_var( i_file_id, i_time_id, i_time ) ,& |
---|
| 1746 | & __LINE__,__MYFILE__) |
---|
| 1747 | DO ii = 1, i_pos |
---|
| 1748 | IF ( k_time .EQ. i_time(ii) ) THEN |
---|
| 1749 | i_pos = ii - 1 |
---|
| 1750 | EXIT |
---|
| 1751 | ENDIF |
---|
| 1752 | ENDDO |
---|
| 1753 | DEALLOCATE( i_time ) |
---|
| 1754 | i_pos = i_pos + 1 |
---|
| 1755 | i_tab_start(4) = i_pos |
---|
| 1756 | ENDIF |
---|
| 1757 | |
---|
| 1758 | ! Put variable(s) |
---|
| 1759 | ! -------------- |
---|
| 1760 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, dd_var, & |
---|
| 1761 | & start=i_tab_start, count=i_tab_count ) ,& |
---|
| 1762 | & __LINE__,__MYFILE__) |
---|
| 1763 | IF ( PRESENT(k_time) ) THEN |
---|
| 1764 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/k_time/), & |
---|
| 1765 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1766 | & __LINE__,__MYFILE__) |
---|
| 1767 | ELSE |
---|
| 1768 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_id, (/i_pos/), & |
---|
| 1769 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1770 | & __LINE__,__MYFILE__) |
---|
| 1771 | ENDIF |
---|
| 1772 | IF ( PRESENT(reftime) ) THEN |
---|
| 1773 | CALL nchdlerr( nf90_put_var( i_file_id, i_reftime_id, (/reftime/), & |
---|
| 1774 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1775 | & __LINE__,__MYFILE__) |
---|
| 1776 | ENDIF |
---|
| 1777 | IF ( PRESENT(leadtime) ) THEN |
---|
| 1778 | CALL nchdlerr( nf90_put_var( i_file_id, i_leadtime_id, (/leadtime/), & |
---|
| 1779 | & start=(/i_tab_start(4)/), count=(/i_tab_count(4)/) ) ,& |
---|
| 1780 | & __LINE__,__MYFILE__) |
---|
| 1781 | ENDIF |
---|
| 1782 | IF ( PRESENT(time_bnd) ) THEN |
---|
| 1783 | CALL nchdlerr( nf90_put_var( i_file_id, i_time_bnd_id, time_bnd, & |
---|
| 1784 | & start=(/1,i_tab_start(4)/), count=(/i_time_bnd(1),i_tab_count(4)/) ) ,& |
---|
| 1785 | & __LINE__,__MYFILE__) |
---|
| 1786 | ENDIF |
---|
| 1787 | |
---|
| 1788 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 1789 | & __LINE__,__MYFILE__) |
---|
| 1790 | |
---|
| 1791 | END SUBROUTINE put_map_3d_d |
---|
| 1792 | |
---|
| 1793 | !!====================================================================== |
---|
| 1794 | |
---|
| 1795 | SUBROUTINE get_var_1d_i ( cd_filename, cd_var, k_var, k_missing ) |
---|
| 1796 | !!---------------------------------------------------------------------- |
---|
| 1797 | !! *** ROUTINE get_var_1d_i *** |
---|
| 1798 | !! |
---|
| 1799 | !! ** Purpose : read 1d map of integers in a netcdf file |
---|
| 1800 | !! |
---|
| 1801 | !! ** Method : use netcdf fortran library |
---|
| 1802 | !! |
---|
| 1803 | !! ** Action : - get variable informations |
---|
| 1804 | !! - read variable |
---|
| 1805 | !! |
---|
| 1806 | !! Reference : |
---|
| 1807 | !! |
---|
| 1808 | !! History : |
---|
| 1809 | !! 06-05 (N. Daget) original code |
---|
| 1810 | !!---------------------------------------------------------------------- |
---|
| 1811 | !! * Modules used |
---|
| 1812 | |
---|
| 1813 | !! * Library used |
---|
| 1814 | |
---|
| 1815 | !! * arguments |
---|
| 1816 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 1817 | cd_filename ! filename |
---|
| 1818 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 1819 | cd_var ! variable name |
---|
| 1820 | INTEGER, DIMENSION(:), INTENT(out) :: & |
---|
| 1821 | k_var ! variable to read in netcdf file |
---|
| 1822 | INTEGER, OPTIONAL, INTENT(out) :: & |
---|
| 1823 | k_missing ! missing value of the variable |
---|
| 1824 | |
---|
| 1825 | !! * local declarations |
---|
| 1826 | INTEGER :: & |
---|
| 1827 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 1828 | i_ndims, & ! Number of dimensions for this variable |
---|
| 1829 | i_type, & ! external data type for this variable |
---|
| 1830 | i_exist ! test |
---|
| 1831 | INTEGER, DIMENSION(1) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 1832 | INTEGER :: i_missing2 ! missing value of the variable |
---|
| 1833 | !!---------------------------------------------------------------------- |
---|
| 1834 | |
---|
| 1835 | ! Open and test netcdf file |
---|
| 1836 | ! ------------------------- |
---|
| 1837 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 1838 | & __LINE__,__MYFILE__) |
---|
| 1839 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 1840 | & __LINE__,__MYFILE__) |
---|
| 1841 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 1842 | & __LINE__,__MYFILE__) |
---|
| 1843 | IF ( i_type .NE. 4 ) THEN |
---|
| 1844 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1845 | WRITE(*,*)'variable = ',cd_var |
---|
| 1846 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 1847 | WRITE(*,*)'The valid external data type is NF_INT : 4' |
---|
| 1848 | WRITE(*,*)'CALL abort' |
---|
| 1849 | CALL abort |
---|
| 1850 | ENDIF |
---|
| 1851 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 1852 | & __LINE__,__MYFILE__) |
---|
| 1853 | IF ( i_ndims .NE. 1 ) THEN |
---|
| 1854 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1855 | WRITE(*,*)'variable = ',cd_var |
---|
| 1856 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 1857 | WRITE(*,*)'The valid number of dimension is 1' |
---|
| 1858 | WRITE(*,*)'CALL abort' |
---|
| 1859 | CALL abort |
---|
| 1860 | ENDIF |
---|
| 1861 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 1862 | & __LINE__,__MYFILE__) |
---|
| 1863 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 1864 | & __LINE__,__MYFILE__) |
---|
| 1865 | i_shape=SHAPE(k_var) |
---|
| 1866 | IF ( i_len(1) .NE. i_shape(1) ) THEN |
---|
| 1867 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1868 | WRITE(*,*)'variable = ',cd_var |
---|
| 1869 | WRITE(*,*)'shape of array = ',SHAPE(k_var) |
---|
| 1870 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 1871 | WRITE(*,*)'Dimensions are different' |
---|
| 1872 | WRITE(*,*)'CALL abort' |
---|
| 1873 | CALL abort |
---|
| 1874 | ENDIF |
---|
| 1875 | |
---|
| 1876 | ! Read variable |
---|
| 1877 | ! ------------- |
---|
| 1878 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, k_var ) ,& |
---|
| 1879 | & __LINE__,__MYFILE__) |
---|
| 1880 | |
---|
| 1881 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', i_missing2 ) |
---|
| 1882 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 1883 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', i_missing2 ) |
---|
| 1884 | ENDIF |
---|
| 1885 | |
---|
| 1886 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 1887 | & __LINE__,__MYFILE__) |
---|
| 1888 | |
---|
| 1889 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 1890 | i_missing2 = MAXVAL(k_var) |
---|
| 1891 | ENDIF |
---|
| 1892 | |
---|
| 1893 | IF ( PRESENT(k_missing) ) THEN |
---|
| 1894 | k_missing = i_missing2 |
---|
| 1895 | ELSE |
---|
| 1896 | WHERE(k_var .EQ. i_missing2) k_var = 0.0 |
---|
| 1897 | WHERE((k_var .GT. 0.) .EQV. (k_var .LE. 0.)) k_var = 0.0 |
---|
| 1898 | ENDIF |
---|
| 1899 | |
---|
| 1900 | END SUBROUTINE get_var_1d_i |
---|
| 1901 | |
---|
| 1902 | SUBROUTINE get_var_2d_i ( cd_filename, cd_var, k_var, k_missing ) |
---|
| 1903 | !!---------------------------------------------------------------------- |
---|
| 1904 | !! *** ROUTINE get_var_2d_i *** |
---|
| 1905 | !! |
---|
| 1906 | !! ** Purpose : read 2d map of integers in a netcdf file |
---|
| 1907 | !! |
---|
| 1908 | !! ** Method : use netcdf fortran library |
---|
| 1909 | !! |
---|
| 1910 | !! ** Action : - get variable informations |
---|
| 1911 | !! - read variable |
---|
| 1912 | !! |
---|
| 1913 | !! Reference : |
---|
| 1914 | !! |
---|
| 1915 | !! History : |
---|
| 1916 | !! 06-05 (N. Daget) original code |
---|
| 1917 | !!---------------------------------------------------------------------- |
---|
| 1918 | !! * Modules used |
---|
| 1919 | |
---|
| 1920 | !! * Library used |
---|
| 1921 | |
---|
| 1922 | !! * arguments |
---|
| 1923 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 1924 | cd_filename ! filename |
---|
| 1925 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 1926 | cd_var ! variable name |
---|
| 1927 | INTEGER, DIMENSION(:,:), INTENT(out) :: & |
---|
| 1928 | k_var ! variable to read in netcdf file |
---|
| 1929 | INTEGER, OPTIONAL, INTENT(out) :: & |
---|
| 1930 | k_missing ! missing value of the variable |
---|
| 1931 | |
---|
| 1932 | !! * local declarations |
---|
| 1933 | INTEGER :: & |
---|
| 1934 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 1935 | i_ndims, & ! Number of dimensions for this variable |
---|
| 1936 | i_type, & ! external data type for this variable |
---|
| 1937 | i_exist ! test |
---|
| 1938 | INTEGER, DIMENSION(2) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 1939 | INTEGER :: i_missing2 ! missing value of the variable |
---|
| 1940 | !!---------------------------------------------------------------------- |
---|
| 1941 | |
---|
| 1942 | ! Open and test netcdf file |
---|
| 1943 | ! ------------------------- |
---|
| 1944 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 1945 | & __LINE__,__MYFILE__) |
---|
| 1946 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 1947 | & __LINE__,__MYFILE__) |
---|
| 1948 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 1949 | & __LINE__,__MYFILE__) |
---|
| 1950 | IF ( i_type .NE. 4 ) THEN |
---|
| 1951 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1952 | WRITE(*,*)'variable = ',cd_var |
---|
| 1953 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 1954 | WRITE(*,*)'The valid external data type is NF_INT : 4' |
---|
| 1955 | WRITE(*,*)'CALL abort' |
---|
| 1956 | CALL abort |
---|
| 1957 | ENDIF |
---|
| 1958 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 1959 | & __LINE__,__MYFILE__) |
---|
| 1960 | IF ( i_ndims .NE. 2 ) THEN |
---|
| 1961 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1962 | WRITE(*,*)'variable = ',cd_var |
---|
| 1963 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 1964 | WRITE(*,*)'The valid number of dimension is 2' |
---|
| 1965 | WRITE(*,*)'CALL abort' |
---|
| 1966 | CALL abort |
---|
| 1967 | ENDIF |
---|
| 1968 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 1969 | & __LINE__,__MYFILE__) |
---|
| 1970 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 1971 | & __LINE__,__MYFILE__) |
---|
| 1972 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 1973 | & __LINE__,__MYFILE__) |
---|
| 1974 | i_shape=SHAPE(k_var) |
---|
| 1975 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) ) THEN |
---|
| 1976 | WRITE(*,*)'filename = ',cd_filename |
---|
| 1977 | WRITE(*,*)'variable = ',cd_var |
---|
| 1978 | WRITE(*,*)'shape of array = ',SHAPE(k_var) |
---|
| 1979 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 1980 | WRITE(*,*)'Dimensions are different' |
---|
| 1981 | WRITE(*,*)'CALL abort' |
---|
| 1982 | CALL abort |
---|
| 1983 | ENDIF |
---|
| 1984 | |
---|
| 1985 | ! Read variable |
---|
| 1986 | ! ------------- |
---|
| 1987 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, k_var ) ,& |
---|
| 1988 | & __LINE__,__MYFILE__) |
---|
| 1989 | |
---|
| 1990 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', i_missing2 ) |
---|
| 1991 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 1992 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', i_missing2 ) |
---|
| 1993 | ENDIF |
---|
| 1994 | |
---|
| 1995 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 1996 | & __LINE__,__MYFILE__) |
---|
| 1997 | |
---|
| 1998 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 1999 | i_missing2 = MAXVAL(k_var) |
---|
| 2000 | ENDIF |
---|
| 2001 | |
---|
| 2002 | IF ( PRESENT(k_missing) ) THEN |
---|
| 2003 | k_missing = i_missing2 |
---|
| 2004 | ELSE |
---|
| 2005 | WHERE(k_var .EQ. i_missing2) k_var = 0.0 |
---|
| 2006 | WHERE((k_var .GT. 0.) .EQV. (k_var .LE. 0.)) k_var = 0.0 |
---|
| 2007 | ENDIF |
---|
| 2008 | |
---|
| 2009 | END SUBROUTINE get_var_2d_i |
---|
| 2010 | |
---|
| 2011 | SUBROUTINE get_var_3d_i ( cd_filename, cd_var, k_var, k_missing ) |
---|
| 2012 | !!---------------------------------------------------------------------- |
---|
| 2013 | !! *** ROUTINE get_var_3d_i *** |
---|
| 2014 | !! |
---|
| 2015 | !! ** Purpose : read 3d map of integers in a netcdf file |
---|
| 2016 | !! |
---|
| 2017 | !! ** Method : use netcdf fortran library |
---|
| 2018 | !! |
---|
| 2019 | !! ** Action : - get variable informations |
---|
| 2020 | !! - read variable |
---|
| 2021 | !! |
---|
| 2022 | !! Reference : |
---|
| 2023 | !! |
---|
| 2024 | !! History : |
---|
| 2025 | !! 06-05 (N. Daget) original code |
---|
| 2026 | !!---------------------------------------------------------------------- |
---|
| 2027 | !! * Modules used |
---|
| 2028 | |
---|
| 2029 | !! * Library used |
---|
| 2030 | |
---|
| 2031 | !! * arguments |
---|
| 2032 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2033 | cd_filename ! filename |
---|
| 2034 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2035 | cd_var ! variable name |
---|
| 2036 | INTEGER, DIMENSION(:,:,:), INTENT(out) :: & |
---|
| 2037 | k_var ! variable to read in netcdf file |
---|
| 2038 | INTEGER, OPTIONAL, INTENT(out) :: & |
---|
| 2039 | k_missing ! missing value of the variable |
---|
| 2040 | |
---|
| 2041 | !! * local declarations |
---|
| 2042 | INTEGER :: & |
---|
| 2043 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2044 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2045 | i_type, & ! external data type for this variable |
---|
| 2046 | i_exist ! test |
---|
| 2047 | INTEGER, DIMENSION(3) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2048 | INTEGER :: i_missing2 ! missing value of the variable |
---|
| 2049 | !!---------------------------------------------------------------------- |
---|
| 2050 | |
---|
| 2051 | ! Open and test netcdf file |
---|
| 2052 | ! ------------------------- |
---|
| 2053 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2054 | & __LINE__,__MYFILE__) |
---|
| 2055 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2056 | & __LINE__,__MYFILE__) |
---|
| 2057 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2058 | & __LINE__,__MYFILE__) |
---|
| 2059 | IF ( i_type .NE. 4 ) THEN |
---|
| 2060 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2061 | WRITE(*,*)'variable = ',cd_var |
---|
| 2062 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2063 | WRITE(*,*)'The valid external data type is NF_INT : 4' |
---|
| 2064 | WRITE(*,*)'CALL abort' |
---|
| 2065 | CALL abort |
---|
| 2066 | ENDIF |
---|
| 2067 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2068 | & __LINE__,__MYFILE__) |
---|
| 2069 | IF ( i_ndims .NE. 3 ) THEN |
---|
| 2070 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2071 | WRITE(*,*)'variable = ',cd_var |
---|
| 2072 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2073 | WRITE(*,*)'The valid number of dimension is 3' |
---|
| 2074 | WRITE(*,*)'CALL abort' |
---|
| 2075 | CALL abort |
---|
| 2076 | ENDIF |
---|
| 2077 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2078 | & __LINE__,__MYFILE__) |
---|
| 2079 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2080 | & __LINE__,__MYFILE__) |
---|
| 2081 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2082 | & __LINE__,__MYFILE__) |
---|
| 2083 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(3), len=i_len(3) ) ,& |
---|
| 2084 | & __LINE__,__MYFILE__) |
---|
| 2085 | i_shape=SHAPE(k_var) |
---|
| 2086 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) & |
---|
| 2087 | .OR. (i_len(3) .NE. i_shape(3)) ) THEN |
---|
| 2088 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2089 | WRITE(*,*)'variable = ',cd_var |
---|
| 2090 | WRITE(*,*)'shape of array = ',SHAPE(k_var) |
---|
| 2091 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2092 | WRITE(*,*)'Dimensions are different' |
---|
| 2093 | WRITE(*,*)'CALL abort' |
---|
| 2094 | CALL abort |
---|
| 2095 | ENDIF |
---|
| 2096 | |
---|
| 2097 | ! Read variable |
---|
| 2098 | ! ------------- |
---|
| 2099 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, k_var ) ,& |
---|
| 2100 | & __LINE__,__MYFILE__) |
---|
| 2101 | |
---|
| 2102 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', i_missing2 ) |
---|
| 2103 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2104 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', i_missing2 ) |
---|
| 2105 | ENDIF |
---|
| 2106 | |
---|
| 2107 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2108 | & __LINE__,__MYFILE__) |
---|
| 2109 | |
---|
| 2110 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2111 | i_missing2 = MAXVAL(k_var) |
---|
| 2112 | ENDIF |
---|
| 2113 | |
---|
| 2114 | IF ( PRESENT(k_missing) ) THEN |
---|
| 2115 | k_missing = i_missing2 |
---|
| 2116 | ELSE |
---|
| 2117 | WHERE(k_var .EQ. i_missing2) k_var = 0.0 |
---|
| 2118 | WHERE((k_var .GT. 0.) .EQV. (k_var .LE. 0.)) k_var = 0.0 |
---|
| 2119 | ENDIF |
---|
| 2120 | |
---|
| 2121 | END SUBROUTINE get_var_3d_i |
---|
| 2122 | |
---|
| 2123 | SUBROUTINE get_var_4d_i ( cd_filename, cd_var, k_var, k_missing ) |
---|
| 2124 | !!---------------------------------------------------------------------- |
---|
| 2125 | !! *** ROUTINE get_var_4d_i *** |
---|
| 2126 | !! |
---|
| 2127 | !! ** Purpose : read 4d map of integers in a netcdf file |
---|
| 2128 | !! |
---|
| 2129 | !! ** Method : use netcdf fortran library |
---|
| 2130 | !! |
---|
| 2131 | !! ** Action : - get variable informations |
---|
| 2132 | !! - read variable |
---|
| 2133 | !! |
---|
| 2134 | !! Reference : |
---|
| 2135 | !! |
---|
| 2136 | !! History : |
---|
| 2137 | !! 06-05 (N. Daget) original code |
---|
| 2138 | !!---------------------------------------------------------------------- |
---|
| 2139 | !! * Modules used |
---|
| 2140 | |
---|
| 2141 | !! * Library used |
---|
| 2142 | |
---|
| 2143 | |
---|
| 2144 | !! * arguments |
---|
| 2145 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2146 | cd_filename ! filename |
---|
| 2147 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2148 | cd_var ! variable name |
---|
| 2149 | INTEGER, DIMENSION(:,:,:,:), INTENT(out) :: & |
---|
| 2150 | k_var ! variable to read in netcdf file |
---|
| 2151 | INTEGER, OPTIONAL, INTENT(out) :: & |
---|
| 2152 | k_missing ! missing value of the variable |
---|
| 2153 | |
---|
| 2154 | !! * local declarations |
---|
| 2155 | INTEGER :: & |
---|
| 2156 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2157 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2158 | i_type, & ! external data type for this variable |
---|
| 2159 | i_exist ! test |
---|
| 2160 | INTEGER, DIMENSION(4) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2161 | INTEGER :: i_missing2 ! missing value of the variable |
---|
| 2162 | !!---------------------------------------------------------------------- |
---|
| 2163 | |
---|
| 2164 | ! Open and test netcdf file |
---|
| 2165 | ! ------------------------- |
---|
| 2166 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2167 | & __LINE__,__MYFILE__) |
---|
| 2168 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2169 | & __LINE__,__MYFILE__) |
---|
| 2170 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2171 | & __LINE__,__MYFILE__) |
---|
| 2172 | IF ( i_type .NE. 4 ) THEN |
---|
| 2173 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2174 | WRITE(*,*)'variable = ',cd_var |
---|
| 2175 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2176 | WRITE(*,*)'The valid external data type is NF_INT : 4' |
---|
| 2177 | WRITE(*,*)'CALL abort' |
---|
| 2178 | CALL abort |
---|
| 2179 | ENDIF |
---|
| 2180 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2181 | & __LINE__,__MYFILE__) |
---|
| 2182 | IF ( i_ndims .NE. 4 ) THEN |
---|
| 2183 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2184 | WRITE(*,*)'variable = ',cd_var |
---|
| 2185 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2186 | WRITE(*,*)'The valid number of dimension is 4' |
---|
| 2187 | WRITE(*,*)'CALL abort' |
---|
| 2188 | CALL abort |
---|
| 2189 | ENDIF |
---|
| 2190 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2191 | & __LINE__,__MYFILE__) |
---|
| 2192 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2193 | & __LINE__,__MYFILE__) |
---|
| 2194 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2195 | & __LINE__,__MYFILE__) |
---|
| 2196 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(3), len=i_len(3) ) ,& |
---|
| 2197 | & __LINE__,__MYFILE__) |
---|
| 2198 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(4), len=i_len(4) ) ,& |
---|
| 2199 | & __LINE__,__MYFILE__) |
---|
| 2200 | i_shape=SHAPE(k_var) |
---|
| 2201 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) & |
---|
| 2202 | .OR. (i_len(3) .NE. i_shape(3)) .OR. (i_len(4) .NE. i_shape(4)) ) THEN |
---|
| 2203 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2204 | WRITE(*,*)'variable = ',cd_var |
---|
| 2205 | WRITE(*,*)'shape of array = ',SHAPE(k_var) |
---|
| 2206 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2207 | WRITE(*,*)'Dimensions are different' |
---|
| 2208 | WRITE(*,*)'CALL abort' |
---|
| 2209 | CALL abort |
---|
| 2210 | ENDIF |
---|
| 2211 | |
---|
| 2212 | ! Read variable |
---|
| 2213 | ! ------------- |
---|
| 2214 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, k_var ) ,& |
---|
| 2215 | & __LINE__,__MYFILE__) |
---|
| 2216 | |
---|
| 2217 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', i_missing2 ) |
---|
| 2218 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2219 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', i_missing2 ) |
---|
| 2220 | ENDIF |
---|
| 2221 | |
---|
| 2222 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2223 | & __LINE__,__MYFILE__) |
---|
| 2224 | |
---|
| 2225 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2226 | i_missing2 = MAXVAL(k_var) |
---|
| 2227 | ENDIF |
---|
| 2228 | |
---|
| 2229 | IF ( PRESENT(k_missing) ) THEN |
---|
| 2230 | k_missing = i_missing2 |
---|
| 2231 | ELSE |
---|
| 2232 | WHERE(k_var .EQ. i_missing2) k_var = 0.0 |
---|
| 2233 | WHERE((k_var .GT. 0.) .EQV. (k_var .LE. 0.)) k_var = 0.0 |
---|
| 2234 | ENDIF |
---|
| 2235 | |
---|
| 2236 | END SUBROUTINE get_var_4d_i |
---|
| 2237 | |
---|
| 2238 | SUBROUTINE get_var_1d_r ( cd_filename, cd_var, p_var, p_missing ) |
---|
| 2239 | !!---------------------------------------------------------------------- |
---|
| 2240 | !! *** ROUTINE get_var_1d_r *** |
---|
| 2241 | !! |
---|
| 2242 | !! ** Purpose : read 1d map of reals in a netcdf file |
---|
| 2243 | !! |
---|
| 2244 | !! ** Method : use netcdf fortran library |
---|
| 2245 | !! |
---|
| 2246 | !! ** Action : - get variable informations |
---|
| 2247 | !! - read variable |
---|
| 2248 | !! |
---|
| 2249 | !! Reference : |
---|
| 2250 | !! |
---|
| 2251 | !! History : |
---|
| 2252 | !! 06-05 (N. Daget) original code |
---|
| 2253 | !!---------------------------------------------------------------------- |
---|
| 2254 | !! * Modules used |
---|
| 2255 | |
---|
| 2256 | !! * Library used |
---|
| 2257 | |
---|
| 2258 | !! * arguments |
---|
| 2259 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2260 | cd_filename ! filename |
---|
| 2261 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2262 | cd_var ! variable name |
---|
| 2263 | REAL(KIND=sp), DIMENSION(:), INTENT(out) :: & |
---|
| 2264 | p_var ! variable to read in netcdf file |
---|
| 2265 | REAL(KIND=sp), OPTIONAL, INTENT(out) :: & |
---|
| 2266 | p_missing ! missing value of the variable |
---|
| 2267 | |
---|
| 2268 | !! * local declarations |
---|
| 2269 | INTEGER :: & |
---|
| 2270 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2271 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2272 | i_type, & ! external data type for this variable |
---|
| 2273 | i_exist ! test |
---|
| 2274 | INTEGER, DIMENSION(1) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2275 | REAL :: z_missing2 ! missing value of the variable |
---|
| 2276 | !!---------------------------------------------------------------------- |
---|
| 2277 | |
---|
| 2278 | ! Open and test netcdf file |
---|
| 2279 | ! ------------------------- |
---|
| 2280 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2281 | & __LINE__,__MYFILE__) |
---|
| 2282 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ),__LINE__,__MYFILE__ ) |
---|
| 2283 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2284 | & __LINE__,__MYFILE__) |
---|
| 2285 | IF ( i_type .NE. 5 ) THEN |
---|
| 2286 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2287 | WRITE(*,*)'variable = ',cd_var |
---|
| 2288 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2289 | WRITE(*,*)'The valid external data type is NF_FLOAT : 5' |
---|
| 2290 | ! WRITE(*,*)'CALL abort' |
---|
| 2291 | ! CALL abort |
---|
| 2292 | ENDIF |
---|
| 2293 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2294 | & __LINE__,__MYFILE__) |
---|
| 2295 | IF ( i_ndims .NE. 1 ) THEN |
---|
| 2296 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2297 | WRITE(*,*)'variable = ',cd_var |
---|
| 2298 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2299 | WRITE(*,*)'The valid number of dimension is 1' |
---|
| 2300 | WRITE(*,*)'CALL abort' |
---|
| 2301 | CALL abort |
---|
| 2302 | ENDIF |
---|
| 2303 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2304 | & __LINE__,__MYFILE__) |
---|
| 2305 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2306 | & __LINE__,__MYFILE__) |
---|
| 2307 | i_shape=SHAPE(p_var) |
---|
| 2308 | IF ( i_len(1) .NE. i_shape(1) ) THEN |
---|
| 2309 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2310 | WRITE(*,*)'variable = ',cd_var |
---|
| 2311 | WRITE(*,*)'shape of array = ',SHAPE(p_var) |
---|
| 2312 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2313 | WRITE(*,*)'Dimensions are different' |
---|
| 2314 | WRITE(*,*)'CALL abort' |
---|
| 2315 | CALL abort |
---|
| 2316 | ENDIF |
---|
| 2317 | |
---|
| 2318 | ! Read variable |
---|
| 2319 | ! ------------- |
---|
| 2320 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, p_var ) ,& |
---|
| 2321 | & __LINE__,__MYFILE__) |
---|
| 2322 | |
---|
| 2323 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', z_missing2 ) |
---|
| 2324 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2325 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', z_missing2 ) |
---|
| 2326 | ENDIF |
---|
| 2327 | |
---|
| 2328 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2329 | & __LINE__,__MYFILE__) |
---|
| 2330 | |
---|
| 2331 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2332 | z_missing2 = MAXVAL(p_var) |
---|
| 2333 | ENDIF |
---|
| 2334 | |
---|
| 2335 | IF ( PRESENT(p_missing) ) THEN |
---|
| 2336 | p_missing = z_missing2 |
---|
| 2337 | ELSE |
---|
| 2338 | WHERE(p_var .EQ. z_missing2) p_var = 0.0 |
---|
| 2339 | WHERE((p_var .GT. 0.) .EQV. (p_var .LE. 0.)) p_var = 0.0 |
---|
| 2340 | ENDIF |
---|
| 2341 | |
---|
| 2342 | END SUBROUTINE get_var_1d_r |
---|
| 2343 | |
---|
| 2344 | SUBROUTINE get_var_2d_r ( cd_filename, cd_var, p_var, p_missing ) |
---|
| 2345 | !!---------------------------------------------------------------------- |
---|
| 2346 | !! *** ROUTINE get_var_2d_r *** |
---|
| 2347 | !! |
---|
| 2348 | !! ** Purpose : read 2d map of reals in a netcdf file |
---|
| 2349 | !! |
---|
| 2350 | !! ** Method : use netcdf fortran library |
---|
| 2351 | !! |
---|
| 2352 | !! ** Action : - get variable informations |
---|
| 2353 | !! - read variable |
---|
| 2354 | !! |
---|
| 2355 | !! Reference : |
---|
| 2356 | !! |
---|
| 2357 | !! History : |
---|
| 2358 | !! 06-05 (N. Daget) original code |
---|
| 2359 | !!---------------------------------------------------------------------- |
---|
| 2360 | !! * Modules used |
---|
| 2361 | |
---|
| 2362 | !! * Library used |
---|
| 2363 | |
---|
| 2364 | !! * arguments |
---|
| 2365 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2366 | cd_filename ! filename |
---|
| 2367 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2368 | cd_var ! variable name |
---|
| 2369 | REAL(KIND=sp), DIMENSION(:,:), INTENT(out) :: & |
---|
| 2370 | p_var ! variable to read in netcdf file |
---|
| 2371 | REAL(KIND=sp), OPTIONAL, INTENT(out) :: & |
---|
| 2372 | p_missing ! missing value of the variable |
---|
| 2373 | |
---|
| 2374 | !! * local declarations |
---|
| 2375 | INTEGER :: & |
---|
| 2376 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2377 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2378 | i_type, & ! external data type for this variable |
---|
| 2379 | i_exist ! test |
---|
| 2380 | INTEGER, DIMENSION(2) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2381 | REAL :: z_missing2 ! missing value of the variable |
---|
| 2382 | !!---------------------------------------------------------------------- |
---|
| 2383 | |
---|
| 2384 | ! Open and test netcdf file |
---|
| 2385 | ! ------------------------- |
---|
| 2386 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2387 | & __LINE__,__MYFILE__) |
---|
| 2388 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2389 | & __LINE__,__MYFILE__) |
---|
| 2390 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2391 | & __LINE__,__MYFILE__) |
---|
| 2392 | IF ( i_type .NE. 5 ) THEN |
---|
| 2393 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2394 | WRITE(*,*)'variable = ',cd_var |
---|
| 2395 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2396 | WRITE(*,*)'The valid external data type is NF_FLOAT : 5' |
---|
| 2397 | ! WRITE(*,*)'CALL abort' |
---|
| 2398 | ! CALL abort |
---|
| 2399 | ENDIF |
---|
| 2400 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2401 | & __LINE__,__MYFILE__) |
---|
| 2402 | IF ( i_ndims .NE. 2 ) THEN |
---|
| 2403 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2404 | WRITE(*,*)'variable = ',cd_var |
---|
| 2405 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2406 | WRITE(*,*)'The valid number of dimension is 2' |
---|
| 2407 | WRITE(*,*)'CALL abort' |
---|
| 2408 | CALL abort |
---|
| 2409 | ENDIF |
---|
| 2410 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2411 | & __LINE__,__MYFILE__) |
---|
| 2412 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2413 | & __LINE__,__MYFILE__) |
---|
| 2414 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2415 | & __LINE__,__MYFILE__) |
---|
| 2416 | i_shape=SHAPE(p_var) |
---|
| 2417 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) ) THEN |
---|
| 2418 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2419 | WRITE(*,*)'variable = ',cd_var |
---|
| 2420 | WRITE(*,*)'shape of array = ',SHAPE(p_var) |
---|
| 2421 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2422 | WRITE(*,*)'Dimensions are different' |
---|
| 2423 | WRITE(*,*)'CALL abort' |
---|
| 2424 | CALL abort |
---|
| 2425 | ENDIF |
---|
| 2426 | |
---|
| 2427 | ! Read variable |
---|
| 2428 | ! ------------- |
---|
| 2429 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, p_var ) ,& |
---|
| 2430 | & __LINE__,__MYFILE__) |
---|
| 2431 | |
---|
| 2432 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', z_missing2 ) |
---|
| 2433 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2434 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', z_missing2 ) |
---|
| 2435 | ENDIF |
---|
| 2436 | |
---|
| 2437 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2438 | & __LINE__,__MYFILE__) |
---|
| 2439 | |
---|
| 2440 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2441 | z_missing2 = MAXVAL(p_var) |
---|
| 2442 | ENDIF |
---|
| 2443 | |
---|
| 2444 | IF ( PRESENT(p_missing) ) THEN |
---|
| 2445 | p_missing = z_missing2 |
---|
| 2446 | ELSE |
---|
| 2447 | WHERE(p_var .EQ. z_missing2) p_var = 0.0 |
---|
| 2448 | WHERE((p_var .GT. 0.) .EQV. (p_var .LE. 0.)) p_var = 0.0 |
---|
| 2449 | ENDIF |
---|
| 2450 | |
---|
| 2451 | END SUBROUTINE get_var_2d_r |
---|
| 2452 | |
---|
| 2453 | SUBROUTINE get_var_3d_r ( cd_filename, cd_var, p_var, p_missing ) |
---|
| 2454 | !!---------------------------------------------------------------------- |
---|
| 2455 | !! *** ROUTINE get_var_3d_r *** |
---|
| 2456 | !! |
---|
| 2457 | !! ** Purpose : read 3d map of reals in a netcdf file |
---|
| 2458 | !! |
---|
| 2459 | !! ** Method : use netcdf fortran library |
---|
| 2460 | !! |
---|
| 2461 | !! ** Action : - get variable informations |
---|
| 2462 | !! - read variable |
---|
| 2463 | !! |
---|
| 2464 | !! Reference : |
---|
| 2465 | !! |
---|
| 2466 | !! History : |
---|
| 2467 | !! 06-05 (N. Daget) original code |
---|
| 2468 | !!---------------------------------------------------------------------- |
---|
| 2469 | !! * Modules used |
---|
| 2470 | |
---|
| 2471 | !! * Library used |
---|
| 2472 | |
---|
| 2473 | !! * arguments |
---|
| 2474 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2475 | cd_filename ! filename |
---|
| 2476 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2477 | cd_var ! variable name |
---|
| 2478 | REAL(KIND=sp), DIMENSION(:,:,:), INTENT(out) :: & |
---|
| 2479 | p_var ! variable to read in netcdf file |
---|
| 2480 | REAL(KIND=sp), OPTIONAL, INTENT(out) :: & |
---|
| 2481 | p_missing ! missing value of the variable |
---|
| 2482 | |
---|
| 2483 | !! * local declarations |
---|
| 2484 | INTEGER :: & |
---|
| 2485 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2486 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2487 | i_type, & ! external data type for this variable |
---|
| 2488 | i_exist ! test |
---|
| 2489 | INTEGER, DIMENSION(3) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2490 | REAL :: z_missing2 ! missing value of the variable |
---|
| 2491 | !!---------------------------------------------------------------------- |
---|
| 2492 | |
---|
| 2493 | ! Open and test netcdf file |
---|
| 2494 | ! ------------------------- |
---|
| 2495 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2496 | & __LINE__,__MYFILE__) |
---|
| 2497 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2498 | & __LINE__,__MYFILE__) |
---|
| 2499 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2500 | & __LINE__,__MYFILE__) |
---|
| 2501 | IF ( i_type .NE. 5 ) THEN |
---|
| 2502 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2503 | WRITE(*,*)'variable = ',cd_var |
---|
| 2504 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2505 | WRITE(*,*)'The valid external data type is NF_FLOAT : 5' |
---|
| 2506 | ! WRITE(*,*)'CALL abort' |
---|
| 2507 | ! CALL abort |
---|
| 2508 | ENDIF |
---|
| 2509 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2510 | & __LINE__,__MYFILE__) |
---|
| 2511 | IF ( i_ndims .NE. 3 ) THEN |
---|
| 2512 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2513 | WRITE(*,*)'variable = ',cd_var |
---|
| 2514 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2515 | WRITE(*,*)'The valid number of dimension is 3' |
---|
| 2516 | WRITE(*,*)'CALL abort' |
---|
| 2517 | CALL abort |
---|
| 2518 | ENDIF |
---|
| 2519 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2520 | & __LINE__,__MYFILE__) |
---|
| 2521 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2522 | & __LINE__,__MYFILE__) |
---|
| 2523 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2524 | & __LINE__,__MYFILE__) |
---|
| 2525 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(3), len=i_len(3) ) ,& |
---|
| 2526 | & __LINE__,__MYFILE__) |
---|
| 2527 | i_shape=SHAPE(p_var) |
---|
| 2528 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) & |
---|
| 2529 | .OR. (i_len(3) .NE. i_shape(3)) ) THEN |
---|
| 2530 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2531 | WRITE(*,*)'variable = ',cd_var |
---|
| 2532 | WRITE(*,*)'shape of array = ',SHAPE(p_var) |
---|
| 2533 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2534 | WRITE(*,*)'Dimensions are different' |
---|
| 2535 | WRITE(*,*)'CALL abort' |
---|
| 2536 | CALL abort |
---|
| 2537 | ENDIF |
---|
| 2538 | |
---|
| 2539 | ! Read variable |
---|
| 2540 | ! ------------- |
---|
| 2541 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, p_var ) ,& |
---|
| 2542 | & __LINE__,__MYFILE__) |
---|
| 2543 | |
---|
| 2544 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', z_missing2 ) |
---|
| 2545 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2546 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', z_missing2 ) |
---|
| 2547 | ENDIF |
---|
| 2548 | |
---|
| 2549 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2550 | & __LINE__,__MYFILE__) |
---|
| 2551 | |
---|
| 2552 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2553 | z_missing2 = MAXVAL(p_var) |
---|
| 2554 | ENDIF |
---|
| 2555 | |
---|
| 2556 | IF ( PRESENT(p_missing) ) THEN |
---|
| 2557 | p_missing = z_missing2 |
---|
| 2558 | ELSE |
---|
| 2559 | WHERE(p_var .EQ. z_missing2) p_var = 0.0 |
---|
| 2560 | WHERE((p_var .GT. 0.) .EQV. (p_var .LE. 0.)) p_var = 0.0 |
---|
| 2561 | ENDIF |
---|
| 2562 | |
---|
| 2563 | END SUBROUTINE get_var_3d_r |
---|
| 2564 | |
---|
| 2565 | SUBROUTINE get_var_4d_r ( cd_filename, cd_var, p_var, p_missing ) |
---|
| 2566 | !!---------------------------------------------------------------------- |
---|
| 2567 | !! *** ROUTINE get_var_4d_r *** |
---|
| 2568 | !! |
---|
| 2569 | !! ** Purpose : read 4d map of reals in a netcdf file |
---|
| 2570 | !! |
---|
| 2571 | !! ** Method : use netcdf fortran library |
---|
| 2572 | !! |
---|
| 2573 | !! ** Action : - get variable informations |
---|
| 2574 | !! - read variable |
---|
| 2575 | !! |
---|
| 2576 | !! Reference : |
---|
| 2577 | !! |
---|
| 2578 | !! History : |
---|
| 2579 | !! 06-05 (N. Daget) original code |
---|
| 2580 | !!---------------------------------------------------------------------- |
---|
| 2581 | !! * Modules used |
---|
| 2582 | |
---|
| 2583 | !! * Library used |
---|
| 2584 | |
---|
| 2585 | !! * arguments |
---|
| 2586 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2587 | cd_filename ! filename |
---|
| 2588 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2589 | cd_var ! variable name |
---|
| 2590 | REAL(KIND=sp), DIMENSION(:,:,:,:), INTENT(out) :: & |
---|
| 2591 | p_var ! variable to read in netcdf file |
---|
| 2592 | REAL(KIND=sp), OPTIONAL, INTENT(out) :: & |
---|
| 2593 | p_missing ! missing value of the variable |
---|
| 2594 | |
---|
| 2595 | !! * local declarations |
---|
| 2596 | INTEGER :: & |
---|
| 2597 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2598 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2599 | i_type, & ! external data type for this variable |
---|
| 2600 | i_exist ! test |
---|
| 2601 | INTEGER, DIMENSION(4) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2602 | REAL :: z_missing2 ! missing value of the variable |
---|
| 2603 | !!---------------------------------------------------------------------- |
---|
| 2604 | |
---|
| 2605 | ! Open and test netcdf file |
---|
| 2606 | ! ------------------------- |
---|
| 2607 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2608 | & __LINE__,__MYFILE__) |
---|
| 2609 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2610 | & __LINE__,__MYFILE__) |
---|
| 2611 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2612 | & __LINE__,__MYFILE__) |
---|
| 2613 | IF ( i_type .NE. 5 ) THEN |
---|
| 2614 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2615 | WRITE(*,*)'variable = ',cd_var |
---|
| 2616 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2617 | WRITE(*,*)'The valid external data type is NF_FLOAT : 5' |
---|
| 2618 | ! WRITE(*,*)'CALL abort' |
---|
| 2619 | ! CALL abort |
---|
| 2620 | ENDIF |
---|
| 2621 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2622 | & __LINE__,__MYFILE__) |
---|
| 2623 | IF ( i_ndims .NE. 4 ) THEN |
---|
| 2624 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2625 | WRITE(*,*)'variable = ',cd_var |
---|
| 2626 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2627 | WRITE(*,*)'The valid number of dimension is 4' |
---|
| 2628 | WRITE(*,*)'CALL abort' |
---|
| 2629 | CALL abort |
---|
| 2630 | ENDIF |
---|
| 2631 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2632 | & __LINE__,__MYFILE__) |
---|
| 2633 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2634 | & __LINE__,__MYFILE__) |
---|
| 2635 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2636 | & __LINE__,__MYFILE__) |
---|
| 2637 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(3), len=i_len(3) ) ,& |
---|
| 2638 | & __LINE__,__MYFILE__) |
---|
| 2639 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(4), len=i_len(4) ) ,& |
---|
| 2640 | & __LINE__,__MYFILE__) |
---|
| 2641 | i_shape=SHAPE(p_var) |
---|
| 2642 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) & |
---|
| 2643 | .OR. (i_len(3) .NE. i_shape(3)) .OR. (i_len(4) .NE. i_shape(4)) ) THEN |
---|
| 2644 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2645 | WRITE(*,*)'variable = ',cd_var |
---|
| 2646 | WRITE(*,*)'shape of array = ',SHAPE(p_var) |
---|
| 2647 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2648 | WRITE(*,*)'Dimensions are different' |
---|
| 2649 | WRITE(*,*)'CALL abort' |
---|
| 2650 | CALL abort |
---|
| 2651 | ENDIF |
---|
| 2652 | |
---|
| 2653 | ! Read variable |
---|
| 2654 | ! ------------- |
---|
| 2655 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, p_var ) ,& |
---|
| 2656 | & __LINE__,__MYFILE__) |
---|
| 2657 | |
---|
| 2658 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', z_missing2 ) |
---|
| 2659 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2660 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', z_missing2 ) |
---|
| 2661 | ENDIF |
---|
| 2662 | |
---|
| 2663 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2664 | & __LINE__,__MYFILE__) |
---|
| 2665 | |
---|
| 2666 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2667 | z_missing2 = MAXVAL(p_var) |
---|
| 2668 | ENDIF |
---|
| 2669 | |
---|
| 2670 | IF ( PRESENT(p_missing) ) THEN |
---|
| 2671 | p_missing = z_missing2 |
---|
| 2672 | ELSE |
---|
| 2673 | WHERE(p_var .EQ. z_missing2) p_var = 0.0 |
---|
| 2674 | WHERE((p_var .GT. 0.) .EQV. (p_var .LE. 0.)) p_var = 0.0 |
---|
| 2675 | ENDIF |
---|
| 2676 | |
---|
| 2677 | END SUBROUTINE get_var_4d_r |
---|
| 2678 | |
---|
| 2679 | SUBROUTINE get_var_1d_d ( cd_filename, cd_var, dd_var, dd_missing ) |
---|
| 2680 | !!---------------------------------------------------------------------- |
---|
| 2681 | !! *** ROUTINE get_var_1d_d *** |
---|
| 2682 | !! |
---|
| 2683 | !! ** Purpose : read 1d map of real(kind=dp) reals in a netcdf file |
---|
| 2684 | !! |
---|
| 2685 | !! ** Method : use netcdf fortran library |
---|
| 2686 | !! |
---|
| 2687 | !! ** Action : - get variable informations |
---|
| 2688 | !! - read variable |
---|
| 2689 | !! |
---|
| 2690 | !! Reference : |
---|
| 2691 | !! |
---|
| 2692 | !! History : |
---|
| 2693 | !! 06-05 (N. Daget) original code |
---|
| 2694 | !!---------------------------------------------------------------------- |
---|
| 2695 | !! * Modules used |
---|
| 2696 | |
---|
| 2697 | !! * Library used |
---|
| 2698 | |
---|
| 2699 | !! * arguments |
---|
| 2700 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2701 | cd_filename ! filename |
---|
| 2702 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2703 | cd_var ! variable name |
---|
| 2704 | REAL(KIND=dp), DIMENSION(:), INTENT(out) :: & |
---|
| 2705 | dd_var ! variable to read in netcdf file |
---|
| 2706 | REAL(KIND=dp), OPTIONAL, INTENT(out) :: & |
---|
| 2707 | dd_missing ! missing value of the variable |
---|
| 2708 | |
---|
| 2709 | !! * local declarations |
---|
| 2710 | INTEGER :: & |
---|
| 2711 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2712 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2713 | i_type, & ! external data type for this variable |
---|
| 2714 | i_exist ! test |
---|
| 2715 | INTEGER, DIMENSION(1) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2716 | REAL(KIND=dp) :: dl_missing2 ! missing value of the variable |
---|
| 2717 | !!---------------------------------------------------------------------- |
---|
| 2718 | |
---|
| 2719 | ! Open and test netcdf file |
---|
| 2720 | ! ------------------------- |
---|
| 2721 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2722 | & __LINE__,__MYFILE__) |
---|
| 2723 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2724 | & __LINE__,__MYFILE__) |
---|
| 2725 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2726 | & __LINE__,__MYFILE__) |
---|
| 2727 | IF ( i_type .NE. NF90_DOUBLE ) THEN |
---|
| 2728 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2729 | WRITE(*,*)'variable = ',cd_var |
---|
| 2730 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2731 | WRITE(*,*)'The valid external data type is NF90_DOUBLE : 6' |
---|
| 2732 | ! WRITE(*,*)'CALL abort' |
---|
| 2733 | ! CALL abort |
---|
| 2734 | ENDIF |
---|
| 2735 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2736 | & __LINE__,__MYFILE__) |
---|
| 2737 | IF ( i_ndims .NE. 1 ) THEN |
---|
| 2738 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2739 | WRITE(*,*)'variable = ',cd_var |
---|
| 2740 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2741 | WRITE(*,*)'The valid number of dimension is 1' |
---|
| 2742 | WRITE(*,*)'CALL abort' |
---|
| 2743 | CALL abort |
---|
| 2744 | ENDIF |
---|
| 2745 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2746 | & __LINE__,__MYFILE__) |
---|
| 2747 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2748 | & __LINE__,__MYFILE__) |
---|
| 2749 | i_shape=SHAPE(dd_var) |
---|
| 2750 | IF ( i_len(1) .NE. i_shape(1) ) THEN |
---|
| 2751 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2752 | WRITE(*,*)'variable = ',cd_var |
---|
| 2753 | WRITE(*,*)'shape of array = ',SHAPE(dd_var) |
---|
| 2754 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2755 | WRITE(*,*)'Dimensions are different' |
---|
| 2756 | WRITE(*,*)'CALL abort' |
---|
| 2757 | CALL abort |
---|
| 2758 | ENDIF |
---|
| 2759 | |
---|
| 2760 | ! Read variable |
---|
| 2761 | ! ------------- |
---|
| 2762 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, dd_var ) ,& |
---|
| 2763 | & __LINE__,__MYFILE__) |
---|
| 2764 | |
---|
| 2765 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', dl_missing2 ) |
---|
| 2766 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2767 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', dl_missing2 ) |
---|
| 2768 | ENDIF |
---|
| 2769 | |
---|
| 2770 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2771 | & __LINE__,__MYFILE__) |
---|
| 2772 | |
---|
| 2773 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2774 | dl_missing2 = MAXVAL(dd_var) |
---|
| 2775 | ENDIF |
---|
| 2776 | |
---|
| 2777 | IF ( PRESENT(dd_missing) ) THEN |
---|
| 2778 | dd_missing = dl_missing2 |
---|
| 2779 | ELSE |
---|
| 2780 | WHERE(dd_var .EQ. dl_missing2) dd_var = 0.0 |
---|
| 2781 | WHERE((dd_var .GT. 0.) .EQV. (dd_var .LE. 0.)) dd_var = 0.0 |
---|
| 2782 | ENDIF |
---|
| 2783 | |
---|
| 2784 | END SUBROUTINE get_var_1d_d |
---|
| 2785 | |
---|
| 2786 | SUBROUTINE get_var_2d_d ( cd_filename, cd_var, dd_var, dd_missing ) |
---|
| 2787 | !!---------------------------------------------------------------------- |
---|
| 2788 | !! *** ROUTINE get_var_2d_d *** |
---|
| 2789 | !! |
---|
| 2790 | !! ** Purpose : read 2d map of real(kind=dp) reals in a netcdf file |
---|
| 2791 | !! |
---|
| 2792 | !! ** Method : use netcdf fortran library |
---|
| 2793 | !! |
---|
| 2794 | !! ** Action : - get variable informations |
---|
| 2795 | !! - read variable |
---|
| 2796 | !! |
---|
| 2797 | !! Reference : |
---|
| 2798 | !! |
---|
| 2799 | !! History : |
---|
| 2800 | !! 06-05 (N. Daget) original code |
---|
| 2801 | !!---------------------------------------------------------------------- |
---|
| 2802 | !! * Modules used |
---|
| 2803 | |
---|
| 2804 | !! * Library used |
---|
| 2805 | |
---|
| 2806 | !! * arguments |
---|
| 2807 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2808 | cd_filename ! filename |
---|
| 2809 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2810 | cd_var ! variable name |
---|
| 2811 | REAL(KIND=dp), DIMENSION(:,:), INTENT(out) :: & |
---|
| 2812 | dd_var ! variable to read in netcdf file |
---|
| 2813 | REAL(KIND=dp), OPTIONAL, INTENT(out) :: & |
---|
| 2814 | dd_missing ! missing value of the variable |
---|
| 2815 | |
---|
| 2816 | !! * local declarations |
---|
| 2817 | INTEGER :: & |
---|
| 2818 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2819 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2820 | i_type, & ! external data type for this variable |
---|
| 2821 | i_exist ! test |
---|
| 2822 | INTEGER, DIMENSION(2) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2823 | REAL(KIND=dp) :: dl_missing2 ! missing value of the variable |
---|
| 2824 | !!---------------------------------------------------------------------- |
---|
| 2825 | |
---|
| 2826 | ! Open and test netcdf file |
---|
| 2827 | ! ------------------------- |
---|
| 2828 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2829 | & __LINE__,__MYFILE__) |
---|
| 2830 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2831 | & __LINE__,__MYFILE__) |
---|
| 2832 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2833 | & __LINE__,__MYFILE__) |
---|
| 2834 | IF ( i_type .NE. NF90_DOUBLE ) THEN |
---|
| 2835 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2836 | WRITE(*,*)'variable = ',cd_var |
---|
| 2837 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2838 | WRITE(*,*)'The valid external data type is NF90_DOUBLE : 6' |
---|
| 2839 | ! WRITE(*,*)'CALL abort' |
---|
| 2840 | ! CALL abort |
---|
| 2841 | ENDIF |
---|
| 2842 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2843 | & __LINE__,__MYFILE__) |
---|
| 2844 | IF ( i_ndims .NE. 2 ) THEN |
---|
| 2845 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2846 | WRITE(*,*)'variable = ',cd_var |
---|
| 2847 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2848 | WRITE(*,*)'The valid number of dimension is 2' |
---|
| 2849 | WRITE(*,*)'CALL abort' |
---|
| 2850 | CALL abort |
---|
| 2851 | ENDIF |
---|
| 2852 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2853 | & __LINE__,__MYFILE__) |
---|
| 2854 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2855 | & __LINE__,__MYFILE__) |
---|
| 2856 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2857 | & __LINE__,__MYFILE__) |
---|
| 2858 | i_shape=SHAPE(dd_var) |
---|
| 2859 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) ) THEN |
---|
| 2860 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2861 | WRITE(*,*)'variable = ',cd_var |
---|
| 2862 | WRITE(*,*)'shape of array = ',SHAPE(dd_var) |
---|
| 2863 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2864 | WRITE(*,*)'Dimensions are different' |
---|
| 2865 | WRITE(*,*)'CALL abort' |
---|
| 2866 | CALL abort |
---|
| 2867 | ENDIF |
---|
| 2868 | |
---|
| 2869 | ! Read variable |
---|
| 2870 | ! ------------- |
---|
| 2871 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, dd_var ) ,& |
---|
| 2872 | & __LINE__,__MYFILE__) |
---|
| 2873 | |
---|
| 2874 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', dl_missing2 ) |
---|
| 2875 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2876 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', dl_missing2 ) |
---|
| 2877 | ENDIF |
---|
| 2878 | |
---|
| 2879 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2880 | & __LINE__,__MYFILE__) |
---|
| 2881 | |
---|
| 2882 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2883 | dl_missing2 = MAXVAL(dd_var) |
---|
| 2884 | ENDIF |
---|
| 2885 | |
---|
| 2886 | IF ( PRESENT(dd_missing) ) THEN |
---|
| 2887 | dd_missing = dl_missing2 |
---|
| 2888 | ELSE |
---|
| 2889 | WHERE(dd_var .EQ. dl_missing2) dd_var = 0.0 |
---|
| 2890 | WHERE((dd_var .GT. 0.) .EQV. (dd_var .LE. 0.)) dd_var = 0.0 |
---|
| 2891 | ENDIF |
---|
| 2892 | |
---|
| 2893 | END SUBROUTINE get_var_2d_d |
---|
| 2894 | |
---|
| 2895 | SUBROUTINE get_var_3d_d ( cd_filename, cd_var, dd_var, dd_missing ) |
---|
| 2896 | !!---------------------------------------------------------------------- |
---|
| 2897 | !! *** ROUTINE get_var_3d_d *** |
---|
| 2898 | !! |
---|
| 2899 | !! ** Purpose : read 3d map of real(kind=dp) reals in a netcdf file |
---|
| 2900 | !! |
---|
| 2901 | !! ** Method : use netcdf fortran library |
---|
| 2902 | !! |
---|
| 2903 | !! ** Action : - get variable informations |
---|
| 2904 | !! - read variable |
---|
| 2905 | !! |
---|
| 2906 | !! Reference : |
---|
| 2907 | !! |
---|
| 2908 | !! History : |
---|
| 2909 | !! 06-05 (N. Daget) original code |
---|
| 2910 | !!---------------------------------------------------------------------- |
---|
| 2911 | !! * Modules used |
---|
| 2912 | |
---|
| 2913 | !! * Library used |
---|
| 2914 | |
---|
| 2915 | !! * arguments |
---|
| 2916 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 2917 | cd_filename ! filename |
---|
| 2918 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 2919 | cd_var ! variable name |
---|
| 2920 | REAL(KIND=dp), DIMENSION(:,:,:), INTENT(out) :: & |
---|
| 2921 | dd_var ! variable to read in netcdf file |
---|
| 2922 | REAL(KIND=dp), OPTIONAL, INTENT(out) :: & |
---|
| 2923 | dd_missing ! missing value of the variable |
---|
| 2924 | |
---|
| 2925 | !! * local declarations |
---|
| 2926 | INTEGER :: & |
---|
| 2927 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 2928 | i_ndims, & ! Number of dimensions for this variable |
---|
| 2929 | i_type, & ! external data type for this variable |
---|
| 2930 | i_exist ! test |
---|
| 2931 | INTEGER, DIMENSION(3) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 2932 | REAL(KIND=dp) :: dl_missing2 ! missing value of the variable |
---|
| 2933 | !!---------------------------------------------------------------------- |
---|
| 2934 | |
---|
| 2935 | ! Open and test netcdf file |
---|
| 2936 | ! ------------------------- |
---|
| 2937 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 2938 | & __LINE__,__MYFILE__) |
---|
| 2939 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 2940 | & __LINE__,__MYFILE__) |
---|
| 2941 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 2942 | & __LINE__,__MYFILE__) |
---|
| 2943 | IF ( i_type .NE. NF90_DOUBLE ) THEN |
---|
| 2944 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2945 | WRITE(*,*)'variable = ',cd_var |
---|
| 2946 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 2947 | WRITE(*,*)'The valid external data type is NF90_DOUBLE : 6' |
---|
| 2948 | ! WRITE(*,*)'CALL abort' |
---|
| 2949 | ! CALL abort |
---|
| 2950 | ENDIF |
---|
| 2951 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 2952 | & __LINE__,__MYFILE__) |
---|
| 2953 | IF ( i_ndims .NE. 3 ) THEN |
---|
| 2954 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2955 | WRITE(*,*)'variable = ',cd_var |
---|
| 2956 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 2957 | WRITE(*,*)'The valid number of dimension is 3' |
---|
| 2958 | WRITE(*,*)'CALL abort' |
---|
| 2959 | CALL abort |
---|
| 2960 | ENDIF |
---|
| 2961 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 2962 | & __LINE__,__MYFILE__) |
---|
| 2963 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 2964 | & __LINE__,__MYFILE__) |
---|
| 2965 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 2966 | & __LINE__,__MYFILE__) |
---|
| 2967 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(3), len=i_len(3) ) ,& |
---|
| 2968 | & __LINE__,__MYFILE__) |
---|
| 2969 | i_shape=SHAPE(dd_var) |
---|
| 2970 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) & |
---|
| 2971 | .OR. (i_len(3) .NE. i_shape(3)) ) THEN |
---|
| 2972 | WRITE(*,*)'filename = ',cd_filename |
---|
| 2973 | WRITE(*,*)'variable = ',cd_var |
---|
| 2974 | WRITE(*,*)'shape of array = ',SHAPE(dd_var) |
---|
| 2975 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 2976 | WRITE(*,*)'Dimensions are different' |
---|
| 2977 | WRITE(*,*)'CALL abort' |
---|
| 2978 | CALL abort |
---|
| 2979 | ENDIF |
---|
| 2980 | |
---|
| 2981 | ! Read variable |
---|
| 2982 | ! ------------- |
---|
| 2983 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, dd_var ) ,& |
---|
| 2984 | & __LINE__,__MYFILE__) |
---|
| 2985 | |
---|
| 2986 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', dl_missing2 ) |
---|
| 2987 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2988 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', dl_missing2 ) |
---|
| 2989 | ENDIF |
---|
| 2990 | |
---|
| 2991 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 2992 | & __LINE__,__MYFILE__) |
---|
| 2993 | |
---|
| 2994 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 2995 | dl_missing2 = MAXVAL(dd_var) |
---|
| 2996 | ENDIF |
---|
| 2997 | |
---|
| 2998 | IF ( PRESENT(dd_missing) ) THEN |
---|
| 2999 | dd_missing = dl_missing2 |
---|
| 3000 | ELSE |
---|
| 3001 | WHERE(dd_var .EQ. dl_missing2) dd_var = 0.0 |
---|
| 3002 | WHERE((dd_var .GT. 0.) .EQV. (dd_var .LE. 0.)) dd_var = 0.0 |
---|
| 3003 | ENDIF |
---|
| 3004 | |
---|
| 3005 | END SUBROUTINE get_var_3d_d |
---|
| 3006 | |
---|
| 3007 | SUBROUTINE get_var_4d_d ( cd_filename, cd_var, dd_var, dd_missing ) |
---|
| 3008 | !!---------------------------------------------------------------------- |
---|
| 3009 | !! *** ROUTINE get_var_4d_d *** |
---|
| 3010 | !! |
---|
| 3011 | !! ** Purpose : read 4d map of real(kind=dp) reals in a netcdf file |
---|
| 3012 | !! |
---|
| 3013 | !! ** Method : use netcdf fortran library |
---|
| 3014 | !! |
---|
| 3015 | !! ** Action : - get variable informations |
---|
| 3016 | !! - read variable |
---|
| 3017 | !! |
---|
| 3018 | !! Reference : |
---|
| 3019 | !! |
---|
| 3020 | !! History : |
---|
| 3021 | !! 06-05 (N. Daget) original code |
---|
| 3022 | !!---------------------------------------------------------------------- |
---|
| 3023 | !! * Modules used |
---|
| 3024 | |
---|
| 3025 | !! * Library used |
---|
| 3026 | |
---|
| 3027 | !! * arguments |
---|
| 3028 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 3029 | cd_filename ! filename |
---|
| 3030 | CHARACTER(len=80), OPTIONAL, INTENT(in) :: & |
---|
| 3031 | cd_var ! variable name |
---|
| 3032 | REAL(KIND=dp), DIMENSION(:,:,:,:), INTENT(out) :: & |
---|
| 3033 | dd_var ! variable to read in netcdf file |
---|
| 3034 | REAL(KIND=dp), OPTIONAL, INTENT(out) :: & |
---|
| 3035 | dd_missing ! missing value of the variable |
---|
| 3036 | |
---|
| 3037 | !! * local declarations |
---|
| 3038 | INTEGER :: & |
---|
| 3039 | i_file_id, i_var_id, & ! file and variable identifier |
---|
| 3040 | i_ndims, & ! Number of dimensions for this variable |
---|
| 3041 | i_type, & ! external data type for this variable |
---|
| 3042 | i_exist ! test |
---|
| 3043 | INTEGER, DIMENSION(4) :: i_dimid, i_len, i_shape ! dimensions of the variable |
---|
| 3044 | REAL(KIND=dp) :: dl_missing2 ! missing value of the variable |
---|
| 3045 | !!---------------------------------------------------------------------- |
---|
| 3046 | |
---|
| 3047 | ! Open and test netcdf file |
---|
| 3048 | ! ------------------------- |
---|
| 3049 | CALL nchdlerr( nf90_open( cd_filename, nf90_nowrite, i_file_id ) ,& |
---|
| 3050 | & __LINE__,__MYFILE__) |
---|
| 3051 | CALL nchdlerr( nf90_inq_varid( i_file_id, cd_var, i_var_id ) ,& |
---|
| 3052 | & __LINE__,__MYFILE__) |
---|
| 3053 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, xtype=i_type ) ,& |
---|
| 3054 | & __LINE__,__MYFILE__) |
---|
| 3055 | IF ( i_type .NE. NF90_DOUBLE ) THEN |
---|
| 3056 | WRITE(*,*)'filename = ',cd_filename |
---|
| 3057 | WRITE(*,*)'variable = ',cd_var |
---|
| 3058 | WRITE(*,*)'External type for this variable = ',i_type |
---|
| 3059 | WRITE(*,*)'The valid external data type is NF90_DOUBLE : 6' |
---|
| 3060 | ! WRITE(*,*)'CALL abort' |
---|
| 3061 | ! CALL abort |
---|
| 3062 | ENDIF |
---|
| 3063 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, ndims=i_ndims ) ,& |
---|
| 3064 | & __LINE__,__MYFILE__) |
---|
| 3065 | IF ( i_ndims .NE. 4 ) THEN |
---|
| 3066 | WRITE(*,*)'filename = ',cd_filename |
---|
| 3067 | WRITE(*,*)'variable = ',cd_var |
---|
| 3068 | WRITE(*,*)'Number of dimensions for this variable = ',i_ndims |
---|
| 3069 | WRITE(*,*)'The valid number of dimension is 4' |
---|
| 3070 | WRITE(*,*)'CALL abort' |
---|
| 3071 | CALL abort |
---|
| 3072 | ENDIF |
---|
| 3073 | CALL nchdlerr( nf90_inquire_variable( i_file_id, i_var_id, dimids=i_dimid ) ,& |
---|
| 3074 | & __LINE__,__MYFILE__) |
---|
| 3075 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(1), len=i_len(1) ) ,& |
---|
| 3076 | & __LINE__,__MYFILE__) |
---|
| 3077 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(2), len=i_len(2) ) ,& |
---|
| 3078 | & __LINE__,__MYFILE__) |
---|
| 3079 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(3), len=i_len(3) ) ,& |
---|
| 3080 | & __LINE__,__MYFILE__) |
---|
| 3081 | CALL nchdlerr( nf90_inquire_dimension( i_file_id, i_dimid(4), len=i_len(4) ) ,& |
---|
| 3082 | & __LINE__,__MYFILE__) |
---|
| 3083 | i_shape=SHAPE(dd_var) |
---|
| 3084 | IF ( (i_len(1) .NE. i_shape(1)) .OR. (i_len(2) .NE. i_shape(2)) & |
---|
| 3085 | .OR. (i_len(3) .NE. i_shape(3)) .OR. (i_len(4) .NE. i_shape(4)) ) THEN |
---|
| 3086 | WRITE(*,*)'filename = ',cd_filename |
---|
| 3087 | WRITE(*,*)'variable = ',cd_var |
---|
| 3088 | WRITE(*,*)'shape of array = ',SHAPE(dd_var) |
---|
| 3089 | WRITE(*,*)'Dimension length of variable = ',i_len |
---|
| 3090 | WRITE(*,*)'Dimensions are different' |
---|
| 3091 | WRITE(*,*)'CALL abort' |
---|
| 3092 | CALL abort |
---|
| 3093 | ENDIF |
---|
| 3094 | |
---|
| 3095 | ! Read variable |
---|
| 3096 | ! ------------- |
---|
| 3097 | CALL nchdlerr( nf90_get_var( i_file_id, i_var_id, dd_var ) ,& |
---|
| 3098 | & __LINE__,__MYFILE__) |
---|
| 3099 | |
---|
| 3100 | i_exist = nf90_get_att( i_file_id, i_var_id, '_FillValue', dl_missing2 ) |
---|
| 3101 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 3102 | i_exist = nf90_get_att( i_file_id, i_var_id, 'missing_value', dl_missing2 ) |
---|
| 3103 | ENDIF |
---|
| 3104 | |
---|
| 3105 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 3106 | & __LINE__,__MYFILE__) |
---|
| 3107 | |
---|
| 3108 | IF ( i_exist .NE. nf90_noerr ) THEN |
---|
| 3109 | dl_missing2 = MAXVAL(dd_var) |
---|
| 3110 | ENDIF |
---|
| 3111 | |
---|
| 3112 | IF ( PRESENT(dd_missing) ) THEN |
---|
| 3113 | dd_missing = dl_missing2 |
---|
| 3114 | ELSE |
---|
| 3115 | WHERE(dd_var .EQ. dl_missing2) dd_var = 0.0 |
---|
| 3116 | WHERE((dd_var .GT. 0.) .EQV. (dd_var .LE. 0.)) dd_var = 0.0 |
---|
| 3117 | ENDIF |
---|
| 3118 | |
---|
| 3119 | END SUBROUTINE get_var_4d_d |
---|
| 3120 | |
---|
| 3121 | !!====================================================================== |
---|
| 3122 | |
---|
| 3123 | SUBROUTINE put_coord_r ( cd_filename, p_lon, p_lat, p_dep, cd_descr ) |
---|
| 3124 | !!---------------------------------------------------------------------- |
---|
| 3125 | !! *** ROUTINE put_coord_r *** |
---|
| 3126 | !! |
---|
| 3127 | !! ** Purpose : write coordinates as reals in a netcdf file |
---|
| 3128 | !! |
---|
| 3129 | !! ** Method : use netcdf fortran library |
---|
| 3130 | !! |
---|
| 3131 | !! ** Action : - get variable informations |
---|
| 3132 | !! - (re)define variable |
---|
| 3133 | !! - put variable in netcdf file |
---|
| 3134 | !! |
---|
| 3135 | !! Reference : |
---|
| 3136 | !! |
---|
| 3137 | !! History : |
---|
| 3138 | !! 06-05 (N. Daget) original code |
---|
| 3139 | !!---------------------------------------------------------------------- |
---|
| 3140 | !! * Modules used |
---|
| 3141 | |
---|
| 3142 | !! * Library used |
---|
| 3143 | |
---|
| 3144 | !! * arguments |
---|
| 3145 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 3146 | cd_filename ! filename |
---|
| 3147 | REAL(KIND=sp), DIMENSION(:,:), INTENT(in) :: & |
---|
| 3148 | p_lon, p_lat ! longitude and latitude |
---|
| 3149 | REAL(KIND=sp), DIMENSION(:), OPTIONAL, INTENT(in) :: & |
---|
| 3150 | p_dep ! depth |
---|
| 3151 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 3152 | cd_descr ! description of file contents |
---|
| 3153 | |
---|
| 3154 | !! * local declarations |
---|
| 3155 | LOGICAL :: llexist ! test |
---|
| 3156 | INTEGER :: & |
---|
| 3157 | i_file_id, i_var_id, & ! file and variable identifiers |
---|
| 3158 | i_dim_x_id, i_dim_y_id, i_dim_z_id, & ! dimension identifiers |
---|
| 3159 | i_var_exist ! test |
---|
| 3160 | INTEGER, DIMENSION(2) :: i_dimxy ! dimensions of longitude and latitude |
---|
| 3161 | INTEGER, DIMENSION(1) :: i_dimz ! dimension of depth |
---|
| 3162 | INTEGER, DIMENSION(3) :: i_dim ! dimensions for netcdf file |
---|
| 3163 | REAL :: & |
---|
| 3164 | z_minx, z_maxx, z_miny, z_maxy, z_minz, z_maxz ! minima and maxima |
---|
| 3165 | !!---------------------------------------------------------------------- |
---|
| 3166 | |
---|
| 3167 | ! Read dimensions and compute min and max |
---|
| 3168 | ! --------------------------------------- |
---|
| 3169 | i_dimxy = SHAPE( p_lon ) |
---|
| 3170 | z_minx = MINVAL( p_lon ) |
---|
| 3171 | z_maxx = MAXVAL( p_lon ) |
---|
| 3172 | z_miny = MINVAL( p_lat ) |
---|
| 3173 | z_maxy = MAXVAL( p_lat ) |
---|
| 3174 | |
---|
| 3175 | IF ( PRESENT( p_dep ) ) THEN |
---|
| 3176 | i_dimz = SHAPE( p_dep ) |
---|
| 3177 | z_minz = MINVAL( p_dep ) |
---|
| 3178 | z_maxz = MAXVAL( p_dep ) |
---|
| 3179 | ENDIF |
---|
| 3180 | |
---|
| 3181 | ! Open or create netcdf file |
---|
| 3182 | ! -------------------------- |
---|
| 3183 | INQUIRE( FILE=TRIM(cd_filename), EXIST=llexist ) |
---|
| 3184 | IF ( .NOT. llexist ) THEN |
---|
| 3185 | IF ( PRESENT( p_dep ) ) THEN |
---|
| 3186 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 3187 | CALL create_map ( cd_filename, i_dimxy, i_dimz, cd_descr=cd_descr ) |
---|
| 3188 | ELSE |
---|
| 3189 | CALL create_map ( cd_filename, i_dimxy, i_dimz ) |
---|
| 3190 | ENDIF |
---|
| 3191 | ELSE |
---|
| 3192 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 3193 | CALL create_map ( cd_filename, i_dimxy, cd_descr=cd_descr ) |
---|
| 3194 | ELSE |
---|
| 3195 | CALL create_map ( cd_filename, i_dimxy ) |
---|
| 3196 | ENDIF |
---|
| 3197 | ENDIF |
---|
| 3198 | ENDIF |
---|
| 3199 | |
---|
| 3200 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 3201 | & __LINE__,__MYFILE__) |
---|
| 3202 | |
---|
| 3203 | ! Add longitude, latitude and depth |
---|
| 3204 | ! --------------------------------- |
---|
| 3205 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'x', i_dim_x_id ) ,& |
---|
| 3206 | & __LINE__,__MYFILE__) |
---|
| 3207 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'y', i_dim_y_id ) ,& |
---|
| 3208 | & __LINE__,__MYFILE__) |
---|
| 3209 | i_dim(1) = i_dim_x_id |
---|
| 3210 | i_dim(2) = i_dim_y_id |
---|
| 3211 | IF ( PRESENT( p_dep ) ) THEN |
---|
| 3212 | i_var_exist = nf90_inq_dimid( i_file_id, 'z', i_dim_z_id ) |
---|
| 3213 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3214 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3215 | & __LINE__,__MYFILE__) |
---|
| 3216 | CALL nchdlerr( nf90_def_dim( i_file_id, 'z', i_dimz(1), i_dim_z_id ) ,& |
---|
| 3217 | & __LINE__,__MYFILE__) |
---|
| 3218 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3219 | & __LINE__,__MYFILE__) |
---|
| 3220 | ENDIF |
---|
| 3221 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'z', i_dim_z_id ) ,& |
---|
| 3222 | & __LINE__,__MYFILE__) |
---|
| 3223 | i_dim(3) = i_dim_z_id |
---|
| 3224 | ENDIF |
---|
| 3225 | |
---|
| 3226 | i_var_exist = nf90_inq_varid( i_file_id, "longitude", i_var_id ) |
---|
| 3227 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3228 | & __LINE__,__MYFILE__) |
---|
| 3229 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3230 | CALL nchdlerr( nf90_def_var( i_file_id, "longitude", nf90_real, (/i_dim(1),i_dim(2)/), i_var_id ) ,& |
---|
| 3231 | & __LINE__,__MYFILE__) |
---|
| 3232 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'data_type', 'float' ) ,& |
---|
| 3233 | & __LINE__,__MYFILE__) |
---|
| 3234 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', 'longitude' ) ,& |
---|
| 3235 | & __LINE__,__MYFILE__) |
---|
| 3236 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', 'longitude' ) ,& |
---|
| 3237 | & __LINE__,__MYFILE__) |
---|
| 3238 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'units', 'degrees_east' ),__LINE__,__MYFILE__ ) |
---|
| 3239 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'axis', 'Y' ) ,& |
---|
| 3240 | & __LINE__,__MYFILE__) |
---|
| 3241 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'positive', 'east' ) ,& |
---|
| 3242 | & __LINE__,__MYFILE__) |
---|
| 3243 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', 9.e+19 ) ,& |
---|
| 3244 | & __LINE__,__MYFILE__) |
---|
| 3245 | ENDIF |
---|
| 3246 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_minx ) ,& |
---|
| 3247 | & __LINE__,__MYFILE__) |
---|
| 3248 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_maxx ) ,& |
---|
| 3249 | & __LINE__,__MYFILE__) |
---|
| 3250 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3251 | & __LINE__,__MYFILE__) |
---|
| 3252 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, p_lon) ,& |
---|
| 3253 | & __LINE__,__MYFILE__) |
---|
| 3254 | |
---|
| 3255 | i_var_exist = nf90_inq_varid( i_file_id, "latitude", i_var_id ) |
---|
| 3256 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3257 | & __LINE__,__MYFILE__) |
---|
| 3258 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3259 | CALL nchdlerr( nf90_def_var( i_file_id, "latitude", nf90_real, (/i_dim(1),i_dim(2)/), i_var_id ) ,& |
---|
| 3260 | & __LINE__,__MYFILE__) |
---|
| 3261 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'data_type', 'float' ) ,& |
---|
| 3262 | & __LINE__,__MYFILE__) |
---|
| 3263 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', 'latitude' ) ,& |
---|
| 3264 | & __LINE__,__MYFILE__) |
---|
| 3265 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', 'latitude' ) ,& |
---|
| 3266 | & __LINE__,__MYFILE__) |
---|
| 3267 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'units', 'degrees_north' ),__LINE__,__MYFILE__ ) |
---|
| 3268 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'axis', 'X' ) ,& |
---|
| 3269 | & __LINE__,__MYFILE__) |
---|
| 3270 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'positive', 'north' ) ,& |
---|
| 3271 | & __LINE__,__MYFILE__) |
---|
| 3272 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', 9.e+19 ) ,& |
---|
| 3273 | & __LINE__,__MYFILE__) |
---|
| 3274 | ENDIF |
---|
| 3275 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_miny ) ,& |
---|
| 3276 | & __LINE__,__MYFILE__) |
---|
| 3277 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_maxy ) ,& |
---|
| 3278 | & __LINE__,__MYFILE__) |
---|
| 3279 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3280 | & __LINE__,__MYFILE__) |
---|
| 3281 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, p_lat),__LINE__,__MYFILE__ ) |
---|
| 3282 | |
---|
| 3283 | IF ( PRESENT( p_dep ) ) THEN |
---|
| 3284 | i_var_exist = nf90_inq_varid( i_file_id, "depth", i_var_id ) |
---|
| 3285 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3286 | & __LINE__,__MYFILE__) |
---|
| 3287 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3288 | CALL nchdlerr( nf90_def_var( i_file_id, "depth", nf90_real, i_dim(3), i_var_id ) ,& |
---|
| 3289 | & __LINE__,__MYFILE__) |
---|
| 3290 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'data_type', 'float' ) ,& |
---|
| 3291 | & __LINE__,__MYFILE__) |
---|
| 3292 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', 'depth' ) ,& |
---|
| 3293 | & __LINE__,__MYFILE__) |
---|
| 3294 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', 'depth below the surface') ,& |
---|
| 3295 | & __LINE__,__MYFILE__) |
---|
| 3296 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'units', 'm' ) ,& |
---|
| 3297 | & __LINE__,__MYFILE__) |
---|
| 3298 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'unit_long', 'meter' ) ,& |
---|
| 3299 | & __LINE__,__MYFILE__) |
---|
| 3300 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'axis', 'Z' ) ,& |
---|
| 3301 | & __LINE__,__MYFILE__) |
---|
| 3302 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'positive', 'down' ) ,& |
---|
| 3303 | & __LINE__,__MYFILE__) |
---|
| 3304 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', 9.e+19 ),__LINE__,__MYFILE__ ) |
---|
| 3305 | ENDIF |
---|
| 3306 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', z_minz ) ,& |
---|
| 3307 | & __LINE__,__MYFILE__) |
---|
| 3308 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', z_maxz ) ,& |
---|
| 3309 | & __LINE__,__MYFILE__) |
---|
| 3310 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3311 | & __LINE__,__MYFILE__) |
---|
| 3312 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, p_dep) ,& |
---|
| 3313 | & __LINE__,__MYFILE__) |
---|
| 3314 | ENDIF |
---|
| 3315 | |
---|
| 3316 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 3317 | & __LINE__,__MYFILE__) |
---|
| 3318 | |
---|
| 3319 | END SUBROUTINE put_coord_r |
---|
| 3320 | |
---|
| 3321 | SUBROUTINE put_coord_d ( cd_filename, dd_lon, dd_lat, dd_dep, cd_descr ) |
---|
| 3322 | !!---------------------------------------------------------------------- |
---|
| 3323 | !! *** ROUTINE put_coord_d *** |
---|
| 3324 | !! |
---|
| 3325 | !! ** Purpose : write coordinates as real(kind=dp) in a netcdf file |
---|
| 3326 | !! |
---|
| 3327 | !! ** Method : use netcdf fortran library |
---|
| 3328 | !! |
---|
| 3329 | !! ** Action : - get variable informations |
---|
| 3330 | !! - (re)define variable |
---|
| 3331 | !! - put variable in netcdf file |
---|
| 3332 | !! |
---|
| 3333 | !! Reference : |
---|
| 3334 | !! |
---|
| 3335 | !! History : |
---|
| 3336 | !! 06-05 (N. Daget) original code |
---|
| 3337 | !!---------------------------------------------------------------------- |
---|
| 3338 | !! * Modules used |
---|
| 3339 | |
---|
| 3340 | !! * Library used |
---|
| 3341 | |
---|
| 3342 | !! * arguments |
---|
| 3343 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 3344 | cd_filename ! filename |
---|
| 3345 | REAL(KIND=dp), DIMENSION(:,:), INTENT(in) :: & |
---|
| 3346 | dd_lon, dd_lat ! longitude and latitude |
---|
| 3347 | REAL(KIND=dp), DIMENSION(:), OPTIONAL, INTENT(in) :: & |
---|
| 3348 | dd_dep ! depth |
---|
| 3349 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 3350 | cd_descr ! description of file contents |
---|
| 3351 | |
---|
| 3352 | !! * local declarations |
---|
| 3353 | LOGICAL :: llexist ! test |
---|
| 3354 | INTEGER :: & |
---|
| 3355 | i_file_id, i_var_id, & ! file and variable identifiers |
---|
| 3356 | i_dim_x_id, i_dim_y_id, i_dim_z_id, & ! dimension identifiers |
---|
| 3357 | i_var_exist ! test |
---|
| 3358 | INTEGER, DIMENSION(2) :: i_dimxy ! dimensions of longitude and latitude |
---|
| 3359 | INTEGER, DIMENSION(1) :: i_dimz ! dimension of depth |
---|
| 3360 | INTEGER, DIMENSION(3) :: i_dim ! dimensions for netcdf file |
---|
| 3361 | REAL(KIND=dp) :: & |
---|
| 3362 | dl_minx, dl_maxx, dl_miny, dl_maxy, & |
---|
| 3363 | dl_minz, dl_maxz, & ! minima and maxima |
---|
| 3364 | dl_missing ! missing value |
---|
| 3365 | !!---------------------------------------------------------------------- |
---|
| 3366 | |
---|
| 3367 | ! Read dimensions and compute min and max |
---|
| 3368 | ! --------------------------------------- |
---|
| 3369 | i_dimxy = SHAPE( dd_lon ) |
---|
| 3370 | dl_minx = MINVAL( dd_lon ) |
---|
| 3371 | dl_maxx = MAXVAL( dd_lon ) |
---|
| 3372 | dl_miny = MINVAL( dd_lat ) |
---|
| 3373 | dl_maxy = MAXVAL( dd_lat ) |
---|
| 3374 | |
---|
| 3375 | IF ( PRESENT( dd_dep ) ) THEN |
---|
| 3376 | i_dimz = SHAPE( dd_dep ) |
---|
| 3377 | dl_minz = MINVAL(dd_dep) |
---|
| 3378 | dl_maxz = MAXVAL(dd_dep) |
---|
| 3379 | ENDIF |
---|
| 3380 | |
---|
| 3381 | ! Open or create netcdf file |
---|
| 3382 | ! -------------------------- |
---|
| 3383 | INQUIRE( FILE=TRIM(cd_filename), EXIST=llexist ) |
---|
| 3384 | IF ( .NOT. llexist ) THEN |
---|
| 3385 | IF ( PRESENT( dd_dep ) ) THEN |
---|
| 3386 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 3387 | CALL create_map ( cd_filename, i_dimxy, i_dimz, cd_descr=cd_descr ) |
---|
| 3388 | ELSE |
---|
| 3389 | CALL create_map ( cd_filename, i_dimxy, i_dimz ) |
---|
| 3390 | ENDIF |
---|
| 3391 | ELSE |
---|
| 3392 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 3393 | CALL create_map ( cd_filename, i_dimxy, cd_descr=cd_descr ) |
---|
| 3394 | ELSE |
---|
| 3395 | CALL create_map ( cd_filename, i_dimxy ) |
---|
| 3396 | ENDIF |
---|
| 3397 | ENDIF |
---|
| 3398 | ENDIF |
---|
| 3399 | |
---|
| 3400 | CALL nchdlerr( nf90_open( cd_filename, nf90_write, i_file_id ) ,& |
---|
| 3401 | & __LINE__,__MYFILE__) |
---|
| 3402 | |
---|
| 3403 | ! Add longitude, latitude and depth |
---|
| 3404 | ! --------------------------------- |
---|
| 3405 | dl_missing = 9.e+19_8 |
---|
| 3406 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'x', i_dim_x_id ) ,& |
---|
| 3407 | & __LINE__,__MYFILE__) |
---|
| 3408 | CALL nchdlerr( nf90_inq_dimid( i_file_id, 'y', i_dim_y_id ) ,& |
---|
| 3409 | & __LINE__,__MYFILE__) |
---|
| 3410 | i_dim(1) = i_dim_x_id |
---|
| 3411 | i_dim(2) = i_dim_y_id |
---|
| 3412 | IF ( PRESENT( dd_dep ) ) THEN |
---|
| 3413 | i_var_exist = nf90_inq_dimid( i_file_id, 'z', i_dim_z_id ) |
---|
| 3414 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3415 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3416 | & __LINE__,__MYFILE__) |
---|
| 3417 | CALL nchdlerr( nf90_def_dim( i_file_id, 'z', i_dimz(1), i_dim_z_id ) ,& |
---|
| 3418 | & __LINE__,__MYFILE__) |
---|
| 3419 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3420 | & __LINE__,__MYFILE__) |
---|
| 3421 | ENDIF |
---|
| 3422 | i_dim(3) = i_dim_z_id |
---|
| 3423 | ENDIF |
---|
| 3424 | |
---|
| 3425 | i_var_exist = nf90_inq_varid( i_file_id, "longitude", i_var_id ) |
---|
| 3426 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3427 | & __LINE__,__MYFILE__) |
---|
| 3428 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3429 | CALL nchdlerr( nf90_def_var( i_file_id, "longitude", nf90_double, (/i_dim(1),i_dim(2)/), i_var_id ) ,& |
---|
| 3430 | & __LINE__,__MYFILE__) |
---|
| 3431 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'data_type', 'float' ) ,& |
---|
| 3432 | & __LINE__,__MYFILE__) |
---|
| 3433 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', 'longitude' ) ,& |
---|
| 3434 | & __LINE__,__MYFILE__) |
---|
| 3435 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', 'longitude' ) ,& |
---|
| 3436 | & __LINE__,__MYFILE__) |
---|
| 3437 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'units', 'degrees_east' ),__LINE__,__MYFILE__ ) |
---|
| 3438 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'axis', 'Y' ) ,& |
---|
| 3439 | & __LINE__,__MYFILE__) |
---|
| 3440 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'positive', 'east' ) ,& |
---|
| 3441 | & __LINE__,__MYFILE__) |
---|
| 3442 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', dl_missing ) ,& |
---|
| 3443 | & __LINE__,__MYFILE__) |
---|
| 3444 | ENDIF |
---|
| 3445 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_minx ) ,& |
---|
| 3446 | & __LINE__,__MYFILE__) |
---|
| 3447 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_maxx ) ,& |
---|
| 3448 | & __LINE__,__MYFILE__) |
---|
| 3449 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3450 | & __LINE__,__MYFILE__) |
---|
| 3451 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, dd_lon) ,& |
---|
| 3452 | & __LINE__,__MYFILE__) |
---|
| 3453 | |
---|
| 3454 | i_var_exist = nf90_inq_varid( i_file_id, "latitude", i_var_id ) |
---|
| 3455 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3456 | & __LINE__,__MYFILE__) |
---|
| 3457 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3458 | CALL nchdlerr( nf90_def_var( i_file_id, "latitude", nf90_double, (/i_dim(1),i_dim(2)/), i_var_id ) ,& |
---|
| 3459 | & __LINE__,__MYFILE__) |
---|
| 3460 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'data_type', 'float' ) ,& |
---|
| 3461 | & __LINE__,__MYFILE__) |
---|
| 3462 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', 'latitude' ) ,& |
---|
| 3463 | & __LINE__,__MYFILE__) |
---|
| 3464 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', 'latitude' ) ,& |
---|
| 3465 | & __LINE__,__MYFILE__) |
---|
| 3466 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'units', 'degrees_north' ),__LINE__,__MYFILE__ ) |
---|
| 3467 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'axis', 'X' ) ,& |
---|
| 3468 | & __LINE__,__MYFILE__) |
---|
| 3469 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'positive', 'north' ) ,& |
---|
| 3470 | & __LINE__,__MYFILE__) |
---|
| 3471 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', dl_missing ) ,& |
---|
| 3472 | & __LINE__,__MYFILE__) |
---|
| 3473 | ENDIF |
---|
| 3474 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_miny ) ,& |
---|
| 3475 | & __LINE__,__MYFILE__) |
---|
| 3476 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_maxy ) ,& |
---|
| 3477 | & __LINE__,__MYFILE__) |
---|
| 3478 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3479 | & __LINE__,__MYFILE__) |
---|
| 3480 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, dd_lat),__LINE__,__MYFILE__ ) |
---|
| 3481 | |
---|
| 3482 | IF ( PRESENT( dd_dep ) ) THEN |
---|
| 3483 | i_var_exist = nf90_inq_varid( i_file_id, "depth", i_var_id ) |
---|
| 3484 | CALL nchdlerr( nf90_redef( i_file_id ) ,& |
---|
| 3485 | & __LINE__,__MYFILE__) |
---|
| 3486 | IF ( i_var_exist .NE. 0 ) THEN |
---|
| 3487 | CALL nchdlerr( nf90_def_var( i_file_id, "depth", nf90_double, i_dim(3), i_var_id ),__LINE__,__MYFILE__ ) |
---|
| 3488 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'data_type', 'float' ) ,& |
---|
| 3489 | & __LINE__,__MYFILE__) |
---|
| 3490 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'standard_name', 'depth' ) ,& |
---|
| 3491 | & __LINE__,__MYFILE__) |
---|
| 3492 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'long_name', 'depth below the surface'),__LINE__,__MYFILE__ ) |
---|
| 3493 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'units', 'm' ) ,& |
---|
| 3494 | & __LINE__,__MYFILE__) |
---|
| 3495 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'unit_long', 'meter' ),__LINE__,__MYFILE__ ) |
---|
| 3496 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'axis', 'Z' ) ,& |
---|
| 3497 | & __LINE__,__MYFILE__) |
---|
| 3498 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'positive', 'down' ) ,& |
---|
| 3499 | & __LINE__,__MYFILE__) |
---|
| 3500 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, '_FillValue', dl_missing ) ,& |
---|
| 3501 | & __LINE__,__MYFILE__) |
---|
| 3502 | ENDIF |
---|
| 3503 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_min', dl_minz ) ,& |
---|
| 3504 | & __LINE__,__MYFILE__) |
---|
| 3505 | CALL nchdlerr( nf90_put_att( i_file_id, i_var_id, 'valid_max', dl_maxz ) ,& |
---|
| 3506 | & __LINE__,__MYFILE__) |
---|
| 3507 | CALL nchdlerr( nf90_enddef( i_file_id ) ,& |
---|
| 3508 | & __LINE__,__MYFILE__) |
---|
| 3509 | CALL nchdlerr( nf90_put_var( i_file_id, i_var_id, dd_dep) ,& |
---|
| 3510 | & __LINE__,__MYFILE__) |
---|
| 3511 | ENDIF |
---|
| 3512 | |
---|
| 3513 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 3514 | & __LINE__,__MYFILE__) |
---|
| 3515 | ! |
---|
| 3516 | END SUBROUTINE put_coord_d |
---|
| 3517 | |
---|
| 3518 | !!====================================================================== |
---|
| 3519 | |
---|
| 3520 | SUBROUTINE create_map ( cd_filename, k_dimxy, k_dimz, cd_descr ) |
---|
| 3521 | !!---------------------------------------------------------------------- |
---|
| 3522 | !! *** ROUTINE create_map *** |
---|
| 3523 | !! |
---|
| 3524 | !! ** Purpose : create netcdf file |
---|
| 3525 | !! |
---|
| 3526 | !! ** Method : use netcdf fortran library |
---|
| 3527 | !! |
---|
| 3528 | !! ** Action : - define dimension of the netcdf file |
---|
| 3529 | !! |
---|
| 3530 | !! Reference : |
---|
| 3531 | !! |
---|
| 3532 | !! History : |
---|
| 3533 | !! 06-05 (N. Daget) original code |
---|
| 3534 | !!---------------------------------------------------------------------- |
---|
| 3535 | !! * Modules used |
---|
| 3536 | |
---|
| 3537 | !! * Library used |
---|
| 3538 | |
---|
| 3539 | !! * arguments |
---|
| 3540 | CHARACTER(len=80), INTENT(in) :: & |
---|
| 3541 | cd_filename ! filename |
---|
| 3542 | INTEGER, DIMENSION(:), INTENT(in) :: k_dimxy ! dimensions of longitude and latitude |
---|
| 3543 | INTEGER, DIMENSION(1), OPTIONAL, INTENT(in) :: k_dimz ! dimension of depth |
---|
| 3544 | CHARACTER(len=80), DIMENSION(6), OPTIONAL, INTENT(in) :: & |
---|
| 3545 | cd_descr ! description of file contents |
---|
| 3546 | |
---|
| 3547 | !! * local declarations |
---|
| 3548 | INTEGER :: & |
---|
| 3549 | i_file_id, i_dim_id ! file and dimension identifiers |
---|
| 3550 | INTEGER, DIMENSION(1) :: i_dim ! dimension of k_dimxy |
---|
| 3551 | !!---------------------------------------------------------------------- |
---|
| 3552 | |
---|
| 3553 | i_dim = SHAPE(k_dimxy) |
---|
| 3554 | |
---|
| 3555 | ! Create file |
---|
| 3556 | ! ----------- |
---|
| 3557 | CALL nchdlerr( nf90_create( cd_filename, nf90_clobber, i_file_id ) ,& |
---|
| 3558 | & __LINE__,__MYFILE__) |
---|
| 3559 | |
---|
| 3560 | ! Define dimensions |
---|
| 3561 | ! ----------------- |
---|
| 3562 | CALL nchdlerr( nf90_def_dim( i_file_id, 'x', k_dimxy(1), i_dim_id ) ,& |
---|
| 3563 | & __LINE__,__MYFILE__) |
---|
| 3564 | CALL nchdlerr( nf90_def_dim( i_file_id, 'y', k_dimxy(2), i_dim_id ) ,& |
---|
| 3565 | & __LINE__,__MYFILE__) |
---|
| 3566 | IF ( PRESENT(k_dimz) ) THEN |
---|
| 3567 | CALL nchdlerr( nf90_def_dim( i_file_id, 'z', k_dimz(1), i_dim_id ) ,& |
---|
| 3568 | & __LINE__,__MYFILE__) |
---|
| 3569 | ENDIF |
---|
| 3570 | IF ( i_dim(1) .EQ. 3 ) THEN |
---|
| 3571 | CALL nchdlerr( nf90_def_dim( i_file_id, 'z', k_dimxy(3), i_dim_id ) ,& |
---|
| 3572 | & __LINE__,__MYFILE__) |
---|
| 3573 | ENDIF |
---|
| 3574 | CALL nchdlerr( nf90_def_dim( i_file_id, 'time', nf90_unlimited, i_dim_id ) ,& |
---|
| 3575 | & __LINE__,__MYFILE__) |
---|
| 3576 | |
---|
| 3577 | IF ( PRESENT( cd_descr ) ) THEN |
---|
| 3578 | CALL nchdlerr( nf90_put_att( i_file_id, nf90_global, "title", cd_descr(1) ) ,& |
---|
| 3579 | & __LINE__,__MYFILE__) |
---|
| 3580 | CALL nchdlerr( nf90_put_att( i_file_id, nf90_global, "institution", cd_descr(2) ) ,& |
---|
| 3581 | & __LINE__,__MYFILE__) |
---|
| 3582 | CALL nchdlerr( nf90_put_att( i_file_id, nf90_global, "source", cd_descr(3) ) ,& |
---|
| 3583 | & __LINE__,__MYFILE__) |
---|
| 3584 | CALL nchdlerr( nf90_put_att( i_file_id, nf90_global, "history", cd_descr(4) ) ,& |
---|
| 3585 | & __LINE__,__MYFILE__) |
---|
| 3586 | CALL nchdlerr( nf90_put_att( i_file_id, nf90_global, "references", cd_descr(5) ) ,& |
---|
| 3587 | & __LINE__,__MYFILE__) |
---|
| 3588 | CALL nchdlerr( nf90_put_att( i_file_id, nf90_global, "comment", cd_descr(6) ) ,& |
---|
| 3589 | & __LINE__,__MYFILE__) |
---|
| 3590 | ENDIF |
---|
| 3591 | |
---|
| 3592 | CALL nchdlerr( nf90_close( i_file_id ) ,& |
---|
| 3593 | & __LINE__,__MYFILE__) |
---|
| 3594 | |
---|
| 3595 | END SUBROUTINE create_map |
---|
| 3596 | |
---|
| 3597 | !!====================================================================== |
---|
| 3598 | |
---|
| 3599 | SUBROUTINE put_att( k_file_id, k_var_id, k_code ) |
---|
| 3600 | !!---------------------------------------------------------------------- |
---|
| 3601 | !! *** ROUTINE put_att *** |
---|
| 3602 | !! |
---|
| 3603 | !! ** Purpose : write CF attributes |
---|
| 3604 | !! |
---|
| 3605 | !! ** Method : use netcdf fortran library |
---|
| 3606 | !! |
---|
| 3607 | !! ** Action : - write CF attributes |
---|
| 3608 | !! |
---|
| 3609 | !! Reference : |
---|
| 3610 | !! |
---|
| 3611 | !! History : |
---|
| 3612 | !! 06-05 (N. Daget) original code |
---|
| 3613 | !!---------------------------------------------------------------------- |
---|
| 3614 | !! * Modules used |
---|
| 3615 | |
---|
| 3616 | !! * Library used |
---|
| 3617 | |
---|
| 3618 | !! * arguments |
---|
| 3619 | INTEGER, INTENT(in) :: k_file_id, k_var_id, & ! file and variable identifiers |
---|
| 3620 | k_code ! CF identifier |
---|
| 3621 | |
---|
| 3622 | !! * local declarations |
---|
| 3623 | CHARACTER(len=80) :: & |
---|
| 3624 | cl_name, cl_longname, & ! names of variable |
---|
| 3625 | cl_unit, cl_longunit ! units of variable |
---|
| 3626 | !!---------------------------------------------------------------------- |
---|
| 3627 | |
---|
| 3628 | ! Get variable attributes and write them |
---|
| 3629 | ! -------------------------------------- |
---|
| 3630 | CALL get_var_info( k_code, cl_name, cl_longname, cl_unit, cl_longunit ) |
---|
| 3631 | |
---|
| 3632 | CALL nchdlerr( nf90_put_att( k_file_id, k_var_id, 'standard_name', TRIM(cl_name) ) ,& |
---|
| 3633 | & __LINE__,__MYFILE__) |
---|
| 3634 | CALL nchdlerr( nf90_put_att( k_file_id, k_var_id, 'long_name', TRIM(cl_longname) ) ,& |
---|
| 3635 | & __LINE__,__MYFILE__) |
---|
| 3636 | CALL nchdlerr( nf90_put_att( k_file_id, k_var_id, 'units', TRIM(cl_unit) ) ,& |
---|
| 3637 | & __LINE__,__MYFILE__) |
---|
| 3638 | CALL nchdlerr( nf90_put_att( k_file_id, k_var_id, 'unit_long', TRIM(cl_longunit) ),__LINE__,__MYFILE__ ) |
---|
| 3639 | |
---|
| 3640 | END SUBROUTINE put_att |
---|
| 3641 | |
---|
| 3642 | !!====================================================================== |
---|
| 3643 | |
---|
| 3644 | SUBROUTINE get_var_info( k_code, cd_name, cd_longname, cd_unit, cd_longunit ) |
---|
| 3645 | !!---------------------------------------------------------------------- |
---|
| 3646 | !! *** ROUTINE put_att *** |
---|
| 3647 | !! |
---|
| 3648 | !! ** Purpose : get CF attributes |
---|
| 3649 | !! |
---|
| 3650 | !! ** Method : outofcore database |
---|
| 3651 | !! |
---|
| 3652 | !! ** Action : - find iCF attributes |
---|
| 3653 | !! |
---|
| 3654 | !! Reference : |
---|
| 3655 | !! |
---|
| 3656 | !! History : |
---|
| 3657 | !! 06-05 (N. Daget) original code |
---|
| 3658 | !!---------------------------------------------------------------------- |
---|
| 3659 | !! * Modules used |
---|
| 3660 | |
---|
| 3661 | !! * Library used |
---|
| 3662 | |
---|
| 3663 | !! * arguments |
---|
| 3664 | CHARACTER(len=80), INTENT(out) :: cd_name ! name of variable |
---|
| 3665 | CHARACTER(len=80), OPTIONAL, INTENT(out) :: & |
---|
| 3666 | cd_longname, cd_unit, cd_longunit ! name and units of variable |
---|
| 3667 | INTEGER, INTENT(in) :: k_code ! CF identifier |
---|
| 3668 | |
---|
| 3669 | !! * local declarations |
---|
| 3670 | !!---------------------------------------------------------------------- |
---|
| 3671 | |
---|
| 3672 | ! Get CF attributes |
---|
| 3673 | ! ----------------- |
---|
| 3674 | SELECT CASE ( k_code ) |
---|
| 3675 | CASE (129) |
---|
| 3676 | cd_name="sea_water_potential_temperature" |
---|
| 3677 | IF ( PRESENT(cd_longname) ) cd_longname="Potential temperature ref to surface K" |
---|
| 3678 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3679 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_Celcius" |
---|
| 3680 | CASE (130) |
---|
| 3681 | cd_name="sea_water_salinity" |
---|
| 3682 | IF ( PRESENT(cd_longname) ) cd_longname="sea water salinity" |
---|
| 3683 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3684 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3685 | CASE (131) |
---|
| 3686 | cd_name="sea_water_x_velocity" |
---|
| 3687 | IF ( PRESENT(cd_longname) ) cd_longname="U zonal current m/s" |
---|
| 3688 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3689 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3690 | CASE (132) |
---|
| 3691 | cd_name="sea_water_y_velocity" |
---|
| 3692 | IF ( PRESENT(cd_longname) ) cd_longname="V meridional current m/s" |
---|
| 3693 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3694 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3695 | CASE (133) |
---|
| 3696 | cd_name="upward_sea_water_velocity" |
---|
| 3697 | IF ( PRESENT(cd_longname) ) cd_longname="W vertical current m/s" |
---|
| 3698 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3699 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3700 | CASE (134) |
---|
| 3701 | cd_name="mst" |
---|
| 3702 | IF ( PRESENT(cd_longname) ) cd_longname="Modulus of strain rate tensor" |
---|
| 3703 | IF ( PRESENT(cd_unit) ) cd_unit="s-1" |
---|
| 3704 | IF ( PRESENT(cd_longunit) ) cd_longunit="per_second" |
---|
| 3705 | CASE (135) |
---|
| 3706 | cd_name="vvs" |
---|
| 3707 | IF ( PRESENT(cd_longname) ) cd_longname="Vertical viscosity" |
---|
| 3708 | IF ( PRESENT(cd_unit) ) cd_unit="m^2/s" |
---|
| 3709 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_meter_per_second" |
---|
| 3710 | CASE (136) |
---|
| 3711 | cd_name="vdf" |
---|
| 3712 | IF ( PRESENT(cd_longname) ) cd_longname="Vertical diffusivity" |
---|
| 3713 | IF ( PRESENT(cd_unit) ) cd_unit="m^2/s" |
---|
| 3714 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_meter_per_second" |
---|
| 3715 | CASE (137) |
---|
| 3716 | cd_name="depth" |
---|
| 3717 | IF ( PRESENT(cd_longname) ) cd_longname="depth" |
---|
| 3718 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3719 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3720 | CASE (138) |
---|
| 3721 | cd_name="sea_water_sigma_theta" |
---|
| 3722 | IF ( PRESENT(cd_longname) ) cd_longname="Sigma theta" |
---|
| 3723 | IF ( PRESENT(cd_unit) ) cd_unit="kgm3" |
---|
| 3724 | IF ( PRESENT(cd_longunit) ) cd_longunit="kilogramme cubicmeter" |
---|
| 3725 | CASE (139) |
---|
| 3726 | cd_name="richardson_number" |
---|
| 3727 | IF ( PRESENT(cd_longname) ) cd_longname="Richardson number" |
---|
| 3728 | IF ( PRESENT(cd_unit) ) cd_unit="" |
---|
| 3729 | IF ( PRESENT(cd_longunit) ) cd_longunit="" |
---|
| 3730 | CASE (140) |
---|
| 3731 | cd_name="UV" |
---|
| 3732 | IF ( PRESENT(cd_longname) ) cd_longname="UV product" |
---|
| 3733 | IF ( PRESENT(cd_unit) ) cd_unit="m**2 s**-2" |
---|
| 3734 | IF ( PRESENT(cd_longunit) ) cd_longunit="m**2 s**-2" |
---|
| 3735 | CASE (141) |
---|
| 3736 | cd_name="UT" |
---|
| 3737 | IF ( PRESENT(cd_longname) ) cd_longname="UT product" |
---|
| 3738 | IF ( PRESENT(cd_unit) ) cd_unit="m s**-1 degC" |
---|
| 3739 | IF ( PRESENT(cd_longunit) ) cd_longunit="m s**-1 degC" |
---|
| 3740 | CASE (142) |
---|
| 3741 | cd_name="VT" |
---|
| 3742 | IF ( PRESENT(cd_longname) ) cd_longname="VT product" |
---|
| 3743 | IF ( PRESENT(cd_unit) ) cd_unit="m s**-1 degC" |
---|
| 3744 | IF ( PRESENT(cd_longunit) ) cd_longunit="m s**-1 degC" |
---|
| 3745 | CASE (143) |
---|
| 3746 | cd_name="UU" |
---|
| 3747 | IF ( PRESENT(cd_longname) ) cd_longname="UU product" |
---|
| 3748 | IF ( PRESENT(cd_unit) ) cd_unit="m**2 s**-2" |
---|
| 3749 | IF ( PRESENT(cd_longunit) ) cd_longunit="m**2 s**-2" |
---|
| 3750 | CASE (144) |
---|
| 3751 | cd_name="VV" |
---|
| 3752 | IF ( PRESENT(cd_longname) ) cd_longname="VV product" |
---|
| 3753 | IF ( PRESENT(cd_unit) ) cd_unit="m**2 s**-2" |
---|
| 3754 | IF ( PRESENT(cd_longunit) ) cd_longunit="m**2 s**-2" |
---|
| 3755 | CASE (145) |
---|
| 3756 | cd_name="sea_surface_height_above_geoid" |
---|
| 3757 | IF ( PRESENT(cd_longname) ) cd_longname="sea_surface_height_above_geoid" |
---|
| 3758 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3759 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3760 | CASE (146) |
---|
| 3761 | cd_name="sea_floor_topography" |
---|
| 3762 | IF ( PRESENT(cd_longname) ) cd_longname="Sea floor topography" |
---|
| 3763 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3764 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3765 | CASE (147) |
---|
| 3766 | cd_name="ocean_barotropic_streamfunction" |
---|
| 3767 | IF ( PRESENT(cd_longname) ) cd_longname="Barotropic Stream Function" |
---|
| 3768 | IF ( PRESENT(cd_unit) ) cd_unit="m3/s" |
---|
| 3769 | IF ( PRESENT(cd_longunit) ) cd_longunit="cubic_meter_per_second" |
---|
| 3770 | CASE (148) |
---|
| 3771 | cd_name="ocean_mixed_layer_thickness" |
---|
| 3772 | IF ( PRESENT(cd_longname) ) cd_longname="depth of the ocean mixed layer from the surface" |
---|
| 3773 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3774 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3775 | CASE (149) |
---|
| 3776 | cd_name="sea_water_bottom_pressure" |
---|
| 3777 | IF ( PRESENT(cd_longname) ) cd_longname="sea_water_bottom_pressure" |
---|
| 3778 | IF ( PRESENT(cd_unit) ) cd_unit="Pa" |
---|
| 3779 | IF ( PRESENT(cd_longunit) ) cd_longunit="Pascal" |
---|
| 3780 | CASE (153) |
---|
| 3781 | cd_name="surface_downward_eastward_stress" |
---|
| 3782 | IF ( PRESENT(cd_longname) ) cd_longname="U-Stress" |
---|
| 3783 | IF ( PRESENT(cd_unit) ) cd_unit="Pa" |
---|
| 3784 | IF ( PRESENT(cd_longunit) ) cd_longunit="Pascal" |
---|
| 3785 | CASE (154) |
---|
| 3786 | cd_name="surface_downward_northward_stress" |
---|
| 3787 | IF ( PRESENT(cd_longname) ) cd_longname="V-Stress" |
---|
| 3788 | IF ( PRESENT(cd_unit) ) cd_unit="Pa" |
---|
| 3789 | IF ( PRESENT(cd_longunit) ) cd_longunit="Pascal" |
---|
| 3790 | CASE (156) |
---|
| 3791 | cd_name="turbulent_kinetic_energy_input" |
---|
| 3792 | IF ( PRESENT(cd_longname) ) cd_longname="turbulent kinetic energy input" |
---|
| 3793 | IF ( PRESENT(cd_unit) ) cd_unit="W.m^2" |
---|
| 3794 | IF ( PRESENT(cd_longunit) ) cd_longunit="watt_per_square_meter" |
---|
| 3795 | CASE (157) |
---|
| 3796 | cd_name="absorbed_solar_radiation" |
---|
| 3797 | IF ( PRESENT(cd_longname) ) cd_longname="Absorbed solar radiation" |
---|
| 3798 | IF ( PRESENT(cd_unit) ) cd_unit="W.m^2" |
---|
| 3799 | IF ( PRESENT(cd_longunit) ) cd_longunit="watt_per_square_meter" |
---|
| 3800 | CASE (158) |
---|
| 3801 | cd_name="surface_downward_water_flux" |
---|
| 3802 | IF ( PRESENT(cd_longname) ) cd_longname="Precipitation minus Evaporation" |
---|
| 3803 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3804 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3805 | CASE (159) |
---|
| 3806 | cd_name="sea_surface_temperature" |
---|
| 3807 | IF ( PRESENT(cd_longname) ) cd_longname="specified sea surface temperature" |
---|
| 3808 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3809 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_Celcius" |
---|
| 3810 | CASE (160) |
---|
| 3811 | cd_name="surface_downward_heat_flux_in_sea_water" |
---|
| 3812 | IF ( PRESENT(cd_longname) ) cd_longname="Specified Surface Heat flux" |
---|
| 3813 | IF ( PRESENT(cd_unit) ) cd_unit="W.m^2" |
---|
| 3814 | IF ( PRESENT(cd_longunit) ) cd_longunit="watt_per_square_meter" |
---|
| 3815 | CASE (161) |
---|
| 3816 | cd_name="diagnosed_sst_error" |
---|
| 3817 | IF ( PRESENT(cd_longname) ) cd_longname="diagnosed sea surface temperature error" |
---|
| 3818 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3819 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3820 | CASE (162) |
---|
| 3821 | cd_name="surface_downward_heat_flux_in_sea_water" |
---|
| 3822 | IF ( PRESENT(cd_longname) ) cd_longname="Heat flux Correction" |
---|
| 3823 | IF ( PRESENT(cd_unit) ) cd_unit="W.m^2" |
---|
| 3824 | IF ( PRESENT(cd_longunit) ) cd_longunit="watt_per_square_meter" |
---|
| 3825 | CASE (163) |
---|
| 3826 | cd_name="d20_isotherm_depth" |
---|
| 3827 | IF ( PRESENT(cd_longname) ) cd_longname="depth of the D20 isotherm" |
---|
| 3828 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3829 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3830 | CASE (164) |
---|
| 3831 | cd_name="ocean_integral_of_sea_water_temperature_wrt_depth" |
---|
| 3832 | IF ( PRESENT(cd_longname) ) cd_longname="averaged temperature over the fisrt 300m" |
---|
| 3833 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3834 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3835 | CASE (167) |
---|
| 3836 | cd_name="barotropic_eastward_sea_water_velocity" |
---|
| 3837 | IF ( PRESENT(cd_longname) ) cd_longname="integral of U dz" |
---|
| 3838 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3839 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3840 | CASE (168) |
---|
| 3841 | cd_name="barotropic_northward_sea_water_velocity" |
---|
| 3842 | IF ( PRESENT(cd_longname) ) cd_longname="integral of V dz" |
---|
| 3843 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3844 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3845 | CASE (169) |
---|
| 3846 | cd_name="product_of_eastward_sea_water_velocity_and_temperature" |
---|
| 3847 | IF ( PRESENT(cd_longname) ) cd_longname="integral of Tudz" |
---|
| 3848 | IF ( PRESENT(cd_unit) ) cd_unit="Km/s" |
---|
| 3849 | IF ( PRESENT(cd_longunit) ) cd_longunit="Kelvin_meter_per_second" |
---|
| 3850 | CASE (170) |
---|
| 3851 | cd_name="product_of_northward_sea_water_velocity_and_temperature" |
---|
| 3852 | IF ( PRESENT(cd_longname) ) cd_longname="integral of Tvdz" |
---|
| 3853 | IF ( PRESENT(cd_unit) ) cd_unit="Km/s" |
---|
| 3854 | IF ( PRESENT(cd_longunit) ) cd_longunit="Kelvin_meter_per_second" |
---|
| 3855 | CASE (171) |
---|
| 3856 | cd_name="velocity_maximum" |
---|
| 3857 | IF ( PRESENT(cd_longname) ) cd_longname="velocity maximum" |
---|
| 3858 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3859 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3860 | CASE (172) |
---|
| 3861 | cd_name="depth_of_maximum_velocity" |
---|
| 3862 | IF ( PRESENT(cd_longname) ) cd_longname="depth of maximum velocity" |
---|
| 3863 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3864 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3865 | CASE (173) |
---|
| 3866 | cd_name="salinity_maximum" |
---|
| 3867 | IF ( PRESENT(cd_longname) ) cd_longname="salinity maximum" |
---|
| 3868 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3869 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3870 | CASE (174) |
---|
| 3871 | cd_name="depth_of_maximum_salinity" |
---|
| 3872 | IF ( PRESENT(cd_longname) ) cd_longname="depth of maximum salinity" |
---|
| 3873 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3874 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3875 | CASE (175) |
---|
| 3876 | cd_name="ocean_integral_of_sea_water_salinity_wrt_depth" |
---|
| 3877 | IF ( PRESENT(cd_longname) ) cd_longname="averaged salinity over the fisrt 300m" |
---|
| 3878 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3879 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3880 | CASE (179) |
---|
| 3881 | cd_name="potential_temperature_analysis_error" |
---|
| 3882 | IF ( PRESENT(cd_longname) ) cd_longname="Potential temperature analysis error" |
---|
| 3883 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3884 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3885 | CASE (180) |
---|
| 3886 | cd_name="background_potential_temperature" |
---|
| 3887 | IF ( PRESENT(cd_longname) ) cd_longname="background potential temperature" |
---|
| 3888 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3889 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3890 | CASE (181) |
---|
| 3891 | cd_name="analysed_potential_temperature" |
---|
| 3892 | IF ( PRESENT(cd_longname) ) cd_longname="Analysed potential temperature" |
---|
| 3893 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3894 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3895 | CASE (182) |
---|
| 3896 | cd_name="potential_temperature_background_error" |
---|
| 3897 | IF ( PRESENT(cd_longname) ) cd_longname="Potential temperature background error" |
---|
| 3898 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3899 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3900 | CASE (183) |
---|
| 3901 | cd_name="analysed_salinity_from_soft" |
---|
| 3902 | IF ( PRESENT(cd_longname) ) cd_longname="analysed salinity from S(T) balance operator" |
---|
| 3903 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3904 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3905 | CASE (184) |
---|
| 3906 | cd_name="sea_water_salinity_increment" |
---|
| 3907 | IF ( PRESENT(cd_longname) ) cd_longname="salinity increment" |
---|
| 3908 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3909 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3910 | CASE (185) |
---|
| 3911 | cd_name="temperature_bias" |
---|
| 3912 | IF ( PRESENT(cd_longname) ) cd_longname="bias in temperature" |
---|
| 3913 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 3914 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 3915 | CASE (186) |
---|
| 3916 | cd_name="salinity_bias" |
---|
| 3917 | IF ( PRESENT(cd_longname) ) cd_longname="bias in salinity" |
---|
| 3918 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3919 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3920 | CASE (187) |
---|
| 3921 | cd_name="eastward_sea_water_velocity_increment_from_balance" |
---|
| 3922 | IF ( PRESENT(cd_longname) ) cd_longname="eastward sea water velocity increment from balance operator" |
---|
| 3923 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3924 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3925 | CASE (188) |
---|
| 3926 | cd_name="northward_sea_water_velocity_increment_from_balance" |
---|
| 3927 | IF ( PRESENT(cd_longname) ) cd_longname="northward sea water velocity increment from balance operator" |
---|
| 3928 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3929 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3930 | CASE (190) |
---|
| 3931 | cd_name="sea_water_salinity_increment_from_soft" |
---|
| 3932 | IF ( PRESENT(cd_longname) ) cd_longname="sea water salinity increment from soft" |
---|
| 3933 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3934 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3935 | CASE (191) |
---|
| 3936 | cd_name="sea_water_salinity_analysis_error" |
---|
| 3937 | IF ( PRESENT(cd_longname) ) cd_longname="sea water salinity analysis error" |
---|
| 3938 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3939 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3940 | CASE (192) |
---|
| 3941 | cd_name="sea_water_background_salinity" |
---|
| 3942 | IF ( PRESENT(cd_longname) ) cd_longname="sea water background salinity" |
---|
| 3943 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3944 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3945 | CASE (193) |
---|
| 3946 | cd_name="sea_water_analysed_salinity" |
---|
| 3947 | IF ( PRESENT(cd_longname) ) cd_longname="sea water analysed salinity" |
---|
| 3948 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3949 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3950 | CASE (194) |
---|
| 3951 | cd_name="sea_water_salinity_background_error" |
---|
| 3952 | IF ( PRESENT(cd_longname) ) cd_longname="sea water salinity background error" |
---|
| 3953 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3954 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3955 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3956 | CASE (500) |
---|
| 3957 | cd_name="bcksta_bal_S" |
---|
| 3958 | IF ( PRESENT(cd_longname) ) cd_longname="balanced part of S" |
---|
| 3959 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3960 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3961 | CASE (501) |
---|
| 3962 | cd_name="bcksta_unbal_S" |
---|
| 3963 | IF ( PRESENT(cd_longname) ) cd_longname="unbalanced part of S" |
---|
| 3964 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 3965 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 3966 | CASE (502) |
---|
| 3967 | cd_name="bcksta_bal_u" |
---|
| 3968 | IF ( PRESENT(cd_longname) ) cd_longname="balanced part of u" |
---|
| 3969 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3970 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3971 | CASE (503) |
---|
| 3972 | cd_name="bcksta_unbal_u" |
---|
| 3973 | IF ( PRESENT(cd_longname) ) cd_longname="unbalanced part of u" |
---|
| 3974 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3975 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3976 | CASE (504) |
---|
| 3977 | cd_name="bcksta_bal_v" |
---|
| 3978 | IF ( PRESENT(cd_longname) ) cd_longname="balanced part of v" |
---|
| 3979 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3980 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3981 | CASE (505) |
---|
| 3982 | cd_name="bcksta_unbal_v" |
---|
| 3983 | IF ( PRESENT(cd_longname) ) cd_longname="unbalanced part of v" |
---|
| 3984 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 3985 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 3986 | CASE (506) |
---|
| 3987 | cd_name="bcksta_bal_e" |
---|
| 3988 | IF ( PRESENT(cd_longname) ) cd_longname="balanced part of SSH" |
---|
| 3989 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3990 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3991 | CASE (507) |
---|
| 3992 | cd_name="bcksta_unbal_e" |
---|
| 3993 | IF ( PRESENT(cd_longname) ) cd_longname="unbalanced part of SSH" |
---|
| 3994 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 3995 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 3996 | CASE (510) |
---|
| 3997 | cd_name="increm_tot_T" |
---|
| 3998 | IF ( PRESENT(cd_longname) ) cd_longname="increment for total part of T" |
---|
| 3999 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 4000 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 4001 | CASE (511) |
---|
| 4002 | cd_name="increm_tot_S" |
---|
| 4003 | IF ( PRESENT(cd_longname) ) cd_longname="increment for total part of S" |
---|
| 4004 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4005 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4006 | CASE (512) |
---|
| 4007 | cd_name="increm_bal_S" |
---|
| 4008 | IF ( PRESENT(cd_longname) ) cd_longname="increment for balanced part of S" |
---|
| 4009 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4010 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4011 | CASE (513) |
---|
| 4012 | cd_name="increm_unbal_S" |
---|
| 4013 | IF ( PRESENT(cd_longname) ) cd_longname="increment for unbalanced part of S" |
---|
| 4014 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4015 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4016 | CASE (514) |
---|
| 4017 | cd_name="increm_tot_u" |
---|
| 4018 | IF ( PRESENT(cd_longname) ) cd_longname="increment for total part of U" |
---|
| 4019 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4020 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4021 | CASE (515) |
---|
| 4022 | cd_name="increm_bal_u" |
---|
| 4023 | IF ( PRESENT(cd_longname) ) cd_longname="increment for balanced part of U" |
---|
| 4024 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4025 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4026 | CASE (516) |
---|
| 4027 | cd_name="increm_unbal_u" |
---|
| 4028 | IF ( PRESENT(cd_longname) ) cd_longname="increment for unbalanced part of U" |
---|
| 4029 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4030 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4031 | CASE (517) |
---|
| 4032 | cd_name="increm_tot_v" |
---|
| 4033 | IF ( PRESENT(cd_longname) ) cd_longname="increment for total part of V" |
---|
| 4034 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4035 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4036 | CASE (518) |
---|
| 4037 | cd_name="increm_bal_v" |
---|
| 4038 | IF ( PRESENT(cd_longname) ) cd_longname="increment for balanced part of V" |
---|
| 4039 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4040 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4041 | CASE (519) |
---|
| 4042 | cd_name="increm_unbal_v" |
---|
| 4043 | IF ( PRESENT(cd_longname) ) cd_longname="increment for unbalanced part of V" |
---|
| 4044 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4045 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4046 | CASE (520) |
---|
| 4047 | cd_name="increm_tot_e" |
---|
| 4048 | IF ( PRESENT(cd_longname) ) cd_longname="increment for total part of SSH" |
---|
| 4049 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4050 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4051 | CASE (521) |
---|
| 4052 | cd_name="increm_bal_e" |
---|
| 4053 | IF ( PRESENT(cd_longname) ) cd_longname="increment for balanced part of SSH" |
---|
| 4054 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4055 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4056 | CASE (522) |
---|
| 4057 | cd_name="increm_unbal_e" |
---|
| 4058 | IF ( PRESENT(cd_longname) ) cd_longname="increment for unbalanced part of SSH" |
---|
| 4059 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4060 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4061 | CASE (530) |
---|
| 4062 | cd_name="pbudct" |
---|
| 4063 | IF ( PRESENT(cd_longname) ) cd_longname="distance between coastline and model u-points" |
---|
| 4064 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4065 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4066 | CASE (531) |
---|
| 4067 | cd_name="pbvdct" |
---|
| 4068 | IF ( PRESENT(cd_longname) ) cd_longname="distance between coastline and model v-points" |
---|
| 4069 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4070 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4071 | CASE (532) |
---|
| 4072 | cd_name="pbtdct" |
---|
| 4073 | IF ( PRESENT(cd_longname) ) cd_longname="distance between coastline and model t-points" |
---|
| 4074 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4075 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4076 | CASE (533) |
---|
| 4077 | cd_name="pbfdct" |
---|
| 4078 | IF ( PRESENT(cd_longname) ) cd_longname="distance between coastline and model f-points" |
---|
| 4079 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4080 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4081 | CASE (540) |
---|
| 4082 | cd_name="bckenw_wetjc" |
---|
| 4083 | IF ( PRESENT(cd_longname) ) cd_longname="energy T weighting coefficient for Jc term" |
---|
| 4084 | IF ( PRESENT(cd_unit) ) cd_unit="m^2/s^2/C^2" |
---|
| 4085 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_meter_per_square_second_per_square_degre_celcius" |
---|
| 4086 | CASE (541) |
---|
| 4087 | cd_name="bckenw_wesjc" |
---|
| 4088 | IF ( PRESENT(cd_longname) ) cd_longname="energy S weighting coefficient for Jc term" |
---|
| 4089 | IF ( PRESENT(cd_unit) ) cd_unit="m^2/s^2/PSU^2" |
---|
| 4090 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_meter_per_square_second_per_square_practical_salinity_scale" |
---|
| 4091 | CASE (550) |
---|
| 4092 | cd_name="bckesd_ana_t" |
---|
| 4093 | IF ( PRESENT(cd_longname) ) cd_longname="standard deviations for total part of T" |
---|
| 4094 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 4095 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 4096 | CASE (551) |
---|
| 4097 | cd_name="bckesd_ana_s" |
---|
| 4098 | IF ( PRESENT(cd_longname) ) cd_longname="standard deviations for unbalanced part of S" |
---|
| 4099 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4100 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4101 | CASE (552) |
---|
| 4102 | cd_name="bckesd_ana_u" |
---|
| 4103 | IF ( PRESENT(cd_longname) ) cd_longname="standard deviations for unbalanced part of u" |
---|
| 4104 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4105 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4106 | CASE (553) |
---|
| 4107 | cd_name="bckesd_ana_v" |
---|
| 4108 | IF ( PRESENT(cd_longname) ) cd_longname="standard deviations for unbalanced part of V" |
---|
| 4109 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4110 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4111 | CASE (554) |
---|
| 4112 | cd_name="bckesd_ana_e" |
---|
| 4113 | IF ( PRESENT(cd_longname) ) cd_longname="standard deviations for unbalanced part of SSH" |
---|
| 4114 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4115 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4116 | CASE (560) |
---|
| 4117 | cd_name="bckesd_mod_t" |
---|
| 4118 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for temperature" |
---|
| 4119 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 4120 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 4121 | CASE (561) |
---|
| 4122 | cd_name="bckesd_mod_s" |
---|
| 4123 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for salinity" |
---|
| 4124 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4125 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4126 | CASE (562) |
---|
| 4127 | cd_name="bckesd_mod_u" |
---|
| 4128 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for u-velocity" |
---|
| 4129 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4130 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4131 | CASE (563) |
---|
| 4132 | cd_name="bckesd_mod_v" |
---|
| 4133 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for v-velocity" |
---|
| 4134 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4135 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4136 | CASE (564) |
---|
| 4137 | cd_name="bckesd_mod_e" |
---|
| 4138 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for SSH" |
---|
| 4139 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4140 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4141 | CASE (565) |
---|
| 4142 | cd_name="bckesd_modf_t" |
---|
| 4143 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for temperature at final time" |
---|
| 4144 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 4145 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 4146 | CASE (566) |
---|
| 4147 | cd_name="bckesd_modf_s" |
---|
| 4148 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for salinity at final time" |
---|
| 4149 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4150 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4151 | CASE (567) |
---|
| 4152 | cd_name="bckesd_modf_u" |
---|
| 4153 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for u-velocity at final time" |
---|
| 4154 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4155 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4156 | CASE (568) |
---|
| 4157 | cd_name="bckesd_modf_v" |
---|
| 4158 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for v-velocity at final time" |
---|
| 4159 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4160 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4161 | CASE (569) |
---|
| 4162 | cd_name="bckesd_modf_e" |
---|
| 4163 | IF ( PRESENT(cd_longname) ) cd_longname="background error standard deviations for SSH at final time" |
---|
| 4164 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4165 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4166 | CASE (570) |
---|
| 4167 | cd_name="bcksal_dSdT" |
---|
| 4168 | IF ( PRESENT(cd_longname) ) cd_longname="dS/dT coefficient for the salinity balance" |
---|
| 4169 | IF ( PRESENT(cd_unit) ) cd_unit="PSU/C" |
---|
| 4170 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale_per_degree_celcius" |
---|
| 4171 | CASE (571) |
---|
| 4172 | cd_name="bcksal_dTdz" |
---|
| 4173 | IF ( PRESENT(cd_longname) ) cd_longname="dT/dz for the background" |
---|
| 4174 | IF ( PRESENT(cd_unit) ) cd_unit="C/m" |
---|
| 4175 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius_per_meter" |
---|
| 4176 | CASE (572) |
---|
| 4177 | cd_name="bcksal_dSdz" |
---|
| 4178 | IF ( PRESENT(cd_longname) ) cd_longname="dS/dz for the background" |
---|
| 4179 | IF ( PRESENT(cd_unit) ) cd_unit="PSU/m" |
---|
| 4180 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale_per_meter" |
---|
| 4181 | CASE (575) |
---|
| 4182 | cd_name="bckssh_alpha" |
---|
| 4183 | IF ( PRESENT(cd_longname) ) cd_longname="Thermal expansion coefficient for the SSH balance" |
---|
| 4184 | IF ( PRESENT(cd_unit) ) cd_unit="" |
---|
| 4185 | IF ( PRESENT(cd_longunit) ) cd_longunit="" |
---|
| 4186 | CASE (576) |
---|
| 4187 | cd_name="bckssh_beta" |
---|
| 4188 | IF ( PRESENT(cd_longname) ) cd_longname="Saline expansion coefficient for the SSH balance" |
---|
| 4189 | IF ( PRESENT(cd_unit) ) cd_unit="" |
---|
| 4190 | IF ( PRESENT(cd_longunit) ) cd_longunit="" |
---|
| 4191 | CASE (580) |
---|
| 4192 | cd_name="filnot" |
---|
| 4193 | IF ( PRESENT(cd_longname) ) cd_longname="filter normalization factor at T-points" |
---|
| 4194 | IF ( PRESENT(cd_unit) ) cd_unit="m^(3/2)" |
---|
| 4195 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_root_of_cube_meter" |
---|
| 4196 | CASE (581) |
---|
| 4197 | cd_name="filnou" |
---|
| 4198 | IF ( PRESENT(cd_longname) ) cd_longname="filter normalization factor at u-points" |
---|
| 4199 | IF ( PRESENT(cd_unit) ) cd_unit="m^(3/2)" |
---|
| 4200 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_root_of_cube_meter" |
---|
| 4201 | CASE (582) |
---|
| 4202 | cd_name="filnov" |
---|
| 4203 | IF ( PRESENT(cd_longname) ) cd_longname="filter normalization factor at v-points" |
---|
| 4204 | IF ( PRESENT(cd_unit) ) cd_unit="m^(3/2)" |
---|
| 4205 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_root_of_cube_meter" |
---|
| 4206 | CASE (583) |
---|
| 4207 | cd_name="filnoe" |
---|
| 4208 | IF ( PRESENT(cd_longname) ) cd_longname="filter normalization factor at eta-points" |
---|
| 4209 | IF ( PRESENT(cd_unit) ) cd_unit="m^(3/2)" |
---|
| 4210 | IF ( PRESENT(cd_longunit) ) cd_longunit="square_root_of_cube_meter" |
---|
| 4211 | CASE (590) |
---|
| 4212 | cd_name="bckint" |
---|
| 4213 | IF ( PRESENT(cd_longname) ) cd_longname="increment to background temperature" |
---|
| 4214 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 4215 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 4216 | CASE (591) |
---|
| 4217 | cd_name="bckins" |
---|
| 4218 | IF ( PRESENT(cd_longname) ) cd_longname="increment to background salinity" |
---|
| 4219 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4220 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity" |
---|
| 4221 | CASE (592) |
---|
| 4222 | cd_name="bckinu" |
---|
| 4223 | IF ( PRESENT(cd_longname) ) cd_longname="increment to background u-velocity" |
---|
| 4224 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4225 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4226 | CASE (593) |
---|
| 4227 | cd_name="bckinv" |
---|
| 4228 | IF ( PRESENT(cd_longname) ) cd_longname="increment to background v-velocity" |
---|
| 4229 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4230 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4231 | CASE (594) |
---|
| 4232 | cd_name="bckineta" |
---|
| 4233 | IF ( PRESENT(cd_longname) ) cd_longname="increment to background SSH" |
---|
| 4234 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4235 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4236 | CASE (610) |
---|
| 4237 | cd_name="tangent_T" |
---|
| 4238 | IF ( PRESENT(cd_longname) ) cd_longname="tangent potential temperature field" |
---|
| 4239 | IF ( PRESENT(cd_unit) ) cd_unit="C" |
---|
| 4240 | IF ( PRESENT(cd_longunit) ) cd_longunit="degree_celcius" |
---|
| 4241 | CASE (611) |
---|
| 4242 | cd_name="tangent_S" |
---|
| 4243 | IF ( PRESENT(cd_longname) ) cd_longname="tangent salinity field" |
---|
| 4244 | IF ( PRESENT(cd_unit) ) cd_unit="PSU" |
---|
| 4245 | IF ( PRESENT(cd_longunit) ) cd_longunit="practical_salinity_scale" |
---|
| 4246 | CASE (612) |
---|
| 4247 | cd_name="tangent_u" |
---|
| 4248 | IF ( PRESENT(cd_longname) ) cd_longname="tangent U zonal current" |
---|
| 4249 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4250 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4251 | CASE (613) |
---|
| 4252 | cd_name="tangent_v" |
---|
| 4253 | IF ( PRESENT(cd_longname) ) cd_longname="tangent V meridional current" |
---|
| 4254 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4255 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4256 | CASE (614) |
---|
| 4257 | cd_name="tangent_w" |
---|
| 4258 | IF ( PRESENT(cd_longname) ) cd_longname="tangent W vertical current" |
---|
| 4259 | IF ( PRESENT(cd_unit) ) cd_unit="m/s" |
---|
| 4260 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter_per_second" |
---|
| 4261 | CASE (615) |
---|
| 4262 | cd_name="tangent_SSH" |
---|
| 4263 | IF ( PRESENT(cd_longname) ) cd_longname="tangent sea surface height above geoid" |
---|
| 4264 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4265 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4266 | CASE (616) |
---|
| 4267 | cd_name="tangent BSF" |
---|
| 4268 | IF ( PRESENT(cd_longname) ) cd_longname="tangent barotropic stream function" |
---|
| 4269 | IF ( PRESENT(cd_unit) ) cd_unit="m3/s" |
---|
| 4270 | IF ( PRESENT(cd_longunit) ) cd_longunit="cubic_meter_per_second" |
---|
| 4271 | CASE (620) |
---|
| 4272 | cd_name="d28_isotherm_depth" |
---|
| 4273 | IF ( PRESENT(cd_longname) ) cd_longname="depth of the D28 isotherm" |
---|
| 4274 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4275 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4276 | CASE (621) |
---|
| 4277 | cd_name="ocean_mixed_layer_thickness_bn2_criterion" |
---|
| 4278 | IF ( PRESENT(cd_longname) ) cd_longname="depth of the ocean mixed layer from the surface with bn2 citerion" |
---|
| 4279 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4280 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4281 | CASE (622) |
---|
| 4282 | cd_name="thermocline_depth" |
---|
| 4283 | IF ( PRESENT(cd_longname) ) cd_longname="depth of the strongest vertical temperature gradient" |
---|
| 4284 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4285 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4286 | CASE (623) |
---|
| 4287 | cd_name="heat_content_of_first_300m" |
---|
| 4288 | IF ( PRESENT(cd_longname) ) cd_longname="heat content of first 300 m" |
---|
| 4289 | IF ( PRESENT(cd_unit) ) cd_unit="J" |
---|
| 4290 | IF ( PRESENT(cd_longunit) ) cd_longunit="joules" |
---|
| 4291 | CASE (624) |
---|
| 4292 | cd_name="turbocline_depth" |
---|
| 4293 | IF ( PRESENT(cd_longname) ) cd_longname="turbocline depth" |
---|
| 4294 | IF ( PRESENT(cd_unit) ) cd_unit="m" |
---|
| 4295 | IF ( PRESENT(cd_longunit) ) cd_longunit="meter" |
---|
| 4296 | CASE (625) |
---|
| 4297 | cd_name="U-energy_transport" |
---|
| 4298 | IF ( PRESENT(cd_longname) ) cd_longname="U-energy transport" |
---|
| 4299 | IF ( PRESENT(cd_unit) ) cd_unit="J/s/m^2" |
---|
| 4300 | IF ( PRESENT(cd_longunit) ) cd_longunit="joules_per_second_per_square_meter" |
---|
| 4301 | CASE (626) |
---|
| 4302 | cd_name="V-energy_transport" |
---|
| 4303 | IF ( PRESENT(cd_longname) ) cd_longname="V-energy transport" |
---|
| 4304 | IF ( PRESENT(cd_unit) ) cd_unit="J/s/m^2" |
---|
| 4305 | IF ( PRESENT(cd_longunit) ) cd_longunit="joules_per_second_per_square_meter" |
---|
| 4306 | CASE default |
---|
| 4307 | cd_name="varname" |
---|
| 4308 | IF ( PRESENT(cd_longname) ) cd_longname="long_varname" |
---|
| 4309 | IF ( PRESENT(cd_unit) ) cd_unit="varunit" |
---|
| 4310 | IF ( PRESENT(cd_longunit) ) cd_longunit="long_varunit" |
---|
| 4311 | END SELECT |
---|
| 4312 | |
---|
| 4313 | END SUBROUTINE get_var_info |
---|
| 4314 | |
---|
| 4315 | END MODULE ioncdf |
---|