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

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

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


Revision 1.34 - (hide annotations) (download)
Sun Jun 17 02:20:46 2012 UTC (11 years, 11 months 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 jmc 1.34 C $Header: /u/gcmpack/MITgcm/model/src/ini_grid.F,v 1.33 2010/03/16 00:08:27 jmc Exp $
2 adcroft 1.8 C $Name: $
3 cnh 1.1
4 jmc 1.19 #include "PACKAGES_CONFIG.h"
5 cnh 1.5 #include "CPP_OPTIONS.h"
6 cnh 1.1
7 cnh 1.10 CBOP
8     C !ROUTINE: INI_GRID
9 edhill 1.21
10 cnh 1.10 C !INTERFACE:
11 cnh 1.1 SUBROUTINE INI_GRID( myThid )
12 edhill 1.21 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 cnh 1.10
18 jmc 1.32 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 cnh 1.10 C !USES:
28 adcroft 1.6 IMPLICIT NONE
29 cnh 1.1 #include "SIZE.h"
30     #include "EEPARAMS.h"
31     #include "PARAMS.h"
32 jmc 1.28 #include "GRID.h"
33 edhill 1.23 #ifdef ALLOW_MNC
34     #include "MNC_PARAMS.h"
35     #endif
36 edhill 1.21 #ifdef ALLOW_MONITOR
37     #include "MONITOR.h"
38     #endif
39 cnh 1.1
40 cnh 1.10 C !INPUT/OUTPUT PARAMETERS:
41 jmc 1.31 C myThid :: my Thread Id number
42 cnh 1.1 INTEGER myThid
43    
44 jmc 1.34 C !FUNCTIONS:
45 jmc 1.30 LOGICAL MASTER_CPU_IO
46     EXTERNAL MASTER_CPU_IO
47    
48 cnh 1.10 C !LOCAL VARIABLES:
49 jmc 1.34 C bi, bj :: tile indices
50     C i, j :: Loop counters
51 jmc 1.31 C msgBuf :: Informational/error message buffer
52 jmc 1.34 INTEGER bi, bj
53     INTEGER i, j
54 cnh 1.1 CHARACTER*(MAX_LEN_MBUF) msgBuf
55 jmc 1.34 CEOP
56    
57     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
58 cnh 1.1
59 jmc 1.34 C Load grid spacing (vector) from files
60 jmc 1.25 CALL LOAD_GRID_SPACING( myThid )
61    
62 edhill 1.21 C Set up vertical grid and coordinate system
63 adcroft 1.4 CALL INI_VERTICAL_GRID( myThid )
64    
65 edhill 1.21 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 jmc 1.31 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 edhill 1.21
81     C Set up horizontal grid and coordinate system
82 cnh 1.1 IF ( usingCartesianGrid ) THEN
83 edhill 1.21 CALL INI_CARTESIAN_GRID( myThid )
84 cnh 1.1 ELSEIF ( usingSphericalPolarGrid ) THEN
85 edhill 1.21 CALL INI_SPHERICAL_POLAR_GRID( myThid )
86 adcroft 1.8 ELSEIF ( usingCurvilinearGrid ) THEN
87 edhill 1.21 CALL INI_CURVILINEAR_GRID( myThid )
88 afe 1.17 ELSEIF ( usingCylindricalGrid ) THEN
89 jmc 1.24 CALL INI_CYLINDER_GRID( myThid )
90 cnh 1.1 ELSE
91 edhill 1.21 _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 jmc 1.34 CALL ALL_PROC_DIE( 0 )
96 edhill 1.21 STOP 'ABNORMAL END: S/R INI_GRID'
97     _END_MASTER(myThid)
98 cnh 1.1 ENDIF
99 dimitri 1.15
100 jmc 1.34 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 adcroft 1.20 #ifdef ALLOW_MONITOR
137 jmc 1.30 IF ( MASTER_CPU_IO(myThid) ) THEN
138 jmc 1.28 C-- only the master thread is allowed to switch On/Off mon_write_stdout
139 jmc 1.33 C & mon_write_mnc (since it is the only thread that uses those flags):
140 jmc 1.28
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 edhill 1.21 #ifdef ALLOW_MNC
148 jmc 1.28 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 edhill 1.21 ENDIF
159 jmc 1.28
160 jmc 1.34 C Print out statistics of each horizontal grid array (helps when debugging)
161 jmc 1.28 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 jmc 1.24 CALL MON_PRINTSTATS_RS(1,angleCosC,'AngleCS',myThid)
178     CALL MON_PRINTSTATS_RS(1,angleSinC,'AngleSN',myThid)
179 edhill 1.21
180 jmc 1.30 IF ( MASTER_CPU_IO(myThid) ) THEN
181 jmc 1.28 mon_write_stdout = .FALSE.
182     mon_write_mnc = .FALSE.
183     ENDIF
184     #endif /* ALLOW_MONITOR */
185 jmc 1.30
186     C-- Everyone else must wait for the grid to be set
187     _BARRIER
188 adcroft 1.8
189 cnh 1.1 RETURN
190     END

  ViewVC Help
Powered by ViewVC 1.1.22