Skip to content

Commit

Permalink
Implements fms2_io to simple coupler files + clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriel Ramirez committed Feb 23, 2021
1 parent b28cedf commit 90db31d
Showing 3 changed files with 95 additions and 203 deletions.
29 changes: 10 additions & 19 deletions simple/coupler_main.F90
Original file line number Diff line number Diff line change
@@ -71,14 +71,16 @@ program coupler_main

use fms_affinity_mod, only: fms_affinity_init, fms_affinity_set

use fms_mod, only: open_namelist_file, file_exist, check_nml_error, &
error_mesg, fms_init, fms_end, close_file, &
use fms_mod, only: check_nml_error, &
error_mesg, fms_init, fms_end, &
write_version_number, uppercase, stdout

use fms_io_mod, only: fms_io_exit
use fms_io_mod, only: fms_io_exit !< This can't be removed until fms_io is not used at all

use fms2_io_mod, only: file_exists

use mpp_mod, only: mpp_init, mpp_pe, mpp_root_pe, mpp_npes, mpp_get_current_pelist, &
stdlog, mpp_error, NOTE, FATAL, WARNING
stdlog, mpp_error, NOTE, FATAL, WARNING, input_nml_file
use mpp_mod, only: mpp_clock_id, mpp_clock_begin, mpp_clock_end

use mpp_mod, only: mpp_chksum, mpp_set_current_pelist
@@ -292,19 +294,8 @@ subroutine coupler_init
!----- read namelist -------
!----- for backwards compatibilty read from file coupler.nml -----

if (file_exist('input.nml')) then
unit = open_namelist_file ()
else
call error_mesg ('program coupler', &
'namelist file input.nml does not exist', FATAL)
endif

ierr=1
do while (ierr /= 0)
read (unit, nml=coupler_nml, iostat=io, end=10)
ierr = check_nml_error (io, 'coupler_nml')
enddo
10 call close_file (unit)
read (input_nml_file, nml=coupler_nml, iostat=io)
ierr = check_nml_error(io, 'coupler_nml')

!----- write namelist to logfile -----

@@ -317,7 +308,7 @@ subroutine coupler_init

!----- read restart file -----

if (file_exist('INPUT/coupler.res')) then
if (file_exists('INPUT/coupler.res')) then
call mpp_open( unit, 'INPUT/coupler.res', action=MPP_RDONLY )
read (unit,*,err=999) calendar_type
read (unit,*) date_init
@@ -493,7 +484,7 @@ subroutine coupler_init
call ice_model_init (Ice, Time_init, Time_atmos, Time_step_atmos, Time_step_ocean, &
glon_bnd, glat_bnd, atmos_domain=Atm%Domain)

if (file_exist('data_table')) then
if (file_exists('data_table')) then
inquire(file='data_table', size=dt_size)
if (dt_size > 0.) then
call data_override_init(Atm_domain_in = Atm%domain)
17 changes: 5 additions & 12 deletions simple/flux_exchange.F90
Original file line number Diff line number Diff line change
@@ -43,14 +43,13 @@ module flux_exchange_mod
#endif
use diag_data_mod, only: CMOR_MISSING_VALUE
use constants_mod, only: RDGAS, RVGAS, CP_AIR, HLV, HLF, PI
use fms_mod, only: file_exist, open_namelist_file, &
check_nml_error, close_file, &
use fms_mod, only: check_nml_error, &
error_mesg, FATAL, stdlog, &
write_version_number, &
mpp_pe, mpp_root_pe, WARNING
use mpp_domains_mod, only: mpp_get_compute_domain

use mpp_mod, only: mpp_min, mpp_max, mpp_sync, NOTE
use mpp_mod, only: mpp_min, mpp_max, mpp_sync, NOTE, input_nml_file

use field_manager_mod, only: MODEL_ATMOS
use tracer_manager_mod, only: get_number_tracers, get_tracer_index, NO_TRACER
@@ -851,16 +850,10 @@ end subroutine flux_exchange_init

subroutine read_namelist

integer :: unit, ierr, io
integer :: ierr, io

if ( file_exist('input.nml')) then
unit = open_namelist_file ()
ierr=1; do while (ierr /= 0)
read (unit, nml=flux_exchange_nml, iostat=io, end=10)
ierr = check_nml_error(io,'flux_exchange_nml')
enddo
10 call close_file (unit)
endif
read (input_nml_file, nml=flux_exchange_nml, iostat=io)
ierr = check_nml_error(io, 'flux_exchange_nml')

do_read_nml = .false.

Loading

0 comments on commit 90db31d

Please sign in to comment.