-
Notifications
You must be signed in to change notification settings - Fork 8
/
hco_esmf_wrappers.F90
82 lines (70 loc) · 2.46 KB
/
hco_esmf_wrappers.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
!------------------------------------------------------------------------------
! Harmonized Emissions Component (HEMCO) !
!------------------------------------------------------------------------------
!BOP
!
! !MODULE: hco_esmf_wrappers
!
! !DESCRIPTION: Module HCO\_ESMF\_WRAPPERS defines quick wrapper functions for
! error checking and common ESMF operations, similar to "MAPL_Generic.h" in MAPL.
!\\
!\\
! !INTERFACE:
!
module hco_esmf_wrappers
!
! !USES:
!
! ESMF Types
use ESMF, only: ESMF_SUCCESS, ESMF_FAILURE
! MPI status in CESM
use cam_abortutils, only: endrun ! fatal terminator
use spmd_utils, only: iam, masterproc
use cam_logfile, only: iulog
implicit none
private
public :: HCO_ESMF_VRFY
public :: HCO_ESMF_ASRT
contains
! Note that the VERIFY and ASSERT functions here are inverse of MAPL and
! return 1 on success, 0 on failure.
logical function HCO_ESMF_VRFY(A, subname, line, ECRC)
integer, intent(in) :: A
character*(*), intent(in) :: subname
integer, intent(in) :: line
integer, optional, intent(out) :: ECRC
character(len=512) :: errmsg
HCO_ESMF_VRFY = A==ESMF_SUCCESS
if(.not. HCO_ESMF_VRFY) then
if(present(ECRC)) then
print'(A40,I10)', subname, line
ECRC = A
endif
write(errmsg,*) 'ABORT in HCO_ESMF_WRAPPERS. VRFY error in ', subname, ' line ', line
if(masterproc) then
write(iulog,*) errmsg
endif
call endrun(errmsg)
endif
end function HCO_ESMF_VRFY
logical function HCO_ESMF_ASRT(A, subname, line, ECRC)
logical, intent(in) :: A
character*(*), intent(in) :: subname
integer, intent(in) :: line
integer, optional, intent(out) :: ECRC
character(len=512) :: errmsg
HCO_ESMF_ASRT = A
if(.not. HCO_ESMF_ASRT) then
if(present(ECRC)) then
print'(A40,I10)', subname, line
ECRC = ESMF_FAILURE
endif
write(errmsg,*) 'ABORT in HCO_ESMF_WRAPPERS. ASRT error in ', subname, ' line ', line
if(masterproc) then
write(iulog,*) errmsg
endif
call endrun(errmsg)
endif
end function HCO_ESMF_ASRT
!EOC
end module hco_esmf_wrappers