restart_converter.f90 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. module rcmod
  2. implicit none
  3. integer :: verb = 1
  4. integer :: nlat = 32
  5. integer :: nlon = 64
  6. integer :: nlev = 10
  7. integer :: nrsp = 506
  8. integer :: nhor = 2048
  9. integer :: nlsoil = 5
  10. integer :: nlev_oce = 1
  11. integer :: nstep
  12. integer :: naccuout
  13. character (len=16) :: yname
  14. real, allocatable :: sphor(:)
  15. real, allocatable :: splev(:,:)
  16. real, allocatable :: gphor(:)
  17. real, allocatable :: gplev(:,:)
  18. real, allocatable :: gpm14(:,:)
  19. real, allocatable :: gpm12(:,:)
  20. end module rcmod
  21. program rescon
  22. use rcmod
  23. allocate(sphor(nrsp))
  24. allocate(splev(nrsp,nlev))
  25. allocate(gphor(nhor))
  26. allocate(gplev(nhor,nlev))
  27. allocate(gpm14(nhor,14))
  28. allocate(gpm12(nhor,12))
  29. open(10,file='puma_restart',form='unformatted')
  30. open(20,file='plasim_restart',form='unformatted')
  31. if (verb == 1) then
  32. print '(77("*"))'
  33. print '("* Planet Simulator Restart File Converter 1.0 *")'
  34. print '(77("*"))'
  35. print '("* Part I * puma_restart *")'
  36. print '(77("*"))'
  37. endif
  38. ! scalars
  39. call scai
  40. if (verb == 1) print '(77("*"))'
  41. ! spectral arrays
  42. call sp3d('sz ')
  43. call sp3d('sd ')
  44. call sp3d('st ')
  45. call sp3d('sq ')
  46. call sp2d('sp ')
  47. call sp3d('szm ')
  48. call sp3d('sdm ')
  49. call sp3d('stm ')
  50. call sp3d('sqm ')
  51. call sp2d('spm ')
  52. call sp2d('so ')
  53. call sp3d('sr ')
  54. ! gridpoint arrays
  55. call gp2d('dls ')
  56. call gp2d('drhs ')
  57. call gp2d('dalb ')
  58. call gp2d('dz0 ')
  59. call gp2d('dicec ')
  60. call gp2d('diced ')
  61. call gp2d('dwatc ')
  62. call gp2d('drunoff ')
  63. call gp2d('dveg ')
  64. call gp2d('dforest ')
  65. call gp3d('dcc ')
  66. call gp3d('dql ')
  67. call gp3d('dqsat ')
  68. call gp2d('dt ')
  69. call gp2d('dq ')
  70. call gp2d('dust3 ')
  71. ! accumulated diagnostics
  72. call gp2d('aprl ')
  73. call gp2d('aprc ')
  74. call gp2d('aprs ')
  75. call gp2d('aevap ')
  76. call gp2d('ashfl ')
  77. call gp2d('alhfl ')
  78. call gp2d('aroff ')
  79. call gp2d('asmelt ')
  80. call gp2d('asndch ')
  81. call gp2d('acc ')
  82. call gp2d('assol ')
  83. call gp2d('asthr ')
  84. call gp2d('atsol ')
  85. call gp2d('atthr ')
  86. call gp2d('ataux ')
  87. call gp2d('atauy ')
  88. call gp2d('atsolu ')
  89. call gp2d('assolu ')
  90. call gp2d('asthru ')
  91. call gp2d('aqvi ')
  92. call gp2d('atsa ')
  93. call gp2d('ats0 ')
  94. close (10)
  95. open(10,file='land_restart',form='unformatted')
  96. read (10) nstep_land
  97. if (nstep /= nstep_land) then
  98. print *,'nstep in puma_restart = ',nstep
  99. print *,'ntspe in land_restart = ',nstep_land
  100. print *,'*** error stop ***'
  101. stop
  102. endif
  103. if (verb == 1) then
  104. print '(77("*"))'
  105. print '("* Part II * land_restart *")'
  106. print '(77("*"))'
  107. endif
  108. ! landmod arrays
  109. call gp2d('dtsl ')
  110. call gp2d('dtsm ')
  111. call gp2d('dqs ')
  112. call gp2d('driver ')
  113. call gp2d('duroff ')
  114. call gp2d('dvroff ')
  115. call gp2d('darea ')
  116. call gp2d('dwmax ')
  117. call gp12('dtcl ')
  118. call gp12('dwcl ')
  119. call gp2d('dsnowt ')
  120. call gp2d('dsnowz ')
  121. call gp3l('dsoilt ')
  122. call gp2d('dcveg ')
  123. call gp2d('dcsoil ')
  124. call gp2d('dglac ')
  125. call gp2d('dz0clim ')
  126. call gp2d('dz0climo ')
  127. call gp2d('dalbclim ')
  128. ! simba arrays
  129. call gp2d('agpp ')
  130. call gp2d('anpp ')
  131. call gp2d('agppl ')
  132. call gp2d('agppw ')
  133. call gp2d('anogrow ')
  134. call gp2d('aresh ')
  135. call gp2d('alitter ')
  136. close (10)
  137. open(10,file='sea_restart',form='unformatted')
  138. read (10) nstep_sea,naccua
  139. if (nstep /= nstep_sea) then
  140. print *,'nstep in puma_restart = ',nstep
  141. print *,'ntspe in sea_restart = ',nstep_sea
  142. print *,'*** error stop ***'
  143. stop
  144. endif
  145. yname = 'naccua'
  146. write (20) yname
  147. write (20) naccua
  148. if (verb == 1) then
  149. print '(77("*"))'
  150. print '("* Part III * sea_restart *")'
  151. print '(77("*"))'
  152. print 1000,'naccua',naccua
  153. endif
  154. ! seamod arrays
  155. call gp2d('dts ')
  156. call gp2d('cheata ')
  157. call gp2d('cpmea ')
  158. call gp2d('cprsa ')
  159. call gp2d('croffa ')
  160. call gp2d('ctauxa ')
  161. call gp2d('ctauya ')
  162. call gp2d('cust3a ')
  163. call gp2d('cshfla ')
  164. call gp2d('cshdta ')
  165. call gp2d('clhfla ')
  166. call gp2d('clhdta ')
  167. call gp2d('cswfla ')
  168. call gp2d('clwfla ')
  169. close (10)
  170. open(10,file='ice_restart',form='unformatted')
  171. read (10) nstep_ice,naccuice,naccuo
  172. ! Ignore nstep from icemod and use nstep from plasim
  173. !if (nstep /= nstep_ice) then
  174. ! print *,'nstep in puma_restart = ',nstep
  175. ! print *,'nstep in ice_restart = ',nstep_ice
  176. ! print *,'*** error stop ***'
  177. ! stop
  178. !endif
  179. yname = 'naccuice'
  180. write (20) yname
  181. write (20) naccuice
  182. yname = 'naccuo'
  183. write (20) yname
  184. write (20) naccuo
  185. if (verb == 1) then
  186. print '(77("*"))'
  187. print '("* Part IV * ice_restart *")'
  188. print '(77("*"))'
  189. print 1000,'naccuice',naccuice
  190. print 1000,'naccuo',naccuo
  191. endif
  192. ! icemod arrays
  193. call gp2d('xls ')
  194. call gp2d('xts ')
  195. call gp2d('xicec ')
  196. call gp2d('xiced ')
  197. call gp2d('xsnow ')
  198. call gp14('xclicec ')
  199. call gp14('xcliced ')
  200. call gp14('xclsst ')
  201. call gp2d('cheat ')
  202. call gp2d('cfresh ')
  203. call gp2d('ctaux ')
  204. call gp2d('ctauy ')
  205. call gp2d('cust3 ')
  206. call gp2d('xflxicea ')
  207. call gp2d('xheata ')
  208. call gp2d('xofluxa ')
  209. call gp2d('xqmelta ')
  210. call gp2d('xcfluxa ')
  211. call gp2d('xsmelta ')
  212. call gp2d('ximelta ')
  213. call gp2d('xtsfluxa ')
  214. call gp2d('xhnewa ')
  215. close (10)
  216. open(10,file='ocean_restart',form='unformatted')
  217. read (10) nstep_oce,naccuoce
  218. yname = 'naccuoce'
  219. write (20) yname
  220. write (20) naccuice
  221. yname = 'nlev_oce'
  222. write (20) yname
  223. write (20) nlev_oce
  224. if (verb == 1) then
  225. print '(77("*"))'
  226. print '("* Part V * ocean_restart *")'
  227. print '(77("*"))'
  228. print 1000,'naccuoce',naccuoce
  229. endif
  230. ! oceanmod arrays
  231. call gp2d('yls ')
  232. call gp3o('ysst ')
  233. call gp2d('yiflux ')
  234. call gp14('yclsst ')
  235. call gp2d('yheata ')
  236. call gp2d('yfssta ')
  237. call gp2d('yifluxa ')
  238. call gp2d('ydssta ')
  239. close (20)
  240. if (verb == 1) print '(77("*"))'
  241. stop
  242. 1000 format("* Integer * ",a8," * ",I12,36X," *")
  243. end program rescon
  244. subroutine scai
  245. use rcmod
  246. character (len=16) :: yn
  247. read (10) nstep,naccuout
  248. yn = 'nstep '
  249. write (20) yn
  250. write (20) nstep
  251. yn = 'naccuout'
  252. write (20) yn
  253. write (20) naccuout
  254. yn = 'nlat '
  255. write (20) yn
  256. write (20) nlat
  257. yn = 'nlon '
  258. write (20) yn
  259. write (20) nlon
  260. yn = 'nlev '
  261. write (20) yn
  262. write (20) nlev
  263. yn = 'nrsp '
  264. write (20) yn
  265. write (20) nrsp
  266. yn = 'nlsoil '
  267. write (20) yn
  268. write (20) nlsoil
  269. if (verb == 1) then
  270. print 1000,'nstep ',nstep
  271. print 1000,'naccuout',naccuout
  272. print 1000,'nlat ',nlat
  273. print 1000,'nlon ',nlon
  274. print 1000,'nlev ',nlev
  275. print 1000,'nrsp ',nrsp
  276. print 1000,'nlsoil ',nlsoil
  277. endif
  278. return
  279. 1000 format("* Integer * ",a8," * ",I12,36X," *")
  280. end subroutine scai
  281. subroutine sp3d(yn)
  282. use rcmod
  283. character (len=16) :: yn
  284. read (10) splev
  285. write (20) yn
  286. write (20) splev
  287. if (verb == 1) print 1000,yn,splev(1,1:4)
  288. return
  289. 1000 format("* Spectral 3D * ",a8," * ",4e12.3," *")
  290. end subroutine sp3d
  291. subroutine sp2d(yn)
  292. use rcmod
  293. character (len=16) :: yn
  294. read (10) sphor
  295. write (20) yn
  296. write (20) sphor
  297. if (verb == 1) print 1000,yn,sphor(1:4)
  298. return
  299. 1000 format("* Spectral 2D * ",a8," * ",4e12.3," *")
  300. end subroutine sp2d
  301. subroutine gp3d(yn)
  302. use rcmod
  303. character (len=16) :: yn
  304. read (10) gplev
  305. write (20) yn
  306. write (20) gplev
  307. if (verb == 1) print 1000,yn,gplev(1,1:4)
  308. return
  309. 1000 format("* Grid 3D * ",a8," * ",4e12.3," *")
  310. end subroutine gp3d
  311. subroutine gp2d(yn)
  312. use rcmod
  313. character (len=16) :: yn
  314. read (10) gphor
  315. write (20) yn
  316. write (20) gphor
  317. if (verb == 1) print 1000,yn,gphor(1:4)
  318. return
  319. 1000 format("* Grid 2D * ",a8," * ",4e12.3," *")
  320. end subroutine gp2d
  321. subroutine gp3l(yn)
  322. use rcmod
  323. character (len=16) :: yn
  324. read (10) gplev(:,1:nlsoil)
  325. write (20) yn
  326. write (20) gplev(:,1:nlsoil)
  327. if (verb == 1) print 1000,yn,gplev(1,1:4)
  328. return
  329. 1000 format("* Grid 3D * ",a8," * ",4e12.3," *")
  330. end subroutine gp3l
  331. subroutine gp14(yn)
  332. use rcmod
  333. character (len=16) :: yn
  334. read (10) gpm14(:,2:13)
  335. gpm14(:, 1) = gpm14(:,13)
  336. gpm14(:,14) = gpm14(:, 2)
  337. write (20) yn
  338. write (20) gpm14
  339. if (verb == 1) print 1000,yn,gpm14(1,1:4)
  340. return
  341. 1000 format("* Grid annual * ",a8," * ",4e12.3," *")
  342. end subroutine gp14
  343. subroutine gp12(yn)
  344. use rcmod
  345. character (len=16) :: yn
  346. read (10) gpm12
  347. write (20) yn
  348. write (20) gpm12
  349. if (verb == 1) print 1000,yn,gpm12(1,1:4)
  350. return
  351. 1000 format("* Grid 12-mon * ",a8," * ",4e12.3," *")
  352. end subroutine gp12
  353. subroutine gp3o(yn)
  354. use rcmod
  355. character (len=16) :: yn
  356. read (10) gplev(:,1:nlev_oce)
  357. write (20) yn
  358. write (20) gplev(:,1:nlev_oce)
  359. if (verb == 1) print 1000,yn,gplev(1:4,1)
  360. return
  361. 1000 format("* Grid 3D * ",a8," * ",4e12.3," *")
  362. end subroutine gp3o