6 |
|
|
7 |
CBOP |
CBOP |
8 |
C !ROUTINE: INI_GRID |
C !ROUTINE: INI_GRID |
9 |
|
|
10 |
C !INTERFACE: |
C !INTERFACE: |
11 |
SUBROUTINE INI_GRID( myThid ) |
SUBROUTINE INI_GRID( myThid ) |
12 |
C !DESCRIPTION: \bv |
C !DESCRIPTION: |
13 |
C *==========================================================* |
C These arrays are used throughout the code in evaluating gradients, |
14 |
C | SUBROUTINE INI_GRID |
C integrals and spatial avarages. This routine is called separately |
15 |
C | o Initialise model grid |
C by each thread and initializes only the region of the domain it is |
16 |
C *==========================================================* |
C "responsible" for. |
17 |
C | These arrays are used throughout the code in evaluating |
|
18 |
C | gradients, integrals and spatial avarages. This routine |
C !CALLING SEQUENCE: |
19 |
C | is called separately by each thread and initialise only |
C INI_GRID |
20 |
C | the region of the domain it is "responsible" for. |
C | -- LOAD_GRID_SPACING |
21 |
C | Notes: |
C | -- INI_VERTICAL_GRID |
22 |
C | Two examples are shown in this code. One illustrates the |
C | / INI_CARTESIAN_GRID |
23 |
C | initialisation of a cartesian grid. The other shows the |
C | / INI_SPHERICAL_POLAR_GRID |
24 |
C | inialisation of a spherical polar grid. Other orthonormal |
C | \ INI_CURVILINEAR_GRID |
25 |
C | grids can be fitted into this design. In this case |
C | \ INI_CYLINDER_GRID |
|
C | custom metric terms also need adding to account for the |
|
|
C | projections of velocity vectors onto these grids. |
|
|
C | The structure used here also makes it possible to |
|
|
C | implement less regular grid mappings. In particular |
|
|
C | o Schemes which leave out blocks of the domain that are |
|
|
C | all land could be supported. |
|
|
C | o Multi-level schemes such as icosohedral or cubic |
|
|
C | grid projectedions onto a sphere can also be fitted |
|
|
C | within the strategy we use. |
|
|
C | Both of the above also require modifying the support |
|
|
C | routines that map computational blocks to simulation |
|
|
C | domain blocks. |
|
|
C *==========================================================* |
|
|
C \ev |
|
26 |
|
|
27 |
C !USES: |
C !USES: |
28 |
IMPLICIT NONE |
IMPLICIT NONE |
|
C === Global variables === |
|
29 |
#include "SIZE.h" |
#include "SIZE.h" |
30 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
31 |
#include "PARAMS.h" |
#include "PARAMS.h" |
32 |
#include "GRID.h" |
#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: |
C !INPUT/OUTPUT PARAMETERS: |
41 |
C == Routine arguments == |
C myThid :: my Thread Id number |
|
C myThid - Number of this instance of INI_GRID |
|
42 |
INTEGER myThid |
INTEGER myThid |
43 |
|
CEOP |
44 |
|
|
45 |
|
C === Functions ==== |
46 |
|
LOGICAL MASTER_CPU_IO |
47 |
|
EXTERNAL MASTER_CPU_IO |
48 |
|
|
49 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
50 |
C == Local variables == |
C msgBuf :: Informational/error message buffer |
|
C msgBuf - Used for informational I/O. |
|
51 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
52 |
#ifdef ALLOW_EXF |
#ifdef ALLOW_MNC |
53 |
INTEGER i, j, bi, bj |
INTEGER i |
54 |
#endif /* ALLOW_EXF */ |
#endif |
|
CEOP |
|
55 |
|
|
56 |
C-- Set up vertical grid and coordinate system |
C load grid spacing (vector) from files |
57 |
|
CALL LOAD_GRID_SPACING( myThid ) |
58 |
|
|
59 |
|
C Set up vertical grid and coordinate system |
60 |
CALL INI_VERTICAL_GRID( myThid ) |
CALL INI_VERTICAL_GRID( myThid ) |
61 |
|
|
62 |
C-- Set up horizontal grid and coordinate system |
C Two examples are shown in this code. One illustrates the |
63 |
|
C initialization of a cartesian grid. The other shows the |
64 |
|
C inialization of a spherical polar grid. Other orthonormal grids |
65 |
|
C can be fitted into this design. In this case custom metric terms |
66 |
|
C also need adding to account for the projections of velocity |
67 |
|
C vectors onto these grids. The structure used here also makes it |
68 |
|
C possible to implement less regular grid mappings. In particular: |
69 |
|
C o Schemes which leave out blocks of the domain that are |
70 |
|
C all land could be supported. |
71 |
|
C o Multi-level schemes such as icosohedral or cubic |
72 |
|
C grid projectedions onto a sphere can also be fitted |
73 |
|
C within the strategy we use. |
74 |
|
C Both of the above also require modifying the support |
75 |
|
C routines that map computational blocks to simulation |
76 |
|
C domain blocks. |
77 |
|
|
78 |
|
C Set up horizontal grid and coordinate system |
79 |
IF ( usingCartesianGrid ) THEN |
IF ( usingCartesianGrid ) THEN |
80 |
CALL INI_CARTESIAN_GRID( myThid ) |
CALL INI_CARTESIAN_GRID( myThid ) |
81 |
ELSEIF ( usingSphericalPolarGrid ) THEN |
ELSEIF ( usingSphericalPolarGrid ) THEN |
82 |
CALL INI_SPHERICAL_POLAR_GRID( myThid ) |
CALL INI_SPHERICAL_POLAR_GRID( myThid ) |
83 |
ELSEIF ( usingCurvilinearGrid ) THEN |
ELSEIF ( usingCurvilinearGrid ) THEN |
84 |
CALL INI_CURVILINEAR_GRID( myThid ) |
CALL INI_CURVILINEAR_GRID( myThid ) |
85 |
|
ELSEIF ( usingCylindricalGrid ) THEN |
86 |
|
CALL INI_CYLINDER_GRID( myThid ) |
87 |
ELSE |
ELSE |
88 |
_BEGIN_MASTER(myThid) |
_BEGIN_MASTER(myThid) |
89 |
WRITE(msgBuf,'(A)') |
WRITE(msgBuf,'(2A)') 'S/R INI_GRID: ', |
90 |
& 'S/R INI_GRID: No grid coordinate system has been selected' |
& 'No grid coordinate system has been selected' |
91 |
CALL PRINT_ERROR( msgBuf , myThid) |
CALL PRINT_ERROR( msgBuf , myThid) |
92 |
STOP 'ABNORMAL END: S/R INI_GRID' |
STOP 'ABNORMAL END: S/R INI_GRID' |
93 |
_END_MASTER(myThid) |
_END_MASTER(myThid) |
94 |
ENDIF |
ENDIF |
95 |
|
|
96 |
#ifdef ALLOW_EXF |
#ifdef ALLOW_MONITOR |
97 |
C-- exf_interp assumes that 0 <= xG, xC <= 360 |
IF ( MASTER_CPU_IO(myThid) ) THEN |
98 |
C This is a quick fix until this assumption is relaxed |
C-- only the master thread is allowed to switch On/Off mon_write_stdout |
99 |
C and the interpolation weights are pre-computed. |
C & mon_write_mnc (since it's the only thread that uses those flags): |
100 |
DO bj = myByLo(myThid), myByHi(myThid) |
|
101 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
IF (monitor_stdio) THEN |
102 |
DO J=1-Oly,sNy+Oly |
mon_write_stdout = .TRUE. |
103 |
DO I=1-Olx,sNx+Olx |
ELSE |
104 |
IF ( xG(I,J,bi,bj) .LT. 0 ) |
mon_write_stdout = .FALSE. |
105 |
& xG(I,J,bi,bj) = xG(I,J,bi,bj) + 360 |
ENDIF |
106 |
IF ( xC(I,J,bi,bj) .LT. 0 ) |
mon_write_mnc = .FALSE. |
107 |
& xC(I,J,bi,bj) = xC(I,J,bi,bj) + 360 |
#ifdef ALLOW_MNC |
108 |
ENDDO |
IF (useMNC .AND. monitor_mnc) THEN |
109 |
ENDDO |
DO i = 1,MAX_LEN_MBUF |
110 |
ENDDO |
mon_fname(i:i) = ' ' |
111 |
ENDDO |
ENDDO |
112 |
#endif /* ALLOW_EXF */ |
mon_fname(1:12) = 'monitor_grid' |
113 |
|
CALL MNC_CW_SET_UDIM(mon_fname, 1, myThid) |
114 |
C-- Write certain grid data to files (useful for creating netCDF |
mon_write_mnc = .TRUE. |
115 |
C and general post-analysis) |
ENDIF |
116 |
CALL WRITE_FLD_XY_RS( 'XC',' ',XC,0,myThid) |
#endif /* ALLOW_MNC */ |
117 |
CALL WRITE_FLD_XY_RS( 'YC',' ',YC,0,myThid) |
|
118 |
CALL WRITE_FLD_XY_RS( 'XG',' ',XG,0,myThid) |
ENDIF |
|
CALL WRITE_FLD_XY_RS( 'YG',' ',YG,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'RAC',' ',rA,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'RAW',' ',rAw,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'RAS',' ',rAs,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'DXG',' ',DXG,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'DYG',' ',DYG,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'DXC',' ',DXC,0,myThid) |
|
|
CALL WRITE_FLD_XY_RS( 'DYC',' ',DYC,0,myThid) |
|
119 |
|
|
120 |
C-- Print out statistics of each horizontal grid array (helps when debugging) |
C Print out statistics of each horizontal grid array (helps when |
121 |
|
C debugging) |
122 |
|
CALL MON_PRINTSTATS_RS(1,xC,'XC',myThid) |
123 |
|
CALL MON_PRINTSTATS_RS(1,xG,'XG',myThid) |
124 |
|
CALL MON_PRINTSTATS_RS(1,dxC,'DXC',myThid) |
125 |
|
CALL MON_PRINTSTATS_RS(1,dxF,'DXF',myThid) |
126 |
|
CALL MON_PRINTSTATS_RS(1,dxG,'DXG',myThid) |
127 |
|
CALL MON_PRINTSTATS_RS(1,dxV,'DXV',myThid) |
128 |
|
CALL MON_PRINTSTATS_RS(1,yC,'YC',myThid) |
129 |
|
CALL MON_PRINTSTATS_RS(1,yG,'YG',myThid) |
130 |
|
CALL MON_PRINTSTATS_RS(1,dyC,'DYC',myThid) |
131 |
|
CALL MON_PRINTSTATS_RS(1,dyF,'DYF',myThid) |
132 |
|
CALL MON_PRINTSTATS_RS(1,dyG,'DYG',myThid) |
133 |
|
CALL MON_PRINTSTATS_RS(1,dyU,'DYU',myThid) |
134 |
|
CALL MON_PRINTSTATS_RS(1,rA,'RA',myThid) |
135 |
|
CALL MON_PRINTSTATS_RS(1,rAw,'RAW',myThid) |
136 |
|
CALL MON_PRINTSTATS_RS(1,rAs,'RAS',myThid) |
137 |
|
CALL MON_PRINTSTATS_RS(1,rAz,'RAZ',myThid) |
138 |
|
CALL MON_PRINTSTATS_RS(1,angleCosC,'AngleCS',myThid) |
139 |
|
CALL MON_PRINTSTATS_RS(1,angleSinC,'AngleSN',myThid) |
140 |
|
|
141 |
|
IF ( MASTER_CPU_IO(myThid) ) THEN |
142 |
|
mon_write_stdout = .FALSE. |
143 |
|
mon_write_mnc = .FALSE. |
144 |
|
ENDIF |
145 |
|
#endif /* ALLOW_MONITOR */ |
146 |
|
|
147 |
#ifdef ALLOW_MONITOR |
C-- Everyone else must wait for the grid to be set |
148 |
CALL MON_PRINTSTATS_RS(1,XC,'XC',myThid) |
_BARRIER |
|
CALL MON_PRINTSTATS_RS(1,XG,'XG',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DXC,'DXC',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DXF,'DXF',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DXG,'DXG',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DXV,'DXV',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,YC,'YC',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,YG,'YG',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DYC,'DYC',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DYF,'DYF',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DYG,'DYG',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,DYU,'DYU',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,RA,'RA',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,RAW,'RAW',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,RAS,'RAS',myThid) |
|
|
CALL MON_PRINTSTATS_RS(1,RAZ,'RAZ',myThid) |
|
|
#endif |
|
149 |
|
|
150 |
RETURN |
RETURN |
151 |
END |
END |