-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhotstart.f90
166 lines (158 loc) · 5.52 KB
/
hotstart.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
!----------------------------------------------------------------------
SUBROUTINE HOT_START (LO,LA,START_TYPE,START_STEP)
! HOT START FUNCTION
! START_TYPE:
! = 0: SAVE RESUMING SNAPSHOTS
! = 1: LOAD RESUMING DATA FROM ONLY FIRST-LEVEL GRIDS (LAYER1)
! = 2: LOAD RESUMING DATA FROM ALL GRIDS
!----------------------------------------------------------------------
USE LAYER_PARAMS
TYPE (LAYER) :: LO
TYPE (LAYER), DIMENSION(NUM_GRID) :: LA
INTEGER :: START_TYPE,START_STEP,SWITCH
COMMON /CONS/ ELMAX,GRAV,PI,R_EARTH,GX,EPS,ZERO,ONE,NUM_GRID, &
NUM_FLT,V_LIMIT,RAD_DEG,RAD_MIN
CALL HOTSTART_DATA (LO,START_TYPE,START_STEP)
IF (START_TYPE .NE. 1) THEN
DO I = 1,NUM_GRID
IF (LA(I)%LAYSWITCH .EQ. 0) CALL HOTSTART_DATA (LA(I), &
START_TYPE,START_STEP)
ENDDO
ENDIF
RETURN
END
!----------------------------------------------------------------------
SUBROUTINE HOTSTART_DATA (LO,START_TYPE,START_STEP)
!----------------------------------------------------------------------
USE LAYER_PARAMS
TYPE (LAYER) :: LO
INTEGER :: START_TYPE,START_STEP,SWITCH
INTEGER IOSTAT
CHARACTER(LEN=20) FNAME1,FNAME2,FNAME3,FNAME4
CHARACTER(LEN=20) FNAME5,FNAME6
CHARACTER(LEN=20) FNAME10,FNAME11
LAYID = LO%ID
IF ( LAYID .EQ. 1) THEN
IS = 1
IE = LO%NX
JS = 1
JE = LO%NY
ELSE
IS = 2
JS = 2
IE = LO%NX
JE = LO%NY
ENDIF
WRITE (FNAME1,4) LAYID,START_STEP
4 FORMAT('z1_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME2,5) LAYID,START_STEP
5 FORMAT('Z2_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME3,6) LAYID,START_STEP
6 FORMAT('m1_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME4,7) LAYID,START_STEP
7 FORMAT('m2_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME5,8) LAYID,START_STEP
8 FORMAT('n1_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME6,9) LAYID,START_STEP
9 FORMAT('n2_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME10,10) LAYID,START_STEP
10 FORMAT('zmax1_',I2.2,'_',I6.6,'.dat')
WRITE (FNAME11,11) LAYID,START_STEP
11 FORMAT('zmin1_',I2.2,'_',I6.6,'.dat')
! ----- OUTPUT DATA FOR FUTURE HOT START -----------
!! OUTPUT WATER SURFACE DISPLACEMENT DATA Z
IF (START_TYPE .EQ. 0) THEN
OPEN (25,FILE=FNAME1,STATUS='UNKNOWN')
DO J = JS,JE
WRITE (25,'(10F12.5)') (LO%Z(I,J,1),I=IS,IE)
ENDDO
CLOSE (25)
!! OUTPUT FLUX DATA IN X DIRECTION
OPEN (25,FILE=FNAME3,STATUS='UNKNOWN')
DO J = JS,JE
WRITE (25,'(10F12.5)') (LO%M(I,J,1),I=IS,IE)
ENDDO
CLOSE (25)
!! OUTPUT FLUX DATA IN Y DIRECTION
OPEN (25,FILE=FNAME5,STATUS='UNKNOWN')
DO J = JS,JE
WRITE (25,'(10F12.5)') (LO%N(I,J,1),I=IS,IE)
ENDDO
CLOSE (25)
!! OUTPUT MAXIMUM SURFACE ELEVATION DATA
OPEN (25,FILE=FNAME10,STATUS='UNKNOWN')
DO J = JS,JE
WRITE (25,'(10F12.5)') (LO%Z_MAX(I,J),I=IS,IE)
ENDDO
CLOSE (25)
!! OUTPUT MAXIMUM SURFACE DEPRESSION DATA
OPEN (25,FILE=FNAME11,STATUS='UNKNOWN')
DO J = JS,JE
WRITE (25,'(10F12.5)') (LO%Z_MIN(I,J),I=IS,IE)
ENDDO
CLOSE (25)
ELSE
!------- LOAD DATA FOR HOT START ------------------------------------
!! LOAD WATER SURFACE DISPLACEMENT DATA FOR HOT START
OPEN (UNIT=25,FILE=FNAME1,STATUS='OLD',IOSTAT=ISTAT, &
FORM='FORMATTED')
IF (ISTAT /= 0) THEN
PRINT *,"WARNING:: HOTSTART CAN'T OPEN Z FILE; USE ZEROS INSTEAD."
LO%Z(:,:,1) = 0.0
ELSE
DO J = JS,JE
READ (25,'(10F12.5)') (LO%Z(I,J,1),I=IS,IE)
ENDDO
ENDIF
CLOSE (25)
!! LOAD VOLUME FLUX DATA IN X DIRECTION FOR HOT START
OPEN (UNIT=25,FILE=FNAME3,STATUS='OLD',IOSTAT=ISTAT, &
FORM='FORMATTED')
IF (ISTAT /= 0) THEN
PRINT *,"WARNING:: HOTSTART CAN'T OPEN P FILE; USE ZEROS INSTEAD."
LO%M(:,:,1) = 0.0
ELSE
DO J = JS,JE
READ (25,'(10F12.5)') (LO%M(I,J,1),I=IS,IE)
ENDDO
ENDIF
CLOSE (25)
!! LOAD VOLUME FLUX DATA IN Y DIRECTION FOR HOT START
OPEN (UNIT=25,FILE=FNAME5,STATUS='OLD',IOSTAT=ISTAT, &
FORM='FORMATTED')
IF (ISTAT /= 0) THEN
PRINT *,"WARNING:: HOTSTART CAN'T OPEN Q FILE; USE ZEROS INSTEAD."
LO%N(:,:,1) = 0.0
ELSE
DO J = JS,JE
READ (25,'(10F12.5)') (LO%N(I,J,1),I=IS,IE)
ENDDO
ENDIF
CLOSE (25)
!! LOAD MAXIMUM SURFACE ELEVATION DATA FOR HOT START
OPEN (UNIT=25,FILE=FNAME10,STATUS='OLD',IOSTAT=ISTAT, &
FORM='FORMATTED')
IF (ISTAT /= 0) THEN
PRINT *,"WARNING:: HOTSTART CAN'T OPEN ZMAX FILE; USE ZEROS INSTEAD."
LO%Z_MAX(:,:) = 0.0
ELSE
DO J = JS,JE
READ (25,'(10F12.5)') (LO%Z_MAX(I,J),I=IS,IE)
ENDDO
ENDIF
CLOSE (25)
!! LOAD MAXIMUM SURFACE DEPRESSION DATA FOR HOT START
OPEN (UNIT=25,FILE=FNAME11,STATUS='OLD',IOSTAT=ISTAT, &
FORM='FORMATTED')
IF (ISTAT /= 0) THEN
PRINT *,"WARNING:: HOTSTART CAN'T OPEN ZMIN FILE; USE ZEROS INSTEAD."
LO%Z_MIN(:,:) = 0.0
ELSE
DO J = JS,JE
READ (25,'(10F12.5)') (LO%Z_MIN(I,J),I=IS,IE)
ENDDO
ENDIF
CLOSE (25)
ENDIF
RETURN
END