@@ -14,7 +14,7 @@ module atm_stream_co2_surface_source
1414 use shr_kind_mod , only : r8 = > shr_kind_r8 , CL = > shr_kind_cl, CS = > shr_kind_cs
1515 use shr_log_mod , only : errMsg = > shr_log_errMsg
1616 use spmd_utils , only : mpicom, masterproc, iam
17- use spmd_utils , only : mpi_character, mpi_integer
17+ use spmd_utils , only : mpi_character, mpi_integer, mpi_logical
1818 use cam_logfile , only : iulog
1919 use cam_abortutils , only : endrun
2020 use cam_esmf_mod , only : model_clock, model_mesh
@@ -26,19 +26,20 @@ module atm_stream_co2_surface_source
2626 public :: stream_co2_surface_source_init ! position datasets for dynamic co2_surface_source
2727 public :: stream_co2_surface_source_interp ! interpolates between two years of co2_surface_source file data
2828
29- logical , public , protected :: stream_co2_surface_source_is_initialized = .false.
30-
3129 type (shr_strdata_type) :: sdat_co2_surface_source ! input data stream
3230
3331 ! namelist variables
34- character (len= CL) :: stream_co2_surface_source_data_filename
3532 character (len= CL) :: stream_co2_surface_source_mesh_filename
36- character (len= CL) :: stream_co2_surface_source_varname ! variable name for co2_surface_source on stream file(s)
37- integer :: stream_co2_surface_source_year_first ! first year in stream to use
38- integer :: stream_co2_surface_source_year_last ! last year in stream to use
39- integer :: stream_co2_surface_source_year_align ! align stream_year_first
33+ character (len= CL) :: stream_co2_surface_source_data_filename
34+ character (len= CL) :: stream_co2_surface_source_data_varname ! variable name for co2_surface_source on stream file(s)
35+ integer :: stream_co2_surface_source_year_first ! first year in stream to use
36+ integer :: stream_co2_surface_source_year_last ! last year in stream to use
37+ integer :: stream_co2_surface_source_year_align ! align stream_year_first
4038
41- character (len=* ), parameter :: sourcefile = __FILE__
39+ logical , public , protected :: co2_surface_source
40+ logical , public , protected :: stream_co2_surface_source_is_initialized = .false.
41+
42+ character (len=* ), parameter :: u_FILE_u = __FILE__
4243
4344! ==============================================================================
4445contains
@@ -61,45 +62,50 @@ subroutine stream_co2_surface_source_readnl(nlfile)
6162 !- ----------------------------------------------------------------------
6263
6364 namelist / co2_surface_source_stream_nl/ &
64- stream_co2_surface_source_data_filename, &
65+ co2_surface_source, &
6566 stream_co2_surface_source_mesh_filename, &
67+ stream_co2_surface_source_data_filename, &
68+ stream_co2_surface_source_data_varname, &
6669 stream_co2_surface_source_year_first, &
6770 stream_co2_surface_source_year_last, &
68- stream_co2_surface_source_year_align, &
69- stream_co2_surface_source_var
71+ stream_co2_surface_source_year_align
7072
7173 ! Default values for namelist
74+ co2_surface_source = .false.
7275 stream_co2_surface_source_data_filename = ' '
7376 stream_co2_surface_source_mesh_filename = ' '
74- stream_co2_surface_source_varlist = ' '
75- stream_co2_surface_source_year_first = 1 ! first year in stream to use
76- stream_co2_surface_source_year_last = 1 ! last year in stream to use
77- stream_co2_surface_source_year_align = 1 ! align stream_co2_surface_source_year_first with this model year
77+ stream_co2_surface_source_data_varname = ' '
78+ stream_co2_surface_source_year_first = - 999 ! first year in stream to use
79+ stream_co2_surface_source_year_last = - 999 ! last year in stream to use
80+ stream_co2_surface_source_year_align = - 999 ! align stream_co2_surface_source_year_first with this model year
7881
7982 ! Read co2_surface_source_stream namelist
8083 if (masterproc) then
8184 open ( newunit= nu_nml, file= trim (nlfile), status= ' old' , iostat= nml_error )
8285 if (nml_error /= 0 ) then
83- call endrun(subName// ' : ERROR opening ' // trim (nlfile)// errMsg(sourcefile , __LINE__))
86+ call endrun(subName// ' : ERROR opening ' // trim (nlfile)// errMsg(u_FILE_u , __LINE__))
8487 end if
8588 call shr_nl_find_group_name(nu_nml, ' co2_surface_source_stream_nl' , status= nml_error)
8689 if (nml_error == 0 ) then
8790 read (nu_nml, nml= co2_surface_source_stream_nl, iostat= nml_error)
8891 if (nml_error /= 0 ) then
89- call endrun(' ERROR reading co2_surface_source_stream_nl namelist' // errMsg(sourcefile , __LINE__))
92+ call endrun(' ERROR reading co2_surface_source_stream_nl namelist' // errMsg(u_FILE_u , __LINE__))
9093 end if
9194 end if
9295 close (nu_nml)
9396 endif
97+ call mpi_bcast(co2_surface_source, &
98+ 1 , mpi_logical, 0 , mpicom, ierr)
99+ if (ierr /= 0 ) call endrun(trim (subname)// " : FATAL: mpi_bcast: stream_co2_surface_source_mesh_filename" )
94100 call mpi_bcast(stream_co2_surface_source_mesh_filename, &
95101 len (stream_co2_surface_source_mesh_filename), mpi_character, 0 , mpicom, ierr)
96102 if (ierr /= 0 ) call endrun(trim (subname)// " : FATAL: mpi_bcast: stream_co2_surface_source_mesh_filename" )
97103 call mpi_bcast(stream_co2_surface_source_data_filename, &
98104 len (stream_co2_surface_source_data_filename), mpi_character, 0 , mpicom, ierr)
99105 if (ierr /= 0 ) call endrun(trim (subname)// " : FATAL: mpi_bcast: stream_co2_surface_source_data_filename" )
100- call mpi_bcast(stream_co2_surface_source_varlist , &
101- len (stream_co2_surface_source_varlist ), mpi_character, 0 , mpicom, ierr)
102- if (ierr /= 0 ) call endrun(trim (subname)// " : FATAL: mpi_bcast: stream_co2_surface_source_varname " )
106+ call mpi_bcast(stream_co2_surface_source_data_varname , &
107+ len (stream_co2_surface_source_data_varname ), mpi_character, 0 , mpicom, ierr)
108+ if (ierr /= 0 ) call endrun(trim (subname)// " : FATAL: mpi_bcast: stream_co2_surface_source_data_varname " )
103109 call mpi_bcast(stream_co2_surface_source_year_first, &
104110 1 , mpi_integer, 0 , mpicom, ierr)
105111 if (ierr /= 0 ) call endrun(trim (subname)// " : FATAL: mpi_bcast: stream_co2_surface_source_year_first" )
@@ -117,8 +123,8 @@ subroutine stream_co2_surface_source_readnl(nlfile)
117123 trim (stream_co2_surface_source_data_filename)
118124 write (iulog,' (3a)' ) subname,' stream_co2_surface_source_mesh_filename = ' ,&
119125 trim (stream_co2_surface_source_mesh_filename)
120- write (iulog,' (3a)' ) subname,' stream_co2_surface_source_varname = ' ,&
121- trim (stream_co2_surface_source_varname )
126+ write (iulog,' (3a)' ) subname,' stream_co2_surface_source_data_varname = ' ,&
127+ trim (stream_co2_surface_source_data_varname )
122128 write (iulog,' (2a,i0)' ) subname,' stream_co2_surface_source_year_first = ' ,&
123129 stream_co2_surface_source_year_first
124130 write (iulog,' (2a,i0)' ) subname,' stream_co2_surface_source_year_last = ' ,&
@@ -158,8 +164,8 @@ subroutine stream_co2_surface_source_init(rc)
158164 stream_yearFirst = stream_co2_surface_source_year_first, &
159165 stream_yearLast = stream_co2_surface_source_year_last, &
160166 stream_yearAlign = stream_co2_surface_source_year_align, &
161- stream_fldlistFile = (/ stream_co2_surface_source_varname / ), &
162- stream_fldListModel = (/ stream_co2_surface_source_varname / ), &
167+ stream_fldlistFile = (/ stream_co2_surface_source_data_varname / ), &
168+ stream_fldListModel = (/ stream_co2_surface_source_data_varname / ), &
163169 stream_lev_dimname = ' null' , &
164170 stream_mapalgo = ' bilinear' , &
165171 stream_offset = 0 , &
@@ -210,18 +216,18 @@ subroutine stream_co2_surface_source_interp(cam_out, rc)
210216
211217 ! Get pointer for stream data that is time and spatially interpolated to model time and grid
212218 call dshr_fldbun_getFldPtr(sdat_co2_surface_source% pstrm(1 )% fldbun_model, &
213- stream_co2_surface_source_varname , fldptr1= dataptr1d, rc= rc)
219+ stream_co2_surface_source_data_varname , fldptr1= dataptr1d, rc= rc)
214220 if (ChkErr(rc,__LINE__,u_FILE_u)) return
215221
216222 ! Set output diagnostic co2_surface_source
217223 ig = 1
218224 do lchnk = begchunk,endchunk
219225 do icol = 1 ,get_ncols_p(lchnk)
220- cam_out(lchnk)% co2_diag (icol) = dataptr1d(ig)
226+ cam_out(lchnk)% co2diag (icol) = dataptr1d(ig)
221227 ig = ig + 1
222228 end do
223229 end do
224230
225231 end subroutine stream_co2_surface_source_interp
226232
227- end module atm_stream_co2_surface_source
233+ end module atm_stream_co2_surface_source
0 commit comments