Ignore:
Timestamp:
Apr 5, 2016, 10:51:51 AM (9 years ago)
Author:
emillour
Message:

Generic GCM: Towards a cleaner separation between physics and dynamics

  • Got rid of references to "dimensions.h" from physics packages: use nbp_lon (=iim), nbp_lat (=jjp1) and nbp_lev from module mod_grid_phy_lmdz (in phy_common) instead.
  • Removed module "comhdiff_mod.F90", as it is only used by module surf_heat_transp_mod.F90, moved module variables there.
  • Addedin "surf_heat_transp_mod" local versions of some arrays and routines (from dyn3d) required to compute gradient, divergence, etc. on the global dynamics grid. As before, the slab ocean only works in serial.

EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/libf/phystd/wstats.F90

    r1422 r1529  
    11subroutine wstats(ngrid,nom,titre,unite,dim,px)
    22
     3use statto_mod, only: istats,istime,count
    34use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin
    4 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo
    5 use statto_mod, only: istats,istime,count
    6 
     5use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, &
     6                              nbp_lon, nbp_lat, nbp_lev
    77implicit none
    88
    9 #include "dimensions.h"
    10 !#include "dimphys.h"
    11 #include "netcdf.inc"
     9include "netcdf.inc"
    1210
    1311integer,intent(in) :: ngrid
    1412character (len=*),intent(in) :: nom,titre,unite
    1513integer,intent(in) :: dim
    16 integer,parameter :: iip1=iim+1
    17 integer,parameter :: jjp1=jjm+1
    18 real,intent(in) :: px(ngrid,llm)
    19 real, dimension(iip1,jjp1,llm) :: mean3d,sd3d,dx3
    20 real, dimension(iip1,jjp1) :: mean2d,sd2d,dx2
     14real,intent(in) :: px(ngrid,nbp_lev)
     15real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: mean3d,sd3d,dx3
     16real, dimension(nbp_lon+1,nbp_lat) :: mean2d,sd2d,dx2
    2117character (len=50) :: namebis
    2218character (len=50), save :: firstvar
     
    3430! Added to work in parallel mode
    3531#ifdef CPP_PARA
    36 real px3_glop(klon_glo,llm) ! to store a 3D data set on global physics grid
    37 real px3_glo(iim,jjp1,llm) ! to store a global 3D data set on global lonxlat grid
     32real px3_glop(klon_glo,nbp_lev) ! to store a 3D data set on global physics grid
     33real px3_glo(nbp_lon,nbp_lat,nbp_lev) ! to store a global 3D data set on global lonxlat grid
    3834real px2_glop(klon_glo) ! to store a 2D data set on global physics grid
    39 real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid
     35real px2_glo(nbp_lon,nbp_lat) ! to store a 2D data set on global lonxlat grid
    4036real px2(ngrid)
    41 real px3(ngrid,llm)
     37real px3(ngrid,nbp_lev)
    4238#else
    4339! When not running in parallel mode:
    44 real px3_glop(ngrid,llm) ! to store a 3D data set on global physics grid
    45 real px3_glo(iim,jjp1,llm) ! to store a global 3D data set on global lonxlat grid
     40real px3_glop(ngrid,nbp_lev) ! to store a 3D data set on global physics grid
     41real px3_glo(nbp_lon,nbp_lat,nbp_lev) ! to store a global 3D data set on global lonxlat grid
    4642real px2_glop(ngrid) ! to store a 2D data set on global physics grid
    47 real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid
     43real px2_glo(nbp_lon,nbp_lat) ! to store a 2D data set on global lonxlat grid
    4844#endif
    4945
     
    6763#ifdef CPP_PARA
    6864 if (dim.eq.3) then
    69   px3(1:ngrid,1:llm)=px(1:ngrid,1:llm)
     65  px3(1:ngrid,1:nbp_lev)=px(1:ngrid,1:nbp_lev)
    7066  ! Gather fieds on a "global" (without redundant longitude) array
    7167  call Gather(px3,px3_glop)
     
    7470    call Grid1Dto2D_glo(px3_glop,px3_glo)
    7571    ! copy dx3_glo() to dx3(:) and add redundant longitude
    76     dx3(1:iim,:,:)=px3_glo(1:iim,:,:)
    77     dx3(iip1,:,:)=dx3(1,:,:)
     72    dx3(1:nbp_lon,:,:)=px3_glo(1:nbp_lon,:,:)
     73    dx3(nbp_lon+1,:,:)=dx3(1,:,:)
    7874  endif
    7975!$OMP END MASTER
     
    8783            call Grid1Dto2D_glo(px2_glop,px2_glo)
    8884            ! copy px2_glo() to dx2(:) and add redundant longitude
    89             dx2(1:iim,:)=px2_glo(1:iim,:)
    90             dx2(iip1,:)=dx2(1,:)
     85            dx2(1:nbp_lon,:)=px2_glo(1:nbp_lon,:)
     86            dx2(nbp_lon+1,:)=dx2(1,:)
    9187          endif
    9288!$OMP END MASTER
     
    9591#else
    9692  if (dim.eq.3) then
    97     px3_glop(:,1:llm)=px(:,1:llm)
     93    px3_glop(:,1:nbp_lev)=px(:,1:nbp_lev)
    9894!  Passage variable physique -->  variable dynamique
    99     DO l=1,llm
    100       DO i=1,iim
     95    DO l=1,nbp_lev
     96      DO i=1,nbp_lon
    10197         px3_glo(i,1,l)=px(1,l)
    102          px3_glo(i,jjp1,l)=px(ngrid,l)
     98         px3_glo(i,nbp_lat,l)=px(ngrid,l)
    10399      ENDDO
    104       DO j=2,jjm
    105          ig0= 1+(j-2)*iim
    106          DO i=1,iim
     100      DO j=2,nbp_lat-1
     101         ig0= 1+(j-2)*nbp_lon
     102         DO i=1,nbp_lon
    107103            px3_glo(i,j,l)=px(ig0+i,l)
    108104         ENDDO
     
    112108    px2_glop(:)=px(:,1)
    113109!    Passage variable physique -->  physique dynamique
    114    DO i=1,iim
     110   DO i=1,nbp_lon
    115111     px2_glo(i,1)=px(1,1)
    116      px2_glo(i,jjp1)=px(ngrid,1)
     112     px2_glo(i,nbp_lat)=px(ngrid,1)
    117113   ENDDO
    118    DO j=2,jjm
    119      ig0= 1+(j-2)*iim
    120      DO i=1,iim
     114   DO j=2,nbp_lat-1
     115     ig0= 1+(j-2)*nbp_lon
     116     DO i=1,nbp_lon
    121117        px2_glo(i,j)=px(ig0+i,1)
    122118     ENDDO
     
    198194   if (dim.eq.3) then
    199195      start=(/1,1,1,indx/)
    200       sizes=(/iip1,jjp1,llm,1/)
     196      sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
    201197      mean3d(:,:,:)=0
    202198      sd3d(:,:,:)=0
    203199   else if (dim.eq.2) then
    204200      start=(/1,1,indx,0/)
    205       sizes=(/iip1,jjp1,1,0/)
     201      sizes=(/nbp_lon+1,nbp_lev,1,0/)
    206202      mean2d(:,:)=0
    207203      sd2d(:,:)=0
     
    211207   if (dim.eq.3) then
    212208      start=(/1,1,1,indx/)
    213       sizes=(/iip1,jjp1,llm,1/)
     209      sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
    214210#ifdef NC_DOUBLE
    215211      ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean3d)
     
    226222   else if (dim.eq.2) then
    227223      start=(/1,1,indx,0/)
    228       sizes=(/iip1,jjp1,1,0/)
     224      sizes=(/nbp_lon+1,nbp_lat,1,0/)
    229225#ifdef NC_DOUBLE
    230226      ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean2d)
     
    245241
    246242if (dim.eq.3) then
    247   dx3(1:iim,:,:)=px3_glo(:,:,:)
    248   dx3(iip1,:,:)=dx3(1,:,:)
     243  dx3(1:nbp_lon,:,:)=px3_glo(:,:,:)
     244  dx3(nbp_lon+1,:,:)=dx3(1,:,:)
    249245else ! dim.eq.2
    250   dx2(1:iim,:)=px2_glo(:,:)
    251   dx2(iip1,:)=dx2(1,:)
     246  dx2(1:nbp_lon,:)=px2_glo(:,:)
     247  dx2(nbp_lon+1,:)=dx2(1,:)
    252248endif
    253249
     
    290286!======================================================
    291287subroutine inivar(nid,varid,ngrid,dim,indx,px,ierr)
     288use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev
    292289
    293290implicit none
    294291
    295 include "dimensions.h"
    296 !include "dimphys.h"
    297292include "netcdf.inc"
    298293
    299294integer, intent(in) :: nid,varid,dim,indx,ngrid
    300 real, dimension(ngrid,llm), intent(in) :: px
     295real, dimension(ngrid,nbp_lev), intent(in) :: px
    301296integer, intent(out) :: ierr
    302 
    303 integer,parameter :: iip1=iim+1
    304 integer,parameter :: jjp1=jjm+1
    305297
    306298integer :: l,i,j,ig0
    307299integer, dimension(4) :: start,sizes
    308 real, dimension(iip1,jjp1,llm) :: dx3
    309 real, dimension(iip1,jjp1) :: dx2
     300real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: dx3
     301real, dimension(nbp_lon+1,nbp_lat) :: dx2
    310302
    311303if (dim.eq.3) then
    312304
    313305   start=(/1,1,1,indx/)
    314    sizes=(/iip1,jjp1,llm,1/)
     306   sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
    315307
    316308!  Passage variable physique -->  variable dynamique
    317309
    318    DO l=1,llm
    319       DO i=1,iip1
     310   DO l=1,nbp_lev
     311      DO i=1,nbp_lon+1
    320312         dx3(i,1,l)=px(1,l)
    321          dx3(i,jjp1,l)=px(ngrid,l)
     313         dx3(i,nbp_lat,l)=px(ngrid,l)
    322314      ENDDO
    323       DO j=2,jjm
    324          ig0= 1+(j-2)*iim
    325          DO i=1,iim
     315      DO j=2,nbp_lat-1
     316         ig0= 1+(j-2)*nbp_lon
     317         DO i=1,nbp_lon
    326318            dx3(i,j,l)=px(ig0+i,l)
    327319         ENDDO
    328          dx3(iip1,j,l)=dx3(1,j,l)
     320         dx3(nbp_lon+1,j,l)=dx3(1,j,l)
    329321      ENDDO
    330322   ENDDO
     
    339331
    340332      start=(/1,1,indx,0/)
    341       sizes=(/iip1,jjp1,1,0/)
     333      sizes=(/nbp_lon+1,nbp_lat,1,0/)
    342334
    343335!    Passage variable physique -->  physique dynamique
    344336
    345   DO i=1,iip1
     337  DO i=1,nbp_lon+1
    346338     dx2(i,1)=px(1,1)
    347      dx2(i,jjp1)=px(ngrid,1)
     339     dx2(i,nbp_lat)=px(ngrid,1)
    348340  ENDDO
    349   DO j=2,jjm
    350      ig0= 1+(j-2)*iim
    351      DO i=1,iim
     341  DO j=2,nbp_lat-1
     342     ig0= 1+(j-2)*nbp_lon
     343     DO i=1,nbp_lon
    352344        dx2(i,j)=px(ig0+i,1)
    353345     ENDDO
    354      dx2(iip1,j)=dx2(1,j)
     346     dx2(nbp_lon+1,j)=dx2(1,j)
    355347  ENDDO
    356348
     
    380372implicit none
    381373
    382 #include "netcdf.inc"
     374include "netcdf.inc"
    383375
    384376integer,intent(in) :: nid ! NetCDF file ID
Note: See TracChangeset for help on using the changeset viewer.