Changeset 3522 for trunk


Ignore:
Timestamp:
Nov 15, 2024, 6:57:22 PM (8 days ago)
Author:
afalco
Message:

Generic PCM: imported write_output() subroutine from Mars PCM to write both diagfi and XIOS.

Still some bug on a few variables from generic condensation, to be checked.

AF

Location:
trunk
Files:
1 added
5 edited

Legend:

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

    r3397 r3522  
    22
    33implicit none
     4
     5real, save :: tab_cntrl_mod(100)
     6
     7!$OMP THREADPRIVATE(tab_cntrl_mod)
    48
    59contains
     
    5054  real,intent(out) :: emis(ngrid) ! surface emissivity
    5155  real,intent(out) :: albedo(ngrid,L_NSPECTV) ! albedo of the surface
    52   real,intent(out) :: q2(ngrid,nlayer+1) ! 
     56  real,intent(out) :: q2(ngrid,nlayer+1) !
    5357  real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
    5458! real co2ice(ngrid) ! co2 ice cover
    5559  real,intent(out) :: cloudfrac(ngrid,nlayer)
    5660  real,intent(out) :: hice(ngrid), totcloudfrac(ngrid)
    57   real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,nslay) 
     61  real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,nslay)
    5862  real,intent(out) :: tsea_ice(ngrid),sea_ice(ngrid)
    5963  real,intent(out) :: rnat(ngrid)
     
    7276      INTEGER nid, nvarid
    7377      INTEGER ierr, i, nsrf
    74 !      integer isoil 
     78!      integer isoil
    7579!      INTEGER length
    7680!      PARAMETER (length=100)
     
    8690      integer :: count
    8791      character(len=30) :: txt ! to store some text
    88      
     92
    8993      INTEGER :: indextime=1 ! index of selected time, default value=1
    9094      logical :: found
    91      
     95
    9296      character(len=8) :: modname="phyetat0"
    9397
     
    314318        else
    315319          rnat(ig)=1.
    316         endif     
     320        endif
    317321      enddo
    318322  endif ! of if (.not.found)
     
    434438endif ! of if (startphy_file)
    435439
    436 ! Non-orographic gravity waves 
     440! Non-orographic gravity waves
    437441if (startphy_file) then
    438442   call get_field("du_nonoro_gwd",du_nonoro_gwd,found,indextime)
     
    486490end subroutine phyetat0
    487491
     492!======================================================================
     493subroutine ini_tab_controle_dyn_xios(idayref)
     494
     495use comcstfi_mod,        only: g, mugaz, omeg, rad, rcp
     496use time_phylmdz_mod,  only: daysec, dtphys
     497use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat, nbp_lev
     498
     499implicit none
     500
     501integer*4, intent(in) :: idayref ! date (initial date for this run)
     502
     503integer :: length, l
     504parameter (length = 100)
     505real    :: tab_cntrl(length) ! run parameters are stored in this array
     506
     507do l = 1,length
     508    tab_cntrl(l) = 0.
     509enddo
     510tab_cntrl(1)  = real(nbp_lon)
     511tab_cntrl(2)  = real(nbp_lat-1)
     512tab_cntrl(3)  = real(nbp_lev)
     513tab_cntrl(4)  = real(idayref)
     514tab_cntrl(5)  = rad
     515tab_cntrl(6)  = omeg
     516tab_cntrl(7)  = g
     517tab_cntrl(8)  = mugaz
     518tab_cntrl(9)  = rcp
     519tab_cntrl(10) = daysec
     520tab_cntrl(11) = dtphys
     521
     522tab_cntrl_mod = tab_cntrl
     523
     524end subroutine ini_tab_controle_dyn_xios
     525
    488526end module phyetat0_mod
  • trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90

    r3437 r3522  
    3838                          igcm_co2_ice, nesp, is_chim, is_condensable,constants_epsi_generic
    3939      use time_phylmdz_mod, only: ecritphy, iphysiq, nday
    40       use phyetat0_mod, only: phyetat0
     40      use phyetat0_mod, only: phyetat0,tab_cntrl_mod
    4141      use surfini_mod, only: surfini
    4242      use wstats_mod, only: callstats, wstats, mkstats
     
    9090      use datafile_mod, only: datadir
    9191      use newton_cooling_hotJ, only: newtcool_MOCHA ! LT, adding for MOCHA protocol
    92      
     92
    9393#ifndef MESOSCALE
    94       use vertical_layers_mod, only: presnivs, pseudoalt
     94      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt
    9595      use mod_phys_lmdz_omp_data, ONLY: is_omp_master
    9696#else
     
    113113      use wxios, only: wxios_context_init, xios_context_finalize
    114114#endif
     115      use write_output_mod, only: write_output
    115116
    116117      implicit none
     
    315316      real zdtsdif(ngrid)     ! Turbdiff/vdifc routines.
    316317      real zdtsurf_hyd(ngrid) ! Hydrol routine.
    317      
     318
    318319      ! For Thermosphere : (K/s)
    319320      real zdtconduc(ngrid,nlayer)
     
    462463      real int_dtaui1(ngrid,nlayer,L_NSPECTI),int_dtauv1(ngrid,nlayer,L_NSPECTV) ! For optical thickness diagnostics.
    463464      real tf, ntf
    464      
     465
    465466      real net_fluxsurf_lw(ngrid) ! net longwave flux at the surface (for diagnostics only)
    466467
     
    468469
    469470      real muvar(ngrid,nlayer+1) ! For Runaway Greenhouse 1D study. By RW
    470      
     471
    471472      ! For fixed variable molar mass
    472473      real, dimension(:),allocatable,save :: p_var
     
    535536         zdtlw(:,:) = 0.0
    536537         zdtconduc(:,:) = 0.0
    537          
     538
    538539!        Initialize fixed variable mu
    539 !        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
     540!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    540541
    541542         if(varspec) then
     
    546547           mu_var = 0.0
    547548           frac_var = 0.0
    548            muvari = 0.0 
     549           muvari = 0.0
    549550           dt_file=TRIM(varspec_data)
    550551           open(33,file=dt_file,form='formatted',status='old',iostat=ios)
     
    557558             do k=1,nvarlayer
    558559               read(33,*) p_var(k), mu_var(k),frac_var(k,1:ngasmx)
    559                !The order of columns in frac_var must correspond to order of molecules gases.def 
     560               !The order of columns in frac_var must correspond to order of molecules gases.def
    560561               !The format of your file must be:
    561562               ! pressure(k) molar_mass(k), molar_fraction_of_gas_1(k), molar_fraction_of_gas_2(k),..., molar_fraction_of_gas_ngasmx(k)
     
    675676           call ocean_slab_get_vars(ngrid, tslab, tice, sea_ice, flux_g, &
    676677                      dt_hdiff, dt_ekman, dt_gm)
    677            
     678
    678679         endif ! end of 'ok_slab_ocean'.
    679680
     
    17231724               dqmoist(1:ngrid,1:nlayer,1:nq)=0.
    17241725               dtmoist(1:ngrid,1:nlayer)=0.
    1725                
     1726
    17261727               ! Moist Convective Adjustment.
    17271728               ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    17281729               call moistadj_generic(ngrid,nlayer,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
    1729            
     1730
    17301731               pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq)     &
    17311732                                                  + dqmoist(1:ngrid,1:nlayer,1:nq)
     
    17381739                  call planetwide_minval(dtmoist(:,:),dtmoist_min)
    17391740                  madjdEz(:,:)=cpp*mass(:,:)*dtmoist(:,:)
    1740                  
     1741
    17411742                  do ig=1,ngrid
    17421743                     madjdE(ig) = cpp*SUM(mass(:,:)*dtmoist(:,:))
    17431744                  enddo
    1744                  
     1745
    17451746                  if (is_master) then
    17461747                     print*,'In moistadj_generic atmospheric energy change   =',dEtot,' W m-2'
     
    17531754                                         massarea(:,:)*dqmoist(:,:,2)*ptimestep/totarea_planet,dWtot)
    17541755                  if (is_master) print*,'In moistadj_generic atmospheric GCS change    =',dWtot,' kg m-2'
    1755                
     1756
    17561757               endif ! end of 'enertest'
    17571758            else
     
    19971998                      tsea_ice, -zdqsdif(:,igcm_h2o_vap), taux, tauy, zmasq)
    19981999
    1999             call ocean_slab_frac(pctsrf_sic, zmasq) 
    2000              
     2000            call ocean_slab_frac(pctsrf_sic, zmasq)
     2001
    20012002            call ocean_slab_get_vars(ngrid, tslab, tice, sea_ice, flux_g, &
    20022003                      dt_hdiff, dt_ekman, dt_gm)
     
    20042005!!!            call ocean_slab_get_vars(ngrid, tslab, tsea_ice, sea_ice, flux_g, &
    20052006!!!                      dt_hdiff, dt_ekman, dt_gm)
    2006                      
     2007
    20072008!! sea_ice defines the sea ice thickness in kg/m2
    20082009!! pctsrf_sic defines the percentage of the oceanic grid that is covered by sea ice (between 0 and **almost** 1)
     
    23982399         if (ngrid.ne.1) then
    23992400            write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin
    2400            
     2401
    24012402            if (ok_slab_ocean) then
    24022403              ! fetch "ocean variables" to ensure they are stored
     
    25202521!-----------------------------------------------------------------------------------------------------
    25212522
    2522       call writediagfi(ngrid,"Ls","solar longitude","deg",0,zls*180./pi)
    2523       call writediagfi(ngrid,"Lss","sub solar longitude","deg",0,zlss*180./pi)
    2524       call writediagfi(ngrid,"RA","right ascension","deg",0,right_ascen*180./pi)
    2525       call writediagfi(ngrid,"Declin","solar declination","deg",0,declin*180./pi)
    2526       call writediagfi(ngrid,"tsurf","Surface temperature","K",2,tsurf)
    2527       call writediagfi(ngrid,"ps","Surface pressure","Pa",2,ps)
    2528       call writediagfi(ngrid,"temp","temperature","K",3,zt)
    2529       call writediagfi(ngrid,"teta","potential temperature","K",3,zh)
    2530       call writediagfi(ngrid,"u","Zonal wind","m.s-1",3,zu)
    2531       call writediagfi(ngrid,"v","Meridional wind","m.s-1",3,zv)
    2532       call writediagfi(ngrid,"w","Vertical wind","m.s-1",3,pw)
    2533       call writediagfi(ngrid,"p","Pressure","Pa",3,pplay)
     2523      call write_output("Ls","solar longitude","deg",zls*180./pi)
     2524      call write_output("Lss","sub solar longitude","deg",zlss*180./pi)
     2525      call write_output("RA","right ascension","deg",right_ascen*180./pi)
     2526      call write_output("Declin","solar declination","deg",declin*180./pi)
     2527      call write_output("dist_star","dist_star","AU",dist_star)
     2528
     2529      call write_output("tsurf","Surface temperature","K",tsurf)
     2530      call write_output("ps","Surface pressure","Pa",ps)
     2531      call write_output("emis","Emissivity","",emis)
     2532      call write_output("temperature","temperature","K",zt)
     2533      call write_output("teta","potential temperature","K",zh)
     2534      call write_output("u","Zonal wind","m.s-1",zu)
     2535      call write_output("v","Meridional wind","m.s-1",zv)
     2536      call write_output("w","Vertical wind","m.s-1",pw)
     2537      call write_output("p","Pressure","Pa",pplay)
     2538      call write_output("omega","omega","Pa/s",omega)
    25342539
    25352540!     Subsurface temperatures
    25362541!        call writediagsoil(ngrid,"tsurf","Surface temperature","K",2,tsurf)
    2537 !        call writediagsoil(ngrid,"temp","temperature","K",3,tsoil)
    25382542
    25392543      ! Oceanic layers
    25402544      if(ok_slab_ocean) then
    2541          call writediagfi(ngrid,"pctsrf_sic","pct ice/sea","",2,pctsrf_sic)
    2542          call writediagfi(ngrid,"tsea_ice","top layer temp, snow/ice","K",2,tsea_ice)
    2543 !         call writediagfi(ngrid,"tice","sea ice temperature","K",2,tice)
    2544          call writediagfi(ngrid,"sea_ice","sea ice","kg/m2",2,sea_ice)
    2545          call writediagfi(ngrid,"tslab1","tslab1","K",2,tslab(:,1))
    2546          call writediagfi(ngrid,"tslab2","tslab2","K",2,tslab(:,2))
    2547          call writediagfi(ngrid,"dt_hdiff1","dt_hdiff1","W m-2",2,dt_hdiff(:,1))
    2548          call writediagfi(ngrid,"dt_hdiff2","dt_hdiff2","W m-2",2,dt_hdiff(:,2))
    2549          call writediagfi(ngrid,"dt_ekman1","dt_ekman1","W m-2",2,dt_ekman(:,1))
    2550          call writediagfi(ngrid,"dt_ekman2","dt_ekman2","W m-2",2,dt_ekman(:,2))
    2551          call writediagfi(ngrid,"dt_gm1","dt_gm1","W m-2",2,dt_gm(:,1))
    2552          call writediagfi(ngrid,"dt_gm2","dt_gm2","W m-2",2,dt_gm(:,2))
    2553          call writediagfi(ngrid,"rnat","nature of the surface","",2,rnat)
    2554          call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux)
    2555          call writediagfi(ngrid,"latentFlux","latent heat flux","w.m^-2",2,zdqsdif(:,igcm_h2o_vap)*RLVTT)
     2545         call write_output("pctsrf_sic","pct ice/sea","",pctsrf_sic)
     2546         call write_output("tsea_ice","top layer temp, snow/ice","K",tsea_ice)
     2547!         call write_output("tice","sea ice temperature","K",tice)
     2548         call write_output("sea_ice","sea ice","kg/m2",sea_ice)
     2549         call write_output("tslab1","tslab1","K",tslab(:,1))
     2550         call write_output("tslab2","tslab2","K",tslab(:,2))
     2551         call write_output("dt_hdiff1","dt_hdiff1","W m-2",dt_hdiff(:,1))
     2552         call write_output("dt_hdiff2","dt_hdiff2","W m-2",dt_hdiff(:,2))
     2553         call write_output("dt_ekman1","dt_ekman1","W m-2",dt_ekman(:,1))
     2554         call write_output("dt_ekman2","dt_ekman2","W m-2",dt_ekman(:,2))
     2555         call write_output("dt_gm1","dt_gm1","W m-2",dt_gm(:,1))
     2556         call write_output("dt_gm2","dt_gm2","W m-2",dt_gm(:,2))
     2557         call write_output("rnat","nature of the surface","",rnat)
     2558         call write_output("sensibFlux","sensible heat flux","w.m^-2",sensibFlux)
     2559         call write_output("latentFlux","latent heat flux","w.m^-2",zdqsdif(:,igcm_h2o_vap)*RLVTT)
    25562560      endif
    25572561
    25582562      ! Thermal plume model
    25592563      if (calltherm) then
    2560          call writediagfi(ngrid,'entr','Entrainment','kg m$^{-2}$ s$^{-1}$', 3, entr)
    2561          call writediagfi(ngrid,'detr','Detrainment','kg m$^{-2}$ s$^{-1}$', 3, detr)
    2562          call writediagfi(ngrid,'fm','Mass flux','kg m$^{-2}$ s$^{-1}$', 3, fm_bis)
    2563          call writediagfi(ngrid,'w_plm','Squared vertical velocity','m s$^{-1}$', 3, zw2_bis)
    2564          call writediagfi(ngrid,'fraca','Updraft fraction','', 3, fraca)
    2565          call writediagfi(ngrid,"zdttherm","dt due to plumes","K-1 s-1",3,zdttherm) !ALS24
     2564         call write_output('entr','Entrainment','kg m$^{-2}$ s$^{-1}$', entr)
     2565         call write_output('detr','Detrainment','kg m$^{-2}$ s$^{-1}$', detr)
     2566         call write_output('fm','Mass flux','kg m$^{-2}$ s$^{-1}$', fm_bis)
     2567         call write_output('w_plm','Squared vertical velocity','m s$^{-1}$', zw2_bis)
     2568         call write_output('fraca','Updraft fraction','', fraca)
     2569         call write_output("zdttherm","dt due to plumes","K-1 s-1",zdttherm) !ALS24
    25662570         IF (tracer) THEN
    2567             call writediagfi(ngrid,"zdqtherm","dq due to plumes, iq = 1","kg kg-1 s-1",3, &
     2571            call write_output("zdqtherm","dq due to plumes, iq = 1","kg kg-1 s-1",&
    25682572                   zdqtherm(1:ngrid,1:nlayer,1)) !ALS24
    2569             call writediagfi(ngrid,"zdqtherm2","dq due to plumes; iq = 2","kg kg-1 s-1",3, &
     2573            call write_output("zdqtherm2","dq due to plumes; iq = 2","kg kg-1 s-1",&
    25702574                   zdqtherm(1:ngrid,1:nlayer,2)) !ALS24
    25712575         ENDIF
     
    25742578!        GW non-oro outputs
    25752579      if (calllott_nonoro) then
    2576          call WRITEDIAGFI(ngrid,"dugwno","GW non-oro dU","m/s2", 3,d_u_hin)
    2577          call WRITEDIAGFI(ngrid,"dvgwno","GW non-oro dV","m/s2", 3,d_v_hin)
     2580         call write_output("dugwno","GW non-oro dU","m/s2", d_u_hin)
     2581         call write_output("dvgwno","GW non-oro dV","m/s2", d_v_hin)
    25782582      endif
    25792583
     
    25812585      if(callrad.and.(.not.newtonian))then
    25822586
    2583          call writediagfi(ngrid,"ALB","Surface albedo"," ",2,albedo_equivalent)
    2584          !call writediagfi(ngrid,"ALB_1st","First Band Surface albedo"," ",2,albedo(:,1))
    2585          call writediagfi(ngrid,"ISR","incoming stellar rad.","W m-2",2,fluxtop_dn)
    2586          call writediagfi(ngrid,"ASR","absorbed stellar rad.","W m-2",2,fluxabs_sw)
    2587          call writediagfi(ngrid,"OLR","outgoing longwave rad.","W m-2",2,fluxtop_lw)
    2588          call writediagfi(ngrid,"shad","rings"," ", 2, fract)
    2589 
     2587         call write_output("ALB","Surface albedo"," ",albedo_equivalent)
     2588         call write_output("ASR","absorbed stellar rad.","W m-2",fluxabs_sw)
     2589         call write_output("ISR","incoming stellar rad.","W m-2",fluxtop_dn)
     2590         call write_output("OLR","outgoing longwave rad.","W m-2",fluxtop_lw)
     2591         call write_output("DYN","dynamical heat input","W m-2",fluxdyn)
     2592         call write_output("shad","rings"," ", fract)
    25902593!           call writediagfi(ngrid,"ASRcs","absorbed stellar rad (cs).","W m-2",2,fluxabs_sw1)
    25912594!           call writediagfi(ngrid,"OLRcs","outgoing longwave rad (cs).","W m-2",2,fluxtop_lw1)
     
    25972600
    25982601         if(ok_slab_ocean) then
    2599             call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrdocean)
     2602            call write_output("GND","heat flux from ground","W m-2",fluxgrdocean)
    26002603         else
    2601             call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrd)
    2602          endif
    2603 
    2604          call writediagfi(ngrid,"DYN","dynamical heat input","W m-2",2,fluxdyn)
    2605 
     2604            call write_output("GND","heat flux from ground","W m-2",fluxgrd)
     2605         endif
    26062606      endif ! end of 'callrad'
    26072607
     
    26092609
    26102610         if (calldifv) then
    2611 
    2612             call writediagfi(ngrid,"q2","turbulent kinetic energy","J.kg^-1",3,q2)
    2613             call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux)
    2614 
     2611            call write_output("q2","turbulent kinetic energy","J.kg^-1",q2)
     2612            call write_output("sensibFlux","sensible heat flux","w.m^-2",sensibFlux)
    26152613!             call writediagfi(ngrid,"dEzdiff","turbulent diffusion heating (-sensible flux)","w.m^-2",3,dEzdiff)
    26162614!             call writediagfi(ngrid,"dEdiff","integrated turbulent diffusion heating (-sensible flux)","w.m^-2",2,dEdiff)
    26172615!             call writediagfi(ngrid,"dEdiffs","In TurbDiff (correc rad+latent heat) surf nrj change","w.m^-2",2,dEdiffs)
    2618 
    26192616         endif
    26202617
    26212618         if (corrk) then
    2622             call writediagfi(ngrid,"dEzradsw","radiative heating","w.m^-2",3,dEzradsw)
    2623             call writediagfi(ngrid,"dEzradlw","radiative heating","w.m^-2",3,dEzradlw)
     2619            call write_output("dEzradsw","radiative heating","w.m^-2",dEzradsw)
     2620            call write_output("dEzradlw","radiative heating","w.m^-2",dEzradlw)
    26242621         endif
    26252622
    26262623         if(watercond) then
    2627 
    2628             call writediagfi(ngrid,"lscaledE","heat from largescale","W m-2",2,lscaledE)
     2624            call write_output("lscaledE","heat from largescale","W m-2",lscaledE)
    26292625            if ((.not.calltherm).and.moistadjustment) then
    2630                call writediagfi(ngrid,"madjdE","heat from moistadj","W m-2",2,madjdE)
     2626               call write_output("madjdE","heat from moistadj","W m-2",madjdE)
    26312627            endif
    2632             call writediagfi(ngrid,"qsatatm","atm qsat"," ",3,qsat)
    2633 
    2634 !            call writediagfi(ngrid,"lscaledEz","heat from largescale","W m-2",3,lscaledEz)
    2635 !            call writediagfi(ngrid,"madjdEz","heat from moistadj","W m-2",3,madjdEz)
    2636 !             call writediagfi(ngrid,"h2o_max_col","maximum H2O column amount","kg.m^-2",2,H2Omaxcol)
    2637 
     2628            call write_output("qsatatm","atm qsat"," ",qsat)
     2629!            call write_output("lscaledEz","heat from largescale","W m-2",lscaledEz)
     2630!            call write_output("madjdEz","heat from moistadj","W m-2",madjdEz)
     2631!            call write_output("h2o_max_col","maximum H2O column amount","kg.m^-2",H2Omaxcol)
    26382632         endif
    26392633
    26402634         if (generic_condensation) then
    2641 
    2642             call writediagfi(ngrid,"genericconddE","heat from generic condensation","W m-2",2,genericconddE)
    2643             call writediagfi(ngrid,"dt_generic_condensation","heating from generic condensation","K s-1",3,dt_generic_condensation)
    2644 
     2635            call write_output("genericconddE","heat from generic condensation","W m-2",genericconddE)
     2636            call write_output("dt_generic_condensation","heating from generic condensation","K s-1",dt_generic_condensation)
    26452637         endif
    26462638
     
    26522644          do nw=1,L_NSPECTV
    26532645            write(str2,'(i2.2)') nw
    2654             call writediagfi(ngrid,'dtauv'//str2,'Layer optical thickness attenuation in VI band '//str2,'',1,int_dtauv(:,nlayer:1:-1,nw))
     2646            call write_output('dtauv'//str2,'Layer optical thickness attenuation in VI band '//str2,'',int_dtauv(:,nlayer:1:-1,nw))
    26552647          enddo
    26562648          do nw=1,L_NSPECTI
    26572649            write(str2,'(i2.2)') nw
    2658             call writediagfi(ngrid,'dtaui'//str2,'Layer optical thickness attenuation in IR band '//str2,'',1,int_dtaui(:,nlayer:1:-1,nw))
     2650            call write_output('dtaui'//str2,'Layer optical thickness attenuation in IR band '//str2,'',int_dtaui(:,nlayer:1:-1,nw))
    26592651          enddo
    26602652        endif
    26612653
    2662 
    26632654        ! Temporary inclusions for heating diagnostics.
    2664         call writediagfi(ngrid,"zdtsw","SW heating","T s-1",3,zdtsw)
    2665         call writediagfi(ngrid,"zdtlw","LW heating","T s-1",3,zdtlw)
    2666         call writediagfi(ngrid,"dtrad","radiative heating","K s-1",3,dtrad)
    2667         call writediagfi(ngrid,"zdtdyn","Dyn. heating","T s-1",3,zdtdyn)
    2668 
    2669         if (tracer .or. water) call writediagfi(ngrid,"dtmoistadj","moist adj heating","K s-1",3,dtmoist)
    2670         if (calladj) call writediagfi(ngrid,"dtdryadj","dry adj heating","K s-1",3,zdtadj)
     2655         call write_output("zdtsw","SW heating","T s-1",zdtsw)
     2656         call write_output("zdtlw","LW heating","T s-1",zdtlw)
     2657         call write_output("dtrad","radiative heating","K s-1",dtrad)
     2658         call write_output("zdtdyn","Dyn. heating","T s-1",zdtdyn)
     2659
     2660        if (tracer .or. water) call write_output("dtmoistadj","moist adj heating","K s-1",dtmoist)
     2661        if (calladj) call write_output("dtdryadj","dry adj heating","K s-1",zdtadj)
    26712662
    26722663        ! For Debugging.
     
    26772668      ! Output aerosols.
    26782669      if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) &
    2679          call writediagfi(ngrid,'CO2ice_reff','CO2ice_reff','m',3,reffrad(1,1,iaero_co2))
     2670         call write_output('CO2ice_reff','CO2ice_reff','m',reffrad(1,1,iaero_co2))
    26802671      if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) &
    2681          call writediagfi(ngrid,'H2Oice_reff','H2Oice_reff','m',3,reffrad(:,:,iaero_h2o))
     2672         call write_output('H2Oice_reff','H2Oice_reff','m',reffrad(:,:,iaero_h2o))
    26822673      if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) &
    2683          call writediagfi(ngrid,'CO2ice_reffcol','CO2ice_reffcol','um kg m^-2',2,reffcol(1,iaero_co2))
     2674         call write_output('CO2ice_reffcol','CO2ice_reffcol','um kg m^-2',reffcol(1,iaero_co2))
    26842675      if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) &
    2685          call writediagfi(ngrid,'H2Oice_reffcol','H2Oice_reffcol','um kg m^-2',2,reffcol(1,iaero_h2o))
     2676         call write_output('H2Oice_reffcol','H2Oice_reffcol','um kg m^-2',reffcol(1,iaero_h2o))
    26862677
    26872678      ! Output tracers.
     
    26892680
    26902681         do iq=1,nq
    2691             call writediagfi(ngrid,noms(iq),noms(iq),'kg/kg',3,zq(1,1,iq))
    2692             call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
    2693                              'kg m^-2',2,qsurf_hist(1,iq) )
    2694             call writediagfi(ngrid,trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
    2695                             'kg m^-2',2,qcol(1,iq) )
    2696 !          call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
    2697 !                          'kg m^-2',2,qsurf(1,iq) )
     2682            call write_output(noms(iq),noms(iq),'kg/kg',zq(:,:,iq))
     2683            call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
     2684                            'kg m^-2',qsurf_hist(1,iq) )
     2685            call write_output(trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
     2686                           'kg m^-2',qcol(:,iq) )
     2687            ! call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
     2688            !              'kg m^-2',qsurf(:,iq) )
    26982689
    26992690            if(watercond.or.CLFvarying)then
    2700                call writediagfi(ngrid,"rneb_man","H2O cloud fraction (conv)"," ",3,rneb_man)
    2701                call writediagfi(ngrid,"rneb_lsc","H2O cloud fraction (large scale)"," ",3,rneb_lsc)
    2702                call writediagfi(ngrid,"CLF","H2O cloud fraction"," ",3,cloudfrac)
    2703                call writediagfi(ngrid,"CLFt","H2O column cloud fraction"," ",2,totcloudfrac)
    2704                call writediagfi(ngrid,"RH","relative humidity"," ",3,RH)
    2705                call writediagfi(ngrid,"vteta","virtual potential temperature","K",3,zh * (1.+(1./epsi-1.) * &
     2691               call write_output("rneb_man","H2O cloud fraction (conv)"," ",rneb_man)
     2692               call write_output("rneb_lsc","H2O cloud fraction (large scale)"," ",rneb_lsc)
     2693               call write_output("CLF","H2O cloud fraction"," ",cloudfrac)
     2694               call write_output("CLFt","H2O column cloud fraction"," ",totcloudfrac)
     2695               call write_output("RH","relative humidity"," ",RH)
     2696               call write_output("vteta","virtual potential temperature","K",zh * (1.+(1./epsi-1.) * &
    27062697                       zq(1:ngrid,1:nlayer,1)))
    27072698            endif
    27082699
    27092700            if(waterrain)then
    2710                call writediagfi(ngrid,"rain","rainfall","kg m-2 s-1",2,zdqsrain)
    2711                call writediagfi(ngrid,"snow","snowfall","kg m-2 s-1",2,zdqssnow)
    2712                call writediagfi(ngrid,"reevap","reevaporation of precipitation","kg m-2 s-1",2,reevap_precip)
     2701               call write_output("rain","rainfall","kg m-2 s-1",zdqsrain)
     2702               call write_output("snow","snowfall","kg m-2 s-1",zdqssnow)
     2703               call write_output("reevap","reevaporation of precipitation","kg m-2 s-1",reevap_precip)
    27132704            endif
    27142705
    27152706            if(generic_condensation)then
     2707               call write_output("CLF","GCS cloud fraction"," ",cloudfrac)
     2708               !AF24: TODO fix rneb_generic and RH_generic failure with write_output()
     2709               ! call write_output("rneb_generic","GCS cloud fraction (generic condensation)"," ",rneb_generic)
     2710               ! call write_output("RH_generic","GCS relative humidity"," ",RH_generic)
    27162711               call writediagfi(ngrid,"rneb_generic","GCS cloud fraction (generic condensation)"," ",3,rneb_generic)
    2717                call writediagfi(ngrid,"CLF","GCS cloud fraction"," ",3,cloudfrac)
    27182712               call writediagfi(ngrid,"RH_generic","GCS relative humidity"," ",3,RH_generic)
    2719                call writediagfi(ngrid,"vteta","virtual potential temperature","K",3,zh * (1.+(1./epsi_generic-1.) * &
     2713               call write_output("vteta","virtual potential temperature","K",zh * (1.+(1./epsi_generic-1.) * &
    27202714                       zq(1:ngrid,1:nlayer,1) ))
    27212715            endif
    27222716
    27232717            if(generic_rain)then
    2724                call writediagfi(ngrid,"rain","generic rainfall","kg m-2 s-1",2,zdqsrain_generic)
    2725                call writediagfi(ngrid,"snow","generic snowfall","kg m-2 s-1",2,zdqssnow_generic)
    2726                call writediagfi(ngrid,"reevap","generic reevaporation of precipitation","kg m-2 s-1",2,reevap_precip_generic)
     2718               call write_output("rain","generic rainfall","kg m-2 s-1",zdqsrain_generic)
     2719               call write_output("snow","generic snowfall","kg m-2 s-1",zdqssnow_generic)
     2720               call write_output("reevap","generic reevaporation of precipitation","kg m-2 s-1",reevap_precip_generic)
    27272721            endif
    27282722
    27292723            if((hydrology).and.(.not.ok_slab_ocean))then
    2730                call writediagfi(ngrid,"hice","oceanic ice height","m",2,hice)
     2724               call write_output("hice","oceanic ice height","m",hice)
    27312725            endif
    27322726
    2733             call writediagfi(ngrid,"tau_col","Total aerosol optical depth","[]",2,tau_col)
    2734 
     2727            call write_output("tau_col","Total aerosol optical depth","[]",tau_col)
    27352728         enddo ! end of 'nq' loop
    2736 
    27372729       endif ! end of 'tracer'
    2738 
    27392730
    27402731      ! Output spectrum.
     
    28352826      ! Send fields to XIOS: (NB these fields must also be defined as
    28362827      ! <field id="..." /> in context_lmdz_physics.xml to be correctly used)
    2837       CALL send_xios_field("ls",zls)
    2838 
    2839       CALL send_xios_field("ps",ps)
    2840       CALL send_xios_field("area",cell_area)
    2841       CALL send_xios_field("p",pplay)
    2842       CALL send_xios_field("temperature",zt)
    2843       CALL send_xios_field("u",zu)
    2844       CALL send_xios_field("v",zv)
    2845       CALL send_xios_field("omega",omega)
    2846 
    2847       IF (calltherm) THEN
    2848          CALL send_xios_field('w_plm',zw2_bis)
    2849          CALL send_xios_field('entr',entr)
    2850          CALL send_xios_field('detr',detr)
    2851 !         CALL send_xios_field('fm',fm_bis)
    2852 !         CALL send_xios_field('fraca',fraca)
    2853       ENDIF
     2828      CALL send_xios_field("controle",tab_cntrl_mod,1)
     2829
     2830      CALL send_xios_field("ap",ap,1)
     2831      CALL send_xios_field("bp",bp,1)
     2832      CALL send_xios_field("aps",aps,1)
     2833      CALL send_xios_field("bps",bps,1)
    28542834
    28552835      IF (water) THEN
    2856          CALL send_xios_field('h2o_vap',zq(:,:,igcm_h2o_vap))
    2857          CALL send_xios_field('h2o_ice',zq(:,:,igcm_h2o_ice))
    2858 
    28592836         CALL send_xios_field('h2o_layer1',zq(:,1,igcm_h2o_vap))
    28602837         CALL send_xios_field('co2_layer1',zq(:,1,igcm_co2_ice))
    2861          CALL send_xios_field('tsurf',tsurf)
    2862          CALL send_xios_field('co2ice',qsurf(1:ngrid,igcm_co2_ice))
    2863          CALL send_xios_field('h2o_ice_s',qsurf(1:ngrid,igcm_h2o_ice))
    28642838      ENDIF
    2865 
    2866       CALL send_xios_field("ISR",fluxtop_dn)
    2867       CALL send_xios_field("OLR",fluxtop_lw)
    2868       CALL send_xios_field("ASR",fluxabs_sw)
    28692839
    28702840      if (specOLR .and. corrk) then
  • trunk/LMDZ.GENERIC/libf/phystd/writediagsoil.F90

    r1543 r3522  
     1module writediagsoil_mod
     2
     3implicit none
     4
     5contains
     6
    17subroutine writediagsoil(ngrid,name,title,units,dimpx,px)
    28
     
    8692    stop
    8793  endif
    88  
     94
    8995  ! Set output sample rate
    9096  isample=int(ecritphy) ! same as for diagfi outputs
    9197  ! Note ecritphy is known from control.h
    92  
     98
    9399  ! Create output NetCDF file
    94100  if (is_master) then
     
    129135    enddo
    130136   endif
    131    
     137
    132138   ! write "header" of file (longitudes, latitudes, geopotential, ...)
    133139   if (klon_glo>1) then ! general 3D case
     
    138144
    139145  endif ! of if (is_master)
    140  
     146
    141147  ! set zitau to -1 to be compatible with zitau incrementation step below
    142148  zitau=-1
    143  
     149
    144150else
    145151  ! If not an initialization call, simply open the NetCDF file
     
    164170    date=float(zitau+1)/float(day_step)
    165171    ! Note: day_step is known from control.h
    166    
     172
    167173    if (is_master) then
    168174     ! Get NetCDF ID for "time"
     
    176182     if (ierr.ne.NF_NOERR) then
    177183      write(*,*)"writediagsoil: Failed writing date to time variable"
    178       stop 
     184      stop
    179185     endif
    180186    endif ! of if (is_master)
     
    217223  endif
    218224#endif
    219  
     225
    220226  ! B. Write (append) the variable to the NetCDF file
    221227  if (is_master) then
     
    235241    call def_var(nid,name,title,units,4,id,varid,ierr)
    236242  endif ! of if (ierr.ne.NF_NOERR)
    237  
     243
    238244  ! B.2. Prepare things to be able to write/append the variable
    239245  corners(1)=1
     
    241247  corners(3)=1
    242248  corners(4)=ntime
    243  
     249
    244250  if (klon_glo==1) then
    245251    edges(1)=1
     
    250256  edges(3)=nsoilmx
    251257  edges(4)=1
    252  
     258
    253259  ! B.3. Write the slab of data
    254260!#ifdef NC_DOUBLE
     
    324330  corners(2)=1
    325331  corners(3)=ntime
    326  
     332
    327333  if (klon_glo==1) then
    328334    edges(1)=1
     
    332338  edges(2)=nbp_lat
    333339  edges(3)=1
    334  
     340
    335341  ! B.3. Write the slab of data
    336342!#ifdef NC_DOUBLE
     
    373379  ! B.2. Prepare things to be able to write/append the variable
    374380  corners(1)=ntime
    375  
     381
    376382  edges(1)=1
    377383
     
    396402
    397403end subroutine writediagsoil
     404
     405end module writediagsoil_mod
  • trunk/LMDZ.GENERIC/libf/phystd/xios_output_mod.F90

    r2735 r3522  
    22
    33 IMPLICIT NONE
    4  
     4
    55 INTEGER,PRIVATE,SAVE :: time_it=0 ! store number of iterations with calls to XIOS since start
    66! does not need to be threadprivate; managed by omp master
    77
    88 CHARACTER(LEN=*), PARAMETER :: context_id= "LMDZ" ! same as in context_lmdz_physics.xml
    9  
     9
    1010#ifdef CPP_XIOS
    1111
    1212 INTERFACE send_xios_field
    13     MODULE PROCEDURE histwrite0d_xios,histwrite2d_xios,histwrite3d_xios!,histwrite1d_xios
     13    MODULE PROCEDURE histwrite0d_xios,histwrite1d_xios,histwrite2d_xios,histwrite3d_xios
    1414 END INTERFACE
    15  
     15
    1616
    1717CONTAINS
     
    3636  USE wxios, ONLY: wxios_domain_param, wxios_domain_param_unstructured, wxios_closedef
    3737  IMPLICIT NONE
    38  
     38
    3939  REAL,INTENT(IN) :: day ! Number of elapsed sols since reference Ls=0.
    4040  REAL,INTENT(IN) :: timeofday ! "Universal time", given as fraction of sol (e.g.: 0.5 for noon).
     
    4646  REAL,INTENT(IN) :: wnoi(:) ! Array of wavenumbers at the spectral interval centers for the infrared.
    4747  real,intent(in) :: wnov (:) !Array of wavenumbers at the spectral interval centers for the visible.
    48  
     48
    4949  INTEGER :: data_ibegin, data_iend
    5050  TYPE(xios_duration) :: timestep
    5151  TYPE(xios_date) :: time_origin
    5252  TYPE(xios_date) :: start_date
    53  
     53
    5454!$OMP BARRIER
    5555!$OMP MASTER
     
    7474!    IF (mpi_rank == 0) THEN
    7575!        data_ibegin = 0
    76 !    ELSE 
     76!    ELSE
    7777!        data_ibegin = ii_begin - 1
    7878!    END IF
     
    129129    !NB: it would make more sense to define months and their length in the
    130130    ! xml files and not to have them hard coded here.... to be improved...
    131    
     131
    132132    ! time origin of the simulation (default: 1st year/1st month/1st day, Ls=0)
    133133    time_origin=xios_date(1,1,1,0,0,0)
     
    151151!$OMP END MASTER
    152152!$OMP BARRIER
    153  
     153
    154154  END SUBROUTINE initialize_xios_output
    155155
     
    159159  USE xios
    160160  IMPLICIT NONE
    161 !$OMP BARRIER   
     161!$OMP BARRIER
    162162!$OMP MASTER
    163163    CALL xios_context_finalize
    164 !$OMP END MASTER   
    165 !$OMP BARRIER   
    166  
     164!$OMP END MASTER
     165!$OMP BARRIER
     166
    167167  END SUBROUTINE finalize_xios_output
    168168
     
    176176    time_it=time_it+1
    177177    CALL xios_update_calendar(time_it)
    178 !$OMP END MASTER   
     178!$OMP END MASTER
    179179  END SUBROUTINE update_xios_timestep
    180180
     
    189189    CALL xios_get_handle(context_id,ctx_hdl)
    190190    CALL xios_set_current_context(ctx_hdl)
    191 !$OMP END MASTER   
     191!$OMP END MASTER
    192192  END SUBROUTINE set_xios_context
    193193
     
    198198  USE print_control_mod, ONLY: prt_level, lunout
    199199  IMPLICIT NONE
    200  
     200
    201201    CHARACTER(LEN=*), INTENT(IN) :: field_name
    202202    REAL, INTENT(IN) :: field
    203    
     203
    204204    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite0d_xios ',trim(field_name)
    205    
     205
    206206!$OMP MASTER
    207207    CALL xios_send_field(field_name,field)
    208208!$OMP END MASTER
    209    
     209
    210210    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite0d_xios ',trim(field_name)
    211    
     211
    212212  END SUBROUTINE histwrite0d_xios
     213
     214!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     215
     216  SUBROUTINE histwrite1d_xios(field_name,field,dimens)
     217  USE xios, ONLY: xios_send_field
     218  USE print_control_mod, ONLY: prt_level, lunout
     219  IMPLICIT NONE
     220
     221    CHARACTER(LEN=*), INTENT(IN) :: field_name
     222    REAL, DIMENSION(:), INTENT(IN) :: field
     223    INTEGER, INTENT(IN) :: dimens
     224    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite1d_xios ',trim(field_name)
     225!$OMP MASTER
     226    CALL xios_send_field(field_name,field)
     227!$OMP END MASTER
     228
     229    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite1d_xios ',trim(field_name)
     230
     231  END SUBROUTINE histwrite1d_xios
    213232
    214233!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
    226245    CHARACTER(LEN=*), INTENT(IN) :: field_name
    227246    REAL, DIMENSION(:), INTENT(IN) :: field
    228      
     247
    229248    REAL,DIMENSION(klon_mpi) :: buffer_omp
    230249    REAL :: Field2d(nbp_lon,jj_nb)
    231250
    232251    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite2d_xios ',trim(field_name)
    233     if ((size(field) .eq. L_NSPECTI) .or. (size(field) .eq. L_NSPECTV)) then 
    234 !$OMP MASTER 
     252    if ((size(field) .eq. L_NSPECTI) .or. (size(field) .eq. L_NSPECTV)) then
     253!$OMP MASTER
    235254      ! only for spectral stuff: IR_Bandwidth and VI_Bandwidth
    236255      call xios_send_field(field_name,field)
     
    239258    endif
    240259    IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
    241    
    242     CALL Gather_omp(field,buffer_omp)   
     260
     261    CALL Gather_omp(field,buffer_omp)
    243262!$OMP MASTER
    244263    CALL grid1Dto2D_mpi(buffer_omp,Field2d)
    245    
     264
    246265    CALL xios_send_field(field_name, Field2d)
    247 !$OMP END MASTER   
     266!$OMP END MASTER
    248267
    249268    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite2d_xios ',trim(field_name)
     
    281300
    282301    CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
    283 !$OMP END MASTER   
     302!$OMP END MASTER
    284303
    285304    IF (prt_level >= 10) write(lunout,*)'End histrwrite3d_xios ',trim(field_name)
  • trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90

    r3508 r3522  
    23902390         call write_output("w","Vertical wind","m.s-1",pw)
    23912391         call write_output("p","Pressure","Pa",pplay)
     2392         call write_output("omega","omega","Pa/s",omega)
    23922393      endif
    23932394
     
    24502451            ! call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
    24512452         !                    'kg m^-2',qsurf_hist(1,iq) )
    2452            call write_output(trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
     2453            call write_output(trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
    24532454                           'kg m^-2',qcol(:,iq) )
    24542455            call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
Note: See TracChangeset for help on using the changeset viewer.