New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 15540 for NEMO/branches/2021/dev_r14116_HPC-10_mcastril_Mixed_Precision_implementation/src/OCE/OBS/obs_averg_h2d.F90 – NEMO

Ignore:
Timestamp:
2021-11-26T12:27:56+01:00 (3 years ago)
Author:
sparonuz
Message:

Mixed precision version, tested up to 30 years on ORCA2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2021/dev_r14116_HPC-10_mcastril_Mixed_Precision_implementation/src/OCE/OBS/obs_averg_h2d.F90

    r14644 r15540  
    8282         & kmaxjfp,  &          ! Max size of model points in j-direction for obs footprint 
    8383         & k2dint               ! Averaging scheme options - see header 
    84       REAL(KIND=wp), INTENT(INOUT) :: & 
     84      REAL(KIND=dp), INTENT(INOUT) :: & 
    8585         & plam, &              ! Geographical (lat,lon) coordinates of 
    8686         & pphi                 ! observation 
    87       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp), INTENT(IN) :: & 
     87      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp), INTENT(IN) :: & 
    8888         & pglam, &             ! Model variable lon 
    8989         & pgphi                ! Model variable lat 
    90       REAL(KIND=wp), DIMENSION(kmaxifp+1,kmaxjfp+1), INTENT(IN) :: & 
     90      REAL(KIND=dp), DIMENSION(kmaxifp+1,kmaxjfp+1), INTENT(IN) :: & 
    9191         & pglamf, &            ! Model variable lon at corners of grid-boxes 
    9292         & pgphif               ! Model variable lat at corners of grid-boxes 
    93       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
     93      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
    9494         & pmask                ! Model variable mask 
    95       REAL(KIND=wp), INTENT(IN) :: & 
     95      REAL(KIND=dp), INTENT(IN) :: & 
    9696         & plamscl, &           ! Diameter (lat,lon) of obs footprint in metres 
    9797         & pphiscl              ! This is the full width (rather than half-width) 
    9898      LOGICAL, INTENT(IN) :: & 
    9999         & lindegrees           ! T=> obs footprint specified in degrees, F=> in metres 
    100       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(OUT) ::  & 
     100      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(OUT) ::  & 
    101101         & pweig                ! Weights for averaging 
    102102      INTEGER, INTENT(IN), OPTIONAL :: & 
     
    170170         & kmaxjfp              ! Max size of model points in j-direction for obs footprint 
    171171 
    172       REAL(KIND=wp), INTENT(IN) :: & 
    173          & plam, & 
    174          & pphi                 ! Geographical (lat,lon) coordinates of 
     172      REAL(KIND=dp), INTENT(IN) ::  plam, pphi 
     173 
     174 
     175 
    175176                                ! observation 
    176       REAL(KIND=wp), INTENT(IN) :: & 
     177      REAL(KIND=dp), INTENT(IN) :: & 
    177178         & plamscl, &           ! Diameter (lat,lon) of obs footprint in metres or degrees (see below) 
    178179         & pphiscl              ! This is the full width (rather than half-width) 
    179180      LOGICAL, INTENT(IN) :: & 
    180181         & lindegrees           ! T=>scales specified in degrees, F=> in metres 
    181       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
     182      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
    182183         & pmask                ! Model variable mask 
    183       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp), INTENT(IN) :: & 
     184      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp), INTENT(IN) :: & 
    184185         & pglam, &             ! Model variable lon 
    185186         & pgphi                ! Model variable lat 
    186       REAL(KIND=wp), DIMENSION(kmaxifp+1,kmaxjfp+1), INTENT(IN) :: & 
     187      REAL(KIND=dp), DIMENSION(kmaxifp+1,kmaxjfp+1), INTENT(IN) :: & 
    187188         & pglamf, &             ! Model variable lon at corners of grid boxes 
    188189         & pgphif                ! Model variable lat at corners of grid boxes 
    189       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(OUT) ::  & 
     190      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(OUT) ::  & 
    190191         & pweig                ! Weights for interpolation 
    191192 
     
    197198         & jnumsubgrid = 20     ! The number of sub grid-boxes (in x and y directions) used to approximate area of obs fp 
    198199 
    199       REAL(KIND=wp), DIMENSION(4) :: & 
     200      REAL(KIND=dp), DIMENSION(4) :: & 
    200201         & zxvert, zyvert, &    ! The lon/lat of the vertices(corners) of the grid box in m relative to centre of obs fp 
    201202         & zdist                ! Distance of each vertex to the centre of the obs footprint 
    202       REAL(KIND=wp), DIMENSION(4) :: & 
     203      REAL(KIND=dp), DIMENSION(4) :: & 
    203204         & zxgrid, zygrid, &      ! Distance of each vertex of grid box to the centre of the grid box in x/y directions 
    204205         & zdgrid 
    205       REAL(KIND=wp) :: & 
     206      REAL(KIND=dp) :: & 
    206207         & zdx, zdy, &          ! The sub grid-box sizes (in metres) 
    207208         & zarea_subbox, &      ! The area of each sub grid-box (in metres squared) 
     
    210211         & zarea_fp, &          ! Total area of obs footprint within the grid box 
    211212         & zareabox             ! Total area of the grid box 
    212       REAL(KIND=wp) :: & 
     213      REAL(KIND=dp) :: & 
    213214         & zphiscl_m, &         ! Diameter of obs footprint in metres 
    214215         & zlamscl_m 
     
    353354         & kmaxjfp              ! Max size of model points in j-direction for obs footprint 
    354355 
    355       REAL(KIND=wp), INTENT(IN) :: & 
    356          & plam, & 
    357          & pphi                 ! Geographical (lat,lon) coordinates of 
     356      REAL(KIND=dp), INTENT(IN) ::  plam, pphi ! Geographical (lat,lon) coordinates of 
     357 
     358 
     359 
    358360                                ! observation 
    359       REAL(KIND=wp), INTENT(IN) :: & 
    360          & plamscl, & 
    361          & pphiscl              ! Width in x/y directions of obs footprint in metres 
     361      REAL(KIND=dp), INTENT(IN) ::  plamscl, pphiscl  ! Width in x/y directions of obs footprint in metres 
     362 
     363 
     364 
    362365                                ! This is the full width (rather than half-width) 
    363366      LOGICAL, INTENT(IN) :: & 
    364367         & lindegrees           !T=> scales specified in degrees, F=> in metres 
    365       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
     368      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
    366369         & pmask                ! Model variable mask 
    367       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp), INTENT(IN) :: & 
     370      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp), INTENT(IN) :: & 
    368371         & pglam, &             ! Model variable lat at centre of grid boxes 
    369372         & pgphi                ! Model variable lon at centre of grid boxes 
    370       REAL(KIND=wp), DIMENSION(kmaxifp+1,kmaxjfp+1), INTENT(IN) :: & 
     373      REAL(KIND=dp), DIMENSION(kmaxifp+1,kmaxjfp+1), INTENT(IN) :: & 
    371374         & pglamf, &             ! Model variable lat at corners of grid boxes 
    372375         & pgphif                ! Model variable lon at corners of grid boxes 
    373       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(OUT) ::  & 
     376      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(OUT) ::  & 
    374377         & pweig                ! Weights for interpolation 
    375378 
     
    379382      INTEGER, DIMENSION(4) :: & 
    380383         & jnumvert 
    381       REAL(KIND=wp), DIMENSION(4) :: & 
     384      REAL(KIND=dp), DIMENSION(4) :: & 
    382385         & zxvert, zyvert         ! The lon/lat of the vertices(corners) of the grid box in m relative to centre of obs fp 
    383       REAL(KIND=wp), DIMENSION(4) :: & 
     386      REAL(KIND=dp), DIMENSION(4) :: & 
    384387         & zdist                  ! Distance of each vertex to the centre of the obs footprint 
    385       REAL(KIND=wp), DIMENSION(4) :: & 
     388      REAL(KIND=dp), DIMENSION(4) :: & 
    386389         & zxgrid, zygrid, &      ! Distance of each vertex of grid box to the centre of the grid box in x/y directions 
    387390         & zdgrid 
    388       REAL(KIND=wp) :: & 
     391      REAL(KIND=dp) :: & 
    389392         & zareabox, &            ! Total area of grid box 
    390393         & zarea_fp, &            ! Total area of obs footprint 
    391394         & zarea_intersect        ! Area of the intersection between the grid box and the obs footprint 
    392       REAL(KIND=wp) :: & 
     395      REAL(KIND=dp) :: & 
    393396         & zlamscl_m, & 
    394397         & zphiscl_m              ! Total width (lat,lon) of obs footprint in metres 
    395       REAL(KIND=wp) :: & 
     398      REAL(KIND=dp) :: & 
    396399         & z_awidth, z_aheight, & ! Width and height of model grid box 
    397400         & z_cwidth, z_cheight    ! Width and height of union of model grid box and obs footprint 
    398       REAL(KIND=wp) :: & 
     401      REAL(KIND=dp) :: & 
    399402         & zleft, zright, &       ! Distance (metres) of corners area of intersection 
    400403         & ztop, zbottom          ! between grid box and obs footprint 
     
    507510         & kmaxifp,   &         ! Max size of model points in i-direction for obs footprint 
    508511         & kmaxjfp              ! Max size of model points in j-direction for obs footprint 
    509       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
     512      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
    510513         & pweig                ! Interpolation weights 
    511       REAL(KIND=wp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
     514      REAL(KIND=dp), DIMENSION(kmaxifp,kmaxjfp,kpk2), INTENT(IN) :: & 
    512515         & pmod                 ! Model variable to interpolate 
    513       REAL(KIND=wp), DIMENSION(kpk2), INTENT(OUT) ::  & 
     516      REAL(KIND=dp), DIMENSION(kpk2), INTENT(OUT) ::  & 
    514517         & pobsk                ! Model profile interpolated to obs (i,j) pt 
    515518 
     
    518521      INTEGER :: & 
    519522         & ikmax 
    520       REAL(KIND=wp) :: & 
    521          & zsum 
     523      REAL(KIND=dp) ::  zsum 
     524 
     525 
    522526 
    523527      !------------------------------------------------------------------------ 
     
    574578      INTEGER , INTENT(IN) :: & 
    575579         & k2dint                   !Type of interpolation/averaging used 
    576       REAL(KIND=wp), INTENT(IN) :: & 
     580      REAL(KIND=dp), INTENT(IN) :: & 
    577581         & plamscl,   &             !Total width/radius in metres of the observation footprint 
    578582         & pphiscl                  ! 
    579583      LOGICAL, INTENT(IN) :: & 
    580584         & lindegrees               !T=> plamscl and pphiscl are specified in degrees 
    581       REAL(KIND=wp), DIMENSION(jpi,jpj), INTENT(IN) :: & 
     585      REAL(KIND=dp), DIMENSION(jpi,jpj), INTENT(IN) :: & 
    582586         & pmask                    !Land/sea mask 
    583587                                    !F=> plamscl and pphiscl are specified in metres 
     
    587591 
    588592      !! * Local variables 
    589       REAL(KIND=wp) :: & 
     593      REAL(KIND=dp) :: & 
    590594         & ze1min,     &            !Minimum global grid-size in i,j directions 
    591595         & ze2min 
    592       REAL(KIND=wp) :: & 
     596      REAL(KIND=dp) :: & 
    593597         & zphiscl_m, & 
    594598         & zlamscl_m 
     
    605609            !If the scales are specified in degrees, work out the max  
    606610            !distance (metres) in x/y directions 
    607             CALL obs_deg2dist( jpi, jpj, CASTWP(glamt), CASTWP(gphit), & 
     611            CALL obs_deg2dist( jpi, jpj, glamt, gphit, & 
    608612               &               plamscl, pphiscl, zlamscl_m, zphiscl_m ) 
    609613         ELSE 
     
    655659      INTEGER , INTENT(IN) :: & 
    656660         & ki, kj                   !x/y dimensions of input lat/lon variables 
    657       REAL(KIND=wp), INTENT(IN), DIMENSION(ki,kj) :: & 
     661      REAL(KIND=dp), INTENT(IN), DIMENSION(ki,kj) :: & 
    658662         & pglam, pgphi             !Longitude and latitudes of grid points 
    659       REAL(KIND=wp), INTENT(IN) :: & 
     663      REAL(KIND=dp), INTENT(IN) :: & 
    660664         & plamscl_deg,   &         !Size in degrees of the observation footprint 
    661665         & pphiscl_deg              ! 
    662       REAL(KIND=wp), INTENT(OUT) :: & 
     666      REAL(KIND=dp), INTENT(OUT) :: & 
    663667         & plamscl_max, &           !Maximum size of obs footprint in metres 
    664668         & pphiscl_max 
     
    667671      INTEGER :: & 
    668672         & ji, jj                   !Counters 
    669       REAL(KIND=wp) :: & 
     673      REAL(KIND=dp) :: & 
    670674         & zlon1, zlon2, &          !Lon values surrounding centre of grid point 
    671675         & zlat1, zlat2, &          !Lat values surrounding centre of grid point 
    672676         & zdlat, zdlon             !Distance in radians in lat/lon directions 
    673       REAL(KIND=wp) :: & 
     677      REAL(KIND=dp) :: & 
    674678         & za1, za2, za, zc, zd 
    675679       
     
    740744      !! * Modules used 
    741745      !! * Arguments 
    742          REAL(KIND=wp), INTENT(IN) :: & 
     746         REAL(KIND=dp), INTENT(IN) :: & 
    743747            &  pglam_bl, pglam_br, &       !lon at corners of grid box 
    744748            &  pglam_tl, pglam_tr 
    745          REAL(KIND=wp), INTENT(IN) :: & 
     749         REAL(KIND=dp), INTENT(IN) :: & 
    746750            &  pgphi_bl, pgphi_br, &       !lat at corners of grid box 
    747751            &  pgphi_tl, pgphi_tr 
    748          REAL(KIND=wp), INTENT(IN) :: & 
     752         REAL(KIND=dp), INTENT(IN) :: & 
    749753            &  pphi, plam                  !lat/lon of centre of obs footprint 
    750          REAL(KIND=wp), DIMENSION(4), INTENT(OUT) :: & 
     754         REAL(KIND=dp), DIMENSION(4), INTENT(OUT) :: & 
    751755            &  pxvert, pyvert              !x/y location (in metres relative to centre of obs footprint) of corners 
    752          REAL(KIND=wp), DIMENSION(4), INTENT(OUT) :: & 
     756         REAL(KIND=dp), DIMENSION(4), INTENT(OUT) :: & 
    753757            &  pdist                       !distance (in metres) of each corner relative to centre of obs footprint 
    754758 
     
    756760         INTEGER :: & 
    757761            &  jvert                       !Counter for corners 
    758          REAL(KIND=wp) :: & 
     762         REAL(KIND=dp) :: & 
    759763            &  zphi, zlam                  !Local values for lon/lat of corners 
    760          REAL(KIND=wp) :: &  
     764         REAL(KIND=dp) :: &  
    761765            &  za1, za2,  &                !For great circle distance calculations 
    762766            &  zb1, zb2,  & 
    763767            &  zc1, zc2 
    764          REAL(KIND=wp) :: & 
     768         REAL(KIND=dp) :: & 
    765769            &  zdist_centre_lat, &         !Distances in lat/lon directions (in metres) 
    766770            &  zdist_centre_lon 
Note: See TracChangeset for help on using the changeset viewer.