flio_rbld.f90 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784
  1. PROGRAM flio_rbld
  2. !
  3. !$Id: flio_rbld.f90 3680 2012-11-27 14:42:24Z rblod $
  4. !-
  5. ! This software is governed by the CeCILL license
  6. ! See IOIPSL/IOIPSL_License_CeCILL.txt
  7. !!--------------------------------------------------------------------
  8. !! PROGRAM flio_rbld
  9. !!
  10. !! PURPOSE :
  11. !! Recombine the files of MPI version of IOIPSL
  12. !! along several dimensions.
  13. !!
  14. !! CALLING SEQUENCE :
  15. !!
  16. !! "flio_rbld" is usually invoked by the script "rebuild"
  17. !!
  18. !! rebuild -h
  19. !!
  20. !! rebuild [-v lev] [-f] -o outfile infile[1] ... infile[n]
  21. !!
  22. !! INPUT for "rebuild" :
  23. !!
  24. !! -h : help
  25. !! -v lev : verbosity level
  26. !! -f : force executing mode
  27. !! -o outfile : name of the recombined file.
  28. !! infiles : names of the files that must be recombined.
  29. !!
  30. !! INPUT for "flio_rbld" :
  31. !!
  32. !! (I) i_v_lev : verbosity level
  33. !! (C) c_force : executing mode (noforce/force)
  34. !! (I) f_nb : total number of files
  35. !! (C) f_nm(:) : names of the files (input_files output_file)
  36. !!
  37. !!
  38. !! ASSOCIATED MODULES :
  39. !! IOIPSL(fliocom)
  40. !!
  41. !! RESTRICTIONS :
  42. !!
  43. !! Cases for character are not coded.
  44. !!
  45. !! Cases for netCDF variables such as array with more
  46. !! than 5 dimensions are not coded.
  47. !!
  48. !! Input files must have the following global attributes :
  49. !!
  50. !! "DOMAIN_number_total"
  51. !! "DOMAIN_number"
  52. !! "DOMAIN_dimensions_ids"
  53. !! "DOMAIN_size_global"
  54. !! "DOMAIN_size_local"
  55. !! "DOMAIN_position_first"
  56. !! "DOMAIN_position_last"
  57. !! "DOMAIN_halo_size_start"
  58. !! "DOMAIN_halo_size_end"
  59. !! "DOMAIN_type"
  60. !!
  61. !! NetCDF files must be smaller than 2 Gb.
  62. !!
  63. !! Character variables should have less than 257 letters
  64. !!
  65. !! EXAMPLE :
  66. !!
  67. !! rebuild -v -o sst.nc sst_[0-9][0-9][0-9][0-9].nc
  68. !!
  69. !! MODIFICATION HISTORY :
  70. !! Sebastien Masson (smasson@jamstec.go.jp) March 2004
  71. !! Jacques Bellier (Jacques.Bellier@cea.fr) June 2005
  72. !!--------------------------------------------------------------------
  73. USE IOIPSL
  74. USE defprec
  75. !-
  76. IMPLICIT NONE
  77. !-
  78. ! Character length
  79. INTEGER,PARAMETER :: chlen=256
  80. !-
  81. ! DO loops and test related variables
  82. INTEGER :: i,ia,id,iv,iw,i_i,i_n
  83. INTEGER :: ik,itmin,itmax,it1,it2,it
  84. LOGICAL :: l_force,l_uld
  85. !-
  86. ! Input arguments related variables
  87. INTEGER :: i_v_lev
  88. CHARACTER(LEN=15) :: c_force
  89. INTEGER :: f_nb,f_nb_in
  90. CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: f_nm
  91. !-
  92. ! Domains related variables
  93. INTEGER :: d_n_t,i_ntd
  94. INTEGER,DIMENSION(:),ALLOCATABLE :: dom_att,d_d_i,d_s_g
  95. INTEGER,DIMENSION(:,:),ALLOCATABLE :: d_s_l,d_p_f,d_p_l,d_h_s,d_h_e
  96. LOGICAL :: l_cgd,l_cof,l_col,l_o_f,l_o_m,l_o_l
  97. CHARACTER(LEN=chlen) :: c_d_n
  98. !-
  99. ! Model files related variables
  100. LOGICAL :: l_ocf
  101. INTEGER,DIMENSION(:),ALLOCATABLE :: f_a_id
  102. INTEGER :: f_id_i1,f_id_i,f_id_o
  103. INTEGER :: f_d_nb,f_v_nb,f_a_nb,f_d_ul
  104. INTEGER :: v_a_nb,a_type
  105. CHARACTER(LEN=chlen),DIMENSION(:),ALLOCATABLE :: &
  106. & f_d_nm,f_v_nm,f_a_nm,v_a_nm
  107. CHARACTER(LEN=chlen) :: f_u_nm
  108. INTEGER,DIMENSION(:),ALLOCATABLE :: v_d_nb,v_d_ul,v_type
  109. INTEGER,DIMENSION(:,:),ALLOCATABLE :: v_d_i
  110. INTEGER,DIMENSION(:),ALLOCATABLE :: f_d_i,f_d_l
  111. INTEGER :: a_l
  112. INTEGER,DIMENSION(flio_max_var_dims) :: d_i,ib,ie
  113. INTEGER,DIMENSION(:),ALLOCATABLE :: &
  114. & io_i,io_n,ia_sf,io_sf,io_cf,ia_sm,io_sm,io_cm,ia_sl,io_sl,io_cl
  115. LOGICAL :: l_ex
  116. CHARACTER(LEN=chlen) :: c_wn1,c_wn2
  117. !-
  118. !?INTEGERS of KIND 1 are not supported on all computers
  119. !?INTEGER(KIND=i_1) :: i1_0d
  120. !?INTEGER(KIND=i_1),DIMENSION(:),ALLOCATABLE :: i1_1d
  121. !?INTEGER(KIND=i_1),DIMENSION(:,:),ALLOCATABLE :: i1_2d
  122. !?INTEGER(KIND=i_1),DIMENSION(:,:,:),ALLOCATABLE :: i1_3d
  123. !?INTEGER(KIND=i_1),DIMENSION(:,:,:,:),ALLOCATABLE :: i1_4d
  124. !?INTEGER(KIND=i_1),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i1_5d
  125. INTEGER(KIND=i_2) :: i2_0d
  126. INTEGER(KIND=i_2),DIMENSION(:),ALLOCATABLE :: i2_1d
  127. INTEGER(KIND=i_2),DIMENSION(:,:),ALLOCATABLE :: i2_2d
  128. INTEGER(KIND=i_2),DIMENSION(:,:,:),ALLOCATABLE :: i2_3d
  129. INTEGER(KIND=i_2),DIMENSION(:,:,:,:),ALLOCATABLE :: i2_4d
  130. INTEGER(KIND=i_2),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i2_5d
  131. INTEGER(KIND=i_4) :: i4_0d
  132. INTEGER(KIND=i_4),DIMENSION(:),ALLOCATABLE :: i4_1d
  133. INTEGER(KIND=i_4),DIMENSION(:,:),ALLOCATABLE :: i4_2d
  134. INTEGER(KIND=i_4),DIMENSION(:,:,:),ALLOCATABLE :: i4_3d
  135. INTEGER(KIND=i_4),DIMENSION(:,:,:,:),ALLOCATABLE :: i4_4d
  136. INTEGER(KIND=i_4),DIMENSION(:,:,:,:,:),ALLOCATABLE :: i4_5d
  137. REAL(KIND=r_4) :: r4_0d
  138. REAL(KIND=r_4),DIMENSION(:),ALLOCATABLE :: r4_1d
  139. REAL(KIND=r_4),DIMENSION(:,:),ALLOCATABLE :: r4_2d
  140. REAL(KIND=r_4),DIMENSION(:,:,:),ALLOCATABLE :: r4_3d
  141. REAL(KIND=r_4),DIMENSION(:,:,:,:),ALLOCATABLE :: r4_4d
  142. REAL(KIND=r_8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: r4_5d
  143. REAL(KIND=r_8) :: r8_0d
  144. REAL(KIND=r_8),DIMENSION(:),ALLOCATABLE :: r8_1d
  145. REAL(KIND=r_8),DIMENSION(:,:),ALLOCATABLE :: r8_2d
  146. REAL(KIND=r_8),DIMENSION(:,:,:),ALLOCATABLE :: r8_3d
  147. REAL(KIND=r_8),DIMENSION(:,:,:,:),ALLOCATABLE :: r8_4d
  148. REAL(KIND=r_8),DIMENSION(:,:,:,:,:),ALLOCATABLE :: r8_5d
  149. !-
  150. ! elapsed and cpu time computation variables
  151. INTEGER :: nb_cc_ini,nb_cc_end,nb_cc_sec,nb_cc_max
  152. REAL :: t_cpu_ini,t_cpu_end
  153. !---------------------------------------------------------------------
  154. !-
  155. !-------------------
  156. ! INPUT arguments
  157. !-------------------
  158. !-
  159. ! Retrieve the verbosity level
  160. READ (UNIT=*,FMT=*) i_v_lev
  161. !-
  162. ! Retrieve the executing mode
  163. READ (UNIT=*,FMT='(A)') c_force
  164. l_force = (TRIM(c_force) == 'force')
  165. !-
  166. ! Retrieve the number of arguments
  167. READ (UNIT=*,FMT=*) f_nb
  168. f_nb_in = f_nb-1
  169. !-
  170. ! Retrieve the file names
  171. ALLOCATE(f_nm(f_nb))
  172. DO iw=1,f_nb
  173. READ (UNIT=*,FMT='(A)') f_nm(iw)
  174. ENDDO
  175. !-
  176. ! Allocate and initialize the array of file access identifiers
  177. ALLOCATE(f_a_id(f_nb_in)); f_a_id(:) = -1;
  178. !-
  179. IF (i_v_lev >= 1) THEN
  180. WRITE (UNIT=*,FMT='("")')
  181. WRITE (UNIT=*,FMT='(" verbosity level : ",I4)') i_v_lev
  182. WRITE (UNIT=*,FMT='(" executing mode : ",A)') TRIM(c_force)
  183. WRITE (UNIT=*,FMT='(" number of args : ",I4)') f_nb
  184. WRITE (UNIT=*,FMT='(" Input files :")')
  185. DO iw=1,f_nb_in
  186. WRITE (*,'(" ",A)') TRIM(f_nm(iw))
  187. ENDDO
  188. WRITE (UNIT=*,FMT='(" Output file :")')
  189. WRITE (*,'(" ",A)') TRIM(f_nm(f_nb))
  190. !-- time initializations
  191. CALL system_clock &
  192. & (count=nb_cc_ini,count_rate=nb_cc_sec,count_max=nb_cc_max)
  193. CALL cpu_time (t_cpu_ini)
  194. ENDIF
  195. !-
  196. !---------------------------------------------------
  197. ! Retrieve basic informations from the first file
  198. !---------------------------------------------------
  199. !-
  200. ! Open the first file
  201. CALL flrb_of (1,f_id_i)
  202. !-
  203. ! Get the attribute "DOMAIN_number_total"
  204. CALL fliogeta (f_id_i,"?","DOMAIN_number_total",d_n_t)
  205. !-
  206. ! Validate the number of input files :
  207. ! should be equal to the total number
  208. ! of domains used in the simulation
  209. IF (d_n_t /= f_nb_in) THEN
  210. IF (l_force) THEN
  211. iw = 2
  212. ELSE
  213. iw = 3
  214. DEALLOCATE(f_nm,f_a_id)
  215. CALL flrb_cf (1,.TRUE.)
  216. ENDIF
  217. CALL ipslerr (iw,"flio_rbld", &
  218. & "The number of input files", &
  219. & "is not equal to the number of DOMAINS"," ")
  220. ENDIF
  221. !-
  222. ! Retrieve the basic characteristics of the first input file
  223. CALL flioinqf &
  224. & (f_id_i,nb_dim=f_d_nb,nb_var=f_v_nb,nb_gat=f_a_nb,id_uld=f_d_ul)
  225. !-
  226. ! Build the list of the names of the
  227. ! dimensions/variables/global_attributes and retrieve
  228. ! the unlimited_dimension name from the first input file
  229. ALLOCATE(f_d_nm(f_d_nb),f_v_nm(f_v_nb),f_a_nm(f_a_nb))
  230. CALL flioinqn (f_id_i,cn_dim=f_d_nm,cn_var=f_v_nm, &
  231. & cn_gat=f_a_nm,cn_uld=f_u_nm)
  232. !-
  233. ! Build the list of the dimensions identifiers and lengths
  234. ALLOCATE(f_d_i(f_d_nb),f_d_l(f_d_nb))
  235. CALL flioinqf (f_id_i,id_dim=f_d_i,ln_dim=f_d_l)
  236. !-
  237. ! Close the file
  238. CALL flrb_cf (1,.FALSE.)
  239. !-
  240. ! Check if the number of needed files is greater than
  241. ! the maximum number of simultaneously opened files.
  242. ! In that case, open and close model files for each reading,
  243. ! otherwise keep the "flio" identifiers of the opened files.
  244. l_ocf = (f_nb > flio_max_files)
  245. !-
  246. !----------------------------------------------------
  247. ! Retrieve domain informations for each input file
  248. !----------------------------------------------------
  249. !-
  250. DO iw=1,f_nb_in
  251. !---
  252. CALL flrb_of (iw,f_id_i)
  253. !---
  254. IF (iw > 1) THEN
  255. c_wn1 = "DOMAIN_number_total"
  256. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  257. IF (l_ex) THEN
  258. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),i_ntd)
  259. IF (i_ntd /= d_n_t) THEN
  260. CALL ipslerr (3,"flio_rbld", &
  261. & "File : "//TRIM(f_nm(iw)), &
  262. & "Attribute : "//TRIM(c_wn1), &
  263. & "not equal to the one of the first file")
  264. ENDIF
  265. ELSE
  266. CALL ipslerr (3,"flio_rbld", &
  267. & "File : "//TRIM(f_nm(iw)), &
  268. & "Attribute : "//TRIM(c_wn1),"not found")
  269. ENDIF
  270. ENDIF
  271. !---
  272. c_wn1 = "DOMAIN_dimensions_ids"
  273. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  274. IF (l_ex) THEN
  275. ALLOCATE(dom_att(a_l))
  276. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  277. IF (iw == 1) THEN
  278. IF (ANY(dom_att(:) == f_d_ul)) THEN
  279. CALL ipslerr (3,"flio_rbld", &
  280. & "File : "//TRIM(f_nm(iw)), &
  281. & "Attribute : "//TRIM(c_wn1), &
  282. & "contains the unlimited dimension")
  283. ENDIF
  284. ALLOCATE (d_d_i(a_l))
  285. d_d_i(:) = dom_att(:)
  286. ELSEIF (SIZE(dom_att) /= SIZE(d_d_i)) THEN
  287. CALL ipslerr (3,"flio_rbld", &
  288. & "File : "//TRIM(f_nm(iw)), &
  289. & "size of the attribute : "//TRIM(c_wn1), &
  290. & "not equal to the one of the first file")
  291. ELSEIF (ANY(dom_att(:) /= d_d_i(:))) THEN
  292. CALL ipslerr (3,"flio_rbld", &
  293. & "File : "//TRIM(f_nm(iw)), &
  294. & "Attribute : "//TRIM(c_wn1), &
  295. & "not equal to the one of the first file")
  296. ENDIF
  297. DEALLOCATE(dom_att)
  298. ELSE
  299. CALL ipslerr (3,"flio_rbld", &
  300. & "File : "//TRIM(f_nm(iw)), &
  301. & "Attribute : "//TRIM(c_wn1),"not found")
  302. ENDIF
  303. !---
  304. c_wn1 = "DOMAIN_size_global"
  305. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  306. IF (l_ex) THEN
  307. IF (a_l /= SIZE(d_d_i)) THEN
  308. CALL ipslerr (3,"flio_rbld", &
  309. & "File : "//TRIM(f_nm(iw)), &
  310. & "size of the attribute : "//TRIM(c_wn1), &
  311. & "not equal to the size of DOMAIN_dimensions_ids")
  312. ELSE
  313. ALLOCATE(dom_att(a_l))
  314. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  315. IF (iw == 1) THEN
  316. ALLOCATE (d_s_g(a_l))
  317. d_s_g(:)=dom_att(:)
  318. ELSEIF (ANY(dom_att(:) /= d_s_g(:))) THEN
  319. CALL ipslerr (3,"flio_rbld", &
  320. & "File : "//TRIM(f_nm(iw)), &
  321. & "Attribute : "//TRIM(c_wn1), &
  322. & "not equal to the one of the first file")
  323. ENDIF
  324. DEALLOCATE(dom_att)
  325. ENDIF
  326. ELSE
  327. CALL ipslerr (3,"flio_rbld", &
  328. & "File : "//TRIM(f_nm(iw)), &
  329. & "Attribute : "//TRIM(c_wn1),"not found")
  330. ENDIF
  331. !---
  332. c_wn1 = "DOMAIN_size_local"
  333. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  334. IF (l_ex) THEN
  335. IF (a_l /= SIZE(d_d_i)) THEN
  336. CALL ipslerr (3,"flio_rbld", &
  337. & "File : "//TRIM(f_nm(iw)), &
  338. & "size of the attribute : "//TRIM(c_wn1), &
  339. & "not equal to the size of DOMAIN_dimensions_ids")
  340. ELSE
  341. ALLOCATE(dom_att(a_l))
  342. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  343. IF (iw == 1) THEN
  344. ALLOCATE (d_s_l(a_l,f_nb_in))
  345. ENDIF
  346. d_s_l(:,iw)=dom_att(:)
  347. DEALLOCATE(dom_att)
  348. ENDIF
  349. ELSE
  350. CALL ipslerr (3,"flio_rbld", &
  351. & "File : "//TRIM(f_nm(iw)), &
  352. & "Attribute : "//TRIM(c_wn1),"not found")
  353. ENDIF
  354. !---
  355. c_wn1 = "DOMAIN_position_first"
  356. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  357. IF (l_ex) THEN
  358. IF (a_l /= SIZE(d_d_i)) THEN
  359. CALL ipslerr (3,"flio_rbld", &
  360. & "File : "//TRIM(f_nm(iw)), &
  361. & "size of the attribute : "//TRIM(c_wn1), &
  362. & "not equal to the size of DOMAIN_dimensions_ids")
  363. ELSE
  364. ALLOCATE(dom_att(a_l))
  365. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  366. IF (iw == 1) THEN
  367. ALLOCATE (d_p_f(a_l,f_nb_in))
  368. ENDIF
  369. d_p_f(:,iw)=dom_att(:)
  370. DEALLOCATE(dom_att)
  371. ENDIF
  372. ELSE
  373. CALL ipslerr (3,"flio_rbld", &
  374. & "File : "//TRIM(f_nm(iw)), &
  375. & "Attribute : "//TRIM(c_wn1),"not found")
  376. ENDIF
  377. !---
  378. c_wn1 = "DOMAIN_position_last"
  379. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  380. IF (l_ex) THEN
  381. IF (a_l /= SIZE(d_d_i)) THEN
  382. CALL ipslerr (3,"flio_rbld", &
  383. & "File : "//TRIM(f_nm(iw)), &
  384. & "size of the attribute : "//TRIM(c_wn1), &
  385. & "not equal to the size of DOMAIN_dimensions_ids")
  386. ELSE
  387. ALLOCATE(dom_att(a_l))
  388. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  389. IF (iw == 1) THEN
  390. ALLOCATE (d_p_l(a_l,f_nb_in))
  391. ENDIF
  392. d_p_l(:,iw)=dom_att(:)
  393. DEALLOCATE(dom_att)
  394. ENDIF
  395. ELSE
  396. CALL ipslerr (3,"flio_rbld", &
  397. & "File : "//TRIM(f_nm(iw)), &
  398. & "Attribute : "//TRIM(c_wn1),"not found")
  399. ENDIF
  400. !---
  401. c_wn1 = "DOMAIN_halo_size_start"
  402. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  403. IF (l_ex) THEN
  404. IF (a_l /= SIZE(d_d_i)) THEN
  405. CALL ipslerr (3,"flio_rbld", &
  406. & "File : "//TRIM(f_nm(iw)), &
  407. & "size of the attribute : "//TRIM(c_wn1), &
  408. & "not equal to the size of DOMAIN_dimensions_ids")
  409. ELSE
  410. ALLOCATE(dom_att(a_l))
  411. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  412. IF (iw == 1) THEN
  413. ALLOCATE (d_h_s(a_l,f_nb_in))
  414. ENDIF
  415. d_h_s(:,iw)=dom_att(:)
  416. DEALLOCATE(dom_att)
  417. ENDIF
  418. ELSE
  419. CALL ipslerr (3,"flio_rbld", &
  420. & "File : "//TRIM(f_nm(iw)), &
  421. & "Attribute : "//TRIM(c_wn1),"not found")
  422. ENDIF
  423. !---
  424. c_wn1 = "DOMAIN_halo_size_end"
  425. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  426. IF (l_ex) THEN
  427. IF (a_l /= SIZE(d_d_i)) THEN
  428. CALL ipslerr (3,"flio_rbld", &
  429. & "File : "//TRIM(f_nm(iw)), &
  430. & "size of the attribute : "//TRIM(c_wn1), &
  431. & "not equal to the size of DOMAIN_dimensions_ids")
  432. ELSE
  433. ALLOCATE(dom_att(a_l))
  434. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),dom_att)
  435. IF (iw == 1) THEN
  436. ALLOCATE (d_h_e(a_l,f_nb_in))
  437. ENDIF
  438. d_h_e(:,iw)=dom_att(:)
  439. DEALLOCATE(dom_att)
  440. ENDIF
  441. ELSE
  442. CALL ipslerr (3,"flio_rbld", &
  443. & "File : "//TRIM(f_nm(iw)), &
  444. & "Attribute : "//TRIM(c_wn1),"not found")
  445. ENDIF
  446. !---
  447. c_wn1 = "DOMAIN_type"
  448. c_wn2 = " "
  449. CALL flioinqa (f_id_i,"?",TRIM(c_wn1),l_ex,a_l=a_l)
  450. IF (l_ex) THEN
  451. CALL fliogeta (f_id_i,"?",TRIM(c_wn1),c_wn2)
  452. CALL strlowercase (c_wn2)
  453. IF (iw == 1) THEN
  454. IF ( (TRIM(c_wn2) == "box") &
  455. & .OR.(TRIM(c_wn2) == "apple") ) THEN
  456. c_d_n = c_wn2
  457. ELSE
  458. CALL ipslerr (3,"flio_rbld", &
  459. & "File : "//TRIM(f_nm(iw)), &
  460. & "Attribute : "//TRIM(c_wn1), &
  461. & "type "//TRIM(c_wn2)//" not (yet) supported")
  462. ENDIF
  463. ELSEIF (TRIM(c_wn2) /= TRIM(c_d_n)) THEN
  464. CALL ipslerr (3,"flio_rbld", &
  465. & "File : "//TRIM(f_nm(iw)), &
  466. & "Attribute : "//TRIM(c_wn1), &
  467. & "not equal to the one of the first file")
  468. ENDIF
  469. ELSE
  470. CALL ipslerr (3,"flio_rbld", &
  471. & "File : "//TRIM(f_nm(iw)), &
  472. & "Attribute : "//TRIM(c_wn1),"not found")
  473. ENDIF
  474. !---
  475. CALL flrb_cf (iw,l_ocf)
  476. !---
  477. ENDDO
  478. !-
  479. IF (i_v_lev >= 2) THEN
  480. WRITE (UNIT=*,FMT='("")')
  481. WRITE (*,'(" From the first file : ")')
  482. WRITE (*,'(" Number of dimensions : ",I2)') f_d_nb
  483. WRITE (*,'(" Idents : ",(10(1X,I4),:))') f_d_i(1:f_d_nb)
  484. WRITE (*,'(" Lengths : ",(10(1X,I4),:))') f_d_l(1:f_d_nb)
  485. WRITE (*,'(" Names: ")')
  486. DO i=1,f_d_nb
  487. WRITE (*,'(" """,A,"""")') TRIM(f_d_nm(i))
  488. ENDDO
  489. IF (f_d_ul > 0) THEN
  490. WRITE (*,'(" Unlimited dimension id : ",I2)') f_d_i(f_d_ul)
  491. ENDIF
  492. WRITE (*,'(" Number of variables : ",I2)') f_v_nb
  493. WRITE (*,'(" Names: ")')
  494. DO i=1,f_v_nb
  495. WRITE (*,'(" """,A,"""")') TRIM(f_v_nm(i))
  496. ENDDO
  497. WRITE (*,'(" Number of global attributes : ",I2)') f_a_nb
  498. WRITE (*,'(" Names: ")')
  499. DO i=1,f_a_nb
  500. WRITE (*,'(" """,A,"""")') TRIM(f_a_nm(i))
  501. ENDDO
  502. ENDIF
  503. IF (i_v_lev >= 3) THEN
  504. WRITE (UNIT=*,FMT='("")')
  505. WRITE (*,'(" From input files : ")')
  506. WRITE (*,'(" Total number of DOMAINS : ",I4)') d_n_t
  507. WRITE (*,'(" DOMAIN_dimensions_ids :",(10(1X,I5),:))') d_d_i(:)
  508. WRITE (*,'(" DOMAIN_size_global :",(10(1X,I5),:))') d_s_g(:)
  509. WRITE (*,'(" DOMAIN_type : """,(A),"""")') TRIM(c_d_n)
  510. DO iw=1,f_nb_in
  511. WRITE (*,'(" File : ",A)') TRIM(f_nm(iw))
  512. WRITE (*,'(" d_s_l :",(10(1X,I5),:))') d_s_l(:,iw)
  513. WRITE (*,'(" d_p_f :",(10(1X,I5),:))') d_p_f(:,iw)
  514. WRITE (*,'(" d_p_l :",(10(1X,I5),:))') d_p_l(:,iw)
  515. WRITE (*,'(" d_h_s :",(10(1X,I5),:))') d_h_s(:,iw)
  516. IF (TRIM(c_d_n) == "apple") THEN
  517. IF (COUNT(d_h_s(:,iw) /= 0) > 1) THEN
  518. CALL ipslerr (3,"flio_rbld", &
  519. & "Beginning offset is not yet supported", &
  520. & "for more than one dimension"," ")
  521. ENDIF
  522. ENDIF
  523. WRITE (*,'(" d_h_e :",(10(1X,I5),:))') d_h_e(:,iw)
  524. IF (TRIM(c_d_n) == "apple") THEN
  525. IF (COUNT(d_h_e(:,iw) /= 0) > 1) THEN
  526. CALL ipslerr (3,"flio_rbld", &
  527. & "Ending offset is not yet supported", &
  528. & "for more than one dimension"," ")
  529. ENDIF
  530. ENDIF
  531. ENDDO
  532. ENDIF
  533. !-
  534. !---------------------------------------
  535. ! Create the dimensionned output file
  536. !---------------------------------------
  537. !-
  538. ! Define the dimensions used in the output file
  539. DO id=1,f_d_nb
  540. DO i=1,SIZE(d_d_i)
  541. IF (f_d_i(id) == d_d_i(i)) THEN
  542. f_d_l(id) = d_s_g(i)
  543. ENDIF
  544. ENDDO
  545. ENDDO
  546. !-
  547. IF (f_d_ul > 0) THEN
  548. i = f_d_l(f_d_ul); f_d_l(f_d_ul) = -1;
  549. ENDIF
  550. !-
  551. ! Create the output file
  552. CALL fliocrfd (TRIM(f_nm(f_nb)),f_d_nm,f_d_l,f_id_o,c_f_n=c_wn1)
  553. !-
  554. IF (f_d_ul > 0) THEN
  555. f_d_l(f_d_ul) = i; itmin = 1; itmax = f_d_l(f_d_ul);
  556. ELSE
  557. itmin = 1; itmax = 1;
  558. ENDIF
  559. !-
  560. ! open the first input file used to build the output file
  561. !-
  562. CALL flrb_of (1,f_id_i1)
  563. !-
  564. ! define the global attributes in the output file
  565. ! copy all global attributes except those beginning by "DOMAIN_"
  566. ! eventually actualize the "file_name" attribute
  567. !-
  568. DO ia=1,f_a_nb
  569. IF (INDEX(TRIM(f_a_nm(ia)),"DOMAIN_") == 1) CYCLE
  570. IF (TRIM(f_a_nm(ia)) == "file_name") THEN
  571. CALL flioputa (f_id_o,"?",TRIM(f_a_nm(ia)),TRIM(c_wn1))
  572. ELSE
  573. CALL fliocpya (f_id_i1,"?",TRIM(f_a_nm(ia)),f_id_o,"?")
  574. ENDIF
  575. ENDDO
  576. !-
  577. ! define the variables in the output file
  578. !-
  579. ALLOCATE(v_d_nb(f_v_nb)); v_d_nb(:) = 0;
  580. ALLOCATE(v_d_ul(f_v_nb)); v_d_ul(:) = 0;
  581. ALLOCATE(v_type(f_v_nb),v_d_i(flio_max_var_dims,f_v_nb));
  582. DO iv=1,f_v_nb
  583. !-- get variable informations
  584. CALL flioinqv &
  585. & (f_id_i1,TRIM(f_v_nm(iv)),l_ex,v_t=v_type(iv), &
  586. & nb_dims=v_d_nb(iv),id_dims=d_i,nb_atts=v_a_nb)
  587. !-- define the new variable
  588. IF (v_d_nb(iv) == 0) THEN
  589. CALL fliodefv &
  590. & (f_id_o,TRIM(f_v_nm(iv)),v_t=v_type(iv))
  591. ELSE
  592. CALL fliodefv &
  593. & (f_id_o,TRIM(f_v_nm(iv)),d_i(1:v_d_nb(iv)),v_t=v_type(iv))
  594. DO iw=1,v_d_nb(iv)
  595. IF (f_d_ul > 0) THEN
  596. IF (d_i(iw) == f_d_ul) THEN
  597. v_d_ul(iv) = iw
  598. ENDIF
  599. ENDIF
  600. ENDDO
  601. v_d_i(1:v_d_nb(iv),iv) = d_i(1:v_d_nb(iv))
  602. ENDIF
  603. !-- copy all variable attributes
  604. IF (v_a_nb > 0) THEN
  605. ALLOCATE(v_a_nm(v_a_nb))
  606. CALL flioinqv (f_id_i1,TRIM(f_v_nm(iv)),l_ex,cn_atts=v_a_nm)
  607. DO ia=1,v_a_nb
  608. CALL fliocpya &
  609. & (f_id_i1,TRIM(f_v_nm(iv)),TRIM(v_a_nm(ia)), &
  610. & f_id_o,TRIM(f_v_nm(iv)))
  611. ENDDO
  612. DEALLOCATE(v_a_nm)
  613. ENDIF
  614. ENDDO
  615. !-
  616. ! update valid_min valid_max attributes values
  617. !-
  618. CALL flrb_rg
  619. !-
  620. !------------------------
  621. ! Fill the output file
  622. !------------------------
  623. !-
  624. DO ik=1,2
  625. l_uld = (ik /= 1)
  626. IF (l_uld) THEN
  627. it1=itmin; it2=itmax;
  628. ELSE
  629. it1=1; it2=1;
  630. ENDIF
  631. DO it=it1,it2
  632. DO iv=1,f_v_nb
  633. IF ( (.NOT.l_uld.AND.(v_d_ul(iv) > 0)) &
  634. & .OR.(l_uld.AND.(v_d_ul(iv) <= 0)) ) THEN
  635. CYCLE
  636. ENDIF
  637. IF (i_v_lev >= 3) THEN
  638. WRITE (UNIT=*,FMT='("")')
  639. IF (l_uld) THEN
  640. WRITE (UNIT=*,FMT=*) "time step : ",it
  641. ENDIF
  642. WRITE (UNIT=*,FMT=*) "variable : ",TRIM(f_v_nm(iv))
  643. WRITE (UNIT=*,FMT=*) "var unlim dim : ",v_d_ul(iv)
  644. ENDIF
  645. !------ do the variable contains dimensions to be recombined ?
  646. l_cgd = .FALSE.
  647. i_n = 1
  648. DO i=1,SIZE(d_d_i)
  649. l_cgd = ANY(v_d_i(1:v_d_nb(iv),iv) == d_d_i(i))
  650. l_cgd = l_cgd.AND.ANY(d_s_l(i,1:f_nb_in) /= d_s_g(i))
  651. IF (l_cgd) THEN
  652. i_n = f_nb_in
  653. EXIT
  654. ENDIF
  655. ENDDO
  656. IF (v_d_nb(iv) > 0) THEN
  657. !-------- Allocate io_i,io_n,ia_sm,io_sm,io_cm
  658. i = v_d_nb(iv)
  659. ALLOCATE(io_i(i),io_n(i),ia_sm(i),io_sm(i),io_cm(i))
  660. !-------- Default definition of io_i,io_n,io_sm,io_cm
  661. io_i(:) = 1; io_n(:) = f_d_l(v_d_i(1:v_d_nb(iv),iv));
  662. ia_sm(:) = 1; io_sm(:) = 1;
  663. IF (v_d_ul(iv) > 0) THEN
  664. io_i(v_d_ul(iv))=it
  665. io_n(v_d_ul(iv))=1
  666. io_sm(v_d_ul(iv))=it
  667. ENDIF
  668. io_cm(:) = io_n(:);
  669. !-------- If needed, allocate offset
  670. l_o_f = .FALSE.; l_o_m = .TRUE.; l_o_l = .FALSE.;
  671. IF (TRIM(c_d_n) == "apple") THEN
  672. ALLOCATE(ia_sf(i),io_sf(i),io_cf(i))
  673. ALLOCATE(ia_sl(i),io_sl(i),io_cl(i))
  674. ia_sf(:) = 1; io_sf(:) = 1; io_cf(:) = io_n(:);
  675. ia_sl(:) = 1; io_sl(:) = 1; io_cl(:) = io_n(:);
  676. IF (v_d_ul(iv) > 0) THEN
  677. io_sf(v_d_ul(iv))=it
  678. io_sl(v_d_ul(iv))=it
  679. ENDIF
  680. ENDIF
  681. !-------- Initialize to zero variables data
  682. ! approximate dimension
  683. IF ( it == 1 .AND. l_cgd) THEN
  684. ! Enter I*J I*J is larger thant total number of single files
  685. if ( ((f_d_l(1)/(d_s_l(1,1)-3)) * (f_d_l(2)/(d_s_l(2,1)-3) )) .gt. d_n_t ) then
  686. CALL ZeroFill (f_id_o, f_v_nm(iv), f_d_l, v_d_nb(iv), v_type(iv), v_d_i(1:v_d_nb(iv),iv))
  687. endif
  688. ENDIF
  689. ENDIF
  690. !------
  691. DO i_i=1,i_n
  692. IF (l_cgd) THEN
  693. !---------- the variable contains dimensions to be recombined
  694. !-----------
  695. !---------- open each file containing a small piece of data
  696. CALL flrb_of (i_i,f_id_i)
  697. !-----------
  698. !---------- do the variable has offset at first/last block ?
  699. l_cof = .FALSE.; l_col = .FALSE.;
  700. IF (TRIM(c_d_n) == "apple") THEN
  701. L_BF: DO id=1,v_d_nb(iv)
  702. DO i=1,SIZE(d_d_i)
  703. IF (v_d_i(id,iv) == d_d_i(i)) THEN
  704. l_cof = (d_h_s(i,i_i) /= 0)
  705. IF (l_cof) EXIT L_BF
  706. ENDIF
  707. ENDDO
  708. ENDDO L_BF
  709. L_BL: DO id=1,v_d_nb(iv)
  710. DO i=1,SIZE(d_d_i)
  711. IF (v_d_i(id,iv) == d_d_i(i)) THEN
  712. l_col = (d_h_e(i,i_i) /= 0)
  713. IF (l_col) EXIT L_BL
  714. ENDIF
  715. ENDDO
  716. ENDDO L_BL
  717. ENDIF
  718. !---------- if needed, redefine start and count for dimensions
  719. l_o_f = .FALSE.; l_o_m = .TRUE.; l_o_l = .FALSE.;
  720. DO id=1,v_d_nb(iv)
  721. DO i=1,SIZE(d_d_i)
  722. IF (v_d_i(id,iv) == d_d_i(i)) THEN
  723. io_n(id) = d_p_l(i,i_i)-d_p_f(i,i_i)+1
  724. ia_sm(id) = 1
  725. io_sm(id) = d_p_f(i,i_i)
  726. io_cm(id) = io_n(id)
  727. IF (TRIM(c_d_n) == "box") THEN
  728. ia_sm(id) = ia_sm(id)+d_h_s(i,i_i)
  729. io_sm(id) = io_sm(id)+d_h_s(i,i_i)
  730. io_cm(id) = io_cm(id)-d_h_s(i,i_i)-d_h_e(i,i_i)
  731. ELSEIF (TRIM(c_d_n) == "apple") THEN
  732. IF (l_cof) THEN
  733. IF (d_h_s(i,i_i) /= 0) THEN
  734. ia_sf(id) = 1+d_h_s(i,i_i)
  735. io_sf(id) = d_p_f(i,i_i)+d_h_s(i,i_i)
  736. io_cf(id) = io_n(id)-d_h_s(i,i_i)
  737. ELSE
  738. io_sf(id) = d_p_f(i,i_i)
  739. io_cf(id) = 1
  740. ia_sm(id) = ia_sm(id)+1
  741. io_sm(id) = io_sm(id)+1
  742. io_cm(id) = io_cm(id)-1
  743. l_o_f = .TRUE.
  744. ENDIF
  745. ENDIF
  746. IF (l_col) THEN
  747. IF (d_h_e(i,i_i) /= 0) THEN
  748. ia_sl(id) = 1
  749. io_sl(id) = d_p_f(i,i_i)
  750. io_cl(id) = io_n(id)-d_h_e(i,i_i)
  751. ELSE
  752. io_cm(id) = io_cm(id)-1
  753. ia_sl(id) = 1+io_n(id)-1
  754. io_sl(id) = d_p_f(i,i_i)+io_n(id)-1
  755. io_cl(id) = 1
  756. l_o_l = .TRUE.
  757. ENDIF
  758. ENDIF
  759. ENDIF
  760. ENDIF
  761. ENDDO
  762. ENDDO
  763. l_o_m = ALL(io_cm > 0)
  764. ELSE
  765. !---------- the data can be read/write in one piece
  766. f_id_i = f_id_i1
  767. ENDIF
  768. !---------
  769. IF (i_v_lev >= 3) THEN
  770. WRITE (UNIT=*,FMT=*) &
  771. & TRIM(f_nm(i_i))//" - "//TRIM(f_v_nm(iv))
  772. WRITE (UNIT=*,FMT=*) "io_i : ",io_i(:)
  773. WRITE (UNIT=*,FMT=*) "io_n : ",io_n(:)
  774. WRITE (UNIT=*,FMT=*) "l_o_f : ",l_o_f
  775. IF (l_o_f) THEN
  776. WRITE (UNIT=*,FMT=*) "ia_sf : ",ia_sf(:)
  777. WRITE (UNIT=*,FMT=*) "io_sf : ",io_sf(:)
  778. WRITE (UNIT=*,FMT=*) "io_cf : ",io_cf(:)
  779. ENDIF
  780. WRITE (UNIT=*,FMT=*) "l_o_m : ",l_o_m
  781. IF (l_o_m) THEN
  782. WRITE (UNIT=*,FMT=*) "ia_sm : ",ia_sm(:)
  783. WRITE (UNIT=*,FMT=*) "io_sm : ",io_sm(:)
  784. WRITE (UNIT=*,FMT=*) "io_cm : ",io_cm(:)
  785. ENDIF
  786. WRITE (UNIT=*,FMT=*) "l_o_l : ",l_o_l
  787. IF (l_o_l) THEN
  788. WRITE (UNIT=*,FMT=*) "ia_sl : ",ia_sl(:)
  789. WRITE (UNIT=*,FMT=*) "io_sl : ",io_sl(:)
  790. WRITE (UNIT=*,FMT=*) "io_cl : ",io_cl(:)
  791. ENDIF
  792. ENDIF
  793. !---------
  794. !-------- Cases according to the type, shape and offsets of the data
  795. !---------
  796. SELECT CASE (v_type(iv))
  797. !?INTEGERS of KIND 1 are not supported on all computers
  798. !? CASE (flio_i1) !--- INTEGER 1
  799. !? SELECT CASE (v_d_nb(iv))
  800. !? CASE (0) !--- Scalar
  801. !? CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_0d)
  802. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i1_0d)
  803. !? CASE (1) !--- 1d array
  804. !? ALLOCATE(i1_1d(io_n(1)))
  805. !? CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_1d, &
  806. !? & start=io_i(:),count=io_n(:))
  807. !? IF (l_o_f) THEN
  808. !? ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
  809. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  810. !? & i1_1d(ib(1):ie(1)), &
  811. !? & start=io_sf(:),count=io_cf(:))
  812. !? ENDIF
  813. !? IF (l_o_m) THEN
  814. !? ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
  815. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  816. !? & i1_1d(ib(1):ie(1)), &
  817. !? & start=io_sm(:),count=io_cm(:))
  818. !? ENDIF
  819. !? IF (l_o_l) THEN
  820. !? ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
  821. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  822. !? & i1_1d(ib(1):ie(1)), &
  823. !? & start=io_sl(:),count=io_cl(:))
  824. !? ENDIF
  825. !? DEALLOCATE(i1_1d)
  826. !? CASE (2) !--- 2d array
  827. !? ALLOCATE(i1_2d(io_n(1),io_n(2)))
  828. !? CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_2d, &
  829. !? & start=io_i(:),count=io_n(:))
  830. !? IF (l_o_f) THEN
  831. !? ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
  832. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  833. !? & i1_2d(ib(1):ie(1),ib(2):ie(2)), &
  834. !? & start=io_sf(:),count=io_cf(:))
  835. !? ENDIF
  836. !? IF (l_o_m) THEN
  837. !? ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
  838. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  839. !? & i1_2d(ib(1):ie(1),ib(2):ie(2)), &
  840. !? & start=io_sm(:),count=io_cm(:))
  841. !? ENDIF
  842. !? IF (l_o_l) THEN
  843. !? ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
  844. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  845. !? & i1_2d(ib(1):ie(1),ib(2):ie(2)), &
  846. !? & start=io_sl(:),count=io_cl(:))
  847. !? ENDIF
  848. !? DEALLOCATE(i1_2d)
  849. !? CASE (3) !--- 3d array
  850. !? ALLOCATE(i1_3d(io_n(1),io_n(2),io_n(3)))
  851. !? CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_3d, &
  852. !? & start=io_i(:),count=io_n(:))
  853. !? IF (l_o_f) THEN
  854. !? ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
  855. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  856. !? & i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  857. !? & start=io_sf(:),count=io_cf(:))
  858. !? ENDIF
  859. !? IF (l_o_m) THEN
  860. !? ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
  861. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  862. !? & i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  863. !? & start=io_sm(:),count=io_cm(:))
  864. !? ENDIF
  865. !? IF (l_o_l) THEN
  866. !? ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
  867. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  868. !? & i1_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  869. !? & start=io_sl(:),count=io_cl(:))
  870. !? ENDIF
  871. !? DEALLOCATE(i1_3d)
  872. !? CASE (4) !--- 4d array
  873. !? ALLOCATE(i1_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
  874. !? CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_4d, &
  875. !? & start=io_i(:),count=io_n(:))
  876. !? IF (l_o_f) THEN
  877. !? ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
  878. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  879. !? & i1_4d(ib(1):ie(1),ib(2):ie(2), &
  880. !? & ib(3):ie(3),ib(4):ie(4)), &
  881. !? & start=io_sf(:),count=io_cf(:))
  882. !? ENDIF
  883. !? IF (l_o_m) THEN
  884. !? ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
  885. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  886. !? & i1_4d(ib(1):ie(1),ib(2):ie(2), &
  887. !? & ib(3):ie(3),ib(4):ie(4)), &
  888. !? & start=io_sm(:),count=io_cm(:))
  889. !? ENDIF
  890. !? IF (l_o_l) THEN
  891. !? ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
  892. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  893. !? & i1_4d(ib(1):ie(1),ib(2):ie(2), &
  894. !? & ib(3):ie(3),ib(4):ie(4)), &
  895. !? & start=io_sl(:),count=io_cl(:))
  896. !? ENDIF
  897. !? DEALLOCATE(i1_4d)
  898. !? CASE (5) !--- 5d array
  899. !? ALLOCATE(i1_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
  900. !? CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i1_5d, &
  901. !? & start=io_i(:),count=io_n(:))
  902. !? IF (l_o_f) THEN
  903. !? ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
  904. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  905. !? & i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  906. !? & ib(4):ie(4),ib(5):ie(5)), &
  907. !? & start=io_sf(:),count=io_cf(:))
  908. !? ENDIF
  909. !? IF (l_o_m) THEN
  910. !? ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
  911. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  912. !? & i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  913. !? & ib(4):ie(4),ib(5):ie(5)), &
  914. !? & start=io_sm(:),count=io_cm(:))
  915. !? ENDIF
  916. !? IF (l_o_l) THEN
  917. !? ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
  918. !? CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  919. !? & i1_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  920. !? & ib(4):ie(4),ib(5):ie(5)), &
  921. !? & start=io_sl(:),count=io_cl(:))
  922. !? ENDIF
  923. !? DEALLOCATE(i1_5d)
  924. !? END SELECT
  925. !? CASE (flio_i2) !--- INTEGER 2
  926. CASE (flio_i1,flio_i2) !--- INTEGER 1/INTEGER 2
  927. SELECT CASE (v_d_nb(iv))
  928. CASE (0) !--- Scalar
  929. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_0d)
  930. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i2_0d)
  931. CASE (1) !--- 1d array
  932. ALLOCATE(i2_1d(io_n(1)))
  933. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_1d, &
  934. & start=io_i(:),count=io_n(:))
  935. IF (l_o_f) THEN
  936. ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
  937. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  938. & i2_1d(ib(1):ie(1)), &
  939. & start=io_sf(:),count=io_cf(:))
  940. ENDIF
  941. IF (l_o_m) THEN
  942. ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
  943. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  944. & i2_1d(ib(1):ie(1)), &
  945. & start=io_sm(:),count=io_cm(:))
  946. ENDIF
  947. IF (l_o_l) THEN
  948. ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
  949. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  950. & i2_1d(ib(1):ie(1)), &
  951. & start=io_sl(:),count=io_cl(:))
  952. ENDIF
  953. DEALLOCATE(i2_1d)
  954. CASE (2) !--- 2d array
  955. ALLOCATE(i2_2d(io_n(1),io_n(2)))
  956. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_2d, &
  957. & start=io_i(:),count=io_n(:))
  958. IF (l_o_f) THEN
  959. ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
  960. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  961. & i2_2d(ib(1):ie(1),ib(2):ie(2)), &
  962. & start=io_sf(:),count=io_cf(:))
  963. ENDIF
  964. IF (l_o_m) THEN
  965. ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
  966. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  967. & i2_2d(ib(1):ie(1),ib(2):ie(2)), &
  968. & start=io_sm(:),count=io_cm(:))
  969. ENDIF
  970. IF (l_o_l) THEN
  971. ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
  972. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  973. & i2_2d(ib(1):ie(1),ib(2):ie(2)), &
  974. & start=io_sl(:),count=io_cl(:))
  975. ENDIF
  976. DEALLOCATE(i2_2d)
  977. CASE (3) !--- 3d array
  978. ALLOCATE(i2_3d(io_n(1),io_n(2),io_n(3)))
  979. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_3d, &
  980. & start=io_i(:),count=io_n(:))
  981. IF (l_o_f) THEN
  982. ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
  983. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  984. & i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  985. & start=io_sf(:),count=io_cf(:))
  986. ENDIF
  987. IF (l_o_m) THEN
  988. ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
  989. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  990. & i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  991. & start=io_sm(:),count=io_cm(:))
  992. ENDIF
  993. IF (l_o_l) THEN
  994. ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
  995. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  996. & i2_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  997. & start=io_sl(:),count=io_cl(:))
  998. ENDIF
  999. DEALLOCATE(i2_3d)
  1000. CASE (4) !--- 4d array
  1001. ALLOCATE(i2_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
  1002. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_4d, &
  1003. & start=io_i(:),count=io_n(:))
  1004. IF (l_o_f) THEN
  1005. ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
  1006. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1007. & i2_4d(ib(1):ie(1),ib(2):ie(2), &
  1008. & ib(3):ie(3),ib(4):ie(4)), &
  1009. & start=io_sf(:),count=io_cf(:))
  1010. ENDIF
  1011. IF (l_o_m) THEN
  1012. ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
  1013. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1014. & i2_4d(ib(1):ie(1),ib(2):ie(2), &
  1015. & ib(3):ie(3),ib(4):ie(4)), &
  1016. & start=io_sm(:),count=io_cm(:))
  1017. ENDIF
  1018. IF (l_o_l) THEN
  1019. ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
  1020. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1021. & i2_4d(ib(1):ie(1),ib(2):ie(2), &
  1022. & ib(3):ie(3),ib(4):ie(4)), &
  1023. & start=io_sl(:),count=io_cl(:))
  1024. ENDIF
  1025. DEALLOCATE(i2_4d)
  1026. CASE (5) !--- 5d array
  1027. ALLOCATE(i2_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
  1028. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i2_5d, &
  1029. & start=io_i(:),count=io_n(:))
  1030. IF (l_o_f) THEN
  1031. ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
  1032. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1033. & i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1034. & ib(4):ie(4),ib(5):ie(5)), &
  1035. & start=io_sf(:),count=io_cf(:))
  1036. ENDIF
  1037. IF (l_o_m) THEN
  1038. ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
  1039. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1040. & i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1041. & ib(4):ie(4),ib(5):ie(5)), &
  1042. & start=io_sm(:),count=io_cm(:))
  1043. ENDIF
  1044. IF (l_o_l) THEN
  1045. ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
  1046. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1047. & i2_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1048. & ib(4):ie(4),ib(5):ie(5)), &
  1049. & start=io_sl(:),count=io_cl(:))
  1050. ENDIF
  1051. DEALLOCATE(i2_5d)
  1052. END SELECT
  1053. CASE (flio_i4) !--- INTEGER 4
  1054. SELECT CASE (v_d_nb(iv))
  1055. CASE (0) !--- Scalar
  1056. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_0d)
  1057. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),i4_0d)
  1058. CASE (1) !--- 1d array
  1059. ALLOCATE(i4_1d(io_n(1)))
  1060. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_1d, &
  1061. & start=io_i(:),count=io_n(:))
  1062. IF (l_o_f) THEN
  1063. ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
  1064. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1065. & i4_1d(ib(1):ie(1)), &
  1066. & start=io_sf(:),count=io_cf(:))
  1067. ENDIF
  1068. IF (l_o_m) THEN
  1069. ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
  1070. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1071. & i4_1d(ib(1):ie(1)), &
  1072. & start=io_sm(:),count=io_cm(:))
  1073. ENDIF
  1074. IF (l_o_l) THEN
  1075. ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
  1076. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1077. & i4_1d(ib(1):ie(1)), &
  1078. & start=io_sl(:),count=io_cl(:))
  1079. ENDIF
  1080. DEALLOCATE(i4_1d)
  1081. CASE (2) !--- 2d array
  1082. ALLOCATE(i4_2d(io_n(1),io_n(2)))
  1083. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_2d, &
  1084. & start=io_i(:),count=io_n(:))
  1085. IF (l_o_f) THEN
  1086. ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
  1087. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1088. & i4_2d(ib(1):ie(1),ib(2):ie(2)), &
  1089. & start=io_sf(:),count=io_cf(:))
  1090. ENDIF
  1091. IF (l_o_m) THEN
  1092. ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
  1093. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1094. & i4_2d(ib(1):ie(1),ib(2):ie(2)), &
  1095. & start=io_sm(:),count=io_cm(:))
  1096. ENDIF
  1097. IF (l_o_l) THEN
  1098. ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
  1099. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1100. & i4_2d(ib(1):ie(1),ib(2):ie(2)), &
  1101. & start=io_sl(:),count=io_cl(:))
  1102. ENDIF
  1103. DEALLOCATE(i4_2d)
  1104. CASE (3) !--- 3d array
  1105. ALLOCATE(i4_3d(io_n(1),io_n(2),io_n(3)))
  1106. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_3d, &
  1107. & start=io_i(:),count=io_n(:))
  1108. IF (l_o_f) THEN
  1109. ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
  1110. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1111. & i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1112. & start=io_sf(:),count=io_cf(:))
  1113. ENDIF
  1114. IF (l_o_m) THEN
  1115. ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
  1116. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1117. & i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1118. & start=io_sm(:),count=io_cm(:))
  1119. ENDIF
  1120. IF (l_o_l) THEN
  1121. ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
  1122. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1123. & i4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1124. & start=io_sl(:),count=io_cl(:))
  1125. ENDIF
  1126. DEALLOCATE(i4_3d)
  1127. CASE (4) !--- 4d array
  1128. ALLOCATE(i4_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
  1129. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_4d, &
  1130. & start=io_i(:),count=io_n(:))
  1131. IF (l_o_f) THEN
  1132. ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
  1133. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1134. & i4_4d(ib(1):ie(1),ib(2):ie(2), &
  1135. & ib(3):ie(3),ib(4):ie(4)), &
  1136. & start=io_sf(:),count=io_cf(:))
  1137. ENDIF
  1138. IF (l_o_m) THEN
  1139. ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
  1140. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1141. & i4_4d(ib(1):ie(1),ib(2):ie(2), &
  1142. & ib(3):ie(3),ib(4):ie(4)), &
  1143. & start=io_sm(:),count=io_cm(:))
  1144. ENDIF
  1145. IF (l_o_l) THEN
  1146. ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
  1147. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1148. & i4_4d(ib(1):ie(1),ib(2):ie(2), &
  1149. & ib(3):ie(3),ib(4):ie(4)), &
  1150. & start=io_sl(:),count=io_cl(:))
  1151. ENDIF
  1152. DEALLOCATE(i4_4d)
  1153. CASE (5) !--- 5d array
  1154. ALLOCATE(i4_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
  1155. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),i4_5d, &
  1156. & start=io_i(:),count=io_n(:))
  1157. IF (l_o_f) THEN
  1158. ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
  1159. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1160. & i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1161. & ib(4):ie(4),ib(5):ie(5)), &
  1162. & start=io_sf(:),count=io_cf(:))
  1163. ENDIF
  1164. IF (l_o_m) THEN
  1165. ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
  1166. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1167. & i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1168. & ib(4):ie(4),ib(5):ie(5)), &
  1169. & start=io_sm(:),count=io_cm(:))
  1170. ENDIF
  1171. IF (l_o_l) THEN
  1172. ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
  1173. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1174. & i4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1175. & ib(4):ie(4),ib(5):ie(5)), &
  1176. & start=io_sl(:),count=io_cl(:))
  1177. ENDIF
  1178. DEALLOCATE(i4_5d)
  1179. END SELECT
  1180. CASE (flio_r4) !--- REAL 4
  1181. SELECT CASE (v_d_nb(iv))
  1182. CASE (0) !--- Scalar
  1183. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_0d)
  1184. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),r4_0d)
  1185. CASE (1) !--- 1d array
  1186. ALLOCATE(r4_1d(io_n(1)))
  1187. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_1d, &
  1188. & start=io_i(:),count=io_n(:))
  1189. IF (l_o_f) THEN
  1190. ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
  1191. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1192. & r4_1d(ib(1):ie(1)), &
  1193. & start=io_sf(:),count=io_cf(:))
  1194. ENDIF
  1195. IF (l_o_m) THEN
  1196. ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
  1197. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1198. & r4_1d(ib(1):ie(1)), &
  1199. & start=io_sm(:),count=io_cm(:))
  1200. ENDIF
  1201. IF (l_o_l) THEN
  1202. ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
  1203. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1204. & r4_1d(ib(1):ie(1)), &
  1205. & start=io_sl(:),count=io_cl(:))
  1206. ENDIF
  1207. DEALLOCATE(r4_1d)
  1208. CASE (2) !--- 2d array
  1209. ALLOCATE(r4_2d(io_n(1),io_n(2)))
  1210. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_2d, &
  1211. & start=io_i(:),count=io_n(:))
  1212. IF (l_o_f) THEN
  1213. ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
  1214. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1215. & r4_2d(ib(1):ie(1),ib(2):ie(2)), &
  1216. & start=io_sf(:),count=io_cf(:))
  1217. ENDIF
  1218. IF (l_o_m) THEN
  1219. ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
  1220. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1221. & r4_2d(ib(1):ie(1),ib(2):ie(2)), &
  1222. & start=io_sm(:),count=io_cm(:))
  1223. ENDIF
  1224. IF (l_o_l) THEN
  1225. ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
  1226. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1227. & r4_2d(ib(1):ie(1),ib(2):ie(2)), &
  1228. & start=io_sl(:),count=io_cl(:))
  1229. ENDIF
  1230. DEALLOCATE(r4_2d)
  1231. CASE (3) !--- 3d array
  1232. ALLOCATE(r4_3d(io_n(1),io_n(2),io_n(3)))
  1233. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_3d, &
  1234. & start=io_i(:),count=io_n(:))
  1235. IF (l_o_f) THEN
  1236. ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
  1237. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1238. & r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1239. & start=io_sf(:),count=io_cf(:))
  1240. ENDIF
  1241. IF (l_o_m) THEN
  1242. ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
  1243. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1244. & r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1245. & start=io_sm(:),count=io_cm(:))
  1246. ENDIF
  1247. IF (l_o_l) THEN
  1248. ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
  1249. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1250. & r4_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1251. & start=io_sl(:),count=io_cl(:))
  1252. ENDIF
  1253. DEALLOCATE(r4_3d)
  1254. CASE (4) !--- 4d array
  1255. ALLOCATE(r4_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
  1256. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_4d, &
  1257. & start=io_i(:),count=io_n(:))
  1258. IF (l_o_f) THEN
  1259. ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
  1260. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1261. & r4_4d(ib(1):ie(1),ib(2):ie(2), &
  1262. & ib(3):ie(3),ib(4):ie(4)), &
  1263. & start=io_sf(:),count=io_cf(:))
  1264. ENDIF
  1265. IF (l_o_m) THEN
  1266. ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
  1267. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1268. & r4_4d(ib(1):ie(1),ib(2):ie(2), &
  1269. & ib(3):ie(3),ib(4):ie(4)), &
  1270. & start=io_sm(:),count=io_cm(:))
  1271. ENDIF
  1272. IF (l_o_l) THEN
  1273. ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
  1274. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1275. & r4_4d(ib(1):ie(1),ib(2):ie(2), &
  1276. & ib(3):ie(3),ib(4):ie(4)), &
  1277. & start=io_sl(:),count=io_cl(:))
  1278. ENDIF
  1279. DEALLOCATE(r4_4d)
  1280. CASE (5) !--- 5d array
  1281. ALLOCATE(r4_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
  1282. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r4_5d, &
  1283. & start=io_i(:),count=io_n(:))
  1284. IF (l_o_f) THEN
  1285. ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
  1286. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1287. & r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1288. & ib(4):ie(4),ib(5):ie(5)), &
  1289. & start=io_sf(:),count=io_cf(:))
  1290. ENDIF
  1291. IF (l_o_m) THEN
  1292. ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
  1293. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1294. & r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1295. & ib(4):ie(4),ib(5):ie(5)), &
  1296. & start=io_sm(:),count=io_cm(:))
  1297. ENDIF
  1298. IF (l_o_l) THEN
  1299. ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
  1300. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1301. & r4_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1302. & ib(4):ie(4),ib(5):ie(5)), &
  1303. & start=io_sl(:),count=io_cl(:))
  1304. ENDIF
  1305. DEALLOCATE(r4_5d)
  1306. END SELECT
  1307. CASE (flio_r8) !--- REAL 8
  1308. SELECT CASE (v_d_nb(iv))
  1309. CASE (0) !--- Scalar
  1310. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_0d)
  1311. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)),r8_0d)
  1312. CASE (1) !--- 1d array
  1313. ALLOCATE(r8_1d(io_n(1)))
  1314. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_1d, &
  1315. & start=io_i(:),count=io_n(:))
  1316. IF (l_o_f) THEN
  1317. ib(1:1) = ia_sf(1:1); ie(1:1) = ib(1:1)+io_cf(1:1)-1;
  1318. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1319. & r8_1d(ib(1):ie(1)), &
  1320. & start=io_sf(:),count=io_cf(:))
  1321. ENDIF
  1322. IF (l_o_m) THEN
  1323. ib(1:1) = ia_sm(1:1); ie(1:1) = ib(1:1)+io_cm(1:1)-1;
  1324. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1325. & r8_1d(ib(1):ie(1)), &
  1326. & start=io_sm(:),count=io_cm(:))
  1327. ENDIF
  1328. IF (l_o_l) THEN
  1329. ib(1:1) = ia_sl(1:1); ie(1:1) = ib(1:1)+io_cl(1:1)-1;
  1330. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1331. & r8_1d(ib(1):ie(1)), &
  1332. & start=io_sl(:),count=io_cl(:))
  1333. ENDIF
  1334. DEALLOCATE(r8_1d)
  1335. CASE (2) !--- 2d array
  1336. ALLOCATE(r8_2d(io_n(1),io_n(2)))
  1337. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_2d, &
  1338. & start=io_i(:),count=io_n(:))
  1339. IF (l_o_f) THEN
  1340. ib(1:2) = ia_sf(1:2); ie(1:2) = ib(1:2)+io_cf(1:2)-1;
  1341. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1342. & r8_2d(ib(1):ie(1),ib(2):ie(2)), &
  1343. & start=io_sf(:),count=io_cf(:))
  1344. ENDIF
  1345. IF (l_o_m) THEN
  1346. ib(1:2) = ia_sm(1:2); ie(1:2) = ib(1:2)+io_cm(1:2)-1;
  1347. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1348. & r8_2d(ib(1):ie(1),ib(2):ie(2)), &
  1349. & start=io_sm(:),count=io_cm(:))
  1350. ENDIF
  1351. IF (l_o_l) THEN
  1352. ib(1:2) = ia_sl(1:2); ie(1:2) = ib(1:2)+io_cl(1:2)-1;
  1353. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1354. & r8_2d(ib(1):ie(1),ib(2):ie(2)), &
  1355. & start=io_sl(:),count=io_cl(:))
  1356. ENDIF
  1357. DEALLOCATE(r8_2d)
  1358. CASE (3) !--- 3d array
  1359. ALLOCATE(r8_3d(io_n(1),io_n(2),io_n(3)))
  1360. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_3d, &
  1361. & start=io_i(:),count=io_n(:))
  1362. IF (l_o_f) THEN
  1363. ib(1:3) = ia_sf(1:3); ie(1:3) = ib(1:3)+io_cf(1:3)-1;
  1364. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1365. & r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1366. & start=io_sf(:),count=io_cf(:))
  1367. ENDIF
  1368. IF (l_o_m) THEN
  1369. ib(1:3) = ia_sm(1:3); ie(1:3) = ib(1:3)+io_cm(1:3)-1;
  1370. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1371. & r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1372. & start=io_sm(:),count=io_cm(:))
  1373. ENDIF
  1374. IF (l_o_l) THEN
  1375. ib(1:3) = ia_sl(1:3); ie(1:3) = ib(1:3)+io_cl(1:3)-1;
  1376. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1377. & r8_3d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3)), &
  1378. & start=io_sl(:),count=io_cl(:))
  1379. ENDIF
  1380. DEALLOCATE(r8_3d)
  1381. CASE (4) !--- 4d array
  1382. ALLOCATE(r8_4d(io_n(1),io_n(2),io_n(3),io_n(4)))
  1383. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_4d, &
  1384. & start=io_i(:),count=io_n(:))
  1385. IF (l_o_f) THEN
  1386. ib(1:4) = ia_sf(1:4); ie(1:4) = ib(1:4)+io_cf(1:4)-1;
  1387. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1388. & r8_4d(ib(1):ie(1),ib(2):ie(2), &
  1389. & ib(3):ie(3),ib(4):ie(4)), &
  1390. & start=io_sf(:),count=io_cf(:))
  1391. ENDIF
  1392. IF (l_o_m) THEN
  1393. ib(1:4) = ia_sm(1:4); ie(1:4) = ib(1:4)+io_cm(1:4)-1;
  1394. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1395. & r8_4d(ib(1):ie(1),ib(2):ie(2), &
  1396. & ib(3):ie(3),ib(4):ie(4)), &
  1397. & start=io_sm(:),count=io_cm(:))
  1398. ENDIF
  1399. IF (l_o_l) THEN
  1400. ib(1:4) = ia_sl(1:4); ie(1:4) = ib(1:4)+io_cl(1:4)-1;
  1401. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1402. & r8_4d(ib(1):ie(1),ib(2):ie(2), &
  1403. & ib(3):ie(3),ib(4):ie(4)), &
  1404. & start=io_sl(:),count=io_cl(:))
  1405. ENDIF
  1406. DEALLOCATE(r8_4d)
  1407. CASE (5) !--- 5d array
  1408. ALLOCATE(r8_5d(io_n(1),io_n(2),io_n(3),io_n(4),io_n(5)))
  1409. CALL fliogetv (f_id_i,TRIM(f_v_nm(iv)),r8_5d, &
  1410. & start=io_i(:),count=io_n(:))
  1411. IF (l_o_f) THEN
  1412. ib(1:5) = ia_sf(1:5); ie(1:5) = ib(1:5)+io_cf(1:5)-1;
  1413. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1414. & r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1415. & ib(4):ie(4),ib(5):ie(5)), &
  1416. & start=io_sf(:),count=io_cf(:))
  1417. ENDIF
  1418. IF (l_o_m) THEN
  1419. ib(1:5) = ia_sm(1:5); ie(1:5) = ib(1:5)+io_cm(1:5)-1;
  1420. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1421. & r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1422. & ib(4):ie(4),ib(5):ie(5)), &
  1423. & start=io_sm(:),count=io_cm(:))
  1424. ENDIF
  1425. IF (l_o_l) THEN
  1426. ib(1:5) = ia_sl(1:5); ie(1:5) = ib(1:5)+io_cl(1:5)-1;
  1427. CALL flioputv (f_id_o,TRIM(f_v_nm(iv)), &
  1428. & r8_5d(ib(1):ie(1),ib(2):ie(2),ib(3):ie(3), &
  1429. & ib(4):ie(4),ib(5):ie(5)), &
  1430. & start=io_sl(:),count=io_cl(:))
  1431. ENDIF
  1432. DEALLOCATE(r8_5d)
  1433. END SELECT
  1434. END SELECT
  1435. !-------- eventually close each file containing a small piece of data
  1436. CALL flrb_cf (i_i,l_ocf.AND.l_cgd.AND.(i_i /= 1))
  1437. ENDDO
  1438. !------ If needed, deallocate io_* arrays
  1439. IF (v_d_nb(iv) > 0) THEN
  1440. DEALLOCATE(io_i,io_n,ia_sm,io_sm,io_cm)
  1441. IF (TRIM(c_d_n) == "apple") THEN
  1442. DEALLOCATE(ia_sf,io_sf,io_cf)
  1443. DEALLOCATE(ia_sl,io_sl,io_cl)
  1444. ENDIF
  1445. ENDIF
  1446. ENDDO
  1447. ENDDO
  1448. ENDDO
  1449. !-
  1450. !-------------------
  1451. ! Ending the work
  1452. !-------------------
  1453. !-
  1454. ! Close files
  1455. CALL flrb_cf (0,.TRUE.)
  1456. !-
  1457. ! Deallocate
  1458. DEALLOCATE(f_nm,f_a_id)
  1459. DEALLOCATE(f_d_nm,f_v_nm,f_a_nm)
  1460. DEALLOCATE(f_d_i,f_d_l)
  1461. DEALLOCATE(v_d_nb,v_d_ul,v_type,v_d_i)
  1462. DEALLOCATE(d_d_i,d_s_g)
  1463. DEALLOCATE(d_s_l,d_p_f,d_p_l,d_h_s,d_h_e)
  1464. !-
  1465. IF (i_v_lev >= 1) THEN
  1466. !-- elapsed and cpu time computation
  1467. CALL cpu_time (t_cpu_end)
  1468. CALL system_clock(count=nb_cc_end)
  1469. WRITE (UNIT=*,FMT='("")')
  1470. WRITE (UNIT=*,fmt='(" elapsed time (s) : ",1PE11.4)') &
  1471. & REAL(nb_cc_end-nb_cc_ini)/REAL(nb_cc_sec)
  1472. WRITE (UNIT=*,fmt='(" CPU time (s) : ",1PE11.4)') &
  1473. & t_cpu_end-t_cpu_ini
  1474. ENDIF
  1475. !=======
  1476. CONTAINS
  1477. !=======
  1478. SUBROUTINE flrb_of (i_f_n,i_f_i)
  1479. !---------------------------------------------------------------------
  1480. ! Open the file of number "i_f_n" if necessary,
  1481. ! and returns its identifier in "i_f_i".
  1482. !---------------------------------------------------------------------
  1483. IMPLICIT NONE
  1484. !-
  1485. INTEGER,INTENT(IN) :: i_f_n
  1486. INTEGER,INTENT(OUT) :: i_f_i
  1487. !---------------------------------------------------------------------
  1488. IF (f_a_id(i_f_n) < 0) THEN
  1489. CALL flioopfd (TRIM(f_nm(i_f_n)),i_f_i)
  1490. f_a_id(i_f_n) = i_f_i
  1491. ELSE
  1492. i_f_i = f_a_id(i_f_n)
  1493. ENDIF
  1494. !---------------------
  1495. END SUBROUTINE flrb_of
  1496. !===
  1497. SUBROUTINE flrb_cf (i_f_n,l_cf)
  1498. !---------------------------------------------------------------------
  1499. ! Close the file of number "i_f_n" if "l_cf" is TRUE.
  1500. ! Close all files if "i_f_n <= 0".
  1501. !---------------------------------------------------------------------
  1502. IMPLICIT NONE
  1503. !-
  1504. INTEGER,INTENT(IN) :: i_f_n
  1505. LOGICAL,INTENT(IN) :: l_cf
  1506. !---------------------------------------------------------------------
  1507. IF (i_f_n <= 0) THEN
  1508. CALL flioclo ()
  1509. f_a_id(:) = -1
  1510. ELSE
  1511. IF (l_cf) THEN
  1512. IF (f_a_id(i_f_n) < 0) THEN
  1513. CALL ipslerr (2,"flio_rbld", &
  1514. & "The file",TRIM(f_nm(i_f_n)),"is already closed")
  1515. ELSE
  1516. CALL flioclo (f_a_id(i_f_n))
  1517. f_a_id(i_f_n) = -1
  1518. ENDIF
  1519. ENDIF
  1520. ENDIF
  1521. !---------------------
  1522. END SUBROUTINE flrb_cf
  1523. !===
  1524. SUBROUTINE flrb_rg
  1525. !---------------------------------------------------------------------
  1526. ! Update valid_min valid_max attributes values
  1527. !---------------------------------------------------------------------
  1528. INTEGER :: k,j
  1529. LOGICAL :: l_vmin,l_vmax
  1530. INTEGER(KIND=i_4) :: i4_vmin,i4_vmax
  1531. REAL(KIND=r_4) :: r4_vmin,r4_vmax
  1532. REAL(KIND=r_8) :: r8_vmin,r8_vmax
  1533. !---------------------------------------------------------------------
  1534. DO k=1,f_v_nb
  1535. !-- get attribute informations
  1536. CALL flioinqa &
  1537. & (f_id_i1,TRIM(f_v_nm(k)),'valid_min',l_vmin,a_t=a_type)
  1538. CALL flioinqa &
  1539. & (f_id_i1,TRIM(f_v_nm(k)),'valid_max',l_vmax,a_t=a_type)
  1540. !---
  1541. IF (l_vmin.OR.l_vmax) THEN
  1542. !---- get values of min/max
  1543. SELECT CASE (a_type)
  1544. CASE (flio_i1,flio_i2,flio_i4) !--- INTEGER 1/2/4
  1545. DO j=1,f_nb_in
  1546. CALL flrb_of (j,f_id_i)
  1547. IF (l_vmin) THEN
  1548. CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",i4_0d)
  1549. IF (j == 1) THEN
  1550. i4_vmin = i4_0d
  1551. ELSE
  1552. i4_vmin = MIN(i4_vmin,i4_0d)
  1553. ENDIF
  1554. ENDIF
  1555. IF (l_vmax) THEN
  1556. CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",i4_0d)
  1557. IF (j == 1) THEN
  1558. i4_vmax = i4_0d
  1559. ELSE
  1560. i4_vmax = MAX(i4_vmax,i4_0d)
  1561. ENDIF
  1562. ENDIF
  1563. CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
  1564. ENDDO
  1565. IF (l_vmin) THEN
  1566. CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",i4_vmin)
  1567. ENDIF
  1568. IF (l_vmax) THEN
  1569. CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",i4_vmax)
  1570. ENDIF
  1571. CASE (flio_r4) !--- REAL 4
  1572. DO j=1,f_nb_in
  1573. CALL flrb_of (j,f_id_i)
  1574. IF (l_vmin) THEN
  1575. CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",r4_0d)
  1576. IF (j == 1) THEN
  1577. r4_vmin = r4_0d
  1578. ELSE
  1579. r4_vmin = MIN(r4_vmin,r4_0d)
  1580. ENDIF
  1581. ENDIF
  1582. IF (l_vmax) THEN
  1583. CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",r4_0d)
  1584. IF (j == 1) THEN
  1585. r4_vmax = r4_0d
  1586. ELSE
  1587. r4_vmax = MAX(r4_vmax,r4_0d)
  1588. ENDIF
  1589. ENDIF
  1590. CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
  1591. ENDDO
  1592. IF (l_vmin) THEN
  1593. CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",r4_vmin)
  1594. ENDIF
  1595. IF (l_vmax) THEN
  1596. CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",r4_vmax)
  1597. ENDIF
  1598. CASE (flio_r8) !--- REAL 8
  1599. DO j=1,f_nb_in
  1600. CALL flrb_of (j,f_id_i)
  1601. IF (l_vmin) THEN
  1602. CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_min",r8_0d)
  1603. IF (j == 1) THEN
  1604. r8_vmin = r8_0d
  1605. ELSE
  1606. r8_vmin = MIN(r8_vmin,r8_0d)
  1607. ENDIF
  1608. ENDIF
  1609. IF (l_vmax) THEN
  1610. CALL fliogeta(f_id_i,TRIM(f_v_nm(k)),"valid_max",r8_0d)
  1611. IF (j == 1) THEN
  1612. r8_vmax = r8_0d
  1613. ELSE
  1614. r8_vmax = MAX(r8_vmax,r8_0d)
  1615. ENDIF
  1616. ENDIF
  1617. CALL flrb_cf (j,l_ocf.AND.(f_id_i /= f_id_i1))
  1618. ENDDO
  1619. IF (l_vmin) THEN
  1620. CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_min",r8_vmin)
  1621. ENDIF
  1622. IF (l_vmax) THEN
  1623. CALL flioputa (f_id_o,TRIM(f_v_nm(k)),"valid_max",r8_vmax)
  1624. ENDIF
  1625. END SELECT
  1626. ENDIF
  1627. ENDDO
  1628. !---------------------
  1629. END SUBROUTINE flrb_rg
  1630. !===
  1631. SUBROUTINE ZeroFill(f_id_o,f_v_nm,f_d_l,v_d_nb,v_type,v_d_i)
  1632. IMPLICIT NONE
  1633. ! Character length
  1634. INTEGER,PARAMETER :: chlen=256
  1635. INTEGER :: v_d_nb, v_type ! variable # of dims, variable type, var Unlim dimension
  1636. INTEGER :: f_id_o ! Output file ID
  1637. INTEGER,DIMENSION(:) :: f_d_l, v_d_i ! Global dimensions, variable dimensio ID
  1638. CHARACTER(LEN=chlen) :: f_v_nm ! Variable name
  1639. INTEGER,DIMENSION(:),ALLOCATABLE :: dims
  1640. INTEGER(KIND=i_2) :: i2_0d
  1641. INTEGER(KIND=i_2), ALLOCATABLE :: i2_1d(:), i2_2d(:,:), i2_3d(:,:,:), i2_4d(:,:,:,:), i2_5d(:,:,:,:,:)
  1642. INTEGER(KIND=i_4) :: i4_0d
  1643. INTEGER(KIND=i_4), ALLOCATABLE :: i4_1d(:), i4_2d(:,:), i4_3d(:,:,:), i4_4d(:,:,:,:), i4_5d(:,:,:,:,:)
  1644. REAL(KIND=r_4) :: r4_0d
  1645. REAL(KIND=r_4), ALLOCATABLE :: r4_1d(:), r4_2d(:,:), r4_3d(:,:,:), r4_4d(:,:,:,:), r4_5d(:,:,:,:,:)
  1646. REAL(KIND=r_8) :: r8_0d
  1647. REAL(KIND=r_8), ALLOCATABLE :: r8_1d(:), r8_2d(:,:), r8_3d(:,:,:), r8_4d(:,:,:,:), r8_5d(:,:,:,:,:)
  1648. ! write(*,*) ' Into my sub... TOM'
  1649. ! write(*,*) f_id_o, TRIM(f_v_nm), v_d_nb , v_type
  1650. write(*,*) 'Variable: ',TRIM(f_v_nm), ' intiliazed to zero'
  1651. write(*,*)
  1652. ! define variable dimension
  1653. ALLOCATE(dims(v_d_nb))
  1654. dims=f_d_l(v_d_i)
  1655. SELECT CASE(v_type)
  1656. ! INTEGER 1 and 2
  1657. CASE (flio_i1,flio_i2)
  1658. SELECT CASE (v_d_nb)
  1659. CASE(1)
  1660. ALLOCATE(i2_1d(dims(1)))
  1661. i2_1d=0
  1662. CALL flioputv (f_id_o,TRIM(f_v_nm),i2_1d)
  1663. DEALLOCATE(i2_1d)
  1664. CASE(2)
  1665. ALLOCATE(i2_2d(dims(1),dims(2)))
  1666. i2_2d=0
  1667. CALL flioputv (f_id_o,TRIM(f_v_nm),i2_2d)
  1668. DEALLOCATE(i2_2d)
  1669. CASE(3)
  1670. ALLOCATE(i2_3d(dims(1),dims(2),dims(3)))
  1671. i2_3d=0
  1672. CALL flioputv (f_id_o,TRIM(f_v_nm),i2_3d)
  1673. DEALLOCATE(i2_3d)
  1674. CASE(4)
  1675. ALLOCATE(i2_4d(dims(1),dims(2),dims(3),dims(4)))
  1676. i2_4d=0
  1677. CALL flioputv (f_id_o,TRIM(f_v_nm),i2_4d)
  1678. DEALLOCATE(i2_4d)
  1679. CASE(5)
  1680. ALLOCATE(i2_5d(dims(1),dims(2),dims(3),dims(4),dims(5)))
  1681. i2_5d=0
  1682. CALL flioputv (f_id_o,TRIM(f_v_nm),i2_5d)
  1683. DEALLOCATE(i2_5d)
  1684. END SELECT
  1685. ! INTEGER 4
  1686. CASE (flio_i4)
  1687. SELECT CASE (v_d_nb)
  1688. CASE(1)
  1689. ALLOCATE(i4_1d(dims(1)))
  1690. i4_1d=0
  1691. CALL flioputv (f_id_o,TRIM(f_v_nm),i4_1d)
  1692. DEALLOCATE(i4_1d)
  1693. CASE(2)
  1694. ALLOCATE(i4_2d(dims(1),dims(2)))
  1695. i4_2d=0
  1696. CALL flioputv (f_id_o,TRIM(f_v_nm),i4_2d)
  1697. DEALLOCATE(i4_2d)
  1698. CASE(3)
  1699. ALLOCATE(i4_3d(dims(1),dims(2),dims(3)))
  1700. i4_3d=0
  1701. CALL flioputv (f_id_o,TRIM(f_v_nm),i4_3d)
  1702. DEALLOCATE(i4_3d)
  1703. CASE(4)
  1704. ALLOCATE(i4_4d(dims(1),dims(2),dims(3),dims(4)))
  1705. i4_4d=0
  1706. CALL flioputv (f_id_o,TRIM(f_v_nm),i4_4d)
  1707. DEALLOCATE(i4_4d)
  1708. CASE(5)
  1709. ALLOCATE(i4_5d(dims(1),dims(2),dims(3),dims(4),dims(5)))
  1710. i4_5d=0
  1711. CALL flioputv (f_id_o,TRIM(f_v_nm),i4_5d)
  1712. DEALLOCATE(i4_5d)
  1713. END SELECT
  1714. ! FLOAT 4
  1715. CASE (flio_r4)
  1716. SELECT CASE (v_d_nb)
  1717. CASE(1)
  1718. ALLOCATE(r4_1d(dims(1)))
  1719. r4_1d=0
  1720. CALL flioputv (f_id_o,TRIM(f_v_nm),r4_1d)
  1721. DEALLOCATE(r4_1d)
  1722. CASE(2)
  1723. ALLOCATE(r4_2d(dims(1),dims(2)))
  1724. r4_2d=0
  1725. CALL flioputv (f_id_o,TRIM(f_v_nm),r4_2d)
  1726. DEALLOCATE(r4_2d)
  1727. CASE(3)
  1728. ALLOCATE(r4_3d(dims(1),dims(2),dims(3)))
  1729. r4_3d=0
  1730. CALL flioputv (f_id_o,TRIM(f_v_nm),r4_3d)
  1731. DEALLOCATE(r4_3d)
  1732. CASE(4)
  1733. ALLOCATE(r4_4d(dims(1),dims(2),dims(3),dims(4)))
  1734. r4_4d=0
  1735. CALL flioputv (f_id_o,TRIM(f_v_nm),r4_4d)
  1736. DEALLOCATE(r4_4d)
  1737. CASE(5)
  1738. ALLOCATE(r4_5d(dims(1),dims(2),dims(3),dims(4),dims(5)))
  1739. r4_5d=0
  1740. CALL flioputv (f_id_o,TRIM(f_v_nm),r4_5d)
  1741. DEALLOCATE(r4_5d)
  1742. END SELECT
  1743. ! FLOAT 8
  1744. CASE (flio_r8)
  1745. SELECT CASE (v_d_nb)
  1746. CASE(1)
  1747. ALLOCATE(r8_1d(dims(1)))
  1748. r8_1d=0
  1749. CALL flioputv (f_id_o,TRIM(f_v_nm),r8_1d)
  1750. DEALLOCATE(r8_1d)
  1751. CASE(2)
  1752. ALLOCATE(r8_2d(dims(1),dims(2)))
  1753. r8_2d=0
  1754. CALL flioputv (f_id_o,TRIM(f_v_nm),r8_2d)
  1755. DEALLOCATE(r8_2d)
  1756. CASE(3)
  1757. ALLOCATE(r8_3d(dims(1),dims(2),dims(3)))
  1758. r8_3d=0
  1759. CALL flioputv (f_id_o,TRIM(f_v_nm),r8_3d)
  1760. DEALLOCATE(r8_3d)
  1761. CASE(4)
  1762. ALLOCATE(r8_4d(dims(1),dims(2),dims(3),dims(4)))
  1763. r8_4d=0
  1764. CALL flioputv (f_id_o,TRIM(f_v_nm),r8_4d)
  1765. DEALLOCATE(r8_4d)
  1766. CASE(5)
  1767. ALLOCATE(r8_5d(dims(1),dims(2),dims(3),dims(4),dims(5)))
  1768. r8_5d=0
  1769. CALL flioputv (f_id_o,TRIM(f_v_nm),r8_5d)
  1770. DEALLOCATE(r8_5d)
  1771. END SELECT
  1772. END SELECT
  1773. DEALLOCATE (dims)
  1774. END SUBROUTINE
  1775. !===
  1776. !--------------------
  1777. END PROGRAM flio_rbld