GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: phylmd/phyetat0_get_mod.F90 Lines: 43 47 91.5 %
Date: 2023-06-30 12:56:34 Branches: 105 158 66.5 %

Line Branch Exec Source
1
MODULE phyetat0_get_mod
2
3
  PRIVATE
4
  PUBLIC :: phyetat0_get, phyetat0_srf
5
6
  INTERFACE phyetat0_get
7
    MODULE PROCEDURE phyetat0_get10, phyetat0_get20, phyetat0_get11, phyetat0_get21
8
  END INTERFACE phyetat0_get
9
  INTERFACE phyetat0_srf
10
    MODULE PROCEDURE phyetat0_srf20, phyetat0_srf30, phyetat0_srf21, phyetat0_srf31
11
  END INTERFACE phyetat0_srf
12
13
CONTAINS
14
15
!==============================================================================
16
68
LOGICAL FUNCTION phyetat0_get10(field, name, descr, default) RESULT(lFound)
17
! Read a field. Check whether reading succeded and use default value if not.
18
  IMPLICIT NONE
19
  REAL,             INTENT(INOUT) :: field(:) ! klon
20
  CHARACTER(LEN=*), INTENT(IN)    :: name
21
  CHARACTER(LEN=*), INTENT(IN)    :: descr
22
  REAL,             INTENT(IN)    :: default
23
!------------------------------------------------------------------------------
24
68
  REAL :: fld(SIZE(field),1)
25


33898
  lFound = phyetat0_get21(fld, [name], descr, default); field = fld(:,1)
26
34
END FUNCTION phyetat0_get10
27
!==============================================================================
28
32
LOGICAL FUNCTION phyetat0_get20(field, name, descr, default) RESULT(lFound)
29
! Same as phyetat0_get11, field on multiple levels.
30
  IMPLICIT NONE
31
  REAL,             INTENT(INOUT) :: field(:,:) ! klon, nlev
32
  CHARACTER(LEN=*), INTENT(IN)    :: name
33
  CHARACTER(LEN=*), INTENT(IN)    :: descr
34
  REAL,             INTENT(IN)    :: default
35
!-----------------------------------------------------------------------------
36

48
  lFound = phyetat0_get21(field, [name], descr, default)
37
16
END FUNCTION phyetat0_get20
38
!==============================================================================
39

2
LOGICAL FUNCTION phyetat0_get11(field, name, descr, default) RESULT(lFound)
40
! Same as phyetat0_get11, multiple names.
41
  IMPLICIT NONE
42
  REAL,             INTENT(INOUT) :: field(:) ! klon
43
  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
44
  CHARACTER(LEN=*), INTENT(IN)    :: descr
45
  REAL,             INTENT(IN)    :: default
46
!-----------------------------------------------------------------------------
47
4
  REAL :: fld(SIZE(field),1)
48
1992
  lFound = phyetat0_get21(fld, name, descr, default); field = fld(:,1)
49
2
END FUNCTION phyetat0_get11
50
!==============================================================================
51
349
LOGICAL FUNCTION phyetat0_get21(field, name, descr, default, tname) RESULT(lFound)
52
! Same as phyetat0_get11, field on multiple levels, multiple names.
53
  USE iostart,           ONLY: get_field
54
  USE print_control_mod, ONLY: lunout
55
  IMPLICIT NONE
56
  REAL,             INTENT(INOUT) :: field(:,:) ! klon, nlev
57
  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
58
  CHARACTER(LEN=*), INTENT(IN)    :: descr
59
  REAL,             INTENT(IN)    :: default
60
  CHARACTER(LEN=*), OPTIONAL, INTENT(OUT) :: tname
61
!-----------------------------------------------------------------------------
62
349
  CHARACTER(LEN=LEN(name)) :: tnam
63
  INTEGER :: i
64
379
  DO i = 1, SIZE(name)
65
349
    CALL get_field(TRIM(name(i)), field, lFound)
66
349
    IF(lFound) EXIT
67
379
    WRITE(lunout,*) "phyetat0: Missing field <",TRIM(name(i)),"> "
68
  END DO
69
349
  IF(.NOT.lFound) THEN
70
30
    WRITE(lunout,*) "Slightly distorted start ; continuing."
71

105500
    field(:,:) = default
72

30
    tnam = name(1)
73
  ELSE
74

319
    tnam = name(i)
75
  END IF
