|
||||
File indexing completed on 2020-07-29 05:12:04 UTC
view on githubraw file Latest commit b9dadda2 on 2020-07-28 16:49:33 UTC64e1bd68a2 Jean*0001 CBOI 0002 C 0003 C !TITLE: WRAPPER CODE SYNOPSIS 0004 C !AUTHORS: mitgcm developers ( support@mitgcm.org ) 0005 C !AFFILIATION: Massachussetts Institute of Technology 0006 C !DATE: 4a0342d0d4 Jean*0007 C !INTRODUCTION: 64e1bd68a2 Jean*0008 C Wrapper synopsis and code Routines in the subdirectories under 0009 C eesupp/ ( src/ and inc/ ) provide the core framework within which 0010 C numerical and ancilliary software of MITgcm operates. The eesupp/ 0011 C directories provide a collection of software we call {\bf WRAPPER} 0012 C ( ({\bf W}rappable {\bf A}pplication {\bf P}aralell {\bf 0013 C P}rogramming {\bf E}nvironment {\bf R}esource). The {bf WRAPPER} 0014 C provides a generic bootstrapping capability to start applications 0015 C in a manner that allows them to exploit single and 0016 C multi-processing environments on all present day hardware 0017 C platforms (spanning vector SMP systems to distributed memory and 0018 C processing cluster systems). Numerical applications must be coded 0019 C to fit within the {\bf WRAPPER}. This entails applications 0020 C adopting a particular style for declaring data structures 0021 C representing grids and values on grids. The {\bf WRAPPER} 0022 C currently provides support for grid point models using a single 0023 C global indexing system. This is sufficient for latitude-logitude, 0024 C cylindrical, and cartesian coordinate configurations. There is 0025 C also limited support for composing grids in which no single, 0026 C sructured global index can be defined. At present, this support is 0027 C limited to specific configurations of projections of a cube onto 0028 C the sphere. 0029 C 0030 C The main functions supported by the current {\bf WRAPPER} code are 0031 C \begin{itemize} 0032 C \item program startup and termination including 0033 C creation/management of multiple threads and/or processes 0034 C \item communication and synchronisatioin operations between 0035 C multiple processes and/or threads 0036 C \item multi-process input and output operations to disk and to 0037 C other applications 0038 C \end{itemize} 0039 C 0040 C Multi-process execution assumes the existence of MPI for process 0041 C startup and termination. However, MPI does not have to be used for 0042 C performance critical operations. Instead, {\bf WRAPPER} 0043 C performance critical parallel primitives are implemented to allow 0044 C them to bind to different low-level system software 0045 C layers. Bindings exist for using {\bf WRAPPER} with portable 0046 C systems such as MPI and UNIX System V IPC memory mapping, as well 0047 C bindings for high-performance propreitary systems such as Myrinet 0048 C GM software and Compaq IMC memory channel technology. 0049 C 0050 CEOI 0051 0052 C-- Get C preprocessor options 0053 #include "PACKAGES_CONFIG.h" 4a0342d0d4 Jean*0054 #include "CPP_OPTIONS.h" 64e1bd68a2 Jean*0055 0056 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| 0057 CBOP 0058 C !ROUTINE: MAIN 0059 0060 C !INTERFACE: 0061 PROGRAM MAIN 0062 0063 C !DESCRIPTION: 0064 C *==========================================================* 4a0342d0d4 Jean*0065 C | PROGRAM MAIN 0066 C | o MAIN wrapper for MITgcm UV implementation. 64e1bd68a2 Jean*0067 C *==========================================================* 4a0342d0d4 Jean*0068 C | MAIN controls the "execution environment". 0069 C | Its main functions are 64e1bd68a2 Jean*0070 C | 1. call procedure EEBOOT to perform execution environment 4a0342d0d4 Jean*0071 C | initialisation. 64e1bd68a2 Jean*0072 C | 2. call procedure THE\_MODEL\_MAIN once for each concurrent 4a0342d0d4 Jean*0073 C | thread. THE\_MODEL\_MAIN is the user supplied top-level 0074 C | routine. 0075 C | 3. call procedure EEDIE to perform execution environment 0076 C | shutdown. 64e1bd68a2 Jean*0077 C *==========================================================* 0078 0079 C !CALLING SEQUENCE: 0080 C 4a0342d0d4 Jean*0081 C main() 64e1bd68a2 Jean*0082 C | 0083 C |--eeboot() :: WRAPPER initilization 0084 C | 0085 C |--check_threads() :: Validate multiple thread start up. 0086 C | 0087 C |--the_model_main() :: Numerical code top-level driver routine 0088 C | 0089 C |--eedie() :: WRAPPER termination 0090 0091 C !USES: 4a0342d0d4 Jean*0092 IMPLICIT NONE 0093 64e1bd68a2 Jean*0094 C == Global variables == 0095 C Include all the "shared" data here. That means all common 0096 C blocks used in the model. On many implementations this is not 0097 C necessary but doing this is the safest method. 0098 #include "SIZE.h" 0099 #include "EEPARAMS.h" 0100 #include "EESUPPORT.h" 0101 #ifdef HAVE_SIGREG 0102 #include "SIGREG.h" 0103 #endif 0104 0105 C !LOCAL VARIABLES: 4a0342d0d4 Jean*0106 C msgBuf :: I/O message buffer 0107 C I :: loop counter 0108 C myThid :: thread Id number 0109 CHARACTER*(MAX_LEN_MBUF) msgBuf 64e1bd68a2 Jean*0110 INTEGER myThid 0111 INTEGER I afa29803a3 Jean*0112 INTEGER dummyComm 64e1bd68a2 Jean*0113 0114 #ifdef USE_OMP_THREADING 0115 INTEGER OMP_GET_THREAD_NUM 0116 EXTERNAL OMP_GET_THREAD_NUM 4a0342d0d4 Jean*0117 #endif 64e1bd68a2 Jean*0118 0119 CEOP 0120 0121 #ifdef USE_GSL_IEEE 4a0342d0d4 Jean*0122 CALL FGSL_IEEE_ENV_SETUP () 64e1bd68a2 Jean*0123 #endif 0124 0125 C-- Set up the execution environment 4a0342d0d4 Jean*0126 C EEBOOT loads a execution environment parameter file afa29803a3 Jean*0127 C ( called "eedata" by default ) and sets variables accordingly. 0128 dummyComm = -1 0129 CALL EEBOOT( dummyComm ) 64e1bd68a2 Jean*0130 4a0342d0d4 Jean*0131 C-- Trap errors 64e1bd68a2 Jean*0132 IF ( eeBootError ) THEN 0133 fatalError = .TRUE. 0134 GOTO 999 0135 ENDIF 0136 0137 #ifdef HAVE_SETRLSTK 0138 IF (useSETRLSTK) THEN 0139 CALL setrlstk 0140 ENDIF 0141 #endif 0142 0143 #ifdef HAVE_SIGREG 0144 IF (useSIGREG) THEN 0145 i_got_signal = 0 0146 CALL sigreg( i_got_signal ) 0147 ENDIF 0148 #endif 0149 0150 #ifdef HAVE_PTHREADS 4a0342d0d4 Jean*0151 c IF (usePTHREADS) THEN 64e1bd68a2 Jean*0152 CALL PTINIT(nThreads) 4a0342d0d4 Jean*0153 c ELSE 64e1bd68a2 Jean*0154 #else 0155 4a0342d0d4 Jean*0156 C-- Start nThreads concurrent threads. 64e1bd68a2 Jean*0157 C Note: We do a fiddly check here. The check is performed 0158 C by CHECK_THREADS. CHECK_THREADS does a count 0159 C of all the threads. If after ten seconds it has not 0160 C found nThreads threads are running it flags an 4a0342d0d4 Jean*0161 C error. This traps the case in which the input 0162 C parameter nThreads is different from the actual 64e1bd68a2 Jean*0163 C number of concurrent threads the OS gives us. This 0164 C case causes a deadlock if we do not trap it here. 0165 #include "MAIN_PDIRECTIVES1.h" 0166 DO I=1,nThreads 0167 #ifdef USE_OMP_THREADING 0168 IF ( OMP_GET_THREAD_NUM() .EQ. I-1 ) THEN 4a0342d0d4 Jean*0169 #endif 64e1bd68a2 Jean*0170 myThid = I 0171 0172 C-- Do check to see if there are nThreads threads running 0173 IF ( .NOT. eeBootError ) THEN 0174 CALL CHECK_THREADS( myThid ) 0175 ENDIF 0176 0177 C-- Invoke nThreads instances of the numerical model 0178 IF ( .NOT. eeBootError ) THEN 4a0342d0d4 Jean*0179 #if (defined (ALLOW_ADMTLM)) 64e1bd68a2 Jean*0180 CALL ADMTLM_DSVD(myThid) 4a0342d0d4 Jean*0181 #elif (defined (ALLOW_HESSIAN_CODE)) 0182 CALL HESSIAN_MAIN(myThid) 64e1bd68a2 Jean*0183 #else b9dadda204 Mart*0184 WRITE(0,'(A,I8,A,I4,A)') 0185 & '-- PId=', myProcId, ' , TId=', myThid, 0186 & ' : ===> Skip THE_MODEL_MAIN call <===' 64e1bd68a2 Jean*0187 c CALL THE_MODEL_MAIN(myThid) 0188 #endif 0189 ENDIF 0190 0191 C-- Each threads sets flag indicating it is done 0192 threadIsComplete(myThid) = .TRUE. 0193 IF ( .NOT. eeBootError ) THEN 0194 _BARRIER 0195 ENDIF 0196 #ifdef USE_OMP_THREADING 0197 ENDIF 4a0342d0d4 Jean*0198 #endif 64e1bd68a2 Jean*0199 ENDDO 0200 #include "MAIN_PDIRECTIVES2.h" 0201 0202 #endif /* HAVE_PTHREADS */ 0203 0204 999 CONTINUE 0205 C-- Shut down execution environment 0206 CALL EEDIE 0207 0208 C-- Write closedown status 0209 IF ( fatalError ) THEN 4a0342d0d4 Jean*0210 WRITE( msgBuf,'(A)') 'PROGRAM MAIN: ends with fatal Error' 0211 CALL PRINT_ERROR( msgBuf, 1 ) 0212 WRITE(standardMessageUnit,'(A)') 0213 & 'PROGRAM MAIN: ends with fatal Error' 64e1bd68a2 Jean*0214 STOP 'ABNORMAL END: PROGRAM MAIN' 0215 ELSE 4a0342d0d4 Jean*0216 WRITE(standardMessageUnit,'(A)') 0217 & 'PROGRAM MAIN: Execution ended Normally' 64e1bd68a2 Jean*0218 STOP 'NORMAL END' 0219 ENDIF 0220 4a0342d0d4 Jean*0221 END 64e1bd68a2 Jean*0222 0223 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| 0224 0225 CBOP 0 0226 C !ROUTINE: PTREENTRY 4a0342d0d4 Jean*0227 64e1bd68a2 Jean*0228 C !INTERFACE: 4a0342d0d4 Jean*0229 SUBROUTINE PTREENTRY( 64e1bd68a2 Jean*0230 I myThid ) 0231 0232 C !DESCRIPTION: 0233 C Re-entry point for a pthreads-based threading mechanism. The 0234 C intent is to produce a threading hack that will work with gcc/g77. 4a0342d0d4 Jean*0235 64e1bd68a2 Jean*0236 C !USES: 4a0342d0d4 Jean*0237 IMPLICIT NONE 64e1bd68a2 Jean*0238 #include "SIZE.h" 0239 #include "EEPARAMS.h" 0240 #include "EESUPPORT.h" 0241 0242 C !INPUT PARAMETERS: 4a0342d0d4 Jean*0243 C myThid :: my thread Id number 0244 INTEGER myThid 64e1bd68a2 Jean*0245 CEOP 0246 4a0342d0d4 Jean*0247 WRITE(*,*) 'myThid = ', myThid 64e1bd68a2 Jean*0248 CALL CHECK_THREADS( myThid ) 0249 4a0342d0d4 Jean*0250 c CALL THE_MODEL_MAIN(myThid) 64e1bd68a2 Jean*0251 0252 threadIsComplete(myThid) = .TRUE. 0253 0254 RETURN 0255 END 0256 0257 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated from https://github.com/MITgcm/MITgcm by the 2.2.1-MITgcm-0.1 LXR engine. The LXR team |