/[MITgcm]/MITgcm_contrib/lab_sea_test/my_min_max_abs.F
ViewVC logotype

Annotation of /MITgcm_contrib/lab_sea_test/my_min_max_abs.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Mon Jul 12 01:00:20 2004 UTC (19 years, 10 months ago) by dimitri
Branch: MAIN
CVS Tags: HEAD
added my_min_max for pkg/seaice routines

1 dimitri 1.1 C $Header: $
2     C $Name: $
3    
4     #include "CPP_OPTIONS.h"
5    
6     C Simple versions of Martins modified min/max/abs functions
7    
8     _RS function mymax_R4( a, b )
9     implicit none
10     _RS a, b
11     _RS mymin_R4
12     external mymin_R4
13     mymax_R4 = -mymin_R4(-a, -b)
14     return
15     end
16    
17     _RS function mymax_R8( a, b )
18     implicit none
19     _RL a, b
20     _RL mymin_R8
21     external mymin_R8
22     mymax_R8 = -mymin_R8(-a, -b)
23     print*,'###max',a,b,mymax_R8
24     return
25     end
26    
27     _RS function mymin_R4( a, b )
28    
29     implicit none
30    
31     _RS a, b
32    
33     _RS myabs_R4
34     external myabs_R4
35    
36     Cml mymin_R4 = .5*(a+b)
37     mymin_R4 = .5*( a+b - myabs_R4(a-b) )
38     Cml mymin_R4 = MIN(a,b)
39    
40     Cml if ( a .lt. b ) then
41     Cml mymin_R4 = a
42     Cml else if ( a .gt. b ) then
43     Cml mymin_R4 = b
44     Cml else
45     Cml mymin_R4 = .5*(a+b)
46     Cml end if
47    
48     return
49     end
50    
51     _RL function mymin_R8( a, b )
52    
53     implicit none
54    
55     _RL a, b
56    
57     _RL myabs_R8
58     external myabs_R8
59    
60     Cml mymin_R8 = .5*(a+b)
61     mymin_R8 = .5*( a+b - myabs_R8(a-b) )
62     Cml mymin_R8 = MIN(a,b)
63    
64     Cml if ( a .lt. b ) then
65     Cml mymin_R8 = a
66     Cml else if ( a .gt. b ) then
67     Cml mymin_R8 = b
68     Cml else
69     Cml mymin_R8 = .5*(a+b)
70     Cml end if
71     print*,'###min',a,b,mymin_R8
72    
73     return
74     end
75    
76     _RS function myabs_R4( x )
77    
78     implicit none
79     C === Global variables ===
80     #include "SIZE.h"
81     #include "EEPARAMS.h"
82     #include "PARAMS.h"
83     C input parameter
84     _RS x
85     c local variable
86     _RS sf, rsf
87     _RS smoothAbsFuncRange
88    
89     c set default value. THhs will go in ini_parms
90     smoothAbsFuncRange = 0.
91    
92     if ( smoothAbsFuncRange .lt. 0.0 ) then
93     c limit of mymin(a,b) = .5*(a+b)
94     myabs_R4 = 0.
95     else
96     if ( smoothAbsFuncRange .ne. 0.0 ) then
97     sf = 10.0/smoothAbsFuncRange
98     rsf = 1./sf
99     else
100     c limit of mymin(a,b) = min(a,b)
101     sf = 0.
102     rsf = 0.
103     end if
104     c
105     if ( x .gt. smoothAbsFuncRange ) then
106     myabs_R4 = x
107     else if ( x .lt. -smoothAbsFuncRange ) then
108     myabs_R4 = -x
109     else
110     myabs_R4 = log(.5*(exp(x*sf)+exp(-x*sf)))*rsf
111     end if
112     end if
113    
114     return
115     end
116    
117     _RL function myabs_R8( x )
118    
119     implicit none
120     C === Global variables ===
121     #include "SIZE.h"
122     #include "EEPARAMS.h"
123     #include "PARAMS.h"
124     C input parameter
125     _RL x
126     c local variable
127     _RL sf, rsf
128     _RL smoothAbsFuncRange
129    
130     c set default value. THhs will go in ini_parms
131     smoothAbsFuncRange = 1.
132    
133     if ( smoothAbsFuncRange .lt. 0.0 ) then
134     c limit of mymin(a,b) = .5*(a+b)
135     myabs_R8 = 0.
136     else
137     if ( smoothAbsFuncRange .ne. 0.0 ) then
138     sf = 10.0D0/smoothAbsFuncRange
139     rsf = 1.D0/sf
140     else
141     c limit of mymin(a,b) = min(a,b)
142     sf = 0.D0
143     rsf = 0.D0
144     end if
145     c
146     if ( x .ge. smoothAbsFuncRange ) then
147     myabs_R8 = x
148     else if ( x .le. -smoothAbsFuncRange ) then
149     myabs_R8 = -x
150     else
151     myabs_R8 = log(.5*(exp(x*sf)+exp(-x*sf)))*rsf
152     end if
153     end if
154    
155     return
156     end

  ViewVC Help
Powered by ViewVC 1.1.22