chgres_cube  1.3.0
 All Data Structures Files Functions Variables
chgres.F90
Go to the documentation of this file.
1 
5 
24  program chgres
25 
26  use mpi
27  use esmf
28 
29  use atmosphere, only : atmosphere_driver
30 
31  use program_setup, only : read_setup_namelist, &
32  read_varmap, &
33  convert_atm, &
34  convert_sfc
35 
36  use model_grid, only : define_target_grid, &
39 
40  use surface, only : surface_driver
41 
42  implicit none
43 
44  integer :: ierr, localpet, npets
45 
46  type(esmf_vm) :: vm
47 
48 !-------------------------------------------------------------------------
49 ! Initialize mpi and esmf environment.
50 !-------------------------------------------------------------------------
51 
52  call mpi_init(ierr)
53 
54  print*,"- INITIALIZE ESMF"
55  call esmf_initialize(rc=ierr)
56  if(esmf_logfounderror(rctocheck=ierr,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
57  call error_handler("INITIALIZING ESMF", ierr)
58 
59  print*,"- CALL VMGetGlobal"
60  call esmf_vmgetglobal(vm, rc=ierr)
61  if(esmf_logfounderror(rctocheck=ierr,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
62  call error_handler("IN VMGetGlobal", ierr)
63 
64  print*,"- CALL VMGet"
65  call esmf_vmget(vm, localpet=localpet, petcount=npets, rc=ierr)
66  if(esmf_logfounderror(rctocheck=ierr,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
67  call error_handler("IN VMGet", ierr)
68 
69  print*,'- NPETS IS ',npets
70  print*,'- LOCAL PET ',localpet
71 
72 !-------------------------------------------------------------------------
73 ! Read program configuration namelist.
74 !-------------------------------------------------------------------------
75 
77 
78 !-------------------------------------------------------------------------
79 ! Read variable mapping file (used for grib2 input data only).
80 !-------------------------------------------------------------------------
81 
82  call read_varmap
83 
84 !-------------------------------------------------------------------------
85 ! Create esmf grid objects for input and target grids.
86 !-------------------------------------------------------------------------
87 
88  call define_target_grid(localpet, npets)
89 
90  call define_input_grid(localpet, npets)
91 
92 !-------------------------------------------------------------------------
93 ! Convert atmospheric fields
94 !-------------------------------------------------------------------------
95 
96  if (convert_atm) then
97 
98  call atmosphere_driver(localpet)
99 
100  end if
101 
102 !-------------------------------------------------------------------------
103 ! Convert surface/nsst fields
104 !-------------------------------------------------------------------------
105 
106  if (convert_sfc) then
107 
108  call surface_driver(localpet)
109 
110  end if
111 
113 
114  print*,"- CALL ESMF_finalize"
115  call esmf_finalize(endflag=esmf_end_keepmpi, rc=ierr)
116 
117  call mpi_finalize(ierr)
118 
119  print*,"- DONE."
120 
121  end program chgres
subroutine, public cleanup_input_target_grid_data
Deallocate all esmf grid objects.
Process surface and nst fields.
Definition: surface.F90:21
subroutine, public read_setup_namelist(filename)
Reads program configuration namelist.
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
Definition: model_grid.F90:9
Process atmospheric fields.
Definition: atmosphere.F90:19
subroutine, public atmosphere_driver(localpet)
Driver routine to process for atmospheric fields.
Definition: atmosphere.F90:110
subroutine error_handler(string, rc)
General error handler.
Definition: utils.F90:9
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine, public read_varmap
Reads the variable mapping table, which is required for initializing with GRIB2 data.
program chgres
Initialize an FV3 model run.
Definition: chgres.F90:24
subroutine, public define_input_grid(localpet, npets)
Driver routine to setup the esmf grid object for the input grid.
Definition: model_grid.F90:117
subroutine, public define_target_grid(localpet, npets)
Setup the esmf grid object for the target grid.
subroutine, public surface_driver(localpet)
Driver routine to process surface/nst data.
Definition: surface.F90:150