knbarton / ners570-finalproject

Ners 570 Final Project
1 stars 1 forks source link

Set up unit testing #10

Open knbarton opened 3 years ago

knbarton commented 3 years ago

This issue is complete when there are unit tests for every function in the code.

littlewatkins commented 3 years ago

There are a couple unit test suites I found for Fortran:

pFUnit which is made for running Fortran code in parallel using MPI. It has limited OpenMP support. There's also this CIME package that uses pFUnit.

The other is FRUITPy which uses python to run the test scripts. It also has support for using MPI.

I'll test both on the basic tsunami model. My initial thought is to use the FRUITPy since we'll have python wrappers. But we'll see how it goes.

littlewatkins commented 3 years ago

Some instructions for how I installed FRUIT and FRUITPy: wget 'https://master.dl.sourceforge.net/project/fortranxunit/fruit_3.4.3/fruit_3.4.3.zip' sudo apt install unzip unzip fruit_3.4.3.zip sudo apt install ruby sudo gem install rake Install Guide Then pip install FRUITpy

littlewatkins commented 3 years ago

This is the framework that Prof. Kochunas uses for unit testing: Futility He says it's better to just copy these files rather than the whole repo: Header File and Fortran file

Here is a sample code

littlewatkins commented 3 years ago

I learned how to wrap Fortran subroutines into Python using numpy.f2py, and then I created a bash script which allows me to run tests using Pytest. F2PY quick tutorial

I'm not sure if this is exactly the most effective way of doing things, since F2PY can only wrap modules and subroutines (at least I think that's all it can do). But then again, if more of our code is just in modules and subroutines, that might be all we need.