--- trunk/libf/phylmd/Mobidic/regr_pr_o3.f90 2008/08/07 15:46:20 19 +++ trunk/phylmd/Mobidic/regr_pr_o3.f 2018/03/20 09:35:59 265 @@ -4,7 +4,7 @@ contains - subroutine regr_pr_o3(o3_mob_regr) + subroutine regr_pr_o3(p3d, o3_mob_regr) ! "regr_pr_o3" stands for "regrid pressure ozone". ! This procedure reads Mobidic ozone mole fraction from @@ -22,15 +22,19 @@ ! We assume that, in the input file, the pressure levels are in ! hPa and strictly increasing. - use conf_gcm_m, only: dayref - use dimens_m, only: iim, jjm, llm - use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, handle_err, & - nf95_get_coord - use netcdf, only: nf90_nowrite, nf90_get_var - use numer_rec, only: assert + use dimensions, only: iim, jjm, llm + use dynetat0_m, only: day_ref use grid_change, only: dyn_phy - use regr1_step_av_m, only: regr1_step_av - use pressure_var, only: p3d + use netcdf, only: nf90_nowrite, nf90_get_var + use netcdf95, only: nf95_open, nf95_close, nf95_inq_varid, handle_err, & + nf95_gw_var + use nr_util, only: assert + use numer_rec_95, only: regr1_step_av + + REAL, intent(in):: p3d(:, :, :) ! (iim + 1, jjm + 1, llm+1) + ! pressure at layer interfaces, in Pa + ! ("p3d(i, j, l)" is at longitude "rlonv(i)", latitude "rlatu(j)", + ! for interface "l") real, intent(out):: o3_mob_regr(:, :, :) ! (iim + 1, jjm + 1, llm) ! (ozone mole fraction from Mobidic adapted to the LMDZ grid) @@ -39,7 +43,7 @@ ! Variables local to the procedure: - real, pointer:: plev(:) + real, allocatable:: plev(:) ! (pressure levels of Mobidic data, in Pa, in strictly increasing order) real, allocatable:: press_in_edg(:) @@ -51,17 +55,22 @@ integer i, j real, allocatable:: r_mob(:, :)! (jjm + 1, n_plev) - ! (ozone mole fraction from Mobidic at day "dayref") + ! (ozone mole fraction from Mobidic at day "day_ref") ! (r_mob(j, k) is at latitude "rlatu(j)" and pressure level "plev(k)".) !------------------------------------------------------------ print *, "Call sequence information: regr_pr_o3" - call assert(shape(o3_mob_regr) == (/iim + 1, jjm + 1, llm/), "regr_pr_o3") + + call assert(shape(o3_mob_regr) == (/iim + 1, jjm + 1, llm/), & + "regr_pr_o3 o3_mob_regr") + call assert(shape(p3d) == (/iim + 1, jjm + 1, llm + 1/), & + "regr_pr_o3 p3d") call nf95_open("coefoz_LMDZ.nc", nf90_nowrite, ncid) - call nf95_get_coord(ncid, "plev", plev) + call nf95_inq_varid(ncid, "plev", varid) + call nf95_gw_var(ncid, varid, plev) ! Convert from hPa to Pa because "regr_pr_av" requires so: plev = plev * 100. n_plev = size(plev) @@ -75,13 +84,11 @@ ! (infinity, but any value guaranteed to be greater than the ! surface pressure would do) - deallocate(plev) ! pointer - call nf95_inq_varid(ncid, "r_Mob", varid) allocate(r_mob(jjm + 1, n_plev)) ! Get data at the right day from the input file: - ncerr = nf90_get_var(ncid, varid, r_mob, start=(/1, 1, dayref/)) + ncerr = nf90_get_var(ncid, varid, r_mob, start=(/1, 1, day_ref/)) call handle_err("nf90_get_var r_Mob", ncerr) ! Latitudes are in increasing order in the input file while ! "rlatu" is in decreasing order so we need to invert order: @@ -89,7 +96,7 @@ call nf95_close(ncid) - ! Regrid in pressure by averaging a step function of pressure. + ! Regrid in pressure by averaging a step function of pressure: do j = 1, jjm + 1 do i = 1, iim if (dyn_phy(i, j)) then