sfc_climo_gen  1.3.0
 All Data Structures Files Functions Variables
driver.F90
Go to the documentation of this file.
1 
5 
24  program driver
25 
26  use model_grid
27  use source_grid
28  use program_setup
29  use utils
30  use esmf
31 
32  implicit none
33 
34  integer :: rc
35  integer :: localpet
36  integer :: npets
37 
38  type(esmf_vm) :: vm
39  type(esmf_regridmethod_flag) :: method
40 
41 !-------------------------------------------------------------------------
42 ! Initialize MPI and ESMF environments.
43 !-------------------------------------------------------------------------
44 
45  call mpi_init(rc)
46 
47  print*,"- INITIALIZE ESMF"
48  call esmf_initialize(rc=rc)
49  if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
50  call error_handler("INITIALIZING ESMF", rc)
51 
52  print*,"- CALL VMGetGlobal"
53  call esmf_vmgetglobal(vm, rc=rc)
54  if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
55  call error_handler("IN VMGetGlobal.", rc)
56 
57  print*,"- CALL VMGet"
58  call esmf_vmget(vm, localpet=localpet, petcount=npets, rc=rc)
59  if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
60  call error_handler("IN VMGet.", rc)
61 
62  print*,'- NPETS IS ',npets
63  print*,'- LOCAL PET ',localpet
64 
65 !-------------------------------------------------------------------------
66 ! Program set up step.
67 !-------------------------------------------------------------------------
68 
69  call read_setup_namelist(localpet)
70 
71 !-------------------------------------------------------------------------
72 ! Define fv3 model grid.
73 !-------------------------------------------------------------------------
74 
75  call define_model_grid(localpet, npets)
76 
77 !-------------------------------------------------------------------------
78 ! Interpolate fields. Vegetation type must be done first as
79 ! it defines which points are permanent land ice.
80 !-------------------------------------------------------------------------
81 
82  call define_source_grid(localpet, npets, input_vegetation_type_file)
83  method=esmf_regridmethod_nearest_stod
84  call interp(localpet, method, input_vegetation_type_file)
86 
87 ! Snow free albedo
88 
89  if (trim(input_snowfree_albedo_file) /= "NULL") then
90  call define_source_grid(localpet, npets, input_snowfree_albedo_file)
91  method=esmf_regridmethod_bilinear
92  if (trim(snowfree_albedo_method)=="conserve") method=esmf_regridmethod_conserve
93  call interp(localpet, method, input_snowfree_albedo_file)
95  endif
96 
97 ! Maximum snow albedo
98 
99  if (trim(input_maximum_snow_albedo_file) /= "NULL") then
100  call define_source_grid(localpet, npets, input_maximum_snow_albedo_file)
101  method=esmf_regridmethod_bilinear
102  if (trim(maximum_snow_albedo_method)=="conserve") method=esmf_regridmethod_conserve
103  call interp(localpet, method, input_maximum_snow_albedo_file)
105  endif
106 
107 ! FACSF - fractional coverage for strong zenith angle
108 ! dependant albedo.
109 
110  if (trim(input_facsf_file) /= "NULL") then
111  call define_source_grid(localpet, npets, input_facsf_file)
112  method=esmf_regridmethod_bilinear
113  call interp(localpet, method, input_facsf_file)
115  endif
116 
117 ! Soil substrate temperature
118 
119  if (trim(input_substrate_temperature_file) /= "NULL") then
120  call define_source_grid(localpet, npets, input_substrate_temperature_file)
121  method=esmf_regridmethod_bilinear
122  call interp(localpet, method, input_substrate_temperature_file)
124  endif
125 
126 ! Slope type
127 
128  if (trim(input_slope_type_file) /= "NULL") then
129  call define_source_grid(localpet, npets, input_slope_type_file)
130  method=esmf_regridmethod_nearest_stod
131  call interp(localpet, method, input_slope_type_file)
133  endif
134 
135 ! Soil type
136 
137  if (trim(input_soil_type_file) /= "NULL") then
138  call define_source_grid(localpet, npets, input_soil_type_file)
139  method=esmf_regridmethod_nearest_stod
140  call interp(localpet, method, input_soil_type_file)
142  endif
143 
144 ! Vegetation greenness
145 
146  if (trim(input_vegetation_greenness_file) /= "NULL") then
147  call define_source_grid(localpet, npets, input_vegetation_greenness_file)
148  method=esmf_regridmethod_bilinear
149  if (trim(vegetation_greenness_method)=="conserve") method=esmf_regridmethod_conserve
150  call interp(localpet, method, input_vegetation_greenness_file)
152  endif
153 
154 ! Leaf Area Index
155 
156  if (trim(input_leaf_area_index_file) /= "NULL") then
157  call define_source_grid(localpet, npets, input_leaf_area_index_file)
158  method=esmf_regridmethod_bilinear
159  if (trim(leaf_area_index_method)=="conserve") method=esmf_regridmethod_conserve
160  call interp(localpet, method, input_leaf_area_index_file)
162  endif
163 
164  call model_grid_cleanup
165 
166  print*,"- CALL ESMF_finalize"
167  call esmf_finalize(endflag=esmf_end_keepmpi, rc=rc)
168 
169  call mpi_finalize(rc)
170 
171  print*,'- DONE.'
172  stop
173 
174  end program driver
subroutine, public source_grid_cleanup
Free up memory associated with this module.
subroutine, public define_source_grid(localpet, npets, input_file)
Defines esmf grid object for source grid.
Definition: source_grid.F90:51
subroutine, public model_grid_cleanup
Model grid cleanup.
Definition: model_grid.F90:387
subroutine, public define_model_grid(localpet, npets)
Define model grid.
Definition: model_grid.F90:53
This module defines the model grid.
Definition: model_grid.F90:10
program driver
Reads static surface data on a global lat/lon grid, interpolates the data to the fv3 model grid...
Definition: driver.F90:24
subroutine, public error_handler(string, rc)
Handle errors.
Definition: utils.f90:48
Set up program execution.
subroutine interp(localpet, method, input_file)
Read the input source data and interpolate it to the model grid.
Definition: interp.F90:13
subroutine, public read_setup_namelist(localpet)
Read program setup namelist.
Read grid specs, date information and land/sea mask for the source data that will be interpolated to ...
Definition: source_grid.F90:12
Utilities.
Definition: utils.f90:8