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/iniwrite.F

    r1524 r1529  
    1       SUBROUTINE iniwrite(nid,idayref,phis)
     1      SUBROUTINE iniwrite(nid,idayref,phis,area)
    22
    33      use comsoil_h, only: mlayer, nsoilmx
    4       use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
    5       use time_phylmdz_mod, only: daysec, dtphys
     4      USE comcstfi_mod, only: g, mugaz, omeg, rad, rcp, pi
    65      USE comvert_mod, ONLY: ap,bp,aps,bps,pseudoalt
    76      USE logic_mod, ONLY: fxyhypb,ysinus
    87      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
     8      USE time_phylmdz_mod, ONLY: daysec, dtphys
    99      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
     10      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
     11      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
    1012      IMPLICIT NONE
    1113
     
    2628c   -------------
    2729
    28 #include "dimensions.h"
    29 #include "paramet.h"
    30 #include "comgeom.h"
    31 #include "netcdf.inc"
     30      include "netcdf.inc"
    3231
    3332c   Arguments:
     
    3635      integer,intent(in) :: nid        ! NetCDF file ID
    3736      INTEGER*4,intent(in) :: idayref  ! date (initial date for this run)
    38       real,intent(in) :: phis(ip1jmp1) ! surface geopotential
     37      real,intent(in) :: phis(nbp_lon+1,nbp_lat) ! surface geopotential
     38      real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2)
    3939
    4040c   Local:
     
    4444      REAL tab_cntrl(length) ! run parameters are stored in this array
    4545      INTEGER ierr
    46 
    47       integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
    48       integer :: idim_rlatu,idim_rlatv,idim_llmp1,idim_llm
     46      REAl :: lon_reg_ext(nbp_lon+1) ! extended longitudes
     47
     48      integer :: nvarid,idim_index,idim_rlonv
     49      integer :: idim_rlatu,idim_llmp1,idim_llm
    4950      integer :: idim_nsoilmx ! "subsurface_layers" dimension ID #
    5051      integer, dimension(2) :: id 
     
    5455         tab_cntrl(l)=0.
    5556      ENDDO
    56       tab_cntrl(1)  = real(iim)
    57       tab_cntrl(2)  = real(jjm)
    58       tab_cntrl(3)  = real(llm)
     57      tab_cntrl(1)  = real(nbp_lon)
     58      tab_cntrl(2)  = real(nbp_lat-1)
     59      tab_cntrl(3)  = real(nbp_lev)
    5960      tab_cntrl(4)  = real(idayref)
    6061      tab_cntrl(5)  = rad
     
    99100
    100101      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
    101       ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
    102       ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
    103       ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
    104       ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
    105       ierr = NF_DEF_DIM (nid, "interlayer", (llm+1), idim_llmp1)
    106       ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
     102!      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
     103      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
     104      ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
     105!      ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
     106      ierr = NF_DEF_DIM (nid, "interlayer", (nbp_lev+1), idim_llmp1)
     107      ierr = NF_DEF_DIM (nid, "altitude", nbp_lev, idim_llm)
    107108      ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoilmx,idim_nsoilmx)
    108109c
     
    129130c --------------------------
    130131c  longitudes and latitudes
    131       ierr = NF_REDEF (nid)
    132 #ifdef NC_DOUBLE
    133       ierr = NF_DEF_VAR (nid, "rlonu", NF_DOUBLE, 1, idim_rlonu,nvarid)
    134 #else
    135       ierr = NF_DEF_VAR (nid, "rlonu", NF_FLOAT, 1, idim_rlonu,nvarid)
    136 #endif
    137       ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 21,
    138      .                       "Longitudes at u nodes")
    139       ierr = NF_ENDDEF(nid)
    140 #ifdef NC_DOUBLE
    141       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu/pi*180)
    142 #else
    143       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu/pi*180)
    144 #endif
     132!
     133!      ierr = NF_REDEF (nid)
     134!#ifdef NC_DOUBLE
     135!      ierr = NF_DEF_VAR (nid, "rlonu", NF_DOUBLE, 1, idim_rlonu,nvarid)
     136!#else
     137!      ierr = NF_DEF_VAR (nid, "rlonu", NF_FLOAT, 1, idim_rlonu,nvarid)
     138!#endif
     139!      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 21,
     140!     .                       "Longitudes at u nodes")
     141!      ierr = NF_ENDDEF(nid)
     142!#ifdef NC_DOUBLE
     143!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu/pi*180)
     144!#else
     145!      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu/pi*180)
     146!#endif
    145147c
    146148c --------------------------
     
    156158      ierr = NF_ENDDEF(nid)
    157159#ifdef NC_DOUBLE
    158       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
    159 #else
    160       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
    161 #endif
    162 c
    163 c --------------------------
     160      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
     161#else
     162      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
     163#endif
     164c
     165c --------------------------
     166      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
     167      !add extra redundant point (180 degrees, since lon_reg starts at -180
     168      lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
     169
    164170      ierr = NF_REDEF (nid)
    165171#ifdef NC_DOUBLE
     
    173179      ierr = NF_ENDDEF(nid)
    174180#ifdef NC_DOUBLE
    175       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
    176 #else
    177       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
     181      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
     182#else
     183      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
    178184#endif
    179185c
     
    199205c
    200206c --------------------------
    201       ierr = NF_REDEF (nid)
    202 #ifdef NC_DOUBLE
    203       ierr = NF_DEF_VAR (nid, "rlatv", NF_DOUBLE, 1, idim_rlatv,nvarid)
    204 #else
    205       ierr = NF_DEF_VAR (nid, "rlatv", NF_FLOAT, 1, idim_rlatv,nvarid)
    206 #endif
    207       ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20,
    208      .                       "Latitudes at v nodes")
    209       ierr = NF_ENDDEF(nid)
    210 #ifdef NC_DOUBLE
    211       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv/pi*180)
    212 #else
    213       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv/pi*180)
    214 #endif
     207!      ierr = NF_REDEF (nid)
     208!#ifdef NC_DOUBLE
     209!      ierr = NF_DEF_VAR (nid, "rlatv", NF_DOUBLE, 1, idim_rlatv,nvarid)
     210!#else
     211!      ierr = NF_DEF_VAR (nid, "rlatv", NF_FLOAT, 1, idim_rlatv,nvarid)
     212!#endif
     213!      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20,
     214!     .                       "Latitudes at v nodes")
     215!      ierr = NF_ENDDEF(nid)
     216!#ifdef NC_DOUBLE
     217!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv/pi*180)
     218!#else
     219!      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv/pi*180)
     220!#endif
    215221c
    216222c --------------------------
     
    274280c  Mesh area and conversion coefficients cov. <-> contra. <--> natural
    275281
    276       id(1)=idim_rlonu
    277       id(2)=idim_rlatu
    278 c
    279       ierr = NF_REDEF (nid)
    280 #ifdef NC_DOUBLE
    281       ierr = NF_DEF_VAR (nid, "cu", NF_DOUBLE, 2, id,nvarid)
    282 #else
    283       ierr = NF_DEF_VAR (nid, "cu", NF_FLOAT, 2, id,nvarid)
    284 #endif
    285       ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
    286      .             "Conversion coefficients cov <--> natural")
    287       ierr = NF_ENDDEF(nid)
    288 #ifdef NC_DOUBLE
    289       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
    290 #else
    291       ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
    292 #endif
    293 c
    294       id(1)=idim_rlonv
    295       id(2)=idim_rlatv
    296 c
    297 c --------------------------
    298       ierr = NF_REDEF (nid)
    299 #ifdef NC_DOUBLE
    300       ierr = NF_DEF_VAR (nid, "cv", NF_DOUBLE, 2, id,nvarid)
    301 #else
    302       ierr = NF_DEF_VAR (nid, "cv", NF_FLOAT, 2, id,nvarid)
    303 #endif
    304       ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
    305      .             "Conversion coefficients cov <--> natural")
    306       ierr = NF_ENDDEF(nid)
    307 #ifdef NC_DOUBLE
    308       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
    309 #else
    310       ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
    311 #endif
     282!      id(1)=idim_rlonu
     283!      id(2)=idim_rlatu
     284c
     285!      ierr = NF_REDEF (nid)
     286!#ifdef NC_DOUBLE
     287!      ierr = NF_DEF_VAR (nid, "cu", NF_DOUBLE, 2, id,nvarid)
     288!#else
     289!      ierr = NF_DEF_VAR (nid, "cu", NF_FLOAT, 2, id,nvarid)
     290!#endif
     291!      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
     292!     .             "Conversion coefficients cov <--> natural")
     293!      ierr = NF_ENDDEF(nid)
     294!#ifdef NC_DOUBLE
     295!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
     296!#else
     297!      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
     298!#endif
     299c
     300!      id(1)=idim_rlonv
     301!      id(2)=idim_rlatv
     302c
     303c --------------------------
     304!      ierr = NF_REDEF (nid)
     305!#ifdef NC_DOUBLE
     306!      ierr = NF_DEF_VAR (nid, "cv", NF_DOUBLE, 2, id,nvarid)
     307!#else
     308!      ierr = NF_DEF_VAR (nid, "cv", NF_FLOAT, 2, id,nvarid)
     309!#endif
     310!      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
     311!     .             "Conversion coefficients cov <--> natural")
     312!      ierr = NF_ENDDEF(nid)
     313!#ifdef NC_DOUBLE
     314!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
     315!#else
     316!      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
     317!#endif
    312318c
    313319      id(1)=idim_rlonv
     
    325331      ierr = NF_ENDDEF(nid)
    326332#ifdef NC_DOUBLE
    327       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
    328 #else
    329       ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
     333      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
     334#else
     335      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
    330336#endif
    331337c
     
    350356c
    351357
    352       write(*,*)'iniwrite: iim,jjm,llm,idayref',iim,jjm,llm,idayref
     358      write(*,*)'iniwrite: nbp_lon,nbp_lat,nbp_lev,idayref',
     359     & nbp_lon,nbp_lat,nbp_lev,idayref
    353360      write(*,*)'iniwrite: rad,omeg,g,mugaz,rcp',
    354      s rad,omeg,g,mugaz,rcp
     361     & rad,omeg,g,mugaz,rcp
    355362      write(*,*)'iniwrite: daysec,dtphys',daysec,dtphys
    356363
Note: See TracChangeset for help on using the changeset viewer.