oasis-cpp-interface-ftn.F90 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. ! OASIS-MCT calls for LPJ-GUESS.
  2. ! March 2015 - removed all old prism calls
  3. ! ------------------------------------------------------------------------------------------------------
  4. ! *** int oasismct_init_comp_(int *, char *);
  5. ! ------------------------------------------------------------------------------------------------------
  6. integer function oasismct_init_comp(compid,model_name)
  7. use mod_oasis
  8. ! Arguments
  9. integer, intent(out) :: compid
  10. character(len=4),intent(in) :: model_name
  11. ! Locals
  12. integer :: ierror
  13. print*, "LPJ-GUESS - calling oasis_init_comp"
  14. call oasis_init_comp(compid,model_name,ierror)
  15. print*, "LPJ-GUESS - oasis_init_comp returned with ierror =",ierror
  16. print*, "LPJ-GUESS - oasis_init_comp returned compid = ",compid
  17. oasismct_init_comp = ierror
  18. return
  19. end function oasismct_init_comp
  20. ! ------------------------------------------------------------------------------------------------------
  21. ! *** int oasismct_get_localcomm_(int *);
  22. ! ------------------------------------------------------------------------------------------------------
  23. integer function oasismct_get_localcomm(localcommid)
  24. use mod_oasis
  25. ! Arguments
  26. integer, intent(out) :: localcommid
  27. ! Locals
  28. integer :: ierror,lcid
  29. print*, "LPJ-GUESS - calling oasis_get_localcomm"
  30. call oasis_get_localcomm(lcid, ierror)
  31. print*, "LPJ-GUESS - oasis_get_localcomm returned ierror =",ierror
  32. print*, "LPJ-GUESS - localcomm = ",lcid
  33. localcommid = lcid
  34. oasismct_get_localcomm = ierror
  35. return
  36. end function oasismct_get_localcomm
  37. ! ------------------------------------------------------------------------------------------------------
  38. ! *** int oasismct_create_couplcomm_(int, int, int *);
  39. ! ------------------------------------------------------------------------------------------------------
  40. integer function oasismct_create_couplcomm(myrank, loccommid, cplcommid)
  41. use mod_oasis
  42. use mpi
  43. ! Arguments
  44. integer, intent(in) :: myrank
  45. integer, intent(in) :: loccommid
  46. integer, intent(out) :: cplcommid
  47. ! Locals
  48. integer :: ierror
  49. integer :: icpl
  50. icpl = 1
  51. if (myrank /= 0) icpl = MPI_UNDEFINED
  52. print*, "LPJ-GUESS - calling oasis_create_couplcomm with icpl = ",icpl
  53. call oasis_create_couplcomm(icpl, loccommid, cplcommid, ierror)
  54. print*, "LPJ-GUESS - oasis_create_couplcomm returned ierror =",ierror
  55. oasismct_create_couplcomm = ierror
  56. return
  57. end function oasismct_create_couplcomm
  58. ! ------------------------------------------------------------------------------------------------------
  59. ! *** int oasismct_abort_(compid, routine_name, abort_message, return_code);
  60. ! ------------------------------------------------------------------------------------------------------
  61. integer function oasismct_abort(compid, routine_name, abort_message, return_code)
  62. use mod_oasis
  63. ! Arguments
  64. integer, intent(in) :: compid
  65. character(len=24),intent(in) :: routine_name
  66. character(len=50),intent(in) :: abort_message
  67. integer, intent(in) :: return_code
  68. ! Locals
  69. call oasis_abort(compid, routine_name, abort_message, return_code)
  70. oasismct_abort = 666
  71. return
  72. end function oasismct_abort
  73. ! ------------------------------------------------------------------------------------------------------
  74. ! *** int oasismct_terminate_(void);
  75. ! ------------------------------------------------------------------------------------------------------
  76. integer function oasismct_terminate()
  77. use mod_oasis
  78. ! Locals
  79. integer :: ierror
  80. call oasis_terminate(ierror)
  81. oasismct_terminate = ierror
  82. return
  83. end function oasismct_terminate
  84. ! ------------------------------------------------------------------------------------------------------
  85. ! *** int oasismct_def_partition_(int *, int *, int *);
  86. ! ------------------------------------------------------------------------------------------------------
  87. integer function oasismct_def_partition(il_part_id,ig_paral,ig_paral_len)
  88. use mod_oasis
  89. ! use mod_oasis_def_partition
  90. ! Arguments
  91. integer,intent(out) :: il_part_id
  92. integer,intent(in) :: ig_paral_len
  93. integer,intent(in) :: ig_paral(ig_paral_len)
  94. ! Locals
  95. integer :: ierror
  96. print*, "LPJ-GUESS - oasis_def_partition with ig_paral(1)=",ig_paral(1)
  97. print*, "LPJ-GUESS - oasis_def_partition with ig_paral(2)=",ig_paral(2)
  98. print*, "LPJ-GUESS - oasis_def_partition with ig_paral(3)=",ig_paral(3)
  99. call oasis_def_partition(il_part_id,ig_paral,ierror)
  100. print*, "LPJ-GUESS - called oasis_def_partition with ierror =",ierror
  101. oasismct_def_partition = ierror
  102. return
  103. end function oasismct_def_partition
  104. ! ------------------------------------------------------------------------------------------------------
  105. ! *** int oasismct_def_var_(int *, char *, int *, int *, int *, int *, int *);
  106. ! ------------------------------------------------------------------------------------------------------
  107. integer function oasismct_def_var(var_id,name,il_part_id,var_nodims,kinout,var_actual_shape,var_type)
  108. use mod_oasis
  109. ! Arguments
  110. integer, intent(out) :: var_id
  111. character(len=8),intent(in) :: name
  112. integer, intent(in) :: il_part_id
  113. integer, intent(in) :: var_nodims(2)
  114. integer, intent(in) :: kinout
  115. integer, intent(in) :: var_actual_shape(2*var_nodims(1))
  116. integer, intent(in) :: var_type
  117. ! Locals
  118. integer :: ierror
  119. print*, "LPJ-GUESS - calling oasis_def_var for ",name
  120. call oasis_def_var(var_id,name,il_part_id,var_nodims,kinout,var_actual_shape,var_type,ierror)
  121. print*, "LPJ-GUESS - oasis_def_var returned ierror =",ierror
  122. oasismct_def_var = ierror
  123. return
  124. end function oasismct_def_var
  125. ! ------------------------------------------------------------------------------------------------------
  126. ! *** int oasismct_enddef_(void);
  127. ! ------------------------------------------------------------------------------------------------------
  128. integer function oasismct_enddef()
  129. use mod_oasis
  130. ! Locals
  131. integer :: ierror
  132. print*, "LPJ-GUESS - calling oasis_enddef"
  133. call oasis_enddef(ierror)
  134. print*, "LPJ-GUESS - oasis_enddef returned ierror:",ierror
  135. oasismct_enddef = ierror
  136. return
  137. end function oasismct_enddef
  138. ! ------------------------------------------------------------------------------------------------------
  139. ! *** int oasismct_put_1d_(int *, int *, double *, int *);
  140. ! ------------------------------------------------------------------------------------------------------
  141. integer function oasismct_put_1d(var_id,date,field_array,field_array_len)
  142. use mod_oasis
  143. ! Arguments
  144. integer, intent(in) :: var_id
  145. integer, intent(in) :: date
  146. integer, intent(in) :: field_array_len
  147. double precision,intent(in) :: field_array(field_array_len)
  148. ! Locals
  149. integer :: info
  150. call oasis_put(var_id,date,field_array,info)
  151. oasismct_put_1d = info
  152. return
  153. end function oasismct_put_1d
  154. ! ------------------------------------------------------------------------------------------------------
  155. ! *** int oasismct_put_2d_(int *, int *, double *, int *, int *);
  156. ! ------------------------------------------------------------------------------------------------------
  157. integer function oasismct_put_2d(var_id,date,field_array,field_array_len_x,field_array_len_y)
  158. use mod_oasis
  159. ! Arguments
  160. integer, intent(in) :: var_id
  161. integer, intent(in) :: date
  162. integer, intent(in) :: field_array_len_x
  163. integer, intent(in) :: field_array_len_y
  164. double precision,intent(in) :: field_array(field_array_len_x,field_array_len_y)
  165. ! Locals
  166. integer :: info
  167. call oasis_put(var_id,date,field_array,info)
  168. oasismct_put_2d = info
  169. return
  170. end function oasismct_put_2d
  171. ! ------------------------------------------------------------------------------------------------------
  172. ! *** int oasismct_get_1d_(int *, int *, double *, int *);
  173. ! ------------------------------------------------------------------------------------------------------
  174. integer function oasismct_get_1d(var_id,date,field_array,field_array_len)
  175. use mod_oasis
  176. ! Arguments
  177. integer, intent(in) :: var_id
  178. integer, intent(in) :: date
  179. integer, intent(in) :: field_array_len
  180. double precision,intent(out) :: field_array(field_array_len)
  181. ! Locals
  182. integer :: info
  183. call oasis_get(var_id,date,field_array,info)
  184. oasismct_get_1d = info
  185. return
  186. end function oasismct_get_1d
  187. ! ------------------------------------------------------------------------------------------------------
  188. ! *** int oasismct_get_2d_(int *, int *, double *, int *);
  189. ! ------------------------------------------------------------------------------------------------------
  190. integer function oasismct_get_2d(var_id,date,field_array,field_array_len_x,field_array_len_y)
  191. use mod_oasis
  192. ! Arguments
  193. integer, intent(in) :: var_id
  194. integer, intent(in) :: date
  195. integer, intent(in) :: field_array_len_x,field_array_len_y
  196. double precision,intent(out) :: field_array(field_array_len_x,field_array_len_y)
  197. ! Locals
  198. integer :: info
  199. call oasis_get(var_id,date,field_array,info)
  200. ! Outcomment some of these when debugging
  201. select case ( info )
  202. case ( OASIS_Recvd )
  203. print*, " received from other model"
  204. case ( OASIS_FromRest )
  205. print*, " read from restart file (directly or via coupler)"
  206. case ( OASIS_Input )
  207. print*, " read from input file"
  208. case ( OASIS_RecvOut )
  209. print*, " received from other model (directly or via coupler) and written to output file"
  210. case ( OASIS_FromRestOut )
  211. print*, " read from restart file (directly or via coupler) and written to output file"
  212. case ( OASIS_Ok )
  213. print*, " no field received; continue"
  214. case default
  215. print*, "Error from oasismct_get_2d, oasis_get in LPJ-GUESS"
  216. end select
  217. oasismct_get_2d = info
  218. return
  219. end function oasismct_get_2d