Changeset 1529


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

Location:
trunk/LMDZ.GENERIC
Files:
7 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/README

    r1525 r1529  
    11521152- Got rid of references to "control_mod" from the physics. Added a couple
    11531153  of relevent variables for outputs in time_phylmdz_mod.
     1154
     1155== 05/04/2016 == EM
     1156- Got rid of references to "dimensions.h" from physics packages:
     1157  use nbp_lon (=iim), nbp_lat (=jjp1) and nbp_lev
     1158  from module mod_grid_phy_lmdz (in phy_common) instead.
     1159- Removed module "comhdiff_mod.F90", as it is only used by module
     1160  surf_heat_transp_mod.F90, moved module variables there.
     1161- Addedin "surf_heat_transp_mod" local versions of some arrays
     1162  and routines (from dyn3d) required to compute gradient, divergence, etc.
     1163  on the global dynamics grid.
     1164  As before, the slab ocean only works in serial.
  • trunk/LMDZ.GENERIC/libf/dynlonlat_phylonlat/phystd/iniphysiq_mod.F90

    r1525 r1529  
    44
    55subroutine iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep,           &
    6                      rlatu,rlatv,rlonu,rlonv,aire,cu,cv,                 &
     6               rlatudyn,rlatvdyn,rlonudyn,rlonvdyn,airedyn,cudyn,cvdyn,  &
    77                     prad,pg,pr,pcpp,iflag_phys)
    88
     
    2121                       rlond, & ! longitudes
    2222                       rlatd ! latitudes
     23use surf_heat_transp_mod, only: ini_surf_heat_transp
    2324use infotrac, only : nqtot ! number of advected tracers
    2425use planete_mod, only: ini_planete_mod
     
    2930                              north_east, north_west, &
    3031                              south_west, south_east
     32use ioipsl_getin_p_mod, only: getin_p
    3133
    3234implicit none
    3335include "dimensions.h"
     36include "paramet.h"
     37include "comgeom.h"
    3438include "iniprint.h"
    3539
     
    4347integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes
    4448integer,intent(in) :: jj  ! number of atompsheric columns along latitudes
    45 real,intent(in) :: rlatu(jj+1) ! latitudes of the physics grid
    46 real,intent(in) :: rlatv(jj) ! latitude boundaries of the physics grid
    47 real,intent(in) :: rlonv(ii+1) ! longitudes of the physics grid
    48 real,intent(in) :: rlonu(ii+1) ! longitude boundaries of the physics grid
    49 real,intent(in) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2)
    50 real,intent(in) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
    51 real,intent(in) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
     49real,intent(in) :: rlatudyn(jj+1) ! latitudes of the physics grid
     50real,intent(in) :: rlatvdyn(jj) ! latitude boundaries of the physics grid
     51real,intent(in) :: rlonvdyn(ii+1) ! longitudes of the physics grid
     52real,intent(in) :: rlonudyn(ii+1) ! longitude boundaries of the physics grid
     53real,intent(in) :: airedyn(ii+1,jj+1) ! area of the dynamics grid (m2)
     54real,intent(in) :: cudyn((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
     55real,intent(in) :: cvdyn((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
    5256integer,intent(in) :: pdayref ! reference day of for the simulation
    5357real,intent(in) :: ptimestep !physics time step (s)
     
    6064real :: total_area_phy, total_area_dyn
    6165real :: pi
     66logical :: ok_slab_ocean
    6267
    6368! boundaries, on global grid
     
    99104 
    100105DO i=1,ii
    101    boundslon_reg(i,east)=rlonu(i)
    102    boundslon_reg(i,west)=rlonu(i+1)
     106   boundslon_reg(i,east)=rlonudyn(i)
     107   boundslon_reg(i,west)=rlonudyn(i+1)
    103108ENDDO
    104109
    105110boundslat_reg(1,north)= PI/2
    106 boundslat_reg(1,south)= rlatv(1)
     111boundslat_reg(1,south)= rlatvdyn(1)
    107112DO j=2,jj
    108    boundslat_reg(j,north)=rlatv(j-1)
    109    boundslat_reg(j,south)=rlatv(j)
     113   boundslat_reg(j,north)=rlatvdyn(j-1)
     114   boundslat_reg(j,south)=rlatvdyn(j)
    110115ENDDO
    111 boundslat_reg(jj+1,north)= rlatv(jj)
     116boundslat_reg(jj+1,north)= rlatvdyn(jj)
    112117boundslat_reg(jj+1,south)= -PI/2
    113118
    114119! Write values in module regular_lonlat_mod
    115 CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, &
     120CALL init_regular_lonlat(ii,jj+1, rlonvdyn(1:ii), rlatudyn, &
    116121                         boundslon_reg, boundslat_reg)
    117122
    118123! Generate global arrays on full physics grid
    119124allocate(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
    120 latfi(1)=rlatu(1)
     125latfi(1)=rlatudyn(1)
    121126lonfi(1)=0.
    122 cufi(1) = cu(1)
    123 cvfi(1) = cv(1)
     127cufi(1) = cudyn(1)
     128cvfi(1) = cvdyn(1)
    124129DO j=2,jj
    125130  DO i=1,ii
    126     latfi((j-2)*ii+1+i)= rlatu(j)
    127     lonfi((j-2)*ii+1+i)= rlonv(i)
    128     cufi((j-2)*ii+1+i) = cu((j-1)*(ii+1)+i)
    129     cvfi((j-2)*ii+1+i) = cv((j-1)*(ii+1)+i)
     131    latfi((j-2)*ii+1+i)= rlatudyn(j)
     132    lonfi((j-2)*ii+1+i)= rlonvdyn(i)
     133    cufi((j-2)*ii+1+i) = cudyn((j-1)*(ii+1)+i)
     134    cvfi((j-2)*ii+1+i) = cvdyn((j-1)*(ii+1)+i)
    130135  ENDDO
    131136ENDDO
    132 latfi(klon_glo)= rlatu(jj+1)
     137latfi(klon_glo)= rlatudyn(jj+1)
    133138lonfi(klon_glo)= 0.
    134 cufi(klon_glo) = cu((ii+1)*jj+1)
    135 cvfi(klon_glo) = cv((ii+1)*jj-ii)
     139cufi(klon_glo) = cudyn((ii+1)*jj+1)
     140cvfi(klon_glo) = cvdyn((ii+1)*jj-ii)
    136141
    137142! build airefi(), mesh area on physics grid
    138143allocate(airefi(klon_glo))
    139 CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi)
     144CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,airedyn,airefi)
    140145! Poles are single points on physics grid
    141 airefi(1)=sum(aire(1:ii,1))
    142 airefi(klon_glo)=sum(aire(1:ii,jj+1))
     146airefi(1)=sum(airedyn(1:ii,1))
     147airefi(klon_glo)=sum(airedyn(1:ii,jj+1))
    143148
    144149! Sanity check: do total planet area match between physics and dynamics?
    145 total_area_dyn=sum(aire(1:ii,1:jj+1))
     150total_area_dyn=sum(airedyn(1:ii,1:jj+1))
    146151total_area_phy=sum(airefi(1:klon_glo))
    147152IF (total_area_dyn/=total_area_phy) THEN
     
    174179call ini_planete_mod(nlayer,preff,ap,bp)
    175180
     181! for slab ocean, copy over some arrays
     182ok_slab_ocean=.false. ! default value
     183call getin_p("ok_slab_ocean",ok_slab_ocean)
     184if (ok_slab_ocean) then
     185  call ini_surf_heat_transp(ip1jm,ip1jmp1,unsairez,fext,unsaire, &
     186                            cu,cuvsurcv,cv,cvusurcu,aire,apoln,apols, &
     187                            aireu,airev)
     188endif
     189
    176190! copy some fundamental parameters to physics
    177191! and do some initializations
  • trunk/LMDZ.GENERIC/libf/phystd/aeroptproperties.F90

    r1397 r1529  
    3131!     Varying nueff section removed by R. Wordsworth for simplicity
    3232!     ==============================================================
    33 
    34 !#include "dimensions.h"
    35 !#include "dimphys.h"
    3633
    3734!     Local variables
  • trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90

    r1526 r1529  
    1919      USE tracer_h
    2020      use comcstfi_mod, only: pi, mugaz, cpp
    21       use callkeys_mod, only: varactive,diurnal,tracer,water,nosurf,varfixed,satval,    &
    22                               kastprof,strictboundcorrk,specOLR,CLFvarying
     21      use callkeys_mod, only: varactive,diurnal,tracer,water,nosurf,varfixed,satval,        &
     22                              kastprof,strictboundcorrk,specOLR,CLFvarying
    2323
    2424      implicit none
     
    144144
    145145      ! Local aerosol optical properties for each column on RADIATIVE grid.
    146       real*8,save ::  QXVAER(L_LEVELS+1,L_NSPECTV,naerkind)
    147       real*8,save ::  QSVAER(L_LEVELS+1,L_NSPECTV,naerkind)
    148       real*8,save ::  GVAER(L_LEVELS+1,L_NSPECTV,naerkind)
    149       real*8,save ::  QXIAER(L_LEVELS+1,L_NSPECTI,naerkind)
    150       real*8,save ::  QSIAER(L_LEVELS+1,L_NSPECTI,naerkind)
    151       real*8,save ::  GIAER(L_LEVELS+1,L_NSPECTI,naerkind)
    152 
    153       !REAL :: QREFvis3d(ngrid,nlayer,naerkind)
    154       !REAL :: QREFir3d(ngrid,nlayer,naerkind)
    155       !save QREFvis3d, QREFir3d
     146      real*8,save,allocatable ::  QXVAER(:,:,:)
     147      real*8,save,allocatable ::  QSVAER(:,:,:)
     148      real*8,save,allocatable ::  GVAER(:,:,:)
     149      real*8,save,allocatable ::  QXIAER(:,:,:)
     150      real*8,save,allocatable ::  QSIAER(:,:,:)
     151      real*8,save,allocatable ::  GIAER(:,:,:)
     152
    156153      real, dimension(:,:,:), save, allocatable :: QREFvis3d
    157154      real, dimension(:,:,:), save, allocatable :: QREFir3d
     
    188185
    189186
    190       qxvaer(:,:,:)=0.0
    191       qsvaer(:,:,:)=0.0
    192       gvaer(:,:,:) =0.0
    193 
    194       qxiaer(:,:,:)=0.0
    195       qsiaer(:,:,:)=0.0
    196       giaer(:,:,:) =0.0
    197 
    198187      if(firstcall) then
     188
     189        ! test on allocated necessary because of CLFvarying (two calls to callcorrk in physiq)
     190        if(.not.allocated(QXVAER)) allocate(QXVAER(L_LEVELS+1,L_NSPECTV,naerkind))
     191        if(.not.allocated(QSVAER)) allocate(QSVAER(L_LEVELS+1,L_NSPECTV,naerkind))
     192        if(.not.allocated(GVAER)) allocate(GVAER(L_LEVELS+1,L_NSPECTV,naerkind))
     193        if(.not.allocated(QXIAER)) allocate(QXIAER(L_LEVELS+1,L_NSPECTI,naerkind))
     194        if(.not.allocated(QSIAER)) allocate(QSIAER(L_LEVELS+1,L_NSPECTI,naerkind))
     195        if(.not.allocated(GIAER)) allocate(GIAER(L_LEVELS+1,L_NSPECTI,naerkind))
    199196
    200197         !!! ALLOCATED instances are necessary because of CLFvarying (strategy to call callcorrk twice in physiq...)
     
    212209         endif
    213210         call su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
    214        
     211       
    215212         
    216213!--------------------------------------------------
     
    264261      end if ! of if (firstcall)
    265262
    266 
    267263!=======================================================================
    268264!          I.b  Initialization on every call   
    269265!=======================================================================
    270266 
    271  
     267      qxvaer(:,:,:)=0.0
     268      qsvaer(:,:,:)=0.0
     269      gvaer(:,:,:) =0.0
     270
     271      qxiaer(:,:,:)=0.0
     272      qsiaer(:,:,:)=0.0
     273      giaer(:,:,:) =0.0
     274
    272275!--------------------------------------------------
    273276!     Effective radius and variance of the aerosols
     
    277280
    278281         if ((iaer.eq.iaero_co2).and.tracer.and.(igcm_co2_ice.gt.0)) then ! Treat condensed co2 particles.
    279             call co2_reffrad(ngrid,nlayer,nq,pq,reffrad(1,1,iaero_co2))
     282            call co2_reffrad(ngrid,nlayer,nq,pq,reffrad(1,1,iaero_co2))
    280283            print*,'Max. CO2 ice particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
    281284            print*,'Min. CO2 ice particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
    282         end if
     285        end if
    283286         
    284287         if ((iaer.eq.iaero_h2o).and.water) then ! Treat condensed water particles. To be generalized for other aerosols ...
    285             call h2o_reffrad(ngrid,nlayer,pq(1,1,igcm_h2o_ice),pt, &
     288            call h2o_reffrad(ngrid,nlayer,pq(1,1,igcm_h2o_ice),pt, &
    286289                             reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
    287290            print*,'Max. H2O cloud particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
     
    290293         
    291294         if(iaer.eq.iaero_dust)then
    292             call dust_reffrad(ngrid,nlayer,reffrad(1,1,iaero_dust))
     295            call dust_reffrad(ngrid,nlayer,reffrad(1,1,iaero_dust))
    293296            print*,'Dust particle size = ',reffrad(1,1,iaer)/1.e-6,' um'
    294297         endif
    295298         
    296299         if(iaer.eq.iaero_h2so4)then
    297             call h2so4_reffrad(ngrid,nlayer,reffrad(1,1,iaero_h2so4))
     300            call h2so4_reffrad(ngrid,nlayer,reffrad(1,1,iaero_h2so4))
    298301            print*,'H2SO4 particle size =',reffrad(1,1,iaer)/1.e-6,' um'
    299302         endif
    300303         
    301304          if(iaer.eq.iaero_back2lay)then
    302             call back2lay_reffrad(ngrid,reffrad(1,1,iaero_back2lay),nlayer,pplev)
     305            call back2lay_reffrad(ngrid,reffrad(1,1,iaero_back2lay),nlayer,pplev)
    303306         endif
    304307         
     
    321324           reffrad,QREFvis3d,QREFir3d,                             &
    322325           tau_col,cloudfrac,totcloudfrac,clearsky)               
    323          
     326         
    324327
    325328
     
    475478         DO nw=1,L_NSPECTV ! Short Wave loop.
    476479            albv(nw)=albedo(ig,nw)
    477         ENDDO
     480        ENDDO
    478481
    479482         if (nosurf) then ! Case with no surface.
    480483            DO nw=1,L_NSPECTV
    481484               if(albv(nw).gt.0.0) then
    482                   print*,'For open lower boundary in callcorrk must'
     485                  print*,'For open lower boundary in callcorrk must'
    483486                  print*,'have spectral surface band albedos all set to zero!'
    484487                  call abort
    485                endif
    486             ENDDO         
     488               endif
     489            ENDDO         
    487490         endif
    488491
     
    770773
    771774         Cmk= 0.01 * 1.0 / (glat(ig) * mugaz * 1.672621e-27) ! q_main=1.0 assumed.
    772         glat_ig=glat(ig)
     775        glat_ig=glat(ig)
    773776
    774777!-----------------------------------------------------------------------
     
    798801         else ! During the night, fluxes = 0.
    799802            nfluxtopv       = 0.0d0
    800             fluxtopvdn      = 0.0d0
     803            fluxtopvdn      = 0.0d0
    801804            nfluxoutv_nu(:) = 0.0d0
    802805            nfluxgndv_nu(:) = 0.0d0
     
    813816            surface_stellar_flux=sum(nfluxgndv_nu(1:L_NSPECTV))     
    814817            if(surface_stellar_flux .gt. 1.0e-3) then ! equivalent albedo makes sense only if the stellar flux received by the surface is positive.
    815                DO nw=1,L_NSPECTV                 
    816                   albedo_temp(nw)=albedo(ig,nw)*nfluxgndv_nu(nw)
     818               DO nw=1,L_NSPECTV                 
     819                  albedo_temp(nw)=albedo(ig,nw)*nfluxgndv_nu(nw)
    817820               ENDDO
    818                albedo_temp(1:L_NSPECTV)=albedo_temp(1:L_NSPECTV)/surface_stellar_flux
     821               albedo_temp(1:L_NSPECTV)=albedo_temp(1:L_NSPECTV)/surface_stellar_flux
    819822               albedo_equivalent(ig)=sum(albedo_temp(1:L_NSPECTV))
    820823            else
    821824               albedo_equivalent(ig)=0.0 ! Spectrally Integrated Albedo not defined for non-irradiated grid points. So we arbitrary set the equivalent albedo to 0.
    822825            endif
    823         else
    824             albedo_equivalent(ig)=0.0 ! Spectrally Integrated Albedo not defined for non-irradiated grid points. So we arbitrary set the equivalent albedo to 0.
    825         endif
     826        else
     827            albedo_equivalent(ig)=0.0 ! Spectrally Integrated Albedo not defined for non-irradiated grid points. So we arbitrary set the equivalent albedo to 0.
     828        endif
    826829
    827830
     
    956959        IF( ALLOCATED( pfgasref ) ) DEALLOCATE( pfgasref )
    957960!$OMP END MASTER
    958 !$OMP BARRIER   
     961!$OMP BARRIER
    959962        IF ( ALLOCATED(reffrad)) DEALLOCATE(reffrad)
    960963        IF ( ALLOCATED(nueffrad)) DEALLOCATE(nueffrad)
  • trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F

    r1525 r1529  
    907907      end                       !rcm1d
    908908 
    909 c***********************************************************************
    910 c***********************************************************************
    911 c     Subroutines Bidons utilise seulement en 3D, mais
    912 c     necessaire a la compilation de rcm1d en 1D
    913 
    914 !      subroutine gr_fi_dyn
    915 !      RETURN
    916 !      END
    917  
    918 c***********************************************************************
    919 c***********************************************************************
    920 
    921 !#include "../dyn3d/disvert.F"
    922 !#include "../dyn3d/abort_gcm.F"
    923 !#include "../dyn3d/diverg.F"
    924 !#include "../dyn3d/grad.F"
    925 !#include "../dyn3d/gr_u_scal.F"
    926 !#include "../dyn3d/gr_v_scal.F"
    927 !#include "../dyn3d/gr_dyn_fi.F"
    928 
     909
  • trunk/LMDZ.GENERIC/libf/phystd/inifis_mod.F90

    r1525 r1529  
    99             prad,pg,pr,pcpp)
    1010
    11   use radinc_h, only : naerkind
     11  use radinc_h, only: ini_radinc_h, naerkind
     12  use radcommon_h, only: ini_radcommon_h
    1213  use datafile_mod, only: datadir
    1314  use comdiurn_h, only: sinlat, coslat, sinlon, coslon
     
    2122  use planetwide_mod, only: planetwide_sumval
    2223  use callkeys_mod
     24  use mod_phys_lmdz_para, only : is_parallel
    2325
    2426!=======================================================================
     
    7476  REAL SSUM
    7577 
    76   CHARACTER ch1*12
    77   CHARACTER ch80*80
    78 
    79   logical chem, h2o
    80 
    81   real psurf,pN2 ! added by RW for Gliese 581d N2+CO2
    82 
    8378  ! initialize constants in comcstfi_mod
    8479  rad=prad
     
    333328     call getin_p("ok_slab_ocean",ok_slab_ocean)
    334329     write(*,*) "ok_slab_ocean = ",ok_slab_ocean
     330     ! Sanity check: for now slab oncean only works in serial mode
     331     if (ok_slab_ocean.and.is_parallel) then
     332       write(*,*) " Error: slab ocean should only be used in serial mode!"
     333       call abort
     334     endif
    335335
    336336     write(*,*) "Use slab-sea-ice ?"
     
    718718  ENDDO
    719719
     720  ! initialize variables in radinc_h
     721  call ini_radinc_h(nlayer)
     722 
     723  ! allocate "radcommon_h" arrays
     724  call ini_radcommon_h()
     725
    720726  ! allocate "comsoil_h" arrays
    721727  call ini_comsoil_h(ngrid)
  • trunk/LMDZ.GENERIC/libf/phystd/inistats.F

    r1422 r1529  
    11      subroutine inistats(ierr)
    22
     3      use statto_mod, only: istats,istime
    34      use mod_phys_lmdz_para, only : is_master
    4       use statto_mod, only: istats,istime
    55      USE comvert_mod, ONLY: ap,bp,aps,bps,preff,pseudoalt,presnivs
    6       USE comconst_mod, ONLY: daysec,dtphys,pi
     6      USE comconst_mod, ONLY: pi
     7      USE time_phylmdz_mod, ONLY: daysec,dtphys
     8      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
     9      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
    710      implicit none
    811
    9 #include "dimensions.h"
    10 #include "paramet.h"
    11 #include "comgeom.h"
    12 #include "netcdf.inc"
     12      include "netcdf.inc"
    1313
    1414      integer,intent(out) :: ierr
    1515      integer :: nid
    1616      integer :: l,nsteppd
    17       real, dimension(llm) ::  sig_s
     17      real, dimension(nbp_lev) ::  sig_s
     18      real :: lon_reg_ext(nbp_lon+1) ! extended longitudes
    1819      integer :: idim_lat,idim_lon,idim_llm,idim_llmp1,idim_time
    1920      real, dimension(istime) :: lt
     
    3940      write (*,*)
    4041
    41       do l= 1, llm
     42      do l= 1, nbp_lev
    4243         sig_s(l)=((ap(l)+ap(l+1))/preff+bp(l)+bp(l+1))/2.
    4344         pseudoalt(l)=-10.*log(presnivs(l)/preff)   
    4445      enddo
     46     
     47      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
     48      !add extra redundant point (180 degrees, since lon_reg starts at -180
     49      lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
    4550
    4651      if (is_master) then
     
    5358      endif
    5459
    55       ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_lat)
    56       ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_lon)
    57       ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
    58       ierr = NF_DEF_DIM (nid, "llmp1", llm+1, idim_llmp1)
     60      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_lat)
     61      ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_lon)
     62      ierr = NF_DEF_DIM (nid, "altitude", nbp_lev, idim_llm)
     63      ierr = NF_DEF_DIM (nid, "llmp1", nbp_lev+1, idim_llmp1)
    5964      ierr = NF_DEF_DIM (nid, "Time", NF_UNLIMITED, idim_time)
    6065
     
    6873     &            "degrees_north",1,idim_lat,nvarid,ierr)
    6974#ifdef NC_DOUBLE
    70       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
     75      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
    7176#else
    72       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
     77      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
    7378#endif
    7479      call def_var_stats(nid,"longitude","East longitude",
    7580     &            "degrees_east",1,idim_lon,nvarid,ierr)
    7681#ifdef NC_DOUBLE
    77       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
     82      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
    7883#else
    79       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
     84      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
    8085#endif
    8186
  • trunk/LMDZ.GENERIC/libf/phystd/initracer.F

    r1397 r1529  
    2222c            Ehouarn Millour (oct. 2008) identify tracers by their names
    2323c=======================================================================
    24 
    25 
    26 #include "dimensions.h"
    2724
    2825      integer :: ngrid,nq
  • 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
  • trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specIR.F

    r1524 r1529  
    1       SUBROUTINE iniwrite_specIR(nid,idayref)
     1      SUBROUTINE iniwrite_specIR(nid,idayref,area)
    22
    33      use radinc_h, only: L_NSPECTI
     
    88      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
    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
    1113      implicit none
     
    2729c   -------------
    2830
    29 #include "dimensions.h"
    30 #include "paramet.h"
    31 #include "comgeom.h"
    32 #include "netcdf.inc"
    33 !#include"dimphys.h"
     31      include "netcdf.inc"
    3432
    3533c   Arguments:
     
    3836      integer,intent(in) :: nid        ! NetCDF file ID
    3937      INTEGER*4,intent(in) :: idayref  ! date (initial date for this run)
     38      real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2)
    4039
    4140c   Local:
     
    4544      REAL tab_cntrl(length) ! run parameters are stored in this array
    4645      INTEGER ierr
     46      REAl :: lon_reg_ext(nbp_lon+1) ! extended longitudes
    4747
    4848      integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
     
    5757         tab_cntrl(l)=0.
    5858      ENDDO
    59       tab_cntrl(1)  = FLOAT(iim)
    60       tab_cntrl(2)  = FLOAT(jjm)
    61       tab_cntrl(3)  = FLOAT(llm)
     59      tab_cntrl(1)  = FLOAT(nbp_lon)
     60      tab_cntrl(2)  = FLOAT(nbp_lat-1)
     61      tab_cntrl(3)  = FLOAT(nbp_lev)
    6262      tab_cntrl(4)  = FLOAT(idayref)
    6363      tab_cntrl(5)  = rad
     
    102102
    103103      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
    104       ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
    105       ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
     104      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
     105      ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
    106106      ierr = NF_DEF_DIM (nid, "IR Wavenumber",L_NSPECTI,idim_bandsIR)
    107107
     
    141141      ierr = NF_ENDDEF(nid)
    142142#ifdef NC_DOUBLE
    143       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
    144 #else
    145       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
    146 #endif
    147 c
    148 c --------------------------
     143      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
     144#else
     145      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
     146#endif
     147c
     148c --------------------------
     149      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
     150      !add extra redundant point (180 degrees, since lon_reg starts at -180
     151      lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
     152     
    149153      ierr = NF_REDEF (nid)
    150154#ifdef NC_DOUBLE
     
    158162      ierr = NF_ENDDEF(nid)
    159163#ifdef NC_DOUBLE
    160       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
    161 #else
    162       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
     164      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
     165#else
     166      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
    163167#endif
    164168c
     
    172176#ifdef NC_DOUBLE
    173177      ierr=NF_DEF_VAR(nid,"IR Wavenumber",NF_DOUBLE,1,
    174      .                          idim_bandsIR,nvarid)
     178     .                                idim_bandsIR,nvarid)
    175179#else
    176180      ierr=NF_DEF_VAR(nid,"IR Wavenumber",NF_FLOAT,1,
    177      .                          idim_bandsIR,nvarid)
     181     .                                idim_bandsIR,nvarid)
    178182#endif
    179183      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 34,
     
    196200#ifdef NC_DOUBLE
    197201      ierr=NF_DEF_VAR(nid,"IR Bandwidth",NF_DOUBLE,1,
    198      .                          idim_bandsIR,nvarid)
     202     .                                idim_bandsIR,nvarid)
    199203#else
    200204      ierr=NF_DEF_VAR(nid,"IR Bandwidth",NF_FLOAT,1,
    201      .                          idim_bandsIR,nvarid)
     205     .                                idim_bandsIR,nvarid)
    202206#endif
    203207      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 25,
     
    230234      ierr = NF_ENDDEF(nid)
    231235#ifdef NC_DOUBLE
    232       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
    233 #else
    234       ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
     236      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
     237#else
     238      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
    235239#endif
    236240
  • trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specVI.F

    r1524 r1529  
    1       SUBROUTINE iniwrite_specVI(nid,idayref)
     1      SUBROUTINE iniwrite_specVI(nid,idayref,area)
    22
    33      use radinc_h, only: L_NSPECTV
    44      use radcommon_h, only: WNOV,DWNV
    5       use comsoil_h
    65      use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
    76      use time_phylmdz_mod, only: daysec, dtphys
     
    98      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
    109      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
    1112
    1213      implicit none
     
    2829c   -------------
    2930
    30 #include "dimensions.h"
    31 #include "paramet.h"
    32 #include "comgeom.h"
    33 #include "netcdf.inc"
    34 !#include"dimphys.h"
     31      include "netcdf.inc"
    3532
    3633c   Arguments:
    3734c   ----------
    3835
    39       integer nid        ! NetCDF file ID
    40       INTEGER*4 idayref  ! date (initial date for this run)
     36      integer,intent(in) :: nid        ! NetCDF file ID
     37      INTEGER*4,INTENT(IN) :: idayref  ! date (initial date for this run)
     38      real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2)
    4139
    4240c   Local:
     
    4644      REAL tab_cntrl(length) ! run parameters are stored in this array
    4745      INTEGER ierr
     46      REAl :: lon_reg_ext(nbp_lon+1) ! extended longitudes
    4847
    4948      integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
     
    5857         tab_cntrl(l)=0.
    5958      ENDDO
    60       tab_cntrl(1)  = FLOAT(iim)
    61       tab_cntrl(2)  = FLOAT(jjm)
    62       tab_cntrl(3)  = FLOAT(llm)
     59      tab_cntrl(1)  = FLOAT(nbp_lon)
     60      tab_cntrl(2)  = FLOAT(nbp_lat-1)
     61      tab_cntrl(3)  = FLOAT(nbp_lev)
    6362      tab_cntrl(4)  = FLOAT(idayref)
    6463      tab_cntrl(5)  = rad
     
    103102
    104103      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
    105       ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
    106       ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
     104      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
     105      ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
    107106      ierr = NF_DEF_DIM (nid, "VI Wavenumber",L_NSPECTV,idim_bandsVI)
    108107
     
    141140      ierr = NF_ENDDEF(nid)
    142141#ifdef NC_DOUBLE
    143       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
    144 #else
    145       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
    146 #endif
    147 c
    148 c --------------------------
     142      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
     143#else
     144      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
     145#endif
     146c
     147c --------------------------
     148      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
     149      !add extra redundant point (180 degrees, since lon_reg starts at -180
     150      lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
     151
    149152      ierr = NF_REDEF (nid)
    150153#ifdef NC_DOUBLE
     
    158161      ierr = NF_ENDDEF(nid)
    159162#ifdef NC_DOUBLE
    160       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
    161 #else
    162       ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
     163      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
     164#else
     165      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
    163166#endif
    164167c
     
    172175#ifdef NC_DOUBLE
    173176      ierr=NF_DEF_VAR(nid,"VI Wavenumber",NF_DOUBLE,1,
    174      .                          idim_bandsVI,nvarid)
     177     .                                idim_bandsVI,nvarid)
    175178#else
    176179      ierr=NF_DEF_VAR(nid,"VI Wavenumber",NF_FLOAT,1,
    177      .                          idim_bandsVI,nvarid)
     180     .                                idim_bandsVI,nvarid)
    178181#endif
    179182      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 33,
     
    197200#ifdef NC_DOUBLE
    198201      ierr=NF_DEF_VAR(nid,"VI Bandwidth",NF_DOUBLE,1,
    199      .                          idim_bandsVI,nvarid)
     202     .                                idim_bandsVI,nvarid)
    200203#else
    201204      ierr=NF_DEF_VAR(nid,"VI Bandwidth",NF_FLOAT,1,
    202      .                          idim_bandsVI,nvarid)
     205     .                                idim_bandsVI,nvarid)
    203206#endif
    204207      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 24,
     
    231234      ierr = NF_ENDDEF(nid)
    232235#ifdef NC_DOUBLE
    233       ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
    234 #else
    235       ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
     236      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
     237#else
     238      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
    236239#endif
    237240
  • trunk/LMDZ.GENERIC/libf/phystd/iniwritesoil.F90

    r1384 r1529  
    1 subroutine iniwritesoil(nid,ngrid)
     1subroutine iniwritesoil(nid,ngrid,inertia,area)
    22
    33! initialization routine for 'writediagoil'. Here we create/define
     
    55! (time-independent) parameters.
    66
    7 use comsoil_h, only: mlayer, inertiedat, nsoilmx
    8 use comcstfi_mod, only: pi
     7use comsoil_h, only: mlayer, nsoilmx
     8USE comcstfi_mod, only: pi
     9USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
     10use mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
    911
    1012implicit none
    1113
    12 #include"dimensions.h"
    13 #include"paramet.h"
    14 #include"comgeom.h"
    15 #include"netcdf.inc"
     14include"netcdf.inc"
    1615
    1716! Arguments:
    1817integer,intent(in) :: ngrid
    1918integer,intent(in) :: nid ! NetCDF output file ID
     19real,intent(in) :: inertia(nbp_lon+1,nbp_lat,nsoilmx)
     20real,intent(in) :: area(nbp_lon+1,nbp_lat) ! mesh area (m2)
    2021
    2122! Local variables:
     
    3031integer,dimension(3) :: dimids ! to store IDs of dimensions of a variable
    3132character(len=60) :: text ! to store some text
    32 real,dimension(iip1,jjp1,nsoilmx) :: data3 ! to store 3D data
     33real,dimension(nbp_lon+1,nbp_lat,nsoilmx) :: data3 ! to store 3D data
    3334integer :: i,j,l,ig0
     35real :: lon_reg_ext(nbp_lon+1) ! extended longitudes
    3436
    3537! 1. Define the dimensions
     
    3840
    3941! Define the dimensions
    40 ierr=NF_DEF_DIM(nid,"longitude",iip1,idim_rlonv)
    41 ! iip1 known from paramet.h
     42ierr=NF_DEF_DIM(nid,"longitude",nbp_lon+1,idim_rlonv)
    4243if (ierr.ne.NF_NOERR) then
    4344  write(*,*)"iniwritesoil: Error, could not define longitude dimension"
    4445endif
    45 ierr=NF_DEF_DIM(nid,"latitude",jjp1,idim_rlatu)
    46 ! jjp1 known from paramet.h
     46ierr=NF_DEF_DIM(nid,"latitude",nbp_lat,idim_rlatu)
    4747if (ierr.ne.NF_NOERR) then
    4848  write(*,*)"iniwritesoil: Error, could not define latitude dimension"
    4949endif
    5050ierr=NF_DEF_DIM(nid,"depth",nsoilmx,idim_depth)
    51 ! nsoilmx known from dimphys.h
     51! nsoilmx known from comsoil_h
    5252if (ierr.ne.NF_NOERR) then
    5353  write(*,*)"iniwritesoil: Error, could not define depth dimension"
     
    8181ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
    8282
     83lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
     84!add extra redundant point (180 degrees, since lon_reg starts at -180
     85lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
     86
    8387! Write longitude to file
    8488ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
    8589! Write
    8690#ifdef NC_DOUBLE
    87 ierr=NF_PUT_VAR_DOUBLE(nid,varid,rlonv*(180./pi))
    88 #else
    89 ierr=NF_PUT_VAR_REAL(nid,varid,rlonv*(180./pi))
    90 #endif
    91 ! Note: rlonv is known from comgeom.h
     91ierr=NF_PUT_VAR_DOUBLE(nid,varid,lon_reg_ext*(180./pi))
     92#else
     93ierr=NF_PUT_VAR_REAL(nid,varid,lon_reg_ext*(180./pi))
     94#endif
     95! Note: rlonv is known from comgeom.h and pi from comcstfi.h
    9296if (ierr.ne.NF_NOERR) then
    9397  write(*,*)"iniwritesoil: Error, could not write longitude variable"
     
    117121! Write
    118122#ifdef NC_DOUBLE
    119 ierr=NF_PUT_VAR_DOUBLE(nid,varid,rlatu*(180./pi))
    120 #else
    121 ierr=NF_PUT_VAR_REAL(nid,varid,rlatu*(180./pi))
    122 #endif
    123 ! Note: rlatu is known from comgeom.h
     123ierr=NF_PUT_VAR_DOUBLE(nid,varid,lat_reg*(180./pi))
     124#else
     125ierr=NF_PUT_VAR_REAL(nid,varid,lat_reg*(180./pi))
     126#endif
    124127if (ierr.ne.NF_NOERR) then
    125128  write(*,*)"iniwritesoil: Error, could not write longitude variable"
     
    209212! Write
    210213#ifdef NC_DOUBLE
    211 ierr=NF_PUT_VAR_DOUBLE(nid,varid,aire)
    212 #else
    213 ierr=NF_PUT_VAR_REAL(nid,varid,aire)
    214 #endif
    215 ! Note: aire is known from comgeom.h
     214ierr=NF_PUT_VAR_DOUBLE(nid,varid,area)
     215#else
     216ierr=NF_PUT_VAR_REAL(nid,varid,area)
     217#endif
    216218if (ierr.ne.NF_NOERR) then
    217219  write(*,*)"iniwritesoil: Error, could not write area variable"
     
    240242ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
    241243
    242 ! Recast data along 'dynamics' grid
    243 ! Note: inertiedat is known from comsoil_h
    244 
    245 do l=1,nsoilmx
    246   ! handle the poles
    247   do i=1,iip1
    248     data3(i,1,l)=inertiedat(1,l)
    249     data3(i,jjp1,l)=inertiedat(ngrid,l)
    250   enddo
    251   ! rest of the grid
    252   do j=2,jjm
    253     ig0=1+(j-2)*iim
    254     do i=1,iim
    255       data3(i,j,l)=inertiedat(ig0+i,l)
    256     enddo
    257     data3(iip1,j,l)=data3(1,j,l) ! extra (modulo) longitude
    258   enddo
    259 enddo ! of do l=1,nsoilmx
    260 
    261244! Write data2 to file
    262245ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
    263246! Write
    264247#ifdef NC_DOUBLE
    265 ierr=NF_PUT_VAR_DOUBLE(nid,varid,data3)
    266 #else
    267 ierr=NF_PUT_VAR_REAL(nid,varid,data3)
     248ierr=NF_PUT_VAR_DOUBLE(nid,varid,inertia)
     249#else
     250ierr=NF_PUT_VAR_REAL(nid,varid,inertia)
    268251#endif
    269252if (ierr.ne.NF_NOERR) then
  • trunk/LMDZ.GENERIC/libf/phystd/mass_redistribution.F90

    r1526 r1529  
    1       SUBROUTINE mass_redistribution(ngrid,nlayer,nq,ptimestep,   &
     1SUBROUTINE mass_redistribution(ngrid,nlayer,nq,ptimestep,   &
    22                       rnat,pcapcal,pplay,pplev,pt,ptsrf,pq,pqs,     &
    33                       pu,pv,pdt,pdtsrf,pdq,pdu,pdv,pdmassmr,  &
     
    224224!        Van Leer scheme:
    225225         w(1:nlayer+1)=-zmflux(1:nlayer+1)*ptimestep
    226          call vl1d(zzt,2.,zzmass,w,ztm)
    227          call vl1d(zzu ,2.,zzmass,w,zum)
    228          call vl1d(zzv ,2.,zzmass,w,zvm)
     226         call vl1d(nlayer,zzt,2.,zzmass,w,ztm)
     227         call vl1d(nlayer,zzu,2.,zzmass,w,zum)
     228         call vl1d(nlayer,zzv,2.,zzmass,w,zvm)
    229229         do iq=1,nq
    230230           zq1(1:nlayer)=zzq(1:nlayer,iq)
     
    232232!               print*,iq
    233233!               print*,zq1
    234            call vl1d(zq1,2.,zzmass,w,zqm1)
     234           call vl1d(nlayer,zq1,2.,zzmass,w,zqm1)
    235235           do l=2,nlayer
    236236              zzq(l,iq)=zq1(l)
     
    281281      END DO  ! loop on ig
    282282
    283       return
    284       end
    285 
    286 
     283CONTAINS
    287284
    288285! *****************************************************************
    289       SUBROUTINE vl1d(q,pente_max,zzmass,w,qm)
     286      SUBROUTINE vl1d(llm,q,pente_max,zzmass,w,qm)
    290287!
    291288!   
     
    299296!
    300297!   --------------------------------------------------------------------
     298     
    301299      IMPLICIT NONE
    302 
    303 #include "dimensions.h"
    304300
    305301!   Arguments:
    306302!   ----------
     303      integer,intent(in) :: llm
    307304      real zzmass(llm),pente_max
    308305      REAL q(llm),qm(llm+1)
     
    406403!         end if
    407404
    408       return
    409       end
     405       END SUBROUTINE vl1d
     406
     407END SUBROUTINE mass_redistribution
  • trunk/LMDZ.GENERIC/libf/phystd/mkstat.F90

    r1397 r1529  
    1010!  Yann W. july 2003
    1111
     12use statto_mod, only: istime,count
    1213use mod_phys_lmdz_para, only : is_master
    13 use statto_mod, only: istime,count
     14use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev
    1415
    1516implicit none
    1617
    17 #include "dimensions.h"
    18 #include "netcdf.inc"
     18include "netcdf.inc"
    1919
    20 integer,parameter :: iip1=iim+1
    21 integer,parameter :: jjp1=jjm+1
    2220integer :: ierr,nid,nbvar,i,ndims,lt,nvarid
    2321integer, dimension(4) :: id,varid,start,size
    2422integer, dimension(5) :: dimids
    2523character (len=50) :: name,nameout,units,title
    26 real, dimension(iip1,jjp1,llm) :: sum3d,square3d,mean3d,sd3d
    27 real, dimension(iip1,jjp1) :: sum2d,square2d,mean2d,sd2d
     24real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: sum3d,square3d,mean3d,sd3d
     25real, dimension(nbp_lon+1,nbp_lat) :: sum2d,square2d,mean2d,sd2d
    2826real, dimension(istime) :: time
    29 real, dimension(jjp1) :: lat
    30 real, dimension(iip1) :: lon
    31 real, dimension(llm) :: alt
     27real, dimension(nbp_lat) :: lat
     28real, dimension(nbp_lon+1) :: lon
     29real, dimension(nbp_lev) :: alt
    3230logical :: lcopy=.true.
    3331!integer :: latid,lonid,altid,timeid
     
    3533!integer, dimension(4) :: dimout
    3634
     35! Incrementation of count for the last step, which is not done in wstats
     36count(istime)=count(istime)+1
     37
    3738if (is_master) then
    3839! only the master needs do this
    39 
    40 ! Incrementation of count for the last step, which is not done in wstats
    41 count(istime)=count(istime)+1
    4240
    4341ierr = NF_OPEN("stats.nc",NF_WRITE,nid)
     
    107105!      dimout(4)=timeid
    108106
    109       size=(/iip1,jjp1,llm,1/)
     107      size=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
    110108      do lt=1,istime
    111109         start=(/1,1,1,lt/)
     
    137135!      dimout(3)=timeid
    138136
    139       size=(/iip1,jjp1,1,0/)
     137      size=(/nbp_lon+1,nbp_lat,1,0/)
    140138      do lt=1,istime
    141139         start=(/1,1,lt,0/)
  • trunk/LMDZ.GENERIC/libf/phystd/physiq.F90

    r1525 r1529  
    2626      use time_phylmdz_mod, only: ecritphy, iphysiq, nday
    2727      use phyredem, only: physdem0, physdem1
    28       use slab_ice_h
     28      use slab_ice_h, only: capcalocean, capcalseaice,capcalsno, &
     29                            noceanmx
    2930      use ocean_slab_mod, only :ocean_slab_init, ocean_slab_ice, &
     31                                ini_surf_heat_transp_mod, &
    3032                                ocean_slab_get_vars,ocean_slab_final
    3133      use surf_heat_transp_mod,only :init_masquv
     
    558560                                sea_ice, pctsrf_sic)
    559561
     562           call ini_surf_heat_transp_mod()
     563           
    560564           knindex(:) = 0
    561565
  • trunk/LMDZ.GENERIC/libf/phystd/radcommon_h.F90

    r1315 r1529  
    1       module radcommon_h
    2 
    3       use radinc_h
     1module radcommon_h
     2      use radinc_h, only: L_NSPECTI, L_NSPECTV, L_NGAUSS, NTstar, NTstop, &
     3                          naerkind, nsizemax
    44      implicit none
    55
     
    121121      REAL :: omegaREFir(naerkind,nsizemax)
    122122
    123       REAL tstellar ! Stellar brightness temperature (SW)
     123      REAL,SAVE :: tstellar ! Stellar brightness temperature (SW)
    124124
    125       real*8 planckir(L_NSPECTI,NTstop-NTstar+1)
     125      real*8,save :: planckir(L_NSPECTI,NTstop-NTstar+1)
    126126
    127       real*8 PTOP, TAUREF(L_LEVELS+1)
     127      real*8,save :: PTOP
     128      real*8,save,allocatable :: TAUREF(:)
    128129
    129       real*8, parameter :: UBARI = 0.5D0
     130      real*8,parameter :: UBARI = 0.5D0
    130131
    131       real*8 gweight(L_NGAUSS)
     132      real*8,save :: gweight(L_NGAUSS)
    132133!$OMP THREADPRIVATE(QREFvis,QREFir,omegaREFvis,omegaREFir,&     ! gweight read by master in sugas_corrk
    133134                !$OMP tstellar,planckir,PTOP,TAUREF)
     
    144145      real*8, parameter :: grav = 6.672E-11
    145146
    146       real*8 Cmk
    147       save Cmk
    148       real*8 glat_ig
    149       save glat_ig
     147      real*8,save :: Cmk
     148      real*8,save :: glat_ig
    150149!$OMP THREADPRIVATE(Cmk,glat_ig)
    151150
    152151      ! extinction of incoming sunlight (Saturn's rings, eclipses, etc...)
    153       REAL, DIMENSION(:), ALLOCATABLE :: eclipse
     152      REAL, DIMENSION(:), ALLOCATABLE ,SAVE :: eclipse
    154153
    155154      !Latitude-dependent gravity
    156       REAL, DIMENSION(:), ALLOCATABLE :: glat
     155      REAL, DIMENSION(:), ALLOCATABLE , SAVE :: glat
    157156!$OMP THREADPRIVATE(glat,eclipse)
    158157
    159       end module radcommon_h
     158contains
     159
     160      subroutine ini_radcommon_h
     161      use radinc_h, only: L_LEVELS
     162      implicit none
     163     
     164        allocate(TAUREF(L_LEVELS+1))
     165     
     166      end subroutine ini_radcommon_h
     167
     168end module radcommon_h
  • trunk/LMDZ.GENERIC/libf/phystd/radii_mod.F90

    r1521 r1529  
    88!     water cloud optical properties
    99
    10       use callkeys_mod, only: radfixed,Nmix_co2,                        &
    11                 pres_bottom_tropo,pres_top_tropo,size_tropo,    &
    12                 pres_bottom_strato,size_strato
     10      use callkeys_mod, only: radfixed,Nmix_co2,                    &
     11                pres_bottom_tropo,pres_top_tropo,size_tropo,        &
     12                pres_bottom_strato,size_strato
    1313     
    1414      real, save ::  rad_h2o
     
    2121
    2222
    23       contains
     23contains
    2424
    2525
     
    3838      use ioipsl_getin_p_mod, only: getin_p
    3939      use radinc_h, only: naerkind
    40       use aerosol_mod
    41 !      USE tracer_h
    42       Implicit none
    43 
    44 !      include "dimensions.h"
    45 !      include "dimphys.h"
     40      use aerosol_mod, only: iaero_back2lay, iaero_co2, iaero_dust, &
     41                             iaero_h2o, iaero_h2so4
     42      Implicit none
    4643
    4744      integer,intent(in) :: ngrid
     
    8178               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
    8279            endif
    83            
    84             if(iaer.eq.iaero_back2lay)then ! Two-layer aerosols
     80           
     81            if(iaer.eq.iaero_back2lay)then ! Two-layer aerosols
    8582               reffrad(1:ngrid,1:nlayer,iaer) = 2.e-6
    8683               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1
     
    10198         if (radfixed) then
    10299
    103             write(*,*)"radius of H2O water particles:"
     100            write(*,*)"radius of H2O water particles:"
    104101            rad_h2o=13. ! default value
    105102            call getin_p("rad_h2o",rad_h2o)
    106103            write(*,*)" rad_h2o = ",rad_h2o
    107104
    108             write(*,*)"radius of H2O ice particles:"
     105            write(*,*)"radius of H2O ice particles:"
    109106            rad_h2o_ice=35. ! default value
    110107            call getin_p("rad_h2o_ice",rad_h2o_ice)
    111108            write(*,*)" rad_h2o_ice = ",rad_h2o_ice
    112109
    113         else
     110        else
    114111
    115112            write(*,*)"Number mixing ratio of H2O water particles:"
     
    122119            call getin_p("Nmix_h2o_ice",Nmix_h2o_ice)
    123120            write(*,*)" Nmix_h2o_ice = ",Nmix_h2o_ice
    124         endif
     121        endif
    125122
    126123      print*,'exit su_aer_radii'
     
    173170               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
    174171               zfice = MIN(MAX(zfice,0.0),1.0)
    175                zrad_liq  = CBRT( 3*pq(ig,l)/(4*Nmix_h2o*pi*rhowater) )
    176                zrad_ice  = CBRT( 3*pq(ig,l)/(4*Nmix_h2o_ice*pi*rhowaterice) )
     172               zrad_liq  = CBRT( 3*pq(ig,l)/(4*Nmix_h2o*pi*rhowater) )
     173               zrad_ice  = CBRT( 3*pq(ig,l)/(4*Nmix_h2o_ice*pi*rhowaterice) )
    177174               nueffrad(ig,l) = coef_chaud * (1.-zfice) + coef_froid * zfice
    178175               zrad = zrad_liq * (1.-zfice) + zrad_ice * zfice
    179176
    180                reffrad(ig,l) = min(max(zrad,1.e-6),1000.e-6)
     177               reffrad(ig,l) = min(max(zrad,1.e-6),1000.e-6)
    181178               enddo
    182179            enddo     
     
    213210
    214211      if (radfixed) then
    215         reffliq(1:ngrid,1:nlayer)= rad_h2o
    216         reffice(1:ngrid,1:nlayer)= rad_h2o_ice
     212        reffliq(1:ngrid,1:nlayer)= rad_h2o
     213        reffice(1:ngrid,1:nlayer)= rad_h2o_ice
    217214      else
    218         do k=1,nlayer
    219            do i=1,ngrid
    220              reffliq(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o*pi*rhowater))
    221              reffliq(i,k) = min(max(reffliq(i,k),1.e-6),1000.e-6)
    222            
    223              reffice(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o_ice*pi*rhowaterice))
    224              reffice(i,k) = min(max(reffice(i,k),1.e-6),1000.e-6)
    225            enddo
    226         enddo
     215        do k=1,nlayer
     216           do i=1,ngrid
     217             reffliq(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o*pi*rhowater))
     218             reffliq(i,k) = min(max(reffliq(i,k),1.e-6),1000.e-6)
     219           
     220             reffice(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o_ice*pi*rhowaterice))
     221             reffice(i,k) = min(max(reffice(i,k),1.e-6),1000.e-6)
     222           enddo
     223        enddo
    227224      endif
    228225
  • trunk/LMDZ.GENERIC/libf/phystd/radinc_h.F90

    r1520 r1529  
    1       module radinc_h
     1module radinc_h
    22
    3       implicit none
     3  implicit none
    44
    5 #include "dimensions.h"
    6 #include "bands.h"
    7 #include "scatterers.h"
     5  include "bands.h"
     6  include "scatterers.h"
    87
    98!======================================================================
     
    5756!----------------------------------------------------------------------
    5857
    59       integer, parameter :: L_NLAYRAD  = llm
    60       integer, parameter :: L_LEVELS   = 2*(llm-1)+3
    61       integer, parameter :: L_NLEVRAD  = llm+1
     58      integer,save :: L_NLAYRAD  ! = nbp_lev ! set by ini_radinc_h
     59      integer,save :: L_LEVELS   ! = 2*(nbp_lev-1)+3 ! set by ini_radinc_h
     60      integer,save :: L_NLEVRAD  ! = nbp_lev+1 ! set by ini_radinc_h
     61!$OMP THREADPRIVATE(L_NLAYRAD,L_LEVELS,L_NLEVRAD)
    6262
    6363      ! These are set in sugas_corrk
     
    9696!$OMP THREADPRIVATE(banddir)
    9797
    98       end module radinc_h
     98contains
     99
     100  subroutine ini_radinc_h(nbp_lev)
     101  ! Initialize module variables
     102  implicit none
     103  integer,intent(in) :: nbp_lev
     104 
     105  L_NLAYRAD = nbp_lev
     106  L_LEVELS = 2*(nbp_lev-1)+3
     107  L_NLEVRAD = nbp_lev+1
     108 
     109  end subroutine
     110
     111end module radinc_h
  • trunk/LMDZ.GENERIC/libf/phystd/soil.F

    r1524 r1529  
    2020!        heat capacity are commons in comsoil.h
    2121!-----------------------------------------------------------------------
    22 
    23 !      include "dimensions.h"
    24 !      include "dimphys.h"
    25 
    2622
    2723c-----------------------------------------------------------------------
  • trunk/LMDZ.GENERIC/libf/phystd/suaer_corrk.F90

    r1470 r1529  
    22
    33      ! inputs
    4       use radinc_h,    only: L_NSPECTI,L_NSPECTV,nsizemax,iim,jjm,naerkind
     4      use radinc_h,    only: L_NSPECTI,L_NSPECTV,nsizemax,naerkind
    55      use radcommon_h, only: blamv,blami,lamrefir,lamrefvis
    66      use datafile_mod, only: datadir, aerdir
  • trunk/LMDZ.GENERIC/libf/phystd/surf_heat_transp_mod.F90

    r1397 r1529  
    44MODULE surf_heat_transp_mod
    55
    6 
     6IMPLICIT NONE 
     7
     8  ! Variables copied over from dyn3d dynamics:
     9  REAL,SAVE,ALLOCATABLE :: fext(:)
     10  REAL,SAVE,ALLOCATABLE :: unsairez(:)
     11  REAL,SAVE,ALLOCATABLE :: unsaire(:)
     12  REAL,SAVE,ALLOCATABLE :: cu(:)
     13  REAL,SAVE,ALLOCATABLE :: cv(:)
     14  REAL,SAVE,ALLOCATABLE :: cuvsurcv(:)
     15  REAL,SAVE,ALLOCATABLE :: cvusurcu(:)
     16  REAL,SAVE,ALLOCATABLE :: aire(:)
     17  REAL,SAVE :: apoln
     18  REAL,SAVE :: apols
     19  REAL,SAVE,ALLOCATABLE :: aireu(:)
     20  REAL,SAVE,ALLOCATABLE :: airev(:)
     21
     22  LOGICAL,SAVE :: alpha_var
     23  LOGICAL,SAVE :: slab_upstream
     24  REAL,SAVE,ALLOCATABLE :: zmasqu(:)
     25  REAL,SAVE,ALLOCATABLE :: zmasqv(:)
     26  REAL,SAVE,ALLOCATABLE :: unsfv(:)
     27  REAL,SAVE,ALLOCATABLE :: unsev(:)
     28  REAL,SAVE,ALLOCATABLE :: unsfu(:)
     29  REAL,SAVE,ALLOCATABLE :: unseu(:)
     30
     31  ! Routines usable only by routines within this module:
     32  PRIVATE :: gr_fi_dyn, gr_dyn_fi
     33  ! Routines from dyn3d, valid on global dynamics grid only:
     34  PRIVATE :: grad,diverg,gr_u_scal,gr_v_scal
     35 
    736CONTAINS
    8 
    9       SUBROUTINE divgrad_phy(ngrid,nlevs,temp,delta)
    10 
    11       USE comhdiff_mod, ONLY: zmasqu,zmasqv
    12 
     37 
     38  SUBROUTINE ini_surf_heat_transp(ip1jm,ip1jmp1,unsairez_,fext_,unsaire_,&
     39                                  cu_,cuvsurcv_,cv_,cvusurcu_, &
     40                                  aire_,apoln_,apols_, &
     41                                  aireu_,airev_)
     42    USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat
     43    IMPLICIT NONE
     44    ! Transfer some variables from dyn3d dynamics
     45    INTEGER,INTENT(IN) :: ip1jm
     46    INTEGER,INTENT(IN) :: ip1jmp1
     47    REAL,INTENT(IN) :: unsairez_(ip1jm)
     48    REAL,INTENT(IN) :: fext_(ip1jm)
     49    REAL,INTENT(IN) :: unsaire_(ip1jmp1)
     50    REAL,INTENT(IN) :: cu_(ip1jmp1)
     51    REAL,INTENT(IN) :: cuvsurcv_(ip1jm)
     52    REAL,INTENT(IN) :: cv_(ip1jm)
     53    REAL,INTENT(IN) :: cvusurcu_(ip1jmp1)
     54    REAL,INTENT(IN) :: aire_(ip1jmp1)
     55    REAL,INTENT(IN) :: apoln_
     56    REAL,INTENT(IN) :: apols_
     57    REAL,INTENT(IN) :: aireu_(ip1jmp1)
     58    REAL,INTENT(IN) :: airev_(ip1jm)
     59   
     60    ! Sanity check
     61    if ((ip1jm.ne.((nbp_lon+1)*(nbp_lat-1))).or. &
     62        (ip1jmp1.ne.((nbp_lon+1)*nbp_lat))) then
     63      write(*,*) "ini_surf_heat_transp Error: wrong array sizes"
     64      stop
     65    endif
     66   
     67    allocate(unsairez(ip1jm))
     68    unsairez(:)=unsairez_(:)
     69    allocate(fext(ip1jm))
     70    fext(:)=fext_(:)
     71    allocate(unsaire(ip1jmp1))
     72    unsaire(:)=unsaire_(:)
     73    allocate(cu(ip1jmp1))
     74    cu(:)=cu_(:)
     75    allocate(cuvsurcv(ip1jm))
     76    cuvsurcv(:)=cuvsurcv_(:)
     77    allocate(cv(ip1jm))
     78    cv(:)=cv_(:)
     79    allocate(cvusurcu(ip1jmp1))
     80    cvusurcu(:)=cvusurcu_(:)
     81    allocate(aire(ip1jmp1))
     82    aire(:)=aire_(:)
     83    apoln=apoln_
     84    apols=apols_
     85    allocate(aireu(ip1jmp1))
     86    aireu(:)=aireu_(:)
     87    allocate(airev(ip1jm))
     88    airev(:)=airev_(:)
     89   
     90  END SUBROUTINE ini_surf_heat_transp
     91 
     92  SUBROUTINE ini_surf_heat_transp_mod
     93    USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat
     94    IMPLICIT NONE
     95    INTEGER :: ip1jm, ip1jmp1
     96   
     97    ip1jm=(nbp_lon+1)*(nbp_lat-1)
     98    ip1jmp1=(nbp_lon+1)*nbp_lat
     99 
     100    allocate(zmasqu(ip1jmp1))
     101    allocate(zmasqv(ip1jm))
     102    allocate(unsfv(ip1jm))
     103    allocate(unsev(ip1jm))
     104    allocate(unsfu(ip1jmp1))
     105    allocate(unseu(ip1jmp1))
     106
     107  END SUBROUTINE ini_surf_heat_transp_mod
     108
     109  SUBROUTINE divgrad_phy(ngrid,nlevs,temp,delta)
     110
     111      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
    13112      IMPLICIT NONE
    14113
    15 #include "dimensions.h"
    16 !#include "dimphys.h"
    17 #include "paramet.h"
    18 #include "comgeom.h"
    19      
    20114      INTEGER,INTENT(IN) :: ngrid, nlevs
    21115      REAL,INTENT(IN) :: temp(ngrid,nlevs)
    22116      REAL,INTENT(OUT) :: delta(ngrid,nlevs)
    23       REAL delta_2d(ip1jmp1,nlevs)
     117      REAL delta_2d((nbp_lon+1)*nbp_lat,nlevs)
    24118      INTEGER :: ll
    25       REAL ghx(ip1jmp1,nlevs), ghy(ip1jm,nlevs)
    26 
     119      REAL ghx((nbp_lon+1)*nbp_lat,nlevs)
     120      REAL ghy((nbp_lon+1)*(nbp_lat-1),nlevs)
     121      INTEGER :: iip1,jjp1
     122     
     123      iip1=nbp_lon+1
     124      jjp1=nbp_lat
    27125
    28126      CALL gr_fi_dyn(nlevs,ngrid,iip1,jjp1,temp,delta_2d)
     
    42140
    43141
    44       SUBROUTINE init_masquv(ngrid,zmasq)
    45 
    46       USE comhdiff_mod, ONLY: zmasqu,zmasqv,unsfu,unsfv,unseu,unsev
    47      
     142  SUBROUTINE init_masquv(ngrid,zmasq)
     143
     144      USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat
    48145      IMPLICIT NONE
    49 
    50 #include "dimensions.h"
    51 !#include "dimphys.h"
    52 #include "paramet.h"
    53 #include "comgeom.h"
    54146
    55147
    56148      INTEGER,INTENT(IN) :: ngrid
    57149      REAL zmasq(ngrid)
    58       REAL zmasq_2d(ip1jmp1)
    59       REAL ff(ip1jm)
     150      REAL zmasq_2d((nbp_lon+1)*nbp_lat)
     151      REAL ff((nbp_lon+1)*(nbp_lat-1))
    60152      REAL eps
    61153      INTEGER i
    62 
     154      INTEGER :: iim,iip1,jjp1,ip1jm,ip1jmp1
     155     
     156      iim=nbp_lon
     157      iip1=nbp_lon+1
     158      jjp1=nbp_lat
     159      ip1jm=(nbp_lon+1)*(nbp_lat-1)
     160      ip1jmp1=(nbp_lon+1)*nbp_lat
    63161
    64162! Masques u,v
     
    104202
    105203
    106       SUBROUTINE slab_ekman2(ngrid,tx_phy,ty_phy,ts_phy,dt_phy)
    107  
    108           use slab_ice_h
    109           USE comhdiff_mod, ONLY: zmasqu,zmasqv,unsfu,unsfv,unseu,unsev
     204  SUBROUTINE slab_ekman2(ngrid,tx_phy,ty_phy,ts_phy,dt_phy)
     205 
     206      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
     207      USE slab_ice_h, ONLY: noceanmx
    110208
    111209      IMPLICIT NONE
    112210     
    113 #include "dimensions.h"
    114 !#include "dimphys.h"
    115 #include "paramet.h"
    116 #include "comgeom.h"
    117 
    118211      INTEGER,INTENT(IN) :: ngrid
    119212      INTEGER ij
    120       REAL txv(ip1jm),fluxm(ip1jm),tyv(ip1jm)
    121       REAL fluxtm(ip1jm,noceanmx),fluxtz(ip1jmp1,noceanmx)
    122       REAL tyu(ip1jmp1),txu(ip1jmp1),fluxz(ip1jmp1),fluxv(ip1jmp1)
    123       REAL dt(ip1jmp1,noceanmx),ts(ip1jmp1,noceanmx)
     213      REAL txv((nbp_lon+1)*(nbp_lat-1)),fluxm((nbp_lon+1)*(nbp_lat-1))
     214      REAL tyv((nbp_lon+1)*(nbp_lat-1))
     215      REAL fluxtm((nbp_lon+1)*(nbp_lat-1),noceanmx)
     216      REAL fluxtz((nbp_lon+1)*nbp_lat,noceanmx)
     217      REAL tyu((nbp_lon+1)*nbp_lat),txu((nbp_lon+1)*nbp_lat)
     218      REAL fluxz((nbp_lon+1)*nbp_lat),fluxv((nbp_lon+1)*nbp_lat)
     219      REAL dt((nbp_lon+1)*nbp_lat,noceanmx),ts((nbp_lon+1)*nbp_lat,noceanmx)
    124220      REAL tx_phy(ngrid),ty_phy(ngrid)
    125221      REAL dt_phy(ngrid,noceanmx),ts_phy(ngrid,noceanmx)
    126222
    127 
    128 
     223      INTEGER iim,iip1,iip2,jjp1,ip1jm,ip1jmi1,ip1jmp1
     224
     225      iim=nbp_lon
     226      iip1=nbp_lon+1
     227      iip2=nbp_lon+2
     228      jjp1=nbp_lon
     229      ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
     230      ip1jmi1=(nbp_lon+1)*(nbp_lat-1)-(nbp_lon+1) ! = ip1jm - iip1
     231      ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
    129232
    130233! Passage taux,y sur grilles 2d
     
    226329  END SUBROUTINE slab_ekman2
    227330
    228  
     331!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     332
     333  SUBROUTINE gr_fi_dyn(nfield,ngrid,im,jm,pfi,pdyn)
     334  ! Transfer a variable on global "physics" grid to global "dynamics" grid
     335  IMPLICIT NONE
     336
     337  INTEGER,INTENT(IN) :: im,jm,ngrid,nfield
     338  REAL,INTENT(IN) :: pfi(ngrid,nfield)
     339  REAL,INTENT(OUT) :: pdyn(im,jm,nfield)
     340 
     341  INTEGER :: i,j,ifield,ig
     342 
     343  DO ifield=1,nfield
     344    ! Handle poles
     345    DO i=1,im
     346      pdyn(i,1,ifield)=pfi(1,ifield)
     347      pdyn(i,jm,ifield)=pfi(ngrid,ifield)
     348    ENDDO
     349    ! Other points
     350    DO j=2,jm-1
     351      ig=2+(j-2)*(im-1)
     352      CALL SCOPY(im-1,pfi(ig,ifield),1,pdyn(1,j,ifield),1)
     353      pdyn(im,j,ifield)=pdyn(1,j,ifield)
     354    ENDDO
     355  ENDDO ! of DO ifield=1,nfield
     356 
     357  END SUBROUTINE gr_fi_dyn
     358 
     359
     360
     361  SUBROUTINE gr_dyn_fi(nfield,im,jm,ngrid,pdyn,pfi)
     362  ! Transfer a variable on global "dynamics" grid to global "physics" grid
     363  IMPLICIT NONE
     364 
     365  INTEGER,INTENT(IN) :: im,jm,ngrid,nfield
     366  REAL,INTENT(IN) :: pdyn(im,jm,nfield)
     367  REAL,INTENT(OUT) :: pfi(ngrid,nfield)
     368 
     369  INTEGER j,ifield,ig
     370
     371  ! Sanity check:
     372  IF(ngrid.NE.2+(jm-2)*(im-1)) THEN
     373    WRITE(*,*) "gr_dyn_fi error, wrong sizes"
     374    STOP
     375  ENDIF
     376 
     377  ! Handle poles
     378  CALL SCOPY(nfield,pdyn,im*jm,pfi,ngrid)
     379  CALL SCOPY(nfield,pdyn(1,jm,1),im*jm,pfi(ngrid,1),ngrid)
     380  ! Other points
     381  DO ifield=1,nfield
     382    DO j=2,jm-1
     383      ig=2+(j-2)*(im-1)
     384      CALL SCOPY(im-1,pdyn(1,j,ifield),1,pfi(ig,ifield),1)
     385    ENDDO
     386  ENDDO
     387
     388  END SUBROUTINE gr_dyn_fi
     389
     390
     391
     392  SUBROUTINE  grad(klevel,pg,pgx,pgy)
     393  ! compute the covariant components x,y of the gradient of pg
     394  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
     395  IMPLICIT NONE
     396 
     397  INTEGER,INTENT(IN) :: klevel
     398  REAL,INTENT(IN) :: pg((nbp_lon+1)*nbp_lat,klevel)
     399  REAL,INTENT(OUT) :: pgx((nbp_lon+1)*nbp_lat,klevel)
     400  REAL,INTENT(OUT) :: pgy((nbp_lon+1)*(nbp_lat-1),klevel)
     401
     402  INTEGER :: l,ij
     403  INTEGER :: iim,iip1,ip1jm,ip1jmp1
     404 
     405  iim=nbp_lon
     406  iip1=nbp_lon+1
     407  ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
     408  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
     409 
     410  DO l=1,klevel
     411    DO ij=1,ip1jmp1-1
     412      pgx(ij,l)=pg(ij+1,l)-pg(ij,l)
     413    ENDDO
     414    ! correction for pgx(ip1,j,l) ...
     415    ! ... pgx(iip1,j,l)=pgx(1,j,l) ...
     416    DO ij=iip1,ip1jmp1,iip1
     417      pgx(ij,l)=pgx(ij-iim,l)
     418    ENDDO
     419    DO ij=1,ip1jm
     420      pgy(ij,l)=pg(ij,l)-pg(ij+iip1,l)
     421    ENDDO
     422  ENDDO
     423 
     424  END SUBROUTINE grad
     425
     426
     427
     428  SUBROUTINE diverg(klevel,x,y,div)
     429  ! compute the divergence of a vector field of components
     430  ! x,y. y and y being covriant components
     431  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
     432  IMPLICIT NONE
     433 
     434  INTEGER,INTENT(IN) :: klevel
     435  REAL,INTENT(IN) :: x((nbp_lon+1)*nbp_lat,klevel)
     436  REAL,INTENT(IN) :: y((nbp_lon+1)*(nbp_lat-1),klevel)
     437  REAL,INTENT(OUT) :: div((nbp_lon+1)*nbp_lat,klevel)
     438 
     439  INTEGER :: l,ij
     440  INTEGER :: iim,iip1,iip2,ip1jm,ip1jmp1,ip1jmi1
     441 
     442  REAL :: aiy1(nbp_lon+1),aiy2(nbp_lon+1)
     443  REAL :: sumypn,sumyps
     444  REAL,EXTERNAL :: SSUM
     445 
     446  iim=nbp_lon
     447  iip1=nbp_lon+1
     448  iip2=nbp_lon+2
     449  ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
     450  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
     451  ip1jmi1=(nbp_lon+1)*(nbp_lat-1)-(nbp_lon+1) ! = ip1jm - iip1
     452 
     453  DO l=1,klevel
     454    DO ij=iip2,ip1jm-1
     455      div(ij+1,l)= &
     456        cvusurcu(ij+1)*x(ij+1,l)-cvusurcu(ij)*x(ij,l)+ &
     457        cuvsurcv(ij-iim)*y(ij-iim,l)-cuvsurcv(ij+1)*y(ij+1,l)
     458    ENDDO
     459    ! correction for div(1,j,l) ...
     460    ! ... div(1,j,l)= div(iip1,j,l) ...
     461    DO ij=iip2,ip1jm,iip1
     462      div(ij,l)=div(ij+iim,l)
     463    ENDDO
     464    ! at the poles
     465    DO ij=1,iim
     466      aiy1(ij)=cuvsurcv(ij)*y(ij,l)
     467      aiy2(ij)=cuvsurcv(ij+ip1jmi1)*y(ij+ip1jmi1,l)
     468    ENDDO
     469    sumypn=SSUM(iim,aiy1,1)/apoln
     470    sumyps=SSUM(iim,aiy2,1)/apols
     471    DO ij=1,iip1
     472      div(ij,l)=-sumypn
     473      div(ij+ip1jm,l)=sumyps
     474    ENDDO
     475  ENDDO ! of DO l=1,klevel
     476 
     477  !!! CALL filtreg( div, jjp1, klevel, 2, 2, .TRUE., 1 )
     478 
     479  DO l=1,klevel
     480    DO ij=iip2,ip1jm
     481      div(ij,l)=div(ij,l)*unsaire(ij)
     482    ENDDO
     483  ENDDO
     484 
     485  END SUBROUTINE diverg
     486
     487
     488
     489  SUBROUTINE gr_u_scal(nx,x_u,x_scal)
     490  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
     491  IMPLICIT NONE
     492 
     493  INTEGER,INTENT(IN) :: nx
     494  REAL,INTENT(IN) :: x_u((nbp_lon+1)*nbp_lat,nx)
     495  REAL,INTENT(OUT) :: x_scal((nbp_lon+1)*nbp_lat,nx)
     496 
     497  INTEGER :: l,ij
     498  INTEGER :: iip1,jjp1,ip1jmp1
     499 
     500  iip1=nbp_lon+1
     501  jjp1=nbp_lat
     502  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
     503 
     504  DO l=1,nx
     505    DO ij=ip1jmp1,2,-1
     506      x_scal(ij,l)= &
     507                   (aireu(ij)*x_u(ij,l)+aireu(ij-1)*x_u(ij-1,l)) &
     508                  /(aireu(ij)+aireu(ij-1))
     509    ENDDO
     510  ENDDO
     511 
     512  CALL SCOPY(nx*jjp1,x_scal(iip1,1),iip1,x_scal(1,1),iip1)
     513
     514  END SUBROUTINE gr_u_scal
     515
     516
     517
     518  SUBROUTINE gr_v_scal(nx,x_v,x_scal)
     519  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
     520  IMPLICIT NONE
     521 
     522  INTEGER,INTENT(IN) :: nx
     523  REAL,INTENT(IN) :: x_v((nbp_lon+1)*(nbp_lat-1),nx)
     524  REAL,INTENT(OUT) :: x_scal((nbp_lon+1)*nbp_lat,nx)
     525 
     526  INTEGER :: l,ij
     527  INTEGER :: iip1,iip2,ip1jm,ip1jmp1
     528 
     529  iip1=nbp_lon+1
     530  iip2=nbp_lon+2
     531  ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
     532  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
     533 
     534  DO l=1,nx
     535    DO ij=iip2,ip1jm
     536      x_scal(ij,l)= &
     537                   (airev(ij-iip1)*x_v(ij-iip1,l)+airev(ij)*x_v(ij,l)) &
     538                  /(airev(ij-iip1)+airev(ij))
     539    ENDDO
     540    DO ij=1,iip1
     541      x_scal(ij,l)=0.
     542    ENDDO
     543    DO ij=ip1jm+1,ip1jmp1
     544      x_scal(ij,l)=0.
     545    ENDDO
     546  ENDDO
     547
     548  END SUBROUTINE gr_v_scal
     549 
    229550END MODULE surf_heat_transp_mod
    230551
  • trunk/LMDZ.GENERIC/libf/phystd/vdif_kc.F

    r1308 r1529  
    11      SUBROUTINE vdif_kc(ngrid,nlay,dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn)
    22      IMPLICIT NONE
    3 c.......................................................................
    4 !#include "dimensions.h"
    5 !#include "dimphys.h"
    63c.......................................................................
    74c
  • trunk/LMDZ.GENERIC/libf/phystd/vlz_fi.F

    r1308 r1529  
    1515c   --------------------------------------------------------------------
    1616      IMPLICIT NONE
    17 c
    18 !#include "dimensions.h"
    19 !#include "dimphys.h"
    20 
    2117c
    2218c
  • trunk/LMDZ.GENERIC/libf/phystd/writediagfi.F

    r1525 r1529  
    4040!=================================================================
    4141      use surfdat_h, only: phisfi
     42      use comgeomphy, only: airephy
    4243      use time_phylmdz_mod, only: ecritphy, day_step, iphysiq, day_ini
    4344      USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root,
    4445     &                               is_master, gather
    45       USE mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo
     46      USE mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo,
     47     &                              nbp_lon, nbp_lat, nbp_lev
    4648      implicit none
    4749
    4850! Commons
    49       include "dimensions.h"
    50       include "paramet.h"
    51       include "comgeom.h"
    5251      include "netcdf.inc"
    5352
     
    5655      character (len=*),intent(in) :: nom,titre,unite
    5756      integer,intent(in) :: dim
    58       real,intent(in) :: px(ngrid,llm)
     57      real,intent(in) :: px(ngrid,nbp_lev)
    5958
    6059! Local variables:
    6160
    62       real*4 dx3(iip1,jjp1,llm) ! to store a 3D data set
    63       real*4 dx2(iip1,jjp1)     ! to store a 2D (surface) data set
    64       real*4 dx1(llm)           ! to store a 1D (column) data set
     61      real*4 dx3(nbp_lon+1,nbp_lat,nbp_lev) ! to store a 3D data set
     62      real*4 dx2(nbp_lon+1,nbp_lat)     ! to store a 2D (surface) data set
     63      real*4 dx1(nbp_lev)           ! to store a 1D (column) data set
    6564      real*4 dx0
    6665
     
    6867!$OMP THREADPRIVATE(date)
    6968
    70       REAL phis(ip1jmp1)
     69      REAL phis((nbp_lon+1),nbp_lat)
     70      REAL area((nbp_lon+1),nbp_lat)
    7171
    7272      integer irythme
    7373      integer ierr,ierr2
    74       integer iq
    75       integer i,j,l,zmax , ig0
     74      integer i,j,l, ig0
    7675
    7776      integer,save :: zitau=0
     
    102101#ifdef CPP_PARA
    103102! Added to work in parallel mode
    104       real dx3_glop(klon_glo,llm)
    105       real dx3_glo(iim,jjp1,llm) ! to store a global 3D data set
     103      real dx3_glop(klon_glo,nbp_lev)
     104      real dx3_glo(nbp_lon,nbp_lat,nbp_lev) ! to store a global 3D data set
    106105      real dx2_glop(klon_glo)
    107       real dx2_glo(iim,jjp1)     ! to store a global 2D (surface) data set
     106      real dx2_glo(nbp_lon,nbp_lat)     ! to store a global 2D (surface) data set
    108107      real px2(ngrid)
    109 !      real dx1_glo(llm)          ! to store a 1D (column) data set
     108!      real dx1_glo(nbp_lev)          ! to store a 1D (column) data set
    110109!      real dx0_glo
    111110      real phisfi_glo(klon_glo) ! surface geopotential on global physics grid
     111      real areafi_glo(klon_glo) ! mesh area on global physics grid
    112112#else
    113113      real phisfi_glo(ngrid) ! surface geopotential on global physics grid
     114      real areafi_glo(ngrid) ! mesh area on global physics grid
    114115#endif
    115116
     
    117118!Sortie des variables au rythme voulu
    118119
    119       irythme = ecritphy ! sortie au rythme de ecritphy
     120      irythme = int(ecritphy) ! sortie au rythme de ecritphy
    120121!     irythme = iconser  ! sortie au rythme des variables de controle
    121122!     irythme = iphysiq  ! sortie a tous les pas physique
     
    188189          ! Gather phisfi() geopotential on physics grid
    189190          call Gather(phisfi,phisfi_glo)
     191          ! Gather airephy() mesh area on physics grid
     192          call Gather(airephy,areafi_glo)
    190193#else
    191194         phisfi_glo(:)=phisfi(:)
     195         areafi_glo(:)=airephy(:)
    192196#endif
    193197
     
    216220         ierr = NF_ENDDEF(nid)
    217221
     222         ! Build phis() and area()
     223         do i=1,nbp_lon+1 ! poles
     224           phis(i,1)=phisfi_glo(1)
     225           phis(i,nbp_lat)=phisfi_glo(klon_glo)
     226           ! for area, divide at the poles by nbp_lon
     227           area(i,1)=areafi_glo(1)/nbp_lon
     228           area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
     229         enddo
     230         do j=2,nbp_lat-1
     231           ig0= 1+(j-2)*nbp_lon
     232           do i=1,nbp_lon
     233              phis(i,j)=phisfi_glo(ig0+i)
     234              area(i,j)=areafi_glo(ig0+i)
     235           enddo
     236           ! handle redundant point in longitude
     237           phis(nbp_lon+1,j)=phis(1,j)
     238           area(nbp_lon+1,j)=area(1,j)
     239         enddo
     240         
    218241         ! write "header" of file (longitudes, latitudes, geopotential, ...)
    219          call gr_fi_dyn(1,size(phisfi_glo),iip1,jjp1,phisfi_glo,phis)
    220          call iniwrite(nid,day_ini,phis)
     242         call iniwrite(nid,day_ini,phis,area)
    221243
    222244         endif ! of if (is_master)
     
    234256
    235257      if (ngrid.eq.1) then
    236         ! in testphys1d, for the 1d version of the GCM, iphysiq
    237         ! should be most likely 1 (because no dyn!)
     258        ! in testphys1d, for the 1d version of the GCM, iphysiq and irythme
     259        ! are undefined; so set them to 1
    238260        iphysiq=1
     261        irythme=1
    239262        ! NB:
    240263      endif
     
    296319            call Grid1Dto2D_glo(dx3_glop,dx3_glo)
    297320            ! copy dx3_glo() to dx3(:) and add redundant longitude
    298             dx3(1:iim,:,:)=dx3_glo(1:iim,:,:)
    299             dx3(iip1,:,:)=dx3(1,:,:)
     321            dx3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
     322            dx3(nbp_lon+1,:,:)=dx3(1,:,:)
    300323          endif
    301324!$OMP END MASTER
     
    304327!         Passage variable physique -->  variable dynamique
    305328!         recast (copy) variable from physics grid to dynamics grid
    306            DO l=1,llm
    307              DO i=1,iip1
     329           DO l=1,nbp_lev
     330             DO i=1,nbp_lon+1
    308331                dx3(i,1,l)=px(1,l)
    309                 dx3(i,jjp1,l)=px(ngrid,l)
     332                dx3(i,nbp_lat,l)=px(ngrid,l)
    310333             ENDDO
    311              DO j=2,jjm
    312                 ig0= 1+(j-2)*iim
    313                 DO i=1,iim
     334             DO j=2,nbp_lat-1
     335                ig0= 1+(j-2)*nbp_lon
     336                DO i=1,nbp_lon
    314337                   dx3(i,j,l)=px(ig0+i,l)
    315338                ENDDO
    316                 dx3(iip1,j,l)=dx3(1,j,l)
     339                dx3(nbp_lon+1,j,l)=dx3(1,j,l)
    317340             ENDDO
    318341           ENDDO
     
    344367           corner(4)=ntime
    345368
    346            edges(1)=iip1
    347            edges(2)=jjp1
    348            edges(3)=llm
     369           edges(1)=nbp_lon+1
     370           edges(2)=nbp_lat
     371           edges(3)=nbp_lev
    349372           edges(4)=1
    350373!#ifdef NC_DOUBLE
     
    380403            call Grid1Dto2D_glo(dx2_glop,dx2_glo)
    381404            ! copy dx2_glo() to dx2(:) and add redundant longitude
    382             dx2(1:iim,:)=dx2_glo(1:iim,:)
    383             dx2(iip1,:)=dx2(1,:)
     405            dx2(1:nbp_lon,:)=dx2_glo(1:nbp_lon,:)
     406            dx2(nbp_lon+1,:)=dx2(1,:)
    384407          endif
    385408!$OMP END MASTER
     
    390413!         recast (copy) variable from physics grid to dynamics grid
    391414
    392              DO i=1,iip1
     415             DO i=1,nbp_lon+1
    393416                dx2(i,1)=px(1,1)
    394                 dx2(i,jjp1)=px(ngrid,1)
     417                dx2(i,nbp_lat)=px(ngrid,1)
    395418             ENDDO
    396              DO j=2,jjm
    397                 ig0= 1+(j-2)*iim
    398                 DO i=1,iim
     419             DO j=2,nbp_lat-1
     420                ig0= 1+(j-2)*nbp_lon
     421                DO i=1,nbp_lon
    399422                   dx2(i,j)=px(ig0+i,1)
    400423                ENDDO
    401                 dx2(iip1,j)=dx2(1,j)
     424                dx2(nbp_lon+1,j)=dx2(1,j)
    402425             ENDDO
    403426#endif
     
    426449           corner(2)=1
    427450           corner(3)=ntime
    428            edges(1)=iip1
    429            edges(2)=jjp1
     451           edges(1)=nbp_lon+1
     452           edges(2)=nbp_lat
    430453           edges(3)=1
    431454
     
    457480!         Passage variable physique -->  physique dynamique
    458481!         recast (copy) variable from physics grid to dynamics grid
    459           do l=1,llm
     482          do l=1,nbp_lev
    460483            dx1(l)=px(1,l)
    461484          enddo
     
    479502           corner(2)=ntime
    480503           
    481            edges(1)=llm
     504           edges(1)=nbp_lev
    482505           edges(2)=1
    483506!#ifdef NC_DOUBLE
     
    543566
    544567#endif
     568! of #ifndef MESOSCALE
    545569      end
  • trunk/LMDZ.GENERIC/libf/phystd/writediagsoil.F90

    r1525 r1529  
    1212! Modifs: Aug.2010 Ehouarn: enforce outputs to be real*4
    1313
    14 use comsoil_h, only: nsoilmx
     14use comsoil_h, only: nsoilmx, inertiedat
     15use comgeomphy, only: airephy
    1516use time_phylmdz_mod, only: ecritphy, day_step, iphysiq
    1617use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
    17 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo
     18use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, &
     19                              nbp_lon, nbp_lat
    1820
    1921implicit none
    2022
    21 #include"dimensions.h"
    22 #include"paramet.h"
    23 #include"netcdf.inc"
     23include"netcdf.inc"
    2424
    2525! Arguments:
     
    3131integer,intent(in) :: dimpx ! dimension of the variable (3,2 or 0)
    3232real,dimension(ngrid,nsoilmx),intent(in) :: px ! variable
    33 ! Note: nsoilmx is a parameter set in 'comsoil_h'
    3433
    3534! Local variables:
    36 real*4,dimension(iip1,jjp1,nsoilmx) :: data3 ! to store 3D data
    37 ! Note iip1,jjp1 known from paramet.h; nsoilmx known from comsoil_h
    38 real*4,dimension(iip1,jjp1) :: data2 ! to store 2D data
     35real*4,dimension(nbp_lon+1,nbp_lat,nsoilmx) :: data3 ! to store 3D data
     36real*4,dimension(nbp_lon+1,nbp_lat) :: data2 ! to store 2D data
    3937real*4 :: data0 ! to store 0D data
    4038integer :: i,j,l ! for loops
     
    4240
    4341real*4,save :: date ! time counter (in elapsed days)
     42
     43real :: inertia((nbp_lon+1),nbp_lat,nsoilmx)
     44real :: area((nbp_lon+1),nbp_lat)
     45
     46real :: inertiafi_glo(klon_glo,nsoilmx)
     47real :: areafi_glo(klon_glo)
     48
    4449integer,save :: isample ! sample rate at which data is to be written to output
    4550integer,save :: ntime=0 ! counter to internally store time steps
     
    6065! Added to work in parallel mode
    6166real dx3_glop(klon_glo,nsoilmx)
    62 real dx3_glo(iim,jjp1,nsoilmx) ! to store a global 3D data set
     67real dx3_glo(nbp_lon,nbp_lat,nsoilmx) ! to store a global 3D data set
    6368real dx2_glop(klon_glo)
    64 real dx2_glo(iim,jjp1)     ! to store a global 2D (surface) data set
     69real dx2_glo(nbp_lon,nbp_lat)     ! to store a global 2D (surface) data set
    6570real px2(ngrid)
    6671#endif
     
    8186 
    8287  ! Set output sample rate
    83   isample=ecritphy ! same as for diagfi outputs
     88  isample=int(ecritphy) ! same as for diagfi outputs
    8489  ! Note ecritphy is known from control.h
    8590 
     
    9196    stop
    9297   endif
     98
     99#ifdef CPP_PARA
     100   ! Gather inertiedat() soil thermal inertia on physics grid
     101   call Gather(inertiedat,inertiafi_glo)
     102   ! Gather airephy() mesh area on physics grid
     103   call Gather(airephy,areafi_glo)
     104#else
     105         inertiafi_glo(:,:)=inertiedat(:,:)
     106         areafi_glo(:)=airephy(:)
     107#endif
     108
     109   ! build inertia() and area()
     110   do i=1,nbp_lon+1 ! poles
     111     inertia(i,1,1:nsoilmx)=inertiafi_glo(1,1:nsoilmx)
     112     inertia(i,nbp_lat,1:nsoilmx)=inertiafi_glo(klon_glo,1:nsoilmx)
     113     ! for area, divide at the poles by nbp_lon
     114     area(i,1)=areafi_glo(1)/nbp_lon
     115     area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
     116   enddo
     117   do j=2,nbp_lat-1
     118     ig0= 1+(j-2)*nbp_lon
     119     do i=1,nbp_lon
     120        inertia(i,j,1:nsoilmx)=inertiafi_glo(ig0+i,1:nsoilmx)
     121        area(i,j)=areafi_glo(ig0+i)
     122     enddo
     123     ! handle redundant point in longitude
     124     inertia(nbp_lon+1,j,1:nsoilmx)=inertia(1,j,1:nsoilmx)
     125     area(nbp_lon+1,j)=area(1,j)
     126   enddo
     127   
     128   ! write "header" of file (longitudes, latitudes, geopotential, ...)
     129   call iniwritesoil(nid,ngrid,inertia,area)
     130
    93131  endif ! of if (is_master)
    94 
    95   ! Define dimensions and axis attributes
    96   call iniwritesoil(nid,ngrid)
    97132 
    98133  ! set zitau to -1 to be compatible with zitau incrementation step below
     
    148183    call Grid1Dto2D_glo(dx3_glop,dx3_glo)
    149184    ! copy dx3_glo() to dx3(:) and add redundant longitude
    150     data3(1:iim,:,:)=dx3_glo(1:iim,:,:)
    151     data3(iip1,:,:)=data3(1,:,:)
     185    data3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
     186    data3(nbp_lon+1,:,:)=data3(1,:,:)
    152187  endif
    153188!$OMP END MASTER
     
    156191  do l=1,nsoilmx
    157192    ! handle the poles
    158     do i=1,iip1
     193    do i=1,nbp_lon+1
    159194      data3(i,1,l)=px(1,l)
    160       data3(i,jjp1,l)=px(ngrid,l)
     195      data3(i,nbp_lat,l)=px(ngrid,l)
    161196    enddo
    162197    ! rest of the grid
    163     do j=2,jjm
    164       ig0=1+(j-2)*iim
    165       do i=1,iim
     198    do j=2,nbp_lat-1
     199      ig0=1+(j-2)*nbp_lon
     200      do i=1,nbp_lon
    166201        data3(i,j,l)=px(ig0+i,l)
    167202      enddo
    168       data3(iip1,j,l)=data3(1,j,l) ! extra (modulo) longitude
     203      data3(nbp_lon+1,j,l)=data3(1,j,l) ! extra (modulo) longitude
    169204    enddo
    170205  enddo
     
    195230  corners(4)=ntime
    196231 
    197   edges(1)=iip1
    198   edges(2)=jjp1
     232  edges(1)=nbp_lon+1
     233  edges(2)=nbp_lat
    199234  edges(3)=nsoilmx
    200235  edges(4)=1
     
    223258    call Grid1Dto2D_glo(dx2_glop,dx2_glo)
    224259    ! copy dx3_glo() to dx3(:) and add redundant longitude
    225     data2(1:iim,:)=dx2_glo(1:iim,:)
    226     data2(iip1,:)=data2(1,:)
     260    data2(1:nbp_lon,:)=dx2_glo(1:nbp_lon,:)
     261    data2(nbp_lon+1,:)=data2(1,:)
    227262  endif
    228263!$OMP END MASTER
     
    230265#else
    231266  ! handle the poles
    232   do i=1,iip1
     267  do i=1,nbp_lon+1
    233268    data2(i,1)=px(1,1)
    234     data2(i,jjp1)=px(ngrid,1)
     269    data2(i,nbp_lat)=px(ngrid,1)
    235270  enddo
    236271  ! rest of the grid
    237   do j=2,jjm
    238     ig0=1+(j-2)*iim
    239     do i=1,iim
     272  do j=2,nbp_lat-1
     273    ig0=1+(j-2)*nbp_lon
     274    do i=1,nbp_lon
    240275      data2(i,j)=px(ig0+i,1)
    241276    enddo
    242     data2(iip1,j)=data2(1,j) ! extra (modulo) longitude
     277    data2(nbp_lon+1,j)=data2(1,j) ! extra (modulo) longitude
    243278  enddo
    244279#endif
     
    266301  corners(3)=ntime
    267302 
    268   edges(1)=iip1
    269   edges(2)=jjp1
     303  edges(1)=nbp_lon+1
     304  edges(2)=nbp_lat
    270305  edges(3)=1
    271306 
  • trunk/LMDZ.GENERIC/libf/phystd/writediagspecIR.F

    r1525 r1529  
    4343! Addition by RW (2010) to allow OLR to be saved in .nc format
    4444      use radinc_h, only : L_NSPECTI
    45 !      USE surfdat_h, only : phisfi
    46 #ifdef CPP_PARA
     45      use comgeomphy, only: airephy
    4746      use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
    48       use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo
    49 #endif
     47      use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo,
     48     &                              nbp_lon, nbp_lat
    5049      use time_phylmdz_mod, only: ecritphy, iphysiq, day_step, day_ini
    5150      use callkeys_mod, only: iradia
     
    5352      implicit none
    5453
    55 ! Commons
    56 #include "dimensions.h"
    57 !#include "dimphys.h"
    58 #include "paramet.h"
    59 !#include "control.h"
    60 #include "comgeom.h"
    61 #include "netcdf.inc"
     54      include "netcdf.inc"
    6255
    6356! Arguments on input:
     
    7366!      real dx0
    7467
    75       real date
    76 
    77 !      REAL phis(ip1jmp1)
    78 
    7968      integer irythme
    8069      integer ierr
     
    8271      integer i,j,l,zmax , ig0
    8372
    84       integer zitau
    85       character firstnom*20
    86       SAVE firstnom
    87       SAVE zitau
    88       SAVE date
    89       data firstnom /'1234567890'/
    90       data zitau /0/
     73      integer,save :: zitau=0
     74      character(len=20),save :: firstnom='1234567890'
     75      real,save :: date
    9176!$OMP THREADPRIVATE(firstnom,zitau,date)
    9277
     
    10085      integer, dimension(4) :: edges,corner
    10186
     87      real area((nbp_lon+1),nbp_lat)
    10288! added by RDW for OLR output
    103        real dx3(iip1,jjp1,L_NSPECTI) ! to store the data set
     89       real dx3(nbp_lon+1,nbp_lat,L_NSPECTI) ! to store the data set
    10490
    10591#ifdef CPP_PARA
    10692! Added to work in parallel mode
    10793      real dx3_glop(klon_glo,L_NSPECTI)
    108       real dx3_glo(iim,jjp1,L_NSPECTI) ! to store a global 3D data set
    109 #else
    110       logical,parameter :: is_master=.true.
    111       logical,parameter :: is_mpi_root=.true.
     94      real dx3_glo(nbp_lon,nbp_lat,L_NSPECTI) ! to store a global 3D data set
     95      real areafi_glo(klon_glo) ! mesh area on global physics grid
     96#else
     97      real areafi_glo(ngrid) ! mesh area on global physics grid
    11298#endif
    11399
     
    139125         endif
    140126
     127#ifdef CPP_PARA
     128          ! Gather airephy() mesh area on physics grid
     129          call Gather(airephy,areafi_glo)
     130#else
     131         areafi_glo(:)=airephy(:)
     132#endif
    141133         ! Create the NetCDF file
    142134         if (is_master) then
     
    159151         ierr = NF_ENDDEF(nid)
    160152
    161 !         call gr_fi_dyn(1,size(phisfi_glo),iip1,jjp1,phisfi_glo,phis)
     153         ! Build area()
     154         do i=1,nbp_lon+1 ! poles
     155           ! divide at the poles by nbp_lon
     156           area(i,1)=areafi_glo(1)/nbp_lon
     157           area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
     158         enddo
     159         do j=2,nbp_lat-1
     160           ig0= 1+(j-2)*nbp_lon
     161           do i=1,nbp_lon
     162              area(i,j)=areafi_glo(ig0+i)
     163           enddo
     164           ! handle redundant point in longitude
     165           area(nbp_lon+1,j)=area(1,j)
     166         enddo
     167
    162168         ! write "header" of file (longitudes, latitudes, area, ...)
    163          call iniwrite_specIR(nid,day_ini)
     169         call iniwrite_specIR(nid,day_ini,area)
    164170         endif ! of if (is_master)
    165171
     
    215221             endif
    216222
    217              write(6,*)'WRITEDIAGSPEC: date= ', date
     223             write(6,*)'WRITEDIAGSPECIR: date= ', date
    218224           endif ! of if (is_master)
    219225        end if ! of if (nom.eq.firstnom)
     
    233239            call Grid1Dto2D_glo(dx3_glop,dx3_glo)
    234240            ! copy dx3_glo() to dx3(:) and add redundant longitude
    235             dx3(1:iim,:,:)=dx3_glo(1:iim,:,:)
    236             dx3(iip1,:,:)=dx3(1,:,:)
     241            dx3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
     242            dx3(nbp_lon+1,:,:)=dx3(1,:,:)
    237243          endif
    238244!$OMP END MASTER
     
    240246#else
    241247           DO l=1,L_NSPECTI
    242              DO i=1,iip1
     248             DO i=1,nbp_lon+1
    243249                dx3(i,1,l)=px(1,l)
    244                 dx3(i,jjp1,l)=px(ngrid,l)
     250                dx3(i,nbp_lat,l)=px(ngrid,l)
    245251             ENDDO
    246              DO j=2,jjm
    247                 ig0= 1+(j-2)*iim
    248                 DO i=1,iim
     252             DO j=2,nbp_lat-1
     253                ig0= 1+(j-2)*nbp_lon
     254                DO i=1,nbp_lon
    249255                   dx3(i,j,l)=px(ig0+i,l)
    250256                ENDDO
    251                 dx3(iip1,j,l)=dx3(1,j,l)
     257                dx3(nbp_lon+1,j,l)=dx3(1,j,l)
    252258             ENDDO
    253259           ENDDO
     
    279285           corner(4)=ntime
    280286
    281            edges(1)=iip1
    282            edges(2)=jjp1
     287           edges(1)=nbp_lon+1
     288           edges(2)=nbp_lat
    283289           edges(3)=L_NSPECTI
    284290           edges(4)=1
  • trunk/LMDZ.GENERIC/libf/phystd/writediagspecVI.F

    r1525 r1529  
    4343! Addition by RW (2010) to allow OSR to be saved in .nc format
    4444      use radinc_h, only : L_NSPECTV
    45 !      USE surfdat_h
    46 #ifdef CPP_PARA
     45      use comgeomphy, only: airephy
    4746      use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
    48       use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo
    49 #endif
     47      use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo,
     48     &                              nbp_lon, nbp_lat
    5049      use time_phylmdz_mod, only: ecritphy, iphysiq, day_step, day_ini
    5150      use callkeys_mod, only: iradia
     
    5352      implicit none
    5453
    55 ! Commons
    56 #include "dimensions.h"
    57 !#include "dimphys.h"
    58 #include "paramet.h"
    59 !#include "control.h"
    60 #include "comgeom.h"
    61 #include "netcdf.inc"
     54      include "netcdf.inc"
    6255
    6356! Arguments on input:
     
    7366!      real dx0
    7467
    75       real date
    76 
    77 !      REAL phis(ip1jmp1)
    78 
    7968      integer irythme
    8069      integer ierr
     
    8271      integer i,j,l,zmax , ig0
    8372
    84       integer zitau
    85       character firstnom*20
    86       SAVE firstnom
    87       SAVE zitau
    88       SAVE date
    89       data firstnom /'1234567890'/
    90       data zitau /0/
     73      integer,save :: zitau=0
     74      character(len=20),save :: firstnom='1234567890'
     75      real,save :: date
    9176!$OMP THREADPRIVATE(firstnom,zitau,date)
    9277
     
    10085      integer, dimension(4) :: edges,corner
    10186
     87      real area((nbp_lon+1),nbp_lat)
    10288! added by RDW for OSR output
    103        real dx3(iip1,jjp1,L_NSPECTV) ! to store the data set
     89       real dx3(nbp_lon+1,nbp_lat,L_NSPECTV) ! to store the data set
    10490
    10591#ifdef CPP_PARA
    10692! Added to work in parallel mode
    10793      real dx3_glop(klon_glo,L_NSPECTV)
    108       real dx3_glo(iim,jjp1,L_NSPECTV) ! to store a global 3D data set
    109 #else
    110       logical,parameter :: is_master=.true.
    111       logical,parameter :: is_mpi_root=.true.
     94      real dx3_glo(nbp_lon,nbp_lat,L_NSPECTV) ! to store a global 3D data set
     95      real areafi_glo(klon_glo) ! mesh area on global physics grid
     96#else
     97      real areafi_glo(ngrid) ! mesh area on global physics grid
    11298#endif
    11399
     
    138124         endif
    139125
     126#ifdef CPP_PARA
     127          ! Gather airephy() mesh area on physics grid
     128          call Gather(airephy,areafi_glo)
     129#else
     130         areafi_glo(:)=airephy(:)
     131#endif
    140132         ! Create the NetCDF file
    141133         if (is_master) then
     
    158150         ierr = NF_ENDDEF(nid)
    159151
     152         ! Build area()
     153         do i=1,nbp_lon+1 ! poles
     154           ! divide at the poles by nbp_lon
     155           area(i,1)=areafi_glo(1)/nbp_lon
     156           area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
     157         enddo
     158         do j=2,nbp_lat-1
     159           ig0= 1+(j-2)*nbp_lon
     160           do i=1,nbp_lon
     161              area(i,j)=areafi_glo(ig0+i)
     162           enddo
     163           ! handle redundant point in longitude
     164           area(nbp_lon+1,j)=area(1,j)
     165         enddo
     166
    160167         ! write "header" of file (longitudes, latitudes, geopotential, ...)
    161 !         call gr_fi_dyn(1,ngrid,iip1,jjp1,phisfi,phis)
    162 !         call iniwrite(nid,day_ini,phis)
    163          call iniwrite_specVI(nid,day_ini)
     168         call iniwrite_specVI(nid,day_ini,area)
    164169         endif ! of if (is_master)
    165170
     
    215220             endif
    216221
    217              write(6,*)'WRITEDIAGSPEC: date= ', date
     222             write(6,*)'WRITEDIAGSPECVI: date= ', date
    218223           endif ! of if (is_master)
    219224        end if ! of if (nom.eq.firstnom)
     
    233238            call Grid1Dto2D_glo(dx3_glop,dx3_glo)
    234239            ! copy dx3_glo() to dx3(:) and add redundant longitude
    235             dx3(1:iim,:,:)=dx3_glo(1:iim,:,:)
    236             dx3(iip1,:,:)=dx3(1,:,:)
     240            dx3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
     241            dx3(nbp_lon+1,:,:)=dx3(1,:,:)
    237242          endif
    238243!$OMP END MASTER
     
    240245#else
    241246           DO l=1,L_NSPECTV
    242              DO i=1,iip1
     247             DO i=1,nbp_lon+1
    243248                dx3(i,1,l)=px(1,l)
    244                 dx3(i,jjp1,l)=px(ngrid,l)
     249                dx3(i,nbp_lat,l)=px(ngrid,l)
    245250             ENDDO
    246              DO j=2,jjm
    247                 ig0= 1+(j-2)*iim
    248                 DO i=1,iim
     251             DO j=2,nbp_lat-1
     252                ig0= 1+(j-2)*nbp_lon
     253                DO i=1,nbp_lon
    249254                   dx3(i,j,l)=px(ig0+i,l)
    250255                ENDDO
    251                 dx3(iip1,j,l)=dx3(1,j,l)
     256                dx3(nbp_lon+1,j,l)=dx3(1,j,l)
    252257             ENDDO
    253258           ENDDO
     
    279284           corner(4)=ntime
    280285
    281            edges(1)=iip1
    282            edges(2)=jjp1
     286           edges(1)=nbp_lon+1
     287           edges(2)=nbp_lat
    283288           edges(3)=L_NSPECTV
    284289           edges(4)=1
  • 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.