source: CPL/oasis3/trunk/src/mod/oasis3/src/idivmax.f @ 1677

Last change on this file since 1677 was 1677, checked in by aclsce, 12 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 1.9 KB
Line 
1      FUNCTION idivmax (ka, kna, kguess)
2C****
3C               ******************************
4C               * OASIS FUNCTION  -  LEVEL T *
5C               * --------------     ------- *
6C               ******************************
7C
8C**** *idivmax*  - Search function
9C
10C     Purpose:
11C     -------
12C     Search the greatest common divisor of all elements of an integer array
13C
14C**   Interface:
15C     ---------
16C       *ii =*  *idivmax (ka, kna, kguess)*
17C
18C     Input:
19C     -----
20C                ka     : array to be searched (integer 1D)
21C                kna    : array dimension (integer)
22C                kguess : initial guess for the divisor (integer)
23C
24C     Output:
25C     ------
26C     None
27C
28C     Workspace:
29C     ---------
30C     None
31C
32C     Externals:
33C     ---------
34C     None
35C
36C     Reference:
37C     ---------
38C     See OASIS manual (1995)
39C
40C     History:
41C     -------
42C       Version   Programmer     Date      Description
43C       -------   ----------     ----      ----------- 
44C       2.0       L. Terray      95/09/01  created
45C
46C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47C
48C* ---------------------------- Include files ---------------------------
49C
50      USE mod_kinds_oasis
51      USE mod_unit
52C
53C* ---------------------------- Argument declarations -------------------
54C
55      INTEGER (kind=ip_intwp_p) idivmax, ka(kna)
56C
57C* ---------------------------- Poema verses ----------------------------
58C
59C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60C
61C
62C*    1. Check if kguess divides all ka elements
63C        ---------------------------------------
64C
65      DO 110 jk = kguess, 1, -1
66        IF (mod(kguess,jk) .EQ. 0) THEN
67            DO 120 ji = 1, kna
68              IF (mod(ka(ji),jk) .NE. 0) GO TO 110
69 120        CONTINUE
70            GO TO 130
71        ENDIF
72 110  CONTINUE
73 130  idivmax = jk
74C
75C
76C*    2. End of routine
77C        --------------
78C
79      RETURN
80      END
Note: See TracBrowser for help on using the repository browser.