Changeset 2641 in lmdz_wrf


Ignore:
Timestamp:
Jun 28, 2019, 9:38:35 PM (5 years ago)
Author:
lfita
Message:

Adding:

  • `curl2D_1o': Subroutine to compute the first order curl of a 2D vectorial field
  • `divergence2D_1o': Subroutine to compute the first order divergence of a 2D vectorial field
  • `gradient2D_1o': Subroutine to compute the first order gradient of a 2D field
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/module_scientific.f90

    r2617 r2641  
    1818! coincident_polygon: Subroutine to provide the intersection polygon between two polygons
    1919! crossingpoints_polys: Subroutine to provide the crossing points between two polygons
     20! curl2D_1o: Subroutine to compute the first order curl of a 2D vectorial field
    2021! distanceRK: Function to provide the distance between two points
     22! divergence2D_1o: Subroutine to compute the first order divergence of a 2D vectorial field
    2123! FindMinimumR_K*: Function returns the location of the minimum in the section between Start and End.
    2224! fill3DI_2Dvec: Subroutine to fill a 3D integer matrix from a series of indices from a 2D matrix
    2325! fill3DR_2Dvec: Subroutine to fill a 3D float matrix from a series of indices from a 2D matrix
     26! gradient2D_1o: Subroutine to compute the first order gradient of a 2D field
    2427! grid_within_polygon: Subroutine to determine which grid cells from a matrix lay inside a polygon
    2528! grid_spacepercen: Subroutine to compute the space-percentages of a series of grid cells (B) which lay inside another
     
    76027605  END SUBROUTINE crossingpoints_polys
    76037606
     7607  SUBROUTINE gradient2D_1o(dx, dy, var, dsx, dsy, grad)
     7608  ! Subroutine to compute the first order gradient of a 2D field
     7609
     7610    IMPLICIT NONE
     7611
     7612    INTEGER, INTENT(in)                                  :: dx, dy
     7613    REAL(r_k), DIMENSION(dx,dy), INTENT(in)              :: var, dsx, dsy
     7614    REAL(r_k), DIMENSION(dx,dy,2), INTENT(out)           :: grad
     7615
     7616! Local
     7617    INTEGER                                              :: i, j
     7618
     7619!!!!!!! Variables
     7620! dx, dy: shape of the 2D field
     7621! var: variable
     7622! dsx, dsy: matrices of distances betweeen grid points along each axis
     7623! grad: gradient
     7624
     7625    fname = 'gradient2D_1o'
     7626
     7627    grad = zeroRK
     7628
     7629    DO i=2, dx-1
     7630      DO j=2, dy-1
     7631        grad(i,j,:) = (/ (var(i+1,j)-var(i,j))/dsx(i,j), (var(i,j+1)-var(i,j))/dsy(i,j) /)
     7632      END DO
     7633    END DO
     7634
     7635  END SUBROUTINE gradient2D_1o
     7636
     7637  SUBROUTINE divergence2D_1o(dx, dy, dsx, dsy, xvar, yvar, diver)
     7638  ! Subroutine to compute the first order divergence of a 2D vectorial field
     7639
     7640    IMPLICIT NONE
     7641
     7642    INTEGER, INTENT(in)                                  :: dx, dy
     7643    REAL(r_k), DIMENSION(dx,dy), INTENT(in)              :: xvar, yvar, dsx, dsy
     7644    REAL(r_k), DIMENSION(dx,dy), INTENT(out)             :: diver
     7645
     7646! Local
     7647    INTEGER                                              :: i, j
     7648
     7649!!!!!!! Variables
     7650! dx, dy: shape of the 2D field
     7651! xvar, yvar: x-y components of vectorial variable
     7652! dsx, dsy: matrices of distances betweeen grid points along each axis
     7653! diver: divergence
     7654
     7655    fname = 'divergence2D_1o'
     7656
     7657    diver = zeroRK
     7658
     7659    DO i=2, dx-1
     7660      DO j=2, dy-1
     7661        diver(i,j) = (xvar(i+1,j)-xvar(i,j))/dsx(i,j) + (yvar(i,j+1)-yvar(i,j))/dsy(i,j)
     7662      END DO
     7663    END DO
     7664
     7665  END SUBROUTINE divergence2D_1o
     7666
     7667  SUBROUTINE curl2D_1o(dx, dy, dsx, dsy, xvar, yvar, curl)
     7668  ! Subroutine to compute the first order curl of a 2D vectorial field
     7669
     7670    IMPLICIT NONE
     7671
     7672    INTEGER, INTENT(in)                                  :: dx, dy
     7673    REAL(r_k), DIMENSION(dx,dy), INTENT(in)              :: xvar, yvar, dsx, dsy
     7674    REAL(r_k), DIMENSION(dx,dy), INTENT(out)             :: curl
     7675
     7676! Local
     7677    INTEGER                                              :: i, j
     7678
     7679!!!!!!! Variables
     7680! dx, dy: shape of the 2D field
     7681! xvar, yvar: x-y components of vectorial variable
     7682! dsx, dsy: matrices of distances betweeen grid points along each axis
     7683! curl: curl
     7684
     7685    fname = 'curl2D_1o'
     7686
     7687    curl = zeroRK
     7688
     7689    DO i=1, dx-1
     7690      DO j=1, dy-1
     7691        curl(i,j) = (yvar(i+1,j)-yvar(i,j))/dsx(i,j) - (xvar(i,j+1)-xvar(i,j))/dsy(i,j)
     7692      END DO
     7693    END DO
     7694
     7695  END SUBROUTINE curl2D_1o
     7696
    76047697END MODULE module_scientific
Note: See TracChangeset for help on using the changeset viewer.