Changeset 1263 for LMDZ4/branches/LMDZ4-dev/libf/bibio
- Timestamp:
- Nov 17, 2009, 2:00:14 PM (15 years ago)
- Location:
- LMDZ4/branches/LMDZ4-dev/libf/bibio
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ4/branches/LMDZ4-dev/libf/bibio/netcdf95.F90
r1157 r1263 25 25 ! criticisms for some (not all) procedures. 26 26 27 ! "nf95_get_att" is more secure than "nf90_get_att" because it 28 ! checks that the "values" argument is long enough and removes the 29 ! null terminator, if any. 30 27 31 ! This module replaces some of the official NetCDF procedures. 28 32 ! This module also provides the procedures "handle_err" and "nf95_gw_var". … … 35 39 use nf95_gw_var_m 36 40 use nf95_put_att_m 41 use nf95_get_att_m 37 42 use simple 38 43 use handle_err_m -
LMDZ4/branches/LMDZ4-dev/libf/bibio/nf95_def_var_m.F90
r1157 r1263 1 1 ! $Id$ 2 2 module nf95_def_var_m 3 4 ! The generic procedure name "nf90_def_var" applies to 5 ! "nf90_def_var_Scalar" but we cannot apply the generic procedure name 6 ! "nf95_def_var" to "nf95_def_var_scalar" because of the additional 7 ! optional argument. 8 ! "nf95_def_var_scalar" cannot be distinguished from "nf95_def_var_oneDim". 3 9 4 10 implicit none … … 9 15 10 16 private 11 public nf95_def_var 17 public nf95_def_var, nf95_def_var_scalar 12 18 13 19 contains 20 21 subroutine nf95_def_var_scalar(ncid, name, xtype, varid, ncerr) 22 23 use netcdf, only: nf90_def_var 24 use handle_err_m, only: handle_err 25 26 integer, intent( in) :: ncid 27 character (len = *), intent( in) :: name 28 integer, intent( in) :: xtype 29 integer, intent(out) :: varid 30 integer, intent(out), optional:: ncerr 31 32 ! Variable local to the procedure: 33 integer ncerr_not_opt 34 35 !------------------- 36 37 ncerr_not_opt = nf90_def_var(ncid, name, xtype, varid) 38 if (present(ncerr)) then 39 ncerr = ncerr_not_opt 40 else 41 call handle_err("nf95_def_var_scalar " // name, ncerr_not_opt, ncid) 42 end if 43 44 end subroutine nf95_def_var_scalar 45 46 !*********************** 14 47 15 48 subroutine nf95_def_var_oneDim(ncid, name, xtype, dimids, varid, ncerr) -
LMDZ4/branches/LMDZ4-dev/libf/bibio/nf95_put_var_m.F90
r1157 r1263 5 5 6 6 interface nf95_put_var 7 module procedure nf95_put_var_1D_FourByteReal, & 7 module procedure nf95_put_var_FourByteReal, nf95_put_var_FourByteInt, & 8 nf95_put_var_1D_FourByteReal, nf95_put_var_1D_FourByteInt, & 8 9 nf95_put_var_2D_FourByteReal, nf95_put_var_3D_FourByteReal, & 9 10 nf95_put_var_4D_FourByteReal … … 19 20 contains 20 21 22 subroutine nf95_put_var_FourByteReal(ncid, varid, values, start, ncerr) 23 24 use netcdf, only: nf90_put_var 25 use handle_err_m, only: handle_err 26 27 integer, intent( in) :: ncid, varid 28 real, intent( in) :: values 29 integer, dimension(:), optional, intent( in) :: start 30 integer, intent(out), optional:: ncerr 31 32 ! Variable local to the procedure: 33 integer ncerr_not_opt 34 35 !------------------- 36 37 ncerr_not_opt = nf90_put_var(ncid, varid, values, start) 38 if (present(ncerr)) then 39 ncerr = ncerr_not_opt 40 else 41 call handle_err("nf95_put_var_FourByteReal", ncerr_not_opt, ncid, & 42 varid) 43 end if 44 45 end subroutine nf95_put_var_FourByteReal 46 47 !*********************** 48 49 subroutine nf95_put_var_FourByteInt(ncid, varid, values, start, ncerr) 50 51 use netcdf, only: nf90_put_var 52 use handle_err_m, only: handle_err 53 54 integer, intent( in) :: ncid, varid 55 integer, intent( in) :: values 56 integer, dimension(:), optional, intent( in) :: start 57 integer, intent(out), optional:: ncerr 58 59 ! Variable local to the procedure: 60 integer ncerr_not_opt 61 62 !------------------- 63 64 ncerr_not_opt = nf90_put_var(ncid, varid, values, start) 65 if (present(ncerr)) then 66 ncerr = ncerr_not_opt 67 else 68 call handle_err("nf95_put_var_FourByteInt", ncerr_not_opt, ncid, & 69 varid) 70 end if 71 72 end subroutine nf95_put_var_FourByteInt 73 74 !*********************** 75 21 76 subroutine nf95_put_var_1D_FourByteReal(ncid, varid, values, start, count, & 22 77 stride, map, ncerr) … … 45 100 46 101 end subroutine nf95_put_var_1D_FourByteReal 102 103 !*********************** 104 105 subroutine nf95_put_var_1D_FourByteInt(ncid, varid, values, start, count, & 106 stride, map, ncerr) 107 108 use netcdf, only: nf90_put_var 109 use handle_err_m, only: handle_err 110 111 integer, intent(in) :: ncid, varid 112 integer, intent(in) :: values(:) 113 integer, dimension(:), optional, intent(in) :: start, count, stride, map 114 integer, intent(out), optional:: ncerr 115 116 ! Variable local to the procedure: 117 integer ncerr_not_opt 118 119 !------------------- 120 121 ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, & 122 map) 123 if (present(ncerr)) then 124 ncerr = ncerr_not_opt 125 else 126 call handle_err("nf95_put_var_1D_FourByteInt", ncerr_not_opt, ncid, & 127 varid) 128 end if 129 130 end subroutine nf95_put_var_1D_FourByteInt 47 131 48 132 !*********************** -
LMDZ4/branches/LMDZ4-dev/libf/bibio/regr1_step_av_m.F90
r1157 r1263 17 17 ! The difference between the procedures is the rank of the first argument. 18 18 19 module procedure regr11_step_av, regr12_step_av, regr13_step_av 19 module procedure regr11_step_av, regr12_step_av, regr13_step_av, & 20 regr14_step_av 20 21 end interface 21 22 … … 203 204 end function regr13_step_av 204 205 206 !******************************************** 207 208 function regr14_step_av(vs, xs, xt) result(vt) 209 210 ! "vs" has rank 4. 211 212 use assert_eq_m, only: assert_eq 213 use assert_m, only: assert 214 use interpolation, only: locate 215 216 real, intent(in):: vs(:, :, :, :) ! values of steps on the source grid 217 ! (Step "is" is between "xs(is)" and "xs(is + 1)".) 218 219 real, intent(in):: xs(:) 220 ! (edges of steps on the source grid, in strictly increasing order) 221 222 real, intent(in):: xt(:) 223 ! (edges of cells of the target grid, in strictly increasing order) 224 225 real vt(size(xt) - 1, size(vs, 2), size(vs, 3), size(vs, 4)) 226 ! (average values on the target grid) 227 ! (Cell "it" is between "xt(it)" and "xt(it + 1)".) 228 229 ! Variables local to the procedure: 230 integer is, it, ns, nt 231 real left_edge 232 233 !--------------------------------------------- 234 235 ns = assert_eq(size(vs, 1), size(xs) - 1, "regr14_step_av ns") 236 nt = size(xt) - 1 237 238 ! Quick check on sort order: 239 call assert(xs(1) < xs(2), "regr14_step_av xs bad order") 240 call assert(xt(1) < xt(2), "regr14_step_av xt bad order") 241 242 call assert(xs(1) <= xt(1) .and. xt(nt + 1) <= xs(ns + 1), & 243 "regr14_step_av extrapolation") 244 245 is = locate(xs, xt(1)) ! 1 <= is <= ns, because we forbid extrapolation 246 do it = 1, nt 247 ! 1 <= is <= ns 248 ! xs(is) <= xt(it) < xs(is + 1) 249 ! Compute "vt(it, :, :, :)": 250 left_edge = xt(it) 251 vt(it, :, :, :) = 0. 252 do while (xs(is + 1) < xt(it + 1)) 253 ! 1 <= is <= ns - 1 254 vt(it, :, :, :) = vt(it, :, :, :) + (xs(is + 1) - left_edge) & 255 * vs(is, :, :, :) 256 is = is + 1 257 left_edge = xs(is) 258 end do 259 ! 1 <= is <= ns 260 vt(it, :, :, :) = (vt(it, :, :, :) + (xt(it + 1) - left_edge) & 261 * vs(is, :, :, :)) / (xt(it + 1) - xt(it)) 262 if (xs(is + 1) == xt(it + 1)) is = is + 1 263 ! 1 <= is <= ns .or. it == nt 264 end do 265 266 end function regr14_step_av 267 205 268 end module regr1_step_av_m -
LMDZ4/branches/LMDZ4-dev/libf/bibio/regr3_lint_m.F90
r1157 r1263 11 11 ! input array. 12 12 ! The difference betwwen the procedures is the rank of the first argument. 13 module procedure regr33_lint 13 module procedure regr33_lint, regr34_lint 14 14 end interface 15 15 … … 57 57 end function regr33_lint 58 58 59 !********************************************************* 60 61 function regr34_lint(vs, xs, xt) result(vt) 62 63 ! "vs" has rank 4. 64 65 use assert_eq_m, only: assert_eq 66 use interpolation, only: hunt 67 68 real, intent(in):: vs(:, :, :, :) 69 ! (values of the function at source points "xs") 70 71 real, intent(in):: xs(:) 72 ! (abscissas of points in source grid, in strictly monotonic order) 73 74 real, intent(in):: xt(:) 75 ! (abscissas of points in target grid) 76 77 real vt(size(vs, 1), size(vs, 2), size(xt), size(vs, 4)) 78 ! (values of the function on the target grid) 79 80 ! Variables local to the procedure: 81 integer is, it, ns 82 integer is_b ! "is" bound between 1 and "ns - 1" 83 84 !-------------------------------------- 85 86 ns = assert_eq(size(vs, 3), size(xs), "regr34_lint ns") 87 88 is = -1 ! go immediately to bisection on first call to "hunt" 89 90 do it = 1, size(xt) 91 call hunt(xs, xt(it), is) 92 is_b = min(max(is, 1), ns - 1) 93 vt(:, :, it, :) = ((xs(is_b+1) - xt(it)) * vs(:, :, is_b, :) & 94 + (xt(it) - xs(is_b)) * vs(:, :, is_b+1, :)) & 95 / (xs(is_b+1) - xs(is_b)) 96 end do 97 98 end function regr34_lint 99 59 100 end module regr3_lint_m -
LMDZ4/branches/LMDZ4-dev/libf/bibio/simple.F90
r1157 r1263 118 118 ! unknown in the calling procedure, before the call. 119 119 ! Here we use a better solution: a pointer argument array. 120 ! This procedure associates and defines '"dimids" if it is present.120 ! This procedure associates and defines "dimids" if it is present. 121 121 122 122 use netcdf, only: nf90_inquire_variable, nf90_max_var_dims
Note: See TracChangeset
for help on using the changeset viewer.