<p><b>duda</b> 2012-03-19 20:01:44 -0600 (Mon, 19 Mar 2012)</p><p>BRANCH COMMIT<br>
<br>
Merge trunk changes into io branch.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/omp_blocks/io/Makefile
===================================================================
--- branches/omp_blocks/io/Makefile        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/Makefile        2012-03-20 02:01:44 UTC (rev 1679)
@@ -14,10 +14,10 @@
dummy:
-        ( make error )
+        ( $(MAKE) error )
xlf:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = mpxlf90" \
        "CC_PARALLEL = mpcc" \
        "FC_SERIAL = xlf90" \
@@ -35,7 +35,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
ftn:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = ftn" \
        "CC_PARALLEL = cc" \
        "FC_SERIAL = ftn" \
@@ -50,7 +50,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pgi:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = mpif90" \
        "CC_PARALLEL = mpicc" \
        "FC_SERIAL = pgf90" \
@@ -68,7 +68,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pgi-nersc:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = ftn" \
        "CC_PARALLEL = cc" \
        "FC_SERIAL = ftn" \
@@ -83,7 +83,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pgi-llnl:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = mpipgf90" \
        "CC_PARALLEL = pgcc" \
        "FC_SERIAL = pgf90" \
@@ -98,7 +98,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
ifort:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = mpif90" \
        "CC_PARALLEL = gcc" \
        "FC_SERIAL = ifort" \
@@ -116,7 +116,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
gfortran:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = mpif90" \
        "CC_PARALLEL = mpicc" \
        "FC_SERIAL = gfortran" \
@@ -134,7 +134,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
g95:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = mpif90" \
        "CC_PARALLEL = mpicc" \
        "FC_SERIAL = g95" \
@@ -149,7 +149,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pathscale-nersc:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = ftn" \
        "CC_PARALLEL = cc" \
        "FC_SERIAL = ftn" \
@@ -164,7 +164,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
cray-nersc:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = ftn" \
        "CC_PARALLEL = cc" \
        "FC_SERIAL = ftn" \
@@ -179,7 +179,7 @@
        "CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
