-
Notifications
You must be signed in to change notification settings - Fork 4
/
m_put_mod_fld.F90
76 lines (59 loc) · 2.9 KB
/
m_put_mod_fld.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module m_put_mod_fld
! KAL -- This routine puts one of the fields to the restart file, specified
! KAL -- by name, vertical level and time level.
! KAL -- Its a bit dangerous to use -- indx must be updated correctly (max one
! KAL -- increment per call of this routine), otherwise there wil be a
! KAL -- inconsistency between .a and .b files
contains
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! KAL - This is for the new file type
subroutine put_mod_fld(memfile,fld,iens,cfld,vlevel,tlevel,indx,nx,ny)
use mod_raw_io
implicit none
integer, intent(in) :: nx,ny
integer, intent(in) :: iens ! Ensemble member to read
real, dimension(nx,ny), intent(in) :: fld ! output fld
character(len=*), intent(in) :: memfile! base name of input files
character(len=8), intent(in) :: cfld ! name of fld
integer, intent(in) :: tlevel ! time level
integer, intent(in) :: vlevel ! vertical level
integer, intent(in) :: indx ! index into file
real*4:: amin, amax,spval
real*4:: writefldr4(nx,ny)
integer , parameter :: nop=123
integer :: ios
spval=2**100
writefldr4 = real(fld, 4)
! for debug
!print *, 'Dump: '//trim(memfile)//' '//trim(cfld), vlevel, tlevel,indx
! Write fld into index of .a file -- Direct access file
!call writeraw(writefldr4, &! feltet som skal skrivast
! amin,amax, &! min og max (returnerast fra writeraw)
! nx,ny, &! dimensjon
! .false.,spval, &! feltet vil ikkje faa "no-value" verdiar
! memfile//'.a', &! forelopig filnavn...
! indx) ! indexen i .a fila
call writeraw(writefldr4, &! feltet som skal skrivast
amin,amax, &! min og max (returnerast fra writeraw)
nx,ny, &! dimensjon
.true.,spval, &! feltet vil ikkje faa "no-value" verdiar
memfile//'.a', &! forelopig filnavn...
indx) ! indexen i .a fila
! Skriv header -- .b fil -- Hold tunga rett i munnen her og utanfor rutina,
! ellers blir det inkonsistens mellom .a og .b filer - dette vil fangast opp
! av postprosessering. Dette er tungvint men vanskelig aa omgaa fordi
! .b-fila er sekvensiell mens .a fila er direct access.
if (indx==1) then
! forste indeks - vi overskriv evt gamle filer
open(nop,file=memfile//'.b',status='replace')
else
! Ellers legg vi til
open(nop,file=memfile//'.b',status='old', position='append')
end if
! Skriv i vei !
write(nop,4100,iostat=ios) cfld,vlevel,tlevel,amin,amax
close(nop)
4100 format(a,': layer,tlevel,range = ',i3,i3,2x,1p2e16.7)
! format (a8,23x,i3,i3,2x,2e16.7)
end subroutine
end module m_put_mod_fld