-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample_app.F90
117 lines (95 loc) · 4.31 KB
/
sample_app.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
program sampleApp
!-----------------------------------------------------------------------------
! Generic ESMF Main
!-----------------------------------------------------------------------------
use ESMF
use sample_driver_mod, only: &
driver_SS => SetServices
implicit none
integer :: rc, userRc
type(ESMF_Config) :: config
type(ESMF_GridComp) :: drvComp
character(ESMF_MAXSTR) :: drvName
! -> INITIALIZE ESMF
call ESMF_Initialize(defaultCalkind=ESMF_CALKIND_GREGORIAN, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
#ifdef DEBUG
! -> FLUSH LOGS IMMEDIATELY
call ESMF_LogSet(flush=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
#endif
call ESMF_LogWrite("Sample App STARTING", ESMF_LOGMSG_INFO, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!-----------------------------------------------------------------------------
! -> CREATE THE CONFIG
config = ESMF_ConfigCreate(rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> LOAD THE CONFIG
call ESMF_ConfigLoadFile(config, "sample.rc", rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> SET THE DRIVER NAME
call ESMF_ConfigGetAttribute(config, drvName, &
label="driver_name:", default="DRIVER", rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> CREATE THE DRIVER
drvComp = ESMF_GridCompCreate(name=trim(drvName), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> SET THE CONFIG
call ESMF_GridCompSet(drvComp, config=config, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> SET DRIVER SERVICES
call ESMF_GridCompSetServices(drvComp, driver_SS, userRc=userRc, 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=userRc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> INITIALIZE THE DRIVER
call ESMF_GridCompInitialize(drvComp, userRc=userRc, 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=userRc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> RUN THE DRIVER
call ESMF_GridCompRun(drvComp, userRc=userRc, 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=userRc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! -> FINALIZE THE DRIVER
call ESMF_GridCompFinalize(drvComp, userRc=userRc, 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=userRc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
!-----------------------------------------------------------------------------
call ESMF_LogWrite("Sample App FINISHED", ESMF_LOGMSG_INFO, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) &
call ESMF_Finalize(endflag=ESMF_END_ABORT)
! FINALIZE ESMF
call ESMF_Finalize()
end program