/[MITgcm]/MITgcm/model/src/ini_grid.F
ViewVC logotype

Contents of /MITgcm/model/src/ini_grid.F

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


Revision 1.34 - (show annotations) (download)
Sun Jun 17 02:20:46 2012 UTC (12 years ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63o, checkpoint64a, checkpoint64c, checkpoint64b
Changes since 1.33: +48 -9 lines
move computation of recip of grid distance & area from INI_MASKS_ETC to INI_GRID

1 C $Header: /u/gcmpack/MITgcm/model/src/ini_grid.F,v 1.33 2010/03/16 00:08:27 jmc Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6
7 CBOP
8 C !ROUTINE: INI_GRID
9
10 C !INTERFACE:
11 SUBROUTINE INI_GRID( myThid )
12 C !DESCRIPTION:
13 C These arrays are used throughout the code in evaluating gradients,
14 C integrals and spatial avarages. This routine is called separately
15 C by each thread and initializes only the region of the domain it is
16 C "responsible" for.
17
18 C !CALLING SEQUENCE:
19 C INI_GRID
20 C | -- LOAD_GRID_SPACING
21 C | -- INI_VERTICAL_GRID
22 C | / INI_CARTESIAN_GRID
23 C | / INI_SPHERICAL_POLAR_GRID
24 C | \ INI_CURVILINEAR_GRID
25 C | \ INI_CYLINDER_GRID
26
27 C !USES:
28 IMPLICIT NONE
29 #include "SIZE.h"
30 #include "EEPARAMS.h"
31 #include "PARAMS.h"
32 #include "GRID.h"
33 #ifdef ALLOW_MNC
34 #include "MNC_PARAMS.h"
35 #endif
36 #ifdef ALLOW_MONITOR
37 #include "MONITOR.h"
38 #endif
39
40 C !INPUT/OUTPUT PARAMETERS:
41 C myThid :: my Thread Id number
42 INTEGER myThid
43
44 C !FUNCTIONS:
45 LOGICAL MASTER_CPU_IO
46 EXTERNAL MASTER_CPU_IO
47
48 C !LOCAL VARIABLES:
49 C bi, bj :: tile indices
50 C i, j :: Loop counters
51 C msgBuf :: Informational/error message buffer
52 INTEGER bi, bj
53 INTEGER i, j
54 CHARACTER*(MAX_LEN_MBUF) msgBuf
55 CEOP
56
57 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
58
59 C Load grid spacing (vector) from files
60 CALL LOAD_GRID_SPACING( myThid )
61
62 C Set up vertical grid and coordinate system
63 CALL INI_VERTICAL_GRID( myThid )
64
65 C Two examples are shown in this code. One illustrates the
66 C initialization of a cartesian grid. The other shows the
67 C inialization of a spherical polar grid. Other orthonormal grids
68 C can be fitted into this design. In this case custom metric terms
69 C also need adding to account for the projections of velocity
70 C vectors onto these grids. The structure used here also makes it
71 C possible to implement less regular grid mappings. In particular:
72 C o Schemes which leave out blocks of the domain that are
73 C all land could be supported.
74 C o Multi-level schemes such as icosohedral or cubic
75 C grid projectedions onto a sphere can also be fitted
76 C within the strategy we use.
77 C Both of the above also require modifying the support
78 C routines that map computational blocks to simulation
79 C domain blocks.
80
81 C Set up horizontal grid and coordinate system
82 IF ( usingCartesianGrid ) THEN
83 CALL INI_CARTESIAN_GRID( myThid )
84 ELSEIF ( usingSphericalPolarGrid ) THEN
85 CALL INI_SPHERICAL_POLAR_GRID( myThid )
86 ELSEIF ( usingCurvilinearGrid ) THEN
87 CALL INI_CURVILINEAR_GRID( myThid )
88 ELSEIF ( usingCylindricalGrid ) THEN
89 CALL INI_CYLINDER_GRID( myThid )
90 ELSE
91 _BEGIN_MASTER(myThid)
92 WRITE(msgBuf,'(2A)') 'S/R INI_GRID: ',
93 & 'No grid coordinate system has been selected'
94 CALL PRINT_ERROR( msgBuf , myThid)
95 CALL ALL_PROC_DIE( 0 )
96 STOP 'ABNORMAL END: S/R INI_GRID'
97 _END_MASTER(myThid)
98 ENDIF
99
100 C--- Calculate reciprocals grid lengths (formerly part of INI_MASKS_ETC)
101 DO bj = myByLo(myThid), myByHi(myThid)
102 DO bi = myBxLo(myThid), myBxHi(myThid)
103 DO j=1-OLy,sNy+OLy
104 DO i=1-OLx,sNx+OLx
105 IF ( dxG(i,j,bi,bj) .NE. 0. )
106 & recip_dxG(i,j,bi,bj) = 1. _d 0/dxG(i,j,bi,bj)
107 IF ( dyG(i,j,bi,bj) .NE. 0. )
108 & recip_dyG(i,j,bi,bj) = 1. _d 0/dyG(i,j,bi,bj)
109 IF ( dxC(i,j,bi,bj) .NE. 0. )
110 & recip_dxC(i,j,bi,bj) = 1. _d 0/dxC(i,j,bi,bj)
111 IF ( dyC(i,j,bi,bj) .NE. 0. )
112 & recip_dyC(i,j,bi,bj) = 1. _d 0/dyC(i,j,bi,bj)
113 IF ( dxF(i,j,bi,bj) .NE. 0. )
114 & recip_dxF(i,j,bi,bj) = 1. _d 0/dxF(i,j,bi,bj)
115 IF ( dyF(i,j,bi,bj) .NE. 0. )
116 & recip_dyF(i,j,bi,bj) = 1. _d 0/dyF(i,j,bi,bj)
117 IF ( dxV(i,j,bi,bj) .NE. 0. )
118 & recip_dxV(i,j,bi,bj) = 1. _d 0/dxV(i,j,bi,bj)
119 IF ( dyU(i,j,bi,bj) .NE. 0. )
120 & recip_dyU(i,j,bi,bj) = 1. _d 0/dyU(i,j,bi,bj)
121 IF ( rA (i,j,bi,bj) .NE. 0. )
122 & recip_rA (i,j,bi,bj) = 1. _d 0/rA (i,j,bi,bj)
123 IF ( rAs(i,j,bi,bj) .NE. 0. )
124 & recip_rAs(i,j,bi,bj) = 1. _d 0/rAs(i,j,bi,bj)
125 IF ( rAw(i,j,bi,bj) .NE. 0. )
126 & recip_rAw(i,j,bi,bj) = 1. _d 0/rAw(i,j,bi,bj)
127 IF ( rAz(i,j,bi,bj) .NE. 0. )
128 & recip_rAz(i,j,bi,bj) = 1. _d 0/rAz(i,j,bi,bj)
129 ENDDO
130 ENDDO
131 ENDDO
132 ENDDO
133
134 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
135
136 #ifdef ALLOW_MONITOR
137 IF ( MASTER_CPU_IO(myThid) ) THEN
138 C-- only the master thread is allowed to switch On/Off mon_write_stdout
139 C & mon_write_mnc (since it is the only thread that uses those flags):
140
141 IF (monitor_stdio) THEN
142 mon_write_stdout = .TRUE.
143 ELSE
144 mon_write_stdout = .FALSE.
145 ENDIF
146 mon_write_mnc = .FALSE.
147 #ifdef ALLOW_MNC
148 IF (useMNC .AND. monitor_mnc) THEN
149 DO i = 1,MAX_LEN_MBUF
150 mon_fname(i:i) = ' '
151 ENDDO
152 mon_fname(1:12) = 'monitor_grid'
153 CALL MNC_CW_SET_UDIM(mon_fname, 1, myThid)
154 mon_write_mnc = .TRUE.
155 ENDIF
156 #endif /* ALLOW_MNC */
157
158 ENDIF
159
160 C Print out statistics of each horizontal grid array (helps when debugging)
161 CALL MON_PRINTSTATS_RS(1,xC,'XC',myThid)
162 CALL MON_PRINTSTATS_RS(1,xG,'XG',myThid)
163 CALL MON_PRINTSTATS_RS(1,dxC,'DXC',myThid)
164 CALL MON_PRINTSTATS_RS(1,dxF,'DXF',myThid)
165 CALL MON_PRINTSTATS_RS(1,dxG,'DXG',myThid)
166 CALL MON_PRINTSTATS_RS(1,dxV,'DXV',myThid)
167 CALL MON_PRINTSTATS_RS(1,yC,'YC',myThid)
168 CALL MON_PRINTSTATS_RS(1,yG,'YG',myThid)
169 CALL MON_PRINTSTATS_RS(1,dyC,'DYC',myThid)
170 CALL MON_PRINTSTATS_RS(1,dyF,'DYF',myThid)
171 CALL MON_PRINTSTATS_RS(1,dyG,'DYG',myThid)
172 CALL MON_PRINTSTATS_RS(1,dyU,'DYU',myThid)
173 CALL MON_PRINTSTATS_RS(1,rA,'RA',myThid)
174 CALL MON_PRINTSTATS_RS(1,rAw,'RAW',myThid)
175 CALL MON_PRINTSTATS_RS(1,rAs,'RAS',myThid)
176 CALL MON_PRINTSTATS_RS(1,rAz,'RAZ',myThid)
177 CALL MON_PRINTSTATS_RS(1,angleCosC,'AngleCS',myThid)
178 CALL MON_PRINTSTATS_RS(1,angleSinC,'AngleSN',myThid)
179
180 IF ( MASTER_CPU_IO(myThid) ) THEN
181 mon_write_stdout = .FALSE.
182 mon_write_mnc = .FALSE.
183 ENDIF
184 #endif /* ALLOW_MONITOR */
185
186 C-- Everyone else must wait for the grid to be set
187 _BARRIER
188
189 RETURN
190 END

  ViewVC Help
Powered by ViewVC 1.1.22