1 | MODULE isfutils |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE isfutils *** |
---|
4 | !! istutils module : miscelenious useful routines |
---|
5 | !!====================================================================== |
---|
6 | !! History : 4.1 ! 2019-09 (P. Mathiot) original code |
---|
7 | !!---------------------------------------------------------------------- |
---|
8 | |
---|
9 | !!---------------------------------------------------------------------- |
---|
10 | !! isfutils : - read_2dcstdta to read a constant input file with iom_get |
---|
11 | !! - debug to print array sum, min, max in ocean.output |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | |
---|
14 | USE iom |
---|
15 | USE lib_fortran |
---|
16 | USE lib_mpp |
---|
17 | |
---|
18 | IMPLICIT NONE |
---|
19 | |
---|
20 | PRIVATE |
---|
21 | |
---|
22 | INTERFACE debug |
---|
23 | MODULE PROCEDURE debug2d, debug3d |
---|
24 | END INTERFACE debug |
---|
25 | |
---|
26 | PUBLIC read_2dcstdta, debug |
---|
27 | |
---|
28 | CONTAINS |
---|
29 | |
---|
30 | SUBROUTINE read_2dcstdta(cdfile, cdvar, pvar) |
---|
31 | !!-------------------------------------------------------------------- |
---|
32 | !! *** ROUTINE read_2dcstdta *** |
---|
33 | !! |
---|
34 | !! ** Purpose : read input file |
---|
35 | !! |
---|
36 | !!-------------------------------------------------------------------- |
---|
37 | !!-------------------------- OUT ------------------------------------- |
---|
38 | REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: pvar ! output variable |
---|
39 | !!-------------------------- IN ------------------------------------- |
---|
40 | CHARACTER(len=256) , INTENT(in ) :: cdfile, cdvar ! input file name and variable name |
---|
41 | !!-------------------------------------------------------------------- |
---|
42 | INTEGER :: inum |
---|
43 | !!-------------------------------------------------------------------- |
---|
44 | |
---|
45 | CALL iom_open( cdfile, inum ) |
---|
46 | CALL iom_get( inum, jpdom_data, cdvar, pvar, 1) |
---|
47 | CALL iom_close(inum) |
---|
48 | |
---|
49 | END SUBROUTINE read_2dcstdta |
---|
50 | |
---|
51 | SUBROUTINE debug2d(cdtxt,pvar) |
---|
52 | !!-------------------------------------------------------------------- |
---|
53 | !! *** ROUTINE isf_debug2d *** |
---|
54 | !! |
---|
55 | !! ** Purpose : add debug print |
---|
56 | !! |
---|
57 | !!-------------------------------------------------------------------- |
---|
58 | !!-------------------------- OUT ------------------------------------- |
---|
59 | !!-------------------------- IN ------------------------------------- |
---|
60 | CHARACTER(LEN=256) , INTENT(in ) :: cdtxt |
---|
61 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: pvar |
---|
62 | !!-------------------------------------------------------------------- |
---|
63 | REAL(wp) :: zmin, zmax, zsum |
---|
64 | !!-------------------------------------------------------------------- |
---|
65 | ! |
---|
66 | zsum = glob_sum( 'debug', pvar(:,:) ) |
---|
67 | zmin = MINVAL( pvar(:,:) ) ; CALL mpp_min( 'debug', zmin ) ! min over the global domain |
---|
68 | zmax = MAXVAL( pvar(:,:) ) ; CALL mpp_max( 'debug', zmax ) ! max over the global domain |
---|
69 | ! |
---|
70 | WRITE(numout,*) TRIM(cdtxt),' (min, max, sum) : ',zmin, zmax, zsum |
---|
71 | ! |
---|
72 | FLUSH(numout) |
---|
73 | END SUBROUTINE debug2d |
---|
74 | |
---|
75 | SUBROUTINE debug3d(cdtxt,pvar) |
---|
76 | !!-------------------------------------------------------------------- |
---|
77 | !! *** ROUTINE isf_debug3d *** |
---|
78 | !! |
---|
79 | !! ** Purpose : add debug print |
---|
80 | !! |
---|
81 | !!-------------------------------------------------------------------- |
---|
82 | !!-------------------------- OUT ------------------------------------- |
---|
83 | !!-------------------------- IN ------------------------------------- |
---|
84 | CHARACTER(LEN=256) , INTENT(in ) :: cdtxt |
---|
85 | REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pvar |
---|
86 | !!-------------------------------------------------------------------- |
---|
87 | REAL(wp) :: zmin, zmax, zsum |
---|
88 | !!-------------------------------------------------------------------- |
---|
89 | ! |
---|
90 | zsum = glob_sum( 'debug', pvar(:,:) ) |
---|
91 | zmin = MINVAL( pvar(:,:) ) ; CALL mpp_min( 'debug', zmin ) ! min over the global domain |
---|
92 | zmax = MAXVAL( pvar(:,:) ) ; CALL mpp_max( 'debug', zmax ) ! max over the global domain |
---|
93 | ! |
---|
94 | WRITE(numout,*) TRIM(cdtxt),' (min, max, sum) : ',zmin, zmax, zsum |
---|
95 | ! |
---|
96 | FLUSH(numout) |
---|
97 | ! |
---|
98 | END SUBROUTINE debug3d |
---|
99 | |
---|
100 | END MODULE isfutils |
---|
101 | |
---|