[Dart-dev] [4755] DART/trunk/models/bgrid_solo/model_mod.f90: Added sanity checks for calling static_init_model() to
nancy at ucar.edu
nancy at ucar.edu
Wed Feb 23 15:31:16 MST 2011
Revision: 4755
Author: thoar
Date: 2011-02-23 15:31:16 -0700 (Wed, 23 Feb 2011)
Log Message:
-----------
Added sanity checks for calling static_init_model() to
all PUBLIC routines.
Modified Paths:
--------------
DART/trunk/models/bgrid_solo/model_mod.f90
-------------- next part --------------
Modified: DART/trunk/models/bgrid_solo/model_mod.f90
===================================================================
--- DART/trunk/models/bgrid_solo/model_mod.f90 2011-02-23 22:04:05 UTC (rev 4754)
+++ DART/trunk/models/bgrid_solo/model_mod.f90 2011-02-23 22:31:16 UTC (rev 4755)
@@ -100,6 +100,8 @@
revision = "$Revision$", &
revdate = "$Date$"
+logical, save :: module_initialized = .false.
+
!-----------------------------------------------------------------------
! bgrid_prog_var_mod:prog_var_type
! data structure that contains all prognostic fields and tracers
@@ -253,6 +255,8 @@
!!!integer :: i, j, k
+if ( .not. module_initialized ) call static_init_model
+
! Convert the vector to a B-grid native state representation
call vector_to_prog_var(x, get_model_size(), global_Var)
@@ -309,7 +313,10 @@
! INitializes class data for a B-grid model (all the stuff that needs to
! be done once.
+if ( module_initialized ) return ! only need to do this once.
+module_initialized = .true.
+
call fms_init()
call atmos_model_init()
@@ -321,7 +328,6 @@
! Initializes an instance (Var) of a B-grid model state variable
-
type(prog_var_type), intent(out) :: Var
call prog_var_init(Dynam%Hgrid, num_levels, ntracers, Var)
@@ -351,6 +357,8 @@
! Havana no longer distinguishes prognostic tracers
!!!integer :: ix, jx, kx, nt, ntp
+if ( .not. module_initialized ) call static_init_model
+
! Need to initialize var???
call init_model_instance(global_Var)
@@ -842,9 +850,10 @@
function get_model_size()
-
integer :: get_model_size
+if ( .not. module_initialized ) call static_init_model
+
get_model_size = model_size
end function get_model_size
@@ -1009,6 +1018,8 @@
type(time_type) :: get_model_time_step
+if ( .not. module_initialized ) call static_init_model
+
! Time_step_atmos is global static storage
get_model_time_step = Time_step_atmos
@@ -1046,6 +1057,8 @@
integer :: lat_index, lon_index
real(r8) :: lon, lat, lev
+if ( .not. module_initialized ) call static_init_model
+
! Get the bounds for storage on Temp and Velocity grids
tis = Dynam%Hgrid%Tmp%is; tie = Dynam%Hgrid%Tmp%ie
num_t_lons = tie - tis + 1
@@ -1153,6 +1166,7 @@
real(r8) :: lon_fract, lat_fract, val(2, 2), temp_lon, a(2)
real(r8) :: lon, lat, level, lon_lat_lev(3), pressure
+if ( .not. module_initialized ) call static_init_model
! All interps okay for now
istatus = 0
@@ -1500,6 +1514,8 @@
type(time_type), intent(out) :: i_time
+if ( .not. module_initialized ) call static_init_model
+
i_time = mTime
end subroutine init_time
@@ -1564,6 +1580,8 @@
character(len=NF90_MAX_NAME) :: str1
!-----------------------------------------------------------------------------------------
+if ( .not. module_initialized ) call static_init_model
+
ierr = 0 ! assume normal termination
!-------------------------------------------------------------------------------
@@ -1905,6 +1923,8 @@
integer :: kub, klb
integer :: nTmpI, nTmpJ, nVelI, nVelJ, nlev, ntracer
+if ( .not. module_initialized ) call static_init_model
+
ierr = 0 ! assume normal termination
!-------------------------------------------------------------------------------
@@ -2038,6 +2058,8 @@
real(r8), intent(out) :: pert_state(:)
logical, intent(out) :: interf_provided
+if ( .not. module_initialized ) call static_init_model
+
interf_provided = .false.
! you *cannot* set this to junk. in at least one
@@ -2055,10 +2077,12 @@
subroutine ens_mean_for_model(ens_mean)
!------------------------------------------------------------------
-! Not used in low-order models
+! Not used in this model.
real(r8), intent(in) :: ens_mean(:)
+if ( .not. module_initialized ) call static_init_model
+
end subroutine ens_mean_for_model
More information about the Dart-dev
mailing list