m_mpif90.F90 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  3. !-----------------------------------------------------------------------
  4. ! CVS m_mpif90.F90,v 1.3 2002-08-22 23:14:52 jacob Exp
  5. ! CVS MCT_2_8_0
  6. !-----------------------------------------------------------------------
  7. !BOP
  8. !
  9. ! !MODULE: m_mpif90 - a Fortran 90 style MPI module interface.
  10. !
  11. ! !DESCRIPTION:
  12. !
  13. ! By wrapping \verb'include "mpif.h"' into a module, \verb"m_mpif()"
  14. ! provides an easy way to
  15. !\begin{itemize}
  16. ! \item avoid the problem with {\sl fixed} or {\sl free} formatted
  17. ! Fortran 90 files;
  18. ! \item provide protections with only a limited set of \verb"PUBLIC"
  19. ! variables; and
  20. ! \item be extended to a MPI Fortran 90 binding.
  21. !\end{itemize}
  22. !
  23. ! !INTERFACE:
  24. module m_mpif90
  25. use m_mpif, only : MP_INTEGER => MPI_INTEGER
  26. use m_mpif, only : MP_REAL => MPI_REAL
  27. use m_mpif, only : MP_DOUBLE_PRECISION &
  28. => MPI_DOUBLE_PRECISION
  29. use m_mpif, only : MP_LOGICAL => MPI_LOGICAL
  30. use m_mpif, only : MP_CHARACTER => MPI_CHARACTER
  31. use m_mpif, only : MP_REAL4 => MPI_REAL4
  32. use m_mpif, only : MP_REAL8 => MPI_REAL8
  33. use m_mpif, only : MP_COMM_WORLD => MPI_COMM_WORLD
  34. use m_mpif, only : MP_COMM_NULL => MPI_COMM_NULL
  35. use m_mpif, only : MP_SUM => MPI_SUM
  36. use m_mpif, only : MP_PROD => MPI_PROD
  37. use m_mpif, only : MP_MIN => MPI_MIN
  38. use m_mpif, only : MP_MAX => MPI_MAX
  39. use m_mpif, only : MP_MAX_ERROR_STRING &
  40. => MPI_MAX_ERROR_STRING
  41. use m_mpif, only : MP_STATUS_SIZE => MPI_STATUS_SIZE
  42. use m_mpif, only : MP_ANY_SOURCE => MPI_ANY_SOURCE
  43. implicit none
  44. private
  45. public :: MP_type
  46. public :: MP_INTEGER
  47. public :: MP_REAL
  48. public :: MP_DOUBLE_PRECISION
  49. public :: MP_LOGICAL
  50. public :: MP_CHARACTER
  51. public :: MP_REAL4
  52. public :: MP_REAL8
  53. public :: MP_COMM_WORLD
  54. public :: MP_COMM_NULL
  55. public :: MP_SUM
  56. public :: MP_PROD
  57. public :: MP_MIN
  58. public :: MP_MAX
  59. public :: MP_ANY_SOURCE
  60. public :: MP_MAX_ERROR_STRING
  61. public :: MP_init
  62. public :: MP_initialized
  63. public :: MP_finalize
  64. public :: MP_abort
  65. public :: MP_wtime
  66. public :: MP_wtick
  67. public :: MP_comm_size
  68. public :: MP_comm_rank
  69. public :: MP_comm_dup
  70. public :: MP_comm_free
  71. public :: MP_cart_create
  72. public :: MP_dims_create
  73. public :: MP_cart_coords
  74. public :: MP_cart_rank
  75. public :: MP_error_string
  76. public :: MP_perr
  77. public :: MP_STATUS_SIZE
  78. public :: MP_status
  79. public :: MP_log2
  80. ! !REVISION HISTORY:
  81. ! 09Dec97 - Jing Guo <guo@thunder> - initial prototyping/coding.
  82. ! . started with everything public, without any interface
  83. ! declaration.
  84. ! . Then limited to only variables current expected to
  85. ! be used.
  86. !
  87. !EOP
  88. !_______________________________________________________________________
  89. integer,dimension(MP_STATUS_SIZE) :: MP_status
  90. !----------------------------------------
  91. interface MP_init
  92. subroutine MPI_init(ier)
  93. integer,intent(out) :: ier
  94. end subroutine MPI_init
  95. end interface
  96. interface MP_initialized
  97. subroutine MPI_initialized(flag,ier)
  98. logical,intent(out) :: flag
  99. integer,intent(out) :: ier
  100. end subroutine MPI_initialized
  101. end interface
  102. interface MP_finalize
  103. subroutine MPI_finalize(ier)
  104. integer,intent(out) :: ier
  105. end subroutine MPI_finalize
  106. end interface
  107. interface MP_error_string
  108. subroutine MPI_error_string(ierror,cerror,ln,ier)
  109. integer,intent(in) :: ierror
  110. character(len=*),intent(out) :: cerror
  111. integer,intent(out) :: ln
  112. integer,intent(out) :: ier
  113. end subroutine MPI_error_string
  114. end interface
  115. interface MP_type; module procedure &
  116. typeI_, & ! MPI_INTEGER
  117. typeL_, & ! MPI_LOGICAL
  118. typeC_, & ! MPI_CHARACTER
  119. typeSP_, & ! MPI_REAL
  120. typeDP_, & ! MPI_DOUBLE_PRECISION
  121. typeI1_, & ! MPI_INTEGER
  122. typeL1_, & ! MPI_LOGICAL
  123. typeC1_, & ! MPI_CHARACTER
  124. typeSP1_, & ! MPI_REAL
  125. typeDP1_, & ! MPI_DOUBLE_PRECISION
  126. typeI2_, & ! MPI_INTEGER
  127. typeL2_, & ! MPI_LOGICAL
  128. typeC2_, & ! MPI_CHARACTER
  129. typeSP2_, & ! MPI_REAL
  130. typeDP2_ ! MPI_DOUBLE_PRECISION
  131. end interface
  132. interface MP_perr; module procedure perr_; end interface
  133. interface MP_abort
  134. subroutine MPI_abort(comm,errorcode,ier)
  135. integer,intent(in) :: comm
  136. integer,intent(in) :: errorcode
  137. integer,intent(out) :: ier
  138. end subroutine MPI_abort
  139. end interface
  140. !----------------------------------------
  141. interface MP_wtime
  142. function MPI_wtime()
  143. double precision :: MPI_wtime
  144. end function MPI_wtime
  145. end interface
  146. interface MP_wtick
  147. function MPI_wtick()
  148. double precision :: MPI_wtick
  149. end function MPI_wtick
  150. end interface
  151. !----------------------------------------
  152. interface MP_comm_size
  153. subroutine MPI_comm_size(comm,size,ier)
  154. integer,intent(in) :: comm
  155. integer,intent(out) :: size
  156. integer,intent(out) :: ier
  157. end subroutine MPI_comm_size
  158. end interface
  159. interface MP_comm_rank
  160. subroutine MPI_comm_rank(comm,rank,ier)
  161. integer,intent(in) :: comm
  162. integer,intent(out) :: rank
  163. integer,intent(out) :: ier
  164. end subroutine MPI_comm_rank
  165. end interface
  166. interface MP_comm_dup
  167. subroutine MPI_comm_dup(comm,newcomm,ier)
  168. integer,intent(in) :: comm
  169. integer,intent(out) :: newcomm
  170. integer,intent(out) :: ier
  171. end subroutine MPI_comm_dup
  172. end interface
  173. interface MP_comm_free
  174. subroutine MPI_comm_free(comm,ier)
  175. integer,intent(inout) :: comm
  176. integer,intent(out) :: ier
  177. end subroutine MPI_comm_free
  178. end interface
  179. !----------------------------------------
  180. interface MP_cart_create
  181. subroutine MPI_cart_create(comm_old,ndims,dims,periods, &
  182. reorder,comm_cart,ier)
  183. integer,intent(in) :: comm_old
  184. integer,intent(in) :: ndims
  185. integer,dimension(*),intent(in) :: dims
  186. logical,dimension(*),intent(in) :: periods
  187. logical, intent(in) :: reorder
  188. integer,intent(out) :: comm_cart
  189. integer,intent(out) :: ier
  190. end subroutine MPI_cart_create
  191. end interface
  192. interface MP_dims_create
  193. subroutine MPI_dims_create(nnodes,ndims,dims,ier)
  194. integer,intent(in) :: nnodes
  195. integer,intent(in) :: ndims
  196. integer,dimension(*),intent(inout) :: dims
  197. integer,intent(out) :: ier
  198. end subroutine MPI_dims_create
  199. end interface
  200. interface MP_cart_coords
  201. subroutine MPI_cart_coords(comm,rank,maxdims,coords,ier)
  202. integer,intent(in) :: comm
  203. integer,intent(in) :: rank
  204. integer,intent(in) :: maxdims
  205. integer,dimension(*),intent(out) :: coords
  206. integer,intent(out) :: ier
  207. end subroutine MPI_cart_coords
  208. end interface
  209. interface MP_cart_rank
  210. subroutine MPI_cart_rank(comm,coords,rank,ier)
  211. integer,intent(in) :: comm
  212. integer,dimension(*),intent(in) :: coords
  213. integer,intent(out) :: rank
  214. integer,intent(out) :: ier
  215. end subroutine MPI_cart_rank
  216. end interface
  217. !----------------------------------------
  218. character(len=*),parameter :: myname='m_mpif90'
  219. contains
  220. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  222. !BOP -------------------------------------------------------------------
  223. !
  224. ! !IROUTINE: typeI_ - return MPI datatype of INTEGER
  225. !
  226. ! !DESCRIPTION:
  227. !
  228. ! !INTERFACE:
  229. function typeI_(ival)
  230. implicit none
  231. integer,intent(in) :: ival
  232. integer :: typeI_
  233. ! !REVISION HISTORY:
  234. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  235. ! - initial prototype/prolog/code
  236. !EOP ___________________________________________________________________
  237. character(len=*),parameter :: myname_=myname//'::typeI_'
  238. typeI_=MP_INTEGER
  239. end function typeI_
  240. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  241. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  242. !BOP -------------------------------------------------------------------
  243. !
  244. ! !IROUTINE: typeL_ - return MPI datatype of LOGICAL
  245. !
  246. ! !DESCRIPTION:
  247. !
  248. ! !INTERFACE:
  249. function typeL_(lval)
  250. implicit none
  251. logical,intent(in) :: lval
  252. integer :: typeL_
  253. ! !REVISION HISTORY:
  254. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  255. ! - initial prototype/prolog/code
  256. !EOP ___________________________________________________________________
  257. character(len=*),parameter :: myname_=myname//'::typeL_'
  258. typeL_=MP_LOGICAL
  259. end function typeL_
  260. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  261. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  262. !BOP -------------------------------------------------------------------
  263. !
  264. ! !IROUTINE: typeC_ - return MPI datatype of CHARACTER
  265. !
  266. ! !DESCRIPTION:
  267. !
  268. ! !INTERFACE:
  269. function typeC_(cval)
  270. implicit none
  271. character(len=*),intent(in) :: cval
  272. integer :: typeC_
  273. ! !REVISION HISTORY:
  274. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  275. ! - initial prototype/prolog/code
  276. !EOP ___________________________________________________________________
  277. character(len=*),parameter :: myname_=myname//'::typeC_'
  278. typeC_=MP_CHARACTER
  279. end function typeC_
  280. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  281. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  282. !BOP -------------------------------------------------------------------
  283. !
  284. ! !IROUTINE: typeSP_ - return MPI datatype of single precision REAL
  285. !
  286. ! !DESCRIPTION:
  287. !
  288. ! !INTERFACE:
  289. function typeSP_(rval)
  290. use m_realkinds,only : SP
  291. implicit none
  292. real(SP),intent(in) :: rval
  293. integer :: typeSP_
  294. ! !REVISION HISTORY:
  295. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  296. ! - initial prototype/prolog/code
  297. !EOP ___________________________________________________________________
  298. character(len=*),parameter :: myname_=myname//'::typeSP_'
  299. typeSP_=MP_REAL
  300. end function typeSP_
  301. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  302. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  303. !BOP -------------------------------------------------------------------
  304. !
  305. ! !IROUTINE: typeDP_ - return MPI datatype of double precision REAL
  306. !
  307. ! !DESCRIPTION:
  308. !
  309. ! !INTERFACE:
  310. function typeDP_(rval)
  311. use m_realkinds,only : DP
  312. implicit none
  313. real(DP),intent(in) :: rval
  314. integer :: typeDP_
  315. ! !REVISION HISTORY:
  316. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  317. ! - initial prototype/prolog/code
  318. !EOP ___________________________________________________________________
  319. character(len=*),parameter :: myname_=myname//'::typeDP_'
  320. typeDP_=MP_DOUBLE_PRECISION
  321. end function typeDP_
  322. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  323. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  324. !BOP -------------------------------------------------------------------
  325. !
  326. ! !IROUTINE: typeI1_ - return MPI datatype of INTEGER
  327. !
  328. ! !DESCRIPTION:
  329. !
  330. ! !INTERFACE:
  331. function typeI1_(ival)
  332. implicit none
  333. integer,dimension(:),intent(in) :: ival
  334. integer :: typeI1_
  335. ! !REVISION HISTORY:
  336. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  337. ! - initial prototype/prolog/code
  338. !EOP ___________________________________________________________________
  339. character(len=*),parameter :: myname_=myname//'::typeI1_'
  340. typeI1_=MP_INTEGER
  341. end function typeI1_
  342. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  343. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  344. !BOP -------------------------------------------------------------------
  345. !
  346. ! !IROUTINE: typeL1_ - return MPI datatype of LOGICAL
  347. !
  348. ! !DESCRIPTION:
  349. !
  350. ! !INTERFACE:
  351. function typeL1_(lval)
  352. implicit none
  353. logical,dimension(:),intent(in) :: lval
  354. integer :: typeL1_
  355. ! !REVISION HISTORY:
  356. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  357. ! - initial prototype/prolog/code
  358. !EOP ___________________________________________________________________
  359. character(len=*),parameter :: myname_=myname//'::typeL1_'
  360. typeL1_=MP_LOGICAL
  361. end function typeL1_
  362. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  363. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  364. !BOP -------------------------------------------------------------------
  365. !
  366. ! !IROUTINE: typeC1_ - return MPI datatype of CHARACTER
  367. !
  368. ! !DESCRIPTION:
  369. !
  370. ! !INTERFACE:
  371. function typeC1_(cval)
  372. implicit none
  373. character(len=*),dimension(:),intent(in) :: cval
  374. integer :: typeC1_
  375. ! !REVISION HISTORY:
  376. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  377. ! - initial prototype/prolog/code
  378. !EOP ___________________________________________________________________
  379. character(len=*),parameter :: myname_=myname//'::typeC1_'
  380. typeC1_=MP_CHARACTER
  381. end function typeC1_
  382. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  383. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  384. !BOP -------------------------------------------------------------------
  385. !
  386. ! !IROUTINE: typeSP1_ - return MPI datatype of single precision REAL
  387. !
  388. ! !DESCRIPTION:
  389. !
  390. ! !INTERFACE:
  391. function typeSP1_(rval)
  392. use m_realkinds,only : SP
  393. implicit none
  394. real(SP),dimension(:),intent(in) :: rval
  395. integer :: typeSP1_
  396. ! !REVISION HISTORY:
  397. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  398. ! - initial prototype/prolog/code
  399. !EOP ___________________________________________________________________
  400. character(len=*),parameter :: myname_=myname//'::typeSP1_'
  401. typeSP1_=MP_REAL
  402. end function typeSP1_
  403. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  405. !BOP -------------------------------------------------------------------
  406. !
  407. ! !IROUTINE: typeDP1_ - return MPI datatype of double precision REAL
  408. !
  409. ! !DESCRIPTION:
  410. !
  411. ! !INTERFACE:
  412. function typeDP1_(rval)
  413. use m_realkinds,only : DP
  414. implicit none
  415. real(DP),dimension(:),intent(in) :: rval
  416. integer :: typeDP1_
  417. ! !REVISION HISTORY:
  418. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  419. ! - initial prototype/prolog/code
  420. !EOP ___________________________________________________________________
  421. character(len=*),parameter :: myname_=myname//'::typeDP1_'
  422. typeDP1_=MP_DOUBLE_PRECISION
  423. end function typeDP1_
  424. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  425. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  426. !BOP -------------------------------------------------------------------
  427. !
  428. ! !IROUTINE: typeI2_ - return MPI datatype of INTEGER
  429. !
  430. ! !DESCRIPTION:
  431. !
  432. ! !INTERFACE:
  433. function typeI2_(ival)
  434. implicit none
  435. integer,dimension(:,:),intent(in) :: ival
  436. integer :: typeI2_
  437. ! !REVISION HISTORY:
  438. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  439. ! - initial prototype/prolog/code
  440. !EOP ___________________________________________________________________
  441. character(len=*),parameter :: myname_=myname//'::typeI2_'
  442. typeI2_=MP_INTEGER
  443. end function typeI2_
  444. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  445. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  446. !BOP -------------------------------------------------------------------
  447. !
  448. ! !IROUTINE: typeL2_ - return MPI datatype of LOGICAL
  449. !
  450. ! !DESCRIPTION:
  451. !
  452. ! !INTERFACE:
  453. function typeL2_(lval)
  454. implicit none
  455. logical,dimension(:,:),intent(in) :: lval
  456. integer :: typeL2_
  457. ! !REVISION HISTORY:
  458. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  459. ! - initial prototype/prolog/code
  460. !EOP ___________________________________________________________________
  461. character(len=*),parameter :: myname_=myname//'::typeL2_'
  462. typeL2_=MP_LOGICAL
  463. end function typeL2_
  464. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  465. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  466. !BOP -------------------------------------------------------------------
  467. !
  468. ! !IROUTINE: typeC2_ - return MPI datatype of CHARACTER
  469. !
  470. ! !DESCRIPTION:
  471. !
  472. ! !INTERFACE:
  473. function typeC2_(cval)
  474. implicit none
  475. character(len=*),dimension(:,:),intent(in) :: cval
  476. integer :: typeC2_
  477. ! !REVISION HISTORY:
  478. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  479. ! - initial prototype/prolog/code
  480. !EOP ___________________________________________________________________
  481. character(len=*),parameter :: myname_=myname//'::typeC2_'
  482. typeC2_=MP_CHARACTER
  483. end function typeC2_
  484. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  485. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  486. !BOP -------------------------------------------------------------------
  487. !
  488. ! !IROUTINE: typeSP2_ - return MPI datatype of single precision REAL
  489. !
  490. ! !DESCRIPTION:
  491. !
  492. ! !INTERFACE:
  493. function typeSP2_(rval)
  494. use m_realkinds,only : SP
  495. implicit none
  496. real(SP),dimension(:,:),intent(in) :: rval
  497. integer :: typeSP2_
  498. ! !REVISION HISTORY:
  499. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  500. ! - initial prototype/prolog/code
  501. !EOP ___________________________________________________________________
  502. character(len=*),parameter :: myname_=myname//'::typeSP2_'
  503. typeSP2_=MP_REAL
  504. end function typeSP2_
  505. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  506. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  507. !BOP -------------------------------------------------------------------
  508. !
  509. ! !IROUTINE: typeDP2_ - return MPI datatype of double precision REAL
  510. !
  511. ! !DESCRIPTION:
  512. !
  513. ! !INTERFACE:
  514. function typeDP2_(rval)
  515. use m_realkinds,only : DP
  516. implicit none
  517. real(DP),dimension(:,:),intent(in) :: rval
  518. integer :: typeDP2_
  519. ! !REVISION HISTORY:
  520. ! 28Sep99 - Jing Guo <guo@dao.gsfc.nasa.gov>
  521. ! - initial prototype/prolog/code
  522. !EOP ___________________________________________________________________
  523. character(len=*),parameter :: myname_=myname//'::typeDP2_'
  524. typeDP2_=MP_DOUBLE_PRECISION
  525. end function typeDP2_
  526. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  527. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  528. !BOP -------------------------------------------------------------------
  529. !
  530. ! !IROUTINE: perr_ - MPI error information hanlder
  531. !
  532. ! !DESCRIPTION:
  533. !
  534. ! !INTERFACE:
  535. subroutine perr_(proc,MP_proc,ierror)
  536. use m_stdio, only : stderr
  537. implicit none
  538. character(len=*),intent(in) :: proc
  539. character(len=*),intent(in) :: MP_proc
  540. integer,intent(in) :: ierror
  541. ! !REVISION HISTORY:
  542. ! 21Apr98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
  543. !EOP ___________________________________________________________________
  544. character(len=*),parameter :: myname_=myname//'::perr_'
  545. character(len=MP_MAX_ERROR_STRING) :: estr
  546. integer :: ln,ier
  547. call MP_error_string(ierror,estr,ln,ier)
  548. if(ier /= 0 .or. ln<=0) then
  549. write(stderr,'(4a,i4)') proc,': ', &
  550. MP_proc,' error, ierror =',ierror
  551. else
  552. write(stderr,'(6a)') proc,': ', &
  553. MP_proc,' error, "',estr(1:ln),'"'
  554. endif
  555. end subroutine perr_
  556. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  557. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  558. !BOP -------------------------------------------------------------------
  559. !
  560. ! !IROUTINE: MP_log2 - The smallest integer its power of 2 is >= nPE
  561. !
  562. ! !DESCRIPTION:
  563. !
  564. ! !INTERFACE:
  565. function MP_log2(nPE)
  566. implicit none
  567. integer,intent(in) :: nPE
  568. integer :: MP_log2
  569. ! !REVISION HISTORY:
  570. ! 01Feb00 - Jing Guo <guo@dao.gsfc.nasa.gov>
  571. ! - initial prototype/prolog/code
  572. !EOP ___________________________________________________________________
  573. character(len=*),parameter :: myname_=myname//'::MP_log2'
  574. integer :: n2
  575. MP_log2=0
  576. n2=1
  577. do while(n2<nPE)
  578. MP_log2 = MP_log2+1
  579. n2 = n2+n2
  580. end do
  581. end function MP_log2
  582. end module m_mpif90
  583. !.