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