forked from uturuncoglu/RegESM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regesm.F90
158 lines (158 loc) · 7.16 KB
/
regesm.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
!-----------------------------------------------------------------------
!
! This file is part of ITU RegESM.
!
! ITU RegESM is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! ITU RegESM is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with ITU RegESM. If not, see <http://www.gnu.org/licenses/>.
!
!-----------------------------------------------------------------------
#define FILENAME "regesm.F90"
!
!-----------------------------------------------------------------------
! RegESM (REGional Earth System Model) Application
!-----------------------------------------------------------------------
!
program regesm
!
!-----------------------------------------------------------------------
! Used module declarations
!-----------------------------------------------------------------------
!
use ESMF
!
use mod_config
use mod_esmf_esm, only : ESM_SetServices
!
implicit none
!
!-----------------------------------------------------------------------
! Local variable declarations
!-----------------------------------------------------------------------
!
integer :: rc, urc
type(ESMF_GridComp) :: esmComp
type(ESMF_VM) :: vm
!
!-----------------------------------------------------------------------
! Initialize ESMF framework
!-----------------------------------------------------------------------
!
call ESMF_Initialize(logkindflag=ESMF_LOGKIND_MULTI, vm=vm, &
ioUnitLBound=20, ioUnitUBound=1000, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Create component
!-----------------------------------------------------------------------
!
esmComp = ESMF_GridCompCreate(name="regesm", rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Read main configuration file
!-----------------------------------------------------------------------
!
call read_config(vm, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Add additional fields to NUOPC field dictionary
!-----------------------------------------------------------------------
!
call set_field_dir(vm, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Register component
!-----------------------------------------------------------------------
!
call ESMF_GridCompSetServices(esmComp, &
ESM_SetServices, &
userRc=urc, &
rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Initialize component
!-----------------------------------------------------------------------
!
call ESMF_GridCompInitialize(esmComp, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Wait for finishing initialize phase
!-----------------------------------------------------------------------
!
call ESMF_VMBarrier(vm, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Run component
!-----------------------------------------------------------------------
!
call ESMF_GridCompRun(esmComp, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Finalize component
!-----------------------------------------------------------------------
!
call ESMF_GridCompFinalize(esmComp, userRc=urc, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
if (ESMF_LogFoundError(rcToCheck=urc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Destroy the earth system Component
!-----------------------------------------------------------------------
!
call ESMF_GridCompDestroy(esmComp, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!
!-----------------------------------------------------------------------
! Finalize ESMF framework
!-----------------------------------------------------------------------
!
call ESMF_Finalize(rc=rc)
!
end program regesm