-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.F90
85 lines (58 loc) · 1.55 KB
/
utils.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
module utils
use filestruct, only : dim_t
contains
subroutine get_dimname_str(ndims,dimids,dims,dimname_str)
integer, intent(in) :: ndims
integer, intent(in) :: dimids(:)
type(dim_t) :: dims(:)
character(len=*),intent(out) :: dimname_str
integer :: dlen
integer :: j
dimname_str = ' '
if(ndims>0) then
dimname_str(1:1) = '('
dlen=2
do j=1,ndims
dimname_str(dlen:) = trim(dims(dimids(j))%name)//','
dlen=dlen+ len_trim(dims(dimids(j))%name) + 1
end do
dimname_str(dlen-1:dlen-1) = ')'
end if
end subroutine get_dimname_str
subroutine get_dim_str(ndims,loc,dim_str)
integer, intent(in) :: ndims
integer, intent(in) :: loc(:)
character(len=*),intent(out) :: dim_str
integer :: dlen
integer :: j
dim_str = ' '
if(ndims>0) then
dim_str(1:1) = '('
dlen=2
do j=1,ndims
write(dim_str(dlen:),'(i6,a)') loc(j),','
dlen=len_trim(dim_str)+1
end do
dim_str(dlen-1:dlen-1) = ')'
end if
end subroutine get_dim_str
subroutine checknf90(ierr,returnflag,err_str)
use netcdf, only : nf90_noerr, nf90_strerror
integer, intent(in) :: ierr
logical, optional, intent(in) :: returnflag
character(len=*), optional, intent(in) :: err_str
if(ierr/=NF90_NOERR) then
print *, trim(nf90_strerror(ierr))
if(present(err_str)) then
print *, trim(err_str)
end if
if(present(returnflag)) then
if(returnflag) return
end if
#ifdef AIX
call xl__trbk()
#endif
stop
end if
end subroutine checknf90
end module utils