My Project
fvcom.f90
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 !/===========================================================================/
13 ! Copyright (c) 2007, The University of Massachusetts Dartmouth
14 ! Produced at the School of Marine Science & Technology
15 ! Marine Ecosystem Dynamics Modeling group
16 ! All rights reserved.
17 !
18 ! FVCOM has been developed by the joint UMASSD-WHOI research team. For
19 ! details of authorship and attribution of credit please see the FVCOM
20 ! technical manual or contact the MEDM group.
21 !
22 !
23 ! This file is part of FVCOM. For details, see http://fvcom.smast.umassd.edu
24 ! The full copyright notice is contained in the file COPYRIGHT located in the
25 ! root directory of the FVCOM code. This original header must be maintained
26 ! in all distributed versions.
27 !
28 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30 ! THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 ! PURPOSE ARE DISCLAIMED.
32 !
33 !/---------------------------------------------------------------------------/
34 ! CVS VERSION INFORMATION
35 ! $Id$
36 ! $Name$
37 ! $Revision$
38 !/===========================================================================/
39 
40 !==============================================================================!
41 ! VERSION 4.1
42 !==============================================================================!
43 
44 PROGRAM fvcom
45 
46 ! CODING STATUS: Beta release
47 ! Remaining Work:
48 ! Add variable, 1/ART, 1/ART2... etc
49 ! Fix bottom boundary condition for scalars
50 ! Add sediment
51 ! Add assimilation modes
52 ! Test GOTM Interface
53 !
54 
55  !================================================================================!
56  ! !
57  ! USG-FVCOM !
58  ! The Unstructured Grid Finite Volume Coastal Ocean Model !
59  ! !
60  ! The USG-FVCOM (publicly called FVCOM) was developed by Drs. Changsheng Chen !
61  ! and Hedong Liu at the Marine Ecosystem Dynamics Modeling Laboratory at the !
62  ! School of Marine Science and Technology (SMAST), University of Massachusetts- !
63  ! Dartmouth (UMASSD) and Dr. Robert C. Beardsley at the Department of Physical !
64  ! Oceanography, Woods Hole Oceanographic Institution (WHOI). This code was !
65  ! rewritten in FORTRAN 90/2K, modularized, rendered somewhat understandable, !
66  ! and parallelized by Geoff Cowles at SMAST/UMASSD. FVCOM is being upgraded by !
67  ! the UMASSD-WHOI joint team led by Dr. Chen and Dr. Beardsley. !
68  ! !
69  ! The Development was initially supported by the Georgia Sea Grant College !
70  ! Program for the study of the complex dynamic system in Georgia estuaries. The !
71  ! code improvement has been supported by Dr. Chen's research grants received !
72  ! from NSF and NOAA Coastal Ocean research grants and SMAST fishery research !
73  ! grants. !
74  ! !
75  ! FVCOM is a prognostic, unstructured grid, Finite-Volume free-surface three- !
76  ! dimensional hydrostatic/non-hydrostatic primitive equations, Coastal Ocean !
77  ! circulation Model (Chen et al., 2003; 2006, 2007). The model computes the !
78  ! momentum, continuity, temperature salinity, and density equations and is !
79  ! closed physically and mathematically using user-specified turbulent parameters!
80  ! or turbulent closure submodel. The irregular bottom slope is represented using!
81  ! a generalized terrain-following coordinate transformation with spatially !
82  ! variable vertical distribution (Pietrzak et al., 2002). The horizontal grids !
83  ! comprise unstructured triangular cells. The spatial fluxes of momentum are !
84  ! discretized using a second-order accurate finite-volume method (Kobayashi et !
85  ! al. 1999) in conjunction with a vertical velocity adjustment enforce exact !
86  ! volume conservation in individual control volumes. The flux of scalars (e. g. !
87  ! temperature, salinity) is calculated by the second-order accurate upwind !
88  ! scheme. The finite-volume method (FVM) used in this model combines the !
89  ! advantages of the finite-element method (FEM) for geometric flexibility and !
90  ! the finite-difference method (FDM) for simple discrete computation. Current, !
91  ! temperature, and salinity in the model are computed in the integral form of !
92  ! the equations, which provides a better representation of the conservation laws!
93  ! for mass, momentum, and heat in the coastal region with complex geometry. !
94  ! !
95  ! FVCOM was originally developed for the coastal and estuarine applications. !
96  ! With implementation of spherical coordinates, this model is capable of using !
97  ! for the global ocean. !
98  ! !
99  ! All users should read this agreement carefully. A user, who receives any !
100  ! version of the source code of FVCOM, must accept all the terms and conditions !
101  ! of this agreement and also agree that this agreement is like any written !
102  ! negotiated agreement signed by you. You may be required to have another !
103  ! written agreement directly with Dr. Changsheng Chen at SMAST/UMASSD that !
104  ! supplements all or portions of this agreement. Dr. Changsheng Chen, leader of !
105  ! the FVCOM development team, owns all intellectual property rights to the !
106  ! software. The University of Massachusetts-Dartmouth owns the copyright of the !
107  ! software. All copyrights are reserved. Unauthorized reproduction and re- !
108  ! distribution of this program are expressly prohibited. This program is only !
109  ! permitted for use in non-commercial academic research and education. !
110  ! Commercial use must be approved by Dr. Chen. Registration is required for all !
111  ! new users. Users should realize that this model software is a research product!
112  ! without any warranty. Users must take full responsibility for any mistakes !
113  ! that might be caused by any inappropriate modification of the source code. !
114  ! Modification is not encouraged for users who do not have a deep understanding !
115  ! of the finite-volume numerical methods used in FVCOM. Contributions made to !
116  ! correcting and modifying the programs will be credited, but will not affect !
117  ! copyrights. No duplicate configurations of FVCOM are allowed in the same !
118  ! geographical region, particularly in the regions where FVCOM has been already !
119  ! been applied. Users who want to use FVCOM in a region that the SMAST/UMASS !
120  ! Marine Ecosystem Dynamics Modeling (MEDM) group (led by Dr. Chen) is working !
121  ! on must request permission from Dr. Chen. No competition is allowed in the !
122  ! same region using FVCOM, especially with Dr. Chen's group. FVCOM has been !
123  ! validated for many standard model test cases. Users are welcome to do any !
124  ! further model validation experiments. These experiments shall be carried out !
125  ! in collaboration with the SMAST/UMASSD model development team. To avoid or !
126  ! reduce deriving any incorrect conclusions due to an inappropriate use of !
127  ! FVCOM, users are required to contact the scientific leaders of the FVCOM !
128  ! development team (Dr. Chen at SMAST/UMASSD and Dr. Beardsley at WHOI) before !
129  ! any formal publications are prepared for model validation. !
130  ! !
131  ! For public use, all users should name this model as "FVCOM". In any !
132  ! publications with the use of FVCOM, acknowledgement must be included. The !
133  ! rationale behind this FVCOM distribution policy is straightforward. New !
134  ! researchers and educators who want to use FVCOM and agree to the above !
135  ! requirements get free access to the latest version of FVCOM and the collective!
136  ! wisdom and experience of the FVCOM development team and existing users. !
137  ! Problems arising in new FVCOM applications, both related to conceptual as well!
138  ! as numerical and coding issues, can be shared with the development team and !
139  ! other users who can work together on physics and code improvements that over !
140  ! time will lead to a better FVCOM. !
141  ! !
142  ! FVCOM has been developed to date with state and federal funding with the !
143  ! idea that FVCOM will become a community model that new users start to use the !
144  ! model and its scientific usefulness and numerical accuracy and efficiency !
145  ! continue to improve. The FVCOM distribution policy is designed to encourage !
146  ! this transition while maintaining a central core group responsible for overall!
147  ! FVCOM development direction, implementing official code improvements, and !
148  ! maintaining well tested and documented updated code versions. !
149  ! !
150  ! !
151  ! External forces used to drive this model: !
152  ! !
153  ! 1) Tidal amplitudes and phases at open boundaries (initial designs include 8 !
154  ! tidal constituents, more can be added as needed) plus astronomical !
155  ! forcing implemented via gradients of tidal-generating potential for !
156  ! each tidal constituent and various corrections due to the Earth tidal !
157  ! and ocean loading. !
158  ! 2) Wind stress [3 ways: a) uniform wind speed and direction, b) spatially !
159  ! distributed wind velocity field, and c) the weather model output wind !
160  ! fields (NCEP, MM5, WRF, ECMWF). !
161  ! 3) Air pressure gradients [2 ways: weather model output and Hurricane or !
162  ! typhoon model predicted. !
163  ! 4) Surface heat flux [3 ways: a) uniform heat flux, b) spatially distributed !
164  ! heat flux, and c) the weather model-output heat flux fields. All the !
165  ! surface net heat flux and short-wave radiation are needed in the input !
166  ! file. !
167  ! 5) Precipitation via evaporation. !
168  ! 6) River discharges: specify the location and discharge volume, temperature, !
169  ! and salinity. !
170  ! 7) Groundwater input: currently diffused bottom flux only. !
171  ! !
172  ! Note: FVCOM can be run directly by coupling with the weather model (WRF or !
173  ! MM5). This is used in the US Northeast Coastal Ocean Forecast System !
174  ! (NECOFS) (http://fvcom.smast.umassd.edu). Modes use for air-sea coupling!
175  ! is not included in this release. !
176  ! !
177  ! Hydrodynamics initial conditions: !
178  ! !
179  ! The model can be prognostically run for both barotropic and baroclinic cases. !
180  ! !
181  ! Tidal forcing can be added into the system with zero velocity field at initial!
182  ! or specified the 3-D tidal initial velocity field using the model-predicted !
183  ! harmonic tidal currents. !
184  ! !
185  ! Initial fields of temperature and salinity needed to be specified by using !
186  ! either limatological field, real-time observed field or idealized functions. !
187  ! The model has included Gregorian time for the time simulation for tidal !
188  ! currents. !
189  ! !
190  ! For the purpose of interdisciplinary studies, biological, chemical, and !
191  ! sediment suspension models are available for FVCOM. These submodels are !
192  ! directly driven by the FVCOM physical model. These submodels are called !
193  ! offline FVCOM modes. A description of these submodels follows. !
194  ! !
195  ! Generalized Biological Model (GBM)-a software platform that allows users to !
196  ! build his own biological model in FVCOM (developed by a team including !
197  ! Drs. Chen, Tian and Qi) !
198  ! !
199  ! NPZ model-built using GBM for 3 component nutrient-phytoplankton-zooplankton. !
200  ! !
201  ! NPZD model-an 4 and 8 component nutrient-phytoplankton-zooplankton-detritus !
202  ! model constructed by GBM !
203  ! !
204  ! NPZDB-model-a 9 phosphorus-controlled component nutrient-phytoplankton- !
205  ! zooplankton-detritus-bacteria model constructed by GBM !
206  ! !
207  ! FVCOM-WQM: The water quality model modified from US-EPA WASP with inclusion of!
208  ! the benthic process. This code was converted from the structured grid !
209  ! WQM (developed by Zheng and Chen) to the unstructured grid version. !
210  ! !
211  ! UG-RCA: The unstructured grid Row/column version of the water quality model !
212  ! ESOP (RCA). UG-RCA developed by the FVCOM development team (Drs. Chen, !
213  ! J. Qi and R. Tian) on converting HydroQual's structured grid RCA to !
214  ! unstructured grid finite-volume version. !
215  ! !
216  ! UG-CE-QUAL-ICM: A unstructured grid version of the army corp water quality !
217  ! model. The code was written by Drs. Qi and Chen at UMASSD and modified !
218  ! and tested by Drs. Kim, Labiosa, Khanhaonkar and Yang at PNL. !
219  ! !
220  ! FVCOM-SED: The 3-D sediment module (developed by Cowles based on the U.S.G.S. !
221  ! national community sediment transport model and modified by the FVCOM !
222  ! development team staff-Ge, Wu, Chen and FVCOM users to include cohesive !
223  ! process). This code can run online coupled with FVCOM or offline driven !
224  ! by the FVCOM output !
225  ! !
226  ! FVCOM-SWAVE: The unstructured-grid (UG) version of the Simulating Wave !
227  ! Nearshore (SWAN) surface wave model. The code was developed by Drs. Qi !
228  ! and Chen at SMAST/UMASSD (Qi et al. 2008) !
229  ! !
230  ! Lagrangian particle tracking: !
231  ! !
232  ! FVCOM-LAG: A bilinear interpolation scheme is used to determine the particle !
233  ! velocity for the Lagrangian particle tracking. A random walk process !
234  ! also could be included with a specified function related to horizontal !
235  ! and vertical diffusion coefficients !
236  ! !
237  ! Key references: !
238  ! !
239  ! Chen, C., H. Liu, and R. C. Beardsley, 2003. An unstructured grid, finite- !
240  ! volume, three-dimensional, primitive equations ocean model: application to!
241  ! coastal ocean and estuaries, Journal of Atmospheric and Oceanic !
242  ! Technology, 20, 159-186. !
243  ! !
244  ! Chen, C, R. C. Beardsley and G. Cowles, 2006. An unstructured grid, finite- !
245  ! volume coastal ocean model (FVCOM) system. Special Issue entitled Advance !
246  ! in Computational Oceanography, Oceanography, 19(1), 78-89. !
247  ! !
248  ! Chen, C. H. Huang, R. C. Beardsley, H. Liu, Q. Xu and G. Cowles, 2007. A !
249  ! finite-volume numerical approach for coastal ocean circulation studies: !
250  ! comparisons with finite difference models. J. Geophys. Res. 112, C03018, !
251  ! doi:10.1029/2006JC003485. !
252  ! !
253  ! Chen, C., P. Malanotte-Rizzoli, J. Wei, R. C. Beardsley, Z. Lai, P. Xue, S. !
254  ! Lyu, Q. Xu, J. Qi, and G. W. Cowles, 2009. Application and comparison of !
255  ! Kalman filters for coastal ocean problems: An experiment with FVCOM, J. !
256  ! Geophys. Res., 114, C05011, doi:10.1029/2007JC004548. !
257  ! !
258  ! Cowles, G., 2008. Parallelization of the FVCOM Coastal Ocean Model, !
259  ! International Journal of High Performance Computing Applications, 22(2), !
260  ! 177-193. !
261  ! !
262  ! Huang, H. C. Chen, G. Cowles, C. D. Winant, R. C. Beardsley, K. Hedstrom, D. !
263  ! B. Haidvogel, 2008. FVCOM validation experiments: comparisons with ROMS !
264  ! for three idealized test problems. J. Geophys. Res, 113, C07042, doi: !
265  ! 10.1029/2007JC004557. !
266  ! !
267  ! Lai, Z, C. Chen, G. Cowles and R. C. Beardsley, 2009. A non-hydrostatic !
268  ! version of FVCOM, part I: validation experiments. J. Geophys. Res., !
269  ! in revision. !
270  ! !
271  ! Lai, Z., C. Chen, G. Cowles and R. C. Beardsley, 2009. A non-hydrostatic !
272  ! version of FVCOM, part II: mechanistic study of tidally generated !
273  ! nonlinear internal waves in Massachusetts Bay. J. Geophys. Res., !
274  ! submitted. !
275  ! !
276  ! Qi, J. C. Chen, R. C. Beardsley, W. Perrie G. Cowles and Z. Lai, 2009. An !
277  ! unstructured-grid finite-volume surface wave model (FVCOM-SWAVE): !
278  ! implementation, validations and applications. Ocean Modelling, 28, !
279  ! 153-166. doi:10.1016/j.ocemod.2009.01.007. !
280  ! !
281  ! Please direct criticisms and suggestions to !
282  ! !
283  ! Changsheng Chen !
284  ! School for Marine Science and Technology !
285  ! University of Massachusetts-Dartmouth !
286  ! New Bedford, MA 02742 !
287  ! Phone: 508-910-6388, Fax: 508-910-6371 !
288  ! E-mail: c1chen@umassd.edu, cchen@whoi.edu !
289  ! Web: http://fvcom.smast.umassd.edu !
290  ! !
291  ! What are new for version 3.1? !
292  ! !
293  ! 1) Fully sea-ice coupling. The sea ice model was developed by converting the !
294  ! structured grid CICE into the unstructured grid version called UG-CICE). !
295  ! This is one component of G. Gao's Ph.D. thesis work supervised by C. Chen, !
296  ! R. C. Beardsley and A. Proshutinsky. The code was written by G. Gao with !
297  ! assistance of J. Qi and C. Chen and tested by G. Gao and C. Chen. !
298  ! !
299  ! 2) Non-hydrostatic version. The non-hydrostatic dynamics is added into FVCOM !
300  ! as one component of Z. Lai's Ph.D. thesis work supervised by C. Chen, G. !
301  ! Cowles and R. C. Beardsley. The code was written by Z. Lai with assistance!
302  ! of C. Chen and G. Cowles, and tested by Z. Lai and C. Chen. !
303  ! !
304  ! 3) Fully current-wave interaction. An unstructured grid surface wave model !
305  ! (called FVCOM-SWAVE) was developed by Qi et al. (2008). This wave model !
306  ! is modified from SWAN by converting it to unstructured grid version using !
307  ! the second-order accurate FVCOM algorithms. The implementing FVCOM-SWAVE !
308  ! into FVCOM was initialized by A. Wu at SMAST/UMASSD as one component of his!
309  ! Ph.D. thesis work. The work is supervised by C. Chen at SMAST/UMASSD. The !
310  ! code is re-organized, modified and re-debugged to fit more flexible and !
311  ! general setup of FVCOM by J. Qi and C. Chen. !
312  ! !
313  ! 4) Fully current-wave-sediment interaction. Coupling of wave-sediment was !
314  ! initialized by A. Wu and J. Ge at SMAST/UMASSD as a visiting student !
315  ! project. The code was re-organized, modified and re-debugged by J. Qi and !
316  ! C. Chen when it is implemented into version 3.1. !
317  ! !
318  ! 5) NetCDF Input and output. Version 3.1 uses the NetCDF input and output !
319  ! implemented into FVCOM by David Stuebe at SMAST/UMASSD. The code is also !
320  ! modified to improve the efficiency of inter-node data exchange and model !
321  ! output writing. !
322  ! !
323  ! 6) Semi-implicit solver. In addition to the mode-split version, a semi- !
324  ! implicit solver was implemented into FVCOM by Z. Lai and C. Chen. Using !
325  ! this option requires the installation of PETCs. With this implementation, !
326  ! FVCOM can be run by choosing either mode-split scheme or semi-implicit !
327  ! scheme. The semi-implicit version of FVCOM can significantly increase the !
328  ! computational efficiency for regional and global scale application. !
329  ! !
330  ! 7) Nesting software module. This module is built in FVCOM to allow multi-sub-!
331  ! regional FVCOM domains to be run simultaneously through nesting approach. !
332  ! The module was originally written by P. Xue at SMAST/UMASSD when he and !
333  ! Chen applied FVCOM Kalman Filter to conduct The Observing System Simulation!
334  ! Experiments (OSSEs) in Nantucket Sound. This module was modified by Dave !
335  ! Stuebe at SMAST/UMASSD and implemented into the version 3.0 of FVCOM, and !
336  ! graded by J. Qi and C. Chen at SMAST/UMASSD for current-wave interaction !
337  ! modules in in version 3.1. !
338  ! !
339  ! 8) Dike-Groyne module. This module is implemented into FVCOM to deal with the !
340  ! vertical wall under or above the sea surface. The algorithm was derived by !
341  ! C. Chen at SMAST/UMASSD, and the parallelized code was written and tested !
342  ! by J. Qi, J. Ge and C. Chen at SMAST/UMASSD. !
343  ! !
344  ! 9) SST/SSH assimilation module. A SSH assimilation module is added to include!
345  ! the satellite-altimeter data into FVCOM. The algorithm is the same as that !
346  ! used for SST assimilation. The SST/SSH is merged together by Q. Xu, Z. Lai !
347  ! and C. Chen at SMAST/UMASSD and implemented into version 3.1. C. Chen !
348  ! improved the SST algorithm to avoid the unreal thin layer caused by SST !
349  ! nudging. !
350  ! !
351  ! 10) Kalman Filter Assimilation modules. The Kalman Filter package is upgraded !
352  ! by adding a Signular Evolutive Interpolated Kalman filter (SEIK). The !
353  ! source code of SEIK code is provided by Dr. Lars Nerger at AWI, Germany. !
354  ! In addition to Reduced Rank Kalman Filter (RRKF), Ensemble Kalman Filter !
355  ! (EnKF), we also reconstruct Ensemble Transform Kalman Filter (EnTKF) for !
356  ! the OSSEs application. The Kalman Filter assimilation modules were !
357  ! originally developed by a team effort led by C. Chen at SMAST/UMASSD and P.!
358  ! Rizzoli/MIT. The team members include P. Xue, Z. Lai, Q. Xu and J. Qi at !
359  ! SMAST/UMASSD, J. Wei and S. Lyu at MIT and R. C. Beardsley at WHOI. The !
360  ! package is upgraded and implemented into version 3.1 by P. Xue, J.Qi and !
361  ! C.Chen. Dr. Lars Nerger owns the copyright of SEIK method used in FVCOM. ! !
362  ! !
363  ! 11) Optimal Interpolation Assimilation Module. This module is implemented into!
364  ! FVCOM to integrate vertical profiles of hydrographic/current data into the !
365  ! assimilation. The code was written by Q. Xu, J. Qi and C. Chen at !
366  ! SMAST/UMASSD. !
367  ! !
368  ! 12) The pre-process programs to convert the input from the old version of !
369  ! FVCOM to version 3.0 or up. !
370  ! !
371  ! 13) Bugs in the wet/dry treatments on heat flux at the wet/dry boundary are !
372  ! corrected. The bug was detected by T. Kim and fixed by C. Chen and J. Qi at!
373  ! SMAST/UMASSD. The second-order limiter for advection terms in the wet/dry !
374  ! treatment was originally coded in Fortran 77 version of FVCOM. This limiter!
375  ! is added back to updated version 2.6 or up of FVCOM by C. Chen and J. Qi at!
376  ! SMAST/UMASSD. !
377  ! !
378  ! Bugs in selecting General Turbulence Module is corrected by J. Qi and C. !
379  ! Chen at SMAST/UMASSD. !
380  ! !
381  ! Non-general definitions and commands in arrays, variables and NetCDF !
382  ! modules are changed by G. Cowles and Z. Lai to allow to use the version 3.1 of!
383  ! FVCOM on IBM super computer. These problems only occur in version 3.0 or up. !
384  ! The bugs in PETCs were detected by Z. Lai, C. Chen and J. Qi at SMAST/UMASSD !
385  ! and corrected by the PETCs development team. !
386  ! !
387  ! Bugs in the Lagrangian-tracking in the generalized terrain-following !
388  ! coordinates are corrected. Many minor bugs are also corrected. !
389  ! !
390  ! Enjoy! C. Chen at SMAST/UMASSD at Dec. 8 2009. !
391  !================================================================================!
392 
393  !==============================================================================!
394  ! INCLUDE MODULES !
395  !==============================================================================!
396 
397  USE mod_utils
398  USE control
399 
400  USE mod_par
401 
402  USE mod_startup
403 
404  USE mod_time
405  USE mod_clock
406 
407  USE mod_input
408  USE mod_ncdio
409  USE mod_ncll
410 
411  USE mod_setup
412  USE mod_set_time
413 
414  USE mod_force
415  USE mod_obcs
416 
417  USE mod_nesting
418 
419  USE mod_report
420  USE probes
421  USE mod_boundschk !bounds checking
422 
423 
424 
425 
426 
427 
428 
429 
430 ! for periodic lateral boundary conditions
431 
432 
433 
434 
435 
436 
439 
440  !------------------------------------------------------------------------------|
441  IMPLICIT NONE
442 
443  character(len=*),parameter::cvs_id="$Id$" ! [sng] CVS Identification
444  character(len=*),parameter::cvs_date="$Date$" ! [sng] Date string
445  character(len=*),parameter::cvs_name="$Name$" ! [sng] File name string
446  character(len=*),parameter::cvs_revision="$Revision$" ! [sng] File revision string
447 
448  INTEGER :: ierr
449 
450  type(watch) timer
451 
452  type(time) ::get_begin
453  integer status
454 
455  !==============================================================================!
456  ! INITIALIZE ALL CONTROL VARIABLES
457  !==============================================================================!
458  CALL initialize_control("FVCOM")
459 
460 
461  !==============================================================================!
462  ! INITIALIZE A STOP WATCH TIMER FOR TESTING SUBROUTINE EFFICENCY !
463  !==============================================================================!
464  CALL watch_init(timer)
465 
466  !==============================================================================!
467  ! IMPORT CASENAME AND COMMAND LINE ARGUMENTS AND START LOG FILE !
468  !==============================================================================!
469  CALL commandlineio(cvs_id,cvs_date,cvs_name,cvs_revision)
470  if(dbg_set(dbg_log)) Call write_banner(par,nprocs,myid)
471 
472  !==============================================================================!
473  ! SET DEFAULT VALUES AND READ NAME LISTS
474  !==============================================================================!
475 
476  CALL namelist
477 
478  !==============================================================================!
479  ! SET MODEL CONTROL PARAMTERS BASED ON NAME LIST HERE !
480  !==============================================================================!
481  CALL cntrl_prmtrs
482 
483  !==============================================================================!
484  ! SET THE STARTUP TYPE TO BE USED! !
485  !==============================================================================!
486  CALL set_startup_type ! see: startup_type.F
487 
488  !==============================================================================!
489  ! OPEN ALL FILES NEEDED BASED ON THE RUN PARAMETERS !
490  !==============================================================================!
491  CALL open_all
492 
493  !==============================================================================!
494  ! SET MODEL TIME BASED ON THE NAMELIST TIME STRINGS OR RESTART FILE !
495  !==============================================================================!
496  CALL setup_time
497 
498  !==============================================================================!
499  ! LOAD GRID CONNECTIVITY AND OBC LIST FOR METIS DECOMPOSITION !
500  !==============================================================================!
501  CALL load_grid
502 
503  !==============================================================================!
504  ! SETUP THE DOMAIN FOR PARALLEL OR SERIAL RUNNING !
505  !==============================================================================!
506  CALL setup_domain
507 
508  !==============================================================================!
509  ! ALLOCATE ALL DOMAIN SIZE VARIABLES HERE !
510  !==============================================================================!
511  CALL allocate_all
512  !==============================================================================!
513  ! LOAD/SETUP PHYSICAL QUANTITIES (CORIOLIS, GRAVITY, SPONGE LAYER, XY/LATLON)!
514  !==============================================================================!
515  CALL coords_n_const
516 
517  !==============================================================================!
518  ! CALCULATE GRID METRICS - NEIGHBORS, GRADIENTS, CELL AREA, INTERP COEFF'S !
519  !==============================================================================!
520  CALL grid_metrics
521 
522  !==============================================================================!
523  ! SETUP THE SEDIMENT MODEL (MUST COME BEFORE SETUP_FORCING) !
524  !==============================================================================!
525 
526 
527 !JQI !==============================================================================!
528 !JQI ! SETUP THE MODEL FORCING !
529 !JQI !==============================================================================!
530 !JQI CALL SETUP_FORCING
531 
532  !==============================================================================!
533  ! GET THE PARAMETERS OF BIOLOGICAL MODEL !
534  !==============================================================================!
535 
536  !==============================================================================!
537  ! SETUP THE MODEL FORCING !
538  !==============================================================================!
539  CALL setup_forcing
540 
541  !==============================================================================!
542  ! SETUP OTHER TOOLS, MODELS AND DATA ASSIMILATION !
543  !==============================================================================!
544 
545 
546  ! SETUP PETSc FOR SEMI_IMPLICIT AND NON-HYDROSTATIC MODULE
547 
548 
549 
550 
551 
552  ! SETUP DATA ASSIMILATION MODE
553 ! New Open Boundary Condition ----2
554 
555  !==============================================================================!
556  ! SET THE INITIAL CONDITIONS FOR THE MODEL !
557  !==============================================================================!
558  CALL startup
559 
560 !qxu{ test function READ_DATETIME
561 ! GET_BEGIN = READ_DATETIME('2009-01-01T00:00:00.0','ymd','UTC',status)
562 ! CALL PRINT_TIME(GET_BEGIN,IPT,'2009-01-01T00:00:00.0')
563 !qxu}
564 
565  !==============================================================================!
566  ! CALL ARCHIVE TO SETUP THE OUTPUT AND DUMP CONSTANT VALUES !
567  !==============================================================================!
568  CALL bcond_gcn(8,0)
569 
570  CALL archive
571  ! ORDER MATTERS - ARCHIVE_NEST MUST GO AFTER ARCHIVE DURING SETUP!
572  CALL archive_nest
573 
576 
577  ! Setup Bounds checking (shutdown if variables exceed threshold)
578  CALL setup_boundschk !bounds checking
579 
580 
581 
586  END IF
587  !==============================================================================!
588  ! SELECT THE RUN MODE AND EXECUTE THE MAIN LOOP
589  !==============================================================================!
590  SELECT CASE(fvcom_run_mode)
591  ! RUN MODE SET IN mod_assim.F(set_assim_param)
592 
593  ! =============================================================================!
594  ! == PURE SIMULATION MODE - Instantanious data assimilation only ==============!
595  CASE(fvcom_pure_sim)
596  ! =============================================================================!
597 
598 
599  !==============================================================================!
600  ! PREPARE TO START FVCOM'S MAIN LOOP !
601  !==============================================================================!
602  if(dbg_set(dbg_log)) THEN
603  write(ipt,*) "!===================================================="
604  write(ipt,*) "!===================================================="
605  write(ipt,*) "!============== STARTING MAIN LOOP AT:==============="
606  if(dbg_set(dbg_log)) &
608  write(ipt,*) "!===================================================="
609  end if
610 
611  CALL report('INITIAL CONDITIONS')
612 
613  if(dbg_set(dbg_log)) THEN
614  write(ipt,*) "!===================================================="
615  write(ipt,*) "!===================================================="
616  write(ipt,*) "!===================================================="
617  end if
618 
619  !////////////////////////// MAIN LOOP //////////////////////////////////////////
620  DO iint=istart,iend
621 
623 
624  CALL internal_step
625 
626  !==============================================================================!
627  ! OUTPUT SCREEN REPORT/TIME SERIES DATA/OUTPUT FILES |
628  !==============================================================================!
629  if(dbg_set(dbg_log)) &
631 
632  IF(report_now(iint,ireport)) CALL report('FLOW FIELD STATS')
633 
634  !==============================================================================!
635  ! CALL ARCHIVE TO WRITE THE OUTPUT (SELECTED BASED ON INTTIME) !
636  !==============================================================================!
637 
638 !for Eulerian velocity output
639 
640  CALL archive
641 
642 
643  CALL dump_probe_data
645  !==============================================================================!
646  ! CALL SHUTDOWN CHECK TO LOOK FOR BAD VALUES !
647  !==============================================================================!
648  CALL shutdown_check(d1)
649 
650  !==============================================================================!
651  ! CALL BOUNDS CHECK TO SEE IF VARIABLES EXCEED USER-DEFINED THRESHOLDS
652  !==============================================================================!
653  CALL boundschk !bounds checking
654 
655  !==============================================================================!
656  ! LAGRANGIAN PARTICLE TRACKING |
657  !==============================================================================!
658 
659  !==============================================================================!
660  ! NESTING OUTPUT |
661  !==============================================================================!
662  IF(ncnest_on) CALL archive_nest
663 
664  END DO
665  !////////////////////////// END MAIN LOOP //////////////////////////////////////
666 
667  ! ================================================================================!
668  ! == THIS MAIN LOOP USES NUDGING OR OI METHODS TO ASSIMILATE =====================!
670  ! ================================================================================!
671 
672 ! ! ================================================================================!
673 ! ! == THIS MAIN LOOP USES OPTIMAL INTERPOLATION METHODS TO ASSIMILATE ============!
674 ! CASE(FVCOM_OI_ASSIM)
675 ! ! ================================================================================!
676 !
677 ! CALL SET_OIASSIM_INTERVALS
678 ! CALL ALLOC_BUFFER_OI
679 !
680 ! ! SET THE ASSIMILATION/SIMULATION RESET TIME
681 ! ASSIM_RESTART_TIME = StartTime
682 !
683 ! ! INITIALIZE THE COUNT VARIABLES FOR THE SST LOOP
684 ! INT_START = ISTART
685 ! INT_COUNT = ISTART
686 ! IF(SST_OIASSIM.OR.SSTGRD_OIASSIM)THEN
687 ! INT_END = ISTART + 2*(IEND-ISTART)
688 ! ELSEIF(TS_OIASSIM.OR.CUR_OIASSIM)THEN
689 ! INT_END = IEND
690 ! END IF
691 ! !==============================================================================!
692 ! ! PREPARE TO START FVCOM'S MAIN LOOP !
693 ! !==============================================================================!
694 ! if(DBG_SET(dbg_log)) THEN
695 ! write(IPT,*) "===================================================="
696 ! write(IPT,*) "===================================================="
697 ! write(IPT,*) "======STARTING MAIN LOOP OIASSIMILATION MODE:======="
698 ! Call REPORT_TIME(IINT,INT_START,INT_END,IntTime)
699 ! write(IPT,*) "===================================================="
700 ! end if
701 !
702 ! CALL REPORT('INITIAL CONDITIONS')
703 !
704 ! if(DBG_SET(dbg_log)) THEN
705 ! write(IPT,*) "===================================================="
706 ! write(IPT,*) "===================================================="
707 ! write(IPT,*) "===================================================="
708 ! end if
709 
710 ! DO WHILE(IntTime < EndTime)
711 ! IF(SST_OIASSIM.OR.SSTGRD_OIASSIM)THEN
712 ! ASSIM_RESTART_TIME = ASSIM_RESTART_TIME + days2time(1.0_DP) ! ADD ONE MORE DAY
713 ! ELSEIF(TS_OIASSIM.OR.CUR_OIASSIM)THEN
714 ! ASSIM_RESTART_TIME = EndTime
715 ! END IF
716 ! SST_SAVE_INDEX = 0
717 ! SST_SAVE_TIME = IntTime + sst_save_interval
718 !
719 ! CALL OI_SAVE_STATE
720 !
721 !
722 ! if(DBG_SET(dbg_log)) THEN
723 ! Call REPORT_TIME(IINT,INT_START,INT_END,IntTime)
724 ! write(IPT,*) "======= Start 1 Day Simulation ===================="
725 ! end if
726 ! !==============================================================================!
727 ! ! RUN PURE SIMULATION MODE:
728 ! !==============================================================================!
729 !
730 ! OIASSIM_FLAG = 0
731 ! DO WHILE(IntTime < ASSIM_RESTART_TIME)
732 !
733 ! IINT = IINT + 1
734 ! IntTime=IntTime + IMDTI
735 !
736 ! CALL INTERNAL_STEP
737 !
738 ! !==============================================================================!
739 ! ! OUTPUT SCREEN REPORT/TIME SERIES DATA/OUTPUT FILES |
740 ! !==============================================================================!
741 ! if(DBG_SET(dbg_log)) &
742 ! & Call REPORT_TIME(IINT,INT_START,INT_END,IntTime)
743 !
744 ! IF(REPORT_NOW(IINT,IREPORT)) CALL REPORT('FLOW FIELD STATS')
745 !
746 ! !==============================================================================!
747 ! ! CALL SHUTDOWN CHECK TO LOOK FOR BAD VALUES !
748 ! !==============================================================================!
749 ! IF(TS_OIASSIM.OR.CUR_OIASSIM)THEN
750 !
751 ! CALL ARCHIVE
752 !
753 ! CALL DUMP_PROBE_DATA
754 !
755 ! END IF
756 !
757 ! CALL SHUTDOWN_CHECK(D1)
758 !
759 ! END DO
760 !
761 ! IF(SST_OIASSIM.OR.SSTGRD_OIASSIM)THEN
762 ! !==============================================================================!
763 ! ! CALL RESTORE TO RUN ASSIMILATION CODE |
764 ! !==============================================================================!
765 ! CALL OI_RESTORE_STATE
766 !
767 ! if(DBG_SET(dbg_log)) THEN
768 ! Call REPORT_TIME(INT_COUNT,INT_START,INT_END,IntTime)
769 ! write(IPT,*) "======= Start 1 Day Assimilation ===================="
770 ! end if
771 !
772 ! !==============================================================================!
773 ! ! RUN DATA ASSIMILATION MODE:
774 ! !==============================================================================!
775 ! OIASSIM_FLAG = 1
776 ! DO WHILE(IntTime < ASSIM_RESTART_TIME)
777 !
778 ! IINT = IINT + 1
779 ! IntTime=IntTime + IMDTI
780 !
781 ! CALL INTERNAL_STEP
782 !
783 ! !==============================================================================!
784 ! ! OUTPUT SCREEN REPORT/TIME SERIES DATA/OUTPUT FILES |
785 ! !==============================================================================!
786 ! if(DBG_SET(dbg_log)) &
787 ! & Call REPORT_TIME(IINT,INT_START,INT_END,IntTime)
788 !
789 ! IF(REPORT_NOW(IINT,IREPORT)) CALL REPORT('FLOW FIELD STATS')
790 !
791 ! !==============================================================================!
792 ! ! CALL ARCHIVE TO WRITE THE OUTPUT (SELECTED BASED ON INTTIME) !
793 ! !==============================================================================!
794 ! CALL ARCHIVE
795 !
796 ! CALL DUMP_PROBE_DATA
797 ! !==============================================================================!
798 ! ! CALL SHUTDOWN CHECK TO LOOK FOR BAD VALUES !
799 ! !==============================================================================!
800 ! CALL SHUTDOWN_CHECK(D1)
801 !
802 !
803 ! !==============================================================================!
804 ! ! LAGRANGIAN PARTICLE TRACKING |
805 ! !==============================================================================!
806 !# if defined (LAG_PARTICLE)
807 ! CALL LAG_UPDATE
808 !# endif
809 !
810 ! END DO
811 ! END IF
812 ! ! RUN THE NEXT DAY
813 !
814 ! END DO
815 
817  CASE(fvcom_rrkf_with_ssa)
818 
819 !============================================END RRKF_WITH_SSA================================|
820 
821 
822 
823 
824 
826 
827 !============================================END ENKF_WITHOUT_SSA================================|
828 
829  CASE(fvcom_enkf_with_ssa)
830 
831 !============================================END ENKF_WITH_SSA================================|
832  CASE DEFAULT
833  CALL fatal_error("UNKNOWN FVCOM_RUN_MODE :'"//trim(fvcom_run_mode),&
834  & "Options are the following: '"//trim(fvcom_pure_sim)//"&
835  &' OR '"//trim(fvcom_nudge_oi_assim) )
836  END SELECT
837 
838 
839 
840 
841 
842 
843  if(dbg_set(dbg_log)) write(ipt,*)"TADA!"
844  CALL pshutdown
845 
846 END PROGRAM fvcom
subroutine setup_time
integer(itime) iend
Definition: mod_main.f90:853
subroutine report(INFO_STRING)
Definition: mod_report.f90:63
subroutine archive
Definition: mod_ncdio.f90:153
subroutine get_output_file_interval(STRING, INTERVAL)
subroutine dump_probe_data
Definition: mod_probe.f90:761
subroutine internal_step
logical function dbg_set(vrb)
Definition: mod_utils.f90:182
subroutine watch_init(MYWATCH)
Definition: mod_clock.f90:116
subroutine namelist
Definition: namelist.f90:41
subroutine setup_domain
logical par
Definition: mod_main.f90:102
type(time) inttime
Definition: mod_main.f90:827
subroutine report_time(IINT, ISTART, IEND, STIME)
Definition: mod_clock.f90:334
subroutine open_all
Definition: open_all.f90:41
logical ncnest_on
type(time) starttime
Definition: mod_main.f90:833
subroutine bcond_gcn(IDX, K_RK)
Definition: bcond_gcn.f90:58
subroutine commandlineio(CVS_ID, CVS_Date, CVS_Name, CVS_Revision)
Definition: mod_input.f90:66
integer(itime) istart
Definition: mod_main.f90:852
subroutine set_startup_type
subroutine coords_n_const
integer probes_number
Definition: mod_main.f90:795
integer(itime) iint
Definition: mod_main.f90:850
subroutine setup_boundschk
subroutine, public startup
Definition: mod_startup.f90:71
character(len=80), parameter fvcom_rrkf_without_ssa
Definition: mod_main.f90:755
subroutine, public setup_forcing
Definition: mod_force.f90:301
program fvcom
Definition: fvcom.f90:44
integer ireport
Definition: mod_main.f90:185
logical function report_now(IINT, IREPORT)
Definition: mod_report.f90:46
subroutine initialize_control(NAME)
Definition: mod_utils.f90:141
subroutine boundschk
character(len=80), parameter fvcom_enkf_without_ssa
Definition: mod_main.f90:757
character(len=80), parameter fvcom_enkf_with_ssa
Definition: mod_main.f90:758
character(len=80), parameter fvcom_nudge_oi_assim
Definition: mod_main.f90:752
subroutine fatal_error(ER1, ER2, ER3, ER4)
Definition: mod_utils.f90:230
type(time) imdti
Definition: mod_main.f90:848
character(len=80), parameter fvcom_rrkf_with_ssa
Definition: mod_main.f90:756
subroutine pshutdown
Definition: mod_utils.f90:280
subroutine grid_metrics
subroutine load_grid
Definition: load_grid.f90:41
character(len=80) probes_file
Definition: mod_main.f90:796
character(len=80) fvcom_run_mode
Definition: mod_main.f90:748
integer ipt
Definition: mod_main.f90:922
logical probes_on
Definition: mod_main.f90:794
character(len=80), parameter fvcom_pure_sim
Definition: mod_main.f90:749
subroutine archive_nest
subroutine set_probes(P_ON, NP, FNM)
Definition: mod_probe.f90:497
subroutine allocate_all
subroutine write_banner(PAR, NP, ID)
Definition: mod_utils.f90:1534
integer, parameter dbg_log
Definition: mod_utils.f90:65
subroutine cntrl_prmtrs