1 | PROGRAM make_dmp_file |
---|
2 | !================================================================================ |
---|
3 | ! *** PROGRAM make_dmp_file **** |
---|
4 | !================================================================================ |
---|
5 | ! |
---|
6 | ! Purpose: Create a file containing a spacially varying |
---|
7 | ! restoration coefficient to be used by TRADMP |
---|
8 | ! |
---|
9 | ! Method: 1) Read in tmask from mesh_mask file to use as a template |
---|
10 | ! 2) Calculate restoration coefficients (user should modify to their |
---|
11 | ! own specifications e.g. to mask certain regions only). |
---|
12 | ! Avoid 3D arrays! |
---|
13 | ! 3) Write the array to output file |
---|
14 | ! |
---|
15 | ! History: Original code: Tim Graham (Jul 2014) - some code moved from |
---|
16 | ! old tradmp.F90 module to this tool (as part of NEMO |
---|
17 | ! simplification process). |
---|
18 | !------------------------------------------------------------------------------- |
---|
19 | |
---|
20 | ! Declare variables |
---|
21 | USE netcdf |
---|
22 | USE utils |
---|
23 | USE coastdist |
---|
24 | USE med_red_seas |
---|
25 | USE zoom |
---|
26 | |
---|
27 | IMPLICIT NONE |
---|
28 | INTEGER :: ji, jj, jk ! dummpy loop variables |
---|
29 | REAL(8) :: zsdmp, zbdmp ! Surface and bottom damping coeff |
---|
30 | CHARACTER(LEN=200) :: meshfile = 'mesh_mask.nc' ! mesh file |
---|
31 | CHARACTER(LEN=200) :: outfile = 'dmp_mask.nc' ! output file |
---|
32 | REAL(8) :: zlat, zlat2, zlat0 |
---|
33 | |
---|
34 | ! Read namelist |
---|
35 | OPEN( UNIT=numnam, FILE='namelist', FORM='FORMATTED', STATUS='OLD' ) |
---|
36 | READ( numnam, nam_dmp_create ) |
---|
37 | CLOSE( numnam ) |
---|
38 | |
---|
39 | IF ( ln_full_field .AND. lzoom ) THEN |
---|
40 | WRITE(numerr,*) 'Only one of ln_full_field and lzoom can be .true.' |
---|
41 | STOP |
---|
42 | ENDIF |
---|
43 | |
---|
44 | CALL grid_info(meshfile) |
---|
45 | WRITE(numout, *) 'jpi = ',jpi |
---|
46 | WRITE(numout, *) 'jpj = ',jpj |
---|
47 | WRITE(numout, *) 'jpk = ',jpk |
---|
48 | |
---|
49 | ALLOCATE( resto(jpi, jpj) ) |
---|
50 | |
---|
51 | !Create output file |
---|
52 | CALL make_outfile( outfile ) |
---|
53 | |
---|
54 | CALL check_nf90( nf90_get_var( ncin, gphit_id, gphit, (/ 1,1 /), (/ jpi, jpj /) ) ) |
---|
55 | |
---|
56 | !Calculate surface and bottom damping coefficients |
---|
57 | zsdmp = 1. / ( pn_surf * rday ) |
---|
58 | zbdmp = 1. / ( pn_bot * rday ) |
---|
59 | |
---|
60 | !Loop through levels and read in tmask for each level as starting point for |
---|
61 | !coefficient array |
---|
62 | DO jk = 1, jpk-1 |
---|
63 | resto(:,:) = 0. |
---|
64 | |
---|
65 | IF (.NOT. (jk == 1 .AND. ln_zero_top_layer) ) THEN |
---|
66 | !Read in tmask depth for this level |
---|
67 | CALL check_nf90( nf90_get_var( ncin, tmask_id, tmask, (/ 1,1,jk /), (/ jpi, jpj,1 /) ) ) |
---|
68 | CALL check_nf90( nf90_get_var( ncin, gdept_id, gdept, (/ 1,1,jk /), (/ jpi, jpj,1 /) ) ) |
---|
69 | |
---|
70 | |
---|
71 | IF ( ln_full_field ) THEN |
---|
72 | !Set basic value of resto |
---|
73 | DO jj = 1, jpj |
---|
74 | DO ji = 1, jpi |
---|
75 | resto(ji,jj) = tmask(ji, jj) * (zbdmp + (zsdmp-zbdmp) * EXP(-gdept(ji,jj)/pn_dep)) |
---|
76 | END DO |
---|
77 | END DO |
---|
78 | IF ((nn_hdmp > 0)) THEN |
---|
79 | zlat0 = 10. !width of latitude strip where resto decreases |
---|
80 | zlat2 = nn_hdmp + zlat0 |
---|
81 | DO jj = 1, jpj |
---|
82 | DO ji = 1, jpi |
---|
83 | zlat = ABS(gphit(ji,jj)) |
---|
84 | IF ( nn_hdmp <= zlat .AND. zlat <= zlat2 ) THEN |
---|
85 | resto(ji,jj) = resto(ji,jj) * 0.5 * ( 1. - COS( rpi*(zlat-nn_hdmp)/zlat0 ) ) |
---|
86 | ELSE IF ( zlat < nn_hdmp ) THEN |
---|
87 | resto(ji,jj) = 0. |
---|
88 | ENDIF |
---|
89 | END DO |
---|
90 | END DO |
---|
91 | ENDIF |
---|
92 | |
---|
93 | IF (ln_coast) THEN |
---|
94 | ! Reduce damping in vicinity of coastlines |
---|
95 | CALL coast_dist_weight(resto) |
---|
96 | ENDIF |
---|
97 | ENDIF |
---|
98 | |
---|
99 | ! Damping in Med/Red Seas (or local modifications if full field is set) |
---|
100 | IF (ln_med_red_seas .AND. (cp_cfg == 'orca')) THEN |
---|
101 | CALL med_red_dmp(resto) |
---|
102 | ENDIF |
---|
103 | |
---|
104 | IF ( lzoom ) THEN |
---|
105 | CALL dtacof_zoom(resto, tmask) |
---|
106 | ENDIF |
---|
107 | |
---|
108 | ENDIF |
---|
109 | |
---|
110 | ! Write out resto for this level |
---|
111 | CALL check_nf90( nf90_put_var( ncout, resto_id, resto, (/ 1,1,jk /), (/ jpi, jpj,1 /) ) ) |
---|
112 | |
---|
113 | END DO |
---|
114 | |
---|
115 | ! Close the output file |
---|
116 | CALL check_nf90( nf90_close(ncout) ) |
---|
117 | |
---|
118 | END PROGRAM make_dmp_file |
---|