00001 subroutine flgrad_midpoint_type0(fnc,dfdx,dfdy,dfdz,irf,itf,ipf)
00002 use phys_constant, only : long
00003 use coordinate_grav_r, only : hrginv, drginv
00004 use coordinate_grav_theta, only : dthginv
00005 use coordinate_grav_phi, only : dphiginv
00006 use trigonometry_grav_theta, only : hsinthg, hcosthg, hcosecthg
00007 use trigonometry_grav_phi, only : hsinphig, hcosphig
00008 use def_matter, only : rs
00009 implicit none
00010 real(long), pointer :: fnc(:,:,:)
00011 real(long), intent(out) :: dfdx, dfdy, dfdz
00012 real(long) :: gr1, gr2, gr3, hrs, hrsinv
00013 real(long) :: dfncdr, dfncdth, dfncdphi, drsdth, drsdphi
00014 integer, intent(in) :: irf, itf, ipf
00015
00016
00017
00018
00019
00020
00021 dfncdr = 0.25d0 &
00022 & *(fnc(irf,itf ,ipf ) - fnc(irf-1,itf ,ipf ) &
00023 & + fnc(irf,itf-1,ipf ) - fnc(irf-1,itf-1,ipf ) &
00024 & + fnc(irf,itf ,ipf-1) - fnc(irf-1,itf ,ipf-1) &
00025 & + fnc(irf,itf-1,ipf-1) - fnc(irf-1,itf-1,ipf-1))*drginv(irf)
00026 dfncdth = 0.25d0 &
00027 & *(fnc(irf ,itf,ipf ) - fnc(irf ,itf-1,ipf ) &
00028 & + fnc(irf-1,itf,ipf ) - fnc(irf-1,itf-1,ipf ) &
00029 & + fnc(irf ,itf,ipf-1) - fnc(irf ,itf-1,ipf-1) &
00030 & + fnc(irf-1,itf,ipf-1) - fnc(irf-1,itf-1,ipf-1))*dthginv
00031 dfncdphi = 0.25d0 &
00032 & *(fnc(irf ,itf ,ipf) - fnc(irf ,itf ,ipf-1) &
00033 & + fnc(irf-1,itf ,ipf) - fnc(irf-1,itf ,ipf-1) &
00034 & + fnc(irf ,itf-1,ipf) - fnc(irf ,itf-1,ipf-1) &
00035 & + fnc(irf-1,itf-1,ipf) - fnc(irf-1,itf-1,ipf-1))*dphiginv
00036 drsdth = 0.5d0 &
00037 & *(rs(itf,ipf ) - rs(itf-1,ipf ) &
00038 & + rs(itf,ipf-1) - rs(itf-1,ipf-1))*dthginv
00039 drsdphi = 0.5d0 &
00040 & *(rs(itf ,ipf) - rs(itf ,ipf-1) &
00041 & + rs(itf-1,ipf) - rs(itf-1,ipf-1))*dphiginv
00042 hrs = 0.25d0 &
00043 & *(rs(itf,ipf ) + rs(itf-1,ipf ) &
00044 & + rs(itf,ipf-1) + rs(itf-1,ipf-1))
00045 hrsinv = 1.0d0/hrs
00046
00047
00048
00049 gr1 = dfncdr*hrsinv
00050 gr2 = dfncdth*hrginv(irf)*hrsinv &
00051 & - drsdth*hrsinv*gr1
00052 gr3 = dfncdphi*hrginv(irf)*hrsinv*hcosecthg(itf) &
00053 & - drsdphi*hrsinv*hcosecthg(itf)*gr1
00054
00055 dfdx = gr1 * hsinthg(itf) * hcosphig(ipf) &
00056 & + gr2 * hcosthg(itf) * hcosphig(ipf) &
00057 & - gr3 * hsinphig(ipf)
00058 dfdy = gr1 * hsinthg(itf) * hsinphig(ipf) &
00059 & + gr2 * hcosthg(itf) * hsinphig(ipf) &
00060 & + gr3 * hcosphig(ipf)
00061 dfdz = gr1 * hcosthg(itf) &
00062 & - gr2 * hsinthg(itf)
00063
00064 end subroutine flgrad_midpoint_type0