Changeset 1295


Ignore:
Timestamp:
Jun 13, 2014, 5:28:30 PM (11 years ago)
Author:
milmd
Message:

LMDZ.GENERIC. Diagnostics are done globally. They slightly differ from previous version because of some shorcuts. Correct a bug when using meanOLR option.

Location:
trunk/LMDZ.GENERIC/libf/phystd
Files:
4 edited

Legend:

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

    r787 r1295  
    55
    66       REAL,ALLOCATABLE,DIMENSION(:) :: long,lati,area
    7        REAL :: totarea
     7       REAL :: totarea, totarea_planet
    88
    99       end module comgeomfi_h
  • trunk/LMDZ.GENERIC/libf/phystd/inifis.F

    r1252 r1295  
    77      use datafile_mod, only: datadir
    88      use comdiurn_h, only: sinlat, coslat, sinlon, coslon
    9       use comgeomfi_h, only: long, lati, area, totarea
     9      use comgeomfi_h, only: long, lati, area, totarea, totarea_planet
    1010      use comsoil_h, only: ini_comsoil_h
    1111      use control_mod, only: ecritphy
     12      use planetwide_mod, only: planetwide_sumval
    1213
    1314!=======================================================================
     
    677678      CALL SCOPY(ngrid,parea,1,area,1)
    678679      totarea=SSUM(ngrid,area,1)
     680      call planetwide_sumval(area,totarea_planet)
    679681
    680682      !! those are defined in comdiurn_h.F90
  • trunk/LMDZ.GENERIC/libf/phystd/physiq.F90

    r1283 r1295  
    1919      use comsaison_h, only: mu0, fract, dist_star, declin
    2020      use comsoil_h, only: nsoilmx, layer, mlayer, inertiedat
    21       USE comgeomfi_h, only: long, lati, area, totarea
     21      USE comgeomfi_h, only: long, lati, area, totarea, totarea_planet
    2222      USE tracer_h, only: noms, mmol, radius, rho_q, qext, &
    2323                          alpha_lift, alpha_devil, qextrhor, &
     
    2626      use control_mod, only: ecritphy, iphysiq, nday
    2727      use phyredem, only: physdem0, physdem1
     28      use planetwide_mod, only: planetwide_minval,planetwide_maxval,planetwide_sumval
     29      use mod_phys_lmdz_para, only : is_master
    2830
    2931      implicit none
     
    338340      real madjdE(ngrid), lscaledE(ngrid),madjdEz(ngrid,nlayermx), lscaledEz(ngrid,nlayermx)
    339341!JL12 conservation test for mean flow kinetic energy has been disabled temporarily
     342      real dtmoist_max,dtmoist_min
    340343     
    341       real dItot, dVtot
     344      real dItot, dItot_tmp, dVtot, dVtot_tmp
    342345
    343346!     included by BC for evaporation     
     
    352355!     included by RW to test water conservation (by routine)
    353356      real h2otot
    354       real dWtot, dWtots
     357      real dWtot, dWtot_tmp, dWtots, dWtots_tmp
    355358      real h2o_surf_all
    356359      logical watertest
     
    914917! test energy conservation
    915918         if(enertest)then
    916             dEtotSW  = cpp*SUM(massarea(:,:)*zdtsw(:,:))/totarea
    917             dEtotLW  = cpp*SUM(massarea(:,:)*zdtlw(:,:))/totarea
    918             dEtotsSW = SUM(fluxsurf_sw(:)*(1.-albedo(:))*area(:))/totarea !JL13 carefull, albedo can have changed since the last time we called corrk
    919             dEtotsLW = SUM((fluxsurf_lw(:)*emis(:)-zplanck(:))*area(:))/totarea
     919            call planetwide_sumval(cpp*massarea(:,:)*zdtsw(:,:)/totarea_planet,dEtotSW)
     920            call planetwide_sumval(cpp*massarea(:,:)*zdtlw(:,:)/totarea_planet,dEtotLW)
     921            call planetwide_sumval(fluxsurf_sw(:)*(1.-albedo(:))*area(:)/totarea_planet,dEtotsSW) !JL13 carefull, albedo can have changed since the last time we called corrk
     922            call planetwide_sumval((fluxsurf_lw(:)*emis(:)-zplanck(:))*area(:)/totarea_planet,dEtotsLW)
    920923            dEzRadsw(:,:)=cpp*mass(:,:)*zdtsw(:,:)
    921924            dEzRadlw(:,:)=cpp*mass(:,:)*zdtlw(:,:)
    922             print*,'---------------------------------------------------------------'
    923             print*,'In corrk SW atmospheric heating       =',dEtotSW,' W m-2'
    924             print*,'In corrk LW atmospheric heating       =',dEtotLW,' W m-2'
    925             print*,'atmospheric net rad heating (SW+LW)   =',dEtotLW+dEtotSW,' W m-2'
    926             print*,'In corrk SW surface heating           =',dEtotsSW,' W m-2'
    927             print*,'In corrk LW surface heating           =',dEtotsLW,' W m-2'
    928             print*,'surface net rad heating (SW+LW)       =',dEtotsLW+dEtotsSW,' W m-2'
     925            if (is_master) then
     926                print*,'---------------------------------------------------------------'
     927                print*,'In corrk SW atmospheric heating       =',dEtotSW,' W m-2'
     928                print*,'In corrk LW atmospheric heating       =',dEtotLW,' W m-2'
     929                print*,'atmospheric net rad heating (SW+LW)   =',dEtotLW+dEtotSW,' W m-2'
     930                print*,'In corrk SW surface heating           =',dEtotsSW,' W m-2'
     931                print*,'In corrk LW surface heating           =',dEtotsLW,' W m-2'
     932                print*,'surface net rad heating (SW+LW)       =',dEtotsLW+dEtotsSW,' W m-2'
     933            endif
    929934         endif
    930935!-------------------------
     
    989994               dEzdiff(ig,1)= dEzdiff(ig,1)+ sensibFlux(ig)! subtract flux to the ground
    990995            enddo
    991             dEtot = SUM(dEdiff(:)*area(:))/totarea
     996            call planetwide_sumval(dEdiff(:)*area(:)/totarea_planet,dEtot)
    992997            dEdiffs(:)=capcal(:)*zdtsdif(:)-zflubid(:)-sensibFlux(:)
    993             dEtots = SUM(dEdiffs(:)*area(:))/totarea
    994             AtmToSurf_TurbFlux=SUM(sensibFlux(:)*area(:))/totarea
    995             if (UseTurbDiff) then
    996                print*,'In TurbDiff sensible flux (atm=>surf) =',AtmToSurf_TurbFlux,' W m-2'
    997                print*,'In TurbDiff non-cons atm nrj change   =',dEtot,' W m-2'
    998                print*,'In TurbDiff (correc rad+latent heat) surf nrj change =',dEtots,' W m-2'
    999             else
    1000                print*,'In vdifc sensible flux (atm=>surf)    =',AtmToSurf_TurbFlux,' W m-2'
    1001                print*,'In vdifc non-cons atm nrj change      =',dEtot,' W m-2'
    1002                print*,'In vdifc (correc rad+latent heat) surf nrj change =',dEtots,' W m-2'
    1003             end if
     998            call planetwide_sumval(dEdiffs(:)*area(:)/totarea_planet,dEtots)
     999            call planetwide_sumval(sensibFlux(:)*area(:)/totarea_planet,AtmToSurf_TurbFlux)
     1000            if (is_master) then
     1001             if (UseTurbDiff) then
     1002                print*,'In TurbDiff sensible flux (atm=>surf) =',AtmToSurf_TurbFlux,' W m-2'
     1003                print*,'In TurbDiff non-cons atm nrj change   =',dEtot,' W m-2'
     1004                print*,'In TurbDiff (correc rad+latent heat) surf nrj change =',dEtots,' W m-2'
     1005             else
     1006                print*,'In vdifc sensible flux (atm=>surf)    =',AtmToSurf_TurbFlux,' W m-2'
     1007                print*,'In vdifc non-cons atm nrj change      =',dEtot,' W m-2'
     1008                print*,'In vdifc (correc rad+latent heat) surf nrj change =',dEtots,' W m-2'
     1009             end if
     1010            endif ! of if (is_master)
    10041011! JL12 note that the black body radiative flux emitted by the surface has been updated by the implicit scheme
    10051012!    but not given back elsewhere
     
    10101017         ! test water conservation
    10111018         if(watertest.and.water)then
    1012             dWtot = SUM(massarea(:,:)*zdqdif(:,:,igcm_h2o_vap))*ptimestep/totarea
    1013             dWtots =  SUM(zdqsdif(:,igcm_h2o_vap)*area(:))*ptimestep/totarea
     1019            call planetwide_sumval(massarea(:,:)*zdqdif(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dWtot_tmp)
     1020            call planetwide_sumval(zdqsdif(:,igcm_h2o_vap)*area(:)*ptimestep/totarea_planet,dWtots_tmp)
    10141021            do ig = 1, ngrid
    10151022               vdifcncons(ig)=SUM(mass(ig,:)*zdqdif(ig,:,igcm_h2o_vap))
    10161023            Enddo
    1017             dWtot = dWtot + SUM(massarea(:,:)*zdqdif(:,:,igcm_h2o_ice))*ptimestep/totarea
    1018             dWtots = dWtots + SUM(zdqsdif(:,igcm_h2o_ice)*area(:))*ptimestep/totarea
     1024            call planetwide_sumval(massarea(:,:)*zdqdif(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
     1025            call planetwide_sumval(zdqsdif(:,igcm_h2o_ice)*area(:)*ptimestep/totarea_planet,dWtots)
     1026            dWtot = dWtot + dWtot_tmp
     1027            dWtots = dWtots + dWtots_tmp
    10191028            do ig = 1, ngrid
    10201029               vdifcncons(ig)=vdifcncons(ig) + SUM(mass(ig,:)*zdqdif(ig,:,igcm_h2o_ice))
    10211030            Enddo           
    1022             nconsMAX=MAXVAL(vdifcncons(:))
    1023 
    1024             print*,'---------------------------------------------------------------'
    1025             print*,'In difv atmospheric water change        =',dWtot,' kg m-2'
    1026             print*,'In difv surface water change            =',dWtots,' kg m-2'
    1027             print*,'In difv non-cons factor                 =',dWtot+dWtots,' kg m-2'
    1028             print*,'In difv MAX non-cons factor             =',nconsMAX,' kg m-2 s-1'
     1031            call planetwide_maxval(vdifcncons(:),nconsMAX)
     1032
     1033            if (is_master) then
     1034                print*,'---------------------------------------------------------------'
     1035                print*,'In difv atmospheric water change        =',dWtot,' kg m-2'
     1036                print*,'In difv surface water change            =',dWtots,' kg m-2'
     1037                print*,'In difv non-cons factor                 =',dWtot+dWtots,' kg m-2'
     1038                print*,'In difv MAX non-cons factor             =',nconsMAX,' kg m-2 s-1'
     1039            endif
    10291040
    10301041         endif
     
    10731084         ! test energy conservation
    10741085         if(enertest)then
    1075             dEtot=cpp*SUM(massarea(:,:)*zdtadj(:,:))/totarea
    1076           print*,'In convadj atmospheric energy change  =',dEtot,' W m-2'
     1086            call planetwide_sumval(cpp*massarea(:,:)*zdtadj(:,:)/totarea_planet,dEtot)
     1087            if (is_master) print*,'In convadj atmospheric energy change  =',dEtot,' W m-2'
    10771088         endif
    10781089         !-------------------------
     
    10811092         ! test water conservation
    10821093         if(watertest)then
    1083             dWtot = SUM(massarea(:,:)*zdqadj(:,:,igcm_h2o_vap))*ptimestep/totarea
     1094            call planetwide_sumval(massarea(:,:)*zdqadj(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dWtot_tmp)
    10841095            do ig = 1, ngrid
    10851096               cadjncons(ig)=SUM(mass(ig,:)*zdqadj(ig,:,igcm_h2o_vap))
    10861097            Enddo
    1087             dWtot = dWtot + SUM(massarea(:,:)*zdqadj(:,:,igcm_h2o_ice))*ptimestep/totarea
     1098            call planetwide_sumval(massarea(:,:)*zdqadj(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
     1099            dWtot = dWtot + dWtot_tmp
    10881100            do ig = 1, ngrid
    10891101               cadjncons(ig)=cadjncons(ig) + SUM(mass(ig,:)*zdqadj(ig,:,igcm_h2o_ice))
    10901102            Enddo           
    1091             nconsMAX=MAXVAL(cadjncons(:))
    1092 
    1093             print*,'In convadj atmospheric water change     =',dWtot,' kg m-2'
    1094             print*,'In convadj MAX non-cons factor          =',nconsMAX,' kg m-2 s-1'
     1103            call planetwide_maxval(cadjncons(:),nconsMAX)
     1104
     1105            if (is_master) then
     1106                print*,'In convadj atmospheric water change     =',dWtot,' kg m-2'
     1107                print*,'In convadj MAX non-cons factor          =',nconsMAX,' kg m-2 s-1'
     1108            endif
    10951109         endif
    10961110         !-------------------------
     
    11261140         ! test energy conservation
    11271141         if(enertest)then
    1128             dEtot = cpp*SUM(massarea(:,:)*zdtc(:,:))/totarea
    1129             dEtots = SUM(capcal(:)*zdtsurfc(:)*area(:))/totarea
    1130             print*,'In co2cloud atmospheric energy change   =',dEtot,' W m-2'
    1131             print*,'In co2cloud surface energy change       =',dEtots,' W m-2'
     1142            call planetwide_sumval(cpp*massarea(:,:)*zdtc(:,:)/totarea_planet,dEtot)
     1143            call planetwide_sumval(capcal(:)*zdtsurfc(:)*area(:)/totarea_planet,dEtots)
     1144            if (is_master) then
     1145                print*,'In co2cloud atmospheric energy change   =',dEtot,' W m-2'
     1146                print*,'In co2cloud surface energy change       =',dEtots,' W m-2'
     1147            endif
    11321148         endif
    11331149         !-------------------------
     
    11691185               ! test energy conservation
    11701186               if(enertest)then
    1171                   dEtot=cpp*SUM(massarea(:,:)*dtmoist(:,:))/totarea
     1187                  call planetwide_sumval(cpp*massarea(:,:)*dtmoist(:,:)/totarea_planet,dEtot)
     1188                  call planetwide_maxval(dtmoist(:,:),dtmoist_max)
     1189                  call planetwide_minval(dtmoist(:,:),dtmoist_min)
    11721190                  madjdEz(:,:)=cpp*mass(:,:)*dtmoist(:,:)
    11731191                  do ig=1,ngrid
    11741192                     madjdE(ig) = cpp*SUM(mass(:,:)*dtmoist(:,:))
    11751193                  enddo
    1176                   print*,'In moistadj atmospheric energy change   =',dEtot,' W m-2'
    1177                   print*,'In moistadj MAX atmospheric energy change   =',MAXVAL(dtmoist(:,:))*ptimestep,'K/step'
    1178                   print*,'In moistadj MIN atmospheric energy change   =',MINVAL(dtmoist(:,:))*ptimestep,'K/step'
     1194                  if (is_master) then
     1195                        print*,'In moistadj atmospheric energy change   =',dEtot,' W m-2'
     1196                        print*,'In moistadj MAX atmospheric energy change   =',dtmoist_max*ptimestep,'K/step'
     1197                        print*,'In moistadj MIN atmospheric energy change   =',dtmoist_min*ptimestep,'K/step'
     1198                  endif
    11791199                 
    11801200                ! test energy conservation
    1181                   dWtot = SUM(massarea(:,:)*dqmoist(:,:,igcm_h2o_vap))*ptimestep/totarea
    1182                   dWtot = dWtot + SUM(massarea(:,:)*dqmoist(:,:,igcm_h2o_ice))*ptimestep/totarea
    1183                   print*,'In moistadj atmospheric water change    =',dWtot,' kg m-2'
     1201                  call planetwide_sumval(massarea(:,:)*dqmoist(:,:,igcm_h2o_vap)*ptimestep/totarea_planet+      &
     1202                        massarea(:,:)*dqmoist(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
     1203                  if (is_master) print*,'In moistadj atmospheric water change    =',dWtot,' kg m-2'
    11841204               endif
    11851205               !-------------------------
     
    12021222                     lscaledE(ig) = cpp*SUM(mass(:,:)*dtlscale(:,:))
    12031223                  enddo
    1204                   dEtot=cpp*SUM(massarea(:,:)*(dtlscale(:,:)))/totarea
     1224                  call planetwide_sumval(cpp*massarea(:,:)*dtlscale(:,:)/totarea_planet,dEtot)
    12051225!                 if(isnan(dEtot)) then ! NB: isnan() is not a standard function...
    12061226!                    print*,'Nan in largescale, abort'
    12071227!                     STOP
    12081228!                 endif
    1209                   print*,'In largescale atmospheric energy change =',dEtot,' W m-2'
     1229                  if (is_master) print*,'In largescale atmospheric energy change =',dEtot,' W m-2'
    12101230
    12111231               ! test water conservation
    1212                   dWtot = SUM(massarea(:,:)*dqvaplscale(:,:))*ptimestep/totarea
    1213                   dWtot = dWtot + SUM(massarea(:,:)*dqcldlscale(:,:))*ptimestep/totarea
    1214                   print*,'In largescale atmospheric water change  =',dWtot,' kg m-2'
     1232                  call planetwide_sumval(massarea(:,:)*dqvaplscale(:,:)*ptimestep/totarea_planet+       &
     1233                        SUM(massarea(:,:)*dqcldlscale(:,:))*ptimestep/totarea_planet,dWtot)
     1234                  if (is_master) print*,'In largescale atmospheric water change  =',dWtot,' kg m-2'
    12151235               endif
    12161236               !-------------------------
     
    12501270               ! test energy conservation
    12511271               if(enertest)then
    1252                   dEtot=cpp*SUM(massarea(:,:)*zdtrain(:,:))/totarea
    1253                  print*,'In rain atmospheric T energy change       =',dEtot,' W m-2'
    1254                   dItot = SUM(massarea(:,:)*zdqrain(:,:,igcm_h2o_ice))/totarea*RLVTT/cpp
    1255                   dItot = dItot + SUM(area(:)*zdqssnow(:))/totarea*RLVTT/cpp
    1256                   dVtot = SUM(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap))*ptimestep/totarea
    1257                   dVtot = dVtot + SUM(area(:)*zdqsrain(:))/totarea*RLVTT/cpp
     1272                  call planetwide_sumval(cpp*massarea(:,:)*zdtrain(:,:)/totarea_planet,dEtot)
     1273                  if (is_master) print*,'In rain atmospheric T energy change       =',dEtot,' W m-2'
     1274                  call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_ice)/totarea_planet*RLVTT/cpp,dItot_tmp)
     1275                  call planetwide_sumval(area(:)*zdqssnow(:)/totarea_planet*RLVTT/cpp,dItot)
     1276                  dItot = dItot + dItot_tmp
     1277                  call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dVtot_tmp)
     1278                  call planetwide_sumval(area(:)*zdqsrain(:)/totarea_planet*RLVTT/cpp,dVtot)
     1279                  dVtot = dVtot + dVtot_tmp
    12581280                  dEtot = dItot + dVtot
    1259                  print*,'In rain dItot =',dItot,' W m-2'
    1260                  print*,'In rain dVtot =',dVtot,' W m-2'
    1261                  print*,'In rain atmospheric L energy change       =',dEtot,' W m-2'
     1281                  if (is_master) then
     1282                        print*,'In rain dItot =',dItot,' W m-2'
     1283                        print*,'In rain dVtot =',dVtot,' W m-2'
     1284                        print*,'In rain atmospheric L energy change       =',dEtot,' W m-2'
     1285                  endif
    12621286
    12631287               ! test water conservation
    1264                   dWtot = SUM(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap))*ptimestep/totarea
    1265                   dWtot = dWtot + SUM(massarea(:,:)*zdqrain(:,:,igcm_h2o_ice))*ptimestep/totarea
    1266                   dWtots =  SUM((zdqsrain(:)+zdqssnow(:))*area(:))*ptimestep/totarea
    1267                  print*,'In rain atmospheric water change        =',dWtot,' kg m-2'
    1268                  print*,'In rain surface water change            =',dWtots,' kg m-2'
    1269                  print*,'In rain non-cons factor                 =',dWtot+dWtots,' kg m-2'
     1288                  call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap)*ptimestep/totarea_planet+      &
     1289                        massarea(:,:)*zdqrain(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
     1290                  call planetwide_sumval((zdqsrain(:)+zdqssnow(:))*area(:)*ptimestep/totarea_planet,dWtots)
     1291                  if (is_master) then
     1292                        print*,'In rain atmospheric water change        =',dWtot,' kg m-2'
     1293                        print*,'In rain surface water change            =',dWtots,' kg m-2'
     1294                        print*,'In rain non-cons factor                 =',dWtot+dWtots,' kg m-2'
     1295                  endif
    12701296              endif
    12711297              !-------------------------
     
    12891315           if(watertest)then
    12901316              iq=igcm_h2o_ice
    1291               dWtot = SUM(massarea(:,:)*pq(:,:,iq))*ptimestep/totarea
    1292               dWtots = SUM(massarea(:,:)*pdq(:,:,iq))*ptimestep/totarea
    1293               print*,'Before sedim pq  =',dWtot,' kg m-2'
    1294               print*,'Before sedim pdq =',dWtots,' kg m-2'
     1317              call planetwide_sumval(massarea(:,:)*pq(:,:,iq)*ptimestep/totarea_planet,dWtot)
     1318              call planetwide_sumval(massarea(:,:)*pdq(:,:,iq)*ptimestep/totarea_planet,dWtots)
     1319              if (is_master) then
     1320                print*,'Before sedim pq  =',dWtot,' kg m-2'
     1321                print*,'Before sedim pdq =',dWtots,' kg m-2'
     1322              endif
    12951323           endif
    12961324           !-------------------------
     
    13031331           if(watertest)then
    13041332              iq=igcm_h2o_ice
    1305               dWtot = SUM(massarea(:,:)*pq(:,:,iq))*ptimestep/totarea
    1306               dWtots = SUM(massarea(:,:)*pdq(:,:,iq))*ptimestep/totarea
    1307               print*,'After sedim pq  =',dWtot,' kg m-2'
    1308               print*,'After sedim pdq =',dWtots,' kg m-2'
     1333              call planetwide_sumval(massarea(:,:)*pq(:,:,iq)*ptimestep/totarea_planet,dWtot)
     1334              call planetwide_sumval(massarea(:,:)*pdq(:,:,iq)*ptimestep/totarea_planet,dWtots)
     1335              if (is_master) then
     1336                print*,'After sedim pq  =',dWtot,' kg m-2'
     1337                print*,'After sedim pdq =',dWtots,' kg m-2'
     1338              endif
    13091339           endif
    13101340           !-------------------------
     
    13191349           ! test water conservation
    13201350           if(watertest)then
    1321               dWtot = SUM(massarea(:,:)*(zdqsed(:,:,igcm_h2o_vap)+zdqsed(:,:,igcm_h2o_ice)))*ptimestep/totarea
    1322               dWtots = SUM((zdqssed(:,igcm_h2o_vap)+zdqssed(:,igcm_h2o_ice))*area(:))*ptimestep/totarea
    1323               print*,'In sedim atmospheric ice change         =',dWtot,' kg m-2'
    1324               print*,'In sedim surface ice change             =',dWtots,' kg m-2'
    1325               print*,'In sedim non-cons factor                =',dWtot+dWtots,' kg m-2'
     1351              call planetwide_sumval(massarea(:,:)*(zdqsed(:,:,igcm_h2o_vap)+zdqsed(:,:,igcm_h2o_ice))*ptimestep/totarea_planet,dWtot)
     1352              call planetwide_sumval((zdqssed(:,igcm_h2o_vap)+zdqssed(:,igcm_h2o_ice))*area(:)*ptimestep/totarea_planet,dWtots)
     1353              if (is_master) then
     1354                print*,'In sedim atmospheric ice change         =',dWtot,' kg m-2'
     1355                print*,'In sedim surface ice change             =',dWtots,' kg m-2'
     1356                print*,'In sedim non-cons factor                =',dWtot+dWtots,' kg m-2'
     1357              endif
    13261358           endif
    13271359           !-------------------------
     
    13891421            ! test energy conservation
    13901422            if(enertest)then
    1391                dEtots = SUM(area(:)*capcal(:)*zdtsurf_hyd(:))/totarea
    1392               print*,'In hydrol surface energy change     =',dEtots,' W m-2'
     1423               call planetwide_sumval(area(:)*capcal(:)*zdtsurf_hyd(:)/totarea_planet,dEtots)
     1424               if (is_master) print*,'In hydrol surface energy change     =',dEtots,' W m-2'
    13931425            endif
    13941426            !-------------------------
     
    13971429            ! test water conservation
    13981430            if(watertest)then
    1399                dWtots =  SUM(dqs_hyd(:,igcm_h2o_ice)*area(:))*ptimestep/totarea
    1400                print*,'In hydrol surface ice change            =',dWtots,' kg m-2'
    1401                dWtots =  SUM(dqs_hyd(:,igcm_h2o_vap)*area(:))*ptimestep/totarea
    1402                print*,'In hydrol surface water change          =',dWtots,' kg m-2'
    1403                print*,'---------------------------------------------------------------'
     1431               call planetwide_sumval(dqs_hyd(:,igcm_h2o_ice)*area(:)*ptimestep/totarea_planet,dWtots)
     1432               if (is_master) print*,'In hydrol surface ice change            =',dWtots,' kg m-2'
     1433               call planetwide_sumval(dqs_hyd(:,igcm_h2o_vap)*area(:)*ptimestep/totarea_planet,dWtots)
     1434               if (is_master) then
     1435                print*,'In hydrol surface water change          =',dWtots,' kg m-2'
     1436                print*,'---------------------------------------------------------------'
     1437               endif
    14041438            endif
    14051439            !-------------------------
     
    14391473! test energy conservation
    14401474      if(enertest)then
    1441          dEtots = SUM(area(:)*capcal(:)*zdtsurf(:))/totarea
    1442         print*,'Surface energy change                 =',dEtots,' W m-2'
     1475         call planetwide_sumval(area(:)*capcal(:)*zdtsurf(:)/totarea_planet,dEtots)     
     1476         if (is_master) print*,'Surface energy change                 =',dEtots,' W m-2'
    14431477      endif
    14441478!-------------------------
     
    14871521!     ---------------------------------------------------------
    14881522
    1489       Ts1 = SUM(area(:)*tsurf(:))/totarea
    1490       Ts2 = MINVAL(tsurf(:))
    1491       Ts3 = MAXVAL(tsurf(:))
     1523      call planetwide_sumval(area(:)*tsurf(:)/totarea_planet,Ts1)
     1524      call planetwide_minval(tsurf(:),Ts2)
     1525      call planetwide_maxval(tsurf(:),Ts3)
    14921526      if(callsoil)then
    14931527         TsS = SUM(area(:)*tsoil(:,nsoilmx))/totarea        ! mean temperature at bottom soil layer
     
    14951529           print*,Ts1,Ts2,Ts3,TsS
    14961530      else
     1531        if (is_master) then
    14971532           print*,'  ave[Tsurf]     min[Tsurf]     max[Tsurf]'
    14981533           print*,Ts1,Ts2,Ts3
     1534        endif
    14991535      end if
    15001536
     
    15051541      if(corrk)then
    15061542
    1507          ISR = SUM(area(:)*fluxtop_dn(:))/totarea
    1508          ASR = SUM(area(:)*fluxabs_sw(:))/totarea
    1509          OLR = SUM(area(:)*fluxtop_lw(:))/totarea
    1510          GND = SUM(area(:)*fluxgrd(:))/totarea
    1511          DYN = SUM(area(:)*fluxdyn(:))/totarea
     1543         call planetwide_sumval(area(:)*fluxtop_dn(:)/totarea_planet,ISR)
     1544         call planetwide_sumval(area(:)*fluxabs_sw(:)/totarea_planet,ASR)
     1545         call planetwide_sumval(area(:)*fluxtop_lw(:)/totarea_planet,OLR)
     1546         call planetwide_sumval(area(:)*fluxgrd(:)/totarea_planet,GND)
     1547         call planetwide_sumval(area(:)*fluxdyn(:)/totarea_planet,DYN)
    15121548         do ig=1,ngrid
    15131549            if(fluxtop_dn(ig).lt.0.0)then
     
    15251561            DYN=0.0
    15261562         endif
    1527 
    1528          print*,'  ISR            ASR            OLR            GND            DYN [W m^-2]'
    1529          print*, ISR,ASR,OLR,GND,DYN
    1530 
    1531          if(enertest)then
     1563         
     1564         if (is_master) then
     1565                print*,'  ISR            ASR            OLR            GND            DYN [W m^-2]'
     1566                print*, ISR,ASR,OLR,GND,DYN
     1567         endif
     1568
     1569         if(enertest .and. is_master)then
    15321570            print*,'SW flux/heating difference SW++ - ASR = ',dEtotSW+dEtotsSW-ASR,' W m-2'
    15331571            print*,'LW flux/heating difference LW++ - OLR = ',dEtotLW+dEtotsLW+OLR,' W m-2'
     
    15351573         endif
    15361574
    1537          if(meanOLR)then
     1575         if(meanOLR .and. is_master)then
    15381576            if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then
    15391577               ! to record global radiative balance
     
    15421580               close(92)
    15431581               open(93,file="tem_bal.out",form='formatted',position='append')
    1544                write(93,*) zday,Ts1,Ts2,Ts3,TsS
     1582               if(callsoil)then
     1583                write(93,*) zday,Ts1,Ts2,Ts3,TsS
     1584               else
     1585                write(93,*) zday,Ts1,Ts2,Ts3
     1586               endif
    15451587               close(93)
    15461588            endif
     
    16001642      if(water)then
    16011643
    1602          icesrf = SUM(area(:)*qsurf_hist(:,igcm_h2o_ice))/totarea
    1603          liqsrf = SUM(area(:)*qsurf_hist(:,igcm_h2o_vap))/totarea
    1604          icecol = SUM(area(:)*qcol(:,igcm_h2o_ice))/totarea
    1605          vapcol = SUM(area(:)*qcol(:,igcm_h2o_vap))/totarea
     1644         call planetwide_sumval(area(:)*qsurf_hist(:,igcm_h2o_ice)/totarea_planet,icesrf)
     1645         call planetwide_sumval(area(:)*qsurf_hist(:,igcm_h2o_vap)/totarea_planet,liqsrf)
     1646         call planetwide_sumval(area(:)*qcol(:,igcm_h2o_ice)/totarea_planet,icecol)
     1647         call planetwide_sumval(area(:)*qcol(:,igcm_h2o_vap)/totarea_planet,vapcol)
    16061648
    16071649         h2otot = icesrf + liqsrf + icecol + vapcol
    1608 
    1609          print*,' Total water amount [kg m^-2]: ',h2otot
    1610          print*,' Surface ice    Surface liq.   Atmos. con.     Atmos. vap. [kg m^-2] '
    1611          print*, icesrf,liqsrf,icecol,vapcol
    1612 
    1613          if(meanOLR)then
     1650         
     1651         if (is_master) then
     1652                print*,' Total water amount [kg m^-2]: ',h2otot
     1653                print*,' Surface ice    Surface liq.   Atmos. con.     Atmos. vap. [kg m^-2] '
     1654                print*, icesrf,liqsrf,icecol,vapcol
     1655         endif
     1656
     1657         if(meanOLR .and. is_master)then
    16141658            if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then
    16151659               ! to record global water balance
  • trunk/LMDZ.GENERIC/libf/phystd/planetwide_mod.F90

    r1216 r1295  
    2020end interface
    2121
     22interface planetwide_sumval ! sum() , over the entire planet
     23  module procedure planetwide_sumval_i1, planetwide_sumval_i2, &
     24                   planetwide_sumval_r1, planetwide_sumval_r2
     25end interface
     26
    2227contains
    2328
     
    200205  end subroutine planetwide_minval_r2
    201206
    202 
     207!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     208
     209  subroutine planetwide_sumval_i1(values,values_sum)
     210  use dimphy, only: klon
     211  use mod_grid_phy_lmdz, only : klon_glo
     212  implicit none
     213  integer,intent(in) :: values(:) ! local grid (klon)
     214  integer,intent(out) :: values_sum
     215#ifdef CPP_PARA
     216  integer :: values_glo(klon_glo) ! global grid
     217 
     218  ! gather field on master:
     219  call gather(values,values_glo)
     220  ! calculate sum value
     221  if (is_master) then
     222    values_sum=SUM(values_glo(:))
     223  endif
     224  ! broadcast information to all cores
     225  call bcast(values_sum)
     226#else
     227  values_sum=SUM(values(:))
     228#endif
     229  end subroutine planetwide_sumval_i1
     230
     231  subroutine planetwide_sumval_i2(values,values_sum)
     232  use dimphy, only: klon, klev
     233  use mod_grid_phy_lmdz, only : klon_glo
     234  implicit none
     235  integer,intent(in) :: values(:,:) ! local grid (klon,klev)
     236  integer,intent(out) :: values_sum
     237#ifdef CPP_PARA
     238  integer :: values_glo(klon_glo,klev) ! global grid
     239 
     240  ! gather field on master:
     241  call gather(values,values_glo)
     242  ! calculate sum value
     243  if (is_master) then
     244    values_sum=SUM(values_glo)
     245  endif
     246  ! broadcast information to all cores
     247  call bcast(values_sum)
     248#else
     249  values_sum=SUM(values)
     250#endif
     251  end subroutine planetwide_sumval_i2
     252
     253  subroutine planetwide_sumval_r1(values,values_sum)
     254  use dimphy, only: klon
     255  use mod_grid_phy_lmdz, only : klon_glo
     256  implicit none
     257  real,intent(in) :: values(:) ! local grid (klon)
     258  real,intent(out) :: values_sum
     259#ifdef CPP_PARA
     260  real :: values_glo(klon_glo) ! global grid
     261 
     262  ! gather field on master:
     263  call gather(values,values_glo)
     264  ! calculate sum value
     265  if (is_master) then
     266    values_sum=SUM(values_glo)
     267  endif
     268  ! broadcast information to all cores
     269  call bcast(values_sum)
     270#else
     271  values_sum=SUM(values)
     272#endif
     273  end subroutine planetwide_sumval_r1
     274
     275  subroutine planetwide_sumval_r2(values,values_sum)
     276  use dimphy, only: klon, klev
     277  use mod_grid_phy_lmdz, only : klon_glo
     278  implicit none
     279  real,intent(in) :: values(:,:) ! local grid (klon,klev)
     280  real,intent(out) :: values_sum
     281#ifdef CPP_PARA
     282  real :: values_glo(klon_glo,klev) ! global grid
     283 
     284  ! gather field on master:
     285  call gather(values,values_glo)
     286  ! calculate sum value
     287  if (is_master) then
     288    values_sum=SUM(values_glo)
     289  endif
     290  ! broadcast information to all cores
     291  call bcast(values_sum)
     292#else
     293  values_sum=SUM(values)
     294#endif
     295  end subroutine planetwide_sumval_r2
     296 
     297 
    203298end module planetwide_mod
Note: See TracChangeset for help on using the changeset viewer.