intel-nersc:
-        ( make all \
+        ( $(MAKE) all \
        "FC_PARALLEL = ftn" \
        "CC_PARALLEL = cc" \
        "FC_SERIAL = ftn" \
@@ -231,7 +231,7 @@
        DEBUG_MESSAGE="Debug flags are not defined for this compile group. Defaulting to Optimized flags"
else # FFLAGS_DEBUG IF
        FFLAGS=$(FFLAGS_DEBUG)
-        CFLAGS=$(CFLAGS_DEBUG)
+        CFLAGS=$(CFLAGS_DEBUG) -DMPAS_DEBUG
        LDFLAGS=$(LDFLAGS_DEBUG)
        DEBUG_MESSAGE="Debugging is on."
endif # FFLAGS_DEBUG IF
@@ -267,10 +267,14 @@
        PAPI_MESSAGE="Papi libraries are off."
endif # USE_PAPI IF
+ifneq ($(wildcard $(NETCDF)/lib/libnetcdff.*), ) # CHECK FOR NETCDF4
+        LIBS += -lnetcdff
+endif # CHECK FOR NETCDF4
+
all: mpas_main
mpas_main:
-        cd src; make FC="$(FC)" \
+        cd src; $(MAKE) -j1 FC="$(FC)" \
CC="$(CC)" \
SFC="$(SFC)" \
SCC="$(SCC)" \
@@ -290,7 +294,7 @@
        @echo $(SERIAL_MESSAGE)
        @echo $(PAPI_MESSAGE)
clean:
-        cd src; make clean RM="$(RM)" CORE="$(CORE)"
+        cd src; $(MAKE) clean RM="$(RM)" CORE="$(CORE)"
        $(RM) $(CORE)_model.exe
error: errmsg
@@ -308,7 +312,7 @@
errmsg:
        @echo ""
-        @echo "Usage: make target CORE=[core] [options]"
+        @echo "Usage: $(MAKE) target CORE=[core] [options]"
        @echo ""
        @echo "Example targets:"
        @echo " ifort"
Modified: branches/omp_blocks/io/namelist.input.ocean
===================================================================
--- branches/omp_blocks/io/namelist.input.ocean        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/namelist.input.ocean        2012-03-20 02:01:44 UTC (rev 1679)
@@ -1,6 +1,6 @@
&sw_model
config_test_case = 0
- config_time_integration = 'RK4'
+ config_time_integration = 'split_explicit'
config_rk_filter_btr_mode = .false.
config_dt = 100.0
config_start_time = '0000-01-01_00:00:00'
@@ -82,9 +82,8 @@
&advection
config_vert_tracer_adv = 'stencil'
config_vert_tracer_adv_order = 2
- config_tracer_adv_order = 2
+ config_horiz_tracer_adv_order = 2
config_thickness_adv_order = 2
- config_positive_definite = .false.
config_monotonic = .false.
/
&restore
Modified: branches/omp_blocks/io/src/Makefile
===================================================================
--- branches/omp_blocks/io/src/Makefile        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/Makefile        2012-03-20 02:01:44 UTC (rev 1679)
@@ -6,35 +6,35 @@
        $(FC) $(LDFLAGS) -o $(CORE)_model.exe driver/*.o -L. -ldycore -lops -lframework $(LIBS) -I./external/esmf_time_f90 -L./external/esmf_time_f90 -lesmf_time
reg_includes:
-        ( cd registry; make CC="$(SCC)" )
+        ( cd registry; $(MAKE) CC="$(SCC)" )
        ( cd inc; $(CPP) ../core_$(CORE)/Registry | ../registry/parse > Registry.processed)
-externals:
-        ( cd external; make FC="$(FC)" SFC="$(SFC)" CC="$(CC)" SCC="$(SCC)" FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" NETCDF="$(NETCDF)" CORE="$(CORE)" )
+externals: reg_includes
+        ( cd external; $(MAKE) FC="$(FC)" SFC="$(SFC)" CC="$(CC)" SCC="$(SCC)" FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" NETCDF="$(NETCDF)" CORE="$(CORE)" )
-frame:
-        ( cd framework; make all )
+frame: reg_includes externals
+        ( cd framework; $(MAKE) all )
        ln -sf framework/libframework.a libframework.a
-ops:
-        ( cd operators; make all )
+ops: reg_includes externals frame
+        ( cd operators; $(MAKE) all )
        ln -sf operators/libops.a libops.a
-dycore:
-        ( cd core_$(CORE); make all )
+dycore: reg_includes externals frame ops
+        ( cd core_$(CORE); $(MAKE) all )
        ln -sf core_$(CORE)/libdycore.a libdycore.a
-drver:
-        ( cd driver; make all )
+drver: reg_includes externals frame ops dycore
+        ( cd driver; $(MAKE) all )
clean:
        $(RM) $(CORE)_model.exe libframework.a libops.a libdycore.a
-        ( cd registry; make clean )
-        ( cd external; make clean )
-        ( cd framework; make clean )
-        ( cd operators; make clean )
+        ( cd registry; $(MAKE) clean )
+        ( cd external; $(MAKE) clean )
+        ( cd framework; $(MAKE) clean )
+        ( cd operators; $(MAKE) clean )
        ( cd inc; rm -f *.inc Registry.processed )
        if [ -d core_$(CORE) ] ; then \
-         ( cd core_$(CORE); make clean ) \
+         ( cd core_$(CORE); $(MAKE) clean ) \
        fi;
-        ( cd driver; make clean )
+        ( cd driver; $(MAKE) clean )
Modified: branches/omp_blocks/io/src/core_atmos_physics/Makefile
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/Makefile        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/Makefile        2012-03-20 02:01:44 UTC (rev 1679)
@@ -194,23 +194,28 @@
        mpas_atmphys_vars.o
mpas_atmphys_driver_microphysics.o: \
-        ./physics_wrf/module_mp_kessler.o \
-        ./physics_wrf/module_mp_thompson.o \
-        ./physics_wrf/module_mp_wsm6.o \
+        ./physics_wrf/module_mp_kessler.o \
+        ./physics_wrf/module_mp_thompson.o \
+        ./physics_wrf/module_mp_wsm6.o \
        mpas_atmphys_constants.o \
        mpas_atmphys_interface_nhyd.o \
        mpas_atmphys_vars.o
mpas_atmphys_driver.o: \
-        mpas_atmphys_driver_convection_deep.o \
-        mpas_atmphys_driver_pbl.o \
-        mpas_atmphys_driver_radiation_lw.o \
-        mpas_atmphys_driver_radiation_sw.o \
-        mpas_atmphys_driver_sfclayer.o \
-        mpas_atmphys_constants.o \
-        mpas_atmphys_interface_nhyd.o \
+        mpas_atmphys_driver_convection_deep.o \
+        mpas_atmphys_driver_pbl.o \
+        mpas_atmphys_driver_radiation_lw.o \
+        mpas_atmphys_driver_radiation_sw.o \
+        mpas_atmphys_driver_sfclayer.o \
+        mpas_atmphys_constants.o \
+        mpas_atmphys_interface_nhyd.o \
+        mpas_atmphys_update.o \
        mpas_atmphys_vars.o
+mpas_atmphys_update.o: \
+        mpas_atmphys_driver_convection_deep.o \
+        mpas_atmphys_vars.o
+
endif
clean:
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_date_time.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_date_time.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_date_time.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -96,9 +96,9 @@
!---------------------------------------------------------------------------------------------
- write(0,*)
- write(0,*) '--- enter subroutine monthly_interp_to_date:'
- write(0,*) '--- current_date = ',date_str
+!write(0,*)
+!write(0,*) '--- enter subroutine monthly_interp_to_date:'
+!write(0,*) '--- current_date = ',date_str
write(day15,fmt='(I2.2)') 15
do l = 1 , 12
@@ -116,8 +116,8 @@
call get_julgmt(date_str,target_julyr,target_julday,gmt)
target_date = target_julyr * 1000 + target_julday
- write(0,*) '--- target_julday =',target_julday
- write(0,*) '--- target_date =',target_date
+!write(0,*) '--- target_julday =',target_julday
+!write(0,*) '--- target_date =',target_date
find_month : do l = 0 , 12
if((middle(l) .lt. target_date) .and. (middle(l+1) .ge. target_date)) then
@@ -131,8 +131,8 @@
month2 = month1 + 1
endif
if(n == 1) then
- write(0,*) '--- month1 =',month1
- write(0,*) '--- month2 =',month2
+! write(0,*) '--- month1 =',month1
+! write(0,*) '--- month2 =',month2
endif
field_out(n) = ( field_in(month2,n) * (target_date - middle(l)) &
+ field_in(month1,n) * (middle(l+1) - target_date)) &
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -11,6 +11,7 @@
use mpas_atmphys_driver_radiation_lw
use mpas_atmphys_driver_sfclayer
use mpas_atmphys_constants
+ use mpas_atmphys_update
use mpas_atmphys_vars
#ifdef non_hydrostatic_core
use mpas_atmphys_interface_nhyd
@@ -80,16 +81,21 @@
!call to long wave radiation scheme:
if(l_radtlw) then
call allocate_radiation_lw(xtime_s)
- call driver_radiation_lw(itimestep,block%mesh,block%state%time_levs(1)%state, &
- block%diag_physics,block%sfc_input,block%tend_physics, &
- xtime_s)
+ call driver_radiation_lw(xtime_s,block%mesh,block%state%time_levs(1)%state, &
+ block%diag_physics,block%sfc_input,block%tend_physics)
endif
+ if(l_camlw .and. config_radt_lw_scheme .eq. 'cam_lw') &
+ call radiation_camlw_to_MPAS(block%diag_physics)
+ !call to accumulate long- and short-wave diagnostics if needed:
+ if(config_bucket_update /= 'none' .and. config_bucket_radt .gt. 0._RKIND) &
+ call update_radiation_diagnostics(config_bucket_radt,block%mesh,block%diag_physics)
+
!deallocate all radiation arrays:
if(config_radt_sw_scheme.ne.'off' .or. config_radt_lw_scheme.ne.'off') &
call deallocate_cloudiness
if(config_radt_sw_scheme.ne.'off') call deallocate_radiation_sw
- if(config_radt_lw_scheme.ne.'off') call deallocate_radiation_lw(xtime_s)
+ if(config_radt_lw_scheme.ne.'off') call deallocate_radiation_lw
!call to surface-layer scheme:
if(config_sfclayer_scheme .ne. 'off') then
@@ -118,6 +124,9 @@
call driver_convection_deep(itimestep,block%mesh,block%sfc_input,block%diag_physics, &
block%tend_physics)
call deallocate_convection_deep
+
+ !update diagnostics:
+ call update_convection_deep(config_bucket_rainc,block%mesh,block%diag_physics)
endif
!deallocate arrays shared by all physics parameterizations:
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_convection_deep.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -413,12 +413,12 @@
end subroutine convection_to_MPAS
!=============================================================================================
- subroutine update_convection_deep(dt_dyn,mesh,diag_physics)
+ subroutine update_convection_deep(bucket_rainc,mesh,diag_physics)
!=============================================================================================
!input arguments:
type(mesh_type),intent(in):: mesh
- real(kind=RKIND),intent(in):: dt_dyn
+ real(kind=RKIND),intent(in):: bucket_rainc
!inout arguments:
type(diag_physics_type),intent(inout):: diag_physics
@@ -427,11 +427,19 @@
integer:: iCell
!---------------------------------------------------------------------------------------------
-
-!update the accumuluted precipitation rate at the end of each dynamic time-step:
- do iCell = 1, mesh % nCells
+
+!update the accumulated precipitation at the end of each dynamic time-step:
+ do iCell = 1, mesh % nCellsSolve
diag_physics % rainc % array(iCell) = diag_physics % rainc % array(iCell) &
+ diag_physics % cuprec % array(iCell) * dt_dyn
+
+ if(l_acrain .and. bucket_rainc.gt.0._RKIND .and. &
+ diag_physics%rainc%array(iCell).gt.bucket_rainc) then
+ diag_physics % i_rainc % array(iCell) = diag_physics % i_rainc % array(iCell) + 1
+ diag_physics % rainc % array(iCell) = diag_physics % rainc % array(iCell) &
+ - bucket_rainc
+ endif
+
enddo
end subroutine update_convection_deep
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_microphysics.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -296,7 +296,7 @@
!... copy updated precipitation from the wrf-physics grid back to the geodesic-dynamics grid:
- call precip_to_MPAS(diag_physics)
+ call precip_to_MPAS(config_bucket_rainnc,diag_physics)
!... copy updated cloud microphysics variables from the wrf-physics grid back to the geodesic-
! dynamics grid:
@@ -374,10 +374,11 @@
end subroutine precip_from_MPAS
!=============================================================================================
- subroutine precip_to_MPAS(diag_physics)
+ subroutine precip_to_MPAS(bucket_rainnc,diag_physics)
!=============================================================================================
!output variables:
+ real(kind=RKIND),intent(in):: bucket_rainnc
type(diag_physics_type),intent(inout):: diag_physics
!local variables:
@@ -396,7 +397,13 @@
!accumulated precipitation:
diag_physics % rainnc % array(i) = diag_physics % rainnc % array(i) &
+ diag_physics % rainncv % array(i)
-
+
+ if(l_acrain .and. bucket_rainnc.gt.0._RKIND .and. &
+ diag_physics%rainnc%array(i).gt.bucket_rainnc) then
+ diag_physics % i_rainnc % array(i) = diag_physics % i_rainnc % array(i) + 1
+ diag_physics % rainnc % array(i) = diag_physics % rainnc % array(i) - bucket_rainnc
+ endif
+
enddo
enddo
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_driver_radiation_lw.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -20,7 +20,8 @@
public:: allocate_radiation_lw, &
deallocate_radiation_lw, &
driver_radiation_lw, &
- init_radiation_lw
+ init_radiation_lw, &
+ radiation_camlw_to_MPAS
integer,private:: i,j,k,n
@@ -101,17 +102,11 @@
!allocate these arrays on the first time step, only:
if(xtime_s .lt. 1.e-12) then
-
- write(0,*)
- write(0,*) '--- end subroutine allocate_radiation_lw:'
- write(0,*) '--- allocate emstot_p,abstot_p,absnxt_p'
-
if(.not.allocated(emstot_p) ) allocate(emstot_p(ims:ime,kms:kme,jms:jme) )
if(.not.allocated(abstot_p) ) &
allocate(abstot_p(ims:ime,kms:kme,cam_abs_dim2,jms:jme) )
if(.not.allocated(absnxt_p) ) &
allocate(absnxt_p(ims:ime,kms:kme,cam_abs_dim1,jms:jme) )
-
endif
case default
@@ -121,14 +116,9 @@
end subroutine allocate_radiation_lw
!=============================================================================================
- subroutine deallocate_radiation_lw(xtime_s)
+ subroutine deallocate_radiation_lw
!=============================================================================================
-!input arguments:
- real(kind=RKIND),intent(in):: xtime_s
-
-!---------------------------------------------------------------------------------------------
-
if(allocated(f_ice) ) deallocate(f_ice )
if(allocated(f_rain) ) deallocate(f_rain )
if(allocated(sfc_emiss_p) ) deallocate(sfc_emiss_p )
@@ -196,7 +186,7 @@
end subroutine deallocate_radiation_lw
!=============================================================================================
- subroutine radiation_lw_from_MPAS(mesh,state,diag_physics,sfc_input,xtime_s)
+ subroutine radiation_lw_from_MPAS(xtime_s,mesh,state,diag_physics,sfc_input)
!=============================================================================================
!input arguments:
@@ -301,30 +291,30 @@
enddo
enddo
+ !On the first time-step of each model run, the local arrays absnxt_p, absnst_p,
+ !and emstot_p are filled with the MPAS arrays abstot, absnxt, and emstot. If it
+ !is a new run, these three arrays will be initialized to zero;If a restart run,
+ !these three arrays will be filled with the restart values.
call mpas_timer_start("CAM lw: fill arrays for infrared absorption")
if(xtime_s .lt. 1.e-12) then
- write(0,*)
- write(0,*) '--- radiation_lw_from_MPAS:'
- write(0,*) '--- initialize emstot_p,abstot_p,absnxt_p'
- !infrared absorption:
do j = jts,jte
do n = 1,cam_abs_dim1
do k = kts,kte
do i = its,ite
- absnxt_p(i,k,n,j) = 0.
+ absnxt_p(i,k,n,j) = diag_physics % absnxt % array(k,n,i)
enddo
enddo
enddo
do n = 1,cam_abs_dim2
do k = kts,kte+1
do i = its,ite
- abstot_p(i,k,n,j) = 0.
+ abstot_p(i,k,n,j) = diag_physics % abstot % array(k,n,i)
enddo
enddo
enddo
do k = kts,kte+1
do i = its,ite
- emstot_p(i,k,j) = 0.
+ emstot_p(i,k,j) = diag_physics % emstot % array(k,i)
enddo
enddo
enddo
@@ -377,40 +367,29 @@
end subroutine radiation_lw_from_MPAS
!=============================================================================================
- subroutine radiation_lw_to_MPAS(diag_physics,tend_physics,xtime_s)
+ subroutine radiation_lw_to_MPAS(diag_physics,tend_physics)
!=============================================================================================
!input arguments:
type(diag_physics_type),intent(inout):: diag_physics
type(tend_physics_type),intent(inout):: tend_physics
- real(kind=RKIND),intent(in):: xtime_s
-
!---------------------------------------------------------------------------------------------
do j = jts,jte
do i = its,ite
- diag_physics % glw % array(i) = glw_p(i,j)
- diag_physics % lwcf % array(i) = lwcf_p(i,j)
- diag_physics % lwdnb % array(i) = lwdnb_p(i,j)
- diag_physics % lwdnbc % array(i) = lwdnbc_p(i,j)
- diag_physics % lwdnt % array(i) = lwdnt_p(i,j)
- diag_physics % lwdntc % array(i) = lwdntc_p(i,j)
- diag_physics % lwupb % array(i) = lwupb_p(i,j)
- diag_physics % lwupbc % array(i) = lwupbc_p(i,j)
- diag_physics % lwupt % array(i) = lwupt_p(i,j)
- diag_physics % lwuptc % array(i) = lwuptc_p(i,j)
- diag_physics % olrtoa % array(i) = olrtoa_p(i,j)
+ diag_physics % glw % array(i) = glw_p(i,j)
+ diag_physics % lwcf % array(i) = lwcf_p(i,j)
+ diag_physics % lwdnb % array(i) = lwdnb_p(i,j)
+ diag_physics % lwdnbc % array(i) = lwdnbc_p(i,j)
+ diag_physics % lwdnt % array(i) = lwdnt_p(i,j)
+ diag_physics % lwdntc % array(i) = lwdntc_p(i,j)
+ diag_physics % lwupb % array(i) = lwupb_p(i,j)
+ diag_physics % lwupbc % array(i) = lwupbc_p(i,j)
+ diag_physics % lwupt % array(i) = lwupt_p(i,j)
+ diag_physics % lwuptc % array(i) = lwuptc_p(i,j)
+ diag_physics % olrtoa % array(i) = olrtoa_p(i,j)
enddo
-!not needed:
-!do k = kts,kte+2
-!do i = its,ite
-! diag_physics % lwdnflx % array(k,i) = lwdnflx_p(i,k,j)
-! diag_physics % lwdnflxc % array(k,i) = lwdnflxc_p(i,k,j)
-! diag_physics % lwupflx % array(k,i) = lwupflx_p(i,k,j)
-! diag_physics % lwupflxc % array(k,i) = lwupflxc_p(i,k,j)
-!enddo
-!enddo
do k = kts,kte
do i = its,ite
@@ -419,13 +398,45 @@
enddo
enddo
-!format:
- 101 format(i3,2i6,12(1x,e15.8))
- 102 format(i6,12(1x,e15.8))
+!end select radiation_lw_select
end subroutine radiation_lw_to_MPAS
!=============================================================================================
+ subroutine radiation_camlw_to_MPAS(diag_physics)
+!=============================================================================================
+
+!input arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+
+!---------------------------------------------------------------------------------------------
+
+!write(0,*) '--- writing absnxt,abstot,and emstot to restart =', l_camlw
+ do j = jts,jte
+ do n = 1,cam_abs_dim1
+ do k = kts,kte
+ do i = its,ite
+ diag_physics % absnxt % array(k,n,i) = absnxt_p(i,k,n,j)
+ enddo
+ enddo
+ enddo
+ do n = 1,cam_abs_dim2
+ do k = kts,kte+1
+ do i = its,ite
+ diag_physics % abstot % array(k,n,i) = abstot_p(i,k,n,j)
+ enddo
+ enddo
+ enddo
+ do k = kts,kte+1
+ do i = its,ite
+ diag_physics % emstot % array(k,i) = emstot_p(i,k,j)
+ enddo
+ enddo
+ enddo
+
+ end subroutine radiation_camlw_to_MPAS
+
+!=============================================================================================
subroutine init_radiation_lw(dminfo,mesh,state_1,state_2)
!=============================================================================================
@@ -460,12 +471,10 @@
end subroutine init_radiation_lw
!=============================================================================================
- subroutine driver_radiation_lw(itimestep,mesh,state,diag_physics,sfc_input, &
- tend_physics,xtime_s)
+ subroutine driver_radiation_lw(xtime_s,mesh,state,diag_physics,sfc_input,tend_physics)
!=============================================================================================
!input arguments:
- integer,intent(in):: itimestep
type(mesh_type),intent(in) :: mesh
real(kind=RKIND),intent(in):: xtime_s
@@ -480,14 +489,14 @@
!---------------------------------------------------------------------------------------------
call mpas_timer_start("radiation_lw")
- write(0,100) itimestep
+ write(0,100)
!formats:
100 format(/,' --- enter subroutine driver_radiation_lw: ',i6)
101 format(i8,12(1x,e15.8))
!copy all MPAS arrays to rectangular grid:
- call radiation_lw_from_MPAS(mesh,state,diag_physics,sfc_input,xtime_s)
+ call radiation_lw_from_MPAS(xtime_s,mesh,state,diag_physics,sfc_input)
!call to longwave radiation scheme:
radiation_lw_select: select case (trim(radt_lw_scheme))
@@ -594,7 +603,7 @@
end select radiation_lw_select
!copy all arrays back to MPAS geodesic grid:
- call radiation_lw_to_MPAS(diag_physics,tend_physics,xtime_s)
+ call radiation_lw_to_MPAS(diag_physics,tend_physics)
write(0,*) '--- end subroutine driver_radiation_lw'
call mpas_timer_stop("radiation_lw")
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_init.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_init.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_init.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -58,19 +58,72 @@
!edges:
call init_dirs_forphys(mesh)
-!initialization of temperatures needed for updating the deep soil temperature:
- do iCell = 1, mesh % nCellsSolve
- diag_physics % nsteps_accum % array(iCell) = 0
- diag_physics % ndays_accum % array(iCell) = 1
+!initialization of counters i_rainc and i_rainnc. i_rainc and i_rainnc track the number of
+!times the accumulated convective (rainc) and grid-scale (rainnc) rain exceed the prescribed
+!threshold value:
+ if(.not. config_do_restart) then
+ do iCell = 1, mesh % nCellsSolve
+ diag_physics % i_rainc % array(iCell) = 0
+ diag_physics % i_rainnc % array(iCell) = 0
+ enddo
+ endif
- diag_physics % tday_accum % array(iCell) = sfc_input % tmn % array(iCell)
- diag_physics % tyear_mean % array(iCell) = sfc_input % tmn % array(iCell)
- diag_physics % tyear_accum % array(iCell) = sfc_input % tmn % array(iCell)
- do iLag = 1, mesh % nLags
- diag_physics % tlag % array(iLag,iCell) = sfc_input % tmn % array(iCell)
+!initialization of counters i_acsw* and i_aclw*. i_acsw* and i_aclw* track the number of times
+!the accumulated long and short-wave radiation fluxes exceed their prescribed theshold values.
+ if(.not. config_do_restart) then
+ do iCell = 1, mesh % nCellsSolve
+ diag_physics % i_acswdnb % array(iCell) = 0
+ diag_physics % i_acswdnbc % array(iCell) = 0
+ diag_physics % i_acswdnt % array(iCell) = 0
+ diag_physics % i_acswdntc % array(iCell) = 0
+ diag_physics % i_acswupb % array(iCell) = 0
+ diag_physics % i_acswupbc % array(iCell) = 0
+ diag_physics % i_acswupt % array(iCell) = 0
+ diag_physics % i_acswuptc % array(iCell) = 0
+
+ diag_physics % i_aclwdnb % array(iCell) = 0
+ diag_physics % i_aclwdnbc % array(iCell) = 0
+ diag_physics % i_aclwdnt % array(iCell) = 0
+ diag_physics % i_aclwdntc % array(iCell) = 0
+ diag_physics % i_aclwupb % array(iCell) = 0
+ diag_physics % i_aclwupbc % array(iCell) = 0
+ diag_physics % i_aclwupt % array(iCell) = 0
+ diag_physics % i_aclwuptc % array(iCell) = 0
+
+ diag_physics % acswdnb % array(iCell) = 0._RKIND
+ diag_physics % acswdnbc % array(iCell) = 0._RKIND
+ diag_physics % acswdnt % array(iCell) = 0._RKIND
+ diag_physics % acswdntc % array(iCell) = 0._RKIND
+ diag_physics % acswupb % array(iCell) = 0._RKIND
+ diag_physics % acswupbc % array(iCell) = 0._RKIND
+ diag_physics % acswupt % array(iCell) = 0._RKIND
+ diag_physics % acswuptc % array(iCell) = 0._RKIND
+
+ diag_physics % aclwdnb % array(iCell) = 0._RKIND
+ diag_physics % aclwdnbc % array(iCell) = 0._RKIND
+ diag_physics % aclwdnt % array(iCell) = 0._RKIND
+ diag_physics % aclwdntc % array(iCell) = 0._RKIND
+ diag_physics % aclwupb % array(iCell) = 0._RKIND
+ diag_physics % aclwupbc % array(iCell) = 0._RKIND
+ diag_physics % aclwupt % array(iCell) = 0._RKIND
+ diag_physics % aclwuptc % array(iCell) = 0._RKIND
enddo
- enddo
+ endif
+!initialization of temperatures needed for updating the deep soil temperature:
+ if(.not. config_do_restart) then
+ do iCell = 1, mesh % nCellsSolve
+ diag_physics % nsteps_accum % array(iCell) = 0._RKIND
+ diag_physics % ndays_accum % array(iCell) = 0._RKIND
+ diag_physics % tday_accum % array(iCell) = 0._RKIND
+ diag_physics % tyear_accum % array(iCell) = 0._RKIND
+ diag_physics % tyear_mean % array(iCell) = sfc_input % tmn % array(iCell)
+ do iLag = 1, mesh % nLags
+ diag_physics % tlag % array(iLag,iCell) = sfc_input % tmn % array(iCell)
+ enddo
+ enddo
+ endif
+
!initialization of global surface properties. set here for now, but may be moved when time
!manager is implemented:
call landuse_init_forMPAS(dminfo,julday,mesh,diag_physics,sfc_input)
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_initialize_real.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_initialize_real.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_initialize_real.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -60,14 +60,16 @@
!scan through all the fields in the file:
call read_next_met_field(field,istatus)
do while (istatus == 0)
-
- write(0,*) field % field
- if(index(field % field,'SST' ) /= 0 .or. &
- index(field % field,'SEAICE') /= 0 .or. &
- index(field % field,'ALBEDO') /= 0 .or. &
- index(field % field,'VEGFRA') /= 0 ) then
- write(0,*) field % field
+ !initialization of the sea-surface temperature (SST) and sea-ice fraction (XICE) arrays,
+ !prior to reading the input data:
+ fg % sst % array (1:mesh%nCells) = 0.0_RKIND
+ fg % xice % array (1:mesh%nCells) = 0.0_RKIND
+
+ if(index(field % field,'SKINTEMP') /= 0 .or. &
+ index(field % field,'SST' ) /= 0 .or. &
+ index(field % field,'SEAICE' ) /= 0 ) then
+
!Interpolation routines use real(kind=RKIND), so copy from default real array
allocate(slab_r8(field % nx, field % ny))
do j=1,field % ny
@@ -106,7 +108,7 @@
lat1 = real(field % startlat,RKIND), &
lon1 = real(field % startlon,RKIND))
end if
-
+
!Interpolate field to each MPAS grid cell:
do iCell=1,mesh % nCells
lat = mesh % latCell % array(iCell) * DEG_PER_RAD
@@ -124,7 +126,7 @@
lon = lon - 360.0
call latlon_to_ij(proj, lat, lon, x, y)
end if
-
+
if(index(field % field,'SST') /= 0) then
fg % sst % array(iCell) = interp_sequence(x,y,1,slab_r8,1,field%nx, &
1,field%ny,1,1,-1.e30_RKIND,interp_list,1)
@@ -139,9 +141,7 @@
! exit
end if
call read_next_met_field(field,istatus)
-
enddo
- write(0,*) '--- end subroutine physics_initialize_sst:'
end subroutine physics_initialize_sst
@@ -202,16 +202,28 @@
if(config_input_sst) then
call physics_initialize_sst(mesh,fg)
+ if(maxval(xice(1:nCellsSolve)) == 0._RKIND .and. minval(xice(1:nCellsSolve)) == 0._RKIND) then
+ write(0,*)
+ write(0,*) "The input file does not contain sea-ice data. We freeze the really cold ocean instead"
+ do iCell = 1, nCellsSolve
+ if(landmask(iCell).eq.0 .and. sst(iCell).lt.271._RKIND) xice(iCell) = 1._RKIND
+ enddo
+ endif
+ write(0,*) 'max sst =',maxval(fg % sst % array(1:mesh%nCells))
+ write(0,*) 'min sst =',minval(fg % sst % array(1:mesh%nCells))
+ write(0,*) 'max xice =',maxval(fg % xice % array(1:mesh%nCells))
+ write(0,*) 'min xice =',minval(fg % xice % array(1:mesh%nCells))
+
do iCell = 1, nCellsSolve
!recalculate the sea-ice flag:
- if(xice(iCell) .gt. 0.) then
- seaice(iCell) = 1
+ if(xice(iCell) .gt. 0._RKIND) then
+ seaice(iCell) = 1._RKIND
else
- seaice(iCell) = 0
+ seaice(iCell) = 0._RKIND
endif
!set the skin temperature to the sea-surface temperature over the oceans:
- if(landmask(iCell).eq.0 .and. sst(iCell).gt.170. .and. sst(iCell).lt.400.) &
+ if(landmask(iCell).eq.0 .and. sst(iCell).gt.170._RKIND .and. sst(iCell).lt.400._RKIND) &
skintemp(iCell) = sst(iCell)
enddo
endif
@@ -222,8 +234,8 @@
call monthly_interp_to_date(nCellsSolve,initial_date,albedo12m,sfc_albbck)
do iCell = 1, nCellsSolve
- sfc_albbck(iCell) = sfc_albbck(iCell) / 100.
- if(landmask(iCell) .eq. 0) sfc_albbck(iCell) = 0.08
+ sfc_albbck(iCell) = sfc_albbck(iCell) / 100._RKIND
+ if(landmask(iCell) .eq. 0) sfc_albbck(iCell) = 0.08_RKIND
enddo
!initialization of the green-ness (vegetation) fraction: interpolation of the monthly values to
@@ -237,10 +249,10 @@
!limit the annual maximum snow albedo to 0.08 over open-ocean and to 0.75 over sea-ice cells::
do iCell = 1, nCellsSolve
- if(landmask(iCell) .eq. 0 .and. seaice(iCell) .eq. 0.) then
- snoalb(iCell) = 0.08
- elseif(landmask(iCell) .eq. 0 .and. seaice(iCell) .eq. 1.) then
- snoalb(iCell) = 0.75
+ if(landmask(iCell) .eq. 0 .and. seaice(iCell) .eq. 0._RKIND) then
+ snoalb(iCell) = 0.08_RKIND
+ elseif(landmask(iCell) .eq. 0 .and. seaice(iCell) .eq. 1._RKIND) then
+ snoalb(iCell) = 0.75_RKIND
endif
enddo
@@ -248,12 +260,12 @@
!(m) as functions of the input snow water content (kg/m2). we use a 5:1 ratio from liquid
!water equivalent to snow depth:
do iCell = 1, nCellsSolve
- if(snow(iCell) .ge. 10.) then
- snowc(iCell) = 1.
+ if(snow(iCell) .ge. 10._RKIND) then
+ snowc(iCell) = 1._RKIND
else
- snowc(iCell) = 0.
+ snowc(iCell) = 0._RKIND
endif
- snowh(iCell) = snow(iCell) * 5.0 / 1000.
+ snowh(iCell) = snow(iCell) * 5.0_RKIND / 1000._RKIND
enddo
!initialization of soil layers properties:
@@ -264,10 +276,10 @@
!define xland over land and ocean:
do iCell = 1, nCellsSolve
- if(landmask(iCell) .eq. 1 .or. (landmask(iCell).eq.0 .and. seaice(iCell).eq.1.)) then
- xland(iCell) = 1.
+ if(landmask(iCell) .eq. 1 .or. (landmask(iCell).eq.0 .and. seaice(iCell).eq.1._RKIND)) then
+ xland(iCell) = 1._RKIND
elseif(landmask(iCell) .eq. 0) then
- xland(iCell) = 2.
+ xland(iCell) = 2._RKIND
endif
enddo
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_manager.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_manager.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_manager.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -38,6 +38,22 @@
!between updates is 6 hours and is set with config_camrad_abs_update (00:30:00).
integer, parameter:: camAlarmID = 17
+!defines alarm to save the CAM arrays absnst, absnxt, and emstot to restart files. When the
+!alarm rings, the local arrays absnt_p, absnxt_p, and emstot_p are copied to the MPAS arrays
+!for writing to restart files at the bottom of the time-step:
+ integer, parameter:: camlwAlarmID = 18
+ type(MPAS_TimeInterval_Type):: camlwTimeStep
+
+!defines alarm to check if the accumulated rain due to cloud microphysics and convection is
+!greater than its maximum allowed value:
+ integer, parameter:: acrainAlarmID = 19
+ type(MPAS_TimeInterval_Type):: acrainTimeStep
+
+!defines alarm to check if the accumulated radiation diagnostics due to long- and short-wave
+!radiation is greater than its maximum allowed value:
+ integer, parameter:: acradtAlarmID = 20
+ type(MPAS_TimeInterval_Type):: acradtTimeStep
+
integer :: h, m, s, s_n, s_d, DoY, yr
real(kind=RKIND) :: utc_h
@@ -76,7 +92,8 @@
' GMT =', f16.9,/, &
' UTC_H =', f16.9,/, &
' CURR_JULDAY =', f16.9,/, &
- ' LEAP_YEAR =', 1x,l1,/)
+ ' LEAP_YEAR =', 1x,l1,/, &
+ ' TIME STAMP =', 1x,a32,/)
currTime = mpas_get_clock_time(clock,MPAS_NOW,ierr)
call mpas_get_time(curr_time=currTime,dateTimeString=timeStamp,YYYY=yr,H=h,M=m, &
@@ -88,7 +105,7 @@
julday = DoY
curr_julday = real(julday-1) + utc_h / 24.0
LeapYear = isLeapYear(year)
- write(0,100) year,julday,gmt,utc_h,curr_julday,LeapYear
+ write(0,100) year,julday,gmt,utc_h,curr_julday,LeapYear,timeStamp
block => domain % blocklist
do while(associated(block))
@@ -97,7 +114,7 @@
!monthly values to current day:
if(mpas_is_alarm_ringing(clock,greenAlarmID,ierr=ierr)) then
call mpas_reset_clock_alarm(clock,greenAlarmID,ierr=ierr)
- write(0,*) '--- update background surface albedo, greeness fraction:', timeStamp
+ write(0,*) '--- time to update background surface albedo, greeness fraction.'
call physics_update_surface(timeStamp,block%mesh,block%sfc_input)
endif
@@ -133,7 +150,6 @@
elseif(config_radtlw_interval == "none") then
l_radtlw = .true.
endif
- write(0,*)
write(0,*) '--- time to run the LW radiation scheme L_RADLW =',l_radtlw
endif
@@ -151,6 +167,21 @@
write(0,*) '--- time to run the SW radiation scheme L_RADSW =',l_radtsw
endif
+!check to see if it is time to run the parameterization of convection:
+ if(trim(config_conv_deep_scheme) /= "off") then
+ l_conv = .false.
+
+ if(config_conv_interval /= "none") then
+ if(mpas_is_alarm_ringing(clock,convAlarmID,ierr=ierr)) then
+ call mpas_reset_clock_alarm(clock,convAlarmID,ierr=ierr)
+ l_conv = .true.
+ endif
+ elseif(config_conv_interval == "none") then
+ l_conv = .true.
+ endif
+ write(0,*) '--- time to run the convection scheme L_CONV =',l_conv
+ endif
+
!check to see if it is time to update the ozone trace gas path lengths,the total emissivity,
!and the total absorptivity in the "CAM" long-wave radiation codes.
if(trim(config_radt_lw_scheme) .eq. "cam_lw" .or. &
@@ -161,13 +192,42 @@
call mpas_reset_clock_alarm(clock,camAlarmID,ierr=ierr)
doabsems = .true.
endif
- write(0,*) '--- update CAM absorptivity and emissivity arrays DOABSEMS =',doabsems
+ write(0,*) '--- time to update CAM absorptivity and emissivity arrays DOABSEMS =',doabsems
+ endif
+!check to see if it is time to save the local CAM arrays absnst_p, absnxt_p, and emstot_p to
+!the MPAS arrays:
+ if(trim(config_radt_lw_scheme) .eq. "cam_lw") then
+ l_camlw = .false.
+ if(mpas_is_alarm_ringing(clock,camlwAlarmID,camlwTimeStep,ierr=ierr)) then
+ call mpas_reset_clock_alarm(clock,camlwAlarmID,camlwTimeStep,ierr=ierr)
+ l_camlw = .true.
+ endif
+ write(0,*) '--- time to write local CAM arrays to MPAS arrays L_CAMLW =',l_camlw
endif
-
-!formats:
- 101 format(3x,'l_radtlw = ',l1,3x,'l_radtsw = ',l1)
+!check to see if it is time to apply limit to the accumulated rain due to cloud microphysics
+!and convection:
+ if(trim(config_conv_deep_scheme) /= "off") then
+ l_acrain = .false.
+ if(mpas_is_alarm_ringing(clock,acrainAlarmID,acrainTimeStep,ierr=ierr)) then
+ call mpas_reset_clock_alarm(clock,acrainAlarmID,acrainTimeStep,ierr=ierr)
+ l_acrain = .true.
+ endif
+ write(0,*) '--- time to apply limit to accumulated rainc and rainnc L_ACRAIN =',l_acrain
+ endif
+
+!check to see if it is time to apply limit to the accumulated radiation diagnostics due to
+!long- and short-wave radiation:
+ if(trim(config_radt_lw_scheme) /= "off" .or. trim(config_radt_sw_scheme) /= "off") then
+ l_acradt = .false.
+ if(mpas_is_alarm_ringing(clock,acradtAlarmID,acradtTimeStep,ierr=ierr)) then
+ call mpas_reset_clock_alarm(clock,acradtAlarmID,acradtTimeStep,ierr=ierr)
+ l_acradt = .true.
+ endif
+ write(0,*) '--- time to apply limit to accumulated radiation diags. L_ACRADT =',l_acradt
+ endif
+
end subroutine physics_timetracker
!=============================================================================================
@@ -325,6 +385,39 @@
call physics_error_fatal('subroutine physics_init: error creating alarm CAM')
endif
+!set alarm to write the "CAM" local arrays absnst_p, absnxt_p, and emstot_p to the MPAS arrays
+!for writing to the restart file at the bottom of the time-step:
+ if(trim(config_radt_lw_scheme) .eq. "cam_lw" ) then
+ call mpas_set_timeInterval(camlwTimeStep,dt=config_dt,ierr=ierr)
+ call mpas_set_timeInterval(alarmTimeStep,timeString=config_restart_interval,ierr=ierr)
+ alarmStartTime = startTime + alarmTimeStep
+ call mpas_add_clock_alarm(clock,camlwAlarmID,alarmStartTime,alarmTimeStep,ierr=ierr)
+ if(ierr /= 0) &
+ call physics_error_fatal('subroutine physics_init: error creating alarm CAMLW')
+ endif
+
+!set alarm to check if the accumulated rain due to cloud microphysics and convection is
+!greater than its maximum allowed value:
+ if(config_bucket_update /= "none") then
+ call mpas_set_timeInterval(acrainTimeStep,dt=config_dt,ierr=ierr)
+ call mpas_set_timeInterval(alarmTimeStep,timeString=config_bucket_update,ierr=ierr)
+ alarmStartTime = startTime + alarmTimeStep
+ call mpas_add_clock_alarm(clock,acrainAlarmID,alarmStartTime,alarmTimeStep,ierr=ierr)
+ if(ierr /= 0) &
+ call physics_error_fatal('subroutine physics_init: error creating alarm rain limit')
+ endif
+
+!set alarm to check if the accumulated radiation diagnostics due to long- and short-wave radiation
+!is greater than its maximum allowed value:
+ if(config_bucket_update /= "none") then
+ call mpas_set_timeInterval(acradtTimeStep,dt=config_dt,ierr=ierr)
+ call mpas_set_timeInterval(alarmTimeStep,timeString=config_bucket_update,ierr=ierr)
+ alarmStartTime = startTime + alarmTimeStep
+ call mpas_add_clock_alarm(clock,acradtAlarmID,alarmStartTime,alarmTimeStep,ierr=ierr)
+ if(ierr /= 0) &
+ call physics_error_fatal('subroutine physics_init: error creating alarm radiation limit')
+ endif
+
write(0,102) dt_radtlw,dt_radtsw,dt_cu,dt_pbl
!initialization of physics dimensions to mimic a rectangular grid:
@@ -344,31 +437,39 @@
ids,ide,jds,jde,kds,kde, &
its,ite,jts,jte,kts,kte
-!initialization:
+!initialization local physics variables:
num_months = mesh % nMonths
+ num_soils = mesh% nSoilLevels
-!initialization of physics time-steps:
- dt_dyn = config_dt
- n_microp = config_n_microp
- n_cu = config_n_conv
-
- dt_microp = dt_dyn/n_microp !for now.
-
-!write(0,*) 'mod =',mod(dt_dyn,dt_radtsw)
-!write(0,*) 'mod =',mod(dt_dyn,dt_microp)
-!stop
-
-!cloud microphysics scheme:
- microp_scheme = trim(config_microp_scheme)
conv_deep_scheme = trim(config_conv_deep_scheme)
conv_shallow_scheme = trim(config_conv_shallow_scheme)
- sfclayer_scheme = trim(config_sfclayer_scheme)
+ lsm_scheme = trim(config_lsm_scheme)
+ microp_scheme = trim(config_microp_scheme)
pbl_scheme = trim(config_pbl_scheme)
radt_cld_scheme = trim(config_radt_cld_scheme)
radt_lw_scheme = trim(config_radt_lw_scheme)
radt_sw_scheme = trim(config_radt_sw_scheme)
+ sfclayer_scheme = trim(config_sfclayer_scheme)
-!CAM radiation schemes:
+!initialization of local physics time-steps:
+!... dynamics:
+ dt_dyn = config_dt
+!... cloud microphysics:
+ n_microp = config_n_microp
+ dt_microp = dt_dyn/n_microp !for now.
+!... convection:
+ l_conv = .false.
+ n_cu = nint(dt_cu/dt_dyn)
+ n_cu = max(n_cu,1)
+!... radiation:
+ l_radtlw = .false.
+ l_radtsw = .false.
+!... others:
+ l_camlw = .false.
+ l_acrain = .false.
+ l_acradt = .false.
+
+!initialization for CAM radiation schemes only:
if(trim(config_radt_lw_scheme) .eq. "cam_lw" .or. &
trim(config_radt_sw_scheme) .eq. "cam_sw" ) then
@@ -387,10 +488,7 @@
endif
-!land-surface scheme:
- lsm_scheme = trim(config_lsm_scheme)
- num_soils = mesh% nSoilLevels
-
+!initialization of sea-ice threshold:
if(.not. config_frac_seaice) then
xice_threshold = 0.5
elseif(config_frac_seaice) then
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_todynamics.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_todynamics.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_todynamics.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -236,8 +236,8 @@
enddo
tempField % block => block
- tempField % dims(1) = nVertLevels
- tempField % dims(2) = nCellsSolve
+ tempField % dimSizes(1) = nVertLevels
+ tempField % dimSizes(2) = nCellsSolve
tempField % sendList => block % parinfo % cellsToSend
tempField % recvList => block % parinfo % cellsToRecv
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_update.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_update.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_update.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -4,10 +4,12 @@
use mpas_grid_types
use mpas_atmphys_driver_convection_deep
+ use mpas_atmphys_vars
implicit none
private
- public:: physics_update
+ public:: physics_update, &
+ update_radiation_diagnostics
contains
@@ -31,7 +33,7 @@
do while(associated(block))
!parameterization of convection: update accumulated precipitation.
- call update_convection_deep(dt,block%mesh,block%diag_physics)
+ !call update_convection_deep(dt,config_bucket_rainc,block%mesh,block%diag_physics)
block => block % next
end do
@@ -40,5 +42,117 @@
end subroutine physics_update
!=============================================================================================
+ subroutine update_radiation_diagnostics(bucket_radt,mesh,diag)
+!=============================================================================================
+
+!input arguments:
+ real(kind=RKIND),intent(in):: bucket_radt
+ type(mesh_type),intent(in):: mesh
+
+!inout arguments:
+ type(diag_physics_type),intent(inout):: diag
+
+!local variables:
+ integer:: iCell
+
+!--------------------------------------------------------------------------------------------
+
+ do iCell = 1, mesh%nCellsSolve
+ !short-wave radiation:
+ diag%acswdnb %array(iCell) = diag%acswdnb %array(iCell) + diag%swdnb %array(iCell)*dt_dyn
+ diag%acswdnbc%array(iCell) = diag%acswdnbc%array(iCell) + diag%swdnbc%array(iCell)*dt_dyn
+ diag%acswdnt %array(iCell) = diag%acswdnt %array(iCell) + diag%swdnt %array(iCell)*dt_dyn
+ diag%acswdntc%array(iCell) = diag%acswdntc%array(iCell) + diag%swdntc%array(iCell)*dt_dyn
+ diag%acswupb %array(iCell) = diag%acswupb %array(iCell) + diag%swupb %array(iCell)*dt_dyn
+ diag%acswupbc%array(iCell) = diag%acswupbc%array(iCell) + diag%swupbc%array(iCell)*dt_dyn
+ diag%acswupt %array(iCell) = diag%acswupt %array(iCell) + diag%swupt %array(iCell)*dt_dyn
+ diag%acswuptc%array(iCell) = diag%acswuptc%array(iCell) + diag%swuptc%array(iCell)*dt_dyn
+ !long-wave radiation:
+ diag%aclwdnb %array(iCell) = diag%aclwdnb %array(iCell) + diag%lwdnb %array(iCell)*dt_dyn
+ diag%aclwdnbc%array(iCell) = diag%aclwdnbc%array(iCell) + diag%lwdnbc%array(iCell)*dt_dyn
+ diag%aclwdnt %array(iCell) = diag%aclwdnt %array(iCell) + diag%lwdnt %array(iCell)*dt_dyn
+ diag%aclwdntc%array(iCell) = diag%aclwdntc%array(iCell) + diag%lwdntc%array(iCell)*dt_dyn
+ diag%aclwupb %array(iCell) = diag%aclwupb %array(iCell) + diag%lwupb %array(iCell)*dt_dyn
+ diag%aclwupbc%array(iCell) = diag%aclwupbc%array(iCell) + diag%lwupbc%array(iCell)*dt_dyn
+ diag%aclwupt %array(iCell) = diag%aclwupt %array(iCell) + diag%lwupt %array(iCell)*dt_dyn
+ diag%aclwuptc%array(iCell) = diag%aclwuptc%array(iCell) + diag%lwuptc%array(iCell)*dt_dyn
+ enddo
+
+ if(l_acradt .and. bucket_radt.gt.0._RKIND) then
+
+ do iCell = 1, mesh%nCellsSolve
+ !short-wave radiation:
+ if(diag%acswdnb%array(iCell) .gt. bucket_radt) then
+ diag%i_acswdnb%array(iCell) = diag%i_acswdnb%array(iCell) + 1
+ diag%acswdnb%array(iCell) = diag%acswdnb%array(iCell) - bucket_radt
+ endif
+ if(diag%acswdnbc%array(iCell) .gt. bucket_radt) then
+ diag%i_acswdnbc%array(iCell) = diag%i_acswdnbc%array(iCell) + 1
+ diag%acswdnbc%array(iCell) = diag%acswdnbc%array(iCell) - bucket_radt
+ endif
+ if(diag%acswdnt%array(iCell) .gt. bucket_radt) then
+ diag%i_acswdnt%array(iCell) = diag%i_acswdnt%array(iCell) + 1
+ diag%acswdnt%array(iCell) = diag%acswdnt%array(iCell) - bucket_radt
+ endif
+ if(diag%acswdntc%array(iCell) .gt. bucket_radt) then
+ diag%i_acswdntc%array(iCell) = diag%i_acswdntc%array(iCell) + 1
+ diag%acswdntc%array(iCell) = diag%acswdntc%array(iCell) - bucket_radt
+ endif
+ if(diag%acswupb%array(iCell) .gt. bucket_radt) then
+ diag%i_acswupb%array(iCell) = diag%i_acswupb%array(iCell) + 1
+ diag%acswupb%array(iCell) = diag%acswupb%array(iCell) - bucket_radt
+ endif
+ if(diag%acswupbc%array(iCell) .gt. bucket_radt) then
+ diag%i_acswupbc%array(iCell) = diag%i_acswupbc%array(iCell) + 1
+ diag%acswupbc%array(iCell) = diag%acswupbc%array(iCell) - bucket_radt
+ endif
+ if(diag%acswupt%array(iCell) .gt. bucket_radt) then
+ diag%i_acswupt%array(iCell) = diag%i_acswupt%array(iCell) + 1
+ diag%acswupt%array(iCell) = diag%acswupt%array(iCell) - bucket_radt
+ endif
+ if(diag%acswuptc%array(iCell) .gt. bucket_radt) then
+ diag%i_acswuptc%array(iCell) = diag%i_acswuptc%array(iCell) + 1
+ diag%acswuptc%array(iCell) = diag%acswuptc%array(iCell) - bucket_radt
+ endif
+ !long-wave radiation:
+ if(diag%aclwdnb%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwdnb%array(iCell) = diag%i_aclwdnb%array(iCell) + 1
+ diag%aclwdnb%array(iCell) = diag%aclwdnb%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwdnbc%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwdnbc%array(iCell) = diag%i_aclwdnbc%array(iCell) + 1
+ diag%aclwdnbc%array(iCell) = diag%aclwdnbc%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwdnt%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwdnt%array(iCell) = diag%i_aclwdnt%array(iCell) + 1
+ diag%aclwdnt%array(iCell) = diag%aclwdnt%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwdntc%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwdntc%array(iCell) = diag%i_aclwdntc%array(iCell) + 1
+ diag%aclwdntc%array(iCell) = diag%aclwdntc%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwupb%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwupb%array(iCell) = diag%i_aclwupb%array(iCell) + 1
+ diag%aclwupb%array(iCell) = diag%aclwupb%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwupbc%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwupbc%array(iCell) = diag%i_aclwupbc%array(iCell) + 1
+ diag%aclwupbc%array(iCell) = diag%aclwupbc%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwupt%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwupt%array(iCell) = diag%i_aclwupt%array(iCell) + 1
+ diag%aclwupt%array(iCell) = diag%aclwupt%array(iCell) - bucket_radt
+ endif
+ if(diag%aclwuptc%array(iCell) .gt. bucket_radt) then
+ diag%i_aclwuptc%array(iCell) = diag%i_aclwuptc%array(iCell) + 1
+ diag%aclwuptc%array(iCell) = diag%aclwuptc%array(iCell) - bucket_radt
+ endif
+ enddo
+
+ endif
+
+ end subroutine update_radiation_diagnostics
+
+!=============================================================================================
end module mpas_atmphys_update
!=============================================================================================
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_update_surface.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_update_surface.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_update_surface.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -128,6 +128,12 @@
sfc_emibck => diag_physics % sfc_emibck % array
xicem => diag_physics % xicem % array
+ write(0,*)
+ write(0,*) 'max sst =',maxval(sst(1:nCellsSolve))
+ write(0,*) 'min sst =',minval(sst(1:nCellsSolve))
+ write(0,*) 'max xice =',maxval(xice(1:nCellsSolve))
+ write(0,*) 'min xice =',minval(xice(1:nCellsSolve))
+
do iCell = 1, nCellsSolve
!update the skin temperature and the temperature in the first soil layer to the updated
@@ -236,8 +242,8 @@
real(kind=RKIND),dimension(:),pointer:: dtw1,emiss,ust
!---------------------------------------------------------------------------------------------
- write(0,*)
- write(0,*) '--- enter subroutine physics_update_sstskin:'
+!write(0,*)
+!write(0,*) '--- enter subroutine physics_update_sstskin:'
nCellsSolve = mesh % nCellsSolve
@@ -349,14 +355,16 @@
!local variables:
integer:: iCell,iLag,n,nCellsSolve,nLags
- integer,dimension(:),pointer:: nsteps_accum,ndays_accum
real(kind=RKIND),parameter:: tconst = 0.6
real(kind=RKIND):: deltat,julian,tprior,yrday
+ real(kind=RKIND),dimension(:),pointer:: nsteps_accum,ndays_accum
real(kind=RKIND),dimension(:),pointer :: tday_accum,tmn,tsk,tyear_accum,tyear_mean
real(kind=RKIND),dimension(:,:),pointer:: tlag
!---------------------------------------------------------------------------------------------
+!write(0,*)
+!write(0,*) '--- enter subroutine physics_update_deepsoiltemp:'
nCellsSolve = mesh % nCellsSolve
nLags = mesh % nLags
@@ -380,26 +388,27 @@
!... accumulate the skin temperature for current day:
do iCell = 1, nCellsSolve
- tday_accum(iCell) = tday_accum(iCell) + tsk(iCell)
+ tday_accum(iCell) = tday_accum(iCell) + tsk(iCell)*dt
+! tday_accum(iCell) = tday_accum(iCell) + tsk(iCell)
nsteps_accum(iCell) = nsteps_accum(iCell) + dt
+! nsteps_accum(iCell) = nsteps_accum(iCell) + 1
enddo
!... update the deep soil temperature at the end of the day:
deltat = (julian_in-nint(julian_in))*24.*3600.
- write(0,*)
- write(0,*) 'yrday = ',yrday
- write(0,*) 'julian_in = ',julian_in
- write(0,*) 'nint(julian_in)= ',nint(julian_in)
- write(0,*) 'deltat = ',deltat
- write(0,*) 'nint(deltat)-dt= ',nint(deltat) .lt. dt
+!write(0,*) '--- yrday = ',yrday
+!write(0,*) '--- julian_in = ',julian_in
+!write(0,*) '--- nint(julian_in)= ',nint(julian_in)
+!write(0,*) '--- deltat = ',deltat
+!write(0,*) '--- nint(deltat)-dt= ',nint(deltat) .lt. dt
if(abs(deltat) .le. dt/2) then
- write(0,*) '--- end of day: update deep soil temperature'
julian = julian_in - 1. + dt/(3600.*24.)
do iCell = 1, nCellsSolve
+!--- update tmn:
tprior = 0.
do iLag = 1, nLags
tprior = tprior + tlag(iLag,iCell)
@@ -407,21 +416,22 @@
tprior = tprior / nLags
tmn(iCell) = tconst*tyear_mean(iCell) + (1-tconst)*tprior
+!--- update tlag:
do iLag = 1, nLags-1
tlag(iLag,iCell) = tlag(iLag+1,iCell)
enddo
tlag(nLags,iCell) = tday_accum(iCell) / nsteps_accum(iCell)
tday_accum(iCell) = 0.0
- nsteps_accum(iCell) = 0.0
+ nsteps_accum(iCell) = 0.0
!... end of year:
if(yrday-julian .le. 1.) then
tyear_mean(iCell) = tyear_accum(iCell) / ndays_accum(iCell)
tyear_accum(iCell) = 0.
- ndays_accum(iCell) = 0
+ ndays_accum(iCell) = 0.0
else
tyear_accum(iCell) = tyear_accum(iCell) + tlag(nLags,iCell)
- ndays_accum(iCell) = ndays_accum(iCell) + 1
+ ndays_accum(iCell) = ndays_accum(iCell) + 1.
endif
enddo
Modified: branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_vars.F
===================================================================
--- branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_vars.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_atmos_physics/mpas_atmphys_vars.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -27,7 +27,11 @@
!=============================================================================================
logical:: l_radtlw !controls call to longwave radiation parameterization.
- logical:: l_radtsw !controls call to shortwave parameterization.
+ logical:: l_radtsw !controls call to shortwave radiation parameterization.
+ logical:: l_conv !controls call to convective parameterization.
+ logical:: l_camlw !controls when to save local CAM LW abs and ems arrays.
+ logical:: l_acrain !when .true., limit to accumulated rain is applied.
+ logical:: l_acradt !when .true., limit to lw and sw radiation is applied.
integer,public:: ids,ide,jds,jde,kds,kde
integer,public:: ims,ime,jms,jme,kms,kme
Modified: branches/omp_blocks/io/src/core_hyd_atmos/Registry
===================================================================
--- branches/omp_blocks/io/src/core_hyd_atmos/Registry        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_hyd_atmos/Registry        2012-03-20 02:01:44 UTC (rev 1679)
@@ -4,7 +4,7 @@
namelist integer sw_model config_test_case 5
namelist character sw_model config_time_integration SRK3
namelist real sw_model config_dt 172.8
-namelist integer sw_model config_calendar_type MPAS_360DAY
+namelist character sw_model config_calendar_type 360day
namelist character sw_model config_start_time 0000-01-01_00:00:00
namelist character sw_model config_stop_time none
namelist character sw_model config_run_duration none
Modified: branches/omp_blocks/io/src/core_hyd_atmos/mpas_atmh_time_integration.F
===================================================================
--- branches/omp_blocks/io/src/core_hyd_atmos/mpas_atmh_time_integration.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_hyd_atmos/mpas_atmh_time_integration.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -1629,9 +1629,9 @@
tempField % block => block
- tempField % dims(1) = 2
- tempField % dims(2) = num_scalars
- tempField % dims(3) = grid % nCells
+ tempField % dimSizes(1) = 2
+ tempField % dimSizes(2) = num_scalars
+ tempField % dimSizes(3) = grid % nCells
tempField % sendList => block % parinfo % cellsToSend
tempField % recvList => block % parinfo % cellsToRecv
Modified: branches/omp_blocks/io/src/core_init_nhyd_atmos/Registry
===================================================================
--- branches/omp_blocks/io/src/core_init_nhyd_atmos/Registry        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_init_nhyd_atmos/Registry        2012-03-20 02:01:44 UTC (rev 1679)
@@ -2,7 +2,7 @@
% namelist type namelist_record name default_value
%
namelist integer nhyd_model config_test_case 7
-namelist integer nhyd_model config_calendar_type MPAS_GREGORIAN
+namelist character nhyd_model config_calendar_type gregorian
namelist character nhyd_model config_start_time none
namelist character nhyd_model config_stop_time none
namelist integer nhyd_model config_theta_adv_order 3
Modified: branches/omp_blocks/io/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F
===================================================================
--- branches/omp_blocks/io/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_init_nhyd_atmos/mpas_init_atm_test_cases.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -3193,7 +3193,7 @@
end do
tempField % block => block
- tempField % dims(1) = grid % nCells
+ tempField % dimSizes(1) = grid % nCells
tempField % sendList => parinfo % cellsToSend
tempField % recvList => parinfo % cellsToRecv
tempField % array => hs
Modified: branches/omp_blocks/io/src/core_nhyd_atmos/Registry
===================================================================
--- branches/omp_blocks/io/src/core_nhyd_atmos/Registry        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_nhyd_atmos/Registry        2012-03-20 02:01:44 UTC (rev 1679)
@@ -4,7 +4,7 @@
namelist integer nhyd_model config_test_case 0
namelist character nhyd_model config_time_integration SRK3
namelist real nhyd_model config_dt 600.0
-namelist integer nhyd_model config_calendar_type MPAS_GREGORIAN
+namelist character nhyd_model config_calendar_type gregorian
namelist character nhyd_model config_start_time 0000-01-01_00:00:00
namelist character nhyd_model config_stop_time none
namelist character nhyd_model config_run_duration none
@@ -351,6 +351,7 @@
namelist character physics config_pbl_interval none
namelist character physics config_camrad_abs_update 06:00:00
namelist character physics config_greeness_update 24:00:00
+namelist character physics config_bucket_update none
namelist character physics config_microp_scheme off
namelist character physics config_conv_shallow_scheme off
@@ -363,6 +364,10 @@
namelist character physics config_radt_sw_scheme off
namelist character physics config_sfclayer_scheme off
+namelist real physics config_bucket_radt 0.0_RKIND
+namelist real physics config_bucket_rainc 0.0_RKIND
+namelist real physics config_bucket_rainnc 0.0_RKIND
+
var persistent real east ( R3 nCells ) 0 r east mesh - -
var persistent real north ( R3 nCells ) 0 r north mesh - -
@@ -377,8 +382,8 @@
% tyear_mean : annual mean surface temperature [K]
% tyear_accum : accumulated yearly surface temperature for current year [K]
-var persistent integer nsteps_accum ( nCells Time ) 1 r nsteps_accum diag_physics - -
-var persistent integer ndays_accum ( nCells Time ) 1 r ndays_accum diag_physics - -
+var persistent real nsteps_accum ( nCells Time ) 1 r nsteps_accum diag_physics - -
+var persistent real ndays_accum ( nCells Time ) 1 r ndays_accum diag_physics - -
var persistent real tlag ( nLags nCells Time ) 1 r tlag diag_physics - -
var persistent real tday_accum ( nCells Time ) 1 r tday_accum diag_physics - -
@@ -388,7 +393,7 @@
%--------------------------------------------------------------------------------------------------
%... PARAMETERIZATION OF CLOUD MICROPHYSICS:
%--------------------------------------------------------------------------------------------------
-
+% i_rainnc : counter related to how often rainnc is being reset relative to its bucket value (-)
% rainnc : accumulated total time-step grid-scale precipitation (mm)
% rainncv : time-step total grid-scale precipitation (mm)
% snownc : accumulated grid-scale precipitation of snow (mm)
@@ -397,6 +402,7 @@
% graupelncv: time-step grid-scale precipitation of graupel (mm)
% sr : time-step ratio of frozen versus total grid-scale precipitation (-)
+var persistent integer i_rainnc ( nCells Time ) 1 ro i_rainnc diag_physics - -
var persistent real sr ( nCells Time ) 1 ro sr diag_physics - -
var persistent real rainncv ( nCells Time ) 1 ro rainncv diag_physics - -
var persistent real snowncv ( nCells Time ) 1 o snowncv diag_physics - -
@@ -412,7 +418,7 @@
%--------------------------------------------------------------------------------------------------
%... PARAMETERIZATION OF CONVECTION:
%--------------------------------------------------------------------------------------------------
-
+% i_rainc : counter related to how often rainc is begin reset relative to its bucket value (-)
% cuprec : convective precipitation rate (mm/s)
% rainc : accumulated time-step convective precipitation (mm)
% raincv : time-step convective precipitation (mm)
@@ -421,9 +427,10 @@
% rqccuten : tendency of cloud water mixing ratio due to cumulus convection (kg/kg s-1)
% rqicuten : tendency of cloud ice mixing ratio due to cumulus convection (kg/kg s-1)
-var persistent real cuprec ( nCells Time ) 1 ro cuprec diag_physics - -
-var persistent real rainc ( nCells Time ) 1 ro rainc diag_physics - -
-var persistent real raincv ( nCells Time ) 1 ro raincv diag_physics - -
+var persistent integer i_rainc ( nCells Time ) 1 ro i_rainc diag_physics - -
+var persistent real cuprec ( nCells Time ) 1 ro cuprec diag_physics - -
+var persistent real rainc ( nCells Time ) 1 ro rainc diag_physics - -
+var persistent real raincv ( nCells Time ) 1 ro raincv diag_physics - -
var persistent real rthcuten ( nVertLevels nCells Time ) 1 ro rthcuten tend_physics - -
var persistent real rqvcuten ( nVertLevels nCells Time ) 1 ro rqvcuten tend_physics - -
@@ -558,25 +565,49 @@
%--------------------------------------------------------------------------------------------------
%... PARAMETERIZATION OF SHORTWAVE RADIATION:
%--------------------------------------------------------------------------------------------------
-
% coszr :cosine of the solar zenith angle [-]
-
% gsw :net shortwave flux at surface [W m-2]
% swcf :shortwave cloud forcing at top-of-atmosphere [W m-2]
-% swdnb :all-sky downwelling shortwave flux at bottom-of-atmosphere [J m-2]
-% swdnbc :clear-sky downwelling shortwave flux at bottom-of-atmosphere [J m-2]
-% swdnt :all-sky downwelling shortwave flux at top-of-atmosphere [J m-2]
-% swdntc :clear-sky downwelling shortwave flux at top-of-atmosphere [J m-2]
-% swupb :all-sky upwelling shortwave flux at bottom-of-atmosphere [J m-2]
-% swupbc :clear-sky upwelling shortwave flux at bottom-of-atmosphere [J m-2]
-% swupt :all-sky upwelling shortwave flux at top-of-atmosphere [J m-2]
-% swuptc :clear-sky upwelling shortwave flux at top-of-atmosphere [J m-2]
+% swdnb :all-sky downwelling shortwave flux at bottom-of-atmosphere [W m-2]
+% swdnbc :clear-sky downwelling shortwave flux at bottom-of-atmosphere [W m-2]
+% swdnt :all-sky downwelling shortwave flux at top-of-atmosphere [W m-2]
+% swdntc :clear-sky downwelling shortwave flux at top-of-atmosphere [W m-2]
+% swupb :all-sky upwelling shortwave flux at bottom-of-atmosphere [W m-2]
+% swupbc :clear-sky upwelling shortwave flux at bottom-of-atmosphere [W m-2]
+% swupt :all-sky upwelling shortwave flux at top-of-atmosphere [W m-2]
+% swuptc :clear-sky upwelling shortwave flux at top-of-atmosphere [W m-2]
+% acswdnb :accumulated all-sky downwelling shortwave flux at bottom-of-atmosphere [J m-2]
+% acswdnbc :accumulated clear-sky downwelling shortwave flux at bottom-of-atmosphere [J m-2]
+% acswdnt :accumulated all-sky downwelling shortwave flux at top-of-atmosphere [J m-2]
+% acswdntc :accumulated clear-sky downwelling shortwave flux at top-of-atmosphere [J m-2]
+% acswupb :accumulated all-sky upwelling shortwave flux at bottom-of-atmosphere [J m-2]
+% acswupbc :accumulated clear-sky upwelling shortwave flux at bottom-of-atmosphere [J m-2]
+% acswupt :accumulated all-sky upwelling shortwave flux at top-of-atmosphere [J m-2]
+% acswuptc :accumulated clear-sky upwelling shortwave flux at top-of-atmosphere [J m-2]
% swdnflx :
% swdnflxc :
% swupflx :
% swupflxc :
% rthratensw:uncoupled theta tendency due to shortwave radiation [K s-1]
+% i_acswdnb : counter related to how often swdnb is begin reset relative to its bucket value (-)
+% i_acswdnbc: counter related to how often swdnbc is begin reset relative to its bucket value (-)
+% i_acswdnt : counter related to how often swdnt is begin reset relative to its bucket value (-)
+% i_acswdntc: counter related to how often swdntc is begin reset relative to its bucket value (-)
+% i_acswupb : counter related to how often swupb is begin reset relative to its bucket value (-)
+% i_acswupbc: counter related to how often swupbc is begin reset relative to its bucket value (-)
+% i_acswupt : counter related to how often swupt is begin reset relative to its bucket value (-)
+% i_acswuptc: counter related to how often swuptc is begin reset relative to its bucket value (-)
+
+var persistent integer i_acswdnb ( nCells Time ) 1 ro i_acswdnb diag_physics - -
+var persistent integer i_acswdnbc ( nCells Time ) 1 ro i_acswdnbc diag_physics - -
+var persistent integer i_acswdnt ( nCells Time ) 1 ro i_acswdnt diag_physics - -
+var persistent integer i_acswdntc ( nCells Time ) 1 ro i_acswdntc diag_physics - -
+var persistent integer i_acswupb ( nCells Time ) 1 ro i_acswupb diag_physics - -
+var persistent integer i_acswupbc ( nCells Time ) 1 ro i_acswupbc diag_physics - -
+var persistent integer i_acswupt ( nCells Time ) 1 ro i_acswupt diag_physics - -
+var persistent integer i_acswuptc ( nCells Time ) 1 ro i_acswuptc diag_physics - -
+
var persistent real coszr ( nCells Time ) 1 o coszr diag_physics - -
var persistent real swcf ( nCells Time ) 1 o swcf diag_physics - -
var persistent real swdnb ( nCells Time ) 1 o swdnb diag_physics - -
@@ -587,6 +618,14 @@
var persistent real swupbc ( nCells Time ) 1 o swupbc diag_physics - -
var persistent real swupt ( nCells Time ) 1 o swupt diag_physics - -
var persistent real swuptc ( nCells Time ) 1 o swuptc diag_physics - -
+var persistent real acswdnb ( nCells Time ) 1 ro acswdnb diag_physics - -
+var persistent real acswdnbc ( nCells Time ) 1 ro acswdnbc diag_physics - -
+var persistent real acswdnt ( nCells Time ) 1 ro acswdnt diag_physics - -
+var persistent real acswdntc ( nCells Time ) 1 ro acswdntc diag_physics - -
+var persistent real acswupb ( nCells Time ) 1 ro acswupb diag_physics - -
+var persistent real acswupbc ( nCells Time ) 1 ro acswupbc diag_physics - -
+var persistent real acswupt ( nCells Time ) 1 ro acswupt diag_physics - -
+var persistent real acswuptc ( nCells Time ) 1 ro acswuptc diag_physics - -
var persistent real gsw ( nCells Time ) 1 ro gsw diag_physics - -
var persistent real rthratensw ( nVertLevels nCells Time ) 1 ro rthratensw tend_physics - -
@@ -616,6 +655,14 @@
% lwupbc :clear-sky upwelling longwave flux at bottom-of-atmosphere [W m-2]
% lwupt :all-sky upwelling longwave flux at top-of-atmosphere [W m-2]
% lwuptc :clear-sky upwelling longwave flux at top-of-atmosphere [W m-2]
+% aclwdnb :accumulated all-sky downwelling longwave flux at bottom-of-atmosphere [J m-2]
+% aclwdnbc :accumulated clear-sky downwelling longwave flux at bottom-of-atmosphere [J m-2]
+% aclwdnt :accumulated all-sky downwelling longwave flux at top-of-atmosphere [J m-2]
+% aclwdntc :accumulated clear-sky downwelling longwave flux at top-of-atmosphere [J m-2]
+% aclwupb :accumulated all-sky upwelling longwave flux at bottom-of-atmosphere [J m-2]
+% aclwupbc :accumulated clear-sky upwelling longwave flux at bottom-of-atmosphere [J m-2]
+% aclwupt :accumulated all-sky upwelling longwave flux at top-of-atmosphere [J m-2]
+% aclwuptc :accumulated clear-sky upwelling longwave flux at top-of-atmosphere [J m-2]
% lwdnflx :
% lwdnflxc :
% lwupflx :
@@ -623,6 +670,24 @@
% olrtoa :outgoing longwave radiation at top-of-the-atmosphere [W m-2]
% rthratenlw:uncoupled theta tendency due to longwave radiation [K s-1]
+% i_aclwdnb : counter related to how often lwdnb is begin reset relative to its bucket value (-)
+% i_aclwdnbc: counter related to how often lwdnbc is begin reset relative to its bucket value (-)
+% i_aclwdnt : counter related to how often lwdnt is begin reset relative to its bucket value (-)
+% i_aclwdntc: counter related to how often lwdntc is begin reset relative to its bucket value (-)
+% i_aclwupb : counter related to how often lwupb is begin reset relative to its bucket value (-)
+% i_aclwupbc: counter related to how often lwupbc is begin reset relative to its bucket value (-)
+% i_aclwupt : counter related to how often lwupt is begin reset relative to its bucket value (-)
+% i_aclwuptc: counter related to how often lwuptc is begin reset relative to its bucket value (-)
+
+var persistent integer i_aclwdnb ( nCells Time ) 1 ro i_aclwdnb diag_physics - -
+var persistent integer i_aclwdnbc ( nCells Time ) 1 ro i_aclwdnbc diag_physics - -
+var persistent integer i_aclwdnt ( nCells Time ) 1 ro i_aclwdnt diag_physics - -
+var persistent integer i_aclwdntc ( nCells Time ) 1 ro i_aclwdntc diag_physics - -
+var persistent integer i_aclwupb ( nCells Time ) 1 ro i_aclwupb diag_physics - -
+var persistent integer i_aclwupbc ( nCells Time ) 1 ro i_aclwupbc diag_physics - -
+var persistent integer i_aclwupt ( nCells Time ) 1 ro i_aclwupt diag_physics - -
+var persistent integer i_aclwuptc ( nCells Time ) 1 ro i_aclwuptc diag_physics - -
+
var persistent real lwcf ( nCells Time ) 1 o lwcf diag_physics - -
var persistent real lwdnb ( nCells Time ) 1 o lwdnb diag_physics - -
var persistent real lwdnbc ( nCells Time ) 1 o lwdnbc diag_physics - -
@@ -632,6 +697,14 @@
var persistent real lwupbc ( nCells Time ) 1 o lwupbc diag_physics - -
var persistent real lwupt ( nCells Time ) 1 o lwupt diag_physics - -
var persistent real lwuptc ( nCells Time ) 1 o lwuptc diag_physics - -
+var persistent real aclwdnb ( nCells Time ) 1 ro aclwdnb diag_physics - -
+var persistent real aclwdnbc ( nCells Time ) 1 ro aclwdnbc diag_physics - -
+var persistent real aclwdnt ( nCells Time ) 1 ro aclwdnt diag_physics - -
+var persistent real aclwdntc ( nCells Time ) 1 ro aclwdntc diag_physics - -
+var persistent real aclwupb ( nCells Time ) 1 ro aclwupb diag_physics - -
+var persistent real aclwupbc ( nCells Time ) 1 ro aclwupbc diag_physics - -
+var persistent real aclwupt ( nCells Time ) 1 ro aclwupt diag_physics - -
+var persistent real aclwuptc ( nCells Time ) 1 ro aclwuptc diag_physics - -
var persistent real olrtoa ( nCells Time ) 1 o olrtoa diag_physics - -
var persistent real glw ( nCells Time ) 1 ro glw diag_physics - -
@@ -648,9 +721,9 @@
%--------------------------------------------------------------------------------------------------
%INFRARED ABSORPTION:
-var persistent real absnxt ( nVertLevels cam_dim1 nCells Time ) 1 - absnxt diag_physics - -
-var persistent real abstot ( nVertLevelsP1 nVertLevelsP1 nCells Time ) 1 - abstot diag_physics - -
-var persistent real emstot ( nVertLevelsP1 nCells Time ) 1 - emstot diag_physics - -
+var persistent real absnxt ( nVertLevels cam_dim1 nCells Time ) 1 r absnxt diag_physics - -
+var persistent real abstot ( nVertLevelsP1 nVertLevelsP1 nCells Time ) 1 r abstot diag_physics - -
+var persistent real emstot ( nVertLevelsP1 nCells Time ) 1 r emstot diag_physics - -
% OZONE:
var persistent real pin ( nOznLevels nCells ) 0 - pin mesh - -
Modified: branches/omp_blocks/io/src/core_nhyd_atmos/mpas_atm_mpas_core.F
===================================================================
--- branches/omp_blocks/io/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -493,11 +493,6 @@
call atm_timestep(domain, dt, timeStamp, itimestep)
-#ifdef DO_PHYSICS
- !update physics diagnostics at the end of dynamic time-step:
- if(moist_physics) call physics_update(domain,dt)
-#endif
-
end subroutine atm_do_timestep
Modified: branches/omp_blocks/io/src/core_nhyd_atmos/mpas_atm_time_integration.F
===================================================================
--- branches/omp_blocks/io/src/core_nhyd_atmos/mpas_atm_time_integration.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_nhyd_atmos/mpas_atm_time_integration.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -98,10 +98,7 @@
real (kind=RKIND) :: domain_mass, scalar_mass, scalar_min, scalar_max
real (kind=RKIND) :: global_domain_mass, global_scalar_mass, global_scalar_min, global_scalar_max
- integer :: iDeleteMe, jDeleteMe, kDeleteMe
- type (exchange_list), pointer :: deleteMePtr
-
!
! Initialize RK weights
!
@@ -365,11 +362,24 @@
block => block % next
end do
-!... call to parameterizations of cloud microphysics:
+!... call to parameterizations of cloud microphysics. calculation of the tendency of water vapor to horizontal and
+!... vertical advection needed for the Tiedtke parameterization of convection.
#ifdef DO_PHYSICS
block => domain % blocklist
do while(associated(block))
+ !NOTE: The calculation of the tendency due to horizontal and vertical advection for the water vapor mixing ratio
+ !requires that the subroutine atm_advance_scalars_mono was called on the third Runge Kutta step, so that a halo
+ !update for the scalars at time_levs(1) is applied. A halo update for the scalars at time_levs(2) is done above.
+ if(config_monotonic) then
+ block % tend_physics % rqvdynten % array(:,:) = &
+ ( block % state % time_levs(2) % state % scalars % array(block % state % time_levs(2) % state % index_qv,:,:) &
+ - block % state % time_levs(1) % state % scalars % array(block % state % time_levs(1) % state % index_qv,:,:) ) &
+ / config_dt
+ else
+ block % tend_physics % rqvdynten % array(:,:) = 0._RKIND
+ endif
+
!simply set to zero negative mixing ratios of different water species (for now):
where ( block % state % time_levs(2) % state % scalars % array(:,:,:) .lt. 0.) &
block % state % time_levs(2) % state % scalars % array(:,:,:) = 0.
@@ -1690,8 +1700,8 @@
!
tempField % block => block
- tempField % dims(1) = grid % nVertLevels
- tempField % dims(2) = grid % nCells
+ tempField % dimSizes(1) = grid % nVertLevels
+ tempField % dimSizes(2) = grid % nCells
tempField % sendList => block % parinfo % cellsToSend
tempField % recvList => block % parinfo % cellsToRecv
Modified: branches/omp_blocks/io/src/core_ocean/Makefile
===================================================================
--- branches/omp_blocks/io/src/core_ocean/Makefile        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/Makefile        2012-03-20 02:01:44 UTC (rev 1679)
@@ -36,6 +36,15 @@
         mpas_ocn_vmix_coefs_tanh.o \
         mpas_ocn_restoring.o \
         mpas_ocn_tendency.o \
+         mpas_ocn_tracer_advection.o \
+         mpas_ocn_tracer_advection_std.o \
+         mpas_ocn_tracer_advection_std_hadv.o \
+         mpas_ocn_tracer_advection_std_vadv.o \
+         mpas_ocn_tracer_advection_std_vadv2.o \
+         mpas_ocn_tracer_advection_std_vadv3.o \
+         mpas_ocn_tracer_advection_std_vadv4.o \
+         mpas_ocn_tracer_advection_mono.o \
+         mpas_ocn_tracer_advection_helpers.o \
mpas_ocn_time_integration.o \
mpas_ocn_time_integration_rk4.o \
mpas_ocn_time_integration_split.o \
@@ -120,6 +129,24 @@
mpas_ocn_tracer_hmix_del4.o:
+mpas_ocn_tracer_advection.o: mpas_ocn_tracer_advection_std.o mpas_ocn_tracer_advection_mono.o
+
+mpas_ocn_tracer_advection_std.o: mpas_ocn_tracer_advection_std_hadv.o mpas_ocn_tracer_advection_std_vadv.o
+
+mpas_ocn_tracer_advection_std_hadv.o: mpas_ocn_tracer_advection_helpers.o
+
+mpas_ocn_tracer_advection_std_vadv.o: mpas_ocn_tracer_advection_std_vadv2.o mpas_ocn_tracer_advection_std_vadv3.o mpas_ocn_tracer_advection_std_vadv4.o
+
+mpas_ocn_tracer_advection_std_vadv2.o: mpas_ocn_tracer_advection_helpers.o
+
+mpas_ocn_tracer_advection_std_vadv3.o: mpas_ocn_tracer_advection_helpers.o
+
+mpas_ocn_tracer_advection_std_vadv4.o: mpas_ocn_tracer_advection_helpers.o
+
+mpas_ocn_tracer_advection_mono.o: mpas_ocn_tracer_advection_helpers.o
+
+mpas_ocn_tracer_advection_helpers.o:
+
mpas_ocn_restoring.o:
mpas_ocn_vmix.o: mpas_ocn_vmix_coefs_const.o mpas_ocn_vmix_coefs_rich.o mpas_ocn_vmix_coefs_tanh.o
@@ -170,6 +197,15 @@
                                         mpas_ocn_vmix_coefs_rich.o \
                                         mpas_ocn_vmix_coefs_tanh.o \
                                         mpas_ocn_restoring.o \
+                                         mpas_ocn_tracer_advection.o \
+                                         mpas_ocn_tracer_advection_std.o \
+                                         mpas_ocn_tracer_advection_std_hadv.o \
+                                         mpas_ocn_tracer_advection_std_vadv.o \
+                                         mpas_ocn_tracer_advection_std_vadv2.o \
+                                         mpas_ocn_tracer_advection_std_vadv3.o \
+                                         mpas_ocn_tracer_advection_std_vadv4.o \
+                                         mpas_ocn_tracer_advection_mono.o \
+                                         mpas_ocn_tracer_advection_helpers.o \
                                         mpas_ocn_tendency.o \
                                         mpas_ocn_time_integration.o \
                                         mpas_ocn_time_integration_rk4.o \
Modified: branches/omp_blocks/io/src/core_ocean/Registry
===================================================================
--- branches/omp_blocks/io/src/core_ocean/Registry        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/Registry        2012-03-20 02:01:44 UTC (rev 1679)
@@ -5,12 +5,14 @@
namelist character sw_model config_time_integration RK4
namelist logical sw_model config_rk_filter_btr_mode false
namelist real sw_model config_dt 172.8
-namelist integer sw_model config_calendar_type MPAS_360DAY
+namelist character sw_model config_calendar_type 360day
namelist character sw_model config_start_time 0000-01-01_00:00:00
namelist character sw_model config_stop_time none
namelist character sw_model config_run_duration none
namelist integer sw_model config_stats_interval 100
namelist logical sw_model config_initial_stats false
+namelist logical sw_model config_prescribe_velocity false
+namelist logical sw_model config_prescribe_thickness false
namelist character io config_input_name grid.nc
namelist character io config_output_name output.nc
namelist character io config_restart_name restart.nc
@@ -47,9 +49,9 @@
namelist logical hmix config_include_KE_vertex false
namelist real hmix config_h_tracer_eddy_diff2 0.0
namelist real hmix config_h_tracer_eddy_diff4 0.0
-namelist real hmix config_apvm_upwinding 0.5
namelist logical hmix config_rayleigh_friction false
namelist real hmix config_rayleigh_damping_coeff 0.0
+namelist real hmix config_apvm_scale_factor 0.0
namelist character vmix config_vert_visc_type const
namelist character vmix config_vert_diff_type const
namelist logical vmix config_implicit_vertical_mix .true.
@@ -69,11 +71,12 @@
namelist real vmix_tanh config_zWidth_tanh 100
namelist character eos config_eos_type linear
namelist character advection config_vert_tracer_adv stencil
-namelist integer advection config_vert_tracer_adv_order 4
-namelist integer advection config_tracer_adv_order 2
+namelist integer advection config_vert_tracer_adv_order 4
+namelist integer advection config_horiz_tracer_adv_order 2
namelist integer advection config_thickness_adv_order 2
-namelist logical advection config_positive_definite false
+namelist real advection config_coef_3rd_order 0.25
namelist logical advection config_monotonic false
+namelist logical advection config_check_monotonicity false
namelist logical restore config_restoreTS false
namelist real restore config_restoreT_timescale 90.0
namelist real restore config_restoreS_timescale 90.0
@@ -85,6 +88,7 @@
dim nEdges nEdges
dim maxEdges maxEdges
dim maxEdges2 maxEdges2
+dim nAdvectionCells maxEdges2+0
dim nVertices nVertices
dim TWO 2
dim R3 3
@@ -152,9 +156,17 @@
var persistent real h_s ( nCells ) 0 iro h_s mesh - -
% Space needed for advection
-var persistent real deriv_two ( FIFTEEN TWO nEdges ) 0 - deriv_two mesh - -
-var persistent integer advCells ( TWENTYONE nCells ) 0 - advCells mesh - -
+var persistent real deriv_two ( maxEdges2 TWO nEdges ) 0 - deriv_two mesh - -
+% Added for monotonic advection scheme
+var persistent real adv_coefs ( nAdvectionCells nEdges ) 0 - adv_coefs mesh - -
+var persistent real adv_coefs_2nd ( nAdvectionCells nEdges ) 0 - adv_coefs_2nd mesh - -
+var persistent real adv_coefs_3rd ( nAdvectionCells nEdges ) 0 - adv_coefs_3rd mesh - -
+var persistent integer advCellsForEdge ( nAdvectionCells nEdges ) 0 - advCellsForEdge mesh - -
+var persistent integer nAdvCellsForEdge ( nEdges ) 0 - nAdvCellsForEdge mesh - -
+var persistent integer highOrderAdvectionMask ( nVertLevels nEdges ) 0 - highOrderAdvectionMask mesh - -
+var persistent integer lowOrderAdvectionMask ( nVertLevels nEdges ) 0 - lowOrderAdvectionMask mesh - -
+
% !! NOTE: the following arrays are needed to allow the use
% !! of the module_advection.F w/o alteration
% Space needed for deformation calculation weights
@@ -216,15 +228,15 @@
var persistent real v ( nVertLevels nEdges Time ) 2 - v state - -
var persistent real divergence ( nVertLevels nCells Time ) 2 o divergence state - -
var persistent real vorticity ( nVertLevels nVertices Time ) 2 o vorticity state - -
-var persistent real pv_edge ( nVertLevels nEdges Time ) 2 - pv_edge state - -
+var persistent real Vor_edge ( nVertLevels nEdges Time ) 2 - Vor_edge state - -
var persistent real h_edge ( nVertLevels nEdges Time ) 2 - h_edge state - -
var persistent real h_vertex ( nVertLevels nVertices Time ) 2 - h_vertex state - -
var persistent real ke ( nVertLevels nCells Time ) 2 o ke state - -
var persistent real kev ( nVertLevels nVertices Time ) 2 o kev state - -
var persistent real kevc ( nVertLevels nCells Time ) 2 o kevc state - -
var persistent real ke_edge ( nVertLevels nEdges Time ) 2 - ke_edge state - -
-var persistent real pv_vertex ( nVertLevels nVertices Time ) 2 - pv_vertex state - -
-var persistent real pv_cell ( nVertLevels nCells Time ) 2 - pv_cell state - -
+var persistent real Vor_vertex ( nVertLevels nVertices Time ) 2 - Vor_vertex state - -
+var persistent real Vor_cell ( nVertLevels nCells Time ) 2 o Vor_cell state - -
var persistent real uReconstructX ( nVertLevels nCells Time ) 2 - uReconstructX state - -
var persistent real uReconstructY ( nVertLevels nCells Time ) 2 - uReconstructY state - -
var persistent real uReconstructZ ( nVertLevels nCells Time ) 2 - uReconstructZ state - -
@@ -238,8 +250,8 @@
% Other diagnostic variables: neither read nor written to any files
var persistent real vh ( nVertLevels nEdges Time ) 2 - vh state - -
var persistent real circulation ( nVertLevels nVertices Time ) 2 - circulation state - -
-var persistent real gradPVt ( nVertLevels nEdges Time ) 2 - gradPVt state - -
-var persistent real gradPVn ( nVertLevels nEdges Time ) 2 - gradPVn state - -
+var persistent real gradVor_t ( nVertLevels nEdges Time ) 2 - gradVor_t state - -
+var persistent real gradVor_n ( nVertLevels nEdges Time ) 2 - gradVor_n state - -
% Globally reduced diagnostic variables: only written to output
var persistent real areaCellGlobal ( Time ) 2 o areaCellGlobal state - -
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_advection.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_advection.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_advection.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -9,19 +9,25 @@
contains
- subroutine ocn_initialize_advection_rk( grid )!{{{
+ subroutine ocn_initialize_advection_rk( grid, err )!{{{
!
! compute the cell coefficients for the polynomial fit.
! this is performed during setup for model integration.
! WCS, 31 August 2009
!
+! Described in:
+! Skamarock, W. C., & Gassmann, A. (2011).
+! Conservative Transport Schemes for Spherical Geodesic Grids: High-Order Flux Operators for ODE-Based Time Integration.
+! Monthly Weather Review, 139(9), 2962-2975. doi:10.1175/MWR-D-10-05056.1
+!
implicit none
type (mesh_type), intent(in) :: grid
+ integer, intent(out) :: err
real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
- integer, dimension(:,:), pointer :: advCells
+ integer, dimension(:), pointer :: advCells
! local variables
@@ -50,9 +56,7 @@
integer :: cell1, cell2
integer, parameter :: polynomial_order = 2
-! logical, parameter :: debug = .true.
logical, parameter :: debug = .false.
-! logical, parameter :: least_squares = .false.
logical, parameter :: least_squares = .true.
logical :: add_the_cell, do_the_cell
@@ -61,11 +65,19 @@
real (kind=RKIND) :: rcell, cos2t, costsint, sin2t
real (kind=RKIND), dimension(grid%maxEdges) :: angle_2d
-!---
+!---
+ err = 0
+ if(polynomial_order > 2) then
+ write (*,*) 'Polynomial for second derivitave can only be 2'
+ err = 1
+ return
+ end if
+
pii = 2.*asin(1.0)
- advCells => grid % advCells % array
+! advCells => grid % advCells % array
+ allocate(advCells(grid % maxEdges2))
deriv_two => grid % deriv_two % array
deriv_two(:,:,:) = 0.
@@ -93,7 +105,7 @@
end do
end if
- advCells(1,iCell) = n
+ advCells(1) = n
! check to see if we are reaching outside the halo
@@ -110,10 +122,10 @@
if ( grid % on_a_sphere ) then
do i=1,n
- advCells(i+1,iCell) = cell_list(i)
- xc(i) = grid % xCell % array(advCells(i+1,iCell))/a
- yc(i) = grid % yCell % array(advCells(i+1,iCell))/a
- zc(i) = grid % zCell % array(advCells(i+1,iCell))/a
+ advCells(i+1) = cell_list(i)
+ xc(i) = grid % xCell % array(advCells(i+1))/a
+ yc(i) = grid % yCell % array(advCells(i+1))/a
+ zc(i) = grid % zCell % array(advCells(i+1))/a
end do
theta_abs(iCell) = pii/2. - sphere_angle( xc(1), yc(1), zc(1), &
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_global_diagnostics.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_global_diagnostics.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_global_diagnostics.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -46,8 +46,8 @@
real (kind=RKIND) :: volumeCellGlobal, volumeEdgeGlobal, CFLNumberGlobal, localCFL, localSum, areaCellGlobal, areaEdgeGlobal, areaTriangleGlobal
real (kind=RKIND), dimension(:), pointer :: areaCell, dcEdge, dvEdge, areaTriangle, areaEdge
- real (kind=RKIND), dimension(:,:), pointer :: h, u, v, h_edge, circulation, vorticity, ke, pv_edge, pv_vertex, &
- pv_cell, gradPVn, gradPVt, pressure, MontPot, wTop, rho, tracerTemp
+ real (kind=RKIND), dimension(:,:), pointer :: h, u, v, h_edge, circulation, vorticity, ke, Vor_edge, Vor_vertex, &
+ Vor_cell, gradVor_n, gradVor_t, pressure, MontPot, wTop, rho, tracerTemp
real (kind=RKIND), dimension(:,:,:), pointer :: tracers
real (kind=RKIND), dimension(kMaxVariables) :: sums, mins, maxes, averages, verticalSumMins, verticalSumMaxes, reductions
@@ -93,11 +93,11 @@
circulation => state % circulation % array
vorticity => state % vorticity % array
ke => state % ke % array
- pv_edge => state % pv_edge % array
- pv_vertex => state % pv_vertex % array
- pv_cell => state % pv_cell % array
- gradPVn => state % gradPVn % array
- gradPVt => state % gradPVt % array
+ Vor_edge => state % Vor_edge % array
+ Vor_vertex => state % Vor_vertex % array
+ Vor_cell => state % Vor_cell % array
+ gradVor_n => state % gradVor_n % array
+ gradVor_t => state % gradVor_t % array
MontPot => state % MontPot % array
pressure => state % pressure % array
@@ -176,10 +176,10 @@
verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
- ! pv_edge
+ ! Vor_edge
variableIndex = variableIndex + 1
call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &
- pv_edge(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
+ Vor_edge(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
verticalSumMaxes_tmp(variableIndex))
sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -187,10 +187,10 @@
verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
- ! pv_vertex
+ ! Vor_vertex
variableIndex = variableIndex + 1
call ocn_compute_field_area_weighted_local_stats(dminfo, nVertLevels, nVerticesSolve, areaTriangle(1:nVerticesSolve), &
- pv_vertex(:,1:nVerticesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), &
+ Vor_vertex(:,1:nVerticesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), &
verticalSumMins_tmp(variableIndex), verticalSumMaxes_tmp(variableIndex))
sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -198,10 +198,10 @@
verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
- ! pv_cell
+ ! Vor_cell
variableIndex = variableIndex + 1
call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nCellsSolve, areaCell(1:nCellsSolve), h(:,1:nCellsSolve), &
- pv_cell(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
+ Vor_cell(:,1:nCellsSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
verticalSumMaxes_tmp(variableIndex))
sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -209,10 +209,10 @@
verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
- ! gradPVn
+ ! gradVor_n
variableIndex = variableIndex + 1
call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &
- gradPVn(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
+ gradVor_n(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
verticalSumMaxes_tmp(variableIndex))
sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -220,10 +220,10 @@
verticalSumMins(variableIndex) = min(verticalSumMins(variableIndex), verticalSumMins_tmp(variableIndex))
verticalSumMaxes(variableIndex) = max(verticalSumMaxes(variableIndex), verticalSumMaxes_tmp(variableIndex))
- ! gradPVt
+ ! gradVor_t
variableIndex = variableIndex + 1
call ocn_compute_field_volume_weighted_local_stats(dminfo, nVertLevels, nEdgesSolve, areaEdge(1:nEdgesSolve), h_edge(:,1:nEdgesSolve), &
- gradPVt(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
+ gradVor_t(:,1:nEdgesSolve), sums_tmp(variableIndex), mins_tmp(variableIndex), maxes_tmp(variableIndex), verticalSumMins_tmp(variableIndex), &
verticalSumMaxes_tmp(variableIndex))
sums(variableIndex) = sums(variableIndex) + sums_tmp(variableIndex)
mins(variableIndex) = min(mins(variableIndex), mins_tmp(variableIndex))
@@ -374,23 +374,23 @@
variableIndex = variableIndex + 1
averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
- ! pv_edge
+ ! Vor_edge
variableIndex = variableIndex + 1
averages(variableIndex) = sums(variableIndex)/volumeEdgeGlobal
- ! pv_vertex
+ ! Vor_vertex
variableIndex = variableIndex + 1
averages(variableIndex) = sums(variableIndex)/(areaTriangleGlobal*nVertLevels)
- ! pv_cell
+ ! Vor_cell
variableIndex = variableIndex + 1
averages(variableIndex) = sums(variableIndex)/volumeCellGlobal
- ! gradPVn
+ ! gradVor_n
variableIndex = variableIndex + 1
averages(variableIndex) = sums(variableIndex)/volumeEdgeGlobal
- ! gradPVt
+ ! gradVor_t
variableIndex = variableIndex + 1
averages(variableIndex) = sums(variableIndex)/volumeEdgeGlobal
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_mpas_core.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_mpas_core.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -45,6 +45,7 @@
subroutine mpas_core_init(domain, startTimeStamp)!{{{
use mpas_grid_types
+ use mpas_ocn_tracer_advection
implicit none
@@ -88,6 +89,9 @@
call ocn_tendency_init(err_tmp)
err = ior(err,err_tmp)
+ call mpas_ocn_tracer_advection_init(err_tmp)
+ err = ior(err,err_tmp)
+
call mpas_timer_init(domain)
if(err.eq.1) then
@@ -134,7 +138,10 @@
block => domain % blocklist
do while (associated(block))
- call mpas_init_block(block, block % mesh, dt)
+ call mpas_init_block(block, block % mesh, dt, err)
+ if(err.eq.1) then
+ call mpas_dmpar_abort(dminfo)
+ endif
block % state % time_levs(1) % state % xtime % scalar = startTimeStamp
block => block % next
end do
@@ -213,19 +220,27 @@
end subroutine ocn_simulation_clock_init!}}}
- subroutine mpas_init_block(block, mesh, dt)!{{{
+ subroutine mpas_init_block(block, mesh, dt, err)!{{{
use mpas_grid_types
use mpas_rbf_interpolation
use mpas_vector_reconstruction
+ use mpas_ocn_tracer_advection
+ use ocn_advection
implicit none
type (block_type), intent(inout) :: block
type (mesh_type), intent(inout) :: mesh
real (kind=RKIND), intent(in) :: dt
+ integer, intent(out) :: err
integer :: i, iEdge, iCell, k
+ integer :: err1
+ call ocn_initialize_advection_rk(mesh, err)
+ call mpas_ocn_tracer_advection_coefficients(mesh, err1)
+ err = ior(err, err1)
+
call ocn_time_average_init(block % state % time_levs(1) % state)
call mpas_timer_start("diagnostic solve", .false., initDiagSolveTimer)
@@ -272,29 +287,13 @@
:block % mesh % nVertLevels,iCell) = 0.0
! mrp changed to 0
! :block % mesh % nVertLevels,iCell) = -1e34
-
-! mrp 110516, added just to test for conservation of tracers
- block % state % time_levs(1) % state % tracers % array(block % state % time_levs(1) % state % index_tracer1,:,iCell) = 1.0
-
end do
- if (.not. config_do_restart) then
-
-! mrp 110808 add, so that variables are copied to * variables for split explicit
- do i=2,nTimeLevs
- call mpas_copy_state(block % state % time_levs(i) % state, &
+ do i=2,nTimeLevs
+ call mpas_copy_state(block % state % time_levs(i) % state, &
block % state % time_levs(1) % state)
- end do
-! mrp 110808 add end
+ end do
-
- else
- do i=2,nTimeLevs
- call mpas_copy_state(block % state % time_levs(i) % state, &
- block % state % time_levs(1) % state)
- end do
- endif
-
end subroutine mpas_init_block!}}}
subroutine mpas_core_run(domain, output_obj, output_frame)!{{{
@@ -508,8 +507,8 @@
integer :: iTracer, cell, cell1, cell2
real (kind=RKIND) :: uhSum, hSum, hEdge1
- real (kind=RKIND), dimension(:), pointer :: &
- referenceBottomDepth, referenceBottomDepthTopOfCell
+ real (kind=RKIND), dimension(:), pointer :: referenceBottomDepth, referenceBottomDepthTopOfCell
+
real (kind=RKIND), dimension(:,:), pointer :: h
integer :: nVertLevels
@@ -732,8 +731,12 @@
if (boundaryEdge(k,iEdge).eq.1) then
boundaryCell(k,cellsOnEdge(1,iEdge)) = 1
boundaryCell(k,cellsOnEdge(2,iEdge)) = 1
- cellMask(k,cellsOnEdge(1,iEdge)) = 0
- cellMask(k,cellsOnEdge(2,iEdge)) = 0
+ if(maxLevelCell(cellsOnEdge(1,iEdge)) > k) then
+ cellMask(k, cellsOnEdge(1,iEdge)) = 0
+ end if
+ if(maxLevelCell(cellsOnEdge(2,iEdge)) > k) then
+ cellMask(k, cellsOnEdge(2,iEdge)) = 0
+ end if
boundaryVertex(k,verticesOnEdge(1,iEdge)) = 1
boundaryVertex(k,verticesOnEdge(2,iEdge)) = 1
vertexMask(k,verticesOnEdge(1,iEdge)) = 0
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tendency.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tendency.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tendency.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -21,6 +21,8 @@
use mpas_constants
use mpas_timer
+ use mpas_ocn_tracer_advection
+
use ocn_thick_hadv
use ocn_thick_vadv
@@ -97,22 +99,12 @@
!
!-----------------------------------------------------------------------
- subroutine ocn_tend_h(tend, s, d, grid)!{{{
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ! Compute height and normal wind tendencies, as well as diagnostic variables
- !
- ! Input: s - current model state
- ! grid - grid metadata
- !
- ! Output: tend - computed tendencies for prognostic variables
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
+ subroutine ocn_tend_h(tend, s, grid)!{{{
implicit none
- type (tend_type), intent(inout) :: tend
- type (state_type), intent(in) :: s
- type (diagnostics_type), intent(in) :: d
- type (mesh_type), intent(in) :: grid
+ type (tend_type), intent(inout) :: tend !< Input/Output: Tendency structure
+ type (state_type), intent(in) :: s !< Input: State information
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
real (kind=RKIND), dimension(:,:), pointer :: h_edge, u, wTop, tend_h
@@ -166,25 +158,16 @@
!-----------------------------------------------------------------------
subroutine ocn_tend_u(tend, s, d, grid)!{{{
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ! Compute height and normal wind tendencies, as well as diagnostic variables
- !
- ! Input: s - current model state
- ! grid - grid metadata
- !
- ! Output: tend - computed tendencies for prognostic variables
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
implicit none
- type (tend_type), intent(inout) :: tend
- type (state_type), intent(in) :: s
- type (diagnostics_type), intent(in) :: d
- type (mesh_type), intent(in) :: grid
+ type (tend_type), intent(inout) :: tend !< Input/Output: Tendency structure
+ type (state_type), intent(in) :: s !< Input: State information
+ type (diagnostics_type), intent(in) :: d !< Input: Diagnostic information
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
real (kind=RKIND), dimension(:,:), pointer :: &
h_edge, h, u, rho, zMid, pressure, &
- tend_u, circulation, vorticity, ke, ke_edge, pv_edge, &
+ tend_u, circulation, vorticity, ke, ke_edge, Vor_edge, &
MontPot, wTop, divergence, vertViscTopOfEdge
real (kind=RKIND), dimension(:,:), pointer :: u_src
@@ -202,7 +185,7 @@
divergence => s % divergence % array
ke => s % ke % array
ke_edge => s % ke_edge % array
- pv_edge => s % pv_edge % array
+ Vor_edge => s % Vor_edge % array
MontPot => s % MontPot % array
pressure => s % pressure % array
vertViscTopOfEdge => d % vertViscTopOfEdge % array
@@ -222,7 +205,7 @@
!
call mpas_timer_start("coriolis", .false., velCorTimer)
- call ocn_vel_coriolis_tend(grid, pv_edge, h_edge, u, ke, tend_u, err)
+ call ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, u, ke, tend_u, err)
call mpas_timer_stop("coriolis", velCorTimer)
!
@@ -286,31 +269,21 @@
!> This routine computes the scalar (tracer) tendency for the ocean
!
!-----------------------------------------------------------------------
-
- subroutine ocn_tend_scalar(tend, s, d, grid)!{{{
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !
- ! Input: s - current model state
- ! grid - grid metadata
- ! note: the variable s % tracers really contains the tracers,
- ! not tracers*h
- !
- ! Output: tend - computed scalar tendencies
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
+ subroutine ocn_tend_scalar(tend, s, d, grid, dt)!{{{
implicit none
- type (tend_type), intent(inout) :: tend
- type (state_type), intent(in) :: s
- type (diagnostics_type), intent(in) :: d
- type (mesh_type), intent(in) :: grid
+ type (tend_type), intent(inout) :: tend !< Input/Output: Tendency structure
+ type (state_type), intent(in) :: s !< Input: State information
+ type (diagnostics_type), intent(in) :: d !< Input: Diagnostic information
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+ real (kind=RKIND), intent(in) :: dt !< Input: Time step
real (kind=RKIND), dimension(:,:), pointer :: &
- u,h,wTop, h_edge, vertDiffTopOfCell
+ u, h,wTop, h_edge, vertDiffTopOfCell, tend_h, uh
real (kind=RKIND), dimension(:,:,:), pointer :: &
tracers, tend_tr
- integer :: err
+ integer :: err, iEdge, k
call mpas_timer_start("ocn_tend_scalar")
@@ -322,7 +295,16 @@
vertDiffTopOfCell => d % vertDiffTopOfCell % array
tend_tr => tend % tracers % array
+ tend_h => tend % h % array
+ allocate(uh(grid % nVertLevels, grid % nEdges+1))
+
+ do iEdge = 1, grid % nEdges
+ do k = 1, grid % nVertLevels
+ uh(k, iEdge) = u(k, iEdge) * h_edge(k, iEdge)
+ end do
+ end do
+
!
! initialize tracer tendency (RHS of tracer equation) to zero.
!
@@ -336,20 +318,13 @@
! and then change maxLevelEdgeTop to maxLevelEdgeBot in the following section.
! tracer_edge at the boundary will also need to be defined for flux boundaries.
- call mpas_timer_start("hadv", .false., tracerHadvTimer)
- call ocn_tracer_hadv_tend(grid, u, h_edge, tracers, tend_tr, err)
- call mpas_timer_stop("hadv", tracerHadvTimer)
+ ! Monotonoic Advection, or standard advection
+ call mpas_timer_start("adv", .false., tracerHadvTimer)
+ call mpas_ocn_tracer_advection_tend(tracers, uh, wTop, h, h, dt, grid, tend_h, tend_tr)
+ call mpas_timer_stop("adv", tracerHadvTimer)
!
- ! tracer tendency: vertical advection term -d/dz( h \phi w)
- !
-
- call mpas_timer_start("vadv", .false., tracerVadvTimer)
- call ocn_tracer_vadv_tend(grid, h, wtop, tracers, tend_tr, err)
- call mpas_timer_stop("vadv", tracerVadvTimer)
-
- !
! tracer tendency: del2 horizontal tracer diffusion, div(h \kappa_2 </font>
<font color="gray">abla \phi)
!
call mpas_timer_start("hmix", .false., tracerHmixTimer)
@@ -391,6 +366,8 @@
10 format(2i8,10e20.10)
call mpas_timer_stop("ocn_tend_scalar")
+ deallocate(uh)
+
end subroutine ocn_tend_scalar!}}}
!***********************************************************************
@@ -407,19 +384,11 @@
!-----------------------------------------------------------------------
subroutine ocn_diagnostic_solve(dt, s, grid)!{{{
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ! Compute diagnostic fields used in the tendency computations
- !
- ! Input: grid - grid metadata
- !
- ! Output: s - computed diagnostics
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
implicit none
- real (kind=RKIND), intent(in) :: dt
- type (state_type), intent(inout) :: s
- type (mesh_type), intent(in) :: grid
+ real (kind=RKIND), intent(in) :: dt !< Input: Time step
+ type (state_type), intent(inout) :: s !< Input/Output: State information
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j
@@ -441,7 +410,7 @@
real (kind=RKIND), dimension(:,:), pointer :: &
weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, pressure,&
circulation, vorticity, ke, ke_edge, MontPot, wTop, zMid, &
- pv_edge, pv_vertex, pv_cell, gradPVn, gradPVt, divergence, &
+ Vor_edge, Vor_vertex, Vor_cell, gradVor_n, gradVor_t, divergence, &
rho, temperature, salinity, kev, kevc
real (kind=RKIND), dimension(:,:,:), pointer :: tracers, deriv_two
real (kind=RKIND), dimension(:,:), allocatable:: div_u
@@ -458,11 +427,11 @@
kev => s % kev % array
kevc => s % kevc % array
ke_edge => s % ke_edge % array
- pv_edge => s % pv_edge % array
- pv_vertex => s % pv_vertex % array
- pv_cell => s % pv_cell % array
- gradPVn => s % gradPVn % array
- gradPVt => s % gradPVt % array
+ Vor_edge => s % Vor_edge % array
+ Vor_vertex => s % Vor_vertex % array
+ Vor_cell => s % Vor_cell % array
+ gradVor_n => s % gradVor_n % array
+ gradVor_t => s % gradVor_t % array
rho => s % rho % array
MontPot => s % MontPot % array
pressure => s % pressure % array
@@ -509,6 +478,7 @@
! initialize h_edge to avoid divide by zero and NaN problems.
h_edge = -1.0e34
+ coef_3rd_order = config_coef_3rd_order
do iEdge=1,nEdges*hadv2nd
cell1 = cellsOnEdge(1,iEdge)
@@ -609,8 +579,9 @@
invAreaTri1 = 1.0 / areaTriangle(vertex1)
invAreaTri2 = 1.0 / areaTriangle(vertex2)
- invAreaCell1 = 1.0 / areaCell(cell1)
- invAreaCell2 = 1.0 / areaCell(cell2)
+ !dwj: 02/23/12 arraCell(nCells+1) is still 0, this is a temporary fix
+ invAreaCell1 = 1.0 / max(areaCell(cell1), 1.0)
+ invAreaCell2 = 1.0 / max(areaCell(cell2), 1.0)
do k=1,maxLevelEdgeBot(iEdge)
! Compute circulation and relative vorticity at each vertex
@@ -663,7 +634,8 @@
do iVertex = 1, nVertices*ke_vertex_flag
do i=1,grid % vertexDegree
iCell = cellsOnVertex(i,iVertex)
- invAreaCell1 = 1.0 / areaCell(iCell)
+ !dwj: 02/23/12 arraCell(nCells+1) is still 0, this is a temporary fix
+ invAreaCell1 = 1.0 / max(areaCell(iCell), 1.0)
do k=1,nVertLevels
kevc(k,iCell) = kevc(k,iCell) + kiteAreasOnVertex(i, iVertex) * kev(k, iVertex) * invAreaCell1
enddo
@@ -694,7 +666,7 @@
!
! Compute height at vertices, pv at vertices, and average pv to edge locations
- ! ( this computes pv_vertex at all vertices bounding real cells and distance-1 ghost cells )
+ ! ( this computes Vor_vertex at all vertices bounding real cells and distance-1 ghost cells )
!
do iVertex = 1,nVertices
invAreaTri1 = 1.0 / areaTriangle(iVertex)
@@ -705,35 +677,36 @@
end do
h_vertex = h_vertex * invAreaTri1
- pv_vertex(k,iVertex) = (fCoef*fVertex(iVertex) + vorticity(k,iVertex)) / h_vertex
+ Vor_vertex(k,iVertex) = (fCoef*fVertex(iVertex) + vorticity(k,iVertex)) / h_vertex
end do
end do
- pv_cell(:,:) = 0.0
- pv_edge(:,:) = 0.0
+ Vor_cell(:,:) = 0.0
+ Vor_edge(:,:) = 0.0
do iVertex = 1,nVertices
do i=1,vertexDegree
iCell = cellsOnVertex(i,iVertex)
iEdge = edgesOnVertex(i,iVertex)
- invAreaCell1 = 1.0 / areaCell(iCell)
+ !dwj: 02/23/12 arraCell(nCells+1) is still 0, this is a temporary fix
+ invAreaCell1 = 1.0 / max(areaCell(iCell), 1.0)
! Compute pv at cell centers
- ! ( this computes pv_cell for all real cells and distance-1 ghost cells )
+ ! ( this computes Vor_cell for all real cells and distance-1 ghost cells )
do k = 1,maxLevelCell(iCell)
- pv_cell(k,iCell) = pv_cell(k,iCell) + kiteAreasOnVertex(i, iVertex) * pv_vertex(k, iVertex) * invAreaCell1
+ Vor_cell(k,iCell) = Vor_cell(k,iCell) + kiteAreasOnVertex(i, iVertex) * Vor_vertex(k, iVertex) * invAreaCell1
enddo
! Compute pv at the edges
- ! ( this computes pv_edge at all edges bounding real cells )
+ ! ( this computes Vor_edge at all edges bounding real cells )
do k=1,maxLevelEdgeBot(iEdge)
- pv_edge(k,iEdge) = pv_edge(k,iEdge) + 0.5 * pv_vertex(k,iVertex)
+ Vor_edge(k,iEdge) = Vor_edge(k,iEdge) + 0.5 * Vor_vertex(k,iVertex)
enddo
enddo
enddo
-! gradPVn(:,:) = 0.0
-! gradPVt(:,:) = 0.0
+! gradVor_n(:,:) = 0.0
+! gradVor_t(:,:) = 0.0
do iEdge = 1,nEdges
cell1 = cellsOnEdge(1, iEdge)
cell2 = cellsOnEdge(2, iEdge)
@@ -742,16 +715,16 @@
invLength = 1.0 / dcEdge(iEdge)
! Compute gradient of PV in normal direction
- ! ( this computes gradPVn for all edges bounding real cells )
+ ! ( this computes gradVor_n for all edges bounding real cells )
do k=1,maxLevelEdgeTop(iEdge)
- gradPVn(k,iEdge) = (pv_cell(k,cell2) - pv_cell(k,cell1)) * invLength
+ gradVor_n(k,iEdge) = (Vor_cell(k,cell2) - Vor_cell(k,cell1)) * invLength
enddo
invLength = 1.0 / dvEdge(iEdge)
! Compute gradient of PV in the tangent direction
- ! ( this computes gradPVt at all edges bounding real cells and distance-1 ghost cells )
+ ! ( this computes gradVor_t at all edges bounding real cells and distance-1 ghost cells )
do k = 1,maxLevelEdgeBot(iEdge)
- gradPVt(k,iEdge) = (pv_vertex(k,vertex2) - pv_vertex(k,vertex1)) * invLength
+ gradVor_t(k,iEdge) = (Vor_vertex(k,vertex2) - Vor_vertex(k,vertex1)) * invLength
enddo
enddo
@@ -761,9 +734,9 @@
!
do iEdge = 1,nEdges
do k = 1,maxLevelEdgeBot(iEdge)
- pv_edge(k,iEdge) = pv_edge(k,iEdge) &
- - 0.5 * dt* ( u(k,iEdge) * gradPVn(k,iEdge) &
- + v(k,iEdge) * gradPVt(k,iEdge) )
+ Vor_edge(k,iEdge) = Vor_edge(k,iEdge) &
+ - config_apvm_scale_factor * dt* ( u(k,iEdge) * gradVor_n(k,iEdge) &
+ + v(k,iEdge) * gradVor_t(k,iEdge) )
enddo
enddo
@@ -872,23 +845,13 @@
!> This routine computes the vertical velocity in the top layer for the ocean
!
!-----------------------------------------------------------------------
-
subroutine ocn_wtop(s1,s2, grid)!{{{
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ! Compute diagnostic fields used in the tendency computations
- !
- ! Input: grid - grid metadata
- !
- ! Output: s - computed diagnostics
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
implicit none
- type (state_type), intent(inout) :: s1
- type (state_type), intent(inout) :: s2
- type (mesh_type), intent(in) :: grid
+ type (state_type), intent(inout) :: s1 !< Input/Output: State 1 information
+ type (state_type), intent(inout) :: s2 !< Input/Output: State 2 information
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
- ! mrp 110512 could clean this out, remove pointers?
integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j, cov
real (kind=RKIND) :: flux, vorticity_abs, h_vertex, workpv, rho0Inv, hSum
@@ -1062,19 +1025,10 @@
!-----------------------------------------------------------------------
subroutine ocn_fuperp(s, grid)!{{{
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ! Put f*uBcl^{perp} in u as a work variable
- !
- ! Input: s - current model state
- ! grid - grid metadata
- !
- ! Output: tend - computed tendencies for prognostic variables
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
implicit none
- type (state_type), intent(inout) :: s
- type (mesh_type), intent(in) :: grid
+ type (state_type), intent(inout) :: s !< Input/Output: State information
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
! mrp 110512 I just split compute_tend into compute_tend_u and compute_tend_h.
! Some of these variables can be removed, but at a later time.
@@ -1137,9 +1091,8 @@
!> other tendency routines.
!
!-----------------------------------------------------------------------
-
subroutine ocn_tendency_init(err)!{{{
- integer, intent(out) :: err
+ integer, intent(out) :: err !< Output: Error flag
err = 0
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_time_integration_rk4.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_time_integration_rk4.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_time_integration_rk4.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -146,7 +146,7 @@
! --- update halos for diagnostic variables
call mpas_timer_start("RK4-diagnostic halo update")
- call mpas_dmpar_exch_halo_field(provis % pv_edge)
+ call mpas_dmpar_exch_halo_field(provis % Vor_edge)
if (config_h_mom_eddy_visc4 > 0.0) then
call mpas_dmpar_exch_halo_field(provis % divergence)
call mpas_dmpar_exch_halo_field(provis % vorticity)
@@ -165,7 +165,7 @@
if (.not.config_implicit_vertical_mix) then
call ocn_vmix_coefs(block % mesh, provis, block % diagnostics, err)
end if
- call ocn_tend_h(block % tend, provis, block % diagnostics, block % mesh)
+ call ocn_tend_h(block % tend, provis, block % mesh)
call ocn_tend_u(block % tend, provis, block % diagnostics, block % mesh)
! mrp 110718 filter btr mode out of u_tend
@@ -174,7 +174,7 @@
call filter_btr_mode_tend_u(block % tend, provis, block % diagnostics, block % mesh)
endif
- call ocn_tend_scalar(block % tend, provis, block % diagnostics, block % mesh)
+ call ocn_tend_scalar(block % tend, provis, block % diagnostics, block % mesh, dt)
block => block % next
end do
call mpas_timer_stop("RK4-tendency computations")
@@ -213,6 +213,14 @@
provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
end if
+ if (config_prescribe_velocity) then
+ provis % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+ end if
+
+ if (config_prescribe_thickness) then
+ provis % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+ end if
+
call ocn_diagnostic_solve(dt, provis, block % mesh)
block => block % next
@@ -307,6 +315,14 @@
block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
end if
+ if (config_prescribe_velocity) then
+ block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+ end if
+
+ if (config_prescribe_thickness) then
+ block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+ end if
+
call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % u % array, &
@@ -356,7 +372,7 @@
meshScalingDel2, meshScalingDel4
real (kind=RKIND), dimension(:,:), pointer :: &
weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, pressure, &
- tend_u, circulation, vorticity, ke, ke_edge, pv_edge, &
+ tend_u, circulation, vorticity, ke, ke_edge, Vor_edge, &
MontPot, wTop, divergence, vertViscTopOfEdge
type (dm_info) :: dminfo
@@ -388,7 +404,7 @@
divergence => s % divergence % array
ke => s % ke % array
ke_edge => s % ke_edge % array
- pv_edge => s % pv_edge % array
+ Vor_edge => s % Vor_edge % array
MontPot => s % MontPot % array
pressure => s % pressure % array
vertViscTopOfEdge => d % vertViscTopOfEdge % array
@@ -471,7 +487,7 @@
meshScalingDel2, meshScalingDel4
real (kind=RKIND), dimension(:,:), pointer :: &
weightsOnEdge, kiteAreasOnVertex, h_edge, h, u, v, pressure, &
- tend_u, circulation, vorticity, ke, ke_edge, pv_edge, &
+ tend_u, circulation, vorticity, ke, ke_edge, Vor_edge, &
MontPot, wTop, divergence, vertViscTopOfEdge
type (dm_info) :: dminfo
@@ -503,7 +519,7 @@
divergence => s % divergence % array
ke => s % ke % array
ke_edge => s % ke_edge % array
- pv_edge => s % pv_edge % array
+ Vor_edge => s % Vor_edge % array
MontPot => s % MontPot % array
pressure => s % pressure % array
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_time_integration_split.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_time_integration_split.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_time_integration_split.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -163,7 +163,7 @@
! --- update halos for diagnostic variables
call mpas_timer_start("se halo diag", .false., timer_halo_diagnostic)
- call mpas_dmpar_exch_halo_field(block % state % time_levs(2) % state % pv_edge)
+ call mpas_dmpar_exch_halo_field(block % state % time_levs(2) % state % Vor_edge)
if (config_h_mom_eddy_visc4 > 0.0) then
call mpas_dmpar_exch_halo_field(block % state % time_levs(2) % state % divergence)
call mpas_dmpar_exch_halo_field(block % state % time_levs(2) % state % vorticity)
@@ -184,7 +184,7 @@
if (.not.config_implicit_vertical_mix) then
call ocn_vmix_coefs(block % mesh, block % state % time_levs(2) % state, block % diagnostics, err)
end if
- call ocn_tend_u(block % tend, block % state % time_levs(2) % state , block % diagnostics, block % mesh)
+ call ocn_tend_u(block % tend, block % state % time_levs(2) % state, block % diagnostics, block % mesh)
block => block % next
end do
@@ -655,13 +655,12 @@
!TDR: at this point, I am suggesting just pushing some of this code into subroutines.
!TDR: see comments farther down
+ ! dwj: 02/22/12 splitting thickness and tracer tendency computations and halo updates to allow monotonic advection.
block => domain % blocklist
do while (associated(block))
call ocn_wtop(block % state % time_levs(1) % state,block % state % time_levs(2) % state, block % mesh)
- call ocn_tend_h (block % tend, block % state % time_levs(2) % state , block % diagnostics, block % mesh)
- call ocn_tend_scalar(block % tend, block % state % time_levs(2) % state , block % diagnostics, block % mesh)
-
+ call ocn_tend_h(block % tend, block % state % time_levs(2) % state, block % mesh)
block => block % next
end do
@@ -672,7 +671,19 @@
block => domain % blocklist
do while (associated(block))
+ call ocn_tend_scalar(block % tend, block % state % time_levs(2) % state, block % diagnostics, block % mesh, dt)
+ block => block % next
+ end do
+
+ ! update halo for thickness and tracer tendencies
+ call mpas_timer_start("se halo tracers", .false., timer_halo_tracers)
+ call mpas_dmpar_exch_halo_field(block % tend % tracers)
+ call mpas_timer_stop("se halo tracers", timer_halo_tracers)
+
+ block => domain % blocklist
+ do while (associated(block))
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! If iterating, reset variables for next iteration
@@ -778,15 +789,8 @@
block => block % next
end do
- ! Boundary update on tracers. This is placed here, rather than
- ! on tend % tracers as in RK4, because I needed to update
- ! afterwards for the del4 diffusion operator.
- call mpas_timer_start("se halo tracers", .false., timer_halo_tracers)
- call mpas_dmpar_exch_halo_field(domain % blocklist % state % time_levs(2) % state % tracers)
- call mpas_timer_stop("se halo tracers", timer_halo_tracers)
-
end do ! split_explicit_step = 1, config_n_ts_iter
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! END large iteration loop
@@ -826,6 +830,15 @@
if (config_test_case == 1) then ! For case 1, wind field should be fixed
block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
end if
+
+ if (config_prescribe_velocity) then
+ block % state % time_levs(2) % state % u % array(:,:) = block % state % time_levs(1) % state % u % array(:,:)
+ end if
+
+ if (config_prescribe_thickness) then
+ block % state % time_levs(2) % state % h % array(:,:) = block % state % time_levs(1) % state % h % array(:,:)
+ end if
+
call ocn_diagnostic_solve(dt, block % state % time_levs(2) % state, block % mesh)
call mpas_reconstruct(block % mesh, block % state % time_levs(2) % state % u % array, &
block % state % time_levs(2) % state % uReconstructX % array, &
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,316 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection
+!
+!> \brief MPAS ocean tracer advection driver
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains driver routine for tracer advection tendencys
+!> as well as the routines for setting up advection coefficients and
+!> initialization of the advection routines.
+!
+!-----------------------------------------------------------------------
+
+module mpas_ocn_tracer_advection
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+
+ use mpas_ocn_tracer_advection_std
+ use mpas_ocn_tracer_advection_mono
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_init, &
+ mpas_ocn_tracer_advection_coefficients, &
+ mpas_ocn_tracer_advection_tend
+
+ logical :: monotonicOn
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_coefficients
+!
+!> \brief MPAS ocean tracer advection coefficients
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine precomputes the advection coefficients for horizontal
+!> advection of tracers.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_coefficients( grid, err )!{{{
+
+ implicit none
+ type (mesh_type) :: grid !< Input: Grid information
+ integer, intent(out) :: err
+
+ real (kind=RKIND), dimension(:,:,:), pointer :: deriv_two
+ real (kind=RKIND), dimension(:,:), pointer :: adv_coefs, adv_coefs_2nd, adv_coefs_3rd
+ integer, dimension(:,:), pointer :: cellsOnCell, cellsOnEdge, advCellsForEdge, highOrderAdvectionMask, lowOrderAdvectionMask, boundaryCell
+ integer, dimension(:), pointer :: nEdgesOnCell, nAdvCellsForEdge, maxLevelCell
+
+ integer, dimension(:), pointer :: cell_list, ordered_cell_list
+ integer :: cell1, cell2, iEdge, n, i, j, j_in, iCell, k, nVertLevels
+ logical :: addcell, highOrderAdvection
+
+ deriv_two => grid % deriv_two % array
+ adv_coefs => grid % adv_coefs % array
+ adv_coefs_2nd => grid % adv_coefs_2nd % array
+ adv_coefs_3rd => grid % adv_coefs_3rd % array
+ cellsOnCell => grid % cellsOnCell % array
+ cellsOnEdge => grid % cellsOnEdge % array
+ advCellsForEdge => grid % advCellsForEdge % array
+ boundaryCell => grid % boundaryCell % array
+ highOrderAdvectionMask => grid % highOrderAdvectionMask % array
+ lowOrderAdvectionMask => grid % lowOrderAdvectionMask % array
+ nEdgesOnCell => grid % nEdgesOnCell % array
+ maxLevelCell => grid % maxLevelCell % array
+ nAdvCellsForEdge => grid % nAdvCellsForEdge % array
+
+ nVertLevels = grid % nVertLevels
+
+ allocate(cell_list(grid % maxEdges2 + 2))
+ allocate(ordered_cell_list(grid % maxEdges2 + 2))
+
+ err = 0
+
+ highOrderAdvectionMask = 0
+ lowOrderAdvectionMask = 0
+ if(config_horiz_tracer_adv_order == 2) then
+
+ end if
+
+ do iEdge = 1, grid % nEdges
+ nAdvCellsForEdge(iEdge) = 0
+ cell1 = cellsOnEdge(1,iEdge)
+ cell2 = cellsOnEdge(2,iEdge)
+
+
+ do k = 1, nVertLevels
+ if (boundaryCell(k, cell1) == 1 .or. boundaryCell(k, cell2) == 1) then
+ highOrderAdvectionMask(k, iEdge) = 0
+ lowOrderAdvectionMask(k, iEdge) = 1
+ else
+ highOrderAdvectionMask(k, iEdge) = 1
+ lowOrderAdvectionMask(k, iEdge) = 0
+ end if
+ end do
+
+ !
+ ! do only if this edge flux is needed to update owned cells
+ !
+ if (cell1 <= grid%nCells .or. cell2 <= grid%nCells) then
+
+ cell_list(1) = cell1
+ cell_list(2) = cell2
+ n = 2
+
+ ! add cells surrounding cell 1. n is number of cells currently in list
+ do i = 1, nEdgesOnCell(cell1)
+ if(cellsOnCell(i,cell1) /= cell2) then
+ n = n + 1
+ cell_list(n) = cellsOnCell(i,cell1)
+ end if
+ end do
+
+ ! add cells surrounding cell 2 (brute force approach)
+ do iCell = 1, nEdgesOnCell(cell2)
+ addcell = .true.
+ do i=1,n
+ if(cell_list(i) == cellsOnCell(iCell,cell2)) addcell = .false.
+ end do
+ if(addcell) then
+ n = n+1
+ cell_list(n) = cellsOnCell(iCell,cell2)
+ end if
+ end do
+
+ ! order the list by increasing cell number (brute force approach)
+
+ do i=1,n
+ ordered_cell_list(i) = grid % nCells + 2
+ j_in = 1
+ do j=1,n
+ if(ordered_cell_list(i) > cell_list(j) ) then
+ j_in = j
+ ordered_cell_list(i) = cell_list(j)
+ end if
+ end do
+! ordered_cell_list(i) = cell_list(j_in)
+ cell_list(j_in) = grid % nCells + 3
+ end do
+
+ nAdvCellsForEdge(iEdge) = n
+ do iCell = 1, nAdvCellsForEdge(iEdge)
+ advCellsForEdge(iCell,iEdge) = ordered_cell_list(iCell)
+ end do
+
+ ! we have the ordered list, now construct coefficients
+
+ adv_coefs(:,iEdge) = 0.
+ adv_coefs_2nd(:,iEdge) = 0.
+ adv_coefs_3rd(:,iEdge) = 0.
+
+ ! pull together third and fourth order contributions to the flux
+ ! first from cell1
+
+ j_in = 0
+ do j=1, n
+ if( ordered_cell_list(j) == cell1 ) j_in = j
+ end do
+ adv_coefs (j_in,iEdge) = adv_coefs (j_in,iEdge) + deriv_two(1,1,iEdge)
+ adv_coefs_3rd(j_in,iEdge) = adv_coefs_3rd(j_in,iEdge) + deriv_two(1,1,iEdge)
+
+ do iCell = 1, nEdgesOnCell(cell1)
+ j_in = 0
+ do j=1, n
+ if( ordered_cell_list(j) == cellsOnCell(iCell,cell1) ) j_in = j
+ end do
+ adv_coefs (j_in,iEdge) = adv_coefs (j_in,iEdge) + deriv_two(iCell+1,1,iEdge)
+ adv_coefs_3rd(j_in,iEdge) = adv_coefs_3rd(j_in,iEdge) + deriv_two(iCell+1,1,iEdge)
+ end do
+
+ ! pull together third and fourth order contributions to the flux
+ ! now from cell2
+
+ j_in = 0
+ do j=1, n
+ if( ordered_cell_list(j) == cell2 ) j_in = j
+ enddo
+ adv_coefs (j_in,iEdge) = adv_coefs (j_in,iEdge) + deriv_two(1,2,iEdge)
+ adv_coefs_3rd(j_in,iEdge) = adv_coefs_3rd(j_in,iEdge) - deriv_two(1,2,iEdge)
+
+ do iCell = 1, nEdgesOnCell(cell2)
+ j_in = 0
+ do j=1, n
+ if( ordered_cell_list(j) == cellsOnCell(iCell,cell2) ) j_in = j
+ enddo
+ adv_coefs (j_in,iEdge) = adv_coefs (j_in,iEdge) + deriv_two(iCell+1,2,iEdge)
+ adv_coefs_3rd(j_in,iEdge) = adv_coefs_3rd(j_in,iEdge) - deriv_two(iCell+1,2,iEdge)
+ end do
+
+ do j = 1,n
+ adv_coefs (j,iEdge) = - (grid % dcEdge % array (iEdge) **2) * adv_coefs (j,iEdge) / 12.
+ adv_coefs_3rd(j,iEdge) = - (grid % dcEdge % array (iEdge) **2) * adv_coefs_3rd(j,iEdge) / 12.
+ end do
+
+ ! 2nd order centered contribution - place this in the main flux weights
+
+ j_in = 0
+ do j=1, n
+ if( ordered_cell_list(j) == cell1 ) j_in = j
+ enddo
+ adv_coefs(j_in,iEdge) = adv_coefs(j_in,iEdge) + 0.5
+ adv_coefs_2nd(j_in,iEdge) = adv_coefs_2nd(j_in,iEdge) + 0.5
+
+ j_in = 0
+ do j=1, n
+ if( ordered_cell_list(j) == cell2 ) j_in = j
+ enddo
+ adv_coefs(j_in,iEdge) = adv_coefs(j_in,iEdge) + 0.5
+ adv_coefs_2nd(j_in,iEdge) = adv_coefs_2nd(j_in,iEdge) + 0.5
+
+ ! multiply by edge length - thus the flux is just dt*ru times the results of the vector-vector multiply
+
+ do j=1,n
+ adv_coefs (j,iEdge) = grid % dvEdge % array(iEdge) * adv_coefs (j,iEdge)
+ adv_coefs_2nd(j,iEdge) = grid % dvEdge % array(iEdge) * adv_coefs_2nd(j,iEdge)
+ adv_coefs_3rd(j,iEdge) = grid % dvEdge % array(iEdge) * adv_coefs_3rd(j,iEdge)
+ end do
+
+ end if ! only do for edges of owned-cells
+
+ end do ! end loop over edges
+
+ deallocate(cell_list)
+ deallocate(ordered_cell_list)
+
+ ! If 2nd order advection, set masks appropriately.
+ if(config_horiz_tracer_adv_order == 2) then
+ lowOrderAdvectionMask = 1
+ highOrderAdvectionMask = 0
+ end if
+
+ if (maxval(highOrderAdvectionMask+lowOrderAdvectionMask) > 1) then
+ write(*,*) "Masks don't sum to 1."
+ err = 1
+ endif
+
+ end subroutine mpas_ocn_tracer_advection_coefficients!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_tend
+!
+!> \brief MPAS ocean tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine is the driver routine for computing the tendency for
+!> advection of tracers.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_tend(tracers, uh, w, h, verticalCellSize, dt, grid, tend_h, tend)!{{{
+
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: tracer tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input/Output: tracer values
+ real (kind=RKIND), dimension(:,:), intent(in) :: uh !< Input: Thickness weighted horizontal velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: h !< Input: Thickness field
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of a cell
+ real (kind=RKIND), intent(in) :: dt !< Input: Time step
+ type (mesh_type), intent(in) :: grid !< Input: grid information
+ real (kind=RKIND), dimension(:,:), intent(in) :: tend_h !< Input: Thickness tendency information
+
+ if(monotonicOn) then
+ call mpas_ocn_tracer_advection_mono_tend(tracers, uh, w, h, verticalCellSize, dt, grid, tend_h, tend)
+ else
+ call mpas_ocn_tracer_advection_std_tend(tracers, uh, w, verticalCellSize, grid, tend)
+ endif
+ end subroutine mpas_ocn_tracer_advection_tend!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_init
+!
+!> \brief MPAS ocean tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine is the driver routine for initialization of
+!> the tracer advection routines.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_init(err)!{{{
+
+ integer, intent(inout) :: err !< Input/Output: Error flag
+
+ integer :: err_tmp
+
+ err = 0
+
+ call mpas_ocn_tracer_advection_std_init(err_tmp)
+ call mpas_ocn_tracer_advection_mono_init(err_tmp)
+
+ err = ior(err, err_tmp)
+
+ monotonicOn = .false.
+
+ if(config_monotonic) then
+ monotonicOn = .true.
+ endif
+
+ end subroutine mpas_ocn_tracer_advection_init!}}}
+
+end module mpas_ocn_tracer_advection
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_helpers.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_helpers.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_helpers.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,68 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_helpers
+!
+!> \brief MPAS ocean tracer advection helper functions
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains helper functions tracer advection.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_helpers
+
+ use mpas_kind_types
+
+ implicit none
+ save
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! function mpas_ocn_tracer_advection_vflux4
+!
+!> \brief MPAS ocean 4th order vertical tracer advection stencil
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This function provides the stencil for 4th order vertical advection of tracers.
+!
+!-----------------------------------------------------------------------
+ real function mpas_ocn_tracer_advection_vflux4(q_im2, q_im1, q_i, q_ip1, w)!{{{
+ real (kind=RKIND), intent(in) :: q_im2 !< Input: Tracer value at index i-2
+ real (kind=RKIND), intent(in) :: q_im1 !< Input: Tracer value at index i-1
+ real (kind=RKIND), intent(in) :: q_i !< Input: Tracer value at index i
+ real (kind=RKIND), intent(in) :: q_ip1 !< Input: Tracer value at index i+1
+ real (kind=RKIND), intent(in) :: w !< Input: vertical veloicity
+ mpas_ocn_tracer_advection_vflux4 = w*( 7.*(q_i + q_im1) - (q_ip1 + q_im2) )/12.0
+ end function!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! function mpas_ocn_tracer_advection_vflux3
+!
+!> \brief MPAS ocean 3rd order vertical tracer advection stencil
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This function provides the stencil for 3rd order vertical advection of tracers.
+!
+!-----------------------------------------------------------------------
+ real function mpas_ocn_tracer_advection_vflux3( q_im2, q_im1, q_i, q_ip1, w, coef)!{{{
+ real (kind=RKIND), intent(in) :: q_im2 !< Input: Tracer value at index i-2
+ real (kind=RKIND), intent(in) :: q_im1 !< Input: Tracer value at index i-1
+ real (kind=RKIND), intent(in) :: q_i !< Input: Tracer value at index i
+ real (kind=RKIND), intent(in) :: q_ip1 !< Input: Tracer value at index i+1
+ real (kind=RKIND), intent(in) :: w !< Input: vertical veloicity
+ real (kind=RKIND), intent(in) :: coef !< Input: Advection coefficient
+
+ !dwj 02/21/12 flux3 is different in ocean and atmosphere
+ !flux3 = (u * (7.0 * (q_i + q_im1) - (q_ip1 + q_im2)) + coef * abs(u) * ((q_ip1 - q_im2) - 3.0*(q_i-q_im1)))/12.0
+ mpas_ocn_tracer_advection_vflux3 = (w * (7.0 * (q_i + q_im1) - (q_ip1 + q_im2)) - coef * abs(w) * ((q_ip1 - q_im2) - 3.0*(q_i-q_im1)))/12.0
+ end function!}}}
+
+end module mpas_ocn_tracer_advection_helpers
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_mono.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_mono.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_mono.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,382 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_mono
+!
+!> \brief MPAS ocean monotonic tracer advection with FCT
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains routines for monotonic advection of tracers using a FCT
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_mono
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+
+ use mpas_ocn_tracer_advection_helpers
+
+ implicit none
+ private
+ save
+
+ real (kind=RKIND) :: coef_3rd_order
+
+ public :: mpas_ocn_tracer_advection_mono_tend, &
+ mpas_ocn_tracer_advection_mono_init
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_mono_tend
+!
+!> \brief MPAS ocean monotonic tracer advection tendency with FCT
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine computes the monotonic tracer advection tendencity using a FCT.
+!> Both horizontal and vertical.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_mono_tend(tracers, uh, w, h, verticalCellSize, dt, grid, tend_h, tend)!{{{
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !
+ ! Input: s - current model state
+ ! grid - grid metadata
+ !
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: current tracer values
+ real (kind=RKIND), dimension(:,:), intent(in) :: uh !< Input: Thichness weighted velocitiy
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical velocitiy
+ real (kind=RKIND), dimension(:,:), intent(in) :: h !< Input: Thickness
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of a cell
+ real (kind=RKIND), dimension(:,:), intent(in) :: tend_h !< Input: Tendency for thickness field
+ real (kind=RKIND), intent(in) :: dt !< Input: Timestep
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: Tracer tendency
+
+ integer :: i, iCell, iEdge, k, iTracer, cell1, cell2
+ integer :: nVertLevels, num_tracers, nCells, nEdges, nCellsSolve
+ integer, dimension(:), pointer :: nAdvCellsForEdge, maxLevelCell, maxLevelEdgeTop, nEdgesOnCell
+ integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnCell, advCellsForEdge, highOrderAdvectionMask, lowOrderAdvectionMask
+
+ real (kind=RKIND) :: flux_upwind, tracer_min_new, tracer_max_new, tracer_upwind_new, scale_factor
+ real (kind=RKIND) :: flux, tracer_weight, invDvEdge, invAreaCell1, invAreaCell2
+ real (kind=RKIND) :: cur_max, cur_min, new_max, new_min
+ real (kind=RKIND) :: verticalWeightK, verticalWeightKm1
+ real (kind=RKIND), dimension(:), pointer :: dvEdge, areaCell
+ real (kind=RKIND), dimension(:,:), pointer :: adv_coefs, adv_coefs_2nd, adv_coefs_3rd
+ real (kind=RKIND), dimension(:,:), pointer :: tracer_cur, tracer_new, upwind_tendency, inv_h_new, tracer_max, tracer_min
+ real (kind=RKIND), dimension(:,:), pointer :: flux_incoming, flux_outgoing, high_order_horiz_flux, high_order_vert_flux
+
+ real (kind=RKIND), parameter :: eps = 1.e-10
+
+ ! Initialize pointers
+ dvEdge => grid % dvEdge % array
+ cellsOnEdge => grid % cellsOnEdge % array
+ cellsOnCell => grid % cellsOnCell % array
+ areaCell => grid % areaCell % array
+
+ nEdgesOnCell => grid % nEdgesOnCell % array
+ nAdvCellsForEdge => grid % nAdvCellsForEdge % array
+ advCellsForEdge => grid % advCellsForEdge % array
+ adv_coefs => grid % adv_coefs % array
+ adv_coefs_2nd => grid % adv_coefs_2nd % array
+ adv_coefs_3rd => grid % adv_coefs_3rd % array
+ maxLevelCell => grid % maxLevelCell % array
+ maxLevelEdgeTop => grid % maxLevelEdgeTop % array
+ highOrderAdvectionMask => grid % highOrderAdvectionMask % array
+ lowOrderAdvectionMask => grid % lowOrderAdvectionMask % array
+
+ nCells = grid % nCells
+ nCellsSolve = grid % nCellsSolve
+ nEdges = grid % nEdges
+ nVertLevels = grid % nVertLevels
+ num_tracers = size(tracers,dim=1)
+
+ ! allocate nCells arrays
+
+ allocate(tracer_new(nVertLevels, nCells))
+ allocate(tracer_cur(nVertLevels, nCells))
+ allocate(upwind_tendency(nVertLevels, nCells))
+ allocate(inv_h_new(nVertLevels, nCells))
+ allocate(tracer_max(nVertLevels, nCells))
+ allocate(tracer_min(nVertLevels, nCells))
+ allocate(flux_incoming(nVertLevels, nCells))
+ allocate(flux_outgoing(nVertLevels, nCells))
+
+ ! allocate nEdges arrays
+ allocate(high_order_horiz_flux(nVertLevels, nEdges))
+
+ ! allocate nVertLevels+1 and nCells arrays
+ allocate(high_order_vert_flux(nVertLevels+1, nCells))
+
+ do iCell = 1, nCells
+ do k=1, maxLevelCell(iCell)
+ inv_h_new(k, iCell) = 1.0 / (h(k, iCell) + dt * tend_h(k, iCell))
+ end do
+ end do
+
+ ! Loop over tracers. One tracer is advected at a time. It is copied into a temporary array in order to improve locality
+ do iTracer = 1, num_tracers
+ ! Initialize variables for use in this iTracer iteration
+ do iCell = 1, nCells
+ do k=1, maxLevelCell(iCell)
+ tracer_cur(k,iCell) = tracers(iTracer,k,iCell)
+ upwind_tendency(k, iCell) = 0.0
+
+ !tracer_new is supposed to be the "new" tracer state. This allows bounds checks.
+ if (config_check_monotonicity) then
+ tracer_new(k,iCell) = 0.0
+ end if
+ end do ! k loop
+ end do ! iCell loop
+
+ high_order_vert_flux = 0.0
+ high_order_horiz_flux = 0.0
+
+ ! Compute the high order vertical flux. Also determine bounds on tracer_cur.
+ do iCell = 1, nCells
+ k = 1
+ tracer_max(k,iCell) = max(tracer_cur(k,iCell),tracer_cur(k+1,iCell))
+ tracer_min(k,iCell) = min(tracer_cur(k,iCell),tracer_cur(k+1,iCell))
+
+ k = 2
+ verticalWeightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k, iCell) + verticalCellSize(k-1, iCell))
+ verticalWeightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k, iCell) + verticalCellSize(k-1, iCell))
+ high_order_vert_flux(k,iCell) = w(k,iCell)*(verticalWeightK*tracer_cur(k,iCell)+verticalWeightKm1*tracer_cur(k-1,iCell))
+ tracer_max(k,iCell) = max(tracer_cur(k-1,iCell),tracer_cur(k,iCell),tracer_cur(k+1,iCell))
+ tracer_min(k,iCell) = min(tracer_cur(k-1,iCell),tracer_cur(k,iCell),tracer_cur(k+1,iCell))
+
+ do k=3,maxLevelCell(iCell)-1
+ high_order_vert_flux(k,iCell) = mpas_ocn_tracer_advection_vflux3( tracer_cur(k-2,iCell),tracer_cur(k-1,iCell), &
+ tracer_cur(k ,iCell),tracer_cur(k+1,iCell), &
+ w(k,iCell), coef_3rd_order )
+ tracer_max(k,iCell) = max(tracer_cur(k-1,iCell),tracer_cur(k,iCell),tracer_cur(k+1,iCell))
+ tracer_min(k,iCell) = min(tracer_cur(k-1,iCell),tracer_cur(k,iCell),tracer_cur(k+1,iCell))
+ end do
+
+ k = maxLevelCell(iCell)
+ verticalWeightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k, iCell) + verticalCellSize(k-1, iCell))
+ verticalWeightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k, iCell) + verticalCellSize(k-1, iCell))
+ high_order_vert_flux(k,iCell) = w(k,iCell)*(verticalWeightK*tracer_cur(k,iCell)+verticalWeightKm1*tracer_cur(k-1,iCell))
+ tracer_max(k,iCell) = max(tracer_cur(k,iCell),tracer_cur(k-1,iCell))
+ tracer_min(k,iCell) = min(tracer_cur(k,iCell),tracer_cur(k-1,iCell))
+
+ ! pull tracer_min and tracer_max from the (horizontal) surrounding cells
+ do i = 1, nEdgesOnCell(iCell)
+ do k=1, maxLevelCell(cellsOnCell(i, iCell))
+ tracer_max(k,iCell) = max(tracer_max(k,iCell),tracer_cur(k, cellsOnCell(i,iCell)))
+ tracer_min(k,iCell) = min(tracer_min(k,iCell),tracer_cur(k, cellsOnCell(i,iCell)))
+ end do ! k loop
+ end do ! i loop over nEdgesOnCell
+ end do ! iCell Loop
+
+ ! Compute the high order horizontal flux
+ do iEdge = 1, nEdges
+ do i = 1, nAdvCellsForEdge(iEdge)
+ iCell = advCellsForEdge(i,iEdge)
+ do k = 1, maxLevelCell(iCell)
+ tracer_weight = lowOrderAdvectionMask(k, iEdge) * adv_coefs_2nd(i,iEdge) &
+ + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
+
+ tracer_weight = uh(k,iEdge)*tracer_weight
+ high_order_horiz_flux(k,iEdge) = high_order_horiz_flux(k,iEdge) + tracer_weight* tracer_cur(k,iCell)
+ end do ! k loop
+ end do ! i loop over nAdvCellsForEdge
+ end do ! iEdge loop
+
+ ! low order upwind vertical flux (monotonic and diffused)
+ ! Remove low order flux from the high order flux.
+ ! Store left over high order flux in high_order_vert_flux array.
+ ! Upwind fluxes are accumulated in upwind_tendency
+ do iCell = 1, nCells
+ do k = 2, maxLevelCell(iCell)
+ ! dwj 02/03/12 Ocean and Atmosphere are different in vertical
+! flux_upwind = max(0.,w(k,iCell))*tracer_cur(k-1,iCell) + min(0.,w(k,iCell))*tracer_cur(k,iCell)
+ flux_upwind = min(0.,w(k,iCell))*tracer_cur(k-1,iCell) + max(0.,w(k,iCell))*tracer_cur(k,iCell)
+ upwind_tendency(k-1,iCell) = upwind_tendency(k-1,iCell) + flux_upwind
+ upwind_tendency(k ,iCell) = upwind_tendency(k ,iCell) - flux_upwind
+ high_order_vert_flux(k,iCell) = high_order_vert_flux(k,iCell) - flux_upwind
+ end do ! k loop
+
+ ! flux_incoming contains the total remaining high order flux into iCell
+ ! it is positive.
+ ! flux_outgoing contains the total remaining high order flux out of iCell
+ ! it is negative
+ do k = 1, maxLevelCell(iCell)
+ ! dwj 02/03/12 Ocean and Atmosphere are different in vertical
+! flux_incoming (k,iCell) = -(min(0.,high_order_vert_flux(k+1,iCell))-max(0.,high_order_vert_flux(k,iCell)))
+! flux_outgoing(k,iCell) = -(max(0.,high_order_vert_flux(k+1,iCell))-min(0.,high_order_vert_flux(k,iCell)))
+
+ flux_incoming (k, iCell) = max(0.0, high_order_vert_flux(k+1, iCell)) - min(0.0, high_order_vert_flux(k, iCell))
+ flux_outgoing(k, iCell) = min(0.0, high_order_vert_flux(k+1, iCell)) - max(0.0, high_order_vert_flux(k, iCell))
+ end do ! k Loop
+ end do ! iCell Loop
+
+ ! low order upwind horizontal flux (monotinc and diffused)
+ ! Remove low order flux from the high order flux
+ ! Store left over high order flux in high_order_horiz_flux array
+ ! Upwind fluxes are accumulated in upwind_tendency
+ do iEdge = 1, nEdges
+ cell1 = cellsOnEdge(1,iEdge)
+ cell2 = cellsOnEdge(2,iEdge)
+
+ invAreaCell1 = 1.0 / areaCell(cell1)
+ invAreaCell2 = 1.0 / areaCell(cell2)
+
+ do k = 1, maxLevelEdgeTop(iEdge)
+ flux_upwind = dvEdge(iEdge) * (max(0.,uh(k,iEdge))*tracer_cur(k,cell1) + min(0.,uh(k,iEdge))*tracer_cur(k,cell2))
+ high_order_horiz_flux(k,iEdge) = high_order_horiz_flux(k,iEdge) - flux_upwind
+
+ upwind_tendency(k,cell1) = upwind_tendency(k,cell1) - flux_upwind * invAreaCell1
+ upwind_tendency(k,cell2) = upwind_tendency(k,cell2) + flux_upwind * invAreaCell2
+
+ ! Accumulate remaining high order fluxes
+ flux_outgoing(k,cell1) = flux_outgoing(k,cell1) - max(0.,high_order_horiz_flux(k,iEdge)) * invAreaCell1
+ flux_incoming (k,cell1) = flux_incoming (k,cell1) - min(0.,high_order_horiz_flux(k,iEdge)) * invAreaCell1
+ flux_outgoing(k,cell2) = flux_outgoing(k,cell2) + min(0.,high_order_horiz_flux(k,iEdge)) * invAreaCell2
+ flux_incoming (k,cell2) = flux_incoming (k,cell2) + max(0.,high_order_horiz_flux(k,iEdge)) * invAreaCell2
+ end do ! k loop
+ end do ! iEdge loop
+
+ ! Build the factors for the FCT
+ ! Computed using the bounds that were computed previously, and the bounds on the newly updated value
+ ! Factors are placed in the flux_incoming and flux_outgoing arrays
+ do iCell = 1, nCells
+ do k = 1, maxLevelCell(iCell)
+ tracer_min_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*(upwind_tendency(k,iCell)+flux_outgoing(k,iCell))) * inv_h_new(k,iCell)
+ tracer_max_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*(upwind_tendency(k,iCell)+flux_incoming(k,iCell))) * inv_h_new(k,iCell)
+ tracer_upwind_new = (tracer_cur(k,iCell)*h(k,iCell) + dt*upwind_tendency(k,iCell)) * inv_h_new(k,iCell)
+
+ scale_factor = (tracer_max(k,iCell)-tracer_upwind_new)/(tracer_max_new-tracer_upwind_new+eps)
+ flux_incoming(k,iCell) = min( 1.0, max( 0.0, scale_factor) )
+
+ scale_factor = (tracer_upwind_new-tracer_min(k,iCell))/(tracer_upwind_new-tracer_min_new+eps)
+ flux_outgoing(k,iCell) = min( 1.0, max( 0.0, scale_factor) )
+ end do ! k loop
+ end do ! iCell loop
+
+ ! rescale the high order horizontal fluxes
+ do iEdge = 1, nEdges
+ cell1 = cellsOnEdge(1,iEdge)
+ cell2 = cellsOnEdge(2,iEdge)
+ do k = 1, maxLevelEdgeTop(iEdge)
+ flux = high_order_horiz_flux(k,iEdge)
+ flux = max(0.,flux) * min(flux_outgoing(k,cell1), flux_incoming(k,cell2)) &
+ + min(0.,flux) * min(flux_incoming(k,cell1), flux_outgoing(k,cell2))
+ high_order_horiz_flux(k,iEdge) = flux
+ end do ! k loop
+ end do ! iEdge loop
+
+ ! rescale the high order vertical flux
+ do iCell = 1, nCellsSolve
+ do k = 2, maxLevelCell(iCell)
+ flux = high_order_vert_flux(k,iCell)
+ ! dwj 02/03/12 Ocean and Atmosphere are different in vertical.
+! flux = max(0.,flux) * min(flux_outgoing(k-1,iCell), flux_incoming(k ,iCell)) &
+! + min(0.,flux) * min(flux_outgoing(k ,iCell), flux_incoming(k-1,iCell))
+ flux = max(0.,flux) * min(flux_outgoing(k ,iCell), flux_incoming(k-1,iCell)) &
+ + min(0.,flux) * min(flux_outgoing(k-1,iCell), flux_incoming(k ,iCell))
+ high_order_vert_flux(k,iCell) = flux
+ end do ! k loop
+ end do ! iCell loop
+
+ ! Accumulate the scaled high order horizontal tendencies
+ do iEdge = 1, nEdges
+ cell1 = cellsOnEdge(1,iEdge)
+ cell2 = cellsOnEdge(2,iEdge)
+
+ invAreaCell1 = 1.0 / areaCell(cell1)
+ invAreaCell2 = 1.0 / areaCell(cell2)
+ do k=1,maxLevelEdgeTop(iEdge)
+ tend(iTracer, k, cell1) = tend(iTracer, k, cell1) - high_order_horiz_flux(k, iEdge) * invAreaCell1
+ tend(iTracer, k, cell2) = tend(iTracer, k, cell2) + high_order_horiz_flux(k, iEdge) * invAreaCell2
+
+ if (config_check_monotonicity) then
+ !tracer_new holds a tendency for now.
+ tracer_new(k, cell1) = tracer_new(k, cell1) - high_order_horiz_flux(k, iEdge) * invAreaCell1
+ tracer_new(k, cell2) = tracer_new(k, cell2) + high_order_horiz_flux(k, iEdge) * invAreaCell2
+ end if
+ end do ! k loop
+ end do ! iEdge loop
+
+ ! Accumulate the scaled high order vertical tendencies, and the upwind tendencies
+ do iCell = 1, nCellsSolve
+ do k = 1,maxLevelCell(iCell)
+ tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + (high_order_vert_flux(k+1, iCell) - high_order_vert_flux(k, iCell)) + upwind_tendency(k,iCell)
+
+ if (config_check_monotonicity) then
+ !tracer_new holds a tendency for now. Only for a check on monotonicity
+ tracer_new(k, iCell) = tracer_new(k, iCell) + (high_order_vert_flux(k+1, iCell) - high_order_vert_flux(k, iCell)) + upwind_tendency(k,iCell)
+
+ !tracer_new is now the new state of the tracer. Only for a check on monotonicity
+ tracer_new(k, iCell) = (tracer_cur(k, iCell)*h(k, iCell) + dt * tracer_new(k, iCell)) * inv_h_new(k, iCell)
+ end if
+ end do ! k loop
+ end do ! iCell loop
+
+ if (config_check_monotonicity) then
+ !build min and max bounds on old and new tracer for check on monotonicity.
+ cur_min = minval(tracer_cur(:,1:nCellsSolve))
+ cur_max = maxval(tracer_cur(:,1:nCellsSolve))
+ new_min = minval(tracer_new(:,1:nCellsSolve))
+ new_max = maxval(tracer_new(:,1:nCellsSolve))
+
+ !check monotonicity
+ if(new_min < cur_min-eps) then
+ write(*,*) 'Minimum out of bounds on tracer ', iTracer, cur_min, new_min
+ end if
+
+ if(new_max > cur_max+eps) then
+ write(*,*) 'Maximum out of bounds on tracer ', iTracer, cur_max, new_max
+ end if
+ end if
+ end do ! iTracer loop
+
+ deallocate(tracer_new)
+ deallocate(tracer_cur)
+ deallocate(upwind_tendency)
+ deallocate(inv_h_new)
+ deallocate(tracer_max)
+ deallocate(tracer_min)
+ deallocate(flux_incoming)
+ deallocate(flux_outgoing)
+ deallocate(high_order_horiz_flux)
+ deallocate(high_order_vert_flux)
+ end subroutine mpas_ocn_tracer_advection_mono_tend!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_mono_init
+!
+!> \brief MPAS ocean initialize monotonic tracer advection tendency with FCT
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine initializes the monotonic tracer advection tendencity using a FCT.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_mono_init(err)!{{{
+ integer, intent(inout) :: err !< Input: Error Flags
+
+ integer :: err_tmp
+
+ err = 0
+
+ if ( config_horiz_tracer_adv_order == 3) then
+ coef_3rd_order = config_coef_3rd_order
+ else if(config_horiz_tracer_adv_order == 2 .or. config_horiz_tracer_adv_order == 4) then
+ coef_3rd_order = 0.0
+ end if
+
+ end subroutine mpas_ocn_tracer_advection_mono_init!}}}
+
+end module mpas_ocn_tracer_advection_mono
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,100 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_std
+!
+!> \brief MPAS ocean tracer advection driver (non-monotonic/fct)
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains driver routine for tracer advection tendencies
+!> as well as the routines for setting up advection coefficients and
+!> initialization of the advection routines.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_std
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+ use mpas_timer
+
+ use mpas_ocn_tracer_advection_std_hadv
+ use mpas_ocn_tracer_advection_std_vadv
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_std_tend, &
+ mpas_ocn_tracer_advection_std_init
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_tend
+!
+!> \brief MPAS ocean standard tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine is the driver routine for the standard computation of
+!> tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_tend(tracers, uh, w, verticalCellSize, grid, tend)!{{{
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !
+ ! Input: s - current model state
+ ! grid - grid metadata
+ !
+ ! Output: tend - computed scalar tendencies
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: Tracer tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: Tracer values
+ real (kind=RKIND), dimension(:,:), intent(in) :: uh !< Input: Thickness weighted horizontal velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical Velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of a cell
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+
+ call mpas_timer_start("tracer-hadv", .false.)
+ call mpas_ocn_tracer_advection_std_hadv_tend(tracers, uh, grid, tend)
+ call mpas_timer_stop("tracer-hadv")
+ call mpas_timer_start("tracer-vadv", .false.)
+ call mpas_ocn_tracer_advection_std_vadv_tend(tracers, w, verticalCellSize, grid, tend)
+ call mpas_timer_stop("tracer-vadv")
+
+ end subroutine mpas_ocn_tracer_advection_std_tend!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_init
+!
+!> \brief MPAS ocean standard tracer advection initialization
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine is the driver routine for the initializtion of the standard
+!> tracer advection routines.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_init(err)!{{{
+ integer, intent(inout) :: err !< Input: Error Flags
+
+ integer :: err_tmp
+
+ err = 0
+
+ call mpas_ocn_tracer_advection_std_hadv_init(err_tmp)
+ err = ior(err, err_tmp)
+ call mpas_ocn_tracer_advection_std_vadv_init(err_tmp)
+ err = ior(err, err_tmp)
+
+ end subroutine mpas_ocn_tracer_advection_std_init!}}}
+
+end module mpas_ocn_tracer_advection_std
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_hadv.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,140 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_std_hadv
+!
+!> \brief MPAS ocean standard horizontal tracer advection (non-monotonic/fct)
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains routines for horizontal tracer advection tendencies
+!> and initialization of the horizontal advection routines.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_std_hadv
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+
+ use mpas_ocn_tracer_advection_helpers
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_std_hadv_tend, &
+ mpas_ocn_tracer_advection_std_hadv_init
+
+ real (kind=RKIND) :: coef_3rd_order
+
+ logical :: hadvOn
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_hadv_tend
+!
+!> \brief MPAS ocean standard horizontal tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine computes the tendency for 3rd order horizontal advection of tracers.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_hadv_tend(tracers, uh, grid, tend)!{{{
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/output: Tracer tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: Tracer values
+ real (kind=RKIND), dimension(:,:), intent(in) :: uh !< Input: Thickness weighted horizontal velocity
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+
+ integer :: i, iCell, iEdge, k, iTracer, cell1, cell2
+ real (kind=RKIND) :: flux, tracer_weight
+
+ real (kind=RKIND), dimension(:), pointer :: areaCell
+ integer, dimension(:,:), pointer :: cellsOnEdge
+
+ integer, dimension(:,:), pointer :: advCellsForEdge, highOrderAdvectionMask, lowOrderAdvectionMask
+ integer, dimension(:), pointer :: nAdvCellsForEdge
+ real (kind=RKIND), dimension(:,:), pointer :: adv_coefs, adv_coefs_2nd, adv_coefs_3rd
+ real (kind=RKIND), dimension(:,:), allocatable :: flux_arr
+ integer :: nVertLevels, num_tracers
+
+ if (.not. hadvOn) return
+
+ cellsOnEdge => grid % cellsOnEdge % array
+ areaCell => grid % areaCell % array
+
+ nAdvCellsForEdge => grid % nAdvCellsForEdge % array
+ advCellsForEdge => grid % advCellsForEdge % array
+ adv_coefs => grid % adv_coefs % array
+ adv_coefs_2nd => grid % adv_coefs_2nd % array
+ adv_coefs_3rd => grid % adv_coefs_3rd % array
+ highOrderAdvectionMask => grid % highOrderAdvectionMask % array
+ lowOrderAdvectionMask => grid % lowOrderAdvectionMask % array
+
+ nVertLevels = grid % nVertLevels
+ num_tracers = size(tracers, dim=1)
+
+ allocate(flux_arr(num_tracers, grid % nVertLevels))
+
+ ! horizontal flux divergence, accumulate in tracer_tend
+ do iEdge=1,grid%nEdges
+ cell1 = cellsOnEdge(1,iEdge)
+ cell2 = cellsOnEdge(2,iEdge)
+ if (cell1 <= grid%nCellsSolve .or. cell2 <= grid%nCellsSolve) then ! only for owned cells
+ flux_arr(:,:) = 0.
+ do i=1,nAdvCellsForEdge(iEdge)
+ iCell = advCellsForEdge(i,iEdge)
+ do k=1,grid % nVertLevels
+ tracer_weight = lowOrderAdvectionMask(k, iEdge) * adv_coefs_2nd(i,iEdge) &
+ + highOrderAdvectionMask(k, iEdge) * (adv_coefs(i,iEdge) + coef_3rd_order*sign(1.,uh(k,iEdge))*adv_coefs_3rd(i,iEdge))
+ do iTracer=1,num_tracers
+ flux_arr(iTracer,k) = flux_arr(iTracer,k) + tracer_weight* tracers(iTracer,k,iCell)
+ end do
+ end do
+ end do
+
+ do k=1,grid % nVertLevels
+ do iTracer=1,num_tracers
+ tend(iTracer,k,cell1) = tend(iTracer,k,cell1) - uh(k,iEdge)*flux_arr(iTracer,k)/areaCell(cell1)
+ tend(iTracer,k,cell2) = tend(iTracer,k,cell2) + uh(k,iEdge)*flux_arr(iTracer,k)/areaCell(cell2)
+ end do
+ end do
+ end if
+ end do
+
+ deallocate(flux_arr)
+
+ end subroutine mpas_ocn_tracer_advection_std_hadv_tend!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_hadv_init
+!
+!> \brief MPAS ocean standard horizontal tracer advection initialization
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine initializes the 3rd order standard horizontal advection of tracers
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_hadv_init(err)!{{{
+ integer, intent(inout) :: err !< Input/Output: Error flag
+
+ err = 0
+
+ hadvOn =.true.
+
+ if ( config_horiz_tracer_adv_order == 3) then
+ coef_3rd_order = config_coef_3rd_order
+ else if ( config_horiz_tracer_adv_order == 2 .or. config_horiz_tracer_adv_order == 4) then
+ coef_3rd_order = 0.0
+ end if
+ end subroutine mpas_ocn_tracer_advection_std_hadv_init!}}}
+
+end module mpas_ocn_tracer_advection_std_hadv
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,103 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_std_vadv
+!
+!> \brief MPAS ocean vertical tracer advection driver (non-monotonic/fct)
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains driver routines for vertical tracer advection tendencies
+!> and initialization of the advection routines.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_std_vadv
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+
+ use mpas_ocn_tracer_advection_std_vadv2
+ use mpas_ocn_tracer_advection_std_vadv3
+ use mpas_ocn_tracer_advection_std_vadv4
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_std_vadv_tend, &
+ mpas_ocn_tracer_advection_std_vadv_init
+
+ logical :: order2, order3, order4
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_vadv_tend
+!
+!> \brief MPAS ocean standard vertical tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine is the driver routine for the standard computation of
+!> vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_vadv_tend(tracers, w, verticalCellSize, grid, tend)!{{{
+
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: Tracer Tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: Tracer Values
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical Velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of cell
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+
+ if(order2) then
+ call mpas_ocn_tracer_advection_std_vadv2_tend(tracers, w, verticalCellSize, grid, tend)
+ else if(order3) then
+ call mpas_ocn_tracer_advection_std_vadv3_tend(tracers, w, verticalCellSize, grid, tend)
+ else if(order4) then
+ call mpas_ocn_tracer_advection_std_vadv4_tend(tracers, w, verticalCellSize, grid, tend)
+ endif
+
+ end subroutine mpas_ocn_tracer_advection_std_vadv_tend!}}}
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_vadv_init
+!
+!> \brief MPAS ocean standard vertical tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine initializes the vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_vadv_init(err)!{{{
+ integer, intent(inout) :: err !< Input/Output: Error flag
+
+ err = 0
+
+ order2 = .false.
+ order3 = .false.
+ order4 = .false.
+
+ if (config_vert_tracer_adv_order == 2) then
+ order2 = .true.
+ else if (config_vert_tracer_adv_order == 3) then
+ order3 = .true.
+ else if (config_vert_tracer_adv_order == 4) then
+ order4 = .true.
+ else
+ print *, 'invalid value for config_tracer_vadv_order'
+ print *, 'options are 2, 3, or 4'
+ err = 1
+ endif
+
+ end subroutine mpas_ocn_tracer_advection_std_vadv_init!}}}
+
+end module mpas_ocn_tracer_advection_std_vadv
+
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv2.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv2.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv2.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,96 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_std_vadv2
+!
+!> \brief MPAS ocean 2nd order vertical tracer advection driver (non-monotonic/fct)
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains routines for 2nd order vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_std_vadv2
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+
+ use mpas_ocn_tracer_advection_helpers
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_std_vadv2_tend
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_vadv2_tend
+!
+!> \brief MPAS ocean 2nd order standard vertical tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine is the driver routine for the 2nd order standard computation of
+!> vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_vadv2_tend(tracers, w, verticalCellSize, grid, tend)!{{{
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: tracer tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: Tracer values
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical Velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of cell
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+
+ integer :: i, iCell, iEdge, k, iTracer, cell1, cell2
+ real (kind=RKIND) :: flux, tracer_edge, tracer_weight
+ real (kind=RKIND) :: tracer_weight_cell1, tracer_weight_cell2
+
+
+ real (kind=RKIND), dimension(:,:), allocatable :: vert_flux
+ real (kind=RKIND) :: weightK, weightKm1
+ integer :: nVertLevels, num_tracers
+ integer, dimension(:), pointer :: maxLevelCell
+
+ nVertLevels = grid % nVertLevels
+ num_tracers = size(tracers, dim=1)
+ maxLevelCell => grid % maxLevelCell % array
+
+ allocate(vert_flux(num_tracers, nVertLevels+1))
+
+ !
+ ! vertical flux divergence
+ !
+
+ ! zero fluxes at top and bottom
+
+ vert_flux(:,1) = 0.
+
+ do iCell=1,grid % nCellsSolve
+ do k = 2, maxLevelCell(iCell)
+ do iTracer=1,num_tracers
+ weightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ weightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ vert_flux(iTracer,k) = w(k,iCell)*(weightK*tracers(iTracer,k,iCell)+weightKm1*tracers(iTracer,k-1,iCell))
+ end do
+ end do
+
+ vert_flux(:,maxLevelCell(iCell)+1) = 0
+
+ do k=1,maxLevelCell(iCell)
+ do iTracer=1,num_tracers
+ tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + ( vert_flux(iTracer, k+1) - vert_flux(iTracer, k))
+ end do
+ end do
+ end do
+
+ deallocate(vert_flux)
+
+ end subroutine mpas_ocn_tracer_advection_std_vadv2_tend!}}}
+
+end module mpas_ocn_tracer_advection_std_vadv2
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv3.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv3.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv3.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,106 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_std_vadv3
+!
+!> \brief MPAS ocean 3rd order vertical tracer advection driver (non-monotonic/fct)
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains routines for 3rd order vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_std_vadv3
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+
+ use mpas_ocn_tracer_advection_helpers
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_std_vadv3_tend
+
+ real (kind=RKIND) :: coef_3rd_order
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_vadv3_tend
+!
+!> \brief MPAS ocean 3rd order standard vertical tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine computes the 3rd order vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_vadv3_tend(tracers, w, verticalCellSize, grid, tend)!{{{
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: Tracer Tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: Tracer Values
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical Velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of cell
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+
+ integer :: i, iCell, iEdge, k, iTracer, cell1, cell2
+
+ real (kind=RKIND), dimension(:,:), allocatable :: vert_flux
+ real (kind=RKIND) :: weightK, weightKm1
+ integer :: nVertLevels, num_tracers
+ integer, dimension(:), pointer :: maxLevelCell
+
+ coef_3rd_order = config_coef_3rd_order
+
+ nVertLevels = grid % nVertLevels
+ num_tracers = size(tracers, dim=1)
+ maxLevelCell => grid % maxLevelCell % array
+
+ allocate(vert_flux(num_tracers, nVertLevels+1))
+
+ vert_flux(:,1) = 0.
+
+ do iCell=1,grid % nCellsSolve
+
+ k = 2
+ do iTracer=1,num_tracers
+ weightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ weightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ vert_flux(iTracer,k) = w(k,iCell)*(weightK*tracers(iTracer,k,iCell)+weightKm1*tracers(iTracer,k-1,iCell))
+ enddo
+
+ do k=3,maxLevelCell(iCell)-1
+ do iTracer=1,num_tracers
+ vert_flux(iTracer,k) = mpas_ocn_tracer_advection_vflux3( tracers(iTracer,k-2,iCell),tracers(iTracer,k-1,iCell), &
+ tracers(iTracer,k ,iCell),tracers(iTracer,k+1,iCell), &
+ w(k,iCell), coef_3rd_order )
+ end do
+ end do
+
+ k = maxLevelCell(iCell)
+
+ do iTracer=1,num_tracers
+ weightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ weightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ vert_flux(iTracer,k) = w(k,iCell)*(weightK*tracers(iTracer,k,iCell)+weightKm1*tracers(iTracer,k-1,iCell))
+ enddo
+
+ vert_Flux(:, maxLevelCell(iCell)+1) = 0.0
+
+ do k=1,maxLevelCell(iCell)
+ do iTracer=1,num_tracers
+ tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + (vert_flux(iTracer, k+1) - vert_flux(iTracer, k))
+ end do
+ end do
+ end do
+
+ deallocate(vert_flux)
+
+ end subroutine mpas_ocn_tracer_advection_std_vadv3_tend!}}}
+
+end module mpas_ocn_tracer_advection_std_vadv3
Added: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv4.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv4.F         (rev 0)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_advection_std_vadv4.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -0,0 +1,105 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! ocn_tracer_advection_std_vadv4
+!
+!> \brief MPAS ocean 4th order vertical tracer advection driver (non-monotonic/fct)
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This module contains routines for 4th order vertical tracer advection.
+!
+!-----------------------------------------------------------------------
+module mpas_ocn_tracer_advection_std_vadv4
+
+ use mpas_kind_types
+ use mpas_grid_types
+ use mpas_configure
+ use mpas_dmpar
+
+ use mpas_ocn_tracer_advection_helpers
+
+ implicit none
+ private
+ save
+
+ public :: mpas_ocn_tracer_advection_std_vadv4_tend
+
+ contains
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+! routine mpas_ocn_tracer_advection_std_vadv4_tend
+!
+!> \brief MPAS ocean 4th order standard vertical tracer advection tendency
+!> \author Doug Jacobsen
+!> \date 03/09/12
+!> \version SVN:$Id:$
+!> \details
+!> This routine computes the 4th order vertical tracer advection tendencies.
+!
+!-----------------------------------------------------------------------
+ subroutine mpas_ocn_tracer_advection_std_vadv4_tend(tracers, w, verticalCellSize, grid, tend)!{{{
+ real (kind=RKIND), dimension(:,:,:), intent(inout) :: tend !< Input/Output: Tracer tendency
+ real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers !< Input: Tracer Values
+ real (kind=RKIND), dimension(:,:), intent(in) :: w !< Input: Vertical Velocity
+ real (kind=RKIND), dimension(:,:), intent(in) :: verticalCellSize !< Input: Distance between vertical interfaces of cell
+ type (mesh_type), intent(in) :: grid !< Input: Grid information
+
+ integer :: i, iCell, iEdge, k, iTracer, cell1, cell2
+
+ real (kind=RKIND), dimension(:,:), allocatable :: vert_flux
+ real (kind=RKIND) :: weightK, weightKm1
+ integer :: nVertLevels, num_tracers
+ integer, dimension(:), pointer :: maxLevelCell
+
+ nVertLevels = grid % nVertLevels
+ num_tracers = size(tracers, dim=1)
+ maxLevelCell => grid % maxLevelCell % array
+
+ allocate(vert_flux(num_tracers, nVertLevels+1))
+
+ ! vertical flux divergence
+ !
+
+ ! zero fluxes at top and bottom
+
+ vert_flux(:,1) = 0.
+
+ do iCell=1,grid % nCellsSolve
+
+ k = 2
+ do iTracer=1,num_tracers
+ weightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ weightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ vert_flux(iTracer,k) = w(k,iCell)*(weightK*tracers(iTracer,k,iCell)+weightKm1*tracers(iTracer,k-1,iCell))
+ enddo
+ do k=3,nVertLevels-1
+ do iTracer=1,num_tracers
+ vert_flux(iTracer,k) = mpas_ocn_tracer_advection_vflux4( tracers(iTracer,k-2,iCell),tracers(iTracer,k-1,iCell), &
+ tracers(iTracer,k ,iCell),tracers(iTracer,k+1,iCell), w(k,iCell) )
+ end do
+ end do
+
+ k = maxLevelCell(iCell)
+ do iTracer=1,num_tracers
+ weightK = verticalCellSize(k-1, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ weightKm1 = verticalCellSize(k, iCell) / (verticalCellSize(k-1, iCell) + verticalCellSize(k, iCell))
+ vert_flux(iTracer,k) = w(k,iCell)*(weightK*tracers(iTracer,k,iCell)+weightKm1*tracers(iTracer,k-1,iCell))
+ enddo
+
+ vert_flux(:,maxLevelCell(iCell)+1) = 0.0
+
+ do k=1,maxLevelCell(iCell)
+ do iTracer=1,num_tracers
+ tend(iTracer, k, iCell) = tend(iTracer, k, iCell) + (vert_flux(iTracer, k+1) - vert_flux(iTracer, k))
+ end do
+ end do
+
+ end do
+
+ deallocate(vert_flux)
+
+ end subroutine mpas_ocn_tracer_advection_std_vadv4_tend!}}}
+
+end module mpas_ocn_tracer_advection_std_vadv4
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv2.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv2.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv2.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -182,7 +182,7 @@
err = 0
hadv2On = .false.
- if (config_tracer_adv_order == 2) then
+ if (config_horiz_tracer_adv_order == 2) then
hadv2On = .true.
end if
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv3.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv3.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv3.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -221,11 +221,10 @@
err = 0
hadv3On = .false.
- if (config_tracer_adv_order == 3) then
+ if (config_horiz_tracer_adv_order == 3) then
hadv3On = .true.
- coef_3rd_order = 1.0
- if (config_monotonic) coef_3rd_order = 0.25
+ coef_3rd_order = config_coef_3rd_order
end if
!--------------------------------------------------------------------
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv4.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv4.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_tracer_hadv4.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -213,7 +213,7 @@
err = 0
hadv4On = .false.
- if (config_tracer_adv_order == 4) then
+ if (config_horiz_tracer_adv_order == 4) then
hadv4On = .true.
end if
Modified: branches/omp_blocks/io/src/core_ocean/mpas_ocn_vel_coriolis.F
===================================================================
--- branches/omp_blocks/io/src/core_ocean/mpas_ocn_vel_coriolis.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_ocean/mpas_ocn_vel_coriolis.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -62,7 +62,7 @@
!
!-----------------------------------------------------------------------
- subroutine ocn_vel_coriolis_tend(grid, pv_edge, h_edge, u, ke, tend, err)!{{{
+ subroutine ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, u, ke, tend, err)!{{{
!-----------------------------------------------------------------
!
@@ -71,7 +71,7 @@
!-----------------------------------------------------------------
real (kind=RKIND), dimension(:,:), intent(in) :: &
- pv_edge !< Input: Potential vorticity on edge
+ Vor_edge !< Input: Potential vorticity on edge
real (kind=RKIND), dimension(:,:), intent(in) :: &
h_edge !< Input: Thickness on edge
real (kind=RKIND), dimension(:,:), intent(in) :: &
@@ -138,7 +138,7 @@
q = 0.0
do j = 1,nEdgesOnEdge(iEdge)
eoe = edgesOnEdge(j,iEdge)
- workpv = 0.5 * (pv_edge(k,iEdge) + pv_edge(k,eoe))
+ workpv = 0.5 * (Vor_edge(k,iEdge) + Vor_edge(k,eoe))
q = q + weightsOnEdge(j,iEdge) * u(k,eoe) * workpv * h_edge(k,eoe)
end do
Modified: branches/omp_blocks/io/src/core_sw/Registry
===================================================================
--- branches/omp_blocks/io/src/core_sw/Registry        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/core_sw/Registry        2012-03-20 02:01:44 UTC (rev 1679)
@@ -4,7 +4,7 @@
namelist integer sw_model config_test_case 5
namelist character sw_model config_time_integration RK4
namelist real sw_model config_dt 172.8
-namelist integer sw_model config_calendar_type MPAS_360DAY
+namelist character sw_model config_calendar_type 360day
namelist character sw_model config_start_time 0000-01-01_00:00:00
namelist character sw_model config_stop_time none
namelist character sw_model config_run_duration none
Modified: branches/omp_blocks/io/src/external/Makefile
===================================================================
--- branches/omp_blocks/io/src/external/Makefile        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/external/Makefile        2012-03-20 02:01:44 UTC (rev 1679)
@@ -3,7 +3,7 @@
all: esmf_time
esmf_time:
-        ( cd esmf_time_f90; make FC="$(FC) $(FFLAGS)" CPP="$(CPP)" )
+        ( cd esmf_time_f90; $(MAKE) FC="$(FC) $(FFLAGS)" CPP="$(CPP)" )
clean:
-        ( cd esmf_time_f90; make clean )
+        ( cd esmf_time_f90; $(MAKE) clean )
Modified: branches/omp_blocks/io/src/external/esmf_time_f90/ESMF_Calendar.F90
===================================================================
--- branches/omp_blocks/io/src/external/esmf_time_f90/ESMF_Calendar.F90        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/external/esmf_time_f90/ESMF_Calendar.F90        2012-03-20 02:01:44 UTC (rev 1679)
@@ -51,14 +51,23 @@
INTEGER, PARAMETER :: MONTHS_PER_YEAR = 12
- INTEGER, PARAMETER :: mday(MONTHS_PER_YEAR) &
+
+ INTEGER, PARAMETER :: daysPerMonthNoLeap(MONTHS_PER_YEAR) &
= (/31,28,31,30,31,30,31,31,30,31,30,31/)
- INTEGER, PARAMETER :: mdayleap(MONTHS_PER_YEAR) &
+ INTEGER, PARAMETER :: daysPerMonthLeap(MONTHS_PER_YEAR) &
= (/31,29,31,30,31,30,31,31,30,31,30,31/)
- INTEGER, DIMENSION(365) :: daym
- INTEGER, DIMENSION(366) :: daymleap
+ INTEGER, PARAMETER :: daysPerMonth360(MONTHS_PER_YEAR) &
+ = (/30,30,30,30,30,30,30,30,30,30,30,30/)
+
+ INTEGER, DIMENSION(MONTHS_PER_YEAR) :: mday
+ INTEGER, DIMENSION(MONTHS_PER_YEAR) :: mdayleap
+
+ INTEGER, DIMENSION(:), POINTER :: daym
+ INTEGER, DIMENSION(:), POINTER :: daymleap
+
INTEGER :: mdaycum(0:MONTHS_PER_YEAR)
INTEGER :: mdayleapcum(0:MONTHS_PER_YEAR)
+
TYPE(ESMF_BaseTime), TARGET :: monthbdys(0:MONTHS_PER_YEAR)
TYPE(ESMF_BaseTime), TARGET :: monthbdysleap(0:MONTHS_PER_YEAR)
@@ -69,7 +78,6 @@
! ! F90 "enum" type to match C++ ESMC_CalendarType enum
type ESMF_CalendarType
- private
integer :: caltype
end type
@@ -152,7 +160,10 @@
!
! !PUBLIC MEMBER FUNCTIONS:
public ESMF_CalendarCreate
+ public ESMF_CalendarDestroy
+ public ESMF_GetCalendarType
+
! Required inherited and overridden ESMF_Base class methods
public ESMF_CalendarInitialized ! Only in this implementation, intended
@@ -165,6 +176,14 @@
!==============================================================================
+
+
+ type(ESMF_CalendarType) function ESMF_GetCalendarType()
+ ESMF_GetCalendarType = defaultCal % Type
+ end function ESMF_GetCalendarType
+
+
+!==============================================================================
!BOP
! !IROUTINE: ESMF_CalendarCreate - Create a new ESMF Calendar of built-in type
@@ -210,50 +229,61 @@
type(ESMF_DaysPerYear) :: dayspy
if ( present(rc) ) rc = ESMF_FAILURE
-! Calendar type is hard-coded. Use ESMF library if more flexibility is
-! needed.
-#ifdef NO_LEAP_CALENDAR
- if ( calendartype%caltype /= ESMF_CAL_NOLEAP%caltype ) then
+
+ if ( calendartype % caltype == ESMF_CAL_GREGORIAN % caltype ) then
+ ESMF_CalendarCreate % Type = ESMF_CAL_GREGORIAN
+ mday = daysPerMonthNoLeap
+         mdayleap = daysPerMonthLeap
+         allocate(daym(365))
+         allocate(daymleap(366))
+ else if ( calendartype % caltype == ESMF_CAL_NOLEAP % caltype ) then
+ ESMF_CalendarCreate % Type = ESMF_CAL_NOLEAP
+         mday = daysPerMonthNoLeap
+         mdayleap = daysPerMonthNoLeap
+         allocate(daym(365))
+         allocate(daymleap(365))
+ else if ( calendartype % caltype == ESMF_CAL_360DAY % caltype ) then
+ ESMF_CalendarCreate % Type = ESMF_CAL_360DAY
+ mday = daysPerMonth360
+         mdayleap = daysPerMonth360
+         allocate(daym(360))
+         allocate(daymleap(360))
+ else
write(6,*) 'Not a valid calendar type for this implementation'
- write(6,*) 'This implementation only allows ESMF_CAL_NOLEAP'
- write(6,*) 'calender type set to = ', calendartype%caltype
- write(6,*) 'NO_LEAP calendar type is = ', ESMF_CAL_NOLEAP%caltype
+ write(6,*) 'The current implementation only supports ESMF_CAL_NOLEAP, ESMF_CAL_GREGORIAN, ESMF_CAL_360DAY'
return
end if
- ESMF_CalendarCreate%Type = ESMF_CAL_NOLEAP
-#else
- if ( calendartype%caltype /= ESMF_CAL_GREGORIAN%caltype ) then
- write(6,*) 'Not a valid calendar type for this implementation'
- write(6,*) 'This implementation only allows ESMF_CAL_GREGORIAN'
- write(6,*) 'calender type set to = ', calendartype%caltype
- write(6,*) 'GREGORIAN calendar type is = ', ESMF_CAL_GREGORIAN%caltype
- return
- end if
- ESMF_CalendarCreate%Type = ESMF_CAL_GREGORIAN
-#endif
-! This is a bug on some systems -- need initial value set by compiler at
-! startup.
-! However, note that some older compilers do not support compile-time
-! initialization of data members of Fortran derived data types. For example,
-! PGI 5.x compilers do not support this F95 feature. See
-! NO_DT_COMPONENT_INIT.
- ESMF_CalendarCreate%Set = .true.
- ESMF_CalendarCreate%SecondsPerDay = SECONDS_PER_DAY
-! DaysPerYear and SecondsPerYear are incorrect for Gregorian calendars...
- dayspy%D = size(daym)
-!TBH: TODO: Replace DaysPerYear and SecondsPerYear with methods
-!TBH: TODO: since they only make sense for the NO_LEAP calendar!
- ESMF_CalendarCreate%DaysPerYear = dayspy
- ESMF_CalendarCreate%SecondsPerYear = ESMF_CalendarCreate%SecondsPerDay &
- * dayspy%D
-!TBH: TODO: use mdayleap for leap-year calendar
- ESMF_CalendarCreate%DaysPerMonth(:) = mday(:)
+ ESMF_CalendarCreate % Set = .true.
+ ESMF_CalendarCreate % DaysPerMonth(:) = mday(:)
+ ESMF_CalendarCreate % SecondsPerDay = SECONDS_PER_DAY
+
+!TBH: TODO: Replace DaysPerYear and SecondsPerYear with methods
+!TBH: TODO: since they only make sense for the NO_LEAP calendar!
+ dayspy % D = size(daym)
+ ESMF_CalendarCreate % DaysPerYear = dayspy
+ ESMF_CalendarCreate % SecondsPerYear = ESMF_CalendarCreate % SecondsPerDay * dayspy % D
+
if ( present(rc) ) rc = ESMF_SUCCESS
- end function ESMF_CalendarCreate
+ end function ESMF_CalendarCreate
+ subroutine ESMF_CalendarDestroy(rc)
+
+ integer, intent(out), optional :: rc
+
+ if ( present(rc) ) rc = ESMF_FAILURE
+
+ deallocate(daym)
+ deallocate(daymleap)
+
+ if ( present(rc) ) rc = ESMF_SUCCESS
+
+ end subroutine ESMF_CalendarDestroy
+
+
+
!==============================================================================
!BOP
! !IROUTINE: ESMF_CalendarInitialized - check if calendar was created
Modified: branches/omp_blocks/io/src/external/esmf_time_f90/ESMF_Stubs.F90
===================================================================
--- branches/omp_blocks/io/src/external/esmf_time_f90/ESMF_Stubs.F90        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/external/esmf_time_f90/ESMF_Stubs.F90        2012-03-20 02:01:44 UTC (rev 1679)
@@ -91,6 +91,8 @@
! NOOP
SUBROUTINE ESMF_Finalize( rc )
USE esmf_basemod
+ USE esmf_calendarmod
+
INTEGER, INTENT( OUT), OPTIONAL :: rc
#if (defined SPMD) || (defined COUP_CSM)
#include <mpif.h>
@@ -98,6 +100,8 @@
LOGICAL :: flag
INTEGER :: ier
+ CALL ESMF_CalendarDestroy()
+
IF ( PRESENT( rc ) ) rc = ESMF_SUCCESS
#if (defined SPMD) || (defined COUP_CSM)
CALL MPI_Finalized( flag, ier )
Modified: branches/omp_blocks/io/src/external/esmf_time_f90/Meat.F90
===================================================================
--- branches/omp_blocks/io/src/external/esmf_time_f90/Meat.F90        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/external/esmf_time_f90/Meat.F90        2012-03-20 02:01:44 UTC (rev 1679)
@@ -169,26 +169,34 @@
! added from share/module_date_time in WRF.
FUNCTION nfeb ( year ) RESULT (num_days)
+ USE ESMF_CalendarMod
+
! Compute the number of days in February for the given year
IMPLICIT NONE
INTEGER :: year
INTEGER :: num_days
-! TBH: TODO: Replace this hack with run-time decision based on
-! TBH: TODO: passed-in calendar.
-#ifdef NO_LEAP_CALENDAR
- num_days = 28 ! By default, February has 28 days ...
-#else
- num_days = 28 ! By default, February has 28 days ...
- IF (MOD(year,4).eq.0) THEN
- num_days = 29 ! But every four years, it has 29 days ...
- IF (MOD(year,100).eq.0) THEN
- num_days = 28 ! Except every 100 years, when it has 28 days ...
- IF (MOD(year,400).eq.0) THEN
- num_days = 29 ! Except every 400 years, when it has 29 days.
+
+ type(ESMF_CalendarType) :: calendarType
+
+ calendarType = ESMF_GetCalendarType()
+
+ IF (calendarType % caltype == ESMF_CAL_NOLEAP % caltype) then
+ num_days = 28
+ ELSE IF (calendarType % caltype == ESMF_CAL_360DAY % caltype) then
+ num_days = 30
+ ELSE
+ num_days = 28 ! By default, February has 28 days ...
+ IF (MOD(year,4).eq.0) THEN
+ num_days = 29 ! But every four years, it has 29 days ...
+ IF (MOD(year,100).eq.0) THEN
+ num_days = 28 ! Except every 100 years, when it has 28 days ...
+ IF (MOD(year,400).eq.0) THEN
+ num_days = 29 ! Except every 400 years, when it has 29 days.
+ END IF
END IF
END IF
END IF
-#endif
+
END FUNCTION nfeb
@@ -206,6 +214,8 @@
#else
IF ( nfeb( year ) .EQ. 29 ) THEN
num_diy = 366
+ ELSE IF ( nfeb( year ) .EQ. 30 ) THEN
+ num_diy = 360
ELSE
num_diy = 365
ENDIF
Modified: branches/omp_blocks/io/src/framework/mpas_timekeeping.F
===================================================================
--- branches/omp_blocks/io/src/framework/mpas_timekeeping.F        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/framework/mpas_timekeeping.F        2012-03-20 02:01:44 UTC (rev 1679)
@@ -114,15 +114,16 @@
implicit none
- integer, intent(in) :: calendar
+ character (len=*), intent(in) :: calendar
- TheCalendar = calendar
-
- if (TheCalendar == MPAS_GREGORIAN) then
+ if (trim(calendar) == 'gregorian') then
+ TheCalendar = MPAS_GREGORIAN
call ESMF_Initialize(defaultCalendar=ESMF_CAL_GREGORIAN)
- else if (TheCalendar == MPAS_GREGORIAN_NOLEAP) then
+ else if (trim(calendar) == 'gregorian_noleap') then
+ TheCalendar = MPAS_GREGORIAN_NOLEAP
call ESMF_Initialize(defaultCalendar=ESMF_CAL_NOLEAP)
- else if (TheCalendar == MPAS_360DAY) then
+ else if (trim(calendar) == '360day') then
+ TheCalendar = MPAS_360DAY
call ESMF_Initialize(defaultCalendar=ESMF_CAL_360DAY)
else
write(0,*) 'ERROR: mpas_timekeeping_init: Invalid calendar type'
Modified: branches/omp_blocks/io/src/framework/streams.c
===================================================================
--- branches/omp_blocks/io/src/framework/streams.c        2012-03-19 22:08:55 UTC (rev 1678)
+++ branches/omp_blocks/io/src/framework/streams.c        2012-03-20 02:01:44 UTC (rev 1679)
@@ -18,6 +18,37 @@
{
char fname[128];
+#ifndef MPAS_DEBUG
+ if(*id == 0){
+         sprintf(fname, "log.%4.4i.err", *id);
+         fd_err = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
+         if (dup2(fd_err, 2) < 0) {
+                 printf("Error duplicating STDERR</font>
<font color="blue">");
+                 return;
+         }
+
+         sprintf(fname, "log.%4.4i.out", *id);
+         fd_out = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
+         if (dup2(fd_out, 1) < 0) {
+                 printf("Error duplicating STDOUT</font>
<font color="blue">");
+                 return;
+         }
+ } else {
+         sprintf(fname, "/dev/null", *id);
+         fd_err = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
+         if (dup2(fd_err, 2) < 0) {
+                 printf("Error duplicating STDERR</font>
<font color="blue">");
+                 return;
+         }
+
+         sprintf(fname, "/dev/null", *id);
+         fd_out = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
+         if (dup2(fd_out, 1) < 0) {
+                 printf("Error duplicating STDOUT</font>
<font color="gray">");
+                 return;
+         }
+ }
+#else
sprintf(fname, "log.%4.4i.err", *id);
fd_err = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
if (dup2(fd_err, 2) < 0) {
@@ -31,6 +62,7 @@
printf("Error duplicating STDOUT</font>
<font color="blue">");
return;
}
+#endif
}
void close_streams()
</font>
</pre>