Skip to content

Commit

Permalink
Update CPP implementation (#490)
Browse files Browse the repository at this point in the history
* Update CPPs
Rename ncdf to USE_NETCDF (ncdf still works) and update USE_NETCDF implementation
Update NO_I8
Update NO_R16
Remove popcice

* Convert ORCA_GRID CPP to orca_halogrid namelist
Convert a RASM_MODS CPP to bathymetry_format namelist to support reading a pop vertical grid file
Convert gather_scatter_barrier CPP to add_mpi_barriers namelist
Document

* update documentation

* update documentation, remove coupled macros as this is going away soon and change cpp directive to cpp macro

Co-authored-by: Philippe Blain <levraiphilippeblain@gmail.com>
  • Loading branch information
apcraig and phil-blain authored Jul 31, 2020
1 parent b055c7f commit 819eedd
Show file tree
Hide file tree
Showing 29 changed files with 362 additions and 281 deletions.
91 changes: 26 additions & 65 deletions cicecore/cicedynB/general/ice_forcing.F90
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifdef ncdf
#define USE_NETCDF
#endif
!=======================================================================
!
! Reads and interpolates forcing data for atmosphere and ocean quantities.
Expand Down Expand Up @@ -300,9 +303,6 @@ subroutine init_forcing_ocn(dt)
use ice_domain, only: nblocks
use ice_domain_size, only: max_blocks
use ice_flux, only: sss, sst, Tf
#ifdef ncdf
use netcdf
#endif

real (kind=dbl_kind), intent(in) :: &
dt ! time step
Expand Down Expand Up @@ -866,7 +866,6 @@ subroutine read_data_nc (flag, recd, yr, ixm, ixx, ixp, &

character(len=*), parameter :: subname = '(read_data_nc)'

#ifdef ncdf
integer (kind=int_kind) :: &
nrec , & ! record number to read
n2, n4 , & ! like ixm and ixp, but
Expand Down Expand Up @@ -967,9 +966,6 @@ subroutine read_data_nc (flag, recd, yr, ixm, ixx, ixp, &

call ice_timer_stop(timer_readwrite) ! reading/writing

#else
field_data = c0 ! to satisfy intent(out) attribute
#endif
end subroutine read_data_nc

!=======================================================================
Expand Down Expand Up @@ -1007,7 +1003,6 @@ subroutine read_data_nc_hycom (flag, recd, &
intent(out) :: &
field_data ! 2 values needed for interpolation

#ifdef ncdf
! local variables
integer (kind=int_kind) :: &
fid ! file id for netCDF routines
Expand Down Expand Up @@ -1040,11 +1035,6 @@ subroutine read_data_nc_hycom (flag, recd, &

call ice_timer_stop(timer_readwrite) ! reading/writing

#else
field_data = c0 ! to satisfy intent(out) attribute
write(*,*)'ERROR: CICE not compiled with NetCDF'
stop
#endif
end subroutine read_data_nc_hycom

!=======================================================================
Expand Down Expand Up @@ -3342,9 +3332,6 @@ subroutine oned_data

use ice_flux, only: uatm, vatm, Tair, fsw, fsnow, Qa, rhoa, frain

#ifdef ncdf
use netcdf

! local parameters

character (char_len_long) :: &
Expand Down Expand Up @@ -3402,7 +3389,7 @@ subroutine oned_data
Temp = work
Tair(:,:,:) = Temp

if (my_task == master_task) status = nf90_close(fid)
call ice_close_nc(fid)

! hourly solar data beginning Jan 1, 1989, 01:00
met_file = fsw_file
Expand All @@ -3412,7 +3399,7 @@ subroutine oned_data
call ice_read_nc(fid,istep1,fieldname,work,diag)
fsw(:,:,:) = work

if (my_task == master_task) status = nf90_close(fid)
call ice_close_nc(fid)

! hourly interpolated monthly data beginning Jan 1, 1989, 01:00
met_file = humid_file
Expand All @@ -3426,7 +3413,7 @@ subroutine oned_data
call ice_read_nc(fid,istep1,fieldname,work,diag)
fsnow(:,:,:) = work

if (my_task == master_task) status = nf90_close(fid)
call ice_close_nc(fid)

!-------------------------------------------------------------------
! Find specific humidity using Hyland-Wexler formulation
Expand All @@ -3447,8 +3434,6 @@ subroutine oned_data
cldf (:,:,:) = p25 ! cloud fraction
frain(:,:,:) = c0 ! this is available in hourlymet_rh file

#endif

end subroutine oned_data

!=======================================================================
Expand Down Expand Up @@ -3648,7 +3633,7 @@ subroutine ocn_data_ncar_init

use ice_blocks, only: nx_block, ny_block
use ice_domain_size, only: max_blocks
#ifdef ncdf
#ifdef USE_NETCDF
use netcdf
#endif

Expand All @@ -3664,7 +3649,6 @@ subroutine ocn_data_ncar_init
'T', 'S', 'hblt', 'U', 'V', &
'dhdx', 'dhdy', 'qdp' /

#ifdef ncdf
integer (kind=int_kind) :: &
fid , & ! file id
dimid ! dimension id
Expand All @@ -3673,7 +3657,6 @@ subroutine ocn_data_ncar_init
status , & ! status flag
nlat , & ! number of longitudes of data
nlon ! number of latitudes of data
#endif

real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: &
work1
Expand Down Expand Up @@ -3701,7 +3684,7 @@ subroutine ocn_data_ncar_init
endif ! master_task

if (trim(ocn_data_format) == 'nc') then
#ifdef ncdf
#ifdef USE_NETCDF
if (my_task == master_task) then
call ice_open_nc(sst_file, fid)

Expand Down Expand Up @@ -3741,7 +3724,10 @@ subroutine ocn_data_ncar_init
enddo ! month loop
enddo ! field loop

if (my_task == master_task) status = nf90_close(fid)
if (my_task == master_task) call ice_close_nc(fid)
#else
call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined for '//trim(sst_file), &
file=__FILE__, line=__LINE__)
#endif

else ! binary format
Expand Down Expand Up @@ -3803,11 +3789,11 @@ subroutine ocn_data_ncar_init_3D
use ice_domain_size, only: max_blocks
use ice_grid, only: to_ugrid, ANGLET
use ice_read_write, only: ice_read_nc_uv
#ifdef ncdf
#ifdef USE_NETCDF
use netcdf
#endif

#ifdef ncdf
#ifdef USE_NETCDF
integer (kind=int_kind) :: &
n , & ! field index
m , & ! month index
Expand Down Expand Up @@ -3856,7 +3842,7 @@ subroutine ocn_data_ncar_init_3D
endif ! master_task

if (trim(ocn_data_format) == 'nc') then
#ifdef ncdf
#ifdef USE_NETCDF
if (my_task == master_task) then
call ice_open_nc(sst_file, fid)

Expand Down Expand Up @@ -3902,7 +3888,7 @@ subroutine ocn_data_ncar_init_3D
enddo ! month loop
enddo ! field loop

if (my_task == master_task) status = nf90_close(fid)
if (my_task == master_task) call ice_close_nc(fid)

! Rotate vector quantities and shift to U-grid
do n=4,6,2
Expand All @@ -3923,6 +3909,9 @@ subroutine ocn_data_ncar_init_3D
enddo ! month loop
enddo ! field loop

#else
call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', &
file=__FILE__, line=__LINE__)
#endif

else ! binary format
Expand Down Expand Up @@ -4327,9 +4316,6 @@ subroutine ocn_data_hycom_init
use ice_blocks, only: nx_block, ny_block
use ice_domain, only: nblocks
use ice_flux, only: sss, sst, Tf
#ifdef ncdf
use netcdf
#endif

integer (kind=int_kind) :: &
i, j, iblk , & ! horizontal indices
Expand Down Expand Up @@ -4611,7 +4597,6 @@ subroutine read_data_nc_point (flag, recd, yr, ixm, ixx, ixp, &

character(len=*), parameter :: subname = '(read_data_nc_point)'

#ifdef ncdf
integer (kind=int_kind) :: &
nrec , & ! record number to read
n2, n4 , & ! like ixm and ixp, but
Expand Down Expand Up @@ -4723,9 +4708,6 @@ subroutine read_data_nc_point (flag, recd, yr, ixm, ixx, ixp, &

call ice_timer_stop(timer_readwrite) ! reading/writing

#else
field_data = c0 ! to satisfy intent(out) attribute
#endif
end subroutine read_data_nc_point

!=======================================================================
Expand Down Expand Up @@ -4779,13 +4761,9 @@ subroutine ISPOL_data
!
use ice_flux, only: uatm, vatm, Tair, fsw, Qa, rhoa, &
frain, fsnow, flw
#ifdef ncdf
use netcdf
#endif

!local parameters

#ifdef ncdf
character (char_len_long) :: &
met_file, & ! netcdf filename
fieldname ! field name in netcdf file
Expand Down Expand Up @@ -4822,15 +4800,13 @@ subroutine ISPOL_data
sec1hr ! number of seconds in 1 hour

logical (kind=log_kind) :: read1
#endif

integer (kind=int_kind) :: &
recnum , & ! record number
recnum4X ! record number

character(len=*), parameter :: subname = '(ISPOL_data)'

#ifdef ncdf
call icepack_query_parameters(secday_out=secday)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand Down Expand Up @@ -4965,14 +4941,6 @@ subroutine ISPOL_data
flw(:,:,:) = c1intp * flw_data_p(1) &
+ c2intp * flw_data_p(2)
endif !nc
#else

uatm(:,:,:) = c0 !wind velocity (m/s)
vatm(:,:,:) = c0
fsw(:,:,:) = c0
fsnow (:,:,:) = c0

#endif

!flw given cldf and Tair calculated in prepare_forcing

Expand Down Expand Up @@ -5015,11 +4983,7 @@ subroutine ocn_data_ispol_init
!
use ice_gather_scatter
use ice_read_write
#ifdef ncdf
use netcdf
#endif

#ifdef ncdf
integer (kind=int_kind) :: &
n , & ! field index
m ! month index
Expand All @@ -5038,7 +5002,6 @@ subroutine ocn_data_ispol_init

integer (kind=int_kind) :: &
status ! status flag
#endif

character(len=*), parameter :: subname = '(ocn_data_ispol_init)'

Expand All @@ -5058,7 +5021,6 @@ subroutine ocn_data_ispol_init
endif ! master_task

if (trim(ocn_data_format) == 'nc') then
#ifdef ncdf
if (my_task == master_task) then
call ice_open_nc(sst_file, fid)
endif ! master_task
Expand All @@ -5078,8 +5040,7 @@ subroutine ocn_data_ispol_init
enddo ! month loop
enddo ! field loop

if (my_task == master_task) status = nf90_close(fid)
#endif
if (my_task == master_task) call ice_close_nc(fid)

else ! binary format
call abort_ice (error_message=subname//'new ocean forcing is netcdf only', &
Expand Down Expand Up @@ -5188,9 +5149,6 @@ subroutine get_wave_spec
use ice_constants, only: c0
use ice_domain_size, only: nfreq
use ice_timers, only: ice_timer_start, ice_timer_stop, timer_fsd
#ifdef ncdf
use netcdf
#endif

! local variables
integer (kind=int_kind) :: &
Expand Down Expand Up @@ -5228,16 +5186,19 @@ subroutine get_wave_spec
! read more realistic data from a file
if ((trim(wave_spec_type) == 'constant').OR.(trim(wave_spec_type) == 'random')) then
if (trim(wave_spec_file(1:4)) == 'unkn') then
call abort_ice (subname//'ERROR: wave_spec_file '//trim(wave_spec_file))
call abort_ice (subname//'ERROR: wave_spec_file '//trim(wave_spec_file), &
file=__FILE__, line=__LINE__)
else
#ifdef ncdf
#ifdef USE_NETCDF
call ice_open_nc(wave_spec_file,fid)
call ice_read_nc_xyf (fid, 1, 'efreq', wave_spectrum(:,:,:,:), dbug, &
field_loc_center, field_type_scalar)
call ice_close_nc(fid)
#else
write (nu_diag,*) "wave spectrum file not available, requires ncdf"
write (nu_diag,*) "wave spectrum file not available, requires cpp USE_NETCDF"
write (nu_diag,*) "wave spectrum file not available, using default profile"
call abort_ice (subname//'ERROR: wave_spec_file '//trim(wave_spec_file), &
file=__FILE__, line=__LINE__)
#endif
endif
endif
Expand Down
Loading

0 comments on commit 819eedd

Please sign in to comment.