-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw3nmlprncmd.ftn
640 lines (523 loc) · 17.9 KB
/
w3nmlprncmd.ftn
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
#include "w3macros.h"
!/ ------------------------------------------------------------------- /
MODULE W3NMLPRNCMD
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | M. Accensi |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 04-Jan-2018 |
!/ +-----------------------------------+
!/
!/ For updates see subroutines.
!/
! 1. Purpose :
!
! Manages namelists from configuration file ww3_prnc.nml for ww3_prnc program
!
!/ ------------------------------------------------------------------- /
! module defaults
IMPLICIT NONE
PUBLIC
! field structure
TYPE NML_FIELD_T
LOGICAL :: ICE_PARAM1
LOGICAL :: ICE_PARAM2
LOGICAL :: ICE_PARAM3
LOGICAL :: ICE_PARAM4
LOGICAL :: ICE_PARAM5
LOGICAL :: MUD_DENSITY
LOGICAL :: MUD_THICKNESS
LOGICAL :: MUD_VISCOSITY
LOGICAL :: WATER_LEVELS
LOGICAL :: CURRENTS
LOGICAL :: WINDS
LOGICAL :: WINDS_AST
LOGICAL :: ICE_CONC
LOGICAL :: ICE_BERG
LOGICAL :: DATA_ASSIM
END TYPE NML_FIELD_T
! grid structure
TYPE NML_GRID_T
LOGICAL :: ASIS
LOGICAL :: LATLON
END TYPE NML_GRID_T
! forcing structure
TYPE NML_FORCING_T
CHARACTER(15) :: TIMESTART
CHARACTER(15) :: TIMESTOP
TYPE(NML_FIELD_T) :: FIELD
TYPE(NML_GRID_T) :: GRID
CHARACTER(64) :: TIDAL
END TYPE NML_FORCING_T
! file structure
TYPE NML_FILE_T
CHARACTER(256) :: FILENAME
CHARACTER(100) :: LONGITUDE
CHARACTER(100) :: LATITUDE
CHARACTER(100) :: VAR(3)
CHARACTER(15) :: TIMESHIFT
END TYPE NML_FILE_T
! miscellaneous
CHARACTER(256) :: MSG
INTEGER :: NDSN
CONTAINS
!/ ------------------------------------------------------------------- /
SUBROUTINE W3NMLPRNC (NDSI, INFILE, NML_FORCING, NML_FILE, IERR)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | M. Accensi |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 04-Jan-2018 |
!/ +-----------------------------------+
!/
!
! 1. Purpose :
!
! Reads all the namelist to define the forcing field
!
! 2. Method :
!
! See source term routines.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDSI Int.
! INFILE Char.
! NML_FORCING type.
! NML_FILE type.
! IERR Int.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD SUBROUTINE tracing.
! READ_FORCING_NML
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! WW3_PRNC Prog. N/A Preprocess forcing fields.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3ODATMD, ONLY: NDSE
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
INTEGER, INTENT(IN) :: NDSI
CHARACTER*(*), INTENT(IN) :: INFILE
TYPE(NML_FORCING_T), INTENT(INOUT) :: NML_FORCING
TYPE(NML_FILE_T), INTENT(INOUT) :: NML_FILE
INTEGER, INTENT(OUT) :: IERR
!/S INTEGER, SAVE :: IENT = 0
IERR = 0
!/S CALL STRACE (IENT, 'W3NMLPRNC')
! open namelist log file
NDSN = 3
OPEN (NDSN, file=TRIM(INFILE)//'.log', form='formatted', iostat=IERR)
IF (IERR.NE.0) THEN
WRITE (NDSE,'(A)') 'ERROR: open full nml file '//TRIM(INFILE)//'.log failed'
RETURN
END IF
! open input file
OPEN (NDSI, file=TRIM(INFILE), form='formatted', status='old', iostat=IERR)
IF (IERR.NE.0) THEN
WRITE (NDSE,'(A)') 'ERROR: open input file '//TRIM(INFILE)//' failed'
RETURN
END IF
! read forcing namelist
CALL READ_FORCING_NML (NDSI, NML_FORCING)
CALL REPORT_FORCING_NML (NML_FORCING)
! read file namelist
CALL READ_FILE_NML (NDSI, NML_FILE)
CALL REPORT_FILE_NML (NML_FILE)
! close namelist files
CLOSE (NDSI)
CLOSE (NDSN)
END SUBROUTINE W3NMLPRNC
!/ ------------------------------------------------------------------- /
!/ ------------------------------------------------------------------- /
SUBROUTINE READ_FORCING_NML (NDSI, NML_FORCING)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | M. Accensi |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 04-Jan-2018 |
!/ +-----------------------------------+
!/
! 1. Purpose :
!
!
! 2. Method :
!
! See source term routines.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDSI Int.
! NML_FORCING Type.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD SUBROUTINE tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! W3NMLPRNC Subr. N/A Namelist configuration routine.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3ODATMD, ONLY: NDSE
USE W3SERVMD, ONLY: EXTCDE
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
INTEGER, INTENT(IN) :: NDSI
TYPE(NML_FORCING_T), INTENT(INOUT) :: NML_FORCING
! locals
INTEGER :: IERR
TYPE(NML_FORCING_T) :: FORCING
NAMELIST /FORCING_NML/ FORCING
!/S INTEGER, SAVE :: IENT = 0
IERR = 0
!/S CALL STRACE (IENT, 'READ_FORCING_NML')
! set default values for forcing structure
FORCING%TIMESTART = '19000101 000000'
FORCING%TIMESTOP = '29001231 000000'
!
FORCING%FIELD%ICE_PARAM1 = .FALSE.
FORCING%FIELD%ICE_PARAM2 = .FALSE.
FORCING%FIELD%ICE_PARAM3 = .FALSE.
FORCING%FIELD%ICE_PARAM4 = .FALSE.
FORCING%FIELD%ICE_PARAM5 = .FALSE.
FORCING%FIELD%MUD_DENSITY = .FALSE.
FORCING%FIELD%MUD_THICKNESS = .FALSE.
FORCING%FIELD%MUD_VISCOSITY = .FALSE.
FORCING%FIELD%WATER_LEVELS = .FALSE.
FORCING%FIELD%CURRENTS = .FALSE.
FORCING%FIELD%WINDS = .FALSE.
FORCING%FIELD%WINDS_AST = .FALSE.
FORCING%FIELD%ICE_CONC = .FALSE.
FORCING%FIELD%ICE_BERG = .FALSE.
FORCING%FIELD%DATA_ASSIM = .FALSE.
!
FORCING%GRID%LATLON = .FALSE.
FORCING%GRID%ASIS = .FALSE.
!
FORCING%TIDAL = 'unset'
! read forcing namelist
REWIND (NDSI)
READ (NDSI, nml=FORCING_NML, iostat=IERR, iomsg=MSG)
IF (IERR.NE.0) THEN
WRITE (NDSE,'(A,/A)') &
'ERROR: READ_FORCING_NML: namelist read error', &
'ERROR: '//TRIM(MSG)
CALL EXTCDE (1)
END IF
! set/check RETURN values
IF (FORCING%TIDAL.NE.'unset') THEN
IF (.NOT. FORCING%FIELD%WATER_LEVELS .AND. .NOT. FORCING%FIELD%CURRENTS) THEN
WRITE (NDSE,'(A,I3)') 'ERROR: TIDAL must only be used on FIELD%WATER_LEVELS or FIELD%CURRENTS'
CALL EXTCDE (2)
ELSE IF (.NOT. FORCING%GRID%ASIS) THEN
WRITE (NDSE,'(A,I3)') 'ERROR: TIDAL must only be used on GRID%ASIS'
CALL EXTCDE (3)
END IF
END IF
! save namelist
NML_FORCING = FORCING
END SUBROUTINE READ_FORCING_NML
!/ ------------------------------------------------------------------- /
!/ ------------------------------------------------------------------- /
SUBROUTINE READ_FILE_NML (NDSI, NML_FILE)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | M. Accensi |
!/ | |
!/ | FORTRAN 90 |
!/ | Last update : 04-Jan-2018 |
!/ +-----------------------------------+
!/
! 1. Purpose :
!
!
! 2. Method :
!
! See source term routines.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDSI Int.
! NML_FILE Type.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD SUBROUTINE tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! W3NMLPRNC Subr. N/A Namelist configuration routine.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE W3ODATMD, ONLY: NDSE
USE W3SERVMD, ONLY: EXTCDE
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
INTEGER, INTENT(IN) :: NDSI
TYPE(NML_FILE_T), INTENT(INOUT) :: NML_FILE
! locals
INTEGER :: IERR
TYPE(NML_FILE_T) :: FILE
NAMELIST /FILE_NML/ FILE
!/S INTEGER, SAVE :: IENT = 0
IERR = 0
!/S CALL STRACE (IENT, 'READ_FILE_NML')
! set default values for file structure
FILE%FILENAME = 'unset'
FILE%LONGITUDE = 'unset'
FILE%LATITUDE = 'unset'
FILE%VAR(1) = 'unset'
FILE%VAR(2) = 'unset'
FILE%VAR(3) = 'unset'
FILE%TIMESHIFT = '00000000 000000'
! read file namelist
REWIND (NDSI)
READ (NDSI, nml=FILE_NML, iostat=IERR, iomsg=MSG)
IF (IERR.NE.0) THEN
WRITE (NDSE,'(A,/A)') &
'ERROR: READ_FILE_NML: namelist read error', &
'ERROR: '//TRIM(MSG)
CALL EXTCDE (4)
END IF
! save namelist
NML_FILE = FILE
END SUBROUTINE READ_FILE_NML
!/ ------------------------------------------------------------------- /
!/ ------------------------------------------------------------------- /
SUBROUTINE REPORT_FORCING_NML (NML_FORCING)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | M. Accensi |
!/ | FORTRAN 90 |
!/ | Last update : 04-Jan-2018 |
!/ +-----------------------------------+
!/
!/
! 1. Purpose :
!
!
! 2. Method :
!
! See source term routines.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NML_FORCING Type.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD SUBROUTINE tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! W3NMLPRNC Subr. N/A Namelist configuration routine.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
TYPE(NML_FORCING_T), INTENT(IN) :: NML_FORCING
!/S INTEGER, SAVE :: IENT = 0
!/S CALL STRACE (IENT, 'REPORT_FORCING_NML')
WRITE (MSG,'(A)') 'FORCING % '
WRITE (NDSN,'(A)')
WRITE (NDSN,10) TRIM(MSG),'TIMESTART = ', TRIM(NML_FORCING%TIMESTART)
WRITE (NDSN,10) TRIM(MSG),'TIMESTOP = ', TRIM(NML_FORCING%TIMESTOP)
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_PARAM1 = ', NML_FORCING%FIELD%ICE_PARAM1
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_PARAM2 = ', NML_FORCING%FIELD%ICE_PARAM2
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_PARAM3 = ', NML_FORCING%FIELD%ICE_PARAM3
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_PARAM4 = ', NML_FORCING%FIELD%ICE_PARAM4
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_PARAM5 = ', NML_FORCING%FIELD%ICE_PARAM5
WRITE (NDSN,13) TRIM(MSG),'FIELD % MUD_DENSITY = ', NML_FORCING%FIELD%MUD_DENSITY
WRITE (NDSN,13) TRIM(MSG),'FIELD % MUD_THICKNESS = ', NML_FORCING%FIELD%MUD_THICKNESS
WRITE (NDSN,13) TRIM(MSG),'FIELD % MUD_VISCOSITY = ', NML_FORCING%FIELD%MUD_VISCOSITY
WRITE (NDSN,13) TRIM(MSG),'FIELD % WATER_LEVELS = ', NML_FORCING%FIELD%WATER_LEVELS
WRITE (NDSN,13) TRIM(MSG),'FIELD % CURRENTS = ', NML_FORCING%FIELD%CURRENTS
WRITE (NDSN,13) TRIM(MSG),'FIELD % WINDS = ', NML_FORCING%FIELD%WINDS
WRITE (NDSN,13) TRIM(MSG),'FIELD % WINDS_AST = ', NML_FORCING%FIELD%WINDS_AST
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_CONC = ', NML_FORCING%FIELD%ICE_CONC
WRITE (NDSN,13) TRIM(MSG),'FIELD % ICE_BERG = ', NML_FORCING%FIELD%ICE_BERG
WRITE (NDSN,13) TRIM(MSG),'FIELD % DATA_ASSIM = ', NML_FORCING%FIELD%DATA_ASSIM
WRITE (NDSN,13) TRIM(MSG),'GRID % ASIS = ', NML_FORCING%GRID%ASIS
WRITE (NDSN,13) TRIM(MSG),'GRID % LATLON = ', NML_FORCING%GRID%LATLON
WRITE (NDSN,10) TRIM(MSG),'TIDAL = ', NML_FORCING%TIDAL
10 FORMAT (A,2X,A,A)
13 FORMAT (A,2X,A,L1)
END SUBROUTINE REPORT_FORCING_NML
!/ ------------------------------------------------------------------- /
!/ ------------------------------------------------------------------- /
SUBROUTINE REPORT_FILE_NML (NML_FILE)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | M. Accensi |
!/ | FORTRAN 90 |
!/ | Last update : 04-Jan-2018 |
!/ +-----------------------------------+
!/
!/
! 1. Purpose :
!
!
! 2. Method :
!
! See source term routines.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NML_FILE Type.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! STRACE Subr. W3SERVMD SUBROUTINE tracing.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name TYPE Module Description
! ----------------------------------------------------------------
! W3NMLPRNC Subr. N/A Namelist configuration routine.
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! See source code.
!
! 9. Switches :
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/S USE W3SERVMD, ONLY: STRACE
IMPLICIT NONE
TYPE(NML_FILE_T), INTENT(IN) :: NML_FILE
!/S INTEGER, SAVE :: IENT = 0
!/S CALL STRACE (IENT, 'REPORT_FILE_NML')
WRITE (MSG,'(A)') 'FILE % '
WRITE (NDSN,'(A)')
WRITE (NDSN,10) TRIM(MSG),'FILENAME = ', TRIM(NML_FILE%FILENAME)
WRITE (NDSN,10) TRIM(MSG),'LONGITUDE = ', TRIM(NML_FILE%LONGITUDE)
WRITE (NDSN,10) TRIM(MSG),'LATITUDE = ', TRIM(NML_FILE%LATITUDE)
WRITE (NDSN,10) TRIM(MSG),'VAR(1) = ', TRIM(NML_FILE%VAR(1))
WRITE (NDSN,10) TRIM(MSG),'VAR(2) = ', TRIM(NML_FILE%VAR(2))
WRITE (NDSN,10) TRIM(MSG),'VAR(3) = ', TRIM(NML_FILE%VAR(3))
WRITE (NDSN,10) TRIM(MSG),'TIMESHIFT = ', TRIM(NML_FILE%TIMESHIFT)
10 FORMAT (A,2X,A,A)
END SUBROUTINE REPORT_FILE_NML
!/ ------------------------------------------------------------------- /
END MODULE W3NMLPRNCMD
!/ ------------------------------------------------------------------- /