76
349
  WRITE(lunout,'(2(a,ES14.7))') 'phyetat0: '//TRIM(tnam)//' ('//TRIM(descr)//') min/max=', &
77







2683218
    MINval(field),' ',MAXval(field)
78

349
  IF(PRESENT(tname)) tname = tnam
79
349
END FUNCTION phyetat0_get21
80
!==============================================================================
81
142
LOGICAL FUNCTION phyetat0_srf20(field, name, descr, default) RESULT(lFound)
82
! Read a field per sub-surface.
83
! Check whether reading succeded and use default value if not.
84
  IMPLICIT NONE
85
  REAL,             INTENT(INOUT) :: field(:,:)
86
  CHARACTER(LEN=*), INTENT(IN)    :: name
87
  CHARACTER(LEN=*), INTENT(IN)    :: descr
88
  REAL,             INTENT(IN)    :: default
89
!-----------------------------------------------------------------------------
90
142
  REAL :: fld(SIZE(field,1),1,SIZE(field,2))
91


285778
  lFound = phyetat0_srf31(fld, [name], descr, default); field = fld(:,1,:)
92
71
END FUNCTION phyetat0_srf20
93
94
!==============================================================================
95
4
LOGICAL FUNCTION phyetat0_srf30(field, name, descr, default) RESULT(lFound)
96
! Same as phyetat0_sfr11, multiple names tested one after the other.
97
  IMPLICIT NONE
98
  REAL,             INTENT(INOUT) :: field(:,:,:)
99
  CHARACTER(LEN=*), INTENT(IN)    :: name
100
  CHARACTER(LEN=*), INTENT(IN)    :: descr
101
  REAL,             INTENT(IN)    :: default
102
!-----------------------------------------------------------------------------
103

6
  lFound = phyetat0_srf31(field, [name], descr, default)
104
2
END FUNCTION phyetat0_srf30
105
106
!==============================================================================
107
LOGICAL FUNCTION phyetat0_srf21(field, name, descr, default) RESULT(lFound)
108
! Same as phyetat0_sfr11, field on multiple levels.
109
  IMPLICIT NONE
110
  REAL,             INTENT(INOUT) :: field(:,:)
111
  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
112
  CHARACTER(LEN=*), INTENT(IN)    :: descr
113
  REAL,             INTENT(IN)    :: default
114
!-----------------------------------------------------------------------------
115
  REAL :: fld(SIZE(field,1),1,SIZE(field,2))
116
  lFound = phyetat0_srf31(fld, name, descr, default); field = fld(:,1,:)
117
END FUNCTION phyetat0_srf21
118
119
!==============================================================================
120

73
LOGICAL FUNCTION phyetat0_srf31(field, name, descr, default) RESULT(lFound)
121
! Same as phyetat0_sfr11, field on multiple levels, multiple names tested one after the other.
122
  USE iostart,           ONLY: get_field
123
  USE print_control_mod, ONLY: lunout
124
  USE strings_mod,       ONLY: int2str, maxlen
125
  IMPLICIT NONE
126
  REAL,             INTENT(INOUT) :: field(:,:,:)
127
  CHARACTER(LEN=*), INTENT(IN)    :: name(:)
128
  CHARACTER(LEN=*), INTENT(IN)    :: descr
129
  REAL,             INTENT(IN)    :: default
130
!-----------------------------------------------------------------------------
131
  INTEGER :: nsrf, i
132
146
  CHARACTER(LEN=maxlen) :: nam(SIZE(name)), tname, des
133
73
  IF(SIZE(field,3)>99) CALL abort_physic("phyetat0", "Too much sub-cells", 1)
134
370
  DO nsrf = 1, SIZE(field,3)
135

594
    DO i = 1, SIZE(name); nam(i) = TRIM(name(i))//TRIM(int2str(nsrf,2)); END DO
136
297
    des = TRIM(descr)//" srf:"//int2str(nsrf,2)
137
370
    lFound = phyetat0_get21(field(:,:,nsrf), nam, TRIM(des), default, tname)
138
  END DO
139
73
  WRITE(lunout,'(2(a,ES14.7))') 'phyetat0: '//TRIM(tname)//' ('//TRIM(descr)//') min/max=', &
140








1367870
    MINval(field),' ',MAXval(field)
141
73
END FUNCTION phyetat0_srf31
142
143
END MODULE phyetat0_get_mod