Changeset 1395 for trunk/LMDZ.GENERIC


Ignore:
Timestamp:
Mar 12, 2015, 12:45:17 PM (10 years ago)
Author:
emillour
Message:

All GCMS:
Some cleanup and tidying on the dynamics/physics interface.
Essentially affects the "iniphysiq" routine in all physics packages.
EM

Location:
trunk/LMDZ.GENERIC/libf
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/libf/dyn3d/gcm.F

    r1216 r1395  
    55      use control_mod, only: nday, day_step, iperiod, iphysiq,
    66     &                       iconser, ecritphy, idissip
    7       use comgeomphy, only: initcomgeomphy
     7!      use comgeomphy, only: initcomgeomphy
    88      IMPLICIT NONE
    99
     
    159159c    variables pour l'initialisation de la physique :
    160160c    ------------------------------------------------
    161       INTEGER ngridmx
    162       PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
    163       REAL zcufi(ngridmx),zcvfi(ngridmx)
    164       REAL latfi(ngridmx),lonfi(ngridmx)
    165       REAL airefi(ngridmx)
    166       SAVE latfi, lonfi, airefi
    167       INTEGER i,j
     161!      INTEGER ngridmx
     162!      PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
     163!      REAL zcufi(ngridmx),zcvfi(ngridmx)
     164!      REAL latfi(ngridmx),lonfi(ngridmx)
     165!      REAL airefi(ngridmx)
     166!      SAVE latfi, lonfi, airefi
     167!      INTEGER i,j
    168168
    169169c-----------------------------------------------------------------------
     
    183183!#ifdef CPP_PHYS
    184184      CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/))
    185       call initcomgeomphy
     185!      call initcomgeomphy ! now done in iniphysiq
    186186!#endif
    187187!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
    231231
    232232!      IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN
    233          latfi(1)=rlatu(1)
    234          lonfi(1)=0.
    235          zcufi(1) = cu(1)
    236          zcvfi(1) = cv(1)
    237          DO j=2,jjm
    238             DO i=1,iim
    239                latfi((j-2)*iim+1+i)= rlatu(j)
    240                lonfi((j-2)*iim+1+i)= rlonv(i)
    241                zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
    242                zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
    243             ENDDO
    244          ENDDO
    245          latfi(ngridmx)= rlatu(jjp1)
    246          lonfi(ngridmx)= 0.
    247          zcufi(ngridmx) = cu(ip1jm+1)
    248          zcvfi(ngridmx) = cv(ip1jm-iim)
    249 
    250          ! build airefi(), mesh area on physics grid
    251          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
    252          ! Poles are single points on physics grid
    253          airefi(1)=airefi(1)*iim
    254          airefi(ngridmx)=airefi(ngridmx)*iim
     233!         latfi(1)=rlatu(1)
     234!         lonfi(1)=0.
     235!         zcufi(1) = cu(1)
     236!         zcvfi(1) = cv(1)
     237!         DO j=2,jjm
     238!            DO i=1,iim
     239!               latfi((j-2)*iim+1+i)= rlatu(j)
     240!               lonfi((j-2)*iim+1+i)= rlonv(i)
     241!               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
     242!               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
     243!            ENDDO
     244!         ENDDO
     245!         latfi(ngridmx)= rlatu(jjp1)
     246!         lonfi(ngridmx)= 0.
     247!         zcufi(ngridmx) = cu(ip1jm+1)
     248!         zcvfi(ngridmx) = cv(ip1jm-iim)
     249!
     250!         ! build airefi(), mesh area on physics grid
     251!         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
     252!         ! Poles are single points on physics grid
     253!         airefi(1)=airefi(1)*iim
     254!         airefi(ngridmx)=airefi(ngridmx)*iim
    255255
    256256! Initialisation de la physique: pose probleme quand on tourne
     
    258258! Il faut une cle CPP_PHYS
    259259!#ifdef CPP_PHYS
    260 !         CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys/nsplit_phys,
    261          CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys,
    262      &                latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp,
     260!         CALL iniphysiq(iim,jjm,llm,daysec,day_ini,dtphys/nsplit_phys,
     261         CALL iniphysiq(iim,jjm,llm,daysec,day_ini,dtphys,
     262     &                rlatu,rlonv,aire,cu,cv,rad,g,r,cpp,
    263263     &                1)
    264264!     &                iflag_phys)
  • trunk/LMDZ.GENERIC/libf/phystd/iniphysiq.F90

    r1315 r1395  
    1 subroutine iniphysiq(ngrid,nlayer, punjours, pdayref,ptimestep,          &
    2                      plat,plon,parea,pcu,pcv,                            &
     1subroutine iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep,           &
     2                     rlatu,rlonv,aire,cu,cv,                             &
    33                     prad,pg,pr,pcpp,iflag_phys)
    44
     
    1010                               klon_omp_end, & ! end index of local omp subgrid
    1111                               klon_mpi_begin ! start indes of columns (on local mpi grid)
    12 use comgeomphy, only : airephy, & ! physics grid area (m2)
     12
     13use comgeomphy, only : initcomgeomphy, &
     14                       airephy, & ! physics grid area (m2)
    1315                       cuphy, & ! cu coeff. (u_covariant = cu * u)
    1416                       cvphy, & ! cv coeff. (v_covariant = cv * v)
     
    2123include "dimensions.h"
    2224include "comvert.h"
     25include "iniprint.h"
    2326
    2427real,intent(in) :: prad ! radius of the planet (m)
     
    2730real,intent(in) :: pcpp ! specific heat Cp
    2831real,intent(in) :: punjours ! length (in s) of a standard day
    29 integer,intent(in) :: ngrid ! number of horizontal grid points in the physics (full grid)
     32!integer,intent(in) :: ngrid ! number of horizontal grid points in the physics (full grid)
    3033integer,intent(in) :: nlayer ! number of atmospheric layers
    31 real,intent(in) :: plat(ngrid) ! latitudes of the physics grid
    32 real,intent(in) :: plon(ngrid) ! longitudes of the physics grid
    33 real,intent(in) :: parea(klon_glo) ! area (m2)
    34 real,intent(in) :: pcu(klon_glo) ! cu coeff. (u_covariant = cu * u)
    35 real,intent(in) :: pcv(klon_glo) ! cv coeff. (v_covariant = cv * v)
     34integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes
     35integer,intent(in) :: jj  ! number of atompsheric columns along latitudes
     36real,intent(in) :: rlatu(jj+1) ! latitudes of the dynamics U grid
     37real,intent(in) :: rlonv(ii+1) ! longitudes of the dynamics V grid
     38real,intent(in) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2)
     39real,intent(in) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
     40real,intent(in) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
    3641integer,intent(in) :: pdayref ! reference day of for the simulation
    3742real,intent(in) :: ptimestep !physics time step (s)
     
    3944
    4045integer :: ibegin,iend,offset
     46integer :: i,j
    4147character(len=20) :: modname='iniphysiq'
    4248character(len=80) :: abort_message
     49real :: total_area_phy, total_area_dyn
     50
     51
     52! global array, on full physics grid:
     53real,allocatable :: latfi(:)
     54real,allocatable :: lonfi(:)
     55real,allocatable :: cufi(:)
     56real,allocatable :: cvfi(:)
     57real,allocatable :: airefi(:)
    4358
    4459IF (nlayer.NE.klev) THEN
     
    5166ENDIF
    5267
    53 IF (ngrid.NE.klon_glo) THEN
    54   write(*,*) 'STOP in ',trim(modname)
    55   write(*,*) 'Problem with dimensions :'
    56   write(*,*) 'ngrid     = ',ngrid
    57   write(*,*) 'klon   = ',klon_glo
    58   abort_message = ''
    59   CALL abort_gcm (modname,abort_message,1)
     68!IF (ngrid.NE.klon_glo) THEN
     69!  write(*,*) 'STOP in ',trim(modname)
     70!  write(*,*) 'Problem with dimensions :'
     71!  write(*,*) 'ngrid     = ',ngrid
     72!  write(*,*) 'klon   = ',klon_glo
     73!  abort_message = ''
     74!  CALL abort_gcm (modname,abort_message,1)
     75!ENDIF
     76
     77!call init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/))
     78
     79! Generate global arrays on full physics grid
     80allocate(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
     81latfi(1)=rlatu(1)
     82lonfi(1)=0.
     83cufi(1) = cu(1)
     84cvfi(1) = cv(1)
     85DO j=2,jj
     86  DO i=1,ii
     87    latfi((j-2)*ii+1+i)= rlatu(j)
     88    lonfi((j-2)*ii+1+i)= rlonv(i)
     89    cufi((j-2)*ii+1+i) = cu((j-1)*ii+1+i)
     90    cvfi((j-2)*ii+1+i) = cv((j-1)*ii+1+i)
     91  ENDDO
     92ENDDO
     93latfi(klon_glo)= rlatu(jj+1)
     94lonfi(klon_glo)= 0.
     95cufi(klon_glo) = cu((ii+1)*jj+1)
     96cvfi(klon_glo) = cv((ii+1)*jj-ii)
     97
     98! build airefi(), mesh area on physics grid
     99allocate(airefi(klon_glo))
     100CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi)
     101! Poles are single points on physics grid
     102airefi(1)=sum(aire(1:ii,1))
     103airefi(klon_glo)=sum(aire(1:ii,jj+1))
     104
     105! Sanity check: do total planet area match between physics and dynamics?
     106total_area_dyn=sum(aire(1:ii,1:jj+1))
     107total_area_phy=sum(airefi(1:klon_glo))
     108IF (total_area_dyn/=total_area_phy) THEN
     109  WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
     110  WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
     111  WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
     112  IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
     113    ! stop here if the relative difference is more than 0.001%
     114    abort_message = 'planet total surface discrepancy'
     115    CALL abort_gcm(modname, abort_message, 1)
     116  ENDIF
    60117ENDIF
    61118
    62 !$OMP PARALLEL PRIVATE(ibegin,iend) &
    63         !$OMP SHARED(parea,pcu,pcv,plon,plat)
    64      
     119
     120!$OMP PARALLEL
     121! Now generate local lon/lat/cu/cv/area arrays
     122call initcomgeomphy
     123
     124!!!!$OMP PARALLEL PRIVATE(ibegin,iend) &
     125!!!     !$OMP SHARED(airefi,cufi,cvfi,lonfi,latfi)
     126
    65127offset=klon_mpi_begin-1
    66 airephy(1:klon_omp)=parea(offset+klon_omp_begin:offset+klon_omp_end)
    67 cuphy(1:klon_omp)=pcu(offset+klon_omp_begin:offset+klon_omp_end)
    68 cvphy(1:klon_omp)=pcv(offset+klon_omp_begin:offset+klon_omp_end)
    69 rlond(1:klon_omp)=plon(offset+klon_omp_begin:offset+klon_omp_end)
    70 rlatd(1:klon_omp)=plat(offset+klon_omp_begin:offset+klon_omp_end)
     128airephy(1:klon_omp)=airefi(offset+klon_omp_begin:offset+klon_omp_end)
     129cuphy(1:klon_omp)=cufi(offset+klon_omp_begin:offset+klon_omp_end)
     130cvphy(1:klon_omp)=cvfi(offset+klon_omp_begin:offset+klon_omp_end)
     131rlond(1:klon_omp)=lonfi(offset+klon_omp_begin:offset+klon_omp_end)
     132rlatd(1:klon_omp)=latfi(offset+klon_omp_begin:offset+klon_omp_end)
    71133
    72134! copy over preff , ap() and bp()
  • trunk/LMDZ.GENERIC/libf/phystd/newstart.F

    r1370 r1395  
    466466      CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
    467467      ! Poles are single points on physics grid
    468       airefi(1)=airefi(1)*iim
    469       airefi(ngridmx)=airefi(ngridmx)*iim
     468      airefi(1)=sum(aire(1:iim,1))
     469      airefi(ngridmx)=sum(aire(1:iim,jjm+1))
    470470
    471471! also initialize various physics flags/settings which might be needed
Note: See TracChangeset for help on using the changeset viewer.